navigation-edit.vue 8.0 KB

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