123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- /*
- * @Author: your name
- * @Date: 2021-12-22 17:00:22
- * @LastEditTime: 2022-02-17 13:50:31
- * @LastEditors: Please set LastEditors
- * @Description: 获取权限树
- * @FilePath: \Foshan4A2.0\src\views\authorityManagement\minixs\treeData.js
- */
- import { translateDataToTreeAll } from '@/utils/validate'
- import { tissueTreeList, organpop } from '@/api/postInterface'
- import { GetGroupByOrgan, GetGroupByJob, GroupAuths } from '@/api/authGroupApi'
- import { GetGroupTree } from '@/api/AccountGroup'
- export default {
- data () {
- return {
- dataList: {
- AuthCount: 0,
- JobCount: 0,
- OfficerCount: 0,
- OrganId: -1,
- OrganName: "佛山路桥",
- OrganUpid: -2,
- QueryTarget: "0",
- Type: 0,
- disabled: true,
- children: []
- }
- }
- },
- created () {
- this.getOrganTree()
- },
- methods: {
- async getOrganTree (name = '') {
- try {
- const result = await tissueTreeList({
- "QueryName": name
- })
- if (result.code === 0 && result.returnData.length) {
- result.returnData.forEach(item => {
- item.flag = item.Status == 1 ? true : false
- })
- const obj = {
- AuthCount: 0,
- JobCount: 0,
- OfficerCount: 0,
- OrganId: -1,
- OrganName: "佛山路桥",
- OrganUpid: -2,
- QueryTarget: "0",
- Type: 0,
- disabled: true,
- children: translateDataToTreeAll(result.returnData, 'OrganUpid', 'OrganId')
- }
- this.dataList = obj
- } else {
- const obj = {
- AuthCount: 0,
- JobCount: 0,
- OfficerCount: 0,
- OrganId: -1,
- OrganName: "佛山路桥",
- OrganUpid: -2,
- QueryTarget: "0",
- Type: 0,
- disabled: true,
- children: []
- }
- this.dataList = obj
- }
- } catch (error) {
- console.log('出错了', error)
- }
- },
- // 根据组织获取角色
- async getRoleByOrgan (id) {
- try {
- const res = await organpop({
- OrganId: id
- })
- if (res.code === 0) {
- const arr = res.returnData
- if (id == -1) {
- arr.forEach(item => {
- item.name = item.RoleName
- });
- this.arrs = arr
- } else {
- const datas = []
- arr.forEach(item => {
- item.name = item.RoleName
- if (item.IsSelected == 1) {
- datas.push(item)
- }
- });
- this.arrs = datas
- }
- } else {
- this.$message.error(res.message)
- }
- } catch (error) {
- console.log('出错了', error)
- }
- },
- //根据组织获取账号组
- async getGroupByOrgan (id) {
- try {
- let params = {
- OrganId: id
- }
- const res = await GetGroupByOrgan(params)
- if (res.code === 0) {
- const arr = res.returnData
- arr.forEach(item => {
- item.name = item.GroupName
- });
- this.arrs = arr
- } else {
- this.$message.error(res.message)
- }
- } catch (error) {
- console.log('出错了', error)
- }
- },
- //根据岗位获取账号组
- async getGroupByJob (id, index) {
- try {
- let params = {
- JobId: id
- }
- const res = await GetGroupByJob(params)
- if (res.code === 0) {
- const datas = res.returnData
- const arrs = []
- datas.forEach(item => {
- item.name = item.GroupName
- if (item.IsSelected == 1) {
- arrs.push(item)
- }
- })
- this.arrs = arrs
- // if (index == 1) {
- // this.arrs = arrs
- // this.lessCheckBoxs.push(arrs)
- // } else if (index == 2) {
- // if (arrs.length) {
- // this.lessCheckBoxs.push(arrs)
- // const msgs = this.lessCheckBoxs.flat()
- // const uninqMsgs = _.unionBy(msgs, 'GroupId')
- // this.arrs = uninqMsgs
- // }
- // }
- } else {
- this.$message.error(res.message)
- }
- } catch (error) {
- console.log('出错了', error)
- }
- },
- //根组织获取账号组
- async getGroupTree (name = '') {
- try {
- let params = {
- QueryName: name
- }
- const res = await GetGroupTree(params)
- if (res.code === 0) {
- const arr = res.returnData
- arr.forEach(item => {
- item.name = item.GroupName
- });
- this.arrs = arr
- } else {
- this.$message.error(res.message)
- }
- } catch (error) {
- console.log('出错了', error)
- }
- },
- //根据账号组查询权限列表
- async groupAuths (id) {
- try {
- let params = {
- GroupId: id
- }
- const res = await GroupAuths(params)
- if (res.code === 0) {
- this.RoleList = res.returnData
- } else {
- this.$message.error(res.message)
- }
- } catch (error) {
- console.log('出错了', error)
- }
- },
- }
- }
|