treeData.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-12-22 17:00:22
  4. * @LastEditTime: 2022-02-17 13:50:31
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 获取权限树
  7. * @FilePath: \Foshan4A2.0\src\views\authorityManagement\minixs\treeData.js
  8. */
  9. import { translateDataToTreeAll } from '@/utils/validate'
  10. import { tissueTreeList, organpop } from '@/api/postInterface'
  11. import { GetGroupByOrgan, GetGroupByJob, GroupAuths } from '@/api/authGroupApi'
  12. import { GetGroupTree } from '@/api/AccountGroup'
  13. export default {
  14. data () {
  15. return {
  16. dataList: {
  17. AuthCount: 0,
  18. JobCount: 0,
  19. OfficerCount: 0,
  20. OrganId: -1,
  21. OrganName: "佛山路桥",
  22. OrganUpid: -2,
  23. QueryTarget: "0",
  24. Type: 0,
  25. disabled: true,
  26. children: []
  27. }
  28. }
  29. },
  30. created () {
  31. this.getOrganTree()
  32. },
  33. methods: {
  34. async getOrganTree (name = '') {
  35. try {
  36. const result = await tissueTreeList({
  37. "QueryName": name
  38. })
  39. if (result.code === 0 && result.returnData.length) {
  40. result.returnData.forEach(item => {
  41. item.flag = item.Status == 1 ? true : false
  42. })
  43. const obj = {
  44. AuthCount: 0,
  45. JobCount: 0,
  46. OfficerCount: 0,
  47. OrganId: -1,
  48. OrganName: "佛山路桥",
  49. OrganUpid: -2,
  50. QueryTarget: "0",
  51. Type: 0,
  52. disabled: true,
  53. children: translateDataToTreeAll(result.returnData, 'OrganUpid', 'OrganId')
  54. }
  55. this.dataList = obj
  56. } else {
  57. const obj = {
  58. AuthCount: 0,
  59. JobCount: 0,
  60. OfficerCount: 0,
  61. OrganId: -1,
  62. OrganName: "佛山路桥",
  63. OrganUpid: -2,
  64. QueryTarget: "0",
  65. Type: 0,
  66. disabled: true,
  67. children: []
  68. }
  69. this.dataList = obj
  70. }
  71. } catch (error) {
  72. console.log('出错了', error)
  73. }
  74. },
  75. // 根据组织获取角色
  76. async getRoleByOrgan (id) {
  77. try {
  78. const res = await organpop({
  79. OrganId: id
  80. })
  81. if (res.code === 0) {
  82. const arr = res.returnData
  83. if (id == -1) {
  84. arr.forEach(item => {
  85. item.name = item.RoleName
  86. });
  87. this.arrs = arr
  88. } else {
  89. const datas = []
  90. arr.forEach(item => {
  91. item.name = item.RoleName
  92. if (item.IsSelected == 1) {
  93. datas.push(item)
  94. }
  95. });
  96. this.arrs = datas
  97. }
  98. } else {
  99. this.$message.error(res.message)
  100. }
  101. } catch (error) {
  102. console.log('出错了', error)
  103. }
  104. },
  105. //根据组织获取账号组
  106. async getGroupByOrgan (id) {
  107. try {
  108. let params = {
  109. OrganId: id
  110. }
  111. const res = await GetGroupByOrgan(params)
  112. if (res.code === 0) {
  113. const arr = res.returnData
  114. arr.forEach(item => {
  115. item.name = item.GroupName
  116. });
  117. this.arrs = arr
  118. } else {
  119. this.$message.error(res.message)
  120. }
  121. } catch (error) {
  122. console.log('出错了', error)
  123. }
  124. },
  125. //根据岗位获取账号组
  126. async getGroupByJob (id, index) {
  127. try {
  128. let params = {
  129. JobId: id
  130. }
  131. const res = await GetGroupByJob(params)
  132. if (res.code === 0) {
  133. const datas = res.returnData
  134. const arrs = []
  135. datas.forEach(item => {
  136. item.name = item.GroupName
  137. if (item.IsSelected == 1) {
  138. arrs.push(item)
  139. }
  140. })
  141. this.arrs = arrs
  142. // if (index == 1) {
  143. // this.arrs = arrs
  144. // this.lessCheckBoxs.push(arrs)
  145. // } else if (index == 2) {
  146. // if (arrs.length) {
  147. // this.lessCheckBoxs.push(arrs)
  148. // const msgs = this.lessCheckBoxs.flat()
  149. // const uninqMsgs = _.unionBy(msgs, 'GroupId')
  150. // this.arrs = uninqMsgs
  151. // }
  152. // }
  153. } else {
  154. this.$message.error(res.message)
  155. }
  156. } catch (error) {
  157. console.log('出错了', error)
  158. }
  159. },
  160. //根组织获取账号组
  161. async getGroupTree (name = '') {
  162. try {
  163. let params = {
  164. QueryName: name
  165. }
  166. const res = await GetGroupTree(params)
  167. if (res.code === 0) {
  168. const arr = res.returnData
  169. arr.forEach(item => {
  170. item.name = item.GroupName
  171. });
  172. this.arrs = arr
  173. } else {
  174. this.$message.error(res.message)
  175. }
  176. } catch (error) {
  177. console.log('出错了', error)
  178. }
  179. },
  180. //根据账号组查询权限列表
  181. async groupAuths (id) {
  182. try {
  183. let params = {
  184. GroupId: id
  185. }
  186. const res = await GroupAuths(params)
  187. if (res.code === 0) {
  188. this.RoleList = res.returnData
  189. } else {
  190. this.$message.error(res.message)
  191. }
  192. } catch (error) {
  193. console.log('出错了', error)
  194. }
  195. },
  196. }
  197. }