From ba241ab43751d0da307a364f394c44ff98ab1a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=B2=E4=B9=88=E4=BA=86?= Date: Mon, 11 Mar 2024 09:55:42 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E9=97=A8=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/user-boot/dept.ts | 16 +++++++++++++++ src/views/auth/department/index.vue | 32 +++++++++++++++++++++-------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/api/user-boot/dept.ts b/src/api/user-boot/dept.ts index d6476f81..73376097 100644 --- a/src/api/user-boot/dept.ts +++ b/src/api/user-boot/dept.ts @@ -29,3 +29,19 @@ export function updateDept(data: any) { data: data }) } + +export function deleteDept(data:any) { + return request({ + url: '/user-boot/dept/delete', + method: 'post', + data: data + }) +} + +export function selectPid(data:any) { + return request({ + url: '/user-boot/dept/selectPid', + method: 'post', + data: data + }) +} \ No newline at end of file diff --git a/src/views/auth/department/index.vue b/src/views/auth/department/index.vue index 191ac510..72ec6d4e 100644 --- a/src/views/auth/department/index.vue +++ b/src/views/auth/department/index.vue @@ -22,6 +22,8 @@ import TableStore from '@/utils/tableStore' import Table from '@/components/table/index.vue' import PopupForm from './popupForm.vue' import PopupPoint from './popupPoint.vue' +import { deleteDept, selectPid } from '@/api/user-boot/dept' +import { ElMessage, ElMessageBox } from 'element-plus' defineOptions({ name: 'auth/department' @@ -98,7 +100,7 @@ const tableStore = new TableStore({ render: 'basicButton', click: row => { popupFormRef.value.open('编辑部门', { - ...row, + ...row }) } }, @@ -107,14 +109,26 @@ const tableStore = new TableStore({ text: '删除', type: 'danger', icon: 'el-icon-Delete', - render: 'confirmButton', - popconfirm: { - confirmButtonText: '确认', - cancelButtonText: '取消', - confirmButtonType: 'danger', - title: '确定删除该菜单吗?' - }, - click: row => {} + render: 'basicButton', + click: (row: any) => { + if (row.children.length > 0) { + ElMessageBox.confirm('该部门有子部门,是否确认删除', '提示', { + confirmButtonText: '确认删除', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + deleteDept([row.id]).then(response => { + ElMessage.success('删除成功') + tableStore.index() + }) + }) + } else { + deleteDept([row.id]).then(response => { + ElMessage.success('删除成功') + tableStore.index() + }) + } + } }, { name: 'edit',