【更新】bug修改
This commit is contained in:
parent
6fe7fc311a
commit
9419800806
@ -113,6 +113,9 @@ export default {
|
||||
Object.assign(this.localPagination, {
|
||||
showSizeChanger: val
|
||||
})
|
||||
},
|
||||
columns(v) {
|
||||
this.columnsSetting = v
|
||||
}
|
||||
},
|
||||
created () {
|
||||
@ -151,19 +154,19 @@ export default {
|
||||
loadData (pagination, filters, sorter) {
|
||||
this.localLoading = true
|
||||
const parameter = Object.assign({
|
||||
pageNo: (pagination && pagination.current) ||
|
||||
this.showPagination && this.localPagination.current || this.pageNum,
|
||||
pageSize: (pagination && pagination.pageSize) ||
|
||||
this.showPagination && this.localPagination.pageSize || this.pageSize
|
||||
},
|
||||
(sorter && sorter.field && {
|
||||
sortField: sorter.field
|
||||
}) || {},
|
||||
(sorter && sorter.order && {
|
||||
sortOrder: sorter.order
|
||||
}) || {}, {
|
||||
...filters
|
||||
}
|
||||
pageNo: (pagination && pagination.current) ||
|
||||
this.showPagination && this.localPagination.current || this.pageNum,
|
||||
pageSize: (pagination && pagination.pageSize) ||
|
||||
this.showPagination && this.localPagination.pageSize || this.pageSize
|
||||
},
|
||||
(sorter && sorter.field && {
|
||||
sortField: sorter.field
|
||||
}) || {},
|
||||
(sorter && sorter.order && {
|
||||
sortOrder: sorter.order
|
||||
}) || {}, {
|
||||
...filters
|
||||
}
|
||||
)
|
||||
const result = this.data(parameter)
|
||||
// 对接自己的通用数据接口需要修改下方代码中的 r.pageNo, r.totalCount, r.data
|
||||
@ -252,6 +255,13 @@ export default {
|
||||
this.updateSelect([], [])
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 刷新并清空已选
|
||||
*/
|
||||
clearRefreshSelected (bool = false) {
|
||||
this.refresh(bool)
|
||||
this.clearSelected()
|
||||
},
|
||||
/**
|
||||
* 处理交给 table 使用者去处理 clear 事件时,内部选中统计同时调用
|
||||
* @param callback
|
||||
@ -261,10 +271,10 @@ export default {
|
||||
if (this.selectedRowKeys.length <= 0) return null
|
||||
return (
|
||||
<a style="margin-left: 24px" onClick={() => {
|
||||
callback()
|
||||
this.clearSelected()
|
||||
}}>清空</a>
|
||||
)
|
||||
callback()
|
||||
this.clearSelected()
|
||||
}}>清空</a>
|
||||
)
|
||||
},
|
||||
renderAlert () {
|
||||
// 绘制统计列数据
|
||||
@ -285,16 +295,15 @@ export default {
|
||||
|
||||
// 绘制 alert 组件
|
||||
// 统一先去除alert组件
|
||||
return ''
|
||||
/* return (
|
||||
return (
|
||||
<a-alert showIcon={true} style="margin-bottom: 16px">
|
||||
<template slot="message">
|
||||
<span style="margin-right: 12px">已选择: <a style="font-weight: 600">{this.selectedRows.length}</a></span>
|
||||
{needTotalItems}
|
||||
{clearItem}
|
||||
</template>
|
||||
</a-alert>
|
||||
) */
|
||||
<template slot="message">
|
||||
<span style="margin-right: 12px">已选择: <a style="font-weight: 600">{this.selectedRows.length}</a></span>
|
||||
{needTotalItems}
|
||||
{clearItem}
|
||||
</template>
|
||||
</a-alert>
|
||||
)
|
||||
},
|
||||
columnChange(val) {
|
||||
this.columnsSetting = val
|
||||
@ -318,11 +327,11 @@ export default {
|
||||
}
|
||||
return (
|
||||
<a-menu slot="overlay" onClick={onClick} selectable defaultSelectedKeys={[this.customSize]}>
|
||||
<a-menu-item key="default">默认</a-menu-item>
|
||||
<a-menu-item key="middle">中等</a-menu-item>
|
||||
<a-menu-item key="small">紧凑</a-menu-item>
|
||||
<a-menu-item key="default">默认</a-menu-item>
|
||||
<a-menu-item key="middle">中等</a-menu-item>
|
||||
<a-menu-item key="small">紧凑</a-menu-item>
|
||||
</a-menu>
|
||||
)
|
||||
)
|
||||
},
|
||||
onClick: () => {
|
||||
}
|
||||
@ -344,33 +353,34 @@ export default {
|
||||
|
||||
return (
|
||||
<div class="s-table-tool">
|
||||
<div class="s-table-tool-left">
|
||||
{this.$scopedSlots.operator && this.$scopedSlots.operator()}
|
||||
</div>
|
||||
<div class="s-table-tool-right">
|
||||
{
|
||||
tools.map(tool => {
|
||||
if (tool.isDropdown) {
|
||||
return (
|
||||
<a-dropdown trigger={['click']}>
|
||||
<a-tooltip title={tool.title} class="s-tool-item" onClick={tool.onClick}>
|
||||
<a-icon type={tool.icon}/>
|
||||
</a-tooltip>
|
||||
{ tool.menu() }
|
||||
</a-dropdown>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<a-tooltip title={tool.title} class="s-tool-item" onClick={tool.onClick}>
|
||||
<a-icon type={tool.icon} />
|
||||
</a-tooltip>
|
||||
)
|
||||
})
|
||||
}
|
||||
</div>
|
||||
<div class="s-table-tool-left">
|
||||
{this.$scopedSlots.operator && this.$scopedSlots.operator()}
|
||||
</div>
|
||||
)
|
||||
/* return (
|
||||
<div class="s-table-tool-right">
|
||||
{
|
||||
tools.map(tool => {
|
||||
if (tool.isDropdown) {
|
||||
return (
|
||||
<a-dropdown trigger={['click']}>
|
||||
<a-tooltip title={tool.title} class="s-tool-item" onClick={tool.onClick}>
|
||||
<a-icon type={tool.icon}/>
|
||||
</a-tooltip>
|
||||
{ tool.menu() }
|
||||
</a-dropdown>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<a-tooltip title={tool.title} class="s-tool-item" onClick={tool.onClick}>
|
||||
<a-icon type={tool.icon} />
|
||||
</a-tooltip>
|
||||
)
|
||||
})
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
/*
|
||||
return (
|
||||
<a-alert showIcon={true} style="margin-bottom: 16px">
|
||||
<template slot="message">
|
||||
<span style="margin-right: 12px">已选择: <a style="font-weight: 600">{this.selectedRows.length}</a></span>
|
||||
@ -378,7 +388,8 @@ export default {
|
||||
{clearItem}
|
||||
</template>
|
||||
</a-alert>
|
||||
) */
|
||||
)
|
||||
*/
|
||||
}
|
||||
},
|
||||
|
||||
@ -423,16 +434,16 @@ export default {
|
||||
})
|
||||
const table = (
|
||||
<a-table {...{ props, scopedSlots: { ...this.$scopedSlots } }} onChange={this.loadData} onExpand={ (expanded, record) => { this.$emit('expand', expanded, record) } }>
|
||||
{ Object.keys(this.$slots).map(name => (<template slot={name}>{this.$slots[name]}</template>)) }
|
||||
{ Object.keys(this.$slots).map(name => (<template slot={name}>{this.$slots[name]}</template>)) }
|
||||
</a-table>
|
||||
)
|
||||
|
||||
return (
|
||||
<div class="table-wrapper">
|
||||
{ this.renderHeader() }
|
||||
{ showAlert ? this.renderAlert() : null }
|
||||
{ table }
|
||||
</div>
|
||||
return (
|
||||
<div class="table-wrapper">
|
||||
{ this.renderHeader() }
|
||||
{ showAlert ? this.renderAlert() : null }
|
||||
{ table }
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@
|
||||
|
||||
<script>
|
||||
import { STable, XCard } from '@/components'
|
||||
import { getMenuList } from '@/api/modular/system/menuManage'
|
||||
import { getMenuList, sysMenuDelete } from '@/api/modular/system/menuManage'
|
||||
import addForm from './addForm'
|
||||
import editForm from './editForm'
|
||||
import { mapGetters } from 'vuex'
|
||||
@ -160,6 +160,16 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
handleDel (record) {
|
||||
sysMenuDelete(record).then((res) => {
|
||||
if (res.success) {
|
||||
this.$message.success('删除成功')
|
||||
this.$refs.table.refresh()
|
||||
} else {
|
||||
this.$message.error('删除失败:' + res.message)
|
||||
}
|
||||
})
|
||||
},
|
||||
handleOk () {
|
||||
this.$refs.table.refresh()
|
||||
}
|
||||
|
@ -40,9 +40,9 @@
|
||||
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">
|
||||
<a-button @click="$refs.addForm.add()" icon="plus" type="primary" v-if="hasPerm('sysOrg:add')">新增机构</a-button>
|
||||
@ -122,6 +122,13 @@
|
||||
simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
|
||||
replaceFields: {
|
||||
key: 'id'
|
||||
},
|
||||
options: {
|
||||
alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
|
||||
rowSelection: {
|
||||
selectedRowKeys: this.selectedRowKeys,
|
||||
onChange: this.onSelectChange
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -41,6 +41,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import vip.xiaonuo.sys.modular.user.param.SysUserParam;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统组织机构控制器
|
||||
@ -107,8 +108,8 @@ public class SysOrgController {
|
||||
@DataScope
|
||||
@PostMapping("/sysOrg/delete")
|
||||
@BusinessLog(title = "系统组织机构_删除", opType = LogAnnotionOpTypeEnum.DELETE)
|
||||
public ResponseData delete(@RequestBody @Validated(BaseParam.delete.class) SysOrgParam sysOrgParam) {
|
||||
sysOrgService.delete(sysOrgParam);
|
||||
public ResponseData delete(@RequestBody @Validated(BaseParam.delete.class) List<SysOrgParam> sysOrgParamList) {
|
||||
sysOrgService.delete(sysOrgParamList);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
|
@ -72,11 +72,11 @@ public interface SysOrgService extends IService<SysOrg> {
|
||||
/**
|
||||
* 删除系统组织机构
|
||||
*
|
||||
* @param sysOrgParam 删除参数
|
||||
* @param sysOrgParamList 删除参数集合
|
||||
* @author xuyuxiang
|
||||
* @date 2020/3/25 14:57
|
||||
*/
|
||||
void delete(SysOrgParam sysOrgParam);
|
||||
void delete(List<SysOrgParam> sysOrgParamList);
|
||||
|
||||
/**
|
||||
* 编辑系统组织机构
|
||||
|
@ -195,46 +195,47 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void delete(SysOrgParam sysOrgParam) {
|
||||
SysOrg sysOrg = this.querySysOrg(sysOrgParam);
|
||||
Long id = sysOrg.getId();
|
||||
boolean superAdmin = LoginContextHolder.me().isSuperAdmin();
|
||||
if (!superAdmin) {
|
||||
List<Long> dataScope = sysOrgParam.getDataScope();
|
||||
//数据范围为空
|
||||
if (ObjectUtil.isEmpty(dataScope)) {
|
||||
throw new PermissionException(PermissionExceptionEnum.NO_PERMISSION_OPERATE);
|
||||
} else if (!dataScope.contains(id)) {
|
||||
//所操作的数据不在自己的数据范围内
|
||||
throw new PermissionException(PermissionExceptionEnum.NO_PERMISSION_OPERATE);
|
||||
public void delete(List<SysOrgParam> sysOrgParamList) {
|
||||
sysOrgParamList.forEach(sysOrgParam -> {
|
||||
SysOrg sysOrg = this.querySysOrg(sysOrgParam);
|
||||
Long id = sysOrg.getId();
|
||||
boolean superAdmin = LoginContextHolder.me().isSuperAdmin();
|
||||
if (!superAdmin) {
|
||||
List<Long> dataScope = sysOrgParam.getDataScope();
|
||||
//数据范围为空
|
||||
if (ObjectUtil.isEmpty(dataScope)) {
|
||||
throw new PermissionException(PermissionExceptionEnum.NO_PERMISSION_OPERATE);
|
||||
} else if (!dataScope.contains(id)) {
|
||||
//所操作的数据不在自己的数据范围内
|
||||
throw new PermissionException(PermissionExceptionEnum.NO_PERMISSION_OPERATE);
|
||||
}
|
||||
}
|
||||
// 该机构下有员工,则不能删
|
||||
boolean hasOrgEmp = sysEmpService.hasOrgEmp(id);
|
||||
if (hasOrgEmp) {
|
||||
throw new ServiceException(SysOrgExceptionEnum.ORG_CANNOT_DELETE);
|
||||
}
|
||||
}
|
||||
// 该机构下有员工,则不能删
|
||||
boolean hasOrgEmp = sysEmpService.hasOrgEmp(id);
|
||||
if (hasOrgEmp) {
|
||||
throw new ServiceException(SysOrgExceptionEnum.ORG_CANNOT_DELETE);
|
||||
}
|
||||
|
||||
// 该附属机构下若有员工,则不能删除
|
||||
boolean hasExtOrgEmp = sysEmpExtOrgPosService.hasExtOrgEmp(id);
|
||||
if (hasExtOrgEmp) {
|
||||
throw new ServiceException(SysOrgExceptionEnum.ORG_CANNOT_DELETE);
|
||||
}
|
||||
// 该附属机构下若有员工,则不能删除
|
||||
boolean hasExtOrgEmp = sysEmpExtOrgPosService.hasExtOrgEmp(id);
|
||||
if (hasExtOrgEmp) {
|
||||
throw new ServiceException(SysOrgExceptionEnum.ORG_CANNOT_DELETE);
|
||||
}
|
||||
|
||||
// 级联删除子节点
|
||||
List<Long> childIdList = this.getChildIdListById(id);
|
||||
childIdList.add(id);
|
||||
LambdaUpdateWrapper<SysOrg> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(SysOrg::getId, childIdList)
|
||||
.set(SysOrg::getStatus, CommonStatusEnum.DELETED.getCode());
|
||||
this.update(updateWrapper);
|
||||
// 级联删除子节点
|
||||
List<Long> childIdList = this.getChildIdListById(id);
|
||||
childIdList.add(id);
|
||||
LambdaUpdateWrapper<SysOrg> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(SysOrg::getId, childIdList)
|
||||
.set(SysOrg::getStatus, CommonStatusEnum.DELETED.getCode());
|
||||
this.update(updateWrapper);
|
||||
|
||||
// 级联删除该机构及子机构对应的角色-数据范围关联信息
|
||||
sysRoleDataScopeService.deleteRoleDataScopeListByOrgIdList(childIdList);
|
||||
|
||||
// 级联删除该机构子机构对应的用户-数据范围关联信息
|
||||
sysUserDataScopeService.deleteUserDataScopeListByOrgIdList(childIdList);
|
||||
// 级联删除该机构及子机构对应的角色-数据范围关联信息
|
||||
sysRoleDataScopeService.deleteRoleDataScopeListByOrgIdList(childIdList);
|
||||
|
||||
// 级联删除该机构子机构对应的用户-数据范围关联信息
|
||||
sysUserDataScopeService.deleteUserDataScopeListByOrgIdList(childIdList);
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
@ -38,6 +38,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统职位控制器
|
||||
@ -100,8 +101,8 @@ public class SysPosController {
|
||||
@Permission
|
||||
@PostMapping("/sysPos/delete")
|
||||
@BusinessLog(title = "系统职位_删除", opType = LogAnnotionOpTypeEnum.DELETE)
|
||||
public ResponseData delete(@RequestBody @Validated(SysPosParam.delete.class) SysPosParam sysPosParam) {
|
||||
sysPosService.delete(sysPosParam);
|
||||
public ResponseData delete(@RequestBody @Validated(SysPosParam.delete.class) List<SysPosParam> sysPosParamList) {
|
||||
sysPosService.delete(sysPosParamList);
|
||||
return new SuccessResponseData();
|
||||
}
|
||||
|
||||
|
@ -71,11 +71,11 @@ public interface SysPosService extends IService<SysPos> {
|
||||
/**
|
||||
* 删除系统职位
|
||||
*
|
||||
* @param sysPosParam 删除参数
|
||||
* @param sysPosParamList 删除参数集合
|
||||
* @author xuyuxiang
|
||||
* @date 2020/3/25 14:57
|
||||
*/
|
||||
void delete(SysPosParam sysPosParam);
|
||||
void delete(List<SysPosParam> sysPosParamList);
|
||||
|
||||
/**
|
||||
* 编辑系统职位
|
||||
|
@ -107,23 +107,25 @@ public class SysPosServiceImpl extends ServiceImpl<SysPosMapper, SysPos> impleme
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void delete(SysPosParam sysPosParam) {
|
||||
SysPos sysPos = this.querySysPos(sysPosParam);
|
||||
Long id = sysPos.getId();
|
||||
//该职位下是否有员工
|
||||
boolean hasPosEmp = sysEmpPosService.hasPosEmp(id);
|
||||
//只要还有,则不能删
|
||||
if (hasPosEmp) {
|
||||
throw new ServiceException(SysPosExceptionEnum.POS_CANNOT_DELETE);
|
||||
}
|
||||
//该附属职位下是否有员工
|
||||
boolean hasExtPosEmp = sysEmpExtOrgPosService.hasExtPosEmp(id);
|
||||
//只要还有,则不能删
|
||||
if (hasExtPosEmp) {
|
||||
throw new ServiceException(SysPosExceptionEnum.POS_CANNOT_DELETE);
|
||||
}
|
||||
sysPos.setStatus(CommonStatusEnum.DELETED.getCode());
|
||||
this.updateById(sysPos);
|
||||
public void delete(List<SysPosParam> sysPosParamList) {
|
||||
sysPosParamList.forEach(sysPosParam -> {
|
||||
SysPos sysPos = this.querySysPos(sysPosParam);
|
||||
Long id = sysPos.getId();
|
||||
//该职位下是否有员工
|
||||
boolean hasPosEmp = sysEmpPosService.hasPosEmp(id);
|
||||
//只要还有,则不能删
|
||||
if (hasPosEmp) {
|
||||
throw new ServiceException(SysPosExceptionEnum.POS_CANNOT_DELETE);
|
||||
}
|
||||
//该附属职位下是否有员工
|
||||
boolean hasExtPosEmp = sysEmpExtOrgPosService.hasExtPosEmp(id);
|
||||
//只要还有,则不能删
|
||||
if (hasExtPosEmp) {
|
||||
throw new ServiceException(SysPosExceptionEnum.POS_CANNOT_DELETE);
|
||||
}
|
||||
sysPos.setStatus(CommonStatusEnum.DELETED.getCode());
|
||||
this.updateById(sysPos);
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
Loading…
x
Reference in New Issue
Block a user