iam-item-select.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <a-modal
  3. :body-style="bodyStyle"
  4. title="请选择"
  5. :destroy-on-close="true"
  6. :visible="visible"
  7. width="700px"
  8. :confirm-loading="confirmLoading"
  9. @ok="handleOk"
  10. @cancel="handleCancel"
  11. >
  12. <div :class="$style.selectDiv">
  13. <iam-item-tree v-bind="$props" v-on="$listeners" @checking="checking"></iam-item-tree>
  14. </div>
  15. </a-modal>
  16. </template>
  17. <script>
  18. import iamItemTree from './iam-item-tree.vue'
  19. import components from './_import-components/iam-item-select-import'
  20. function checkIn(list, node) {
  21. let indexNum = -1
  22. list.forEach((item, index) => {
  23. if (item.id === node) {
  24. indexNum = index
  25. }
  26. })
  27. return indexNum
  28. }
  29. export default {
  30. name: 'IamItemSelect',
  31. metaInfo: {
  32. title: '选择审计事项',
  33. },
  34. components: {
  35. ...components,
  36. iamItemTree,
  37. },
  38. props: {
  39. /**
  40. * <p>获取数据的回调,获取根节点时,parentId为undefined</p>
  41. * <pre>(parentId,parent) => childrenItems</pre>
  42. */
  43. loadTreeData: {
  44. type: Function,
  45. required: true,
  46. },
  47. selectclick: {
  48. type: Function,
  49. default: null,
  50. },
  51. versionId: {
  52. type: String,
  53. default: '',
  54. },
  55. orgId: {
  56. type: String,
  57. default: '',
  58. },
  59. orgName: {
  60. type: String,
  61. default: '',
  62. },
  63. selecttype: {
  64. type: String,
  65. default: 'control',
  66. },
  67. types: {
  68. type: String,
  69. default: 'NK',
  70. },
  71. /**
  72. * 根节点{code:'200000',name:'西安分公司'}
  73. */
  74. rootNode: {
  75. type: [Object, Array],
  76. default: undefined,
  77. },
  78. /**
  79. * <p>搜索数据的回调</p>
  80. * <pre>(searchText) => items</pre>
  81. * @since 8.0.2
  82. */
  83. searchTreeData: {
  84. type: Function,
  85. default: undefined,
  86. },
  87. /**
  88. * 默认展开指定的树节点
  89. * @since 8.0.7
  90. */
  91. defaultExpandedKeys: {
  92. type: Array,
  93. default: undefined,
  94. },
  95. moduleId: {
  96. type: String,
  97. default: undefined,
  98. },
  99. isAbandonment: {
  100. type: String,
  101. default: 'NO',
  102. },
  103. optionValue: {
  104. type: String,
  105. default: 'id',
  106. },
  107. /**
  108. * @ignore
  109. */
  110. optionLabel: {
  111. type: String,
  112. default: 'name',
  113. },
  114. },
  115. data() {
  116. return {
  117. visible: false,
  118. confirmLoading: true,
  119. bodyStyle: {
  120. padding: 0,
  121. },
  122. treeDataType: '',
  123. checkednode: [],
  124. }
  125. },
  126. created() {},
  127. methods: {
  128. checking(flag) {
  129. if (flag) {
  130. this.confirmLoading = true
  131. } else {
  132. this.confirmLoading = false
  133. }
  134. },
  135. handleOk(e) {
  136. this.visible = !this.visible
  137. // 获取选中的数据
  138. this.$emit('sxhandleOk', this.$refs.auditMattersModalTree.newtree)
  139. // 根据选中的数据展示 左边的表单
  140. },
  141. handleCancel(e) {
  142. this.$emit('handleCancel')
  143. },
  144. treeSelect(allCheckNode, checkNode) {
  145. // 判断当前点击节点是否为选中状态
  146. const indexNum = checkIn(this.checkednode, checkNode.node.dataRef.id)
  147. if (indexNum === -1) {
  148. this.checkednode.push(checkNode.node.dataRef)
  149. } else {
  150. this.checkednode.splice(indexNum, 1)
  151. }
  152. },
  153. checkedKeys(checkNode, allCheckNode) {
  154. this.checkednode = []
  155. allCheckNode.forEach((item) => {
  156. this.checkednode.push(item.data.props)
  157. })
  158. },
  159. openPicker() {
  160. this.visible = !this.visible
  161. },
  162. },
  163. }
  164. </script>
  165. <style module lang="scss">
  166. @use '@/common/design' as *;
  167. .select-div {
  168. height: 500px;
  169. padding: 10px 20px;
  170. }
  171. </style>