imatrix-ui 0.2.5-up → 0.2.7-up

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/README.md +7 -7
  2. package/index.html +13 -13
  3. package/lib/super-ui.css +1 -1
  4. package/lib/super-ui.js +2732 -1940
  5. package/lib/super-ui.umd.cjs +24 -24
  6. package/package.json +1 -1
  7. package/packages/IntervalSelection/index.js +6 -6
  8. package/packages/IntervalSelection/src/quarterScope.vue +405 -405
  9. package/packages/IntervalSelection/src/sectionDate.vue +475 -475
  10. package/packages/breadcrumb/index.js +6 -6
  11. package/packages/breadcrumb/src/breadcrumb.vue +81 -81
  12. package/packages/department-tree/index.js +6 -6
  13. package/packages/department-tree/src/department-tree.vue +113 -113
  14. package/packages/department-tree-inline/index.js +6 -6
  15. package/packages/department-tree-inline/src/department-multi-tree-inline.vue +472 -472
  16. package/packages/department-tree-inline/src/department-single-tree-inline.vue +340 -340
  17. package/packages/department-tree-inline/src/department-tree-inline.vue +86 -86
  18. package/packages/department-tree-inline/src/department-tree-service.js +344 -344
  19. package/packages/department-tree-inline/src/search-result.vue +235 -235
  20. package/packages/department-user-tree/index.js +6 -6
  21. package/packages/department-user-tree/src/department-user-multiple-tree.vue +129 -129
  22. package/packages/department-user-tree/src/department-user-single-tree.vue +94 -94
  23. package/packages/department-user-tree/src/department-user-tree.vue +114 -114
  24. package/packages/department-user-tree-inline/index.js +9 -9
  25. package/packages/department-user-tree-inline/src/department-user-multiple-tree-inline.vue +731 -731
  26. package/packages/department-user-tree-inline/src/department-user-single-tree-inline.vue +334 -334
  27. package/packages/department-user-tree-inline/src/department-user-tree-inline.vue +87 -87
  28. package/packages/department-user-tree-inline/src/department-user-tree-multi-service.js +309 -309
  29. package/packages/department-user-tree-inline/src/department-user-tree-single-service.js +179 -179
  30. package/packages/department-user-tree-inline/src/search-result.vue +273 -273
  31. package/packages/directives/prevent-reclick.js +22 -22
  32. package/packages/dynamic-source-select/index.js +6 -6
  33. package/packages/dynamic-source-select/src/dynamic-source-select-service.js +106 -106
  34. package/packages/dynamic-source-select/src/dynamic-source-select.vue +675 -675
  35. package/packages/dynamic-source-select/src/events.js +78 -78
  36. package/packages/fs-preview/index.js +6 -6
  37. package/packages/fs-preview/src/fs-preview.vue +287 -287
  38. package/packages/fs-upload/index.js +6 -6
  39. package/packages/fs-upload/src/fs-upload-multi.vue +443 -443
  40. package/packages/fs-upload/src/fs-upload-single.vue +353 -350
  41. package/packages/fs-upload/src/fs-upload.vue +191 -191
  42. package/packages/fs-upload/src/see-big-picture.vue +67 -67
  43. package/packages/fs-upload-list/index.js +6 -6
  44. package/packages/fs-upload-list/src/fs-upload-list.vue +372 -372
  45. package/packages/hamburger/index.js +6 -6
  46. package/packages/hamburger/src/hamburger.vue +40 -40
  47. package/packages/index.js +123 -123
  48. package/packages/multipart-upload/index.js +6 -6
  49. package/packages/multipart-upload/src/index.vue +66 -66
  50. package/packages/multipart-upload/src/multipart-upload-form.vue +377 -377
  51. package/packages/multipart-upload/src/multipart-upload-list.vue +517 -517
  52. package/packages/organization-input/index.js +6 -6
  53. package/packages/organization-input/src/organization-input.vue +583 -583
  54. package/packages/plugins/export-data-new.js +623 -623
  55. package/packages/plugins/export-data.js +431 -431
  56. package/packages/plugins/index.js +15 -15
  57. package/packages/plugins/public-method.js +47 -47
  58. package/packages/remove-department/index.js +6 -6
  59. package/packages/remove-department/src/remove-department.vue +200 -200
  60. package/packages/remove-department/src/remove-dept-service.js +31 -31
  61. package/packages/remove-user/index.js +6 -6
  62. package/packages/remove-user/src/remove-user-service.js +31 -31
  63. package/packages/remove-user/src/remove-user.vue +226 -226
  64. package/packages/remove-workgroup/index.js +6 -6
  65. package/packages/remove-workgroup/src/remove-workgroup-service.js +31 -31
  66. package/packages/remove-workgroup/src/remove-workgroup.vue +183 -183
  67. package/packages/rich-editor/index.js +7 -7
  68. package/packages/rich-editor/index.vue +297 -297
  69. package/packages/rich-editor/langs/zh-Hans.js +438 -438
  70. package/packages/rich-editor/viewer.vue +105 -105
  71. package/packages/scan-code-input/index.js +6 -6
  72. package/packages/scan-code-input/src/events.js +34 -34
  73. package/packages/scan-code-input/src/scan-code-input-colse.vue +140 -140
  74. package/packages/scan-code-input/src/scan-code-input.vue +132 -132
  75. package/packages/secret-info/index.js +7 -7
  76. package/packages/secret-info/index.vue +100 -100
  77. package/packages/super-grid/index.js +7 -7
  78. package/packages/super-grid/src/apis.js +1092 -1092
  79. package/packages/super-grid/src/columns-config.vue +427 -427
  80. package/packages/super-grid/src/custom-formatter.js +394 -394
  81. package/packages/super-grid/src/eventBus.js +2 -2
  82. package/packages/super-grid/src/events.js +56 -56
  83. package/packages/super-grid/src/formValidatorUtil.js +300 -300
  84. package/packages/super-grid/src/formatter.js +196 -196
  85. package/packages/super-grid/src/group-column.vue +99 -99
  86. package/packages/super-grid/src/header-context-menu.vue +82 -82
  87. package/packages/super-grid/src/index-column.vue +69 -69
  88. package/packages/super-grid/src/public-methods.js +30 -30
  89. package/packages/super-grid/src/row-operation.vue +193 -193
  90. package/packages/super-grid/src/search-button.vue +74 -74
  91. package/packages/super-grid/src/search-condition-input.vue +73 -73
  92. package/packages/super-grid/src/search-condition-list.vue +68 -68
  93. package/packages/super-grid/src/search-form-advancedQuery.vue +819 -819
  94. package/packages/super-grid/src/search-form-dialog.vue +77 -77
  95. package/packages/super-grid/src/search-form-item.vue +495 -495
  96. package/packages/super-grid/src/search-form-number.vue +111 -111
  97. package/packages/super-grid/src/search-form-ordinarySearch.vue +239 -239
  98. package/packages/super-grid/src/search-form.vue +762 -762
  99. package/packages/super-grid/src/search-methods.js +592 -592
  100. package/packages/super-grid/src/selection-column.vue +46 -46
  101. package/packages/super-grid/src/store.js +3 -3
  102. package/packages/super-grid/src/super-grid-service.js +728 -728
  103. package/packages/super-grid/src/super-grid.vue +3011 -3011
  104. package/packages/super-grid/src/utils.js +880 -880
  105. package/packages/super-grid/src/view-image-dialog.vue +176 -176
  106. package/packages/super-nine-grid/index.js +7 -7
  107. package/packages/super-nine-grid/src/apis.js +108 -108
  108. package/packages/super-nine-grid/src/custom-formatter.js +73 -73
  109. package/packages/super-nine-grid/src/formatter.js +134 -134
  110. package/packages/super-nine-grid/src/search-form-number.vue +35 -35
  111. package/packages/super-nine-grid/src/search-form.vue +700 -700
  112. package/packages/super-nine-grid/src/search-methods.js +151 -151
  113. package/packages/super-nine-grid/src/store.js +3 -3
  114. package/packages/super-nine-grid/src/super-grid-service.js +107 -107
  115. package/packages/svg-icon/index.js +6 -6
  116. package/packages/svg-icon/src/svg-icon.vue +43 -43
  117. package/packages/utils/date-util.js +292 -292
  118. package/packages/utils/dom.js +227 -227
  119. package/packages/utils/gogocodeTransfer.js +59 -59
  120. package/packages/utils/memory-cache-utils.js +117 -117
  121. package/packages/utils/utils.js +180 -180
  122. package/packages/utils/value-set.js +97 -97
  123. package/packages/valid-code/index.js +7 -7
  124. package/packages/valid-code/src/valid-code.vue +104 -104
  125. package/packages/workflow-button/index.js +6 -6
  126. package/packages/workflow-button/src/workflow-button.vue +550 -550
  127. package/packages/workflow-history-list/index.js +6 -6
  128. package/packages/workflow-history-list/src/api.js +7 -7
  129. package/packages/workflow-history-list/src/workflow-history-list.vue +291 -291
  130. package/packages/workgroup-tree/index.js +6 -6
  131. package/packages/workgroup-tree/src/workgroup-tree.vue +86 -86
  132. package/packages/workgroup-tree-inline/index.js +6 -6
  133. package/packages/workgroup-tree-inline/src/search-result.vue +222 -222
  134. package/packages/workgroup-tree-inline/src/workgroup-tree-inline.vue +516 -516
  135. package/packages/workgroup-tree-inline/src/workgroup-tree-service.js +93 -93
  136. package/packages/workgroup-user-tree/index.js +6 -6
  137. package/packages/workgroup-user-tree/src/workgroup-user-tree.vue +103 -103
  138. package/packages/workgroup-user-tree-inline/index.js +9 -9
  139. package/packages/workgroup-user-tree-inline/src/search-result.vue +266 -266
  140. package/packages/workgroup-user-tree-inline/src/workgroup-tree-inline-service.js +239 -239
  141. package/packages/workgroup-user-tree-inline/src/workgroup-user-tree-inline.vue +657 -657
  142. package/packages/year-range-picker/index.js +6 -6
  143. package/packages/year-range-picker/src/year-range-picker.vue +53 -53
  144. package/src/api/sso-service.js +172 -172
  145. package/src/api/tab.js +36 -36
  146. package/src/api/user-service.js +11 -11
  147. package/src/directives/permission/index.js +13 -13
  148. package/src/directives/permission/permission.js +20 -20
  149. package/src/i18n/langs/cn.js +259 -259
  150. package/src/i18n/langs/en.js +269 -269
  151. package/src/index.js +93 -93
  152. package/src/plugins.js +18 -18
  153. package/src/router/index.js +8 -26
  154. package/src/store/getters.js +15 -15
  155. package/src/store/index.js +19 -19
  156. package/src/store/modules/app.js +54 -54
  157. package/src/store/modules/tab-content.js +36 -36
  158. package/src/store/modules/user.js +285 -285
  159. package/src/utils/auth.js +61 -61
  160. package/src/utils/calculator/calculator-factory-wf.js +558 -558
  161. package/src/utils/calculator/calculator-factory.js +145 -145
  162. package/src/utils/calculator/calculator-util.js +166 -166
  163. package/src/utils/eventBus.js +2 -2
  164. package/src/utils/iconUtils.js +28 -28
  165. package/src/utils/index.js +102 -102
  166. package/src/utils/jump-page-utils.js +824 -824
  167. package/src/utils/menu.js +19 -19
  168. package/src/utils/permission.js +31 -31
  169. package/src/utils/permissionAuth.js +96 -96
  170. package/src/utils/range-selector.js +188 -188
  171. package/src/utils/request.js +269 -269
  172. package/src/utils/restful-interface-utils.js +57 -57
  173. package/src/utils/util.js +703 -703
  174. package/src/utils/validate.js +34 -34
  175. package/src/utils/watermark.js +108 -108
  176. package/src/utils/workflow-util.js +93 -93
  177. package/src/views/404.vue +248 -248
  178. package/src/views/dsc-component/Sidebar/Item.vue +84 -84
  179. package/src/views/dsc-component/Sidebar/Link.vue +38 -38
  180. package/src/views/dsc-component/Sidebar/SidebarItem.vue +198 -198
  181. package/src/views/dsc-component/Sidebar/index.vue +229 -228
  182. package/src/views/dsc-component/tabs/tab-content.vue +203 -203
  183. package/src/views/error-page/401.vue +106 -106
  184. package/src/views/error-page/404.vue +248 -248
  185. package/src/views/layout/EmptyLayout.vue +3 -3
  186. package/src/views/layout/Layout.vue +81 -81
  187. package/src/views/layout/NewLayout.vue +18 -18
  188. package/src/views/layout/components/AppMain.vue +39 -39
  189. package/src/views/layout/components/Breadcrumb/index.vue +158 -156
  190. package/src/views/layout/components/Menubar/Item.vue +79 -79
  191. package/src/views/layout/components/Menubar/Link.vue +38 -38
  192. package/src/views/layout/components/Menubar/index.vue +210 -210
  193. package/src/views/layout/components/Sidebar/Item.vue +53 -53
  194. package/src/views/layout/components/Sidebar/Link.vue +38 -38
  195. package/src/views/layout/components/Sidebar/index.vue +141 -141
  196. package/src/views/layout/components/iframe-page.vue +38 -38
  197. package/src/views/layout/components/index.js +4 -4
  198. package/src/views/layout/components/tabs/tab-content.vue +207 -207
  199. package/src/views/layout/mixin/ResizeHandler.js +41 -41
  200. package/src/views/layout/tab-content-iframe-index.vue +38 -38
  201. package/src/views/layout/tab-content-index.vue +93 -93
  202. package/src/views/login/authredirect.vue +10 -10
  203. package/src/views/login/index.vue +296 -296
  204. package/src/views/login/update-password.vue +243 -243
  205. package/src/views/redirect/index.vue +14 -14
  206. package/src/views/wf-history/tache-subprocess-history.vue +45 -45
@@ -1,657 +1,657 @@
1
- <template>
2
- <div>
3
- <el-container style="height: 395px">
4
- <el-aside width="430px">
5
- <el-container style="height: 390px">
6
- <el-header style="text-align: right; font-size: 12px; height: 35px">
7
- <el-autocomplete
8
- v-model="filterText"
9
- size="small"
10
- select-when-unmatched
11
- class="inline-input inline-input-custom"
12
- :fetch-suggestions="querySearch"
13
- :placeholder="$t('departmentUserTree.pleaseEnterUserInformation')"
14
- :trigger-on-focus="false"
15
- @select="handleSelect"
16
- @keyup.enter="clickSearch"
17
- >
18
- <template v-slot:append>
19
- <el-button :icon="ElIconSearch" @click="clickSearch" />
20
- </template>
21
- </el-autocomplete>
22
- </el-header>
23
- <el-main style="padding: 10px">
24
- <div
25
- v-if="!searchValue"
26
- style="
27
- padding-top: 5px;
28
- overflow: auto;
29
- width: auto;
30
- display: inline-block !important;
31
- "
32
- >
33
- <el-tree
34
- ref="workgroupUserTree"
35
- :props="defaultProps"
36
- :load="loadNode"
37
- lazy
38
- :show-checkbox="multiple"
39
- node-key="nodeId"
40
- :render-content="renderContent"
41
- :filter-node-method="filterNode"
42
- @check="handleCheckNode"
43
- @node-click="handleNodeClick"
44
- />
45
- </div>
46
- <div
47
- v-if="searchValue && searchValue.length > 0"
48
- style="height: 100%; overflow: hidden"
49
- >
50
- <workgroup-user-result
51
- ref="workgroupUserResult"
52
- :grid-data="searchResult"
53
- :select-result="selectResult"
54
- :height="height"
55
- :multiple="multiple"
56
- :is-search-result="true"
57
- @selectResult="getSelectWorkgroupUser"
58
- @resultRowDblclick="resultRowDblclick"
59
- @addWorkgroupUser="addWorkgroupUser"
60
- />
61
- </div>
62
- </el-main>
63
- </el-container>
64
- </el-aside>
65
- <el-container v-if="multiple">
66
- <el-aside width="2px">
67
- <table
68
- border="1px"
69
- cellpadding="0"
70
- cellspacing="0"
71
- style="
72
- height: 100%;
73
- border-left-style: solid;
74
- border-bottom-style: none;
75
- border-right-style: none;
76
- border-top-style: none;
77
- border-left-color: #cccccc;
78
- "
79
- />
80
- </el-aside>
81
- <el-main style="padding: 10px">
82
- <div style="text-align: left; font-size: 16px">
83
- {{ $t('departmentUserTree.selectedPeople') }}::
84
- </div>
85
- <div :style="'padding-top: 5px;height:90%;overflow: hidden;'">
86
- <workgroup-user-result
87
- :grid-data="selectResult"
88
- :height="height"
89
- :multiple="multiple"
90
- :is-search-result="false"
91
- @selectResult="getSelectWorkgroupUser"
92
- @resultRowDblclick="resultRowDblclick"
93
- @removeWorkgroupUser="removeWorkgroupUser"
94
- />
95
- </div>
96
- </el-main>
97
- </el-container>
98
- </el-container>
99
- </div>
100
- </template>
101
-
102
- <script>
103
- import { Search as ElIconSearch } from '@element-plus/icons-vue'
104
- import { $on, $off, $once, $emit } from '../../utils/gogocodeTransfer'
105
- import localStorage from '../../../src/utils/local-storage'
106
- import utils from '../../utils/utils'
107
- import workgroupTreeInlineService from './workgroup-tree-inline-service'
108
- import WorkgroupUserResult from './search-result.vue'
109
- export default {
110
- data() {
111
- return {
112
- filterText: '',
113
- defaultProps: {
114
- id: 'id',
115
- label: 'name',
116
- children: 'children',
117
- isLeaf: 'leaf',
118
- },
119
- searchParam: {
120
- userField: null,
121
- searchValue: null,
122
- treeType: 'MAN_GROUP_TREE',
123
- departmentInfo: null,
124
- },
125
- // 当前租户内是否包含分支机构。获得当前选中部门名称时,如果有分支,则需要将分支名称返回给用户,例如:部门1(分支1)
126
- containBranch: false,
127
- // 公司节点的id
128
- tenantNodeId: -1,
129
- // 用于保存所有查询出的节点id
130
- allSearchNodeIds: [],
131
- // 用于保存allSearchNodeIds中所有已加载子节点的id集合
132
- allExpandNodeIds: [],
133
- isClickNode: false,
134
- // 查询的备选值
135
- restaurants: [],
136
- // 查询条件
137
- searchValue: null,
138
- // 工作组的查询结果
139
- searchResult: [],
140
- // 工作组的选中结果
141
- selectResult: [],
142
- searchStoreKey: 'searchWorkgroupUser',
143
- // 单选时,选择的用户信息
144
- selectNodeInfo: null,
145
- // 公司根节点信息
146
- tenantInfo: {},
147
- ElIconSearch,
148
- }
149
- },
150
- name: 'InlineWorkgroupUserTree',
151
- components: {
152
- WorkgroupUserResult,
153
- },
154
- props: {
155
- // 是否是多选树,默认是true
156
- multiple: {
157
- type: Boolean,
158
- default: true,
159
- },
160
- // 显示指定部门节点及其子节点,不传该属性,表示显示整个组织结构树
161
- branchInfo: {
162
- type: Array,
163
- default: null,
164
- },
165
- // 多选用户树时,已选择用户id或登录名集合,多个之间以逗号隔开
166
- selectUserInfo: {
167
- type: [String, Number],
168
- default: null,
169
- },
170
- // 移除用户时,用户属性名称:id、loginName、email、telephone,默认是loginName
171
- searchField: {
172
- type: String,
173
- default: 'loginName',
174
- },
175
- // 多选树时结果之间的分隔符,默认是逗号分隔
176
- separator: {
177
- type: String,
178
- default: ',',
179
- },
180
- },
181
- computed: {},
182
- watch: {
183
- filterText(val) {
184
- if (!val) {
185
- this.searchValue = val
186
- // 清空查询内容时,重新加载整个树
187
- this.loadWorkgroup(this.tenantNodeId, this.tenantNodeId + '')
188
- }
189
- },
190
- },
191
- created() {},
192
- mounted() {
193
- var searchWorkgroup = localStorage.getObject(this.searchStoreKey)
194
- if (searchWorkgroup) {
195
- this.restaurants = searchWorkgroup
196
- } else {
197
- this.restaurants = []
198
- }
199
- },
200
- methods: {
201
- ...utils,
202
- ...workgroupTreeInlineService,
203
- // 将查询结果中指定工作组添加到已选择工作组集合中
204
- addWorkgroupUser(index, workgroup) {
205
- const containWorkgroups = this.selectResult.filter(
206
- this.filterWorkgroup(workgroup)
207
- )
208
- if (containWorkgroups && containWorkgroups.length === 0) {
209
- this.selectResult.push(workgroup)
210
- }
211
- },
212
- filterWorkgroup(queryWorkgroup) {
213
- return (workgroup) => {
214
- return workgroup.id === queryWorkgroup.id
215
- }
216
- },
217
- removeWorkgroupUser(index, workgroup) {
218
- if (this.$refs.workgroupUserTree) {
219
- // 通过查询结果添加的工作组,在返回到组织结构树时,也选中了该工作组,在移除该工作组时,需要去掉复选框的选中状态
220
- const checkedKeys = this.$refs.workgroupUserTree.getCheckedKeys()
221
- const currentCheckedWorkgroupNodeIds = checkedKeys.filter(
222
- this.filterUserNode(workgroup)
223
- )
224
- if (currentCheckedWorkgroupNodeIds.length > 0) {
225
- // 表示当前工作组是选中的状态,需要去掉
226
- currentCheckedWorkgroupNodeIds.forEach((workgroupNodeId) => {
227
- this.$refs.workgroupUserTree.setChecked(workgroupNodeId, false)
228
- })
229
- }
230
- }
231
- this.selectResult = this.removeRow(this.selectResult, workgroup)
232
- if (!this.selectResult || this.selectResult.length === 0) {
233
- // 已选结果面板没有内容,则左侧树节点也不要有选中节点了
234
- if (this.$refs.workgroupUserTree) {
235
- this.$refs.workgroupUserTree.setCheckedKeys([])
236
- }
237
- }
238
- },
239
- getSelectWorkgroupUser(workgroup) {
240
- this.packageSelectResult(workgroup)
241
- },
242
- resultRowDblclick(workgroup) {
243
- this.packageSelectResult(workgroup)
244
- $emit(this, 'result', this.selectNodeInfo)
245
- },
246
- packageSelectResult(user) {
247
- user.tenantCode = this.tenantInfo.code
248
- user.tenantName = this.tenantInfo.tenantName
249
- let name = user.name
250
- if (user.enName && user.enName.trim() !== '') {
251
- name = name + '(' + user.enName + ')'
252
- }
253
- const selectNodeInfo = {
254
- id: user.id,
255
- name: name,
256
- loginName: user.loginName,
257
- email: user.email,
258
- telephone: user.telephone,
259
- containBranch: this.containBranch,
260
- user: user,
261
- enName: user.enName,
262
- subCompanyName: user.subCompanyName,
263
- }
264
- // 表示是勾选单选按钮或 选中树节点
265
- this.selectNodeInfo = selectNodeInfo
266
- },
267
- handleSelect(item) {
268
- this.handleSelectUtil(item, localStorage)
269
- },
270
- search(value) {
271
- this.searchValue = value
272
- // let mySearchValue = value
273
- // if (mySearchValue) {
274
- // mySearchValue = mySearchValue.trim()
275
- // }
276
- // this.searchParam.searchValue = mySearchValue
277
- // this.searchParam.departmentInfo = this.branchInfo
278
- // // this.searchParam.userField = this.searchField
279
- // // 后台查询部门,并拼接树节点
280
- // this.filterAppendNodes(value)
281
- this.$refs.workgroupUserTree.filter(value)
282
- },
283
- // 点击查询按钮调用的方法
284
- clickSearch() {
285
- this.storeSeachValue(localStorage, this.searchStoreKey, this.filterText)
286
- this.search(this.filterText)
287
- },
288
- filterNode(value, data, node) {
289
- if (!value) {
290
- return true
291
- } else {
292
- if (data.nodeType && data.nodeType === 'USER') {
293
- // data.data是用户的所有数据
294
- const user = JSON.parse(data.data)
295
- return this.filterUserVal(user, value)
296
- } else {
297
- // 表示不是用户节点
298
- return false
299
- }
300
- }
301
- },
302
- filterUserVal(user, searchVal) {
303
- const searchFields = [
304
- 'name',
305
- 'loginName',
306
- 'email',
307
- 'telephone',
308
- 'jobNumber',
309
- 'honorificName',
310
- ]
311
- let isHasVal = false
312
- for (let i = 0; i < searchFields.length; i++) {
313
- const searchField = searchFields[i]
314
- const userValue = user[searchField]
315
- if (
316
- userValue.indexOf(searchVal) !== -1 ||
317
- (searchField === 'name' &&
318
- user['enName'] &&
319
- user['enName'].indexOf(searchVal) !== -1)
320
- ) {
321
- isHasVal = true
322
- } else {
323
- isHasVal = false
324
- break
325
- }
326
- }
327
- return isHasVal
328
- },
329
- // 点击复选框时处理
330
- handleCheckNode(data, checkObj) {
331
- if (checkObj.checkedKeys.indexOf(data.nodeId) > -1) {
332
- // 表示正选中data节点
333
- this.checkedNode(data, false)
334
- } else {
335
- // 表示正取消选中data节点,同时要取消其子节点的选中状态
336
- this.cancelCheckedNode(data)
337
- }
338
- },
339
- // 选中当前节点及其子节点
340
- checkedNodeAndChildren(data) {
341
- // 取消选中状态时,保持节点是展开的状态,不要折叠
342
- this.$refs.workgroupUserTree.store.nodesMap[data.nodeId].expanded = true
343
- // 获得所有应该选中的节点
344
- this.$refs.workgroupUserTree.setChecked(data.nodeId, true)
345
- const children = data.children
346
- if (children) {
347
- // 递归设置子子节点的选中状态
348
- children.forEach((nodeData) => {
349
- this.checkedNodeAndChildren(nodeData)
350
- this.selectResult.push(JSON.parse(nodeData.data))
351
- })
352
- }
353
- },
354
- // 取消节点选中状态时
355
- cancelCheckedNode(data) {
356
- if (data.id === this.tenantNodeId) {
357
- // 表示取消公司节点的选中状态,即取消所有节点的勾选状态
358
- this.$refs.workgroupUserTree.setCheckedKeys([])
359
- } else if (data.nodeType && data.nodeType === 'WORKGROUP') {
360
- this.cancelCheckedUserNodesWithWorkgroup(data)
361
- } else {
362
- this.selectResult = this.removeRow(
363
- this.selectResult,
364
- JSON.parse(data.data)
365
- )
366
- }
367
- },
368
- // 选中了根节点公司节点时,选中所有工作组
369
- checkedAllWorkgroups(root) {
370
- const children = root.children
371
- if (children) {
372
- children.forEach((workgroupNode) => {
373
- this.$refs.workgroupUserTree.setChecked(workgroupNode.nodeId, true)
374
- })
375
- }
376
- },
377
- // 取消指定工作组下的用户节点的选中状态
378
- cancelCheckedUserNodesWithWorkgroup(workgroupData) {
379
- const children = workgroupData.children
380
- if (children) {
381
- children.forEach((userNode) => {
382
- this.$refs.workgroupUserTree.setChecked(userNode.nodeId, false)
383
- this.selectResult = this.removeRow(
384
- this.selectResult,
385
- JSON.parse(userNode.data)
386
- )
387
- })
388
- }
389
- },
390
- handleNodeClick(data, node, nodeTree) {
391
- if (this.multiple) {
392
- // 多选部门树时,处理点击节点事件
393
- this.clickNodeWhenMultiple(data)
394
- }
395
- this.selectSingleNode(data, false)
396
- },
397
- selectSingleNode(data, isClickOkBtn) {
398
- if (this.isUserNode(data) && !this.multiple) {
399
- // 点击的是工作组节点,并且是单选树时,点击部门节点直接关闭弹框
400
- const user = JSON.parse(data.data)
401
- user.tenantCode = this.tenantInfo.code
402
- user.tenantName = this.tenantInfo.tenantName
403
- let name = user.name
404
- if (user.enName && user.enName.trim() !== '') {
405
- name = name + '(' + user.enName + ')'
406
- }
407
- const selectNodeInfo = {
408
- id: user.id,
409
- name: name,
410
- loginName: user.loginName,
411
- email: user.email,
412
- telephone: user.telephone,
413
- containBranch: this.containBranch,
414
- user: user,
415
- enName: user.enName,
416
- subCompanyName: user.subCompanyName,
417
- }
418
- this.selectNodeInfo = selectNodeInfo
419
- if (isClickOkBtn === true) {
420
- // 点击确定按钮时才需要调result回调事件,关闭弹框
421
- $emit(this, 'result', selectNodeInfo)
422
- console.log('3=====setSelectNodeInfo=====', selectNodeInfo)
423
- }
424
- }
425
- },
426
- // 多选树时,点击节点处理复选框的选中状态
427
- clickNodeWhenMultiple(data) {
428
- var checkedKeys = []
429
- if (this.$refs.workgroupUserTree) {
430
- checkedKeys = this.$refs.workgroupUserTree.getCheckedKeys()
431
- }
432
- // 取消选中状态时,保持节点是展开的状态,不要折叠
433
- this.$refs.workgroupUserTree.store.nodesMap[data.nodeId].expanded = true
434
- if (checkedKeys.indexOf(data.nodeId) > -1) {
435
- // 表示当前节点是选中状态,则需要取消其选中状态
436
- // 取消当前节点的勾选状态
437
- this.$refs.workgroupUserTree.setChecked(data.nodeId, false)
438
- this.cancelCheckedNode(data)
439
- } else {
440
- // 表示当前节点不是选中的状态,需要勾选该节点
441
- this.$refs.workgroupUserTree.setChecked(data.nodeId, true)
442
- this.checkedNode(data, true)
443
- }
444
- },
445
- isUserNode(data) {
446
- // 当前节点不是公司节点,也不是分支机构节点,表示是部门节点
447
- return (
448
- data.id !== this.tenantNodeId &&
449
- data.nodeType &&
450
- data.nodeType === 'USER'
451
- )
452
- },
453
- singleSetValue() {
454
- let showTip = false
455
- if (this.searchValue) {
456
- console.log('this.selectNodeInfo', this.selectNodeInfo)
457
- if (this.selectNodeInfo) {
458
- $emit(this, 'result', this.selectNodeInfo)
459
- } else {
460
- showTip = true
461
- }
462
- } else {
463
- const data = this.$refs.workgroupUserTree.getCurrentNode()
464
- if (data && data !== null && this.isUserNode(data)) {
465
- this.selectSingleNode(data, true)
466
- } else {
467
- showTip = true
468
- }
469
- }
470
- this.showTip(showTip)
471
- },
472
- multipleSetValue() {
473
- let showTip = false
474
- // 选中的用户结果
475
- var selectNodeInfo = {
476
- userIds: [],
477
- userNames: [],
478
- loginNames: [],
479
- emails: [],
480
- telephones: [],
481
- users: [],
482
- }
483
- if (this.searchValue) {
484
- if (this.selectResult.length > 0) {
485
- this.selectResult.forEach((workgroupData) => {
486
- this.addSelectedUserInfo(selectNodeInfo, workgroupData)
487
- })
488
- $emit(this, 'result', selectNodeInfo)
489
- } else {
490
- showTip = true
491
- }
492
- } else {
493
- var parentIds = []
494
- var nodes = this.$refs.workgroupUserTree.getCheckedNodes()
495
- if (nodes) {
496
- if (nodes.length === 0) {
497
- // 没有选择任何节点
498
- showTip = true
499
- } else {
500
- for (var i = 0; i < nodes.length; i++) {
501
- var node = nodes[i]
502
- if (this.isSelectTenantNode(node.id)) {
503
- // 表示选择了所有工作组人员
504
- selectNodeInfo.userIds = []
505
- selectNodeInfo.userNames = []
506
- selectNodeInfo.userIds.push(node.id)
507
- selectNodeInfo.userNames.push('所有工作组人员')
508
- break
509
- } else if (node.id !== this.tenantNodeId) {
510
- // 不是公司根节点
511
- if (node.leaf) {
512
- // 如果是叶子节点
513
- if (this.isUserNode(node)) {
514
- const user = JSON.parse(node.data)
515
- this.addSelectedUserInfo(selectNodeInfo, user)
516
- }
517
- } else {
518
- // 表示是工作组节点,且该节点下存在用户
519
- const userDatas = node.children
520
- if (userDatas && userDatas.length > 0) {
521
- // 表示已展开过该工作组
522
- userDatas.forEach((userData) => {
523
- const user = JSON.parse(userData.data)
524
- this.addSelectedUserInfo(selectNodeInfo, user)
525
- })
526
- } else {
527
- // 表示没有展开过该节点,需要去后台获得该工作组下的人员信息
528
- parentIds.push(node.id)
529
- }
530
- }
531
- }
532
- }
533
- if (parentIds.length > 0) {
534
- // 表示选中的工作组节点未展开过,则需要去后台查询获得这些工作组下的人员集合
535
- this.getAllSelectedWorkgroupUsers(parentIds, selectNodeInfo)
536
- showTip = false
537
- } else {
538
- if (selectNodeInfo.userIds.length > 0) {
539
- $emit(this, 'result', selectNodeInfo)
540
- console.log('1=====setSelectNodeInfo=====', selectNodeInfo)
541
- } else {
542
- showTip = true
543
- }
544
- }
545
- }
546
- } else {
547
- showTip = true
548
- }
549
- }
550
- this.showTip(showTip)
551
- },
552
- showTip(showTip) {
553
- // 是否需要显示提示框,默认不显示
554
- if (showTip) {
555
- this.$alert(
556
- this.$t('imatrixUIMessage.pleaseSelectPersonnel'),
557
- this.$t('imatrixUIMessage.tips'),
558
- {
559
- confirmButtonText: this.$t('imatrixUIPublicModel.sure'),
560
- }
561
- )
562
- }
563
- },
564
- selectWorkgroupUser() {
565
- if (this.multiple) {
566
- this.multipleSetValue()
567
- } else {
568
- this.singleSetValue()
569
- }
570
- },
571
- // 是否选中了公司节点
572
- isSelectTenantNode(dataId) {
573
- return (
574
- dataId === this.tenantNodeId &&
575
- (!this.branchInfo || this.branchInfo.length === 0)
576
- )
577
- },
578
- // 将选中的部门节点添加到结果集合中
579
- addSelectedUserInfo(result, user) {
580
- const filterResult = result.userIds.filter(this.filterUserId(user))
581
- if (filterResult.length === 0) {
582
- let name = user.name
583
- if (user.enName && user.enName !== '') {
584
- name = name + '(' + user.enName + ')'
585
- }
586
- // if (this.containBranch && user.subCompanyName) {
587
- // // 如果包含分支机构,则拼接分支机构名称
588
- // name = name + '(' + user.subCompanyName + ')'
589
- // }
590
- user.tenantCode = this.tenantInfo.code
591
- user.tenantName = this.tenantInfo.tenantName
592
- result.containBranch = this.containBranch
593
- result.users.push(user)
594
- result.userIds.push(user.id)
595
- result.loginNames.push(user.loginName)
596
- result.userNames.push(name)
597
- result.emails.push(user.email)
598
- result.telephones.push(user.telephone)
599
- }
600
- },
601
- filterUserId(queryWorkgroup) {
602
- return (workgroupNodeId) => {
603
- return workgroupNodeId === queryWorkgroup.id
604
- }
605
- },
606
- filterUserNode(queryUser) {
607
- return (userNodeId) => {
608
- // 用户节点的id的分隔符,USER~departmentId~userId
609
- const nodeIdSeparator = '~'
610
- const userId = userNodeId.substring(
611
- userNodeId.lastIndexOf(nodeIdSeparator) + 1
612
- )
613
- return userId === queryUser.id + ''
614
- }
615
- },
616
- // 给节点添加自定义图标
617
- renderContent(h, { node, data, store }) {
618
- var className
619
- if (node.data.id === -1) {
620
- // node.id ===-1表示公司节点,node.branch表示是分支机构节点
621
- className = 'el-icon-menu'
622
- } else {
623
- // 表示是工作组节点
624
- className = 'el-icon-date'
625
- }
626
- if (
627
- data.nodeType &&
628
- data.nodeType === 'USER' &&
629
- this.searchValue &&
630
- this.filterUserVal(data, this.searchValue)
631
- ) {
632
- // 如果是查询条件
633
- return `<span>
634
- <i class={className}></i>
635
- <span class="searchResult" title={node.label}>
636
- {node.label}
637
- </span>
638
- </span>`
639
- }
640
- return `<span>
641
- <i class={className}></i>
642
- <span title={node.label}>{node.label}</span>
643
- </span>`
644
- },
645
- },
646
- emits: ['result'],
647
- }
648
- </script>
649
-
650
- <style>
651
- .searchResult {
652
- color: red;
653
- }
654
- .inline-input-custom {
655
- width: 90%;
656
- }
657
- </style>
1
+ <template>
2
+ <div>
3
+ <el-container style="height: 395px">
4
+ <el-aside width="430px">
5
+ <el-container style="height: 390px">
6
+ <el-header style="text-align: right; font-size: 12px; height: 35px">
7
+ <el-autocomplete
8
+ v-model="filterText"
9
+ size="small"
10
+ select-when-unmatched
11
+ class="inline-input inline-input-custom"
12
+ :fetch-suggestions="querySearch"
13
+ :placeholder="$t('departmentUserTree.pleaseEnterUserInformation')"
14
+ :trigger-on-focus="false"
15
+ @select="handleSelect"
16
+ @keyup.enter="clickSearch"
17
+ >
18
+ <template v-slot:append>
19
+ <el-button :icon="ElIconSearch" @click="clickSearch" />
20
+ </template>
21
+ </el-autocomplete>
22
+ </el-header>
23
+ <el-main style="padding: 10px">
24
+ <div
25
+ v-if="!searchValue"
26
+ style="
27
+ padding-top: 5px;
28
+ overflow: auto;
29
+ width: auto;
30
+ display: inline-block !important;
31
+ "
32
+ >
33
+ <el-tree
34
+ ref="workgroupUserTree"
35
+ :props="defaultProps"
36
+ :load="loadNode"
37
+ lazy
38
+ :show-checkbox="multiple"
39
+ node-key="nodeId"
40
+ :render-content="renderContent"
41
+ :filter-node-method="filterNode"
42
+ @check="handleCheckNode"
43
+ @node-click="handleNodeClick"
44
+ />
45
+ </div>
46
+ <div
47
+ v-if="searchValue && searchValue.length > 0"
48
+ style="height: 100%; overflow: hidden"
49
+ >
50
+ <workgroup-user-result
51
+ ref="workgroupUserResult"
52
+ :grid-data="searchResult"
53
+ :select-result="selectResult"
54
+ :height="height"
55
+ :multiple="multiple"
56
+ :is-search-result="true"
57
+ @selectResult="getSelectWorkgroupUser"
58
+ @resultRowDblclick="resultRowDblclick"
59
+ @addWorkgroupUser="addWorkgroupUser"
60
+ />
61
+ </div>
62
+ </el-main>
63
+ </el-container>
64
+ </el-aside>
65
+ <el-container v-if="multiple">
66
+ <el-aside width="2px">
67
+ <table
68
+ border="1px"
69
+ cellpadding="0"
70
+ cellspacing="0"
71
+ style="
72
+ height: 100%;
73
+ border-left-style: solid;
74
+ border-bottom-style: none;
75
+ border-right-style: none;
76
+ border-top-style: none;
77
+ border-left-color: #cccccc;
78
+ "
79
+ />
80
+ </el-aside>
81
+ <el-main style="padding: 10px">
82
+ <div style="text-align: left; font-size: 16px">
83
+ {{ $t('departmentUserTree.selectedPeople') }}::
84
+ </div>
85
+ <div :style="'padding-top: 5px;height:90%;overflow: hidden;'">
86
+ <workgroup-user-result
87
+ :grid-data="selectResult"
88
+ :height="height"
89
+ :multiple="multiple"
90
+ :is-search-result="false"
91
+ @selectResult="getSelectWorkgroupUser"
92
+ @resultRowDblclick="resultRowDblclick"
93
+ @removeWorkgroupUser="removeWorkgroupUser"
94
+ />
95
+ </div>
96
+ </el-main>
97
+ </el-container>
98
+ </el-container>
99
+ </div>
100
+ </template>
101
+
102
+ <script>
103
+ import { Search as ElIconSearch } from '@element-plus/icons-vue'
104
+ import { $on, $off, $once, $emit } from '../../utils/gogocodeTransfer'
105
+ import localStorage from '../../../src/utils/local-storage'
106
+ import utils from '../../utils/utils'
107
+ import workgroupTreeInlineService from './workgroup-tree-inline-service'
108
+ import WorkgroupUserResult from './search-result.vue'
109
+ export default {
110
+ data() {
111
+ return {
112
+ filterText: '',
113
+ defaultProps: {
114
+ id: 'id',
115
+ label: 'name',
116
+ children: 'children',
117
+ isLeaf: 'leaf',
118
+ },
119
+ searchParam: {
120
+ userField: null,
121
+ searchValue: null,
122
+ treeType: 'MAN_GROUP_TREE',
123
+ departmentInfo: null,
124
+ },
125
+ // 当前租户内是否包含分支机构。获得当前选中部门名称时,如果有分支,则需要将分支名称返回给用户,例如:部门1(分支1)
126
+ containBranch: false,
127
+ // 公司节点的id
128
+ tenantNodeId: -1,
129
+ // 用于保存所有查询出的节点id
130
+ allSearchNodeIds: [],
131
+ // 用于保存allSearchNodeIds中所有已加载子节点的id集合
132
+ allExpandNodeIds: [],
133
+ isClickNode: false,
134
+ // 查询的备选值
135
+ restaurants: [],
136
+ // 查询条件
137
+ searchValue: null,
138
+ // 工作组的查询结果
139
+ searchResult: [],
140
+ // 工作组的选中结果
141
+ selectResult: [],
142
+ searchStoreKey: 'searchWorkgroupUser',
143
+ // 单选时,选择的用户信息
144
+ selectNodeInfo: null,
145
+ // 公司根节点信息
146
+ tenantInfo: {},
147
+ ElIconSearch,
148
+ }
149
+ },
150
+ name: 'InlineWorkgroupUserTree',
151
+ components: {
152
+ WorkgroupUserResult,
153
+ },
154
+ props: {
155
+ // 是否是多选树,默认是true
156
+ multiple: {
157
+ type: Boolean,
158
+ default: true,
159
+ },
160
+ // 显示指定部门节点及其子节点,不传该属性,表示显示整个组织结构树
161
+ branchInfo: {
162
+ type: Array,
163
+ default: null,
164
+ },
165
+ // 多选用户树时,已选择用户id或登录名集合,多个之间以逗号隔开
166
+ selectUserInfo: {
167
+ type: [String, Number],
168
+ default: null,
169
+ },
170
+ // 移除用户时,用户属性名称:id、loginName、email、telephone,默认是loginName
171
+ searchField: {
172
+ type: String,
173
+ default: 'loginName',
174
+ },
175
+ // 多选树时结果之间的分隔符,默认是逗号分隔
176
+ separator: {
177
+ type: String,
178
+ default: ',',
179
+ },
180
+ },
181
+ computed: {},
182
+ watch: {
183
+ filterText(val) {
184
+ if (!val) {
185
+ this.searchValue = val
186
+ // 清空查询内容时,重新加载整个树
187
+ this.loadWorkgroup(this.tenantNodeId, this.tenantNodeId + '')
188
+ }
189
+ },
190
+ },
191
+ created() {},
192
+ mounted() {
193
+ var searchWorkgroup = localStorage.getObject(this.searchStoreKey)
194
+ if (searchWorkgroup) {
195
+ this.restaurants = searchWorkgroup
196
+ } else {
197
+ this.restaurants = []
198
+ }
199
+ },
200
+ methods: {
201
+ ...utils,
202
+ ...workgroupTreeInlineService,
203
+ // 将查询结果中指定工作组添加到已选择工作组集合中
204
+ addWorkgroupUser(index, workgroup) {
205
+ const containWorkgroups = this.selectResult.filter(
206
+ this.filterWorkgroup(workgroup)
207
+ )
208
+ if (containWorkgroups && containWorkgroups.length === 0) {
209
+ this.selectResult.push(workgroup)
210
+ }
211
+ },
212
+ filterWorkgroup(queryWorkgroup) {
213
+ return (workgroup) => {
214
+ return workgroup.id === queryWorkgroup.id
215
+ }
216
+ },
217
+ removeWorkgroupUser(index, workgroup) {
218
+ if (this.$refs.workgroupUserTree) {
219
+ // 通过查询结果添加的工作组,在返回到组织结构树时,也选中了该工作组,在移除该工作组时,需要去掉复选框的选中状态
220
+ const checkedKeys = this.$refs.workgroupUserTree.getCheckedKeys()
221
+ const currentCheckedWorkgroupNodeIds = checkedKeys.filter(
222
+ this.filterUserNode(workgroup)
223
+ )
224
+ if (currentCheckedWorkgroupNodeIds.length > 0) {
225
+ // 表示当前工作组是选中的状态,需要去掉
226
+ currentCheckedWorkgroupNodeIds.forEach((workgroupNodeId) => {
227
+ this.$refs.workgroupUserTree.setChecked(workgroupNodeId, false)
228
+ })
229
+ }
230
+ }
231
+ this.selectResult = this.removeRow(this.selectResult, workgroup)
232
+ if (!this.selectResult || this.selectResult.length === 0) {
233
+ // 已选结果面板没有内容,则左侧树节点也不要有选中节点了
234
+ if (this.$refs.workgroupUserTree) {
235
+ this.$refs.workgroupUserTree.setCheckedKeys([])
236
+ }
237
+ }
238
+ },
239
+ getSelectWorkgroupUser(workgroup) {
240
+ this.packageSelectResult(workgroup)
241
+ },
242
+ resultRowDblclick(workgroup) {
243
+ this.packageSelectResult(workgroup)
244
+ $emit(this, 'result', this.selectNodeInfo)
245
+ },
246
+ packageSelectResult(user) {
247
+ user.tenantCode = this.tenantInfo.code
248
+ user.tenantName = this.tenantInfo.tenantName
249
+ let name = user.name
250
+ if (user.enName && user.enName.trim() !== '') {
251
+ name = name + '(' + user.enName + ')'
252
+ }
253
+ const selectNodeInfo = {
254
+ id: user.id,
255
+ name: name,
256
+ loginName: user.loginName,
257
+ email: user.email,
258
+ telephone: user.telephone,
259
+ containBranch: this.containBranch,
260
+ user: user,
261
+ enName: user.enName,
262
+ subCompanyName: user.subCompanyName,
263
+ }
264
+ // 表示是勾选单选按钮或 选中树节点
265
+ this.selectNodeInfo = selectNodeInfo
266
+ },
267
+ handleSelect(item) {
268
+ this.handleSelectUtil(item, localStorage)
269
+ },
270
+ search(value) {
271
+ this.searchValue = value
272
+ // let mySearchValue = value
273
+ // if (mySearchValue) {
274
+ // mySearchValue = mySearchValue.trim()
275
+ // }
276
+ // this.searchParam.searchValue = mySearchValue
277
+ // this.searchParam.departmentInfo = this.branchInfo
278
+ // // this.searchParam.userField = this.searchField
279
+ // // 后台查询部门,并拼接树节点
280
+ // this.filterAppendNodes(value)
281
+ this.$refs.workgroupUserTree.filter(value)
282
+ },
283
+ // 点击查询按钮调用的方法
284
+ clickSearch() {
285
+ this.storeSeachValue(localStorage, this.searchStoreKey, this.filterText)
286
+ this.search(this.filterText)
287
+ },
288
+ filterNode(value, data, node) {
289
+ if (!value) {
290
+ return true
291
+ } else {
292
+ if (data.nodeType && data.nodeType === 'USER') {
293
+ // data.data是用户的所有数据
294
+ const user = JSON.parse(data.data)
295
+ return this.filterUserVal(user, value)
296
+ } else {
297
+ // 表示不是用户节点
298
+ return false
299
+ }
300
+ }
301
+ },
302
+ filterUserVal(user, searchVal) {
303
+ const searchFields = [
304
+ 'name',
305
+ 'loginName',
306
+ 'email',
307
+ 'telephone',
308
+ 'jobNumber',
309
+ 'honorificName',
310
+ ]
311
+ let isHasVal = false
312
+ for (let i = 0; i < searchFields.length; i++) {
313
+ const searchField = searchFields[i]
314
+ const userValue = user[searchField]
315
+ if (
316
+ userValue.indexOf(searchVal) !== -1 ||
317
+ (searchField === 'name' &&
318
+ user['enName'] &&
319
+ user['enName'].indexOf(searchVal) !== -1)
320
+ ) {
321
+ isHasVal = true
322
+ } else {
323
+ isHasVal = false
324
+ break
325
+ }
326
+ }
327
+ return isHasVal
328
+ },
329
+ // 点击复选框时处理
330
+ handleCheckNode(data, checkObj) {
331
+ if (checkObj.checkedKeys.indexOf(data.nodeId) > -1) {
332
+ // 表示正选中data节点
333
+ this.checkedNode(data, false)
334
+ } else {
335
+ // 表示正取消选中data节点,同时要取消其子节点的选中状态
336
+ this.cancelCheckedNode(data)
337
+ }
338
+ },
339
+ // 选中当前节点及其子节点
340
+ checkedNodeAndChildren(data) {
341
+ // 取消选中状态时,保持节点是展开的状态,不要折叠
342
+ this.$refs.workgroupUserTree.store.nodesMap[data.nodeId].expanded = true
343
+ // 获得所有应该选中的节点
344
+ this.$refs.workgroupUserTree.setChecked(data.nodeId, true)
345
+ const children = data.children
346
+ if (children) {
347
+ // 递归设置子子节点的选中状态
348
+ children.forEach((nodeData) => {
349
+ this.checkedNodeAndChildren(nodeData)
350
+ this.selectResult.push(JSON.parse(nodeData.data))
351
+ })
352
+ }
353
+ },
354
+ // 取消节点选中状态时
355
+ cancelCheckedNode(data) {
356
+ if (data.id === this.tenantNodeId) {
357
+ // 表示取消公司节点的选中状态,即取消所有节点的勾选状态
358
+ this.$refs.workgroupUserTree.setCheckedKeys([])
359
+ } else if (data.nodeType && data.nodeType === 'WORKGROUP') {
360
+ this.cancelCheckedUserNodesWithWorkgroup(data)
361
+ } else {
362
+ this.selectResult = this.removeRow(
363
+ this.selectResult,
364
+ JSON.parse(data.data)
365
+ )
366
+ }
367
+ },
368
+ // 选中了根节点公司节点时,选中所有工作组
369
+ checkedAllWorkgroups(root) {
370
+ const children = root.children
371
+ if (children) {
372
+ children.forEach((workgroupNode) => {
373
+ this.$refs.workgroupUserTree.setChecked(workgroupNode.nodeId, true)
374
+ })
375
+ }
376
+ },
377
+ // 取消指定工作组下的用户节点的选中状态
378
+ cancelCheckedUserNodesWithWorkgroup(workgroupData) {
379
+ const children = workgroupData.children
380
+ if (children) {
381
+ children.forEach((userNode) => {
382
+ this.$refs.workgroupUserTree.setChecked(userNode.nodeId, false)
383
+ this.selectResult = this.removeRow(
384
+ this.selectResult,
385
+ JSON.parse(userNode.data)
386
+ )
387
+ })
388
+ }
389
+ },
390
+ handleNodeClick(data, node, nodeTree) {
391
+ if (this.multiple) {
392
+ // 多选部门树时,处理点击节点事件
393
+ this.clickNodeWhenMultiple(data)
394
+ }
395
+ this.selectSingleNode(data, false)
396
+ },
397
+ selectSingleNode(data, isClickOkBtn) {
398
+ if (this.isUserNode(data) && !this.multiple) {
399
+ // 点击的是工作组节点,并且是单选树时,点击部门节点直接关闭弹框
400
+ const user = JSON.parse(data.data)
401
+ user.tenantCode = this.tenantInfo.code
402
+ user.tenantName = this.tenantInfo.tenantName
403
+ let name = user.name
404
+ if (user.enName && user.enName.trim() !== '') {
405
+ name = name + '(' + user.enName + ')'
406
+ }
407
+ const selectNodeInfo = {
408
+ id: user.id,
409
+ name: name,
410
+ loginName: user.loginName,
411
+ email: user.email,
412
+ telephone: user.telephone,
413
+ containBranch: this.containBranch,
414
+ user: user,
415
+ enName: user.enName,
416
+ subCompanyName: user.subCompanyName,
417
+ }
418
+ this.selectNodeInfo = selectNodeInfo
419
+ if (isClickOkBtn === true) {
420
+ // 点击确定按钮时才需要调result回调事件,关闭弹框
421
+ $emit(this, 'result', selectNodeInfo)
422
+ console.log('3=====setSelectNodeInfo=====', selectNodeInfo)
423
+ }
424
+ }
425
+ },
426
+ // 多选树时,点击节点处理复选框的选中状态
427
+ clickNodeWhenMultiple(data) {
428
+ var checkedKeys = []
429
+ if (this.$refs.workgroupUserTree) {
430
+ checkedKeys = this.$refs.workgroupUserTree.getCheckedKeys()
431
+ }
432
+ // 取消选中状态时,保持节点是展开的状态,不要折叠
433
+ this.$refs.workgroupUserTree.store.nodesMap[data.nodeId].expanded = true
434
+ if (checkedKeys.indexOf(data.nodeId) > -1) {
435
+ // 表示当前节点是选中状态,则需要取消其选中状态
436
+ // 取消当前节点的勾选状态
437
+ this.$refs.workgroupUserTree.setChecked(data.nodeId, false)
438
+ this.cancelCheckedNode(data)
439
+ } else {
440
+ // 表示当前节点不是选中的状态,需要勾选该节点
441
+ this.$refs.workgroupUserTree.setChecked(data.nodeId, true)
442
+ this.checkedNode(data, true)
443
+ }
444
+ },
445
+ isUserNode(data) {
446
+ // 当前节点不是公司节点,也不是分支机构节点,表示是部门节点
447
+ return (
448
+ data.id !== this.tenantNodeId &&
449
+ data.nodeType &&
450
+ data.nodeType === 'USER'
451
+ )
452
+ },
453
+ singleSetValue() {
454
+ let showTip = false
455
+ if (this.searchValue) {
456
+ console.log('this.selectNodeInfo', this.selectNodeInfo)
457
+ if (this.selectNodeInfo) {
458
+ $emit(this, 'result', this.selectNodeInfo)
459
+ } else {
460
+ showTip = true
461
+ }
462
+ } else {
463
+ const data = this.$refs.workgroupUserTree.getCurrentNode()
464
+ if (data && data !== null && this.isUserNode(data)) {
465
+ this.selectSingleNode(data, true)
466
+ } else {
467
+ showTip = true
468
+ }
469
+ }
470
+ this.showTip(showTip)
471
+ },
472
+ multipleSetValue() {
473
+ let showTip = false
474
+ // 选中的用户结果
475
+ var selectNodeInfo = {
476
+ userIds: [],
477
+ userNames: [],
478
+ loginNames: [],
479
+ emails: [],
480
+ telephones: [],
481
+ users: [],
482
+ }
483
+ if (this.searchValue) {
484
+ if (this.selectResult.length > 0) {
485
+ this.selectResult.forEach((workgroupData) => {
486
+ this.addSelectedUserInfo(selectNodeInfo, workgroupData)
487
+ })
488
+ $emit(this, 'result', selectNodeInfo)
489
+ } else {
490
+ showTip = true
491
+ }
492
+ } else {
493
+ var parentIds = []
494
+ var nodes = this.$refs.workgroupUserTree.getCheckedNodes()
495
+ if (nodes) {
496
+ if (nodes.length === 0) {
497
+ // 没有选择任何节点
498
+ showTip = true
499
+ } else {
500
+ for (var i = 0; i < nodes.length; i++) {
501
+ var node = nodes[i]
502
+ if (this.isSelectTenantNode(node.id)) {
503
+ // 表示选择了所有工作组人员
504
+ selectNodeInfo.userIds = []
505
+ selectNodeInfo.userNames = []
506
+ selectNodeInfo.userIds.push(node.id)
507
+ selectNodeInfo.userNames.push('所有工作组人员')
508
+ break
509
+ } else if (node.id !== this.tenantNodeId) {
510
+ // 不是公司根节点
511
+ if (node.leaf) {
512
+ // 如果是叶子节点
513
+ if (this.isUserNode(node)) {
514
+ const user = JSON.parse(node.data)
515
+ this.addSelectedUserInfo(selectNodeInfo, user)
516
+ }
517
+ } else {
518
+ // 表示是工作组节点,且该节点下存在用户
519
+ const userDatas = node.children
520
+ if (userDatas && userDatas.length > 0) {
521
+ // 表示已展开过该工作组
522
+ userDatas.forEach((userData) => {
523
+ const user = JSON.parse(userData.data)
524
+ this.addSelectedUserInfo(selectNodeInfo, user)
525
+ })
526
+ } else {
527
+ // 表示没有展开过该节点,需要去后台获得该工作组下的人员信息
528
+ parentIds.push(node.id)
529
+ }
530
+ }
531
+ }
532
+ }
533
+ if (parentIds.length > 0) {
534
+ // 表示选中的工作组节点未展开过,则需要去后台查询获得这些工作组下的人员集合
535
+ this.getAllSelectedWorkgroupUsers(parentIds, selectNodeInfo)
536
+ showTip = false
537
+ } else {
538
+ if (selectNodeInfo.userIds.length > 0) {
539
+ $emit(this, 'result', selectNodeInfo)
540
+ console.log('1=====setSelectNodeInfo=====', selectNodeInfo)
541
+ } else {
542
+ showTip = true
543
+ }
544
+ }
545
+ }
546
+ } else {
547
+ showTip = true
548
+ }
549
+ }
550
+ this.showTip(showTip)
551
+ },
552
+ showTip(showTip) {
553
+ // 是否需要显示提示框,默认不显示
554
+ if (showTip) {
555
+ this.$alert(
556
+ this.$t('imatrixUIMessage.pleaseSelectPersonnel'),
557
+ this.$t('imatrixUIMessage.tips'),
558
+ {
559
+ confirmButtonText: this.$t('imatrixUIPublicModel.sure'),
560
+ }
561
+ )
562
+ }
563
+ },
564
+ selectWorkgroupUser() {
565
+ if (this.multiple) {
566
+ this.multipleSetValue()
567
+ } else {
568
+ this.singleSetValue()
569
+ }
570
+ },
571
+ // 是否选中了公司节点
572
+ isSelectTenantNode(dataId) {
573
+ return (
574
+ dataId === this.tenantNodeId &&
575
+ (!this.branchInfo || this.branchInfo.length === 0)
576
+ )
577
+ },
578
+ // 将选中的部门节点添加到结果集合中
579
+ addSelectedUserInfo(result, user) {
580
+ const filterResult = result.userIds.filter(this.filterUserId(user))
581
+ if (filterResult.length === 0) {
582
+ let name = user.name
583
+ if (user.enName && user.enName !== '') {
584
+ name = name + '(' + user.enName + ')'
585
+ }
586
+ // if (this.containBranch && user.subCompanyName) {
587
+ // // 如果包含分支机构,则拼接分支机构名称
588
+ // name = name + '(' + user.subCompanyName + ')'
589
+ // }
590
+ user.tenantCode = this.tenantInfo.code
591
+ user.tenantName = this.tenantInfo.tenantName
592
+ result.containBranch = this.containBranch
593
+ result.users.push(user)
594
+ result.userIds.push(user.id)
595
+ result.loginNames.push(user.loginName)
596
+ result.userNames.push(name)
597
+ result.emails.push(user.email)
598
+ result.telephones.push(user.telephone)
599
+ }
600
+ },
601
+ filterUserId(queryWorkgroup) {
602
+ return (workgroupNodeId) => {
603
+ return workgroupNodeId === queryWorkgroup.id
604
+ }
605
+ },
606
+ filterUserNode(queryUser) {
607
+ return (userNodeId) => {
608
+ // 用户节点的id的分隔符,USER~departmentId~userId
609
+ const nodeIdSeparator = '~'
610
+ const userId = userNodeId.substring(
611
+ userNodeId.lastIndexOf(nodeIdSeparator) + 1
612
+ )
613
+ return userId === queryUser.id + ''
614
+ }
615
+ },
616
+ // 给节点添加自定义图标
617
+ renderContent(h, { node, data, store }) {
618
+ var className
619
+ if (node.data.id === -1) {
620
+ // node.id ===-1表示公司节点,node.branch表示是分支机构节点
621
+ className = 'el-icon-menu'
622
+ } else {
623
+ // 表示是工作组节点
624
+ className = 'el-icon-date'
625
+ }
626
+ if (
627
+ data.nodeType &&
628
+ data.nodeType === 'USER' &&
629
+ this.searchValue &&
630
+ this.filterUserVal(data, this.searchValue)
631
+ ) {
632
+ // 如果是查询条件
633
+ return `<span>
634
+ <i class={className}></i>
635
+ <span class="searchResult" title={node.label}>
636
+ {node.label}
637
+ </span>
638
+ </span>`
639
+ }
640
+ return `<span>
641
+ <i class={className}></i>
642
+ <span title={node.label}>{node.label}</span>
643
+ </span>`
644
+ },
645
+ },
646
+ emits: ['result'],
647
+ }
648
+ </script>
649
+
650
+ <style>
651
+ .searchResult {
652
+ color: red;
653
+ }
654
+ .inline-input-custom {
655
+ width: 90%;
656
+ }
657
+ </style>