setting.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <!--
  2. * @description: 标题属性设置面板
  3. * @Date: 2022-08-17 16:53:28
  4. * @Author: shiyi
  5. -->
  6. <template>
  7. <div class="bs-setting-wrap">
  8. <el-form
  9. ref="form"
  10. label-width="100px"
  11. label-position="left"
  12. :model="config"
  13. :rules="rules"
  14. class="bs-el-form"
  15. >
  16. <SettingTitle>标题</SettingTitle>
  17. <div class="lc-field-body">
  18. <el-form-item
  19. label="标题"
  20. label-width="100px"
  21. prop="title"
  22. >
  23. <el-input
  24. v-model="config.title"
  25. placeholder="请输入标题"
  26. clearable
  27. />
  28. </el-form-item>
  29. </div>
  30. <SettingTitle>位置</SettingTitle>
  31. <div class="lc-field-body">
  32. <PosWhSetting :config="config" />
  33. </div>
  34. <SettingTitle v-if="config.border">边框</SettingTitle>
  35. <div class="lc-field-body">
  36. <BorderSetting
  37. v-if="config.border"
  38. label-width="100px"
  39. :config="config.border"
  40. :bigTitle='config.title'
  41. />
  42. </div>
  43. <SettingTitle>基础</SettingTitle>
  44. <div class="lc-field-body">
  45. <el-form-item
  46. label="URL"
  47. label-width="100px"
  48. prop="customize.url"
  49. style="margin-bottom: 14px"
  50. >
  51. <el-upload
  52. class="bs-el-upload"
  53. :class="{ hide: fileList.length >= 1 }"
  54. :action="upLoadUrl"
  55. :data="fileUploadParam"
  56. :headers="headers"
  57. :accept="accept"
  58. :file-list="fileList"
  59. :auto-upload="true"
  60. :limit="1"
  61. list-type="picture-card"
  62. :on-success="handleUploadSuccess"
  63. :on-error="handleUploadError"
  64. :before-upload="beforeUpload"
  65. >
  66. <i
  67. slot="default"
  68. class="el-icon-plus"
  69. />
  70. <div
  71. slot="file"
  72. slot-scope="{ file }"
  73. >
  74. <img
  75. class="el-upload-list__item-thumbnail"
  76. :src="file.url"
  77. alt=""
  78. >
  79. <span class="el-upload-list__item-actions">
  80. <span
  81. class="el-upload-list__item-delete"
  82. @click="handleRemove(file)"
  83. >
  84. <i class="el-icon-delete" />
  85. </span>
  86. </span>
  87. </div>
  88. <el-input
  89. slot="tip"
  90. v-model="config.customize.url"
  91. class="upload-tip"
  92. placeholder="或输入URL地址"
  93. clearable
  94. />
  95. </el-upload>
  96. </el-form-item>
  97. <el-form-item
  98. label="不透明度"
  99. label-width="100px"
  100. >
  101. <el-input-number
  102. v-model="config.customize.opacity"
  103. class="bs-el-input-number"
  104. placeholder="请输入不透明度"
  105. :min="0.01"
  106. :max="1"
  107. :precision="2"
  108. :step="0.01"
  109. />
  110. </el-form-item>
  111. </div>
  112. </el-form>
  113. </div>
  114. </template>
  115. <script>
  116. import SettingTitle from 'data-room-ui/SettingTitle/index.vue'
  117. import BorderSetting from 'data-room-ui/BigScreenDesign/RightSetting/BorderSetting.vue'
  118. import PosWhSetting from 'data-room-ui/BigScreenDesign/RightSetting/PosWhSetting.vue'
  119. export default {
  120. name: 'PicSetting',
  121. components: {
  122. PosWhSetting,
  123. SettingTitle,
  124. BorderSetting
  125. },
  126. data () {
  127. return {
  128. upLoadUrl:
  129. window.BS_CONFIG?.httpConfigs?.baseURL + '/bigScreen/file/upload',
  130. fileUploadParam: {
  131. module: 'form'
  132. },
  133. headers: {
  134. ...window.BS_CONFIG?.httpConfigs?.headers
  135. },
  136. fileList: [],
  137. accept: 'image/*',
  138. hideUpload: false,
  139. rules: {
  140. 'customize.url': [
  141. // 地址校验
  142. {
  143. validator: (rule, value, callback) => {
  144. if (value) {
  145. const reg = /^(http|https):\/\/([\w.]+\/?)\S*/
  146. if (!reg.test(value)) {
  147. callback(new Error('请输入正确的URL地址'))
  148. } else {
  149. callback()
  150. }
  151. } else {
  152. callback()
  153. }
  154. },
  155. trigger: 'blur'
  156. }
  157. ]
  158. }
  159. }
  160. },
  161. computed: {
  162. config: {
  163. get () {
  164. return this.$store.state.bigScreen.activeItemConfig
  165. },
  166. set (val) {
  167. this.$store.state.bigScreen.activeItemConfig = val
  168. }
  169. }
  170. },
  171. watch: {
  172. 'config.customize.url': function (val) {
  173. if (val) {
  174. this.fileList = [
  175. {
  176. name: this.config.title,
  177. url: this.config.customize.url
  178. }
  179. ]
  180. } else {
  181. this.fileList = []
  182. }
  183. }
  184. },
  185. mounted () {
  186. if (this.config.customize.url) {
  187. this.fileList = [
  188. {
  189. name: this.config.title,
  190. url: this.config.customize.url
  191. }
  192. ]
  193. } else {
  194. this.fileList = []
  195. }
  196. },
  197. methods: {
  198. handleUploadSuccess (res) {
  199. if (res.code === 200) {
  200. this.config.customize.url = res.data.url
  201. this.fileList = [
  202. {
  203. name: this.config.title,
  204. url: this.config.customize.url
  205. }
  206. ]
  207. } else {
  208. this.$message.error(res.msg)
  209. this.fileList = []
  210. }
  211. },
  212. handleUploadError () {
  213. this.$message.error('上传失败')
  214. },
  215. handleRemove () {
  216. this.fileList = []
  217. this.config.customize.url = ''
  218. },
  219. beforeUpload (file) {
  220. const isLt2M = file.size / 1024 / 1024 < 2
  221. if (!isLt2M) {
  222. this.$message.error('上传图片大小不能超过 2MB!')
  223. }
  224. return isLt2M
  225. }
  226. }
  227. }
  228. </script>
  229. <style lang="scss" scoped>
  230. @import '../../assets/style/settingWrap.scss';
  231. .bs-slider {
  232. .el-input-number__decrease {
  233. background: var(--bs-el-background-1);
  234. border-right: 1px solid var(--bs-background-1);
  235. }
  236. .el-input-number__increase {
  237. background: var(--bs-el-background-1);
  238. border-left: 1px solid var(--bs-background-1);
  239. }
  240. }
  241. .bs-setting-wrap {
  242. padding-top: 16px;
  243. ::v-deep .hide .el-upload--picture-card {
  244. display: none !important;
  245. }
  246. ::v-deep .el-upload-list__item {
  247. transition: none !important;
  248. }
  249. ::v-deep .el-upload--picture-card {
  250. margin-bottom: 12px !important;
  251. }
  252. }
  253. .lc-field-body {
  254. padding: 12px 16px;
  255. }
  256. </style>