brand-edit.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <div class="pc-edit">
  3. <!-- 内容 -->
  4. <div class="content-wrap" v-show="diyStore.editTab == 'content'">
  5. <div class="edit-attr-item-wrap">
  6. <h3 class="mb-[10px]">品牌设置</h3>
  7. <el-form label-width="80px" class="px-[10px]">
  8. <el-form-item label="设置">
  9. <el-radio-group v-model="diyStore.editComponent.settings" fill="#409eff">
  10. <el-radio-button label="图片" :value="1" />
  11. <el-radio-button label="品牌" :value="2" />
  12. </el-radio-group>
  13. </el-form-item>
  14. </el-form>
  15. </div>
  16. <template v-if="diyStore.editComponent.settings == 1">
  17. <div class="edit-attr-item-wrap">
  18. <h3 class="mb-[10px]">图片设置</h3>
  19. <el-form label-width="80px" class="px-[10px]">
  20. <div class="edit-attr-box">
  21. <el-form-item label="图片上传">
  22. <div class="flex-row-start">
  23. <upload-image v-model="diyStore.editComponent.imageUrl" :limit="1" />
  24. <div class="flex-column-between images-bos">
  25. <div class="annotation3">(建议上传尺寸相同图片,推荐尺寸230*340)</div>
  26. <div class="flex-row-between images-box">
  27. <div>缩放模式</div>
  28. <div class="flex-row-start" @click="openImageType({ imgType: diyStore.editComponent.imgType }, 1)">
  29. <span style="margin-top: 2px" class="text-primary flex-1 cursor-pointer">{{
  30. diyStore.editComponent.imgType == 1 ? '拉伸' : diyStore.editComponent.imgType == 2 ? '缩放' : '填充'
  31. }}</span>
  32. <el-icon class="cursor-pointer">
  33. <ArrowRight />
  34. </el-icon>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </el-form-item>
  40. <el-form-item label="链接地址">
  41. <el-input v-model="diyStore.editComponent.url" placeholder="请输入链接地址" />
  42. </el-form-item>
  43. </div>
  44. </el-form>
  45. </div>
  46. </template>
  47. <template v-if="diyStore.editComponent.settings == 2">
  48. <div class="edit-attr-item-wrap">
  49. <div class="edit-attr-title flex-row-between">
  50. <div>
  51. <span>品牌设置</span>
  52. <span class="title2">鼠标拖拽可以改变顺序</span>
  53. </div>
  54. </div>
  55. <draggable v-model="diyStore.editComponent.brandList" item-key="id">
  56. <template #item="{ element, index }">
  57. <el-form label-width="90px" class="px-[10px]">
  58. <div class="edit-attr-box">
  59. <el-icon @click="onDel(index)" color="#F56C6C" size="18px" class="circleClose">
  60. <CircleCloseFilled />
  61. </el-icon>
  62. <el-form-item label="图片上传">
  63. <div class="flex-row-start">
  64. <upload-image v-model="element.imageUrl" :limit="1" />
  65. <div class="flex-column-between images-bos">
  66. <div class="annotation3">(建议上传尺寸相同图片,推荐尺寸150*150)</div>
  67. <div class="flex-row-between images-box">
  68. <div>缩放模式</div>
  69. <div class="flex-row-start" @click="openImageType(element, 2)">
  70. <span style="margin-top: 2px" class="text-primary flex-1 cursor-pointer">{{
  71. element.imgType == 1 ? '拉伸' : element.imgType == 2 ? '缩放' : '填充'
  72. }}</span>
  73. <el-icon class="cursor-pointer">
  74. <ArrowRight />
  75. </el-icon>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </el-form-item>
  81. <el-form-item label="品牌名称">
  82. <el-input v-model="element.title" placeholder="请输入品牌名称" :maxlength="10" show-word-limit />
  83. </el-form-item>
  84. <el-form-item label="副标题名称">
  85. <el-input v-model="element.subtitle" placeholder="请输入副标题内容" />
  86. </el-form-item>
  87. <el-form-item label="链接地址">
  88. <el-input v-model="element.url" placeholder="请输入链接地址" />
  89. </el-form-item>
  90. </div>
  91. </el-form>
  92. </template>
  93. </draggable>
  94. <el-button @click="onAdd" style="width: 100%; margin-top: 10px">新增品牌</el-button>
  95. </div>
  96. </template>
  97. </div>
  98. <!-- 样式 -->
  99. <div class="style-wrap" v-show="diyStore.editTab == 'style'">
  100. <div class="edit-attr-item-wrap">
  101. <h3 class="mb-[10px]">样式设置</h3>
  102. <el-form label-width="80px" class="px-[10px]">
  103. <el-form-item label="文字大小">
  104. <el-slider size="small" v-model="diyStore.editComponent.titleSize" show-input :min="1" :max="50" />
  105. </el-form-item>
  106. <el-form-item label="文字加粗">
  107. <el-radio-group size="small" v-model="diyStore.editComponent.titleWeight" fill="#409eff">
  108. <el-radio-button label="加粗" :value="'bold'" />
  109. <el-radio-button label="不加粗" :value="'normal'" />
  110. </el-radio-group>
  111. </el-form-item>
  112. <el-form-item label="文字颜色">
  113. <span class="mr-[10px]">{{ diyStore.editComponent.titleColor }}</span>
  114. <el-color-picker class="mr-[10px]" v-model="diyStore.editComponent.titleColor" />
  115. <el-button @click="diyStore.editComponent.titleColor = '#101828'" size="small">重置</el-button>
  116. </el-form-item>
  117. </el-form>
  118. </div>
  119. <div class="edit-attr-item-wrap">
  120. <h3 class="mb-[10px]">副标题样式</h3>
  121. <el-form label-width="80px" class="px-[10px]">
  122. <el-form-item label="文字大小">
  123. <el-slider size="small" v-model="diyStore.editComponent.subtitleSize" show-input :min="1" :max="50" />
  124. </el-form-item>
  125. <el-form-item label="文字颜色">
  126. <span class="mr-[10px]">{{ diyStore.editComponent.subtitleColor }}</span>
  127. <el-color-picker class="mr-[10px]" v-model="diyStore.editComponent.subtitleColor" />
  128. <el-button @click="diyStore.editComponent.subtitleColor = '#101828'" size="small">重置</el-button>
  129. </el-form-item>
  130. </el-form>
  131. </div>
  132. <div class="edit-attr-item-wrap">
  133. <h3 class="mb-[10px]">图片设置</h3>
  134. <el-form label-width="80px" class="px-[10px]">
  135. <el-form-item label="图片圆角">
  136. <el-slider size="small" v-model="diyStore.editComponent.imageRadius" show-input :min="0" :max="100" />
  137. </el-form-item>
  138. <el-form-item label="模块圆角">
  139. <el-slider size="small" v-model="diyStore.editComponent.boxRadius" show-input :min="0" :max="100" />
  140. </el-form-item>
  141. </el-form>
  142. </div>
  143. <!-- 组件样式 -->
  144. <slot name="style"></slot>
  145. </div>
  146. <ImagesForm ref="ImagesFormRef" @confirmCallBack="confirmCallBack"></ImagesForm>
  147. </div>
  148. </template>
  149. <script lang="ts" setup>
  150. import draggable from 'vuedraggable';
  151. import usePcdiyStore from '@/store/modules/pcdiy';
  152. import uploadImage from '@/components/upload-image/index.vue';
  153. import ImagesForm from '@/components/ImagesForm/index.vue';
  154. const diyStore = usePcdiyStore();
  155. const ImagesFormRef = ref();
  156. // 打开图片类型
  157. const openImageType = (element: any, type: any) => {
  158. const datas = JSON.parse(JSON.stringify(element));
  159. ImagesFormRef.value.onOpen(datas, type);
  160. };
  161. // 图片类型返回
  162. const confirmCallBack = (res: any, type: any) => {
  163. if (type == 1) {
  164. diyStore.editComponent.imgType = res.imgType;
  165. } else {
  166. diyStore.editComponent.brandList.forEach((item: any) => {
  167. if (item.id == res.id) {
  168. item.imgType = res.imgType;
  169. }
  170. });
  171. }
  172. };
  173. const onAdd = () => {
  174. diyStore.editComponent.brandList.push({
  175. imageUrl: '',
  176. title: '品牌名称',
  177. subtitle: '品牌介绍',
  178. url: '',
  179. imgType: 1,
  180. id: Date.now()
  181. });
  182. };
  183. const onDel = (index: any) => {
  184. diyStore.editComponent.brandList.splice(index, 1);
  185. };
  186. </script>
  187. <style lang="scss" scoped>
  188. .pc-edit {
  189. .edit-attr-item-wrap {
  190. border-top: 2px solid var(--el-color-info-light-8);
  191. padding-top: 20px;
  192. &:first-of-type {
  193. border-top: none;
  194. padding-top: 0;
  195. }
  196. .edit-attr-title {
  197. display: flex;
  198. .title2 {
  199. font-size: 12px;
  200. color: #666;
  201. margin-left: 6px;
  202. }
  203. }
  204. .edit-attr-box {
  205. padding: 18px 10px 0 10px;
  206. border: 1px solid #e5e6eb;
  207. border-radius: 4px;
  208. position: relative;
  209. margin-top: 18px;
  210. .images-bos {
  211. flex: 1;
  212. height: 98px;
  213. padding: 5px 0;
  214. }
  215. .images-box {
  216. font-size: 13px;
  217. color: #666;
  218. }
  219. .circleClose {
  220. position: absolute;
  221. top: -9px;
  222. right: -9px;
  223. cursor: pointer;
  224. }
  225. .annotation3 {
  226. font-size: 12px;
  227. color: #666;
  228. line-height: 14px;
  229. }
  230. }
  231. }
  232. :deep(.el-form-item__label) {
  233. font-weight: 400;
  234. }
  235. :deep(.file-selector) {
  236. display: none;
  237. }
  238. }
  239. </style>