|
@@ -99,7 +99,7 @@
|
|
|
<script>
|
|
|
import Table from '@/views/newTable/index.vue'
|
|
|
import Dialog from "@/layout/components/Dialog/index.vue"
|
|
|
-import { setTree, listToTree } from '@/utils/validate'
|
|
|
+import { getAuthData, listToTree } from '@/utils/validate'
|
|
|
import { getToken } from '@/utils/auth'
|
|
|
import pf from '@/layout/mixin/publicFunc'
|
|
|
import * as _ from 'lodash'
|
|
@@ -161,7 +161,9 @@ export default {
|
|
|
multipleTable: [],
|
|
|
rmFlag: false,
|
|
|
msgUserId: '',
|
|
|
- userId: getToken('userid')
|
|
|
+ userId: '',
|
|
|
+ userGroupArr: [],
|
|
|
+ userArr: []
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -177,7 +179,7 @@ export default {
|
|
|
},
|
|
|
computed: {
|
|
|
isAuth () {
|
|
|
- if (this.userId == 1 || this.userId == 99999 || this.userId == 9999) {
|
|
|
+ if (this.userId) {
|
|
|
return true
|
|
|
} else {
|
|
|
return false
|
|
@@ -185,9 +187,14 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
- const { title, qid } = this.$route.meta
|
|
|
+ const { title, qid, auth_id } = this.$route.meta
|
|
|
this.title = title
|
|
|
this.queryId = qid
|
|
|
+ const { arrs } = getAuthData(auth_id)
|
|
|
+ const btns = arrs.filter(item => item.auth_type == 3)
|
|
|
+ if (btns && btns.length) {
|
|
|
+ this.userId = btns[0].auth_ident
|
|
|
+ }
|
|
|
this.getQueryListCo(qid)
|
|
|
this.setTreeData()
|
|
|
},
|
|
@@ -214,20 +221,11 @@ export default {
|
|
|
async getQueryListCo (id) {
|
|
|
try {
|
|
|
this.loading = true;
|
|
|
- const { code, returnData } = await this.getQueryList(SERVICE_ID.userListId)
|
|
|
+ const { code, returnData } = await this.getQueryListAuth(SERVICE_ID.userListId)
|
|
|
if (code == 0 && returnData && returnData.length) {
|
|
|
- const result = await this.getQueryList(SERVICE_ID.getUserTableId)
|
|
|
- if (result.code == 0 && result.returnData && result.returnData.length) {
|
|
|
- result.returnData.forEach(item => {
|
|
|
- if (item.hasOwnProperty('user_name') || item.hasOwnProperty('user_group_id')) {
|
|
|
- item.user_group_name = item.user_name
|
|
|
- item.user_group_id = item.user_id
|
|
|
- }
|
|
|
- })
|
|
|
- const menus = [...returnData, ...result.returnData]
|
|
|
- const treeMenu = listToTree(menus, 'up_user_group_id', 'user_group_id')
|
|
|
- this.arrs = treeMenu
|
|
|
- }
|
|
|
+ this.userGroupArr = [...returnData]
|
|
|
+ const treeMenu = listToTree(this.userGroupArr, 'up_user_group_id', 'user_group_id')
|
|
|
+ this.arrs = treeMenu
|
|
|
this.loading = false;
|
|
|
} else {
|
|
|
this.loading = false;
|
|
@@ -313,6 +311,15 @@ export default {
|
|
|
removeClass (elements) {
|
|
|
elements.className = '';
|
|
|
},
|
|
|
+ disRemoveArr (arr, key) {
|
|
|
+ arr.forEach(item => {
|
|
|
+ if (item.children) {
|
|
|
+ item.children = _.uniqBy(item.children, key)
|
|
|
+ this.disRemoveArr(item.children, key)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return arr
|
|
|
+ },
|
|
|
//服务列表-点击
|
|
|
handleClick (item) {
|
|
|
this.dataType = 'edit'
|
|
@@ -324,8 +331,30 @@ export default {
|
|
|
this.$refs.tree.setCurrentKey(null)
|
|
|
this.msgUserId = null
|
|
|
this.checkDatas = []
|
|
|
+ if (!item.user_id) {
|
|
|
+ this.getUser(item.user_group_id)
|
|
|
+ }
|
|
|
this.getRoleQuth(item)
|
|
|
},
|
|
|
+ //获取用户组-用户
|
|
|
+ async getUser (id) {
|
|
|
+ const a1 = _.cloneDeep(this.userGroupArr)
|
|
|
+ const result = await this.getQueryList(SERVICE_ID.getUserTableId, { up_user_group_id: id })
|
|
|
+ if (result.code == 0 && result.returnData && result.returnData.length) {
|
|
|
+ this.userArr.push(...result.returnData)
|
|
|
+ const a2 = _.cloneDeep(this.userArr)
|
|
|
+ a2.forEach(item => {
|
|
|
+ if (item.hasOwnProperty('user_name') || item.hasOwnProperty('user_group_id')) {
|
|
|
+ item.user_group_name = item.user_name
|
|
|
+ item.user_group_id = item.user_id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const a3 = _.uniqBy(a2, 'user_id')
|
|
|
+ const menus = [...a1, ...a3]
|
|
|
+ const treeMenu = listToTree(menus, 'up_user_group_id', 'user_group_id')
|
|
|
+ this.arrs = this.disRemoveArr(treeMenu, 'user_group_id')
|
|
|
+ }
|
|
|
+ },
|
|
|
//服务列表-保存
|
|
|
async handleSave () {
|
|
|
if (this.dataObj.role_ID && this.dataType == 'edit') {
|