From 7485ff1a870e477ac799d5a05208b05386126c9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Tue, 23 Jul 2024 10:27:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/cms/mpPages/model/index.ts | 4 + .../cms/mpField/components/mp-field-edit.vue | 35 +++--- src/views/cms/mpField/index.vue | 12 +++ .../cms/mpPages/components/mpPagesEdit.vue | 102 +++++++++++++++--- src/views/cms/mpPages/index.vue | 3 +- 5 files changed, 129 insertions(+), 27 deletions(-) diff --git a/src/api/cms/mpPages/model/index.ts b/src/api/cms/mpPages/model/index.ts index 0a0393c..ac06f00 100644 --- a/src/api/cms/mpPages/model/index.ts +++ b/src/api/cms/mpPages/model/index.ts @@ -18,6 +18,10 @@ export interface MpPages { subpackage?: string; // 图标 icon?: string; + // (优先级高于图标) + iconPath?: string; + // (优先级高于图标) + selectedIconPath?: string; // 排序(数字越小越靠前) sortNumber?: number; // 备注 diff --git a/src/views/cms/mpField/components/mp-field-edit.vue b/src/views/cms/mpField/components/mp-field-edit.vue index 792c7f0..8622929 100644 --- a/src/views/cms/mpField/components/mp-field-edit.vue +++ b/src/views/cms/mpField/components/mp-field-edit.vue @@ -27,11 +27,24 @@ - - + + + + @@ -42,13 +55,11 @@ v-model:value="form.sortNumber" /> - - + diff --git a/src/views/cms/mpField/index.vue b/src/views/cms/mpField/index.vue index fbdd64a..a95cd58 100644 --- a/src/views/cms/mpField/index.vue +++ b/src/views/cms/mpField/index.vue @@ -52,6 +52,18 @@ + @@ -38,21 +39,46 @@ dict-code="mpPackage" :placeholder="`选择分包`" style="width: 200px" + :disabled="form.subpackage === 'MainPackage'" v-model:value="form.subpackage" /> - - + + + + + + + + + - - - + + + import { ref, reactive, watch } from 'vue'; import { Form, message } from 'ant-design-vue'; - import { assignObject } from 'ele-admin-pro'; + import { assignObject, uuid } from 'ele-admin-pro'; import { addMpPages, updateMpPages } from '@/api/cms/mpPages'; import { MpPages } from '@/api/cms/mpPages/model'; import { useThemeStore } from '@/store/modules/theme'; import { storeToRefs } from 'pinia'; import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types'; import { FormInstance } from 'ant-design-vue/es/form'; + import { FileRecord } from '@/api/system/file/model'; // 是否是修改 const isUpdate = ref(false); @@ -110,7 +137,8 @@ const maxable = ref(true); // 表格选中数据 const formRef = ref(null); - const images = ref([]); + const iconPath = ref([]); + const selectedIconPath = ref([]); // 用户信息 const form = reactive({ @@ -120,6 +148,9 @@ path: undefined, home: undefined, subpackage: undefined, + icon: undefined, + iconPath: '', + selectedIconPath: '', sortNumber: 100, comments: undefined, status: undefined @@ -150,6 +181,34 @@ ] }); + const chooseFile = (data: FileRecord) => { + iconPath.value.push({ + uid: data.id, + url: data.downloadUrl, + status: 'done' + }); + form.iconPath = data.url; + }; + + const onDeleteItem = (index: number) => { + iconPath.value.splice(index, 1); + form.iconPath = ''; + }; + + const chooseFile2 = (data: FileRecord) => { + selectedIconPath.value.push({ + uid: data.id, + url: data.downloadUrl, + status: 'done' + }); + form.selectedIconPath = data.url; + }; + + const onDeleteItem2 = (index: number) => { + selectedIconPath.value.splice(index, 1); + form.selectedIconPath = ''; + }; + const { resetFields } = useForm(form, rules); /* 保存编辑 */ @@ -184,9 +243,24 @@ () => props.visible, (visible) => { if (visible) { - images.value = []; + iconPath.value = []; + selectedIconPath.value = []; if (props.data) { assignObject(form, props.data); + if (props.data.iconPath) { + iconPath.value.push({ + uid: uuid(), + url: props.data.iconPath, + status: 'done' + }); + } + if (props.data.selectedIconPath) { + selectedIconPath.value.push({ + uid: uuid(), + url: props.data.selectedIconPath, + status: 'done' + }); + } isUpdate.value = true; } else { isUpdate.value = false; diff --git a/src/views/cms/mpPages/index.vue b/src/views/cms/mpPages/index.vue index 93498fb..4ee73ea 100644 --- a/src/views/cms/mpPages/index.vue +++ b/src/views/cms/mpPages/index.vue @@ -22,7 +22,8 @@