setting.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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>基础</SettingTitle>
  35. <div class="lc-field-body">
  36. <el-form-item
  37. label="URL"
  38. label-width="100px"
  39. prop="customize.url"
  40. style="margin-bottom: 14px"
  41. >
  42. <el-upload
  43. class="bs-el-upload"
  44. :class="{ hide: fileList.length >= 1 }"
  45. :action="upLoadUrl"
  46. :data="fileUploadParam"
  47. :headers="headers"
  48. :accept="accept"
  49. :file-list="fileList"
  50. :auto-upload="true"
  51. :limit="1"
  52. list-type="picture-card"
  53. :on-success="handleUploadSuccess"
  54. :before-upload="beforeUpload"
  55. >
  56. <i
  57. slot="default"
  58. class="el-icon-plus"
  59. />
  60. <div
  61. slot="file"
  62. slot-scope="{ file }"
  63. >
  64. <img
  65. class="el-upload-list__item-thumbnail"
  66. :src="file.url"
  67. alt=""
  68. >
  69. <span class="el-upload-list__item-actions">
  70. <span
  71. class="el-upload-list__item-delete"
  72. @click="handleRemove(file)"
  73. >
  74. <i class="el-icon-delete" />
  75. </span>
  76. </span>
  77. </div>
  78. <el-input
  79. slot="tip"
  80. v-model="config.customize.url"
  81. class="upload-tip"
  82. placeholder="或输入URL地址"
  83. clearable
  84. @change="handleUrlChange"
  85. />
  86. </el-upload>
  87. </el-form-item>
  88. <el-form-item
  89. label="不透明度"
  90. label-width="100px"
  91. >
  92. <el-input-number
  93. v-model="config.customize.opacity"
  94. class="bs-el-input-number db-el-input-number"
  95. placeholder="请输入不透明度"
  96. :min="0.01"
  97. :max="1"
  98. :precision="2"
  99. :step="0.01"
  100. />
  101. </el-form-item>
  102. <!-- <el-form-item-->
  103. <!-- label="圆角"-->
  104. <!-- label-width="100px"-->
  105. <!-- >-->
  106. <!-- <el-input-number-->
  107. <!-- v-model="config.customize.radius"-->
  108. <!-- class="bs-el-input-number"-->
  109. <!-- placeholder="请输入圆角大小"-->
  110. <!-- :min="0"-->
  111. <!-- />-->
  112. <!-- </el-form-item>-->
  113. </div>
  114. </el-form>
  115. </div>
  116. </template>
  117. <script>
  118. import SettingTitle from 'packages/SettingTitle/index.vue'
  119. import PosWhSetting from 'packages/BigScreenDesign/RightSetting/PosWhSetting.vue'
  120. export default {
  121. name: 'PicSetting',
  122. components: {
  123. PosWhSetting,
  124. SettingTitle
  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. { required: true, message: '请输入URL地址', trigger: 'blur' },
  142. // 地址校验
  143. {
  144. validator: (rule, value, callback) => {
  145. if (value) {
  146. const reg = /^(http|https):\/\/([\w.]+\/?)\S*/
  147. if (!reg.test(value)) {
  148. callback(new Error('请输入正确的URL地址'))
  149. } else {
  150. callback()
  151. }
  152. } else {
  153. callback()
  154. }
  155. },
  156. trigger: 'blur'
  157. }
  158. ]
  159. }
  160. }
  161. },
  162. computed: {
  163. config: {
  164. get () {
  165. return this.$store.state.bigScreen.activeItemConfig
  166. },
  167. set (val) {
  168. this.$store.state.bigScreen.activeItemConfig = val
  169. }
  170. }
  171. },
  172. watch: {},
  173. mounted () {
  174. if (this.config.customize.url) {
  175. this.fileList = [
  176. {
  177. name: this.config.title,
  178. url: this.config.customize.url
  179. }
  180. ]
  181. } else {
  182. this.fileList = []
  183. }
  184. },
  185. methods: {
  186. handleUploadSuccess (res) {
  187. if (res.code === 200) {
  188. this.config.customize.url = res.data.url
  189. this.fileList = [
  190. {
  191. name: this.config.title,
  192. url: this.config.customize.url
  193. }
  194. ]
  195. } else {
  196. this.$message.error(res.msg)
  197. }
  198. },
  199. handleRemove () {
  200. this.fileList = []
  201. this.config.customize.url = ''
  202. },
  203. beforeUpload (file) {
  204. const isLt2M = file.size / 1024 / 1024 < 2
  205. if (!isLt2M) {
  206. this.$message.error('上传图片大小不能超过 2MB!')
  207. }
  208. return isLt2M
  209. },
  210. handleUrlChange (val) {
  211. this.config.customize.url = val
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. @import '../../assets/style/settingWrap.scss';
  218. .bs-slider {
  219. .el-input-number__decrease {
  220. background: var(--bs-el-background-1);
  221. border-right: 1px solid var(--bs-background-1);
  222. }
  223. .el-input-number__increase {
  224. background: var(--bs-el-background-1);
  225. border-left: 1px solid var(--bs-background-1);
  226. }
  227. }
  228. .bs-setting-wrap {
  229. padding-top: 16px;
  230. /deep/ .hide .el-upload--picture-card {
  231. display: none;
  232. }
  233. /deep/.el-upload-list__item {
  234. transition: none !important;
  235. }
  236. /deep/ .el-upload--picture-card {
  237. margin-bottom: 12px;
  238. }
  239. }
  240. .lc-field-body {
  241. padding: 12px 16px;
  242. }
  243. </style>