From 6e010cb1484d7c25c8f2a436600ca1c78d0672df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Thu, 29 Aug 2024 00:34:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E5=AE=B9=E3=80=81=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=B7=BB=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/cms/design/model/index.ts | 5 +- .../cms/navigation/components/design-edit.vue | 52 +++++++++++-------- src/views/cms/navigation/index.vue | 29 +++++------ 3 files changed, 49 insertions(+), 37 deletions(-) diff --git a/src/api/cms/design/model/index.ts b/src/api/cms/design/model/index.ts index ac97be8..44e20a3 100644 --- a/src/api/cms/design/model/index.ts +++ b/src/api/cms/design/model/index.ts @@ -14,10 +14,13 @@ export interface Design { content?: string; // 类型 type?: string; + categoryId?: number; // 宽 width?: string; // 高 height?: string; + // 页面样式 + styles?: string; // 附件 images?: string; // 用户ID @@ -50,5 +53,5 @@ export interface DesignParam extends PageParam { name?: number; type?: number; userId?: number; - navigationId?: number; + categoryId?: number; } diff --git a/src/views/cms/navigation/components/design-edit.vue b/src/views/cms/navigation/components/design-edit.vue index cbd4f81..4ef59d7 100644 --- a/src/views/cms/navigation/components/design-edit.vue +++ b/src/views/cms/navigation/components/design-edit.vue @@ -5,7 +5,7 @@ :visible="visible" :maskClosable="false" :maxable="true" - :title="isUpdate ? '页面设置' : '页面设置'" + :title="isUpdate ? '编辑内容' : '添加内容'" :body-style="{ paddingBottom: '28px' }" @update:visible="updateVisible" @ok="save" @@ -99,7 +99,7 @@ import { ref, reactive, watch } from 'vue'; import { message } from 'ant-design-vue'; import { uuid} from 'ele-admin-pro'; -import { addDesign, updateDesign } from '@/api/cms/design'; +import { addDesign, pageDesign, updateDesign } from "@/api/cms/design"; import { Design } from '@/api/cms/design/model'; import { useThemeStore } from '@/store/modules/theme'; import { storeToRefs } from 'pinia'; @@ -110,6 +110,7 @@ import TinymceEditor from "@/components/TinymceEditor/index.vue"; import useFormData from "@/utils/use-form-data"; import {removeSiteInfoCache} from "@/api/cms/website"; import {FileRecord} from "@/api/system/file/model"; +import category from "@/views/cms/category/index.vue"; // 是否是修改 const isUpdate = ref(false); @@ -153,6 +154,7 @@ const { form, resetFields, assignFields } = useFormData({ content: '', buyUrl: '', type: '', + categoryId: undefined, styles: '', status: 0, comments: '', @@ -337,7 +339,7 @@ const save = () => { loading.value = true; const formData = { ...form, - navigationId: props.categoryId, + categoryId: props.categoryId, content: content.value }; const saveOrUpdate = isUpdate.value ? updateDesign : addDesign; @@ -362,30 +364,38 @@ watch( () => props.visible, (visible) => { if (visible) { - content.value = '' - images.value = [] - if (props.data) { - assignFields(props.data); - if(props.data.content){ - content.value = props.data.content - } - if(props.data.photo){ - images.value.push({ - uid: uuid(), - url: props.data.photo, - status: 'done' - }) - } - isUpdate.value = !!props.data.pageId; - } else { - isUpdate.value = false; + // 查询页面设计元素 + if(props.categoryId){ content.value = ''; - resetFields(); + images.value = [] + console.log(props.categoryId); + pageDesign({categoryId: props.categoryId,limit: 1}).then(res => { + const design = res?.list[0]; + if(design){ + assignFields(design); + if(design?.content){ + content.value = design.content + } + if(design.photo){ + images.value.push({ + uid: uuid(), + url: design.photo, + status: 'done' + }) + } + isUpdate.value = true; + }else { + isUpdate.value = false; + content.value = ''; + resetFields(); + } + }) } } else { resetFields(); formRef.value?.clearValidate(); } + }, { immediate: true } ); diff --git a/src/views/cms/navigation/index.vue b/src/views/cms/navigation/index.vue index 34e0967..b021a71 100644 --- a/src/views/cms/navigation/index.vue +++ b/src/views/cms/navigation/index.vue @@ -112,13 +112,18 @@