|
@@ -14,16 +14,13 @@
|
|
|
</div>
|
|
|
<div v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)" class="newRole-content-left-bottom">
|
|
|
<el-scrollbar ref="scroll" style="height: 100%">
|
|
|
- <div>
|
|
|
+ <div class="treeArr">
|
|
|
<el-tree ref="treeArr" :data="arrs" :props="defaultArrProps" highlight-current :filter-node-method="filterArrNode" default-expand-all node-key="user_group_id" @node-click="handleClick" :expand-on-click-node="false">
|
|
|
- <span class="custom-tree-node" slot-scope="{ node, data }">
|
|
|
+ <span class="custom-tree-node" slot-scope="{ node }">
|
|
|
<div class="flex">
|
|
|
<div>
|
|
|
<span class="customTxt">{{ node.label }}</span>
|
|
|
</div>
|
|
|
- <div v-show="activeIndex == data.user_group_id" class="right">
|
|
|
- <span @click.stop="handleError" class="error">删除</span>
|
|
|
- </div>
|
|
|
</div>
|
|
|
</span>
|
|
|
</el-tree>
|
|
@@ -36,7 +33,7 @@
|
|
|
<div class="newRole-content-right-bottom contents1 flex1">
|
|
|
<div class="newRole-content-left-top">
|
|
|
<div class="flex head">
|
|
|
- <div class="title">权限列表</div>
|
|
|
+ <div class="title">功能授权</div>
|
|
|
</div>
|
|
|
<div class="search">
|
|
|
<el-input size="small" placeholder="请输入内容" clearable prefix-icon="el-icon-search" :filter-node-method="filterNode" v-model="filterText">
|
|
@@ -50,7 +47,7 @@
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }">
|
|
|
<span class="customTxt">{{ node.label }}</span>
|
|
|
<span v-show="treeCheckId == data.auth_id" class="customBtn">
|
|
|
- <span @click="setItem(node,data)" v-if="data.auth_id != 0 && data.auth_type == 4" class="ym">列授权</span>
|
|
|
+ <span @click.stop="setItem(node,data)" v-if="data.auth_id != 0 && data.auth_type == 4" class="ym">列授权</span>
|
|
|
</span>
|
|
|
</span>
|
|
|
</el-tree>
|
|
@@ -61,19 +58,19 @@
|
|
|
<div class="newRole-content-right-bottom contents2 flex1">
|
|
|
<div class="newRole-content-left-top">
|
|
|
<div class="flex head">
|
|
|
- <div class="title">列授权</div>
|
|
|
+ <div class="title">数据授权</div>
|
|
|
<el-button type="primary" @click="handleColSave" class="bcButton" size="small">保存</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="newRole-content-left-bottom">
|
|
|
- <el-table ref="multipleTable" class="multipleTable" :data="checkArrs" border stripe :maxHeight="tableHeight" tooltip-effect="dark" style="width: 100%;" @selection-change="handleSelectionChange">
|
|
|
+ <el-table ref="multipleTable" class="multipleTable" :data="checkArrs" border max-height="700" stripe tooltip-effect="dark" style="width: 100%;" @selection-change="handleSelectionChange">
|
|
|
<el-table-column label-class-name="DisabledSelection" type="selection" width="100">
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="columnLabel" label="列名">
|
|
|
</el-table-column>
|
|
|
<el-table-column label="行授权">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-input size="small" placeholder="请输入内容" v-model="scope.row.rowauth" clearable>
|
|
|
+ <el-input size="small" placeholder="请输入内容" v-model="scope.row.row_auth" clearable>
|
|
|
</el-input>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -163,18 +160,8 @@ export default {
|
|
|
checkDatas: [],
|
|
|
checkGroups: [],
|
|
|
multipleTable: [],
|
|
|
- rmFlag: false
|
|
|
- }
|
|
|
- },
|
|
|
- computed: {
|
|
|
- tableHeight () {
|
|
|
- const dom = document.querySelector('.contents2')
|
|
|
- if (dom) {
|
|
|
- const height = dom.clientHeight
|
|
|
- return height
|
|
|
- } else {
|
|
|
- return 500
|
|
|
- }
|
|
|
+ rmFlag: false,
|
|
|
+ msgUserId: ''
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -183,6 +170,9 @@ export default {
|
|
|
},
|
|
|
search (val) {
|
|
|
this.$refs.treeArr.filter(val);
|
|
|
+ },
|
|
|
+ treeCheckId () {
|
|
|
+ this.checkArrs = []
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
@@ -275,10 +265,16 @@ export default {
|
|
|
//获取角色已有权限
|
|
|
async getRoleQuth (item) {
|
|
|
this.$refs.tree.setCheckedKeys([])
|
|
|
- const { code, returnData } = await this.getQueryList(SERVICE_ID.authTreeId, { role_id: item.role_ID })
|
|
|
+ const newItem = _.cloneDeep(item)
|
|
|
+ const newObj = {}
|
|
|
+ if (newItem.hasOwnProperty('user_id')) {
|
|
|
+ newObj.user_id = newItem.user_id
|
|
|
+ } else {
|
|
|
+ newObj.user_group_id = newItem.user_group_id
|
|
|
+ }
|
|
|
+ const { code, returnData } = await this.getQueryList(SERVICE_ID.userAuthorizationId, newObj)
|
|
|
if (code == 0) {
|
|
|
const result = returnData
|
|
|
- this.checkDatas.push(result)
|
|
|
if (result && result.length) {
|
|
|
const datas = []
|
|
|
result.forEach(item => {
|
|
@@ -289,21 +285,33 @@ export default {
|
|
|
const res = [...treeDatas, ...result].filter((item) => !(treeDatas.some((p) => item.auth_id == p.auth_id) && result.some((c) => item.auth_id == c.auth_id)))
|
|
|
setTimeout(() => {
|
|
|
res.forEach((item) => {
|
|
|
- this.$refs.tree.setChecked(item.auth_id, false, false);
|
|
|
+ if (item.auth_id) {
|
|
|
+ this.$refs.tree.setChecked(item.auth_id, false, false);
|
|
|
+ }
|
|
|
});
|
|
|
}, 50);
|
|
|
+ setTimeout(() => {
|
|
|
+ const newTreeDatas = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes())
|
|
|
+ const arrs = newTreeDatas.filter(item => item.auth_id != 0)
|
|
|
+ this.checkDatas.push(arrs)
|
|
|
+ }, 70);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ removeClass (elements) {
|
|
|
+ elements.className = '';
|
|
|
+ },
|
|
|
//服务列表-点击
|
|
|
handleClick (item) {
|
|
|
- console.log(item)
|
|
|
this.dataType = 'edit'
|
|
|
this.dataObj = _.cloneDeep(item)
|
|
|
this.formInline = _.cloneDeep(item)
|
|
|
this.activeIndex = item.user_group_id
|
|
|
this.flag = false
|
|
|
- // this.getRoleQuth(item)
|
|
|
+ this.treeCheckId = null
|
|
|
+ this.$refs.tree.setCurrentKey(null)
|
|
|
+ this.msgUserId = null
|
|
|
+ this.getRoleQuth(item)
|
|
|
},
|
|
|
//服务列表-保存
|
|
|
async handleSave () {
|
|
@@ -380,39 +388,64 @@ export default {
|
|
|
this.rmFlag = true
|
|
|
},
|
|
|
handleNodeClick (data) {
|
|
|
+ this.msgUserId = null
|
|
|
this.treeCheckId = data.auth_id
|
|
|
this.treeCheckObj = data
|
|
|
+ // this.treeCheckId = null
|
|
|
+ // this.checkArrs = []
|
|
|
},
|
|
|
- checkChange () {
|
|
|
- if (this.dataObj.role_ID) {
|
|
|
+ async checkChange () {
|
|
|
+ if (this.dataObj.user_group_id) {
|
|
|
const datas = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes());
|
|
|
const arrs = datas.filter(item => item.auth_id != 0)
|
|
|
this.checkDatas.push(arrs)
|
|
|
- const data1 = this.checkDatas[this.checkDatas.length - 1]; //最后一条数据
|
|
|
- const data2 = this.checkDatas[this.checkDatas.length - 2]; //倒数第二条数据
|
|
|
- if (data1.length > data2.length) {
|
|
|
- this.checksBoxTs(data1, data2, "add");
|
|
|
+ if (this.checkDatas.length == 1) {
|
|
|
+ const res = this.checkDatas[this.checkDatas.length - 1]; //最后一条数据
|
|
|
+ const addRes = []
|
|
|
+ const newItem = _.cloneDeep(this.dataObj)
|
|
|
+ res.forEach(item => {
|
|
|
+ if (newItem.hasOwnProperty('user_id')) {
|
|
|
+ item.user_id = newItem.user_id
|
|
|
+ } else {
|
|
|
+ item.user_group_id = newItem.user_group_id
|
|
|
+ }
|
|
|
+ addRes.push(item)
|
|
|
+ })
|
|
|
+ const { code } = await this.getChangeList(SERVICE_ID.userAuthorizationId, addRes, 1)
|
|
|
+ if (code == 0) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.getRoleQuth(this.dataObj)
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+ this.tipMsg(code)
|
|
|
} else {
|
|
|
- this.checksBoxTs(data2, data1, "del");
|
|
|
+ const data1 = this.checkDatas[this.checkDatas.length - 1]; //最后一条数据
|
|
|
+ const data2 = this.checkDatas[this.checkDatas.length - 2]; //倒数第二条数据
|
|
|
+ if (data1.length > data2.length) {
|
|
|
+ this.checksBoxTs(data1, data2, "add");
|
|
|
+ } else {
|
|
|
+ this.checksBoxTs(data2, data1, "del");
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
- this.$message.error('请选中角色后再操作');
|
|
|
+ this.$message.error('请选中账号后再操作');
|
|
|
this.$refs.tree.setCheckedKeys([]);
|
|
|
}
|
|
|
},
|
|
|
async checksBoxTs (datas, arr, type) {
|
|
|
const res = [...datas, ...arr].filter((item) => !(datas.some((p) => item.auth_id == p.auth_id) && arr.some((c) => item.auth_id == c.auth_id)));
|
|
|
- const msgs = []
|
|
|
+ const addRes = []
|
|
|
+ const newItem = _.cloneDeep(this.dataObj)
|
|
|
res.forEach(item => {
|
|
|
- msgs.push({
|
|
|
- ID: item.ID
|
|
|
- })
|
|
|
- item.role_id = this.dataObj.role_ID
|
|
|
- item.role_name = this.dataObj.role_name
|
|
|
- item.role_status = this.dataObj.role_status
|
|
|
+ if (newItem.hasOwnProperty('user_id')) {
|
|
|
+ item.user_id = newItem.user_id
|
|
|
+ } else {
|
|
|
+ item.user_group_id = newItem.user_group_id
|
|
|
+ }
|
|
|
+ addRes.push(item)
|
|
|
})
|
|
|
if (type == 'add') {
|
|
|
- const { code } = await this.getChangeList(SERVICE_ID.authTreeId, res, 1)
|
|
|
+ const { code } = await this.getChangeList(SERVICE_ID.userAuthorizationId, addRes, 1)
|
|
|
if (code == 0) {
|
|
|
setTimeout(() => {
|
|
|
this.getRoleQuth(this.dataObj)
|
|
@@ -420,7 +453,7 @@ export default {
|
|
|
}
|
|
|
this.tipMsg(code)
|
|
|
} else {
|
|
|
- const { code } = await this.getChangeList(SERVICE_ID.authTreeId, msgs, 3)
|
|
|
+ const { code } = await this.getChangeList(SERVICE_ID.userAuthorizationId, addRes, 3)
|
|
|
if (code == 0) {
|
|
|
setTimeout(() => {
|
|
|
this.getRoleQuth(this.dataObj)
|
|
@@ -431,21 +464,39 @@ export default {
|
|
|
// this.checkArrs = []
|
|
|
},
|
|
|
async setItem (node, data) {
|
|
|
- if (this.dataObj.role_ID) {
|
|
|
- const { code, returnData } = await this.getQueryList(SERVICE_ID.getTableColumnId, { serviceOutPutId: data.auth_id })
|
|
|
+ if (this.dataObj.user_id || this.dataObj.user_group_id) {
|
|
|
+ this.msgUserId = data.auth_id
|
|
|
+ const newItem = _.cloneDeep(this.dataObj)
|
|
|
+ const addRes = []
|
|
|
+ const newObj = {}
|
|
|
+ if (newItem.hasOwnProperty('user_id')) {
|
|
|
+ newObj.user_id = newItem.user_id
|
|
|
+ } else {
|
|
|
+ newObj.user_group_id = newItem.user_group_id
|
|
|
+ }
|
|
|
+ addRes.push(newObj)
|
|
|
+ addRes.push({
|
|
|
+ auth_id: data.auth_id
|
|
|
+ })
|
|
|
+ const { code, returnData } = await this.getQueryList(SERVICE_ID.sysUserAuthId, [{ user_id: getToken('userid'), auth_id: data.auth_id }])
|
|
|
if (code == 0) {
|
|
|
const result = returnData
|
|
|
- if (result && result) {
|
|
|
- this.checkArrs = result
|
|
|
- const { code, returnData } = await this.getQueryList(SERVICE_ID.authTreeId, [{ auth_id: data.auth_id }, { role_id: this.dataObj.role_ID }])
|
|
|
+ if (result && result.length) {
|
|
|
+ result.map(item => {
|
|
|
+ item.row_auth = null
|
|
|
+ })
|
|
|
+ this.checkArrs = [...result]
|
|
|
+ const { code, returnData } = await this.getQueryList(SERVICE_ID.userAuthorizationId, addRes)
|
|
|
if (code == 0) {
|
|
|
- const res = returnData
|
|
|
+ const res = returnData.filter(item => item.queryTemplateColumnSetID)
|
|
|
if (res && res.length) {
|
|
|
+ // const caps = _.intersectionBy([result, res], 'queryTemplateColumnSetID')
|
|
|
+ // console.log(caps)
|
|
|
const resmsg = []
|
|
|
result.forEach((item) => {
|
|
|
res.forEach(p => {
|
|
|
if (item.queryTemplateColumnSetID == p.queryTemplateColumnSetID) {
|
|
|
- item.rowauth = p.rowauth
|
|
|
+ item.row_auth = p.row_auth
|
|
|
resmsg.push(item)
|
|
|
}
|
|
|
})
|
|
@@ -455,59 +506,43 @@ export default {
|
|
|
this.$refs.multipleTable.toggleRowSelection(row);
|
|
|
});
|
|
|
}
|
|
|
- this.checkGroups = resmsg
|
|
|
this.multipleTable = resmsg
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- this.$message.error('请选中角色后再操作');
|
|
|
- }
|
|
|
- },
|
|
|
- async groupChange (val) {
|
|
|
- this.checkGroups.push(val)
|
|
|
- if (this.checkGroups.length == 1) {
|
|
|
- const res = this.getColName(val)
|
|
|
- const result = this.sendCheckData(res)
|
|
|
- const { code } = await this.getChangeList(SERVICE_ID.authTreeId, result, 1)
|
|
|
- this.tipMsg(code)
|
|
|
- } else if (this.checkGroups.length > 1) {
|
|
|
- const data1 = this.checkGroups[this.checkGroups.length - 1]; //最后一条数据
|
|
|
- const data2 = this.checkGroups[this.checkGroups.length - 2]; //倒数第二条数据
|
|
|
- const msg = [...data1, ...data2].filter((item) => !(data1.some((p) => item == p) && data2.some((c) => item == c)));
|
|
|
- const cap = this.getColName(msg)
|
|
|
- const result = this.sendCheckData(cap)
|
|
|
- if (data1.length > data2.length) {
|
|
|
- const { code } = await this.getChangeList(SERVICE_ID.authTreeId, result, 1)
|
|
|
- this.tipMsg(code)
|
|
|
- } else {
|
|
|
- const { code } = await this.getChangeList(SERVICE_ID.authTreeId, result, 3)
|
|
|
- this.tipMsg(code)
|
|
|
- }
|
|
|
+ this.$message.error('请选中账号后再操作');
|
|
|
}
|
|
|
},
|
|
|
sendCheckData (arr, type = false) {
|
|
|
const newData = []
|
|
|
+ const newItem = _.cloneDeep(this.dataObj)
|
|
|
arr.forEach(item => {
|
|
|
if (type) {
|
|
|
- const obj = {
|
|
|
- "role_id": this.dataObj.role_ID,
|
|
|
+ const newObj = {
|
|
|
"auth_id": this.treeCheckObj.auth_id,
|
|
|
"queryTemplateColumnSetID": item.queryTemplateColumnSetID,
|
|
|
}
|
|
|
- newData.push(obj)
|
|
|
+ if (newItem.hasOwnProperty('user_id')) {
|
|
|
+ newObj.user_id = newItem.user_id
|
|
|
+ } else {
|
|
|
+ newObj.user_group_id = newItem.user_group_id
|
|
|
+ }
|
|
|
+ newData.push(newObj)
|
|
|
} else {
|
|
|
const obj = {
|
|
|
- "role_id": this.dataObj.role_ID,
|
|
|
- "role_name": this.dataObj.role_name,
|
|
|
- "role_status": this.dataObj.role_status,
|
|
|
"auth_id": this.treeCheckObj.auth_id,
|
|
|
"auth_type": this.treeCheckObj.auth_type,
|
|
|
"queryTemplateColumnSetID": item.queryTemplateColumnSetID,
|
|
|
"columnLabel": item.columnLabel,
|
|
|
"columnname": item.columnName,
|
|
|
- "rowauth": item.rowauth
|
|
|
+ "row_auth": item.row_auth
|
|
|
+ }
|
|
|
+ if (newItem.hasOwnProperty('user_id')) {
|
|
|
+ obj.user_id = newItem.user_id
|
|
|
+ } else {
|
|
|
+ obj.user_group_id = newItem.user_group_id
|
|
|
}
|
|
|
newData.push(obj)
|
|
|
}
|
|
@@ -529,13 +564,25 @@ export default {
|
|
|
this.multipleTable = val
|
|
|
},
|
|
|
async handleColSave () {
|
|
|
- const result = this.sendCheckData(this.multipleTable)
|
|
|
- const dis = this.sendCheckData(this.checkGroups, true)
|
|
|
- if (dis && dis.length) {
|
|
|
- await this.getChangeList(SERVICE_ID.authTreeId, dis, 3)
|
|
|
+ if (this.treeCheckObj.auth_id && this.dataObj.user_group_id && this.msgUserId) {
|
|
|
+ const newItem = _.cloneDeep(this.dataObj)
|
|
|
+ const newObj = {
|
|
|
+ "auth_id": this.treeCheckObj.auth_id,
|
|
|
+ }
|
|
|
+ if (newItem.hasOwnProperty('user_id')) {
|
|
|
+ newObj.user_id = newItem.user_id
|
|
|
+ } else {
|
|
|
+ newObj.user_group_id = newItem.user_group_id
|
|
|
+ }
|
|
|
+ const result = this.sendCheckData(this.multipleTable)
|
|
|
+ const tes = await this.getChangeList(SERVICE_ID.userAuthorizationId, [newObj], 3)
|
|
|
+ if (tes.code == 0) {
|
|
|
+ const { code } = await this.getChangeList(SERVICE_ID.userAuthorizationId, result, 1)
|
|
|
+ this.tipMsg(code)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$message.error('请先选中用户和权限后再操作列设置后保存数据')
|
|
|
}
|
|
|
- const { code } = await this.getChangeList(SERVICE_ID.authTreeId, result, 1)
|
|
|
- this.tipMsg(code)
|
|
|
}
|
|
|
}
|
|
|
}
|