Detail.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <detail
  3. :onManager="onManager"
  4. :data="data"
  5. :base-info="baseInfo"
  6. :extra-info="extraInfo"
  7. :is-edit-name="!data.is_system"
  8. :is-edit-desc="!data.is_system"
  9. :nameRules="nameRules" />
  10. </template>
  11. <script>
  12. import {
  13. getEnabledTableColumn,
  14. getTagTableColumn,
  15. } from '@/utils/common/tableColumn'
  16. import PolicyViewer from '../components/PolicyViewer'
  17. export default {
  18. name: 'PolicyDetail',
  19. props: {
  20. data: {
  21. type: Object,
  22. required: true,
  23. },
  24. onManager: {
  25. type: Function,
  26. required: true,
  27. },
  28. },
  29. data () {
  30. return {
  31. baseInfo: [
  32. getEnabledTableColumn(),
  33. {
  34. field: 'is_public',
  35. title: this.$t('system.text_431'),
  36. formatter: ({ cellValue }) => {
  37. return cellValue ? this.$t('system.text_432') : this.$t('system.text_433')
  38. },
  39. },
  40. getTagTableColumn({
  41. columns: () => this.columns,
  42. tipName: this.$t('dictionary.schedtag'),
  43. }),
  44. ],
  45. extraInfo: [
  46. {
  47. title: this.$t('dictionary.policy'),
  48. items: [
  49. {
  50. field: 'scope',
  51. title: this.$t('system.text_326', [this.$t('dictionary.policy')]),
  52. formatter: ({ row }) => {
  53. return this.$t(`policyScopeLabel.${row.scope}`)
  54. },
  55. },
  56. {
  57. field: 'policy.policy',
  58. title: this.$t('system.text_327', [this.$t('dictionary.policy')]),
  59. slots: {
  60. default: ({ row }) => {
  61. return <PolicyViewer policy={row} />
  62. },
  63. },
  64. },
  65. ],
  66. },
  67. ],
  68. nameRules: [
  69. { required: true, message: this.$t('system.text_168') },
  70. ],
  71. }
  72. },
  73. methods: {
  74. getTag (tag) {
  75. const { tags = [] } = tag
  76. const ret = tags.map(item => {
  77. const { key, value } = item
  78. if (value) {
  79. return `${key.replace('org:', '')}:${value}`
  80. } else {
  81. return key.replace('org:', '')
  82. }
  83. })
  84. return ret.join(' - ')
  85. },
  86. },
  87. }
  88. </script>