From 9291e17c7fd7054751e4bf026a9ca72594d55487 Mon Sep 17 00:00:00 2001 From: ray <1490493387@qq.com> Date: Sat, 16 Nov 2024 21:54:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E9=83=A8=E9=97=A8=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=92=8C=E7=BC=96=E8=BE=91=E9=A1=B6=E7=BA=A7=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E5=9B=9E=E6=98=BE=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/system/dept.ts | 6 ++-- src/views/system/dept/index.vue | 54 ++++++++++++++------------------- 2 files changed, 26 insertions(+), 34 deletions(-) diff --git a/src/api/system/dept.ts b/src/api/system/dept.ts index ea0d2fa9..e3e7530f 100644 --- a/src/api/system/dept.ts +++ b/src/api/system/dept.ts @@ -59,7 +59,7 @@ const DeptAPI = { * @param data 部门表单数据 * @returns 请求结果 */ - update(id: number, data: DeptForm) { + update(id: string, data: DeptForm) { return request({ url: `${DEPT_BASE_URL}/${id}`, method: "put", @@ -116,13 +116,13 @@ export interface DeptVO { /** 部门表单类型 */ export interface DeptForm { /** 部门ID(新增不填) */ - id?: number; + id?: string; /** 部门名称 */ name?: string; /** 部门编号 */ code?: string; /** 父部门ID */ - parentId: number; + parentId: string; /** 排序 */ sort?: number; /** 状态(1:启用;0:禁用) */ diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index f53def24..d8594f1d 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -11,12 +11,7 @@ - + @@ -132,12 +127,7 @@ width="600px" @closed="handleCloseDialog" > - + - 正常 - 禁用 + 正常 + 禁用 @@ -205,20 +195,18 @@ const deptOptions = ref(); const formData = reactive({ status: 1, - parentId: 0, + parentId: "0", sort: 1, }); const rules = reactive({ - parentId: [ - { required: true, message: "上级部门不能为空", trigger: "change" }, - ], + parentId: [{ required: true, message: "上级部门不能为空", trigger: "change" }], name: [{ required: true, message: "部门名称不能为空", trigger: "blur" }], code: [{ required: true, message: "部门编号不能为空", trigger: "blur" }], sort: [{ required: true, message: "显示排序不能为空", trigger: "blur" }], }); -/** 查询部门 */ +// 查询部门 function handleQuery() { loading.value = true; DeptAPI.getList(queryParams).then((data) => { @@ -227,13 +215,13 @@ function handleQuery() { }); } -/** 重置查询 */ +// 重置查询 function handleResetQuery() { queryFormRef.value.resetFields(); handleQuery(); } -/** 行复选框选中记录选中ID集合 */ +// 行复选框选中记录选中ID集合 function handleSelectionChange(selection: any) { ids.value = selection.map((item: any) => item.id); } @@ -244,12 +232,12 @@ function handleSelectionChange(selection: any) { * @param parentId 父部门ID * @param deptId 部门ID */ -async function handleOpenDialog(parentId?: number, deptId?: number) { +async function handleOpenDialog(parentId?: string, deptId?: number) { // 加载部门下拉数据 const data = await DeptAPI.getOptions(); deptOptions.value = [ { - value: 0, + value: "0", label: "顶级部门", children: data, }, @@ -263,11 +251,11 @@ async function handleOpenDialog(parentId?: number, deptId?: number) { }); } else { dialog.title = "新增部门"; - formData.parentId = parentId ?? 0; + formData.parentId = parentId || "0"; } } -/** 提交部门表单 */ +// 提交部门表单 function handleSubmit() { deptFormRef.value.validate((valid: any) => { if (valid) { @@ -294,7 +282,7 @@ function handleSubmit() { }); } -/** 删除部门 */ +// 删除部门 function handleDelete(deptId?: number) { const deptIds = [deptId || ids.value].join(","); @@ -323,19 +311,23 @@ function handleDelete(deptId?: number) { ); } -/** 关闭弹窗 */ -function handleCloseDialog() { - dialog.visible = false; - +// 重置表单 +function resetForm() { deptFormRef.value.resetFields(); deptFormRef.value.clearValidate(); formData.id = undefined; - formData.parentId = 0; + formData.parentId = "0"; formData.status = 1; formData.sort = 1; } +// 关闭弹窗 +function handleCloseDialog() { + dialog.visible = false; + resetForm(); +} + onMounted(() => { handleQuery(); });