roleData.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-12-24 11:36:07
  4. * @LastEditTime: 2022-01-17 10:05:35
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 权限公用
  7. * @FilePath: \Foshan4A2.0\src\views\authorityManagement\minixs\roleData.js
  8. */
  9. import { organpop } from '@/api/postInterface'
  10. import { GetGroupByOrgan, GroupAuths } from '@/api/authGroupApi'
  11. import { GetGroupTree } from '@/api/AccountGroup'
  12. import { QueryRole } from '@/api/apiAuthority'
  13. import { sendSystem } from "@/api/postInterface"
  14. export default {
  15. data () {
  16. return {
  17. arrs: [],
  18. checkArr: [],
  19. checkList: [],
  20. }
  21. },
  22. methods: {
  23. // 根据组织获取角色
  24. async getRoleByOrgan (id) {
  25. try {
  26. const res = await organpop({
  27. OrganId: id
  28. })
  29. if (res.code === 0) {
  30. const arr = res.returnData
  31. if (id == -1) {
  32. arr.forEach(item => {
  33. item.name = item.RoleName
  34. });
  35. this.arrs = arr
  36. } else {
  37. const datas = []
  38. arr.forEach(item => {
  39. item.name = item.RoleName
  40. if (item.IsSelected == 1) {
  41. datas.push(item)
  42. }
  43. });
  44. this.arrs = datas
  45. }
  46. } else {
  47. this.$message.error(res.message)
  48. }
  49. } catch (error) {
  50. console.log('出错了', error)
  51. }
  52. },
  53. //根据组织获取岗位
  54. async getGroupByOrgan (id) {
  55. try {
  56. let params = {
  57. OrganId: id
  58. }
  59. const res = await GetGroupByOrgan(params)
  60. if (res.code === 0) {
  61. const arr = res.returnData
  62. arr.forEach(item => {
  63. item.name = item.GroupName
  64. });
  65. this.arrs = arr
  66. } else {
  67. this.$message.error(res.message)
  68. }
  69. } catch (error) {
  70. console.log('出错了', error)
  71. }
  72. },
  73. //根组织获取岗位
  74. async getGroupTree (name = '') {
  75. try {
  76. let params = {
  77. QueryName: name
  78. }
  79. const res = await GetGroupTree(params)
  80. if (res.code === 0) {
  81. const arr = res.returnData
  82. arr.forEach(item => {
  83. item.name = item.GroupName
  84. });
  85. this.arrs = arr
  86. } else {
  87. this.$message.error(res.message)
  88. }
  89. } catch (error) {
  90. console.log('出错了', error)
  91. }
  92. },
  93. //根据岗位查询权限列表
  94. async groupAuths (id) {
  95. try {
  96. let params = {
  97. GroupId: id
  98. }
  99. const res = await GroupAuths(params)
  100. if (res.code === 0) {
  101. this.RoleList = res.returnData
  102. } else {
  103. this.$message.error(res.message)
  104. }
  105. } catch (error) {
  106. console.log('出错了', error)
  107. }
  108. },
  109. //获取角色列表数据
  110. async gueryRole (name = '') {
  111. try {
  112. const res = await QueryRole({
  113. QueryName: name
  114. })
  115. if (res.code === 0) {
  116. const datas = res.returnData
  117. datas.forEach(item => {
  118. item.name = item.RoleName
  119. });
  120. this.arrs = datas
  121. } else {
  122. this.$message.error(res.message)
  123. }
  124. } catch (error) {
  125. console.log('出错了', error)
  126. }
  127. },
  128. //获取下发系统信息
  129. async getSendSystem () {
  130. const { code, message, returnData } = await sendSystem({
  131. userId: sessionStorage.getItem('User_Id'),
  132. userType: sessionStorage.getItem('UserType')
  133. })
  134. if (code == 0) {
  135. this.checkArr = returnData
  136. } else {
  137. this.$message.error(message)
  138. }
  139. },
  140. }
  141. }