xm-select-modal-render.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <audit-group-picker
  3. v-bind="$attrs"
  4. :single="!multiple"
  5. :read-only="false"
  6. :selectchecked="true"
  7. :selectcheckfn="getData"
  8. @change="change"
  9. />
  10. </template>
  11. <script>
  12. import pickValues from '@/common/services/pick-values'
  13. import auditGroupPicker from '@product/iam/components/picker/audit-group-picker.vue'
  14. import components from './_import-components/xm-select-modal-render-import'
  15. export default {
  16. name: 'XmSelectModalRender',
  17. metaInfo: {
  18. title: 'XmSelectModalRender',
  19. },
  20. components: {
  21. auditGroupPicker,
  22. ...components,
  23. },
  24. props: {
  25. selectField: {
  26. type: String,
  27. default: '',
  28. },
  29. groupIdField: {
  30. type: String,
  31. default: '',
  32. },
  33. groupCodeField: {
  34. type: String,
  35. default: '',
  36. },
  37. groupNameField: {
  38. type: String,
  39. default: '',
  40. },
  41. multiple: {
  42. type: Boolean,
  43. default: false,
  44. },
  45. },
  46. data() {
  47. return {
  48. selectcheckfw: [],
  49. defaultValue: this.$attrs?.value || null,
  50. readOnly: this.$attrs ? this.$attrs['read-only'] : false,
  51. }
  52. },
  53. inject: {
  54. SdFormContext: { default: () => {} },
  55. },
  56. methods: {
  57. getnamedata(data) {
  58. let name = ''
  59. if (JSON.parse(data) === 'object') {
  60. JSON.parse(data).forEach((i) => {
  61. name = name + i.name + ','
  62. })
  63. }
  64. if (name.length > 0) {
  65. if (name.substring(name.length - 1, name.length) === ',')
  66. name = name.substring(0, name.length - 1)
  67. }
  68. return name
  69. },
  70. getData() {
  71. const getdata = new Promise((resolve) => {
  72. if (this.selectField !== '') {
  73. resolve(this.SdFormContext.getFieldValue(this.selectField))
  74. } else {
  75. resolve([])
  76. }
  77. })
  78. return getdata
  79. },
  80. change(values) {
  81. this.$emit('input', values)
  82. let ids = '' // ids
  83. let codes = '' // code
  84. let names = '' // name
  85. values?.forEach((item) => {
  86. // 人员id
  87. if (ids === '') {
  88. ids = item.code
  89. } else {
  90. ids = ids + ',' + item.code
  91. }
  92. // 人员account
  93. if (codes === '') {
  94. codes = item.code
  95. } else {
  96. codes = codes + ',' + item.code
  97. }
  98. // 人员name
  99. if (names === '') {
  100. names = item.name
  101. } else {
  102. names = names + ',' + item.name
  103. }
  104. })
  105. if (this.groupIdField !== '') {
  106. this.SdFormContext.setFieldValue(this.groupIdField, ids)
  107. }
  108. if (this.groupCodeField !== '') {
  109. this.SdFormContext.setFieldValue(this.groupCodeField, codes)
  110. }
  111. if (this.groupNameField !== '') {
  112. this.SdFormContext.setFieldValue(this.groupNameField, names)
  113. }
  114. },
  115. },
  116. }
  117. </script>
  118. <style module lang="scss">
  119. @use '@/common/design' as *;
  120. .xmselinput {
  121. :global .ant-input {
  122. width: 70%;
  123. margin-right: 10px;
  124. }
  125. :global .ant-btn {
  126. width: auto;
  127. padding: 0 10px;
  128. }
  129. }
  130. </style>