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

pull/90/head
小诺 2 years ago committed by 俞宝山
parent cb4f0a4680
commit 1613273835

@ -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>

@ -48,11 +48,19 @@
>
<template #operator class="table-operator">
<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>
新增
</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>
</template>
<template #bodyCell="{ column, record }">
@ -183,16 +191,7 @@
})
}
//
const deleteBatchOrg = () => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
const deleteBatchOrg = (params) => {
bizOrgApi.orgDelete(params).then(() => {
table.value.clearRefreshSelected()
})

@ -48,11 +48,19 @@
>
<template #operator class="table-operator">
<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>
新增
</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>
</template>
<template #bodyCell="{ column, record }">
@ -181,16 +189,7 @@
})
}
//
const deleteBatchPosition = () => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
const deleteBatchPosition = (params) => {
bizPositionApi.positionDelete(params).then(() => {
table.value.clearRefreshSelected()
})

@ -60,7 +60,11 @@
>
<template #operator class="table-operator">
<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>
<span>{{ $t('common.addButton') }}{{ $t('model.user') }}</span>
</a-button>
@ -72,17 +76,12 @@
<template #icon><delete-outlined /></template>
{{ $t('user.batchExportButton') }}
</a-button>
<a-popconfirm
title="删除此信息?"
:visible="deleteVisible"
@visibleChange="deleteVisibleChange"
@confirm="deleteBatchUser"
>
<a-button danger v-if="hasPerm('bizUserBatchDelete')">
<template #icon><delete-outlined /></template>
{{ $t('common.batchRemoveButton') }}
</a-button>
</a-popconfirm>
<xn-batch-delete
v-if="hasPerm('bizUserBatchDelete')"
:buttonName="$t('common.batchRemoveButton')"
:selectedRowKeys="selectedRowKeys"
@batchDelete="deleteBatchUser"
/>
</a-space>
</template>
<template #bodyCell="{ column, record }">
@ -222,7 +221,6 @@
const loading = ref(false)
const cardLoading = ref(true)
const ImpExpRef = ref()
const deleteVisible = ref(false)
// Promise
const loadData = (parameter) => {
return bizUserApi.userPage(Object.assign(parameter, searchFormState)).then((res) => {
@ -338,27 +336,8 @@
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 params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
const deleteBatchUser = (params) => {
bizUserApi.userDelete(params).then(() => {
table.value.clearRefreshSelected()
})

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

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

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

@ -34,7 +34,7 @@
<template #operator class="table-operator">
<a-space>
<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>
</template>
<template #bodyCell="{ column, record }">
@ -122,16 +122,7 @@
})
}
//
const deleteBatchEmail = () => {
if (selectedRowKeys.value.length < 1) {
message.warning('请选择一条或多条数据')
return false
}
const params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
const deleteBatchEmail = (params) => {
messageApi.messageDelete(params).then(() => {
table.value.clearRefreshSelected()
})

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

@ -17,18 +17,7 @@
<template #icon><plus-outlined /></template>
新建
</a-button>
<a-popconfirm
title="删除此信息?"
:visible="deleteVisible"
@visibleChange="deleteVisibleChange"
@confirm="deleteBatchCodeGen"
>
<a-button type="danger">
<template #icon><delete-outlined /></template>
删除
</a-button>
</a-popconfirm>
<xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchCodeGen" />
</a-space>
</template>
<template #bodyCell="{ column, record }">
@ -69,7 +58,6 @@
const indexShow = ref(true)
const stepsRef = ref()
const genPreviewRef = ref()
const deleteVisible = ref(false)
const columns = [
{
@ -189,27 +177,8 @@
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 params = selectedRowKeys.value.map((m) => {
return {
id: m
}
})
const deleteBatchCodeGen = (params) => {
genBasicApi.basicDelete(params).then(() => {
table.value.refresh()
})

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save