fix: 批量删除问题修复
Former-commit-id: 81be6da082b3eed89104b77f53a34ae2a2e7f60b
This commit is contained in:
@@ -20,7 +20,7 @@ const queryFormRef = ref(ElForm);
|
|||||||
const deptFormRef = ref(ElForm);
|
const deptFormRef = ref(ElForm);
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
let ids = reactive([]);
|
const ids = ref<number[]>([]);
|
||||||
const dialog = reactive<DialogOption>({
|
const dialog = reactive<DialogOption>({
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
@@ -65,7 +65,7 @@ function resetQuery() {
|
|||||||
* 行复选框选中记录选中ID集合
|
* 行复选框选中记录选中ID集合
|
||||||
*/
|
*/
|
||||||
function handleSelectionChange(selection: any) {
|
function handleSelectionChange(selection: any) {
|
||||||
ids = selection.map((item: any) => item.id);
|
ids.value = selection.map((item: any) => item.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,10 +133,11 @@ function handleSubmit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除部门
|
||||||
*/
|
*/
|
||||||
function handleDelete(row: any) {
|
function handleDelete(deptId?: number) {
|
||||||
const deptIds = [row.id || ids].join(',');
|
const deptIds = [deptId || ids.value].join(',');
|
||||||
|
|
||||||
if (!deptIds) {
|
if (!deptIds) {
|
||||||
ElMessage.warning('请勾选删除项');
|
ElMessage.warning('请勾选删除项');
|
||||||
return;
|
return;
|
||||||
@@ -146,18 +147,12 @@ function handleDelete(row: any) {
|
|||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
})
|
}).then(() => {
|
||||||
.then(() => {
|
deleteDept(deptIds).then(() => {
|
||||||
deleteDept(deptIds)
|
|
||||||
.then(() => {
|
|
||||||
handleQuery();
|
|
||||||
ElMessage.success('删除成功');
|
ElMessage.success('删除成功');
|
||||||
})
|
resetQuery();
|
||||||
.catch(() => {
|
});
|
||||||
ElMessage.error('删除失败');
|
|
||||||
});
|
});
|
||||||
})
|
|
||||||
.catch(() => ElMessage.warning('已取消删除'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -218,14 +213,13 @@ onMounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-card>
|
<el-card>
|
||||||
<!--toolbar-->
|
|
||||||
<template #header>
|
<template #header>
|
||||||
<el-button type="success" @click="openDialog(0, undefined)"
|
<el-button type="success" @click="openDialog(0, undefined)"
|
||||||
><i-ep-plus />新增</el-button
|
><i-ep-plus />新增</el-button
|
||||||
>
|
>
|
||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="handleDelete"
|
@click="handleDelete()"
|
||||||
:disabled="ids.length === 0"
|
:disabled="ids.length === 0"
|
||||||
><i-ep-delete />删除
|
><i-ep-delete />删除
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|||||||
@@ -162,13 +162,18 @@ function resetForm() {
|
|||||||
/**
|
/**
|
||||||
* 删除字典
|
* 删除字典
|
||||||
*/
|
*/
|
||||||
function handleDelete(dictId: number) {
|
function handleDelete(dictId?: number) {
|
||||||
|
const dictIds = [dictId || ids.value].join(',');
|
||||||
|
if (!dictIds) {
|
||||||
|
ElMessage.warning('请勾选删除项');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ElMessageBox.confirm('确认删除已选中的数据项?', '警告', {
|
ElMessageBox.confirm('确认删除已选中的数据项?', '警告', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const dictIds = [dictId || ids.value].join(',');
|
|
||||||
deleteDict(dictIds).then(() => {
|
deleteDict(dictIds).then(() => {
|
||||||
ElMessage.success('删除成功');
|
ElMessage.success('删除成功');
|
||||||
resetQuery();
|
resetQuery();
|
||||||
@@ -209,7 +214,7 @@ onMounted(() => {
|
|||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
:disabled="ids.length === 0"
|
:disabled="ids.length === 0"
|
||||||
@click="handleDelete"
|
@click="handleDelete()"
|
||||||
><i-ep-delete />删除</el-button
|
><i-ep-delete />删除</el-button
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ function resetQuery() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 行checkbox change事件
|
* 行checkbox change事件
|
||||||
*
|
|
||||||
* @param selection
|
|
||||||
*/
|
*/
|
||||||
function handleSelectionChange(selection: any) {
|
function handleSelectionChange(selection: any) {
|
||||||
ids.value = selection.map((item: any) => item.id);
|
ids.value = selection.map((item: any) => item.id);
|
||||||
@@ -146,13 +144,18 @@ function resetForm() {
|
|||||||
/**
|
/**
|
||||||
* 删除字典类型
|
* 删除字典类型
|
||||||
*/
|
*/
|
||||||
function handleDelete(dictTypeId: number) {
|
function handleDelete(dictTypeId?: number) {
|
||||||
|
const dictTypeIds = [dictTypeId || ids.value].join(',');
|
||||||
|
if (!dictTypeIds) {
|
||||||
|
ElMessage.warning('请勾选删除项');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ElMessageBox.confirm('确认删除已选中的数据项?', '警告', {
|
ElMessageBox.confirm('确认删除已选中的数据项?', '警告', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const dictTypeIds = [dictTypeId || ids.value].join(',');
|
|
||||||
deleteDictTypes(dictTypeIds).then(() => {
|
deleteDictTypes(dictTypeIds).then(() => {
|
||||||
ElMessage.success('删除成功');
|
ElMessage.success('删除成功');
|
||||||
resetQuery();
|
resetQuery();
|
||||||
@@ -219,7 +222,7 @@ onMounted(() => {
|
|||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
:disabled="ids.length === 0"
|
:disabled="ids.length === 0"
|
||||||
@click="handleDelete"
|
@click="handleDelete()"
|
||||||
><i-ep-delete />删除</el-button
|
><i-ep-delete />删除</el-button
|
||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -104,7 +104,6 @@ function openDialog(parentId?: number, menuId?: number) {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
dialog.visible = true;
|
dialog.visible = true;
|
||||||
if (menuId) {
|
if (menuId) {
|
||||||
// 编辑
|
|
||||||
dialog.title = '编辑菜单';
|
dialog.title = '编辑菜单';
|
||||||
getMenuForm(menuId).then(({ data }) => {
|
getMenuForm(menuId).then(({ data }) => {
|
||||||
Object.assign(formData, data);
|
Object.assign(formData, data);
|
||||||
@@ -112,7 +111,6 @@ function openDialog(parentId?: number, menuId?: number) {
|
|||||||
menuCacheData.path = data.path ?? '';
|
menuCacheData.path = data.path ?? '';
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// 新增
|
|
||||||
dialog.title = '新增菜单';
|
dialog.title = '新增菜单';
|
||||||
formData.parentId = parentId;
|
formData.parentId = parentId;
|
||||||
}
|
}
|
||||||
@@ -160,6 +158,7 @@ function submitForm() {
|
|||||||
*/
|
*/
|
||||||
function handleDelete(menuId: number) {
|
function handleDelete(menuId: number) {
|
||||||
if (!menuId) {
|
if (!menuId) {
|
||||||
|
ElMessage.warning('请勾选删除项');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,13 +160,18 @@ function resetForm() {
|
|||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
function handleDelete(roleId: number) {
|
function handleDelete(roleId?: number) {
|
||||||
|
const roleIds = [roleId || ids.value].join(',');
|
||||||
|
if (!roleIds) {
|
||||||
|
ElMessage.warning('请勾选删除项');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ElMessageBox.confirm('确认删除已选中的数据项?', '警告', {
|
ElMessageBox.confirm('确认删除已选中的数据项?', '警告', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const roleIds = [roleId || ids.value].join(',');
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
deleteRoles(roleIds)
|
deleteRoles(roleIds)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|||||||
@@ -258,8 +258,8 @@ function handleSubmit() {
|
|||||||
/**
|
/**
|
||||||
* 删除用户
|
* 删除用户
|
||||||
*/
|
*/
|
||||||
function handleDelete(id: number) {
|
function handleDelete(id?: number) {
|
||||||
const userIds = ([id] || ids.value).join(',');
|
const userIds = [id || ids.value].join(',');
|
||||||
if (!userIds) {
|
if (!userIds) {
|
||||||
ElMessage.warning('请勾选删除项');
|
ElMessage.warning('请勾选删除项');
|
||||||
return;
|
return;
|
||||||
@@ -459,7 +459,7 @@ onMounted(() => {
|
|||||||
<el-button
|
<el-button
|
||||||
type="danger"
|
type="danger"
|
||||||
:disabled="ids.length === 0"
|
:disabled="ids.length === 0"
|
||||||
@click="handleDelete"
|
@click="handleDelete()"
|
||||||
v-hasPerm="['sys:user:delete']"
|
v-hasPerm="['sys:user:delete']"
|
||||||
><i-ep-delete />删除</el-button
|
><i-ep-delete />删除</el-button
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user