【新增】新增用户导出及批量删除

pull/22/head
小诺 2021-06-01 00:14:04 +08:00 committed by 15099670051
parent 8c1ea4101a
commit bd6eb16124
5 changed files with 101 additions and 51 deletions

View File

@ -70,6 +70,21 @@ export function sysUserDelete (parameter) {
})
}
/**
*
*
* @author yubaoshan
* @date 2021/5/30 00:23
*/
export function sysUserExport (parameter) {
return axios({
url: '/sysUser/export',
method: 'get',
params: parameter,
responseType: 'blob'
})
}
/**
*
*

View File

@ -1,5 +1,5 @@
<template>
<a-row :gutter="24" >
<a-row :gutter="24">
<a-col :md="5" :sm="24">
<a-card :bordered="false" :loading="treeLoading">
<div v-if="this.orgTree != ''">
@ -46,12 +46,18 @@
ref="table"
:columns="columns"
:data="loadData"
:alert="true"
:alert="options.alert"
:rowKey="(record) => record.id"
:rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
:rowSelection="options.rowSelection"
>
<template slot="operator" v-if="hasPerm('sysUser:add')">
<template slot="operator">
<a-button type="primary" v-if="hasPerm('sysUser:add')" icon="plus" @click="$refs.addForm.add()"></a-button>
<a-button type="danger" :disabled="selectedRowKeys.length < 1" v-if="hasPerm('sysUser:delete')" @click="batchDelete"><a-icon type="delete"/>批量删除</a-button>
<x-down
v-if="hasPerm('sysUser:export')"
ref="batchExport"
@batchExport="batchExport"
/>
</template>
<span slot="sex" slot-scope="text">
{{ sexFilter(text) }}
@ -84,7 +90,7 @@
<a @click="$refs.userOrgForm.userOrg(record)"></a>
</a-menu-item>
<a-menu-item v-if="hasPerm('sysUser:delete')">
<a-popconfirm placement="topRight" title="确认删除?" @confirm="() => sysUserDelete(record)">
<a-popconfirm placement="topRight" title="确认删除?" @confirm="() => singleDelete(record)">
<a>删除</a>
</a-popconfirm>
</a-menu-item>
@ -101,10 +107,10 @@
</a-row>
</template>
<script>
import { STable, XCard } from '@/components'
import { STable, XCard, XDown } from '@/components'
import { Empty } from 'ant-design-vue'
import { getOrgTree } from '@/api/modular/system/orgManage'
import { getUserPage, sysUserDelete, sysUserChangeStatus, sysUserResetPwd } from '@/api/modular/system/userManage'
import { getUserPage, sysUserDelete, sysUserChangeStatus, sysUserResetPwd, sysUserExport } from '@/api/modular/system/userManage'
import { sysDictTypeDropDown } from '@/api/modular/system/dictManage'
import addForm from './addForm'
import editForm from './editForm'
@ -112,6 +118,7 @@
import userOrgForm from './userOrgForm'
export default {
components: {
XDown,
XCard,
STable,
addForm,
@ -121,8 +128,6 @@
},
data () {
return {
// /
advanced: false,
//
queryParam: {},
//
@ -165,6 +170,13 @@
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
replaceFields: {
key: 'id'
},
options: {
alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
rowSelection: {
selectedRowKeys: this.selectedRowKeys,
onChange: this.onSelectChange
}
}
}
},
@ -257,11 +269,26 @@
})
},
/**
* 删除用户
* @param record
* 单个删除
*/
sysUserDelete (record) {
sysUserDelete(record).then((res) => {
singleDelete (record) {
const param = [{ 'id': record.id }]
this.sysUserDelete(param)
},
/**
* 批量删除
*/
batchDelete () {
const paramIds = this.selectedRowKeys.map((d) => {
return { 'id': d }
})
this.sysUserDelete(paramIds)
},
/**
* 删除用户
*/
sysUserDelete (param) {
sysUserDelete(param).then((res) => {
if (res.success) {
this.$message.success('删除成功')
this.$refs.table.refresh()
@ -272,6 +299,14 @@
this.$message.error('删除错误:' + err.message)
})
},
/**
* 批量导出
*/
batchExport () {
sysUserExport().then((res) => {
this.$refs.batchExport.downloadfile(res)
})
},
/**
* 点击左侧机构树查询列表
*/
@ -281,9 +316,6 @@
}
this.$refs.table.refresh(true)
},
toggleAdvanced () {
this.advanced = !this.advanced
},
handleOk () {
this.$refs.table.refresh()
},

View File

@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
*
@ -84,15 +85,15 @@ public class SysUserController {
/**
*
*
* @author xuyuxiang
* @author xuyuxiang yubaoshan
* @date 2020/3/23 16:28
*/
@Permission
@DataScope
@PostMapping("/sysUser/delete")
@BusinessLog(title = "系统用户_删除", opType = LogAnnotionOpTypeEnum.DELETE)
public ResponseData delete(@RequestBody @Validated(SysUserParam.delete.class) SysUserParam sysUserParam) {
sysUserService.delete(sysUserParam);
public ResponseData delete(@RequestBody @Validated(SysUserParam.delete.class) List<SysUserParam> sysUserParamList) {
sysUserService.delete(sysUserParamList);
return new SuccessResponseData();
}

View File

@ -84,11 +84,11 @@ public interface SysUserService extends IService<SysUser> {
/**
*
*
* @param sysUserParam
* @author xuyuxiang
* @param sysUserParamList
* @author xuyuxiang yubaosahn
* @date 2020/3/23 9:26
*/
void delete(SysUserParam sysUserParam);
void delete(List<SysUserParam> sysUserParamList);
/**
*

View File

@ -201,7 +201,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Transactional(rollbackFor = Exception.class)
@Override
public void delete(SysUserParam sysUserParam) {
public void delete(List<SysUserParam> sysUserParamList) {
sysUserParamList.forEach(sysUserParam -> {
SysUser sysUser = this.querySysUser(sysUserParam);
//不能删除超级管理员
if (AdminTypeEnum.SUPER_ADMIN.getCode().equals(sysUser.getAdminType())) {
@ -233,6 +234,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
//删除该用户对应的用户-数据范围表关联信息
sysUserDataScopeService.deleteUserDataScopeListByUserId(id);
});
}
@Transactional(rollbackFor = Exception.class)