|
@@ -44,7 +44,7 @@
|
|
|
<div class="demo-form">
|
|
|
<el-form :inline="true" :model="formInline" class="flex-wrap">
|
|
|
<el-form-item label="角色名称">
|
|
|
- <el-input style="width:250px" clearable v-model="formInline.role_name" :disabled="activeIndex == null" size="small" placeholder="请输入角色名称"></el-input>
|
|
|
+ <el-input style="width:250px;margin-right: 50px;" clearable v-model="formInline.role_name" :disabled="activeIndex == null" size="small" placeholder="请输入角色名称"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item class="flex1" label="角色描述">
|
|
|
<el-input style="width:600px;" clearable v-model="formInline.comment" :disabled="activeIndex == null" size="small" placeholder="请输入角色描述"></el-input>
|
|
@@ -205,9 +205,11 @@ export default {
|
|
|
methods: {
|
|
|
//获取tree数据
|
|
|
async setTreeData () {
|
|
|
- const result = await this.getQueryList(SERVICE_ID.sysMenuId)
|
|
|
- const treeMenu = setTree(result, 'up_auth_id', 'auth_id')
|
|
|
- this.treeData[0].children = treeMenu
|
|
|
+ const { code, returnData } = await this.getQueryList(SERVICE_ID.sysMenuId)
|
|
|
+ if (code == 0) {
|
|
|
+ const treeMenu = setTree(returnData, 'up_auth_id', 'auth_id')
|
|
|
+ this.treeData[0].children = treeMenu
|
|
|
+ }
|
|
|
},
|
|
|
filterNode (value, data) {
|
|
|
if (!value) return true;
|
|
@@ -280,21 +282,24 @@ export default {
|
|
|
//获取角色已有权限
|
|
|
async getRoleQuth (item) {
|
|
|
this.$refs.tree.setCheckedKeys([])
|
|
|
- const result = await this.getQueryList(SERVICE_ID.authTreeId, { role_id: item.role_ID }, 'role_id')
|
|
|
- this.checkDatas.push(result)
|
|
|
- if (result && result.length) {
|
|
|
- const datas = []
|
|
|
- result.forEach(item => {
|
|
|
- datas.push(item.auth_id)
|
|
|
- })
|
|
|
- this.$refs.tree.setCheckedKeys(datas)
|
|
|
- const treeDatas = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes())
|
|
|
- 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);
|
|
|
- });
|
|
|
- }, 50);
|
|
|
+ const { code, returnData } = await this.getQueryList(SERVICE_ID.authTreeId, { role_id: item.role_ID })
|
|
|
+ if (code == 0) {
|
|
|
+ const result = returnData
|
|
|
+ this.checkDatas.push(result)
|
|
|
+ if (result && result.length) {
|
|
|
+ const datas = []
|
|
|
+ result.forEach(item => {
|
|
|
+ datas.push(item.auth_id)
|
|
|
+ })
|
|
|
+ this.$refs.tree.setCheckedKeys(datas)
|
|
|
+ const treeDatas = this.$refs.tree.getCheckedNodes().concat(this.$refs.tree.getHalfCheckedNodes())
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+ }, 50);
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
//服务列表-点击
|
|
@@ -309,23 +314,23 @@ export default {
|
|
|
//服务列表-保存
|
|
|
async handleSave () {
|
|
|
if (this.dataObj.role_ID && this.dataType == 'edit') {
|
|
|
- const code = await this.getChangeList(this.queryId, this.formInline, 2, 'role_ID')
|
|
|
- if (code) {
|
|
|
+ const { code } = await this.getChangeList(this.queryId, this.formInline, 2, 'role_ID')
|
|
|
+ if (code == 0) {
|
|
|
this.resetTable()
|
|
|
this.getQueryListCo(this.queryId)
|
|
|
}
|
|
|
this.tipMsg(code)
|
|
|
} else if (this.dataType == 'add' && this.arrs[this.arrs.length - 1].role_ID) {
|
|
|
this.formInline.role_ID = this.arrs[this.arrs.length - 1].role_ID
|
|
|
- const code = await this.getChangeList(this.queryId, this.formInline, 2, 'role_ID')
|
|
|
- if (code) {
|
|
|
+ const { code } = await this.getChangeList(this.queryId, this.formInline, 2, 'role_ID')
|
|
|
+ if (code == 0) {
|
|
|
this.resetTable()
|
|
|
this.getQueryListCo(this.queryId)
|
|
|
}
|
|
|
this.tipMsg(code)
|
|
|
} else if (this.dataType == 'add') {
|
|
|
- const code = await this.getChangeList(this.queryId, this.formInline, 1)
|
|
|
- if (code) {
|
|
|
+ const { code } = await this.getChangeList(this.queryId, this.formInline, 1)
|
|
|
+ if (code == 0) {
|
|
|
this.resetTable()
|
|
|
this.getQueryListCo(this.queryId)
|
|
|
}
|
|
@@ -337,8 +342,8 @@ export default {
|
|
|
},
|
|
|
async tableRemove () {
|
|
|
if (this.dataObj.role_ID && this.dataType == 'edit') {
|
|
|
- const code = await this.getChangeList(this.queryId, this.dataObj, 3)
|
|
|
- if (code) {
|
|
|
+ const { code } = await this.getChangeList(this.queryId, this.dataObj, 3)
|
|
|
+ if (code == 0) {
|
|
|
this.resetTable()
|
|
|
this.getQueryListCo(this.queryId)
|
|
|
this.activeIndex = null;
|
|
@@ -352,8 +357,8 @@ export default {
|
|
|
}
|
|
|
this.tipMsg(code)
|
|
|
} else if (this.dataType == 'add' && this.arrs[this.arrs.length - 1].role_ID) {
|
|
|
- const code = await this.getChangeList(this.queryId, this.arrs[this.arrs.length - 1], 3)
|
|
|
- if (code) {
|
|
|
+ const { code } = await this.getChangeList(this.queryId, this.arrs[this.arrs.length - 1], 3)
|
|
|
+ if (code == 0) {
|
|
|
this.resetTable()
|
|
|
this.getQueryListCo(this.queryId)
|
|
|
this.activeIndex = null;
|
|
@@ -413,16 +418,16 @@ export default {
|
|
|
item.role_status = this.dataObj.role_status
|
|
|
})
|
|
|
if (type == 'add') {
|
|
|
- const code = await this.getChangeList(SERVICE_ID.authTreeId, res, 1)
|
|
|
- if (code) {
|
|
|
+ const { code } = await this.getChangeList(SERVICE_ID.authTreeId, res, 1)
|
|
|
+ if (code == 0) {
|
|
|
setTimeout(() => {
|
|
|
this.getRoleQuth(this.dataObj)
|
|
|
}, 100);
|
|
|
}
|
|
|
this.tipMsg(code)
|
|
|
} else {
|
|
|
- const code = await this.getChangeList(SERVICE_ID.authTreeId, msgs, 3)
|
|
|
- if (code) {
|
|
|
+ const { code } = await this.getChangeList(SERVICE_ID.authTreeId, msgs, 3)
|
|
|
+ if (code == 0) {
|
|
|
setTimeout(() => {
|
|
|
this.getRoleQuth(this.dataObj)
|
|
|
}, 100);
|
|
@@ -433,27 +438,33 @@ export default {
|
|
|
},
|
|
|
async setItem (node, data) {
|
|
|
if (this.dataObj.role_ID) {
|
|
|
- const result = await this.getQueryList(SERVICE_ID.getTableColumnId, { serviceOutPutId: data.auth_id }, 'serviceOutPutId')
|
|
|
- if (result && result) {
|
|
|
- this.checkArrs = result
|
|
|
- const res = await this.getQueryList(SERVICE_ID.authTreeId, [{ auth_id: data.auth_id }, { role_id: this.dataObj.role_ID }], ['auth_id', 'role_id'])
|
|
|
- if (res && res.length) {
|
|
|
- const resmsg = []
|
|
|
- result.forEach((item) => {
|
|
|
- res.forEach(p => {
|
|
|
- if (item.queryTemplateColumnSetID == p.queryTemplateColumnSetID) {
|
|
|
- item.rowauth = p.rowauth
|
|
|
- resmsg.push(item)
|
|
|
+ const { code, returnData } = await this.getQueryList(SERVICE_ID.getTableColumnId, { serviceOutPutId: 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 (code == 0) {
|
|
|
+ const res = returnData
|
|
|
+ if (res && res.length) {
|
|
|
+ const resmsg = []
|
|
|
+ result.forEach((item) => {
|
|
|
+ res.forEach(p => {
|
|
|
+ if (item.queryTemplateColumnSetID == p.queryTemplateColumnSetID) {
|
|
|
+ item.rowauth = p.rowauth
|
|
|
+ resmsg.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ if (resmsg && resmsg.length) {
|
|
|
+ resmsg.forEach(row => {
|
|
|
+ this.$refs.multipleTable.toggleRowSelection(row);
|
|
|
+ });
|
|
|
}
|
|
|
- })
|
|
|
- })
|
|
|
- if (resmsg && resmsg.length) {
|
|
|
- resmsg.forEach(row => {
|
|
|
- this.$refs.multipleTable.toggleRowSelection(row);
|
|
|
- });
|
|
|
+ this.checkGroups = resmsg
|
|
|
+ this.multipleTable = resmsg
|
|
|
+ }
|
|
|
}
|
|
|
- this.checkGroups = resmsg
|
|
|
- this.multipleTable = resmsg
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -465,7 +476,7 @@ export default {
|
|
|
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)
|
|
|
+ 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]; //最后一条数据
|
|
@@ -474,10 +485,10 @@ export default {
|
|
|
const cap = this.getColName(msg)
|
|
|
const result = this.sendCheckData(cap)
|
|
|
if (data1.length > data2.length) {
|
|
|
- const code = this.getChangeList(SERVICE_ID.authTreeId, result, 1)
|
|
|
+ const { code } = await this.getChangeList(SERVICE_ID.authTreeId, result, 1)
|
|
|
this.tipMsg(code)
|
|
|
} else {
|
|
|
- const code = this.getChangeList(SERVICE_ID.authTreeId, result, 3)
|
|
|
+ const { code } = await this.getChangeList(SERVICE_ID.authTreeId, result, 3)
|
|
|
this.tipMsg(code)
|
|
|
}
|
|
|
}
|
|
@@ -529,7 +540,7 @@ export default {
|
|
|
if (dis && dis.length) {
|
|
|
await this.getChangeList(SERVICE_ID.authTreeId, dis, 3)
|
|
|
}
|
|
|
- const code = await this.getChangeList(SERVICE_ID.authTreeId, result, 1)
|
|
|
+ const { code } = await this.getChangeList(SERVICE_ID.authTreeId, result, 1)
|
|
|
this.tipMsg(code)
|
|
|
}
|
|
|
}
|