From f801f4fb11ff8ca08417a9ddf0231fb570fa26e3 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期一, 24 七月 2023 16:47:51 +0800 Subject: [PATCH] fix 修复 固定页面header穿模问题 --- src/views/system/notice/index.vue | 134 +++++++++++++++++++++----------------------- 1 files changed, 64 insertions(+), 70 deletions(-) diff --git a/src/views/system/notice/index.vue b/src/views/system/notice/index.vue index d075f5d..0c41ce1 100644 --- a/src/views/system/notice/index.vue +++ b/src/views/system/notice/index.vue @@ -121,9 +121,7 @@ <script setup name="Notice" lang="ts"> import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice"; -import { ComponentInternalInstance } from "vue"; import { NoticeForm, NoticeQuery, NoticeVO } from "@/api/system/notice/types"; -import { ElForm } from 'element-plus'; const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { sys_notice_status, sys_notice_type } = toRefs<any>(proxy?.useDict("sys_notice_status", "sys_notice_type")); @@ -136,116 +134,112 @@ const multiple = ref(true); const total = ref(0); -const queryFormRef = ref(ElForm); -const noticeFormRef = ref(ElForm); +const queryFormRef = ref<ElFormInstance>(); +const noticeFormRef = ref<ElFormInstance>(); const dialog = reactive<DialogOption>({ - visible: false, - title: '' + visible: false, + title: '' }); const initFormData: NoticeForm = { - noticeId: undefined, - noticeTitle: '', - noticeType: '', - noticeContent: '', - status: "0", - remark: '', - createByName: '' + noticeId: undefined, + noticeTitle: '', + noticeType: '', + noticeContent: '', + status: "0", + remark: '', + createByName: '' } const data = reactive<PageData<NoticeForm, NoticeQuery>>({ - form: { ...initFormData }, - queryParams: { - pageNum: 1, - pageSize: 10, - noticeTitle: '', - createByName: '', - status: '', - noticeType: '' - }, - rules: { - noticeTitle: [{ required: true, message: "鍏憡鏍囬涓嶈兘涓虹┖", trigger: "blur" }], - noticeType: [{ required: true, message: "鍏憡绫诲瀷涓嶈兘涓虹┖", trigger: "change" }] - }, + form: { ...initFormData }, + queryParams: { + pageNum: 1, + pageSize: 10, + noticeTitle: '', + createByName: '', + status: '', + noticeType: '' + }, + rules: { + noticeTitle: [{ required: true, message: "鍏憡鏍囬涓嶈兘涓虹┖", trigger: "blur" }], + noticeType: [{ required: true, message: "鍏憡绫诲瀷涓嶈兘涓虹┖", trigger: "change" }] + }, }); const { queryParams, form, rules } = toRefs(data); /** 鏌ヨ鍏憡鍒楄〃 */ const getList = async () => { - loading.value = true; - const res = await listNotice(queryParams.value); - noticeList.value = res.rows; - total.value = res.total; - loading.value = false; + loading.value = true; + const res = await listNotice(queryParams.value); + noticeList.value = res.rows; + total.value = res.total; + loading.value = false; } /** 鍙栨秷鎸夐挳 */ const cancel = () => { - reset(); - dialog.visible = false; + reset(); + dialog.visible = false; } /** 琛ㄥ崟閲嶇疆 */ const reset = () => { - form.value = { ...initFormData }; - noticeFormRef.value.resetFields(); + form.value = { ...initFormData }; + noticeFormRef.value?.resetFields(); } /** 鎼滅储鎸夐挳鎿嶄綔 */ const handleQuery = () => { - queryParams.value.pageNum = 1; - getList(); + queryParams.value.pageNum = 1; + getList(); } /** 閲嶇疆鎸夐挳鎿嶄綔 */ const resetQuery = () => { - queryFormRef.value.resetFields(); - handleQuery(); + queryFormRef.value?.resetFields(); + handleQuery(); } /** 澶氶�夋閫変腑鏁版嵁 */ const handleSelectionChange = (selection: NoticeVO[]) => { - ids.value = selection.map(item => item.noticeId); - single.value = selection.length != 1; - multiple.value = !selection.length; + ids.value = selection.map(item => item.noticeId); + single.value = selection.length != 1; + multiple.value = !selection.length; } /** 鏂板鎸夐挳鎿嶄綔 */ const handleAdd = () => { - dialog.visible = true; - dialog.title = "娣诲姞鍏憡"; - nextTick(() => { - reset(); - }) + reset(); + dialog.visible = true; + dialog.title = "娣诲姞鍏憡"; } /**淇敼鎸夐挳鎿嶄綔 */ -const handleUpdate = (row?: NoticeVO) => { - dialog.visible = true; - dialog.title = "淇敼鍏憡"; - nextTick(async () => { - const noticeId = row?.noticeId || ids.value[0]; - reset(); - const { data } = await getNotice(noticeId); - form.value = data; - }) +const handleUpdate = async (row?: NoticeVO) => { + reset(); + const noticeId = row?.noticeId || ids.value[0]; + const { data } = await getNotice(noticeId); + Object.assign(form.value, data); + dialog.visible = true; + dialog.title = "淇敼鍏憡"; } /** 鎻愪氦鎸夐挳 */ const submitForm = () => { - noticeFormRef.value.validate(async (valid: boolean) => { - if (valid) { - form.value.noticeId ? await updateNotice(form.value) : await addNotice(form.value); - proxy?.$modal.msgSuccess("淇敼鎴愬姛"); - dialog.visible = false; - getList(); - } - }); + noticeFormRef.value?.validate(async (valid: boolean) => { + if (valid) { + form.value.noticeId ? await updateNotice(form.value) : await addNotice(form.value); + proxy?.$modal.msgSuccess("淇敼鎴愬姛"); + dialog.visible = false; + await getList(); + } + }); } /** 鍒犻櫎鎸夐挳鎿嶄綔 */ const handleDelete = async (row?: NoticeVO) => { - const noticeIds = row?.noticeId || ids.value - await proxy?.$modal.confirm('鏄惁纭鍒犻櫎鍏憡缂栧彿涓�"' + noticeIds + '"鐨勬暟鎹」锛�'); - await delNotice(noticeIds); - getList(); - proxy?.$modal.msgSuccess("鍒犻櫎鎴愬姛"); + const noticeIds = row?.noticeId || ids.value + await proxy?.$modal.confirm('鏄惁纭鍒犻櫎鍏憡缂栧彿涓�"' + noticeIds + '"鐨勬暟鎹」锛�'); + await delNotice(noticeIds); + await getList(); + proxy?.$modal.msgSuccess("鍒犻櫎鎴愬姛"); } onMounted(() => { - getList(); + getList(); }) </script> -- Gitblit v1.9.3