|
@@ -82,23 +82,22 @@
|
|
|
<div class="newService-content-left-top">
|
|
|
<div class="flex head">
|
|
|
<div class="title">列授权</div>
|
|
|
+ <el-button type="primary" @click="handleColSave" class="bcButton" size="small">保存</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="newService-content-left-bottom">
|
|
|
- <template v-if="checkArrs.length">
|
|
|
- <el-scrollbar ref="scroll" style="height: 100%">
|
|
|
- <el-checkbox-group @change="groupChange" v-model="checkGroup" size="small">
|
|
|
- <el-row :gutter="20">
|
|
|
- <el-col v-for="(item,index) in checkArrs" :key="index" :span="8">
|
|
|
- <el-checkbox :label="item.columnName" border>{{ item.columnLabel }}</el-checkbox>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </el-checkbox-group>
|
|
|
- </el-scrollbar>
|
|
|
- </template>
|
|
|
- <template v-else>
|
|
|
- <el-empty description="暂无数据"></el-empty>
|
|
|
- </template>
|
|
|
+ <el-table ref="multipleTable" :data="checkArrs" border stripe :maxHeight="tableHeight" tooltip-effect="dark" style="width: 100%;" @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" label="选中" width="55">
|
|
|
+ </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.columnName" clearable>
|
|
|
+ </el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -112,11 +111,12 @@ import Table from '@/views/newTable/index.vue'
|
|
|
import { Query, newData, modifyData, moveData } from "@/api/webApi"
|
|
|
import { setTree } from '@/utils/validate'
|
|
|
import pb from '@/layout/mixin/getPublicData'
|
|
|
+import pf from '@/layout/mixin/publicFunc'
|
|
|
import * as _ from 'lodash'
|
|
|
export default {
|
|
|
name: 'NewService',
|
|
|
components: { Table },
|
|
|
- mixins: [pb],
|
|
|
+ mixins: [pb, pf],
|
|
|
data () {
|
|
|
return {
|
|
|
title: '服务设置',
|
|
@@ -154,12 +154,22 @@ export default {
|
|
|
checkGroup: [],
|
|
|
checkArrs: [],
|
|
|
checkDatas: [],
|
|
|
- checkGroups: []
|
|
|
+ checkGroups: [],
|
|
|
+ multipleTable: []
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
dataList () {
|
|
|
return this.arrs.filter(data => !this.search || data.role_name.toLowerCase().includes(this.search.toLowerCase()))
|
|
|
+ },
|
|
|
+ tableHeight () {
|
|
|
+ const dom = document.querySelector('.contents2')
|
|
|
+ if (dom) {
|
|
|
+ const height = dom.clientHeight
|
|
|
+ return height
|
|
|
+ } else {
|
|
|
+ return 500
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -171,7 +181,7 @@ export default {
|
|
|
const { title, qid } = this.$route.meta
|
|
|
this.title = title
|
|
|
this.queryId = qid
|
|
|
- this.getQueryList(qid)
|
|
|
+ this.getQueryListCo(qid)
|
|
|
this.setTreeData()
|
|
|
},
|
|
|
updated () {
|
|
@@ -180,7 +190,7 @@ export default {
|
|
|
methods: {
|
|
|
//获取tree数据
|
|
|
async setTreeData () {
|
|
|
- const result = await this.getQuery(SERVICE_ID.sysMenuId)
|
|
|
+ const result = await this.getQueryList(SERVICE_ID.sysMenuId)
|
|
|
const treeMenu = setTree(result, 'up_auth_id', 'auth_id')
|
|
|
this.treeData[0].children = treeMenu
|
|
|
},
|
|
@@ -188,7 +198,7 @@ export default {
|
|
|
if (!value) return true;
|
|
|
return data.auth_name.indexOf(value) !== -1;
|
|
|
},
|
|
|
- async getQueryList (id) {
|
|
|
+ async getQueryListCo (id) {
|
|
|
try {
|
|
|
this.loading = true;
|
|
|
const { code, returnData } = await Query({
|
|
@@ -222,7 +232,7 @@ export default {
|
|
|
},
|
|
|
load () {
|
|
|
if (!this.noMore) {
|
|
|
- this.getQueryList(this.queryId);
|
|
|
+ this.getQueryListCo(this.queryId);
|
|
|
}
|
|
|
},
|
|
|
scrollDown () {
|
|
@@ -250,7 +260,8 @@ export default {
|
|
|
},
|
|
|
//获取角色已有权限
|
|
|
async getRoleQuth (item) {
|
|
|
- const result = await this.getQuery(SERVICE_ID.authTreeId, false, { role_id: item.role_ID })
|
|
|
+ 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 = []
|
|
@@ -277,14 +288,29 @@ export default {
|
|
|
this.getRoleQuth(item)
|
|
|
},
|
|
|
//服务列表-保存
|
|
|
- handleSave () {
|
|
|
+ async handleSave () {
|
|
|
if (this.dataObj.role_ID && this.dataType == 'edit') {
|
|
|
- this.generalDataReception(this.queryId, 2, this.formInline)
|
|
|
+ const code = await this.getChangeList(this.queryId, this.formInline, 2, 'role_ID')
|
|
|
+ if (code) {
|
|
|
+ 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
|
|
|
- this.generalDataReception(this.queryId, 2, this.formInline)
|
|
|
+ const code = await this.getChangeList(this.queryId, this.formInline, 2, 'role_ID')
|
|
|
+ if (code) {
|
|
|
+ this.resetTable()
|
|
|
+ this.getQueryListCo(this.queryId)
|
|
|
+ }
|
|
|
+ this.tipMsg(code)
|
|
|
} else if (this.dataType == 'add') {
|
|
|
- this.generalDataReception(this.queryId, 1, this.formInline)
|
|
|
+ const code = await this.getChangeList(this.queryId, this.formInline, 1)
|
|
|
+ if (code) {
|
|
|
+ this.resetTable()
|
|
|
+ this.getQueryListCo(this.queryId)
|
|
|
+ }
|
|
|
+ this.tipMsg(code)
|
|
|
}
|
|
|
else {
|
|
|
this.$message.error('请先选中服务后再操作')
|
|
@@ -297,16 +323,21 @@ export default {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- this.generalDataReception(this.queryId, 3, this.dataObj)
|
|
|
- this.activeIndex = null;
|
|
|
- this.dataObj = {};
|
|
|
- for (const key in this.formInline) {
|
|
|
- if (Object.hasOwnProperty.call(this.formInline, key)) {
|
|
|
- this.formInline[key] = null
|
|
|
+ }).then(async () => {
|
|
|
+ const code = await this.getChangeList(this.queryId, this.dataObj, 3)
|
|
|
+ if (code) {
|
|
|
+ this.resetTable()
|
|
|
+ this.getQueryListCo(this.queryId)
|
|
|
+ this.activeIndex = null;
|
|
|
+ this.dataObj = {};
|
|
|
+ for (const key in this.formInline) {
|
|
|
+ if (Object.hasOwnProperty.call(this.formInline, key)) {
|
|
|
+ this.formInline[key] = null
|
|
|
+ }
|
|
|
}
|
|
|
+ this.flag = true
|
|
|
}
|
|
|
- this.flag = true
|
|
|
+ this.tipMsg(code)
|
|
|
}).catch(() => {
|
|
|
this.$message({
|
|
|
type: 'info',
|
|
@@ -318,17 +349,22 @@ export default {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- this.generalDataReception(this.queryId, 3, this.arrs[this.arrs.length - 1])
|
|
|
- this.activeIndex = null;
|
|
|
- this.dataObj = {};
|
|
|
- for (const key in this.formInline) {
|
|
|
- if (Object.hasOwnProperty.call(this.formInline, key)) {
|
|
|
- this.formInline[key] = null
|
|
|
+ }).then(async () => {
|
|
|
+ const code = await this.getChangeList(this.queryId, this.arrs[this.arrs.length - 1], 3)
|
|
|
+ if (code) {
|
|
|
+ this.resetTable()
|
|
|
+ this.getQueryListCo(this.queryId)
|
|
|
+ this.activeIndex = null;
|
|
|
+ this.dataObj = {};
|
|
|
+ for (const key in this.formInline) {
|
|
|
+ if (Object.hasOwnProperty.call(this.formInline, key)) {
|
|
|
+ this.formInline[key] = null
|
|
|
+ }
|
|
|
}
|
|
|
+ this.flag = true
|
|
|
+ this.dataType = 'edit'
|
|
|
}
|
|
|
- this.flag = true
|
|
|
- this.dataType = 'edit'
|
|
|
+ this.tipMsg(code)
|
|
|
}).catch(() => {
|
|
|
this.$message({
|
|
|
type: 'info',
|
|
@@ -343,35 +379,6 @@ export default {
|
|
|
this.dataObj = {}
|
|
|
}
|
|
|
},
|
|
|
- //服务列表-增/删/改
|
|
|
- async generalDataReception (id = this.queryId, event, data, type) {
|
|
|
- try {
|
|
|
- const params = {
|
|
|
- serviceId: id,
|
|
|
- dataContent: data,
|
|
|
- event: `${event}`,
|
|
|
- };
|
|
|
- const { code } =
|
|
|
- event == 1
|
|
|
- ? await newData(params)
|
|
|
- : event == 2
|
|
|
- ? await modifyData(params)
|
|
|
- : await moveData(params);
|
|
|
- if (code == 0) {
|
|
|
- this.$message.success("操作成功");
|
|
|
- if (type) {
|
|
|
-
|
|
|
- } else {
|
|
|
- this.resetTable();
|
|
|
- this.getQueryList(this.queryId);
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.$message.error("操作失败");
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- this.$message.error("操作失败");
|
|
|
- }
|
|
|
- },
|
|
|
handleNodeClick (data) {
|
|
|
this.treeCheckId = data.auth_id
|
|
|
this.treeCheckObj = data
|
|
@@ -405,43 +412,58 @@ export default {
|
|
|
item.role_status = this.dataObj.role_status
|
|
|
})
|
|
|
if (type == 'add') {
|
|
|
- this.generalDataReception(SERVICE_ID.authTreeId, 1, res, true)
|
|
|
- setTimeout(() => {
|
|
|
- this.getRoleQuth(this.dataObj)
|
|
|
- }, 100);
|
|
|
+ const code = await this.getChangeList(SERVICE_ID.authTreeId, res, 1)
|
|
|
+ if (code) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.getRoleQuth(this.dataObj)
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+ this.tipMsg(code)
|
|
|
} else {
|
|
|
- this.generalDataReception(SERVICE_ID.authTreeId, 3, msgs, true)
|
|
|
+ const code = await this.getChangeList(SERVICE_ID.authTreeId, msgs, 3)
|
|
|
+ if (code) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.getRoleQuth(this.dataObj)
|
|
|
+ }, 100);
|
|
|
+ }
|
|
|
+ this.tipMsg(code)
|
|
|
}
|
|
|
},
|
|
|
async setItem (node, data) {
|
|
|
if (this.dataObj.role_ID) {
|
|
|
- const result = await this.getQuery(SERVICE_ID.getTableColumnId, false, { serviceOutPutId: data.auth_id })
|
|
|
+ const result = await this.getQueryList(SERVICE_ID.getTableColumnId, { serviceOutPutId: data.auth_id }, 'serviceOutPutId')
|
|
|
if (result && result) {
|
|
|
this.checkArrs = result
|
|
|
- const res = await this.getQuery(SERVICE_ID.authTreeId, false, { auth_id: data.auth_id, role_id: this.dataObj.role_ID })
|
|
|
+ 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 datas = []
|
|
|
- res.forEach(item => {
|
|
|
- if (item.columnname) {
|
|
|
- datas.push(item.columnname)
|
|
|
- }
|
|
|
+ const resmsg = []
|
|
|
+ result.forEach(item => {
|
|
|
+ res.forEach(p => {
|
|
|
+ if (item.columnName == p.columnname) {
|
|
|
+ resmsg.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
- if (datas.length) {
|
|
|
- this.checkGroups.push(datas)
|
|
|
+ if (resmsg && resmsg.length) {
|
|
|
+ resmsg.forEach(row => {
|
|
|
+ this.$refs.multipleTable.toggleRowSelection(row);
|
|
|
+ });
|
|
|
}
|
|
|
- this.checkGroup = datas
|
|
|
+ this.checkGroups = resmsg
|
|
|
+ this.multipleTable = resmsg
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
this.$message.error('请选中角色后再操作');
|
|
|
}
|
|
|
},
|
|
|
- groupChange (val) {
|
|
|
+ async groupChange (val) {
|
|
|
this.checkGroups.push(val)
|
|
|
if (this.checkGroups.length == 1) {
|
|
|
const res = this.getColName(val)
|
|
|
const result = this.sendCheckData(res)
|
|
|
- this.generalDataReception(SERVICE_ID.authTreeId, 1, result, true)
|
|
|
+ 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]; //倒数第二条数据
|
|
@@ -449,9 +471,11 @@ export default {
|
|
|
const cap = this.getColName(msg)
|
|
|
const result = this.sendCheckData(cap)
|
|
|
if (data1.length > data2.length) {
|
|
|
- this.generalDataReception(SERVICE_ID.authTreeId, 1, result, true)
|
|
|
+ const code = this.getChangeList(SERVICE_ID.authTreeId, result, 1)
|
|
|
+ this.tipMsg(code)
|
|
|
} else {
|
|
|
- this.generalDataReception(SERVICE_ID.authTreeId, 3, result, true)
|
|
|
+ const code = this.getChangeList(SERVICE_ID.authTreeId, result, 3)
|
|
|
+ this.tipMsg(code)
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -483,8 +507,17 @@ export default {
|
|
|
})
|
|
|
return res
|
|
|
},
|
|
|
- handleRemove (node, data) {
|
|
|
-
|
|
|
+ handleSelectionChange (val) {
|
|
|
+ this.multipleTable = val
|
|
|
+ },
|
|
|
+ async handleColSave () {
|
|
|
+ const result = this.sendCheckData(this.multipleTable)
|
|
|
+ const dis = this.sendCheckData(this.checkGroups)
|
|
|
+ if (dis && dis.length) {
|
|
|
+ await this.getChangeList(SERVICE_ID.authTreeId, dis, 3)
|
|
|
+ }
|
|
|
+ const code = await this.getChangeList(SERVICE_ID.authTreeId, result, 1)
|
|
|
+ this.tipMsg(code)
|
|
|
}
|
|
|
}
|
|
|
}
|