roleData.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-12-24 11:36:07
  4. * @LastEditTime: 2022-01-07 11:29:53
  5. * @LastEditors: Please set LastEditors
  6. * @Description: 权限公用
  7. * @FilePath: \Foshan4A2.0\src\views\authorityManagement\minixs\roleData.js
  8. */
  9. import { GetRoleByGroup } from '@/api/AccountGroup'
  10. export default {
  11. data () {
  12. return {
  13. arrs: []
  14. }
  15. },
  16. methods: {
  17. // 根据岗位获取角色
  18. async getRoleByGroup (id) {
  19. try {
  20. const res = await GetRoleByGroup({
  21. GroupId: id
  22. })
  23. if (res.code === 0) {
  24. const arr = res.returnData
  25. if (id == -1) {
  26. arr.forEach(item => {
  27. item.name = item.RoleName
  28. });
  29. this.arrs = arr
  30. } else {
  31. const datas = []
  32. arr.forEach(item => {
  33. item.name = item.RoleName
  34. if (item.IsSelected == 1) {
  35. datas.push(item)
  36. }
  37. });
  38. this.arrs = datas
  39. }
  40. } else {
  41. this.$message.error(res.message)
  42. }
  43. } catch (error) {
  44. console.log('出错了', error)
  45. }
  46. },
  47. }
  48. }