From 6af68085ff6615e1ec3a5dd18c761250800d6fca Mon Sep 17 00:00:00 2001 From: LiuHao <liuhaoai545@gmail.com> Date: 星期二, 06 六月 2023 22:23:43 +0800 Subject: [PATCH] update 修改页面代码 去除ele的引入以及vue的类型声明 --- src/views/system/dept/index.vue | 46 ++++++++++++++++++++++++---------------------- 1 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index 4e7750d..7daac8b 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -132,9 +132,7 @@ <script setup name="Dept" lang="ts"> import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept" -import { ComponentInternalInstance } from 'vue'; import { DeptForm, DeptQuery, DeptVO } from "@/api/system/dept/types"; -import { ElTable, ElForm } from "element-plus"; interface DeptOptionsType { deptId: number | string; @@ -158,9 +156,9 @@ title: '' }); -const deptTableRef = ref(ElTable); -const queryFormRef = ref(ElForm); -const deptFormRef = ref(ElForm); +const deptTableRef = ref<ElTableInstance>(); +const queryFormRef = ref<ElFormInstance>(); +const deptFormRef = ref<ElFormInstance>(); const initFormData: DeptForm = { deptId: undefined, @@ -209,7 +207,7 @@ /** 琛ㄥ崟閲嶇疆 */ const reset = () => { form.value = {...initFormData}; - deptFormRef.value.resetFields(); + deptFormRef.value?.resetFields(); } /** 鎼滅储鎸夐挳鎿嶄綔 */ @@ -218,7 +216,7 @@ } /** 閲嶇疆鎸夐挳鎿嶄綔 */ const resetQuery = () => { - queryFormRef.value.resetFields(); + queryFormRef.value?.resetFields(); handleQuery() } /** 鏂板鎸夐挳鎿嶄綔 */ @@ -246,7 +244,7 @@ /** 灞曞紑/鎶樺彔鎵�鏈� */ const toggleExpandAll = (data: DeptVO[], status: boolean) => { data.forEach((item) => { - deptTableRef.value.toggleRowExpansion(item, status) + deptTableRef.value?.toggleRowExpansion(item, status) if(item.children && item.children.length > 0) toggleExpandAll(item.children, status) }) } @@ -256,28 +254,32 @@ const res = await getDept(row.deptId); dialog.visible = true; dialog.title = "淇敼閮ㄩ棬"; - nextTick(async () => { - reset(); - form.value = res.data - const response = await listDeptExcludeChild(row.deptId); - const data = proxy?.handleTree<DeptOptionsType>(response.data, "deptId") - if (data) { - deptOptions.value = data; - if (data.length === 0) { - const noResultsOptions: DeptOptionsType = { deptId: res.data.parentId, deptName: res.data.parentName, children: [] }; - deptOptions.value.push(noResultsOptions); - } + await nextTick(async () => { + reset(); + form.value = res.data + const response = await listDeptExcludeChild(row.deptId); + const data = proxy?.handleTree < DeptOptionsType > (response.data, "deptId") + if (data) { + deptOptions.value = data; + if (data.length === 0) { + const noResultsOptions: DeptOptionsType = { + deptId: res.data.parentId, + deptName: res.data.parentName, + children: [] + }; + deptOptions.value.push(noResultsOptions); } + } }) } /** 鎻愪氦鎸夐挳 */ const submitForm = () => { - deptFormRef.value.validate(async (valid: boolean) => { + deptFormRef.value?.validate(async (valid: boolean) => { if (valid) { form.value.deptId ? await updateDept(form.value) : await addDept(form.value); proxy?.$modal.msgSuccess("鎿嶄綔鎴愬姛"); dialog.visible = false; - getList(); + await getList(); } }) } @@ -285,7 +287,7 @@ const handleDelete = async (row: DeptVO) => { await proxy?.$modal.confirm('鏄惁纭鍒犻櫎鍚嶇О涓�"' + row.deptName + '"鐨勬暟鎹」?'); await delDept(row.deptId); - getList(); + await getList(); proxy?.$modal.msgSuccess("鍒犻櫎鎴愬姛"); } -- Gitblit v1.9.3