【升级】所有带有批量删除的功能统一封装为插件共用,实现批量删除确认

pull/90/head
小诺 2023-03-12 11:02:15 +08:00 committed by 俞宝山
parent cb4f0a4680
commit 1613273835
20 changed files with 126 additions and 276 deletions

View File

@ -0,0 +1,53 @@
<template>
<a-popconfirm
title="删除此信息?"
:visible="deleteVisible"
@visibleChange="deleteVisibleChange"
@confirm="deleteBatch"
>
<a-button danger>
<template #icon><delete-outlined /></template>
{{ props.buttonName }}
</a-button>
</a-popconfirm>
</template>
<script setup name="commonBatchDelete">
import { message } from 'ant-design-vue'
const deleteVisible = ref(false)
const emit = defineEmits({ batchDelete: null })
const props = defineProps({
buttonName: {
type: String,
default: () => '批量删除'
},
selectedRowKeys: {
type: Array,
default: () => []
}
})
//
const deleteVisibleChange = () => {
if (deleteVisible.value) {
deleteVisible.value = false
return false
}
if (props.selectedRowKeys.length < 1) {
message.warning('请选择一条或多条数据')
deleteVisible.value = false
return false
} else {
deleteVisible.value = true
}
}
//
const deleteBatch = () => {
const params = props.selectedRowKeys.map((m) => {
return {
id: m
}
})
//
emit('batchDelete', params)
}
</script>

View File

@ -48,11 +48,19 @@
> >
<template #operator class="table-operator"> <template #operator class="table-operator">
<a-space> <a-space>
<a-button type="primary" @click="form.onOpen(undefined, searchFormState.parentId)" v-if="hasPerm('bizOrgAdd')"> <a-button
type="primary"
@click="form.onOpen(undefined, searchFormState.parentId)"
v-if="hasPerm('bizOrgAdd')"
>
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增 新增
</a-button> </a-button>
<a-button danger @click="deleteBatchOrg()" v-if="hasPerm('bizOrgBatchDelete')"></a-button> <xn-batch-delete
v-if="hasPerm('bizOrgBatchDelete')"
:selectedRowKeys="selectedRowKeys"
@batchDelete="deleteBatchOrg"
/>
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -183,16 +191,7 @@
}) })
} }
// //
const deleteBatchOrg = () => { const deleteBatchOrg = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
bizOrgApi.orgDelete(params).then(() => { bizOrgApi.orgDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -48,11 +48,19 @@
> >
<template #operator class="table-operator"> <template #operator class="table-operator">
<a-space> <a-space>
<a-button type="primary" @click="form.onOpen(undefined, searchFormState.orgId)" v-if="hasPerm('bizPositionAdd')"> <a-button
type="primary"
@click="form.onOpen(undefined, searchFormState.orgId)"
v-if="hasPerm('bizPositionAdd')"
>
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增 新增
</a-button> </a-button>
<a-button danger @click="deleteBatchPosition()" v-if="hasPerm('bizPositionBatchDelete')"></a-button> <xn-batch-delete
v-if="hasPerm('bizPositionBatchDelete')"
:selectedRowKeys="selectedRowKeys"
@batchDelete="deleteBatchPosition"
/>
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -181,16 +189,7 @@
}) })
} }
// //
const deleteBatchPosition = () => { const deleteBatchPosition = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
bizPositionApi.positionDelete(params).then(() => { bizPositionApi.positionDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -60,7 +60,11 @@
> >
<template #operator class="table-operator"> <template #operator class="table-operator">
<a-space> <a-space>
<a-button type="primary" @click="form.onOpen(undefined, searchFormState.orgId)" v-if="hasPerm('bizUserAdd')"> <a-button
type="primary"
@click="form.onOpen(undefined, searchFormState.orgId)"
v-if="hasPerm('bizUserAdd')"
>
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
<span>{{ $t('common.addButton') }}{{ $t('model.user') }}</span> <span>{{ $t('common.addButton') }}{{ $t('model.user') }}</span>
</a-button> </a-button>
@ -72,17 +76,12 @@
<template #icon><delete-outlined /></template> <template #icon><delete-outlined /></template>
{{ $t('user.batchExportButton') }} {{ $t('user.batchExportButton') }}
</a-button> </a-button>
<a-popconfirm <xn-batch-delete
title="删除此信息?" v-if="hasPerm('bizUserBatchDelete')"
:visible="deleteVisible" :buttonName="$t('common.batchRemoveButton')"
@visibleChange="deleteVisibleChange" :selectedRowKeys="selectedRowKeys"
@confirm="deleteBatchUser" @batchDelete="deleteBatchUser"
> />
<a-button danger v-if="hasPerm('bizUserBatchDelete')">
<template #icon><delete-outlined /></template>
{{ $t('common.batchRemoveButton') }}
</a-button>
</a-popconfirm>
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -222,7 +221,6 @@
const loading = ref(false) const loading = ref(false)
const cardLoading = ref(true) const cardLoading = ref(true)
const ImpExpRef = ref() const ImpExpRef = ref()
const deleteVisible = ref(false)
// Promise // Promise
const loadData = (parameter) => { const loadData = (parameter) => {
return bizUserApi.userPage(Object.assign(parameter, searchFormState)).then((res) => { return bizUserApi.userPage(Object.assign(parameter, searchFormState)).then((res) => {
@ -338,27 +336,8 @@
downloadUtil.resultDownload(res) downloadUtil.resultDownload(res)
}) })
} }
//
const deleteVisibleChange = () => {
if (deleteVisible.value) {
deleteVisible.value = false
return false
}
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
deleteVisible.value = false
return false
} else {
deleteVisible.value = true
}
}
// //
const deleteBatchUser = () => { const deleteBatchUser = (params) => {
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
bizUserApi.userDelete(params).then(() => { bizUserApi.userDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -28,7 +28,6 @@
</template> </template>
<script setup name="devConfig"> <script setup name="devConfig">
import { Empty } from 'ant-design-vue'
import SysConfig from './sysConfig.vue' import SysConfig from './sysConfig.vue'
import EmailConfig from './emailConfig/index.vue' import EmailConfig from './emailConfig/index.vue'
import SmsConfig from './smsConfig/index.vue' import SmsConfig from './smsConfig/index.vue'

View File

@ -42,7 +42,7 @@
<UploadOutlined /> <UploadOutlined />
文件上传 文件上传
</a-button> </a-button>
<a-button danger @click="deleteBatchFile()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchFile" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -181,16 +181,7 @@
}) })
} }
// //
const deleteBatchFile = () => { const deleteBatchFile = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
fileApi.fileDelete(params).then(() => { fileApi.fileDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -41,7 +41,7 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增 新增
</a-button> </a-button>
<a-button danger @click="deleteBatchJob()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchJob" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -190,16 +190,7 @@
}) })
} }
// //
const deleteBatchJob = () => { const deleteBatchJob = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
jobApi.jobDelete(params).then(() => { jobApi.jobDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -34,7 +34,7 @@
<template #operator class="table-operator"> <template #operator class="table-operator">
<a-space> <a-space>
<a-button type="primary" @click="form.onOpen()"> </a-button> <a-button type="primary" @click="form.onOpen()"> </a-button>
<a-button danger @click="deleteBatchEmail()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchEmail" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -122,16 +122,7 @@
}) })
} }
// //
const deleteBatchEmail = () => { const deleteBatchEmail = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
messageApi.messageDelete(params).then(() => { messageApi.messageDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -47,7 +47,7 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
发送短信 发送短信
</a-button> </a-button>
<a-button danger @click="deleteBatchSms()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchSms" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -152,16 +152,7 @@
}) })
} }
// //
const deleteBatchSms = () => { const deleteBatchSms = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
smsApi.smsDelete(params).then(() => { smsApi.smsDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -17,18 +17,7 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新建 新建
</a-button> </a-button>
<xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchCodeGen" />
<a-popconfirm
title="删除此信息?"
:visible="deleteVisible"
@visibleChange="deleteVisibleChange"
@confirm="deleteBatchCodeGen"
>
<a-button type="danger">
<template #icon><delete-outlined /></template>
删除
</a-button>
</a-popconfirm>
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -69,7 +58,6 @@
const indexShow = ref(true) const indexShow = ref(true)
const stepsRef = ref() const stepsRef = ref()
const genPreviewRef = ref() const genPreviewRef = ref()
const deleteVisible = ref(false)
const columns = [ const columns = [
{ {
@ -189,27 +177,8 @@
table.value.refresh() table.value.refresh()
}) })
} }
//
const deleteVisibleChange = () => {
if (deleteVisible.value) {
deleteVisible.value = false
return false
}
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
deleteVisible.value = false
return false
} else {
deleteVisible.value = true
}
}
// //
const deleteBatchCodeGen = () => { const deleteBatchCodeGen = (params) => {
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
genBasicApi.basicDelete(params).then(() => { genBasicApi.basicDelete(params).then(() => {
table.value.refresh() table.value.refresh()
}) })

View File

@ -41,7 +41,7 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增 新增
</a-button> </a-button>
<a-button danger @click="deleteBatchMobileMenu()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchMobileMenu" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -200,16 +200,7 @@
}) })
} }
// //
const deleteBatchMobileMenu = () => { const deleteBatchMobileMenu = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
mobileMenuApi.mobileMenuDelete(params).then(() => { mobileMenuApi.mobileMenuDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -31,7 +31,7 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增模块 新增模块
</a-button> </a-button>
<a-button danger @click="deleteBatchModule()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchModule" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -128,16 +128,7 @@
}) })
} }
// //
const deleteBatchModule = () => { const deleteBatchModule = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
moduleApi.moduleDelete(params).then(() => { moduleApi.moduleDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -51,7 +51,7 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增 新增
</a-button> </a-button>
<a-button danger @click="deleteBatchOrg()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchOrg" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -175,16 +175,7 @@
}) })
} }
// //
const deleteBatchOrg = () => { const deleteBatchOrg = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
orgApi.orgDelete(params).then(() => { orgApi.orgDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -52,7 +52,7 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增 新增
</a-button> </a-button>
<a-button danger @click="deleteBatchPosition()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchPosition" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -75,7 +75,7 @@
</template> </template>
<script setup name="sysPosition"> <script setup name="sysPosition">
import { message, Empty } from 'ant-design-vue' import { Empty } from 'ant-design-vue'
import positionApi from '@/api/sys/positionApi' import positionApi from '@/api/sys/positionApi'
import orgApi from '@/api/sys/orgApi' import orgApi from '@/api/sys/orgApi'
import Form from './form.vue' import Form from './form.vue'
@ -174,16 +174,7 @@
}) })
} }
// //
const deleteBatchPosition = () => { const deleteBatchPosition = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
positionApi.positionDelete(params).then(() => { positionApi.positionDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -39,7 +39,6 @@
</template> </template>
<script setup> <script setup>
import { message } from 'ant-design-vue'
import buttonApi from '@/api/sys/resource/buttonApi' import buttonApi from '@/api/sys/resource/buttonApi'
import Form from './form.vue' import Form from './form.vue'
const columns = [ const columns = [

View File

@ -1,5 +1,5 @@
<template> <template>
<a-card :bordered="false" class="select-card"> <a-card :bordered="false">
<a-space> <a-space>
<a-radio-group v-model:value="moduleType" button-style="solid"> <a-radio-group v-model:value="moduleType" button-style="solid">
<a-radio-button <a-radio-button
@ -12,7 +12,6 @@
{{ module.title }}</a-radio-button {{ module.title }}</a-radio-button
> >
</a-radio-group> </a-radio-group>
<a-input-search <a-input-search
v-model:value="searchFormState.searchKey" v-model:value="searchFormState.searchKey"
placeholder="请输入菜单名称关键词" placeholder="请输入菜单名称关键词"
@ -22,7 +21,7 @@
/> />
</a-space> </a-space>
</a-card> </a-card>
<a-card :bordered="false"> <a-card :bordered="false" class="mt-2">
<s-table <s-table
ref="table" ref="table"
:columns="columns" :columns="columns"
@ -40,7 +39,7 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增菜单 新增菜单
</a-button> </a-button>
<a-button danger @click="deleteBatchMenu()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchMenu" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -106,7 +105,6 @@
</template> </template>
<script setup name="sysMenu"> <script setup name="sysMenu">
import { message } from 'ant-design-vue'
import menuApi from '@/api/sys/resource/menuApi' import menuApi from '@/api/sys/resource/menuApi'
import Form from './form.vue' import Form from './form.vue'
import changeModuleForm from './changeModuleForm.vue' import changeModuleForm from './changeModuleForm.vue'
@ -236,28 +234,9 @@
}) })
} }
// //
const deleteBatchMenu = () => { const deleteBatchMenu = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
menuApi.menuDelete(params).then(() => { menuApi.menuDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })
} }
</script> </script>
<style scoped>
.select-card {
margin-top: -12px;
margin-left: -12px;
margin-right: -12px;
margin-bottom: 10px;
padding-top: -10px;
}
</style>

View File

@ -4,7 +4,7 @@
<a-row :gutter="24"> <a-row :gutter="24">
<a-col :span="8"> <a-col :span="8">
<a-form-item label="名称关键词" name="searchKey"> <a-form-item label="名称关键词" name="searchKey">
<a-input v-model:value="searchFormState.searchKey" placeholder="请输入模块名称关键词"></a-input> <a-input v-model:value="searchFormState.searchKey" placeholder="请输入模块名称关键词" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="8"> <a-col :span="8">
@ -31,7 +31,7 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增模块 新增模块
</a-button> </a-button>
<a-button danger @click="deleteBatchModule()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchModule" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -122,16 +122,7 @@
}) })
} }
// //
const deleteBatchModule = () => { const deleteBatchModule = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
moduleApi.moduleDelete(params).then(() => { moduleApi.moduleDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -42,7 +42,7 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增单页 新增单页
</a-button> </a-button>
<a-button danger @click="deleteBatchSpa()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchSpa" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -76,7 +76,6 @@
</template> </template>
<script setup name="sysSpa"> <script setup name="sysSpa">
import { message } from 'ant-design-vue'
import spaApi from '@/api/sys/resource/spaApi' import spaApi from '@/api/sys/resource/spaApi'
import tool from '@/utils/tool' import tool from '@/utils/tool'
import Form from './form.vue' import Form from './form.vue'
@ -177,16 +176,7 @@
}) })
} }
// //
const deleteBatchSpa = () => { const deleteBatchSpa = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
spaApi.spaDelete(params).then(() => { spaApi.spaDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -53,7 +53,7 @@
<template #icon><plus-outlined /></template> <template #icon><plus-outlined /></template>
新增角色 新增角色
</a-button> </a-button>
<a-button danger @click="deleteBatchRole()"></a-button> <xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchRole" />
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -108,7 +108,7 @@
</template> </template>
<script setup name="sysRole"> <script setup name="sysRole">
import { message, Empty } from 'ant-design-vue' import { Empty } from 'ant-design-vue'
import roleApi from '@/api/sys/roleApi' import roleApi from '@/api/sys/roleApi'
import orgApi from '@/api/sys/orgApi' import orgApi from '@/api/sys/orgApi'
import grantResourceForm from './grantResourceForm.vue' import grantResourceForm from './grantResourceForm.vue'
@ -239,16 +239,7 @@
}) })
} }
// //
const deleteBatchRole = () => { const deleteBatchRole = (params) => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
roleApi.roleDelete(params).then(() => { roleApi.roleDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })

View File

@ -72,17 +72,11 @@
<template #icon><delete-outlined /></template> <template #icon><delete-outlined /></template>
{{ $t('user.batchExportButton') }} {{ $t('user.batchExportButton') }}
</a-button> </a-button>
<a-popconfirm <xn-batch-delete
title="删除此信息?" :buttonName="$t('common.batchRemoveButton')"
:visible="deleteVisible" :selectedRowKeys="selectedRowKeys"
@visibleChange="deleteVisibleChange" @batchDelete="deleteBatchUser"
@confirm="deleteBatchUser" />
>
<a-button danger>
<template #icon><delete-outlined /></template>
{{ $t('common.batchRemoveButton') }}
</a-button>
</a-popconfirm>
</a-space> </a-space>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
@ -218,7 +212,7 @@
let searchFormState = reactive({}) let searchFormState = reactive({})
const table = ref(null) const table = ref(null)
const treeData = ref([]) const treeData = ref([])
let selectedRowKeys = ref([]) const selectedRowKeys = ref([])
const treeFieldNames = { children: 'children', title: 'name', key: 'id' } const treeFieldNames = { children: 'children', title: 'name', key: 'id' }
let form = ref(null) let form = ref(null)
let RoleSelectorPlus = ref() let RoleSelectorPlus = ref()
@ -228,7 +222,6 @@
const ImpExpRef = ref() const ImpExpRef = ref()
const grantResourceFormRef = ref() const grantResourceFormRef = ref()
const grantPermissionFormRef = ref() const grantPermissionFormRef = ref()
const deleteVisible = ref(false)
// Promise // Promise
const loadData = (parameter) => { const loadData = (parameter) => {
return userApi.userPage(Object.assign(parameter, searchFormState)).then((res) => { return userApi.userPage(Object.assign(parameter, searchFormState)).then((res) => {
@ -260,7 +253,7 @@
alert: { alert: {
show: false, show: false,
clear: () => { clear: () => {
selectedRowKeys = ref([]) selectedRowKeys.value = ref([])
} }
}, },
rowSelection: { rowSelection: {
@ -339,27 +332,8 @@
downloadUtil.resultDownload(res) downloadUtil.resultDownload(res)
}) })
} }
//
const deleteVisibleChange = () => {
if (deleteVisible.value) {
deleteVisible.value = false
return false
}
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
deleteVisible.value = false
return false
} else {
deleteVisible.value = true
}
}
// //
const deleteBatchUser = () => { const deleteBatchUser = (params) => {
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
userApi.userDelete(params).then(() => { userApi.userDelete(params).then(() => {
table.value.clearRefreshSelected() table.value.clearRefreshSelected()
}) })