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 @@