audit-picker-group.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div>
  3. <a-select v-model="onKeys">
  4. <a-select-option v-for="(item, i) in mockData" :key="i" :value="item.key">{{
  5. item.title
  6. }}</a-select-option>
  7. </a-select>
  8. <a-modal v-model="show" :title="title" @ok="onSubmit" @canplay="colseModel">
  9. <a-transfer
  10. :data-source="mockData"
  11. show-search
  12. :filter-option="filterOption"
  13. :target-keys="targetKeys"
  14. :render="(item) => item.title"
  15. :list-style="{ width: '45%', height: '500px' }"
  16. ></a-transfer>
  17. </a-modal>
  18. </div>
  19. </template>
  20. <script>
  21. import AuditRiskbraryService from './riskLibrary'
  22. export default {
  23. name: 'AuditPickerGroup',
  24. metaInfo: {
  25. title: 'AuditPickerGroup',
  26. },
  27. model: {
  28. prop: 'value',
  29. event: 'change',
  30. },
  31. props: {
  32. title: {
  33. type: String,
  34. default: '',
  35. },
  36. value: {
  37. type: [Array],
  38. default: () => [],
  39. },
  40. icon: {
  41. type: String,
  42. default: '',
  43. },
  44. rootNode: {
  45. type: [Object, Array],
  46. default: undefined,
  47. },
  48. hierarchical: {
  49. type: Boolean,
  50. default: false,
  51. },
  52. secretLevel: {
  53. type: String,
  54. default: '',
  55. },
  56. single: {
  57. type: Boolean,
  58. default: false,
  59. },
  60. },
  61. data() {
  62. return {
  63. show: false,
  64. // 数据源
  65. mockData: [],
  66. targetKeys: [],
  67. // 点击确定时, 传递的数据
  68. onKeys: [],
  69. }
  70. },
  71. methods: {
  72. open() {
  73. AuditRiskbraryService.getGroups().then((res) => {
  74. this.mockData = []
  75. res.data.data.map((item, i) => {
  76. this.mockData.push({
  77. key: item.code,
  78. title: item.name,
  79. description: item.description,
  80. })
  81. })
  82. // 设置默认值,默认为当前用户所在组织
  83. this.show = true
  84. })
  85. },
  86. close() {
  87. this.show = false
  88. },
  89. filterOption(inputValue, option) {
  90. return option.title.indexOf(inputValue) > -1
  91. },
  92. onSubmit() {
  93. this.onKeys = this.targetKeys
  94. this.$emit('change', this.onKeys)
  95. this.show = false
  96. this.onKeys = []
  97. this.targetKeys = []
  98. },
  99. colseModel() {
  100. this.show = false
  101. this.onKeys = []
  102. this.targetKeys = []
  103. },
  104. onChange(targetKeys, direction, moveKeys) {
  105. this.targetKeys = targetKeys
  106. },
  107. },
  108. }
  109. </script>
  110. <style module lang="scss">
  111. @use '@/common/design' as *;
  112. </style>