RoleColumn.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div>
  3. <template v-for="(item, idx) of policies">
  4. <side-page-trigger
  5. :key="item"
  6. permission="policies_get"
  7. name="PolicySidePage"
  8. :id="item"
  9. :vm="vm">{{ item }}</side-page-trigger>
  10. {{ idx !== policies.length - 1 ? '、' : '' }}
  11. </template>
  12. </div>
  13. </template>
  14. <script>
  15. import * as R from 'ramda'
  16. import { getRequestT } from '@/utils/utils'
  17. export default {
  18. name: 'RoleColumn',
  19. props: {
  20. roles: {
  21. type: Array,
  22. required: true,
  23. },
  24. vm: {
  25. type: Object,
  26. required: true,
  27. },
  28. },
  29. data () {
  30. return {
  31. policies: [],
  32. }
  33. },
  34. destroyed () {
  35. this.manager = null
  36. },
  37. created () {
  38. this.manager = new this.$Manager('roles', 'v1')
  39. this.getRoles()
  40. },
  41. methods: {
  42. getRoles () {
  43. let policies = []
  44. this.roles.map(item => {
  45. this.manager.get({ id: item.id, query: { $t: getRequestT(), scope: this.$store.getters.scope } }).then(({ data }) => {
  46. const matchPolicies = data.match_policies
  47. if (matchPolicies && matchPolicies.length > 0) {
  48. policies = [...policies, ...matchPolicies]
  49. }
  50. policies = R.uniq(policies)
  51. this.policies = policies
  52. })
  53. })
  54. },
  55. },
  56. }
  57. </script>