Jeecg-Boot 2.1.4 版本发布 | 重构较大,较多新功能

This commit is contained in:
zhangdaiscott
2020-02-24 02:44:53 +08:00
parent 06847cd801
commit 4a4f236772
269 changed files with 15734 additions and 24855 deletions

View File

@ -1,7 +1,7 @@
<template>
<a-card :loading="cardLoading" :bordered="false" style="height: 100%;">
<a-spin :spinning="loading">
<a-input-search @search="handleSearch" style="width:100%;margin-top: 10px" placeholder="输入组织机构名称进行查询..."/>
<a-input-search @search="handleSearch" style="width:100%;margin-top: 10px" placeholder="输入机构名称查询..." allowClear enterButton />
<a-tree
showLine
@ -67,20 +67,21 @@
promise.then(res => {
if (res.success) {
this.treeDataSource = res.result
// update-begin- --- author:wangshuai ------ date:20200102 ---- for:去除默认选中第一条数据、默认展开所有第一级
// 默认选中第一条数据、默认展开所有第一级
if (res.result.length > 0) {
this.expandedKeys = []
res.result.forEach((item, index) => {
if (index === 0) {
this.selectedKeys = [item.id]
this.emitInput(item.orgCode)
}
this.expandedKeys.push(item.id)
})
}
// if (res.result.length > 0) {
// this.expandedKeys = []
// res.result.forEach((item, index) => {
// if (index === 0) {
// this.selectedKeys = [item.id]
// this.emitInput(item.orgCode)
// }
// this.expandedKeys.push(item.id)
// })
// }
// update-end- --- author:wangshuai ------ date:20200102 ---- for:去除默认选中第一条数据、默认展开所有第一级
} else {
this.$message.warn('组织机构查询失败' + res.message)
this.$message.warn(res.message)
console.error('组织机构查询失败:', res)
}
}).finally(() => {

View File

@ -65,12 +65,6 @@
align: 'center',
customRender: (t, r, i) => parseInt(i) + 1
},
{
title: '部门',
width: '20%',
align: 'center',
dataIndex: 'departName'
},
{
title: '姓名',
width: '15%',
@ -83,6 +77,12 @@
align: 'center',
dataIndex: 'workNo'
},
{
title: '部门',
width: '20%',
align: 'center',
dataIndex: 'departName'
},
{
title: '职务',
width: '15%',
@ -91,7 +91,7 @@
customRender: (text) => (text || '').split(',').map(t => this.positionInfo[t] ? this.positionInfo[t] : t).join(',')
},
{
title: '机',
title: '机',
width: '15%',
align: 'center',
dataIndex: 'telephone'
@ -130,14 +130,26 @@
methods: {
loadData(pageNum, orgCode) {
if (!orgCode) {
return
}
//加载数据 若传入参数1则加载第一页的内容
if (pageNum === 1) {
this.ipagination.current = 1
}
this.loading = true
if (pageNum === 1) {
this.ipagination.current = 1
}
// update-begin- --- author:wangshuai ------ date:20200102 ---- for:传过来的部门编码为空全查
if (!orgCode) {
getAction(this.url.list, {
...this.getQueryParams()
}).then((res) => {
if (res.success) {
this.dataSource = res.result.records
this.ipagination.total = res.result.total
}
}).finally(() => {
this.loading = false
this.cardLoading = false
})
// update-end- --- author:wangshuai ------ date:20200102 ---- for:传过来的部门编码为空全查
}else{
//加载数据 若传入参数1则加载第一页的内容
getAction(this.url.list, {
orgCode,
...this.getQueryParams()
@ -150,6 +162,7 @@
this.loading = false
this.cardLoading = false
})
}
},
searchQuery() {

View File

@ -0,0 +1,184 @@
<template>
<a-card :bordered="false">
<template v-if="this.departId">
<a-form>
<a-form-item label='所拥有的权限'>
<a-tree
checkable
@check="onCheck"
:checkedKeys="checkedKeys"
:treeData="treeData"
@expand="onExpand"
@select="onTreeNodeSelect"
:selectedKeys="selectedKeys"
:expandedKeys="expandedKeysss"
:checkStrictly="checkStrictly"
style="height:500px;overflow: auto;">
<span slot="hasDatarule" slot-scope="{slotTitle,ruleFlag}">
{{ slotTitle }}
<a-icon v-if="ruleFlag" type="align-left" style="margin-left:5px;color: red;"></a-icon>
</span>
</a-tree>
</a-form-item>
</a-form>
<div class="anty-form-btn">
<a-dropdown style="float: left" :trigger="['click']" placement="topCenter">
<a-menu slot="overlay">
<!-- 简化Tree逻辑使用默认checkStrictly为false的行为即默认父子关联
<a-menu-item key="1" @click="switchCheckStrictly(1)">父子关联</a-menu-item>
<a-menu-item key="2" @click="switchCheckStrictly(2)">取消关联</a-menu-item>
-->
<a-menu-item key="3" @click="checkALL">全部勾选</a-menu-item>
<a-menu-item key="4" @click="cancelCheckALL">取消全选</a-menu-item>
<a-menu-item key="5" @click="expandAll">展开所有</a-menu-item>
<a-menu-item key="6" @click="closeAll">合并所有</a-menu-item>
</a-menu>
<a-button>
树操作 <a-icon type="up" />
</a-button>
</a-dropdown>
<a-button style="float: right" @click="handleSubmit" type="primary" htmlType="button" icon="form">保存</a-button>
</div>
</template>
<div v-else style="height:330px;"><h3>请先选择一个部门!</h3></div>
<depart-datarule-modal ref="datarule"/>
</a-card>
</template>
<script>
import {queryTreeListForRole,queryDepartPermission,saveDepartPermission} from '@/api/api'
import DepartDataruleModal from './DepartDataruleModal'
export default {
name: 'DepartAuthModal',
components: { DepartDataruleModal },
data(){
return {
departId:"",
treeData: [],
defaultCheckedKeys:[],
checkedKeys:[],
halfCheckedKeys:[],
expandedKeysss:[],
allTreeKeys:[],
autoExpandParent: true,
checkStrictly: false,
title:"部门权限配置",
visible: false,
loading: false,
selectedKeys:[]
}
},
methods: {
onTreeNodeSelect(id){
if(id && id.length>0){
this.selectedKeys = id
}
this.$refs.datarule.show(this.selectedKeys[0],this.departId)
},
onCheck (checkedKeys, { halfCheckedKeys }) {
// 保存选中的和半选中的,后面保存的时候合并提交
this.checkedKeys = checkedKeys
this.halfCheckedKeys = halfCheckedKeys
},
show(departId){
this.departId=departId
this.loadData();
},
close () {
this.reset()
this.$emit('close');
this.visible = false;
},
onExpand(expandedKeys){
this.expandedKeysss = expandedKeys;
this.autoExpandParent = false
},
reset () {
this.expandedKeysss = []
this.checkedKeys = []
this.defaultCheckedKeys = []
this.loading = false
},
expandAll () {
this.expandedKeysss = this.allTreeKeys
},
closeAll () {
this.expandedKeysss = []
},
checkALL () {
this.checkedKeys = this.allTreeKeys
},
cancelCheckALL () {
this.checkedKeys = []
},
handleCancel () {
this.close()
},
handleSubmit() {
let that = this;
if(!that.departId){
this.$message.warning('请点击选择一个部门!')
}
let checkedKeys = [...that.checkedKeys, ...that.halfCheckedKeys]
const permissionIds = checkedKeys.join(",")
let params = {
departId:that.departId,
permissionIds,
lastpermissionIds:that.defaultCheckedKeys.join(","),
};
that.loading = true;
saveDepartPermission(params).then((res)=>{
if(res.success){
that.$message.success(res.message);
that.loading = false;
that.loadData();
}else {
that.$message.error(res.message);
that.loading = false;
}
})
},
convertTreeListToKeyLeafPairs(treeList, keyLeafPair = []) {
for(const {key, isLeaf, children} of treeList) {
keyLeafPair.push({key, isLeaf})
if(children && children.length > 0) {
this.convertTreeListToKeyLeafPairs(children, keyLeafPair)
}
}
return keyLeafPair;
},
emptyCurrForm() {
this.form.resetFields()
},
loadData(){
queryTreeListForRole().then((res) => {
this.treeData = res.result.treeList
this.allTreeKeys = res.result.ids
const keyLeafPairs = this.convertTreeListToKeyLeafPairs(this.treeData)
queryDepartPermission({departId:this.departId}).then((res)=>{
// 过滤出 leaf node 即可,即选中的
// Tree组件中checkStrictly默认为false的时候选中子节点父节点会自动设置选中或半选中
// 保存 checkedKeys 以及 halfCheckedKeys 以便于未做任何操作时提交表单数据
const checkedKeys = [...res.result].filter(key => {
const keyLeafPair = keyLeafPairs.filter(item => item.key === key)[0]
return keyLeafPair && keyLeafPair.isLeaf
})
const halfCheckedKeys = [...res.result].filter(key => {
const keyLeafPair = keyLeafPairs.filter(item => item.key === key)[0]
return keyLeafPair && !keyLeafPair.isLeaf
})
this.checkedKeys = [...checkedKeys];
this.halfCheckedKeys = [...halfCheckedKeys]
this.defaultCheckedKeys = [...halfCheckedKeys, ...checkedKeys];
this.expandedKeysss = this.allTreeKeys;
})
})
}
},
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,116 @@
<template>
<a-drawer
title="数据规则/按钮权限配置"
width="365"
:closable="false"
@close="onClose"
:visible="visible"
>
<a-tabs defaultActiveKey="1">
<a-tab-pane tab="数据规则" key="1">
<a-checkbox-group v-model="dataruleChecked" v-if="dataruleList.length>0">
<a-row>
<a-col :span="24" v-for="(item,index) in dataruleList" :key=" 'dr'+index ">
<a-checkbox :value="item.id">{{ item.ruleName }}</a-checkbox>
</a-col>
<a-col :span="24">
<div style="width: 100%;margin-top: 15px">
<a-button @click="saveDataruleForRole" type="primary" size="small" icon="save">点击保存</a-button>
</div>
</a-col>
</a-row>
</a-checkbox-group>
<div v-else><h3>无配置信息!</h3></div>
</a-tab-pane>
</a-tabs>
</a-drawer>
</template>
<script>
import ARow from 'ant-design-vue/es/grid/Row'
import ACol from 'ant-design-vue/es/grid/Col'
import { getAction,postAction } from '@/api/manage'
export default {
name: 'DepartDataruleModal',
components: { ACol, ARow },
data(){
return {
functionId:'',
departId:'',
visible:false,
tabList: [{
key: '1',
tab: '数据规则',
}, {
key: '2',
tab: '按钮权限',
}],
activeTabKey: '1',
url:{
datarule:"/sys/sysDepartPermission/datarule",
},
dataruleList:[],
dataruleChecked:[]
}
},
methods:{
loadData(){
getAction(`${this.url.datarule}/${this.functionId}/${this.departId}`).then(res=>{
if(res.success){
this.dataruleList = res.result.datarule
let drChecked = res.result.drChecked
if(drChecked){
this.dataruleChecked = drChecked.split(",")
}
}
})
},
saveDataruleForRole(){
if(!this.dataruleChecked || this.dataruleChecked.length==0){
this.$message.warning("请注意,现未勾选任何数据权限!")
}
let params = {
permissionId:this.functionId,
departId:this.departId,
dataRuleIds:this.dataruleChecked.join(",")
}
postAction(this.url.datarule,params).then(res=>{
if(res.success){
this.$message.success(res.message)
}else{
this.$message.error(res.message)
}
})
},
show(functionId,departId){
this.onReset()
this.functionId = functionId
this.departId = departId
this.visible=true
this.loadData()
},
onClose(){
this.visible=false
this.onReset()
},
onTabChange (key) {
this.activeTabKey = key
},
onReset(){
this.functionId=''
this.departId=''
this.dataruleList=[]
this.dataruleChecked=[]
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,217 @@
<template>
<a-drawer
:title="title"
:maskClosable="true"
width=650
placement="right"
:closable="true"
@close="close"
:visible="visible"
style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
<a-form>
<a-form-item label='所拥有的部门权限'>
<a-tree
v-if="treeData.length>0"
checkable
@check="onCheck"
:checkedKeys="checkedKeys"
:treeData="treeData"
@expand="onExpand"
@select="onTreeNodeSelect"
:selectedKeys="selectedKeys"
:expandedKeys="expandedKeysss"
:checkStrictly="checkStrictly">
<span slot="hasDatarule" slot-scope="{slotTitle,ruleFlag}">
{{ slotTitle }}<a-icon v-if="ruleFlag" type="align-left" style="margin-left:5px;color: red;"></a-icon>
</span>
</a-tree>
<div v-else><h3>无可配置部门权限!</h3></div>
</a-form-item>
</a-form>
<div class="drawer-bootom-button">
<a-dropdown style="float: left" :trigger="['click']" placement="topCenter">
<a-menu slot="overlay">
<a-menu-item key="3" @click="checkALL">全部勾选</a-menu-item>
<a-menu-item key="4" @click="cancelCheckALL">取消全选</a-menu-item>
<a-menu-item key="5" @click="expandAll">展开所有</a-menu-item>
<a-menu-item key="6" @click="closeAll">合并所有</a-menu-item>
</a-menu>
<a-button>
树操作 <a-icon type="up" />
</a-button>
</a-dropdown>
<a-popconfirm title="确定放弃编辑" @confirm="close" okText="确定" cancelText="取消">
<a-button style="margin-right: .8rem">取消</a-button>
</a-popconfirm>
<a-button @click="handleSubmit(false)" type="primary" :loading="loading" ghost style="margin-right: 0.8rem">仅保存</a-button>
<a-button @click="handleSubmit(true)" type="primary" :loading="loading">保存并关闭</a-button>
</div>
<dept-role-datarule-modal ref="datarule"></dept-role-datarule-modal>
</a-drawer>
</template>
<script>
import {queryTreeListForDeptRole,queryDeptRolePermission,saveDeptRolePermission} from '@/api/api'
import RoleDataruleModal from './RoleDataruleModal.vue'
import DeptRoleDataruleModal from './DeptRoleDataruleModal'
export default {
name: "DeptRoleAuthModal",
components:{
DeptRoleDataruleModal,
RoleDataruleModal
},
data(){
return {
departId:"",
roleId:"",
treeData: [],
defaultCheckedKeys:[],
checkedKeys:[],
halfCheckedKeys:[],
expandedKeysss:[],
allTreeKeys:[],
autoExpandParent: true,
checkStrictly: false,
title:"部门角色权限配置",
visible: false,
loading: false,
selectedKeys:[]
}
},
methods: {
onTreeNodeSelect(id){
if(id && id.length>0){
this.selectedKeys = id
}
this.$refs.datarule.show(this.selectedKeys[0],this.departId,this.roleId)
},
onCheck (checkedKeys, { halfCheckedKeys }) {
// 保存选中的和半选中的,后面保存的时候合并提交
this.checkedKeys = checkedKeys
this.halfCheckedKeys = halfCheckedKeys
},
show(roleId,departId){
this.departId = departId
this.roleId=roleId
this.visible = true;
},
close () {
this.reset()
this.$emit('close');
this.visible = false;
},
onExpand(expandedKeys){
this.expandedKeysss = expandedKeys;
this.autoExpandParent = false
},
reset () {
this.expandedKeysss = []
this.checkedKeys = []
this.defaultCheckedKeys = []
this.loading = false
},
expandAll () {
this.expandedKeysss = this.allTreeKeys
},
closeAll () {
this.expandedKeysss = []
},
checkALL () {
this.checkedKeys = this.allTreeKeys
},
cancelCheckALL () {
this.checkedKeys = []
},
handleCancel () {
this.close()
},
handleSubmit(exit) {
let that = this;
let checkedKeys = [...that.checkedKeys, ...that.halfCheckedKeys]
const permissionIds = checkedKeys.join(",")
let params = {
roleId:that.roleId,
permissionIds,
lastpermissionIds:that.defaultCheckedKeys.join(","),
};
that.loading = true;
console.log("请求参数",params);
saveDeptRolePermission(params).then((res)=>{
if(res.success){
that.$message.success(res.message);
that.loading = false;
if (exit) {
that.close()
}
}else {
that.$message.error(res.message);
that.loading = false;
if (exit) {
that.close()
}
}
this.loadData();
})
},
convertTreeListToKeyLeafPairs(treeList, keyLeafPair = []) {
for(const {key, isLeaf, children} of treeList) {
keyLeafPair.push({key, isLeaf})
if(children && children.length > 0) {
this.convertTreeListToKeyLeafPairs(children, keyLeafPair)
}
}
return keyLeafPair;
},
loadData(){
queryTreeListForDeptRole({departId:this.departId}).then((res) => {
this.treeData = res.result.treeList
this.allTreeKeys = res.result.ids
const keyLeafPairs = this.convertTreeListToKeyLeafPairs(this.treeData)
queryDeptRolePermission({roleId:this.roleId}).then((res)=>{
// 过滤出 leaf node 即可,即选中的
// Tree组件中checkStrictly默认为false的时候选中子节点父节点会自动设置选中或半选中
// 保存 checkedKeys 以及 halfCheckedKeys 以便于未做任何操作时提交表单数据
const checkedKeys = [...res.result].filter(key => {
const keyLeafPair = keyLeafPairs.filter(item => item.key === key)[0]
return keyLeafPair && keyLeafPair.isLeaf
})
const halfCheckedKeys = [...res.result].filter(key => {
const keyLeafPair = keyLeafPairs.filter(item => item.key === key)[0]
return keyLeafPair && !keyLeafPair.isLeaf
})
this.checkedKeys = [...checkedKeys];
this.halfCheckedKeys = [...halfCheckedKeys]
this.defaultCheckedKeys = [...halfCheckedKeys, ...checkedKeys];
this.expandedKeysss = this.allTreeKeys;
})
})
}
},
watch: {
visible () {
if (this.visible ) {
this.loadData();
}
}
}
}
</script>
<style lang="scss" scoped>
.drawer-bootom-button {
position: absolute;
bottom: 0;
width: 100%;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
left: 0;
background: #fff;
border-radius: 0 0 2px 2px;
}
</style>

View File

@ -0,0 +1,122 @@
<template>
<a-drawer
title="数据规则/按钮权限配置"
width="365"
:closable="false"
@close="onClose"
:visible="visible"
>
<a-tabs defaultActiveKey="1">
<a-tab-pane tab="数据规则" key="1">
<a-checkbox-group v-model="dataruleChecked" v-if="dataruleList.length>0">
<a-row>
<a-col :span="24" v-for="(item,index) in dataruleList" :key=" 'dr'+index ">
<a-checkbox :value="item.id">{{ item.ruleName }}</a-checkbox>
</a-col>
<a-col :span="24">
<div style="width: 100%;margin-top: 15px">
<a-button @click="saveDataruleForRole" type="primary" size="small" icon="save">点击保存</a-button>
</div>
</a-col>
</a-row>
</a-checkbox-group>
<div v-else><h3>无配置信息!</h3></div>
</a-tab-pane>
<!--<a-tab-pane tab="按钮权限" key="2">敬请期待!!!</a-tab-pane>-->
</a-tabs>
</a-drawer>
</template>
<script>
import ARow from 'ant-design-vue/es/grid/Row'
import ACol from 'ant-design-vue/es/grid/Col'
import { getAction,postAction } from '@/api/manage'
export default {
name: 'DeptRoleDataruleModal',
components: { ACol, ARow },
data(){
return {
departId:'',
functionId:'',
roleId:'',
visible:false,
tabList: [{
key: '1',
tab: '数据规则',
}, {
key: '2',
tab: '按钮权限',
}],
activeTabKey: '1',
url:{
datarule:"/sys/sysDepartRole/datarule",
},
dataruleList:[],
dataruleChecked:[]
}
},
methods:{
loadData(){
getAction(`${this.url.datarule}/${this.functionId}/${this.departId}/${this.roleId}`).then(res=>{
console.log(res)
if(res.success){
this.dataruleList = res.result.datarule
let drChecked = res.result.drChecked
if(drChecked){
this.dataruleChecked = drChecked.split(",")
}
}
})
},
saveDataruleForRole(){
if(!this.dataruleChecked || this.dataruleChecked.length==0){
this.$message.warning("请注意,现未勾选任何数据权限!")
}
let params = {
permissionId:this.functionId,
roleId:this.roleId,
dataRuleIds:this.dataruleChecked.join(",")
}
console.log("保存数据权限",params)
postAction(this.url.datarule,params).then(res=>{
if(res.success){
this.$message.success(res.message)
}else{
this.$message.error(res.message)
}
})
},
show(functionId,departId,roleId){
this.onReset()
this.departId = departId
this.functionId = functionId
this.roleId = roleId
this.visible=true
this.loadData()
},
onClose(){
this.visible=false
this.onReset()
},
onTabChange (key) {
this.activeTabKey = key
},
onReset(){
this.functionId=''
this.roleId=''
this.dataruleList=[]
this.dataruleChecked=[]
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,196 @@
<template>
<a-card :bordered="false">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<!-- 搜索区域 -->
<a-form layout="inline">
<a-row :gutter="10">
<a-col :md="10" :sm="12">
<a-form-item label="部门角色名称" style="margin-left:8px">
<a-input placeholder="请输入部门角色" v-model="queryParam.roleName"></a-input>
</a-form-item>
</a-col>
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
<a-col :md="6" :sm="24">
<a-button type="primary" @click="searchQuery" icon="search" style="margin-left: 18px">查询</a-button>
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
</a-col>
</span>
</a-row>
</a-form>
</div>
<!-- 操作按钮区域 -->
<div class="table-operator" :md="24" :sm="24">
<a-button @click="handleAdd" type="primary" icon="plus">部门角色录入</a-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<a-menu slot="overlay">
<a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
</a-menu>
<a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
</a-dropdown>
</div>
<!-- table区域-begin -->
<div>
<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
<i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">
{{selectedRowKeys.length }}</a>项
<a style="margin-left: 24px" @click="onClearSelected">清空</a>
</div>
<a-table
ref="table"
size="middle"
bordered
rowKey="id"
:columns="columns"
:dataSource="dataSource"
:pagination="ipagination"
:loading="loading"
:rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
@change="handleTableChange">
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical"/>
<a-dropdown>
<a class="ant-dropdown-link">
更多 <a-icon type="down"/>
</a>
<a-menu slot="overlay">
<a-menu-item>
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
<a>删除</a>
</a-popconfirm>
</a-menu-item>
<a-menu-item>
<a href="javascript:;" @click="handleDetail(record)">详情</a>
</a-menu-item>
<a-menu-item>
<a @click="handlePerssion(record)">授权</a>
</a-menu-item>
</a-menu>
</a-dropdown>
</span>
</a-table>
</div>
<!-- table区域-end -->
<!-- 表单区域 -->
<sys-depart-role-modal ref="modalForm" @ok="modalFormOk"/>
<dept-role-auth-modal ref="modalDeptRole" />
</a-card>
</template>
<script>
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import {getAction} from '@/api/manage'
import SysDepartRoleModal from './SysDepartRoleModal'
import DeptRoleAuthModal from './DeptRoleAuthModal'
export default {
name: 'DeptRoleInfo',
components: { DeptRoleAuthModal, SysDepartRoleModal },
mixins: [JeecgListMixin],
data() {
return {
description: '部门角色信息',
currentDeptId: '',
// 表头
columns: [{
title: '部门角色名称',
align: "center",
dataIndex: 'roleName'
},
{
title: '部门角色编码',
align: "center",
dataIndex: 'roleCode'
},
{
title: '部门',
align: "center",
dataIndex: 'departId_dictText'
},
{
title: '备注',
align: "center",
dataIndex: 'description'
},
{
title: '操作',
dataIndex: 'action',
scopedSlots: {customRender: 'action'},
align: "center",
width: 170
}],
url: {
list: "/sys/sysDepartRole/list",
delete: "/sys/sysDepartRole/delete",
deleteBatch: "/sys/sysDepartRole/deleteBatch",
}
}
},
created() {
},
methods: {
searchReset() {
this.queryParam = {}
this.currentDeptId = '';
this.loadData(1);
this.$emit('clearSelectedDepartKeys')
},
loadData(arg) {
if (!this.url.list) {
this.$message.error("请设置url.list属性!")
return
}
//加载数据 若传入参数1则加载第一页的内容
if (arg === 1) {
this.ipagination.current = 1;
}
let params = this.getQueryParams();//查询条件
params.deptId = this.currentDeptId;
getAction(this.url.list, params).then((res) => {
if (res.success && res.result) {
this.dataSource = res.result.records;
this.ipagination.total = res.result.total;
}
})
},
open(record) {
this.currentDeptId = record.id;
this.loadData(1);
},
clearList() {
this.currentDeptId = '';
this.dataSource = [];
},
hasSelectDept() {
if (this.currentDeptId == '') {
this.$message.error("请选择一个部门!")
return false;
}
return true;
},
handleEdit: function (record) {
this.$refs.modalForm.title = "编辑";
this.$refs.modalForm.departDisabled = true;
this.$refs.modalForm.disableSubmit = false;
this.$refs.modalForm.edit(record,record.departId);
},
handleAdd: function () {
if (this.currentDeptId == '') {
this.$message.error("请选择一个部门!")
} else {
this.$refs.modalForm.departDisabled = true;
this.$refs.modalForm.add(this.currentDeptId);
this.$refs.modalForm.title = "新增";
}
},
handlePerssion: function(record){
this.$refs.modalDeptRole.show(record.id,record.departId);
},
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,200 @@
<template>
<a-drawer
:title="title"
:maskClosable="true"
width=600
placement="right"
:closable="true"
@close="close"
:visible="visible"
style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
<a-spin :spinning="confirmLoading">
<a-form :form="form" v-if="designNameOption.length>0">
<a-form-item label=''>
<a-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24">
<a-card :style="{ marginTop: '12px',height:'auto' }">
<a-checkbox-group @change="designNameChange" v-model="designNameValue" style="width: 100%">
<a-row>
<template v-for="(des) in designNameOption">
<a-col :span="6">
<a-checkbox :value="des.value">{{ des.text }}</a-checkbox>
</a-col>
</template>
</a-row>
</a-checkbox-group>
</a-card>
</a-col>
</a-form-item>
</a-form>
<div v-else><h3>无可配置角色!</h3></div>
</a-spin>
<div class="drawer-bootom-button">
<a-dropdown style="float: left" :trigger="['click']" placement="topCenter">
<a-menu slot="overlay">
<a-menu-item key="1" @click="checkALL">全部勾选</a-menu-item>
<a-menu-item key="2" @click="cancelCheckALL">取消全选</a-menu-item>
</a-menu>
<a-button>
操作 <a-icon type="up" />
</a-button>
</a-dropdown>
<a-popconfirm title="确定放弃编辑" @confirm="close" okText="确定" cancelText="取消">
<a-button style="margin-right: .8rem">取消</a-button>
</a-popconfirm>
<a-button @click="handleSubmit(true)" type="primary">保存</a-button>
</div>
</a-drawer>
</template>
<script>
import {httpAction, getAction} from '@/api/manage'
import JEllipsis from '@/components/jeecg/JEllipsis'
import {initDictOptions} from '@/components/dict/JDictSelectUtil'
export default {
name: 'DeptRoleUserModal',
components: {
JEllipsis
},
data() {
return {
currentDeptId:"",
title: "部门角色分配",
visible: false,
model: {},
labelCol: {
xs: {span: 24},
sm: {span: 5},
},
wrapperCol: {
xs: {span: 24},
sm: {span: 16},
},
confirmLoading: false,
form: this.$form.createForm(this),
validatorRules: {},
url: {
add: "/sys/sysDepartRole/deptRoleUserAdd",
getDeptRoleList:"/sys/sysDepartRole/getDeptRoleList",
getDeptRoleByUserId:"/sys/sysDepartRole/getDeptRoleByUserId"
},
designNameOption: [],
userId: "",
newRoleId:"",
oldRoleId:"",
designNameValue:[],
desformList: [],
}
},
created() {
},
methods: {
add(record,departId) {
this.userId = record.id;
this.currentDeptId = departId;
this.loadDesformList();
this.edit({});
},
edit(record) {
this.form.resetFields();
this.model = Object.assign({}, record);
this.visible = true;
getAction(this.url.getDeptRoleByUserId,{userId:this.userId}).then((res) => {
if (res.success) {
var designName = [];
for (let value of res.result) {
designName.push(value.droleId)
}
this.oldRoleId=designName.join(",");
this.designNameValue = designName;
this.newRoleId = designName.join(",");
}
});
},
close() {
this.$emit('close');
this.visible = false;
},
handleSubmit() {
const that = this;
// 触发表单验证
that.confirmLoading = true;
let httpurl = this.url.add;
let method = 'post';
let formData = Object.assign(this.model, {});
//时间格式化
formData.userId = this.userId;
formData.newRoleId=this.newRoleId;
formData.oldRoleId=this.oldRoleId;
httpAction(httpurl, formData, method).then((res) => {
if (res.success) {
that.$message.success(res.message);
that.$emit('reload');
that.$emit('ok');
} else {
that.$message.warning(res.message);
}
}).finally(() => {
that.confirmLoading = false;
that.close();
})
},
handleCancel() {
this.designNameOption=[];
this.designNameValue=[];
this.close()
},
designNameChange(selectedValue) {
this.newRoleId=selectedValue.join(",");
},
checkALL(){
var designName = [];
for (let value of this.desformList) {
designName.push(
value.id
)
}
this.designNameValue = designName;
this.newRoleId=designName.join(",");
},
cancelCheckALL(){
this.designNameValue=[];
this.newRoleId="";
},
/** 加载desform */
loadDesformList() {
getAction(this.url.getDeptRoleList, { departId: this.currentDeptId }).then((res) => {
if (res.success) {
this.desformList = res.result
var designName = [];
for (let value of this.desformList) {
designName.push({
value: value.id,
text: value.roleName,
})
}
this.designNameOption = designName;
}
});
},
}
}
</script>
<style scoped>
.drawer-bootom-button {
position: absolute;
bottom: 0;
width: 100%;
border-top: 1px solid #e8e8e8;
padding: 10px 16px;
text-align: right;
left: 0;
background: #fff;
border-radius: 0 0 2px 2px;
}
</style>

View File

@ -7,7 +7,7 @@
<a-row :gutter="10">
<a-col :md="10" :sm="12">
<a-form-item label="用户账号" style="margin-left:8px">
<a-input placeholder="请输入名称查询" v-model="queryParam.username"></a-input>
<a-input placeholder="请输入账号" v-model="queryParam.username"></a-input>
</a-form-item>
</a-col>
<!--<a-col :md="8" :sm="8">-->
@ -25,7 +25,7 @@
</a-form>
</div>
<!-- 操作按钮区域 -->
<div class="table-operator" :md="24" :sm="24" style="margin: -46px 0px 10px 2px">
<div class="table-operator" :md="24" :sm="24" style="margin-top: -15px">
<a-button @click="handleAdd" type="primary" icon="plus" style="margin-top: 16px">用户录入</a-button>
<!--<a-button @click="handleEdit" type="primary" icon="edit" style="margin-top: 16px">用户编辑</a-button>-->
<a-button @click="handleAddUserDepart" type="primary" icon="plus">添加已有用户</a-button>
@ -34,7 +34,7 @@
<a-menu slot="overlay">
<a-menu-item key="1" @click="batchDel">
<a-icon type="delete"/>
删除关系
取消关联
</a-menu-item>
</a-menu>
<a-button style="margin-left: 8px"> 批量操作
@ -80,10 +80,13 @@
</a-menu-item>
<a-menu-item>
<a-popconfirm title="确定要删除关系?" @confirm="() => handleDelete(record.id)">
<a>删除关系</a>
<a-popconfirm title="确定取消与选中部门关联?" @confirm="() => handleDelete(record.id)">
<a>取消关联</a>
</a-popconfirm>
</a-menu-item>
<a-menu-item>
<a href="javascript:;" @click="handleDeptRole(record)">分配部门角色</a>
</a-menu-item>
</a-menu>
</a-dropdown>
</span>
@ -96,6 +99,7 @@
<!-- 表单区域 -->
<user-modal ref="modalForm" @ok="modalFormOk"></user-modal>
<Select-User-Modal ref="selectUserModal" @selectFinished="selectOK"></Select-User-Modal>
<dept-role-user-modal ref="deptRoleUser"></dept-role-user-modal>
</a-card>
</template>
@ -104,11 +108,13 @@
import {getAction, postAction, deleteAction} from '@/api/manage'
import SelectUserModal from './SelectUserModal'
import UserModal from './UserModal'
import DeptRoleUserModal from './DeptRoleUserModal'
export default {
name: "DeptUserInfo",
mixins: [JeecgListMixin],
components: {
DeptRoleUserModal,
SelectUserModal,
UserModal
},
@ -127,6 +133,21 @@
align: "center",
dataIndex: 'realname'
},
{
title: '性别',
align: "center",
dataIndex: 'sex_dictText'
},
{
title: '电话',
align: "center",
dataIndex: 'phone'
},
{
title: '部门',
align: "center",
dataIndex: 'orgCode'
},
{
title: '操作',
dataIndex: 'action',
@ -146,7 +167,12 @@
},
methods: {
searchReset() {
this.queryParam = {}
this.currentDeptId = '';
this.loadData(1);
this.$emit('clearSelectedDepartKeys')
},
loadData(arg) {
if (!this.url.list) {
this.$message.error("请设置url.list属性!")
@ -156,11 +182,11 @@
if (arg === 1) {
this.ipagination.current = 1;
}
if (this.currentDeptId === '') return;
var params = this.getQueryParams();//查询条件
//if (this.currentDeptId === '') return;
let params = this.getQueryParams();//查询条件
params.depId = this.currentDeptId;
getAction(this.url.list, params).then((res) => {
if (res.success) {
if (res.success && res.result) {
this.dataSource = res.result.records;
this.ipagination.total = res.result.total;
}
@ -172,6 +198,11 @@
this.$message.error("请设置url.deleteBatch属性!")
return
}
if (!this.currentDeptId) {
this.$message.error("未选中任何部门无法取消部门与用户的关联!")
return
}
if (this.selectedRowKeys.length <= 0) {
this.$message.warning('请选择一条记录!');
return;
@ -183,12 +214,12 @@
var that = this;
console.log(this.currentDeptId);
this.$confirm({
title: "确认删除",
content: "是否删除选中数据?",
title: "确认取消",
content: "是否取消用户与选中部门的关联?",
onOk: function () {
deleteAction(that.url.deleteBatch, {depId: that.currentDeptId, userIds: ids}).then((res) => {
if (res.success) {
that.$message.success(res.message);
that.$message.success("删除用户与选中部门关系成功");
that.loadData();
that.onClearSelected();
} else {
@ -204,10 +235,15 @@
this.$message.error("请设置url.delete属性!")
return
}
if (!this.currentDeptId) {
this.$message.error("未选中任何部门无法取消部门与用户的关联!")
return
}
var that = this;
deleteAction(that.url.delete, {depId: this.currentDeptId, userId: id}).then((res) => {
if (res.success) {
that.$message.success(res.message);
that.$message.success("删除用户与选中部门关系成功");
if (this.selectedRowKeys.length>0){
for(let i =0; i<this.selectedRowKeys.length;i++){
if (this.selectedRowKeys[i] == id){
@ -232,14 +268,14 @@
this.dataSource = [];
},
hasSelectDept() {
if (this.currentDeptId == null) {
if (this.currentDeptId == '') {
this.$message.error("请选择一个部门!")
return false;
}
return true;
},
handleAddUserDepart() {
if (this.currentDeptId == '') {
if (this.currentDeptId == '' ) {
this.$message.error("请选择一个部门!")
} else {
this.$refs.selectUserModal.visible = true;
@ -277,6 +313,10 @@
this.$message.warning(res.message);
}
})
},
handleDeptRole(record){
this.$refs.deptRoleUser.add(record,this.currentDeptId);
this.$refs.deptRoleUser.title = "部门角色分配";
}
}
}

View File

@ -30,7 +30,7 @@
</template>
<script>
import {changPassword} from '@/api/api'
import {changePassword} from '@/api/api'
export default {
name: "PasswordModal",
@ -96,7 +96,7 @@
if (!err) {
this.confirmLoading = true;
let formData = Object.assign(this.model, values);
changPassword(formData).then((res)=>{
changePassword(formData).then((res)=>{
if(res.success){
this.$message.success(res.message);
this.$emit('ok');

View File

@ -13,13 +13,13 @@
<a-col :span="6">
<a-form-item label="账号">
<a-input placeholder="请输入账号查询" v-model="queryParam.username"></a-input>
<a-input placeholder="请输入账号" v-model="queryParam.username"></a-input>
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="性别">
<a-select v-model="queryParam.sex" placeholder="请选择性别查询">
<a-select v-model="queryParam.sex" placeholder="请选择性别">
<a-select-option value="">请选择性别查询</a-select-option>
<a-select-option value="1">男性</a-select-option>
<a-select-option value="2">女性</a-select-option>
@ -31,20 +31,20 @@
<template v-if="toggleSearchStatus">
<a-col :span="6">
<a-form-item label="邮箱">
<a-input placeholder="请输入邮箱查询" v-model="queryParam.email"></a-input>
<a-input placeholder="请输入邮箱" v-model="queryParam.email"></a-input>
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="手机号码">
<a-input placeholder="请输入手机号码查询" v-model="queryParam.phone"></a-input>
<a-input placeholder="请输入手机号码" v-model="queryParam.phone"></a-input>
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="状态">
<a-select v-model="queryParam.status" placeholder="请选择用户状态查询">
<a-select-option value="">请选择用户状态</a-select-option>
<a-select v-model="queryParam.status" placeholder="请选择状态">
<a-select-option value="">请选择状态</a-select-option>
<a-select-option value="1">正常</a-select-option>
<a-select-option value="2">解冻</a-select-option>
</a-select>
@ -101,7 +101,7 @@
fixed:'left',
width:200
},{
title: '真实姓名',
title: '用户名称',
align:"center",
dataIndex: 'realname',
},{

View File

@ -12,12 +12,12 @@
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline">
<a-form layout="inline" @keyup.enter.native="searchQuery">
<a-row :gutter="24">
<a-col :span="10">
<a-form-item label="姓名">
<a-input placeholder="请输入姓名" v-model="queryParam.username"></a-input>
<a-form-item label="用户账号">
<a-input placeholder="请输入用户账号" v-model="queryParam.username"></a-input>
</a-form-item>
</a-col>
<a-col :span="8">
@ -83,7 +83,7 @@
{
title: '用户账号',
align: "center",
width: 113,
width: 100,
dataIndex: 'username'
},
{
@ -93,10 +93,22 @@
dataIndex: 'realname'
},
{
title: '状态',
title: '性别',
align: "center",
width: 100,
dataIndex: 'status'
dataIndex: 'sex_dictText'
},
{
title: '电话',
align: "center",
width: 100,
dataIndex: 'phone'
},
{
title: '部门',
align: "center",
width: 150,
dataIndex: 'orgCode'
}
],
columns2: [

View File

@ -12,16 +12,16 @@
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-row class="form-row" :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
<a-col :lg="12">
<a-row style="width: 100%;">
<a-col :span="24/2">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="标题">
<a-input placeholder="请输入标题" v-decorator="['titile', validatorRules.title]" :readOnly="disableSubmit" style="width: 90%"/>
<a-input placeholder="请输入标题" v-decorator="['titile', validatorRules.title]" :readOnly="disableSubmit"/>
</a-form-item>
</a-col>
<a-col :lg="12">
<a-col :span="24/2">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
@ -30,76 +30,68 @@
v-decorator="[ 'msgCategory', validatorRules.msgCategory]"
placeholder="请选择消息类型"
:disabled="disableSubmit"
:getPopupContainer = "(target) => target.parentNode"
style="width: 80%" >
:getPopupContainer = "(target) => target.parentNode">
<a-select-option value="1">通知公告</a-select-option>
<a-select-option value="2">系统消息</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row class="form-row" :gutter="24">
<a-col :lg="12">
<a-row style="width: 100%;">
<a-col :span="24/2">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="开始时间:"
style="margin-left: 27px">
<j-date v-decorator="[ 'startTime', validatorRules.startTime]" placeholder="请选择开始时间" showTime dateFormat="YYYY-MM-DD HH:mm:ss" ></j-date>
label="开始时间:">
<j-date style="width: 100%" :getCalendarContainer="node => node.parentNode" v-decorator="[ 'startTime', validatorRules.startTime]" placeholder="请选择开始时间" showTime dateFormat="YYYY-MM-DD HH:mm:ss" ></j-date>
</a-form-item>
</a-col>
<a-col :lg="12">
<a-col :span="24/2">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="结束时间"
class="endTime">
<j-date v-decorator="[ 'endTime', validatorRules.endTime]" placeholder="请选择结束时间" showTime dateFormat="YYYY-MM-DD HH:mm:ss"></j-date>
<j-date style="width: 100%" :getCalendarContainer="node => node.parentNode" v-decorator="[ 'endTime', validatorRules.endTime]" placeholder="请选择结束时间" showTime dateFormat="YYYY-MM-DD HH:mm:ss"></j-date>
</a-form-item>
</a-col>
</a-row>
<a-row class="form-row" :gutter="32">
<a-col :lg="9">
<a-row style="width: 100%;">
<a-col :span="24/2">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="优先级"
style="margin-left: 27px">
label="优先级">
<a-select
v-decorator="[ 'priority', {}]"
placeholder="请选择优先级"
:disabled="disableSubmit"
:getPopupContainer = "(target) => target.parentNode"
style="margin-left: 5px;width: 135%">
:getPopupContainer = "(target) => target.parentNode">
<a-select-option value="L">低</a-select-option>
<a-select-option value="M">中</a-select-option>
<a-select-option value="H">高</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :lg="15" push="3">
<a-col :span="24/2">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="通告对象类型"
style="margin-left: -14px">
label="通告类型">
<a-select
v-decorator="[ 'msgType', validatorRules.msgType]"
placeholder="请选择通告对象类型"
placeholder="请选择通告类型"
:disabled="disableSubmit"
@change="chooseMsgType"
:getPopupContainer = "(target) => target.parentNode"
style="width: 200px;margin-left: 5px">
:getPopupContainer = "(target) => target.parentNode">
<a-select-option value="USER">指定用户</a-select-option>
<a-select-option value="ALL">全体用户</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :lg="24" pull="2">
<a-row style="width: 100%;">
<a-col :span="24/2">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
@ -110,20 +102,19 @@
placeholder="请选择用户"
v-model="selectedUser"
@dropdownVisibleChange="selectUserIds"
style="width: 119%"
>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row>
<a-col :lg="24" pull="3">
<a-row style="width: 100%;">
<a-col :span="24">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
:labelCol="labelColX1"
:wrapperCol="wrapperColX1"
label="内容"
style="margin-left: 5px">
<j-editor style="width: 130%" v-decorator="[ 'msgContent', {} ]" triggerChange></j-editor>
class="j-field-content">
<j-editor v-decorator="[ 'msgContent', {} ]" triggerChange></j-editor>
</a-form-item>
</a-col>
</a-row>
@ -153,11 +144,19 @@
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
sm: { span: 6 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
sm: { span: 18 },
},
labelColX1: {
xs: { span: 24 },
sm: { span: 3 },
},
wrapperColX1: {
xs: { span: 24 },
sm: { span: 21 },
},
confirmLoading: false,

View File

@ -0,0 +1,379 @@
<template>
<a-modal
:title="title"
:width="1000"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="规则名称">
<a-input placeholder="请输入规则名称" v-decorator="['ruleName', validatorRules.ruleName]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="规则Code">
<a-input placeholder="请输入规则Code" v-decorator="['ruleCode', validatorRules.ruleCode]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="规则描述">
<a-textarea placeholder="请输入规则描述" v-decorator="['ruleDescription', {}]"/>
</a-form-item>
</a-form>
<!-- 规则设计 -->
<a-tabs v-model="tabs.activeKey">
<a-tab-pane tab="局部规则" :key="tabs.design.key" forceRender>
<a-alert type="info" showIcon message="局部规则按照你输入的位数有序的校验。"/>
<j-editable-table
ref="designTable"
dragSort
rowNumber
:maxHeight="240"
:columns="tabs.design.columns"
:dataSource="tabs.design.dataSource"
style="margin-top: 8px;"
>
<template #action="props">
<my-action-button :rowEvent="props"/>
</template>
</j-editable-table>
</a-tab-pane>
<a-tab-pane tab="全局规则" :key="tabs.global.key" forceRender>
<j-editable-table
ref="globalTable"
dragSort
rowNumber
actionButton
:maxHeight="240"
:columns="tabs.global.columns"
:dataSource="tabs.global.dataSource"
>
<template #actionButtonAfter>
<a-alert type="info" showIcon message="全局规则可校验用户输入的所有字符;全局规则的优先级比局部规则的要高。" style="margin-bottom: 8px;"/>
</template>
<template #action="props">
<my-action-button :rowEvent="props" allowEmpty/>
</template>
</j-editable-table>
</a-tab-pane>
</a-tabs>
</a-spin>
</a-modal>
</template>
<script>
import pick from 'lodash.pick'
import { httpAction } from '@/api/manage'
import { validateDuplicateValue, alwaysResolve, failedSymbol } from '@/utils/util'
import { FormTypes } from '@/utils/JEditableTableUtil'
import JEditableTable from '@comp/jeecg/JEditableTable'
export default {
name: 'SysCheckRuleModal',
components: {
JEditableTable,
'my-action-button': {
props: { rowEvent: Object, allowEmpty: Boolean },
methods: {
confirmIsShow() {
const { index, allValues: { inputValues } } = this.rowEvent
let value = inputValues[index]
return value.digits || value.pattern
},
handleLineAdd() {
const { target } = this.rowEvent
target.add()
},
handleLineDelete() {
const { rowId, target } = this.rowEvent
target.removeRows(rowId)
},
renderDeleteButton() {
if (this.allowEmpty || this.rowEvent.index > 0) {
if (this.confirmIsShow()) {
return (
<a-popconfirm title="确定要删除吗?" onConfirm={this.handleLineDelete}>
<a-button icon="minus"/>
</a-popconfirm>
)
} else {
return (
<a-button icon="minus" onClick={this.handleLineDelete}/>
)
}
}
return ''
},
},
render() {
return (
<div>
<a-button onClick={this.handleLineAdd} icon="plus"/>
&nbsp;
{this.renderDeleteButton()}
</div>
)
}
}
},
data() {
return {
title: '操作',
visible: false,
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
form: this.$form.createForm(this),
validatorRules: {
ruleName: { rules: [{ required: true, message: '请输入规则名称!' },] },
ruleCode: {
rules: [
{ required: true, message: '请输入规则Code!' },
{ validator: (rule, value, callback) => validateDuplicateValue('sys_check_rule', 'rule_code', value, this.model.id, callback) }
]
},
},
tabs: {
activeKey: 'design',
global: {
key: 'global',
columns: [
{
title: '优先级',
key: 'priority',
width: '15%',
type: FormTypes.select,
defaultValue: '1',
options: [
{ title: '优先运行', value: '1' },
{ title: '最后运行', value: '0' },
],
validateRules: []
},
{
title: '规则正则表达式',
key: 'pattern',
width: '50%',
type: FormTypes.input,
validateRules: [
{ required: true, message: '规则不能为空' },
{ handler: this.validatePatternHandler },
]
},
{
title: '提示文本',
key: 'message',
width: '20%',
type: FormTypes.input,
validateRules: [
{ required: true, message: '${title}不能为空' },
]
},
{
title: '操作',
key: 'action',
width: '15%',
slotName: 'action',
type: FormTypes.slot
}
],
dataSource: [],
},
design: {
key: 'design',
columns: [
{
title: '位数',
key: 'digits',
width: '15%',
type: FormTypes.inputNumber,
validateRules: [
{ required: true, message: '${title}不能为空' },
{ pattern: /^[1-9]\d*$/, message: '请输入零以上的正整数' },
]
},
{
title: '规则正则表达式',
key: 'pattern',
width: '50%',
type: FormTypes.input,
validateRules: [
{ required: true, message: '规则不能为空' },
{ handler: this.validatePatternHandler }
]
},
{
title: '提示文本',
key: 'message',
width: '20%',
type: FormTypes.input,
validateRules: [
{ required: true, message: '${title}不能为空' },
]
},
{
title: '操作',
key: 'action',
width: '15%',
slotName: 'action',
type: FormTypes.slot
},
],
dataSource: [],
}
},
url: {
add: '/sys/checkRule/add',
edit: '/sys/checkRule/edit',
},
}
},
created() {
},
methods: {
validatePatternHandler(type, value, row, column, callback, target) {
if (type === 'blur' || type === 'getValues') {
try {
new RegExp(value)
callback(true)
} catch (e) {
callback(false, '请输入正确的正则表达式')
}
} else {
callback(true) // 不填写或者填写 null 代表不进行任何操作
}
},
add() {
this.edit({})
},
edit(record) {
this.form.resetFields()
this.tabs.activeKey = this.tabs.design.key
this.tabs.global.dataSource = []
this.tabs.design.dataSource = [{ digits: '', pattern: '', message: '' }]
this.model = Object.assign({}, record)
this.visible = true
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'ruleName', 'ruleCode', 'ruleDescription'))
// 子表数据
let ruleJson = this.model.ruleJson
if (ruleJson) {
let ruleList = JSON.parse(ruleJson)
// 筛选出全局规则和局部规则
let global = [], design = [], priority = '1'
ruleList.forEach(rule => {
if (rule.digits === '*') {
global.push(Object.assign(rule, { priority }))
} else {
priority = '0'
design.push(rule)
}
})
this.tabs.global.dataSource = global
this.tabs.design.dataSource = design
}
})
},
close() {
this.$emit('close')
this.visible = false
},
handleOk() {
Promise.all([
// 主表单校验
alwaysResolve(new Promise((resolve, reject) => {
this.form.validateFields((error, values) => error ? reject(error) : resolve(values))
})),
// 局部规则子表校验
alwaysResolve(this.$refs.designTable.getValuesPromise),
// 全局规则子表校验
alwaysResolve(this.$refs.globalTable.getValuesPromise),
]).then(results => {
let [mainResult, designResult, globalResult] = results
if (mainResult.type === failedSymbol) {
return Promise.reject('主表校验未通过')
} else if (designResult.type === failedSymbol) {
this.tabs.activeKey = this.tabs.design.key
return Promise.reject('局部规则子表校验未通过')
} else if (globalResult.type === failedSymbol) {
this.tabs.activeKey = this.tabs.global.key
return Promise.reject('全局规则子表校验未通过')
} else {
// 所有校验已通过,这一步是整合数据
let mainValues = mainResult.data, globalValues = globalResult.data, designValues = designResult.data
// 整合两个子表的数据
let firstGlobal = [], afterGlobal = []
globalValues.forEach(v => {
v.digits = '*'
if (v.priority === '1') {
firstGlobal.push(v)
} else {
afterGlobal.push(v)
}
})
let concatValues = firstGlobal.concat(designValues).concat(afterGlobal)
let subValues = concatValues.map(i => pick(i, 'digits', 'pattern', 'message'))
// 生成 formData用于传入后台
let ruleJson = JSON.stringify(subValues)
let formData = Object.assign(this.model, mainValues, { ruleJson })
// 判断请求方式和请求地址,并发送请求
let method = 'post', httpUrl = this.url.add
if (this.model.id) {
method = 'put'
httpUrl = this.url.edit
}
this.confirmLoading = true
return httpAction(httpUrl, formData, method)
}
}).then((res) => {
if (res.success) {
this.$message.success(res.message)
this.$emit('ok')
this.close()
} else {
this.$message.warning(res.message)
}
}).catch(e => {
console.error(e)
}).finally(() => {
this.confirmLoading = false
})
},
handleCancel() {
this.close()
},
}
}
</script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,58 @@
<template>
<a-modal
title="功能测试"
:width="800"
:visible="visible"
@ok="visible=false"
@cancel="visible=false"
>
<a-form :form="form">
<a-form-item label="功能测试">
<a-input placeholder="请输入" v-decorator="['test', validatorRules.test]" @change="e=>testValue=e.target.value"/>
</a-form-item>
</a-form>
<a-row type="flex" :gutter="8">
<a-col v-for="(str,index) of testValue">
<a-row>
<a-col>
<a-input :value="str" style="text-align: center;width: 40px;"/>
</a-col>
<a-col style="text-align: center;">{{index+1}}</a-col>
</a-row>
</a-col>
</a-row>
</a-modal>
</template>
<script>
import { validateCheckRule } from '@/utils/util'
export default {
name: 'SysCheckRuleModal',
data() {
return {
title: '操作',
visible: false,
ruleCode: '',
testValue: '',
form: this.$form.createForm(this),
validatorRules: {
test: {
rules: [{ validator: (rule, value, callback) => validateCheckRule(this.ruleCode, value, callback) }]
}
},
}
},
methods: {
open(ruleCode) {
this.ruleCode = ruleCode
this.form.resetFields()
this.testValue = ''
this.visible = true
},
}
}
</script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,227 @@
<template>
<a-modal
:title="title"
:width="800"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="数据源名称">
<a-input placeholder="请输入数据源名称" v-decorator="['name', validatorRules.name]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="数据源编码">
<a-input placeholder="请输入数据源编码" :disabled="!!model.id" v-decorator="['code', validatorRules.code]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="数据库类型">
<j-dict-select-tag placeholder="请选择数据库类型" dict-code="database_type" triggerChange v-decorator="['dbType', validatorRules.dbType]" @change="handleDbTypeChange"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="驱动类">
<a-input placeholder="请输入驱动类" v-decorator="['dbDriver', validatorRules.dbDriver]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="数据源地址">
<a-input placeholder="请输入数据源地址" v-decorator="['dbUrl', validatorRules.dbUrl]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="数据库名称">
<a-input placeholder="请输入数据库名称" v-decorator="['dbName', validatorRules.dbName]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="用户名">
<a-input placeholder="请输入用户名" v-decorator="['dbUsername', validatorRules.dbUsername]"/>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="密码">
<a-row :gutter="8">
<a-col :span="21">
<a-input-password placeholder="请输入密码" v-decorator="['dbPassword', validatorRules.dbPassword]"/>
</a-col>
<a-col :span="3">
<a-button type="primary" size="small" style="width: 100%" @click="handleTest">测试</a-button>
</a-col>
</a-row>
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="备注">
<a-textarea placeholder="请输入备注" v-decorator="['remark', {}]"/>
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
import pick from 'lodash.pick'
import { httpAction, postAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'
export default {
name: 'SysDataSourceModal',
components: {},
data() {
return {
title: '操作',
visible: false,
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
form: this.$form.createForm(this),
validatorRules: {
code: {
validateFirst: true,
rules: [
{ required: true, message: '请输入数据源编码!' },
{
validator: (rule, value, callback) => {
let pattern = /^[a-z|A-Z][a-z|A-Z\d_-]{0,}$/
if (!pattern.test(value)) {
callback('编码必须以字母开头可包含数字下划线横杠')
} else {
validateDuplicateValue('sys_data_source', 'code', value, this.model.id, callback)
}
}
}
]
},
name: { rules: [{ required: true, message: '请输入数据源名称!' }] },
dbType: { rules: [{ required: true, message: '请选择数据库类型!' }] },
dbDriver: { rules: [{ required: true, message: '请输入驱动类!' }] },
dbUrl: { rules: [{ required: true, message: '请输入数据源地址!' }] },
dbName: { rules: [{ required: true, message: '请输入数据库名称!' }] },
dbUsername: { rules: [{ required: true, message: '请输入用户名!' }] },
dbPassword: { rules: [{ required: true, message: '请输入密码!' }] }
},
url: {
add: '/sys/dataSource/add',
edit: '/sys/dataSource/edit',
},
dbDriverMap: {
// MySQL 数据库
'1': { dbDriver: 'com.mysql.jdbc.Driver' },
// Oracle
'2': { dbDriver: 'oracle.jdbc.OracleDriver' },
// SQLServer 数据库
'3': { dbDriver: 'com.microsoft.sqlserver.jdbc.SQLServerDriver' },
}
}
},
created() {
},
methods: {
add() {
this.edit({})
},
edit(record) {
this.form.resetFields()
this.model = Object.assign({}, record)
this.visible = true
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model, 'code', 'name', 'remark', 'dbType', 'dbDriver', 'dbUrl', 'dbName', 'dbUsername', 'dbPassword'))
})
},
close() {
this.$emit('close')
this.visible = false
},
handleOk() {
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
this.confirmLoading = true
let formData = Object.assign(this.model, values)
let httpUrl = this.url.add, method = 'post'
if (this.model.id) {
httpUrl = this.url.edit
method = 'put'
// 由于编码的特殊性,所以不能更改
formData['code'] = undefined
}
httpAction(httpUrl, formData, method).then((res) => {
if (res.success) {
this.$message.success(res.message)
this.$emit('ok')
this.close()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.confirmLoading = false
})
}
})
},
handleCancel() {
this.close()
},
// 测试数据源配置是否可以正常连接
handleTest() {
let keys = ['dbType', 'dbDriver', 'dbUrl', 'dbName', 'dbUsername', 'dbPassword']
// 获取以上字段的值,并清除校验状态
let fieldsValues = this.form.getFieldsValue(keys)
let setFields = {}
keys.forEach(key => setFields[key] = { value: fieldsValues[key], errors: null })
// 清除校验状态,目的是可以让错误文字闪烁
this.form.setFields(setFields)
// 重新校验
this.$nextTick(() => {
this.form.validateFields(keys, (errors, values) => {
if (!errors) {
let loading = this.$message.loading('连接中', 0)
postAction('/online/cgreport/api/testConnection', fieldsValues).then(res => {
if (res.success) {
this.$message.success('连接成功')
} else throw new Error(res.message)
}).catch(error => {
this.$warning({ title: '连接失败', content: error.message || error })
}).finally(() => loading())
}
})
})
},
// 数据库类型更改时,联动更改数据库驱动
handleDbTypeChange(val) {
let dbDriver = this.dbDriverMap[val]
if (dbDriver) {
this.form.setFieldsValue(dbDriver)
}
},
}
}
</script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,162 @@
<template>
<a-modal
:title="title"
:width="800"
:visible="visible"
:confirmLoading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel"
cancelText="关闭">
<a-spin :spinning="confirmLoading">
<a-form :form="form">
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="部门角色名称">
<a-input placeholder="请输入部门角色名称" v-decorator="['roleName', validatorRules.roleName]" />
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="部门角色编码">
<a-input placeholder="请输入部门角色编码" v-decorator="['roleCode', validatorRules.roleCode]" />
</a-form-item>
<a-form-item
:labelCol="labelCol"
:wrapperCol="wrapperCol"
label="描述">
<a-input placeholder="请输入描述" v-decorator="['description', validatorRules.description]" />
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</template>
<script>
import { httpAction } from '@/api/manage'
import pick from 'lodash.pick'
import {duplicateCheck } from '@/api/api'
export default {
name: "SysDepartRoleModal",
data () {
return {
title:"操作",
visible: false,
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 5 },
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 16 },
},
confirmLoading: false,
form: this.$form.createForm(this),
validatorRules:{
roleName:{
rules: [
{ required: true, message: '请输入部门角色名称!' },
{ min: 2, max: 30, message: '长度在 2 30 个字符', trigger: 'blur' }
]},
roleCode:{
rules: [
{ required: true, message: '请输入部门角色编码!'},
{ min: 0, max: 64, message: '长度不超过 64 个字符', trigger: 'blur' },
{ validator: this.validateRoleCode}
]},
description:{
rules: [
{ min: 0, max: 126, message: '长度不超过 126 个字符', trigger: 'blur' }
]}
},
url: {
add: "/sys/sysDepartRole/add",
edit: "/sys/sysDepartRole/edit",
},
}
},
created () {
},
methods: {
add (departId) {
this.edit({},departId);
},
edit (record,departId) {
this.departId = departId;
this.form.resetFields();
this.model = Object.assign({}, record);
this.visible = true;
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.model,'roleName','roleCode','description'))
});
},
close () {
this.$emit('close');
this.visible = false;
},
handleOk () {
const that = this;
// 触发表单验证
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true;
let httpurl = '';
let method = '';
if(!this.model.id){
httpurl+=this.url.add;
method = 'post';
}else{
httpurl+=this.url.edit;
method = 'put';
}
let formData = Object.assign(this.model, values);
formData.departId = this.departId;
httpAction(httpurl,formData,method).then((res)=>{
if(res.success){
that.$message.success(res.message);
that.$emit('ok');
}else{
that.$message.warning(res.message);
}
}).finally(() => {
that.confirmLoading = false;
that.close();
})
}
})
},
handleCancel () {
this.close()
},
validateRoleCode(rule, value, callback){
if(/[\u4E00-\u9FA5]/g.test(value)){
callback("部门角色编码不可输入汉字!");
}else{
var params = {
tableName: "sys_depart_role",
fieldName: "role_code",
fieldVal: value,
dataId: this.model.id,
};
duplicateCheck(params).then((res)=>{
if(res.success){
callback();
}else{
callback(res.message);
}
});
}
}
}
}
</script>
<style lang="less" scoped>
</style>

View File

@ -36,8 +36,8 @@
</a-form-item>
</template>
<a-form-item label="用户名" :labelCol="labelCol" :wrapperCol="wrapperCol" >
<a-input placeholder="请输入用户名" v-decorator="[ 'realname', validatorRules.realname]" />
<a-form-item label="用户" :labelCol="labelCol" :wrapperCol="wrapperCol" >
<a-input placeholder="请输入用户" v-decorator="[ 'realname', validatorRules.realname]" />
</a-form-item>
<a-form-item label="工号" :labelCol="labelCol" :wrapperCol="wrapperCol">
@ -71,23 +71,33 @@
<a-button slot="enterButton" icon="search">选择</a-button>
</a-input-search>
</a-form-item>
<a-form-item label="头像" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-upload
listType="picture-card"
class="avatar-uploader"
:showUploadList="false"
:action="uploadAction"
:data="{'isup':1}"
:headers="headers"
:beforeUpload="beforeUpload"
@change="handleChange"
<!-- update--begin--autor:wangshuai-----date:20200108------for新增身份和负责部门------ -->
<a-form-item label="身份" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-radio-group
v-model="identity"
@change="identityChange">
<a-radio value="1">普通用户</a-radio>
<a-radio value="2">上级</a-radio>
</a-radio-group>
</a-form-item>
<a-form-item label="负责部门" :labelCol="labelCol" :wrapperCol="wrapperCol" v-if="departIdShow==true">
<a-select
mode="multiple"
style="width: 100%"
placeholder="请选择负责部门"
v-model="departIds"
optionFilterProp = "children"
:getPopupContainer = "(target) => target.parentNode"
:dropdownStyle="{maxHeight:'200px',overflow:'auto'}"
>
<img v-if="picUrl" :src="getAvatarView()" alt="头像" style="height:104px;max-width:300px"/>
<div v-else>
<a-icon :type="uploadLoading ? 'loading' : 'plus'" />
<div class="ant-upload-text">上传</div>
</div>
</a-upload>
<a-select-option v-for="item in resultDepartOptions" :key="item.key" :value="item.key"
>{{item.title}}</a-select-option
>
</a-select>
</a-form-item>
<!-- update--end--autor:wangshuai-----date:20200108------for新增身份和负责部门------ -->
<a-form-item label="头像" :labelCol="labelCol" :wrapperCol="wrapperCol">
<j-image-upload class="avatar-uploader" text="上传" v-model="fileList" ></j-image-upload>
</a-form-item>
<a-form-item label="生日" :labelCol="labelCol" :wrapperCol="wrapperCol">
@ -145,10 +155,12 @@
import {addUser,editUser,queryUserRole,queryall } from '@/api/api'
import { disabledAuthFilter } from "@/utils/authFilter"
import {duplicateCheck } from '@/api/api'
import JImageUpload from '../../../components/jeecg/JImageUpload'
export default {
name: "UserModal",
components: {
JImageUpload,
departWindow,
JSelectPosition
},
@ -164,6 +176,7 @@
checkedDepartKeys:[],
checkedDepartNames:[], // 保存部门的名称 =>title
checkedDepartNameString:"", // 保存部门的名称 =>title
resultDepartOptions:[],
userId:"", //保存用户id
disableSubmit:false,
userDepartModel:{userId:'',departIdList:[]}, // 保存SysUserDepart的用户部门中间表数据需要的对象
@ -213,6 +226,8 @@
]
}
},
departIdShow:false,
departIds:[], //负责部门id
title:"操作",
visible: false,
model: {},
@ -233,11 +248,13 @@
picUrl: "",
url: {
fileUpload: window._CONFIG['domianURL']+"/sys/common/upload",
imgerver: window._CONFIG['domianURL']+"/sys/common/view",
imgerver: window._CONFIG['staticDomainURL'],
userWithDepart: "/sys/user/userDepartList", // 引入为指定用户查看部门信息需要的url
userId:"/sys/user/generateUserId", // 引入生成添加用户情况下的url
syncUserByUserName:"/process/extActProcess/doSyncUserByUserName",//同步用户到工作流
},
identity:"1",
fileList:[],
}
},
created () {
@ -287,6 +304,9 @@
this.checkedDepartNames=[];
this.checkedDepartNameString = "";
this.userId=""
this.resultDepartOptions=[];
this.departId=[];
this.departIdShow=false;
},
add () {
this.picUrl = "";
@ -301,7 +321,9 @@
that.form.resetFields();
if(record.hasOwnProperty("id")){
that.loadUserRoles(record.id);
this.picUrl = "Has no pic url yet";
setTimeout(() => {
this.fileList = record.avatar;
}, 5)
}
that.userId = record.id;
that.visible = true;
@ -309,6 +331,14 @@
that.$nextTick(() => {
that.form.setFieldsValue(pick(this.model,'username','sex','realname','email','phone','activitiSync','workNo','telephone','post'))
});
//身份为上级显示负责部门,否则不显示
if(this.model.identity=="2"){
this.identity="2";
this.departIdShow=true;
}else{
this.identity="1";
this.departIdShow=false;
}
// 调用查询用户对应的部门信息的方法
that.checkedDepartKeys = [];
that.loadCheckedDeparts();
@ -320,10 +350,25 @@
getAction(that.url.userWithDepart,{userId:that.userId}).then((res)=>{
that.checkedDepartNames = [];
if(res.success){
var depart=[];
var departId=[];
for (let i = 0; i < res.result.length; i++) {
that.checkedDepartNames.push(res.result[i].title);
this.checkedDepartNameString = this.checkedDepartNames.join(",");
that.checkedDepartKeys.push(res.result[i].key);
//新增负责部门选择下拉框
depart.push({
key:res.result[i].key,
title:res.result[i].title
})
departId.push(res.result[i].key)
}
that.resultDepartOptions=depart;
//判断部门id是否存在不存在择直接默认当前所在部门
if(this.model.departIds){
this.departIds=this.model.departIds.split(",");
}else{
this.departIds=departId;
}
that.userDepartModel.departIdList = that.checkedDepartKeys
}else{
@ -341,6 +386,11 @@
this.checkedDepartNameString='';
this.checkedDepartKeys = [];
this.selectedDepartKeys = [];
this.resultDepartOptions=[];
this.departIds=[];
this.departIdShow=false;
this.identity="1";
this.fileList=[];
},
moment,
handleSubmit () {
@ -350,17 +400,22 @@
this.form.validateFields((err, values) => {
if (!err) {
that.confirmLoading = true;
let avatar = that.model.avatar;
if(!values.birthday){
values.birthday = '';
}else{
values.birthday = values.birthday.format(this.dateFormat);
}
let formData = Object.assign(this.model, values);
formData.avatar = avatar;
formData.avatar = that.fileList;
formData.selectedroles = this.selectedRole.length>0?this.selectedRole.join(","):'';
formData.selecteddeparts = this.userDepartModel.departIdList.length>0?this.userDepartModel.departIdList.join(","):'';
formData.identity=this.identity;
//如果是上级择传入departIds,否则为空
if(this.identity==="2"){
formData.departIds=this.departIds.join(",");
}else{
formData.departIds="";
}
// that.addDepartsToUser(that,formData); // 调用根据当前用户添加部门信息的方法
let obj;
if(!this.model.id){
@ -380,7 +435,6 @@
that.confirmLoading = false;
that.checkedDepartNames = [];
that.userDepartModel.departIdList = {userId:'',departIdList:[]};
that.close();
})
@ -528,9 +582,6 @@
}
}
},
getAvatarView(){
return this.url.imgerver +"/"+ this.model.avatar;
},
// 搜索用户对应的部门API
onSearch(){
this.$refs.departWindow.add(this.checkedDepartKeys,this.userId);
@ -543,11 +594,21 @@
this.checkedDepartNameString = '';
this.userId = formData.userId;
this.userDepartModel.userId = formData.userId;
this.departIds=[];
this.resultDepartOptions=[];
var depart=[];
for (let i = 0; i < formData.departIdList.length; i++) {
this.selectedDepartKeys.push(formData.departIdList[i].key);
this.checkedDepartNames.push(formData.departIdList[i].title);
this.checkedDepartNameString = this.checkedDepartNames.join(",");
//新增部门选择,如果上面部门选择后不为空直接付给负责部门
depart.push({
key:formData.departIdList[i].key,
title:formData.departIdList[i].title
})
this.departIds.push(formData.departIdList[i].key)
}
this.resultDepartOptions=depart;
this.userDepartModel.departIdList = this.selectedDepartKeys;
this.checkedDepartKeys = this.selectedDepartKeys //更新当前的选择keys
},
@ -560,6 +621,13 @@
this.drawerWidth = 700;
}
},
identityChange(e){
if(e.target.value==="1"){
this.departIdShow=false;
}else{
this.departIdShow=true;
}
}
}
}
</script>

View File

@ -0,0 +1,191 @@
<template>
<a-modal
:width="1000"
:title="title"
:visible="innerVisible"
@cancel="handleCancel"
cancelText="关闭"
:okButtonProps="{style:{display:'none'}}"
>
<a-alert type="info" showIcon style="margin-bottom: 16px;">
<template slot="message">
<span>已选择</span>
<a style="font-weight: 600;padding: 0 4px;">{{ selectedRowKeys.length }}</a>
<span></span>
<template v-if="selectedRowKeys.length>0">
<a-divider type="vertical"/>
<a @click="handleClearSelection">清空选择</a>
<a-divider type="vertical"/>
<a @click="handleRevertBatch">批量还原</a>
<a-divider type="vertical"/>
<a @click="handleDeleteBatch">批量删除</a>
</template>
</template>
</a-alert>
<a-table
ref="table"
rowKey="id"
size="middle"
bordered
:columns="columns"
:loading="loading"
:dataSource="dataSource"
:pagination="false"
:rowSelection="{selectedRowKeys, onChange: handleTableSelectChange}"
>
<!-- 显示头像 -->
<template slot="avatarslot" slot-scope="text, record, index">
<div class="anty-img-wrap">
<a-avatar shape="square" :src="url.getAvatar(record.avatar)" icon="user"/>
</div>
</template>
<span slot="action" slot-scope="text, record">
<a @click="handleRevert([record.id])"><a-icon type="redo"/> 还原用户</a>
<a-divider type="vertical"/>
<a @click="handleDelete([record.id])"><a-icon type="delete"/> 彻底删除</a>
</span>
</a-table>
</a-modal>
</template>
<script>
// 高度封装的请求,请务必使用 superRequest.call(this,{}) 的方式调用
function superRequest(options) {
this.loading = !!options.loading
options.promise.then(res => {
if (res.success && typeof options.success === 'function') {
options.success(res)
} else {
throw new Error(res.message)
}
}).catch(e => {
console.error('查询已删除的用户失败:', e)
this.$message.warning('查询已删除的用户失败:' + (e.message || e))
}).finally(() => {
this.loading = false
})
}
export default {
name: 'UserRecycleBinModal',
props: {
visible: {
type: Boolean,
default: false
},
},
data() {
return {
title: '用户回收站',
loading: false,
innerVisible: false,
selectedRowKeys: [],
dataSource: [],
columns: [
{ title: '#', align: 'center', key: 'rowIndex', width: 80, customRender: (t, r, i) => i + 1 },
{ title: '账号', align: 'center', dataIndex: 'username' },
{ title: '姓名', align: 'center', dataIndex: 'realname', },
{ title: '头像', align: 'center', dataIndex: 'avatar', scopedSlots: { customRender: 'avatarslot' } },
{ title: '部门', align: 'center', dataIndex: 'orgCode' },
{ title: '操作', align: 'center', dataIndex: 'action', width: 200, scopedSlots: { customRender: 'action' } }
],
url: {
getAvatar: (path) => `window._CONFIG['staticDomainURL']/${path}`,
// 回收站操作get = 获取列表put = 取回delete = 彻底删除
recycleBin: '/sys/user/recycleBin',
},
}
},
watch: {
visible: {
immediate: true,
handler(val) {
if (val) {
this.loadData()
}
this.innerVisible = val
}
},
innerVisible(val) {
this.$emit('update:visible', val)
},
},
methods: {
loadData() {
superRequest.call(this, {
loading: true,
promise: this.$http.get(this.url.recycleBin),
success: res => this.dataSource = res.result
})
},
handleOk() {
this.loadData()
this.$emit('ok')
},
handleCancel() {
this.innerVisible = false
},
// 还原用户
handleRevert(userIds) {
this.$confirm({
title: '恢复用户',
content: `您确定要恢复这 ${userIds.length} 个用户吗?`,
centered: true,
onOk: () => {
superRequest.call(this, {
loading: true,
promise: this.$http.put(this.url.recycleBin, userIds),
success: () => {
this.handleOk()
this.handleClearSelection()
this.$message.success(`还原 ${userIds.length} 个用户成功!`)
}
})
}
})
},
// 彻底删除用户
handleDelete(userIds) {
this.$confirm({
title: '彻底删除用户',
content: (<div>
<p>您确定要彻底删除这 {userIds.length} 个用户吗?</p>
<p style="color:red;">注意:彻底删除后将无法恢复,请谨慎操作!</p>
</div>),
centered: true,
onOk: () => {
superRequest.call(this, {
loading: true,
promise: this.$http.delete(this.url.recycleBin + `?userIds=${userIds.join(',')}`),
success: () => {
this.loadData()
this.handleClearSelection()
this.$message.success(`彻底删除 ${userIds.length} 个用户成功!`)
}
})
},
})
},
handleRevertBatch() {
this.handleRevert(this.selectedRowKeys)
},
handleDeleteBatch() {
this.handleDelete(this.selectedRowKeys)
},
handleClearSelection() {
this.handleTableSelectChange([], [])
},
handleTableSelectChange(selectedRowKeys, selectionRows) {
this.selectedRowKeys = selectedRowKeys
this.selectionRows = selectionRows
},
}
}
</script>
<style lang="scss" scoped></style>

View File

@ -45,7 +45,8 @@
<a-popconfirm title="确定放弃编辑" @confirm="close" okText="确定" cancelText="取消">
<a-button style="margin-right: .8rem">取消</a-button>
</a-popconfirm>
<a-button @click="handleSubmit" type="primary" :loading="loading">提交</a-button>
<a-button @click="handleSubmit(false)" type="primary" :loading="loading" ghost style="margin-right: 0.8rem">仅保存</a-button>
<a-button @click="handleSubmit(true)" type="primary" :loading="loading">保存并关闭</a-button>
</div>
<role-datarule-modal ref="datarule"></role-datarule-modal>
@ -134,7 +135,7 @@
handleCancel () {
this.close()
},
handleSubmit(){
handleSubmit(exit) {
let that = this;
let params = {
roleId:that.roleId,
@ -147,18 +148,20 @@
if(res.success){
that.$message.success(res.message);
that.loading = false;
that.close();
if (exit) {
that.close()
}
}else {
that.$message.error(res.message);
that.loading = false;
that.close();
if (exit) {
that.close()
}
}
this.loadData();
})
},
},
watch: {
visible () {
if (this.visible) {
loadData(){
queryTreeListForRole().then((res) => {
this.treeData = res.result.treeList
this.allTreeKeys = res.result.ids
@ -170,6 +173,12 @@
})
})
}
},
watch: {
visible () {
if (this.visible) {
this.loadData();
}
}
}
}