@ebiz/designer-components 0.1.124 → 0.1.125

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 (230) hide show
  1. package/README.md +29 -29
  2. package/dist/designer-components.css +1 -1
  3. package/dist/index.mjs +35847 -33799
  4. package/dist/{pdf-C9oIcL2N.js → pdf-KomaE0u5.js} +891 -891
  5. package/package.json +1 -1
  6. package/src/App.vue +26 -26
  7. package/src/apiService/SIMPLE_DATA_SERVICE.md +284 -284
  8. package/src/apiService/mockDataService.js +115 -115
  9. package/src/apiService/simpleDataService.js +312 -312
  10. package/src/assets/base.css +86 -86
  11. package/src/assets/logo.svg +1 -1
  12. package/src/components/Button.vue +149 -149
  13. package/src/components/DataContainer.vue +40 -40
  14. package/src/components/EbizApproval.vue +366 -366
  15. package/src/components/EbizApprovalDetail.vue +169 -169
  16. package/src/components/EbizApprovalForm.vue +534 -534
  17. package/src/components/EbizApprovalV2.vue +713 -713
  18. package/src/components/EbizAutoForm.vue +596 -596
  19. package/src/components/EbizAvatar.vue +115 -115
  20. package/src/components/EbizCheckbox.vue +93 -93
  21. package/src/components/EbizCheckboxGroup.vue +69 -69
  22. package/src/components/EbizDepartmentSelector.vue +148 -148
  23. package/src/components/EbizDescriptions.vue +340 -340
  24. package/src/components/EbizDescriptionsItem.vue +47 -47
  25. package/src/components/EbizDetailBlock.vue +81 -81
  26. package/src/components/EbizDetailItem.vue +559 -559
  27. package/src/components/EbizDetailView.md +438 -438
  28. package/src/components/EbizDetailView.vue +355 -355
  29. package/src/components/EbizDialog.vue +260 -260
  30. package/src/components/EbizDictionarySelect.vue +229 -229
  31. package/src/components/EbizDiv.vue +40 -40
  32. package/src/components/EbizDivider.vue +96 -96
  33. package/src/components/EbizDormDashboard.vue +314 -314
  34. package/src/components/EbizDropdown.vue +135 -135
  35. package/src/components/EbizDropdownItem.vue +85 -85
  36. package/src/components/EbizEmployeeInfo.vue +144 -144
  37. package/src/components/EbizEmployeeSelector.vue +1160 -1160
  38. package/src/components/EbizFileList.vue +502 -502
  39. package/src/components/EbizMap.vue +541 -541
  40. package/src/components/EbizMeetingRoomSelector.vue +1149 -1149
  41. package/src/components/EbizMobileMeetingRoomSelector.vue +727 -727
  42. package/src/components/EbizOkrTree.vue +99 -99
  43. package/src/components/EbizPageHeader.vue +98 -98
  44. package/src/components/EbizPagination.vue +162 -162
  45. package/src/components/EbizParkingDashboard.vue +152 -152
  46. package/src/components/EbizPdfViewer.vue +540 -540
  47. package/src/components/EbizPopconfirm.vue +47 -47
  48. package/src/components/EbizQrCode.vue +167 -167
  49. package/src/components/EbizRadio.vue +86 -86
  50. package/src/components/EbizRadioGroup.vue +83 -83
  51. package/src/components/EbizRemoteSelect.vue +232 -232
  52. package/src/components/EbizRichTextEditor.vue +338 -338
  53. package/src/components/EbizRouteBreadcrumb.vue +46 -46
  54. package/src/components/EbizSApprovalProcess.vue +1456 -1426
  55. package/src/components/EbizSelect.vue +85 -85
  56. package/src/components/EbizSpace.vue +100 -100
  57. package/src/components/EbizStatistic.vue +149 -149
  58. package/src/components/EbizStatsCard.vue +113 -113
  59. package/src/components/EbizSwiper.vue +113 -113
  60. package/src/components/EbizSwiperItem.vue +13 -13
  61. package/src/components/EbizSwitch.vue +85 -85
  62. package/src/components/EbizTabHeader.vue +132 -132
  63. package/src/components/EbizTabPanel.vue +22 -22
  64. package/src/components/EbizTable.vue +469 -469
  65. package/src/components/EbizTableColumn.vue +116 -116
  66. package/src/components/EbizTableSort.vue +179 -179
  67. package/src/components/EbizTabs.vue +142 -142
  68. package/src/components/EbizTdesignButtonDialog.vue +332 -332
  69. package/src/components/EbizTdesignLoading.vue +107 -107
  70. package/src/components/EbizTimePicker.vue +143 -143
  71. package/src/components/EbizTitle.vue +91 -91
  72. package/src/components/EbizTree.vue +141 -141
  73. package/src/components/EbizTreeMergeTable.vue +1494 -1494
  74. package/src/components/EbizTreeSelector.vue +469 -469
  75. package/src/components/EbizVideo.vue +553 -553
  76. package/src/components/EbizVxeTable.vue +290 -290
  77. package/src/components/Form.vue +28 -28
  78. package/src/components/Home.vue +7 -7
  79. package/src/components/LaunchInterview.vue +526 -526
  80. package/src/components/MyComponent.vue +39 -39
  81. package/src/components/Table.vue +45 -45
  82. package/src/components/TdesignAlert.vue +115 -115
  83. package/src/components/TdesignButton.vue +135 -135
  84. package/src/components/TdesignCalendar/index.vue +145 -145
  85. package/src/components/TdesignCard.vue +195 -195
  86. package/src/components/TdesignCol.vue +101 -101
  87. package/src/components/TdesignCollapse.vue +142 -142
  88. package/src/components/TdesignCollapsePanel.vue +79 -79
  89. package/src/components/TdesignDatePicker.vue +124 -124
  90. package/src/components/TdesignDescriptions.vue +74 -74
  91. package/src/components/TdesignDescriptionsItem.vue +50 -50
  92. package/src/components/TdesignDialog.vue +225 -225
  93. package/src/components/TdesignForm.vue +138 -138
  94. package/src/components/TdesignFormItem.vue +105 -105
  95. package/src/components/TdesignGrid.vue +55 -55
  96. package/src/components/TdesignIcon.vue +67 -67
  97. package/src/components/TdesignImage.vue +162 -162
  98. package/src/components/TdesignImageViewer.vue +200 -200
  99. package/src/components/TdesignInput.vue +242 -242
  100. package/src/components/TdesignSelect.vue +446 -446
  101. package/src/components/TdesignTag.vue +117 -117
  102. package/src/components/TdesignTextarea.vue +142 -142
  103. package/src/components/TdesignTimeline.vue +58 -58
  104. package/src/components/TdesignTimelineItem.vue +71 -71
  105. package/src/components/TdesignUpload.vue +414 -414
  106. package/src/components/TdesignWatermark.vue +107 -107
  107. package/src/components/ebiz-form/components/cascader.vue +61 -61
  108. package/src/components/ebiz-form/components/checkbox.vue +37 -37
  109. package/src/components/ebiz-form/components/city.vue +137 -137
  110. package/src/components/ebiz-form/components/date-panel.vue +52 -52
  111. package/src/components/ebiz-form/components/date-range-panel.vue +52 -52
  112. package/src/components/ebiz-form/components/date-range.vue +56 -56
  113. package/src/components/ebiz-form/components/date.vue +52 -52
  114. package/src/components/ebiz-form/components/editor-multi-language.vue +47 -47
  115. package/src/components/ebiz-form/components/editor.vue +78 -78
  116. package/src/components/ebiz-form/components/file-multi-language.vue +52 -52
  117. package/src/components/ebiz-form/components/file.vue +149 -149
  118. package/src/components/ebiz-form/components/images-multi-language.vue +52 -52
  119. package/src/components/ebiz-form/components/images.vue +129 -129
  120. package/src/components/ebiz-form/components/img-multi-language.vue +51 -51
  121. package/src/components/ebiz-form/components/img.vue +129 -129
  122. package/src/components/ebiz-form/components/number.vue +50 -50
  123. package/src/components/ebiz-form/components/radio.vue +28 -28
  124. package/src/components/ebiz-form/components/select.vue +119 -119
  125. package/src/components/ebiz-form/components/switch.vue +23 -23
  126. package/src/components/ebiz-form/components/text-multi-language.vue +47 -47
  127. package/src/components/ebiz-form/components/text.vue +52 -52
  128. package/src/components/ebiz-form/components/textarea-multi-language.vue +48 -48
  129. package/src/components/ebiz-form/components/textarea.vue +29 -29
  130. package/src/components/ebiz-form/components/video-multi-language.vue +51 -51
  131. package/src/components/ebiz-form/components/video.vue +97 -97
  132. package/src/components/ebiz-form/index.vue +157 -157
  133. package/src/components/examples/PopconfirmExample.vue +149 -149
  134. package/src/components/icons/IconCommunity.vue +7 -7
  135. package/src/components/icons/IconDocumentation.vue +7 -7
  136. package/src/components/icons/IconEcosystem.vue +7 -7
  137. package/src/components/icons/IconSupport.vue +7 -7
  138. package/src/components/icons/IconTooling.vue +19 -19
  139. package/src/components/mItems/UserInfo.vue +349 -349
  140. package/src/components/senior/EbizApprovalList/ApprovalList.vue +127 -127
  141. package/src/components/senior/EbizSData/index.vue +280 -280
  142. package/src/components/senior/EbizSDialog/index.vue +776 -776
  143. package/src/components/senior/EbizSForm/README.md +157 -157
  144. package/src/components/senior/EbizSForm/index.vue +667 -667
  145. package/src/components/senior/EbizSForm/item.vue +1011 -1011
  146. package/src/components/senior/EbizSForm/mItems/DateTimePicker.vue +51 -51
  147. package/src/components/senior/EbizSForm/mItems/Picker.vue +63 -63
  148. package/src/index.js +327 -327
  149. package/src/main.js +55 -55
  150. package/src/router/index.js +436 -436
  151. package/src/utils/formatCode.js +24 -24
  152. package/src/utils/generateImportStatement.js +52 -52
  153. package/src/utils/hasJsx.js +25 -25
  154. package/src/utils/index.js +166 -166
  155. package/src/utils/mergeOptions.js +29 -29
  156. package/src/utils/parseRequiredBlocks.js +18 -18
  157. package/src/utils/vue-sfc-validator.js +155 -155
  158. package/src/views/Button.vue +23 -23
  159. package/src/views/CheckboxDemo.vue +104 -104
  160. package/src/views/DataContainer.vue +19 -19
  161. package/src/views/DialogDemo.vue +125 -125
  162. package/src/views/EbizApprovalDemo.vue +87 -87
  163. package/src/views/EbizApprovalFormDemo.vue +207 -207
  164. package/src/views/EbizAutoFormDemo.vue +129 -129
  165. package/src/views/EbizAvatar.vue +223 -223
  166. package/src/views/EbizDepartmentSelectorDemo.vue +169 -169
  167. package/src/views/EbizDetailBlockDemo.vue +30 -30
  168. package/src/views/EbizDetailViewDemo.vue +412 -412
  169. package/src/views/EbizDormDashboardDemo.vue +87 -87
  170. package/src/views/EbizEmployeeInfo.vue +249 -249
  171. package/src/views/EbizEmployeeSelector.vue +85 -85
  172. package/src/views/EbizFileListDemo.vue +339 -339
  173. package/src/views/EbizMap.vue +201 -201
  174. package/src/views/EbizMeetingRoomSelectorDemo.vue +293 -293
  175. package/src/views/EbizMobileMeetingRoomSelectorDemo.vue +566 -566
  176. package/src/views/EbizParkingDashboardDemo.vue +28 -28
  177. package/src/views/EbizRadioDemo.vue +151 -151
  178. package/src/views/EbizSDataDemo.vue +136 -136
  179. package/src/views/EbizSDialogDemo.vue +303 -303
  180. package/src/views/EbizSForm/index.vue +352 -352
  181. package/src/views/EbizSFormDemo.vue +420 -420
  182. package/src/views/EbizSpace.vue +185 -185
  183. package/src/views/EbizSwiper.vue +157 -157
  184. package/src/views/EbizTdesignButtonDialogExample.vue +437 -437
  185. package/src/views/Form.vue +19 -19
  186. package/src/views/GridDemo.vue +238 -238
  187. package/src/views/Home.vue +156 -156
  188. package/src/views/LaunchInterviewDemo.vue +111 -111
  189. package/src/views/Mindmap.vue +17 -17
  190. package/src/views/MyComponent.vue +19 -19
  191. package/src/views/OkrTree.vue +19 -19
  192. package/src/views/PageHeaderDemo.vue +104 -104
  193. package/src/views/PaginationDemo.vue +96 -96
  194. package/src/views/PdfViewerDemo.vue +433 -433
  195. package/src/views/PermissionBoxDemo.vue +85 -85
  196. package/src/views/PopconfirmDemo.vue +80 -80
  197. package/src/views/RemoteSelect.vue +350 -350
  198. package/src/views/StatisticDemo.vue +190 -190
  199. package/src/views/SwitchDemo.vue +79 -79
  200. package/src/views/Table.vue +19 -19
  201. package/src/views/TableDemo.vue +334 -334
  202. package/src/views/TableSortDemo.vue +143 -143
  203. package/src/views/TableView.vue +68 -68
  204. package/src/views/TabsDemo.vue +282 -282
  205. package/src/views/TagDemo.vue +101 -101
  206. package/src/views/TdesignAlert.vue +98 -98
  207. package/src/views/TdesignButton.vue +190 -190
  208. package/src/views/TdesignCalendar.vue +94 -94
  209. package/src/views/TdesignCard.vue +296 -296
  210. package/src/views/TdesignCollapse.vue +293 -293
  211. package/src/views/TdesignDatePicker.vue +187 -187
  212. package/src/views/TdesignDescriptions.vue +101 -101
  213. package/src/views/TdesignForm.vue +248 -248
  214. package/src/views/TdesignIcon.vue +203 -203
  215. package/src/views/TdesignImage.vue +215 -215
  216. package/src/views/TdesignImageViewer.vue +198 -198
  217. package/src/views/TdesignInput.vue +252 -252
  218. package/src/views/TdesignSelect.vue +473 -473
  219. package/src/views/TdesignSwiper.vue +157 -157
  220. package/src/views/TextareaDemo.vue +93 -93
  221. package/src/views/TimePickerDemo.vue +146 -146
  222. package/src/views/TimelineDemo.vue +160 -160
  223. package/src/views/Title.vue +19 -19
  224. package/src/views/TreeDemo.vue +254 -254
  225. package/src/views/TreeMergeTableDemo.vue +239 -239
  226. package/src/views/TreeSelectorDemo.vue +245 -245
  227. package/src/views/UploadDemo.vue +128 -128
  228. package/src/views/VideoDemo.vue +245 -245
  229. package/src/views/VxeTableDemo.vue +279 -279
  230. package/src/views/WatermarkDemo.vue +85 -85
@@ -1,1161 +1,1161 @@
1
- <template>
2
- <div class="ebiz-employee-selector">
3
- <!-- 选择框展示区 -->
4
- <div v-if="showDefault" style="display: flex; flex-direction: column; align-items: flex-start; gap: 10px;">
5
- <slot name="selected-items" :event="{ remove: removeItem }" :data="selectedItems">
6
- <div class="selected-items" v-if="selectedItems && selectedItems.length">
7
- <div v-for="(item, index) in selectedItems" :key="index" class="selected-item">
8
- <t-avatar v-if="item.avatar" :image="item.avatar" size="small" />
9
- <t-avatar v-else size="small">{{ getAvatarText(item.name) }}</t-avatar>
10
- <span class="item-info">
11
- <span class="item-code">{{ item.no }} - </span>
12
- <span class="item-name">{{ item.name }}</span>
13
- </span>
14
- <t-icon name="close" class="item-remove" @click="removeItem(index, item.id)"></t-icon>
15
- </div>
16
- </div>
17
- </slot>
18
-
19
- <t-button @click="showDialog" variant="text" theme="primary">{{ props.content }}</t-button>
20
- </div>
21
-
22
- <!-- 选择弹窗 -->
23
- <t-dialog v-model:visible="dialogVisible" :header="props.content" :width="800" footer :close-btn="true"
24
- :close-on-esc-keydown="true" :close-on-overlay-click="true" destroyOnClose>
25
-
26
- <!-- 选项卡 -->
27
- <t-tabs v-model="activeTab" class="selector-tabs">
28
- <t-tab-panel value="organization" label="组织架构" :destroyOnHide="false"></t-tab-panel>
29
- <t-tab-panel value="role" label="角色" :destroyOnHide="false"></t-tab-panel>
30
- <!-- <t-tab-panel value="position" label="岗位" :destroyOnHide="false"></t-tab-panel> -->
31
- <!-- <t-tab-panel value="department" label="同部门" :destroyOnHide="false"></t-tab-panel> -->
32
- <!-- <t-tab-panel value="subordinate" label="我的下属" :destroyOnHide="false"></t-tab-panel> -->
33
- </t-tabs>
34
-
35
-
36
- <div>
37
-
38
- <div class="selector-dialog-content">
39
- <!-- 左侧选择区域 -->
40
- <div class="left-panel">
41
- <!-- 内容区域 -->
42
- <div class="content-area">
43
- <div v-if="loading" class="loading-container">
44
- <t-loading />
45
- </div>
46
- <!-- 组织架构 -->
47
- <div v-show="activeTab === 'organization'" class="tab-content">
48
- <t-tree ref="organizationTree" :data="organizationData"
49
- :keys="{ label: 'name', value: 'id', children: 'children' }" hover activable :active="currentActive"
50
- @active="handleActive" />
51
- </div>
52
-
53
- <!-- 角色 -->
54
- <div v-show="activeTab === 'role'" class="tab-content">
55
- <t-tree ref="roleTree" :data="roleData" :keys="{ label: 'name', value: 'code' }" hover activable
56
- :active="currentActive" @active="handleActive" />
57
- </div>
58
-
59
- <!-- 岗位 -->
60
- <div v-show="activeTab === 'position'" class="tab-content">
61
- <t-tree ref="positionTree" :data="positionData" :keys="{ label: 'name', value: 'id' }" hover activable
62
- :active="currentActive" @active="handleActive" />
63
- </div>
64
-
65
- <!-- 同部门 -->
66
- <div v-show="activeTab === 'department'" class="tab-content">
67
- <t-list :split="true" size="small">
68
- <t-list-item v-for="(item, index) in departmentData" :key="index">
69
- <div class="department-item" @click="selectDepartment(item)">
70
- {{ item.name }}
71
- </div>
72
- </t-list-item>
73
- </t-list>
74
- </div>
75
-
76
- <!-- 我的下属 -->
77
- <div v-show="activeTab === 'subordinate'" class="tab-content">
78
- <t-list :split="true" size="small">
79
- <t-list-item v-for="(item, index) in subordinateData" :key="index">
80
- <div class="department-item" @click="selectDepartment(item)">
81
- {{ item.name }}
82
- </div>
83
- </t-list-item>
84
- </t-list>
85
- </div>
86
- </div>
87
- </div>
88
-
89
- <!-- 右侧人员列表区域 -->
90
- <div class="right-panel">
91
- <div class="employee-header">
92
- <div class="employee-title">
93
- {{ currentNodeName || '人员列表' }}
94
- <div v-if="activeTab === 'organization'" class="sub-dept-option">
95
- <t-checkbox v-model="childDeptEnable">包含子部门</t-checkbox>
96
- </div>
97
- </div>
98
- <div class="employee-count" v-if="!single">
99
- <t-checkbox v-model="selectAll" @change="handleSelectAll">全选</t-checkbox>
100
- <span class="count-info">共 {{ employeeList.length }} 人</span>
101
- </div>
102
- </div>
103
-
104
- <!-- 搜索框 -->
105
- <div class="search-box">
106
- <t-input v-model="searchText" placeholder="请输入姓名/拼音/工号搜索" clearable @change="handleSearchEnter">
107
- <template #suffix-icon>
108
- <t-icon name="search" @click="handleSearchClick"></t-icon>
109
- </template>
110
- </t-input>
111
- <t-button v-if="searchText" size="small" theme="default" class="clear-search-btn"
112
- @click="clearSearch">清除搜索</t-button>
113
- </div>
114
-
115
- <t-checkbox-group v-if="!single" v-model="tempSelectedEmployeeIds" style="width: 100%;"
116
- @change="handleCheckChange">
117
- <div class="employee-list">
118
- <div v-for="(item, index) in filteredEmployeeList" :key="index" class="employee-item"
119
- style="cursor: pointer;">
120
- <t-checkbox :key="item.id" :value="item.id">
121
- <div style="display: flex; align-items: center; gap: 10px; flex: 1;">
122
- <div class="employee-avatar">
123
- <t-avatar v-if="item.avatar" :image="item.avatar" size="small" />
124
- <t-avatar v-else size="small">{{ getAvatarText(item.name) }}</t-avatar>
125
- </div>
126
- <div style="display: flex; align-items: center; justify-content: space-between; width: 300px;">
127
- <div class="employee-info">
128
- <div class="employee-code">{{ item.no }} - </div>
129
- <div class="employee-name">{{ item.name }}</div>
130
- </div>
131
- <div class="employee-dept">
132
- <small style="color: #999;">{{ item.postName }}</small>
133
- </div>
134
- </div>
135
- </div>
136
- </t-checkbox>
137
-
138
- </div>
139
- </div>
140
-
141
- </t-checkbox-group>
142
-
143
- <t-radio-group v-else style="width: 100%;" v-model="tempSelectedEmployeeId" @change="handleCheckChange">
144
- <div class="employee-list">
145
- <div v-for="(item, index) in filteredEmployeeList" :key="index" class="employee-item"
146
- style="cursor: pointer;">
147
- <t-radio :value="item.id">
148
- <div style="display: flex; align-items: center; gap: 10px; flex: 1;">
149
- <div class="employee-avatar">
150
- <t-avatar v-if="item.avatar" :image="item.avatar" size="small" />
151
- <t-avatar v-else size="small">{{ getAvatarText(item.name) }}</t-avatar>
152
- </div>
153
- <div style="display: flex; align-items: center; justify-content: space-between;width: 300px;">
154
- <div class="employee-info">
155
- <div class="employee-code">{{ item.no }} - </div>
156
- <div class="employee-name">{{ item.name }}</div>
157
- </div>
158
- <div class="employee-dept">
159
- <small style="color: #999;">{{ item.postName }}</small>
160
- </div>
161
- </div>
162
-
163
- </div>
164
- </t-radio>
165
-
166
- </div>
167
-
168
- </div>
169
-
170
- </t-radio-group>
171
-
172
-
173
- <div v-if="filteredEmployeeList.length === 0" class="empty-data">
174
- <t-empty />
175
- </div>
176
- </div>
177
- </div>
178
- </div>
179
-
180
-
181
- <!-- 底部按钮区域 -->
182
- <template #footer>
183
- <div class="dialog-footer">
184
- <div class="selected-preview">
185
- <div class="selected-people-count" v-if="!single">
186
- 已选: {{ tempSelectedEmployees.length }} 人
187
- </div>
188
- <div class="selected-people-list" v-if="tempSelectedEmployees.length > 0">
189
- <div v-for="(item, index) in tempSelectedEmployees" :key="index" class="selected-people-item">
190
- <t-avatar v-if="item.avatar" :image="item.avatar" size="small" />
191
- <t-avatar v-else size="small">{{ getAvatarText(item.name) }}</t-avatar>
192
- <span class="item-info">
193
- <span class="item-code">{{ item.no }}</span>
194
- <span class="item-name">{{ item.name }}</span>
195
- </span>
196
- <t-icon v-if="!single" name="close" class="item-remove" @click="removeSelectedEmployee(item)"></t-icon>
197
- </div>
198
- </div>
199
- </div>
200
- <div class="dialog-actions">
201
- <t-button theme="default" @click="handleCancel">取消</t-button>
202
- <t-button theme="primary" @click="handleConfirm">确定</t-button>
203
- </div>
204
- </div>
205
- </template>
206
- </t-dialog>
207
- </div>
208
- </template>
209
-
210
- <script setup>
211
- import { ref, computed, watch, onMounted } from 'vue';
212
- import {
213
- Dialog as TDialog,
214
- Button as TButton,
215
- Icon as TIcon,
216
- Input as TInput,
217
- Tabs as TTabs,
218
- TabPanel as TTabPanel,
219
- Loading as TLoading,
220
- Tree as TTree,
221
- Avatar as TAvatar,
222
- Checkbox as TCheckbox,
223
- CheckboxGroup as TCheckboxGroup,
224
- Empty as TEmpty,
225
- List as TList,
226
- ListItem as TListItem,
227
- MessagePlugin,
228
- Radio as TRadio,
229
- RadioGroup as TRadioGroup
230
- } from 'tdesign-vue-next';
231
- import dataService from '../apiService/simpleDataService';
232
-
233
- // 定义组件属性
234
- const props = defineProps({
235
- // 选中的数据,支持v-model,只存储ID列表
236
- showDefault: {
237
- type: Boolean,
238
- default: true
239
- },
240
- modelValue: {
241
- type: Array,
242
- default: undefined
243
- },
244
- // 单选模式
245
- single: {
246
- type: Boolean,
247
- default: false
248
- },
249
- // 是否展示默认标签页
250
- showDefaultTab: {
251
- type: Boolean,
252
- default: true
253
- },
254
- visible: {
255
- type: Boolean,
256
- default: null
257
- },
258
- // 是否包含部门
259
- includeDepartment: {
260
- type: Boolean,
261
- default: false
262
- },
263
- // 默认标签页
264
- defaultTab: {
265
- type: String,
266
- default: 'organization'
267
- },
268
- // 是否展示顶层组织
269
- showRootOrg: {
270
- type: Boolean,
271
- default: true
272
- },
273
- // 最大选择数量,0表示不限制
274
- maxCount: {
275
- type: Number,
276
- default: 0
277
- },
278
- content: {
279
- type: String,
280
- default: '选择人员'
281
- },
282
- // 是否显示已离职员工
283
- showResigned: {
284
- type: Boolean,
285
- default: false
286
- }
287
- });
288
-
289
- // 定义组件事件
290
- const emit = defineEmits(['update:modelValue', 'change', 'update:visible', 'confirm']);
291
- const tempVisible = ref(false);
292
-
293
- const tempSelectedEmployeeIds = ref([])
294
- const tempSelectedEmployeeId = ref("")
295
-
296
- // 内部状态变量
297
- const dialogVisible = computed({
298
- set(val) {
299
- if (props.visible == null) {
300
- tempVisible.value = val;
301
- return
302
- }
303
- emit('update:visible', val)
304
- },
305
- get() {
306
- return props.visible ?? tempVisible.value
307
- }
308
- });
309
-
310
- const searchText = ref('');
311
- const activeTab = ref(props.defaultTab);
312
- const loading = ref(false);
313
- const selectedItems = ref([]);
314
- // 对话框中临时保存的选中员工列表
315
- const tempSelectedEmployees = ref([]);
316
- // 是否查询子部门
317
- const childDeptEnable = ref(true);
318
-
319
- // 数据源
320
- const organizationData = ref([]);
321
- const roleData = ref([]);
322
- const positionData = ref([]);
323
- const departmentData = ref([]);
324
- const subordinateData = ref([]);
325
- const employeeList = ref([]);
326
- const currentActive = ref([]);
327
- const currentNodeName = ref('');
328
- const selectAll = ref(false);
329
-
330
- // 从名称中获取头像显示文本
331
- const getAvatarText = (name) => {
332
- return name ? name.substring(0, 1) : '';
333
- };
334
-
335
- const computedModelValue = computed({
336
- set(val) {
337
- if (props.single) {
338
- if (val.length > 0) {
339
- emit("update:modelValue", val[0]);
340
- } else {
341
- emit("update:modelValue", "");
342
- }
343
- return;
344
- }
345
- emit("update:modelValue", val);
346
- },
347
- get() {
348
-
349
- let value = props.modelValue
350
-
351
- if (props.single) {
352
- if (Array.isArray(props.modelValue)) {
353
- value = props.modelValue ? props.modelValue : [];
354
- } else {
355
- value = props.modelValue ? [props.modelValue] : [];
356
- }
357
- } else {
358
- if (!value) {
359
- value = [];
360
- }
361
- }
362
- console.log(props.single, value)
363
- value.forEach((val) => {
364
- return Number(val);
365
- })
366
- return value;
367
- }
368
- });
369
-
370
- // 更新全选状态
371
- const updateSelectAllStatus = () => {
372
- selectAll.value = employeeList.value.length > 0 && employeeList.value.every(item => item.checked);
373
- };
374
-
375
- const updateSelectStatus = () => {
376
- employeeList.value.forEach(item => {
377
- item.checked = computedModelValue.value.includes(item.id);
378
- })
379
- }
380
-
381
- // 选中的员工列表
382
- const selectedEmployees = computed(() => {
383
- return employeeList.value.filter((item) => item.checked);
384
- });
385
-
386
- // 根据搜索文本过滤的员工列表
387
- const filteredEmployeeList = computed(() => {
388
- return employeeList.value
389
- });
390
-
391
-
392
- // 获取组织架构数据
393
- const fetchOrganizationData = async () => {
394
- loading.value = true;
395
- try {
396
- const response = await dataService.fetch(
397
- {},
398
- {
399
- apiId: 1933,
400
- key: 'organizationalStructure'
401
- }, "/process/deptList"
402
- );
403
- organizationData.value = response;
404
- handleActive(null, 'organization')
405
- // organizationData.value = processOrgData(response.data || []);
406
- } catch (error) {
407
- MessagePlugin.error({
408
- content: '获取组织架构数据失败',
409
- duration: 3000
410
- });
411
- } finally {
412
- loading.value = false;
413
- }
414
- };
415
-
416
- // 获取角色数据
417
- const fetchRoleData = async () => {
418
- loading.value = true;
419
- try {
420
- const response = await dataService.fetch(
421
- {},
422
- {},
423
- '/process/roleList'
424
- );
425
- roleData.value = response || [];
426
- } catch (error) {
427
- MessagePlugin.error({
428
- content: '获取角色数据失败',
429
- duration: 3000
430
- });
431
- } finally {
432
- loading.value = false;
433
- }
434
- };
435
-
436
- // 获取岗位数据
437
- const fetchPositionData = async () => {
438
- loading.value = true;
439
- try {
440
- const response = await dataService.fetch(
441
- {},
442
- {
443
- },
444
- '/process/roleList'
445
- );
446
- positionData.value = response?.data || [];
447
- } catch (error) {
448
- MessagePlugin.error({
449
- content: '获取岗位数据失败',
450
- duration: 3000
451
- });
452
- } finally {
453
- loading.value = false;
454
- }
455
- };
456
-
457
- // 获取部门数据
458
- const fetchDepartmentData = async () => {
459
- loading.value = true;
460
- try {
461
- const response = await dataService.fetch(
462
- {},
463
- {
464
- apiId: 1933,
465
- key: 'departmentList',
466
- apiType: 'MULTIPLE_DATA_SEARCH'
467
- }
468
- );
469
- departmentData.value = response?.data || [];
470
- } catch (error) {
471
- MessagePlugin.error({
472
- content: '获取部门数据失败',
473
- duration: 3000
474
- });
475
- } finally {
476
- loading.value = false;
477
- }
478
- };
479
-
480
- // 获取下属数据
481
- const fetchSubordinateData = async () => {
482
- loading.value = true;
483
- try {
484
- const response = await dataService.fetch(
485
- {},
486
- {
487
- apiKey: 'subordinateList',
488
- apiType: 'MULTIPLE_DATA_SEARCH'
489
- }
490
- );
491
- subordinateData.value = response?.data || [];
492
- } catch (error) {
493
- MessagePlugin.error({
494
- content: '获取下属数据失败',
495
- duration: 3000
496
- });
497
- } finally {
498
- loading.value = false;
499
- }
500
- };
501
-
502
- // 根据节点ID获取员工列表
503
- const fetchEmployeesByNode = async (nodeId, type, keyword = searchText.value) => {
504
- loading.value = true;
505
- try {
506
- const params = {};
507
-
508
- // 只有当nodeId不为空且type有效时,添加对应参数
509
- if (nodeId && type) {
510
- // 添加是否显示已离职员工参数
511
- params.showResigned = props.showResigned;
512
- // 根据不同类型设置不同的查询参数
513
- switch (type) {
514
- case 'organization':
515
- params.deptId = Array.isArray(nodeId) ? nodeId[0] : nodeId;
516
- // 添加子部门查询参数
517
- params.childDeptEnable = childDeptEnable.value;
518
- break;
519
- case 'role':
520
- params.roleKeyWork = nodeId[0];
521
- break;
522
- case 'position':
523
- params.positionId = nodeId;
524
- break;
525
- case 'department':
526
- params.departmentId = nodeId;
527
- break;
528
- case 'subordinate':
529
- params.managerId = nodeId;
530
- break;
531
- }
532
- }
533
-
534
- // 如果有搜索关键词,添加到查询参数中
535
- if (keyword) {
536
- params.keyWord = keyword;
537
- }
538
-
539
- const response = await dataService.fetch(
540
- params,
541
- {},
542
- '/process/userList'
543
- );
544
- // 获取当前已选择的员工ID列表
545
- const selectedIds = [...new Set(tempSelectedEmployees.value.map(emp => emp.id))];
546
-
547
- // 处理返回数据,添加checked属性,保留已选状态
548
- const employees = (response || []).map(emp => ({
549
- ...emp,
550
- checked: selectedIds.includes(emp.id)
551
- }));
552
-
553
- employeeList.value = employees;
554
-
555
- handleCheckChange()
556
-
557
- updateSelectAllStatus();
558
- } catch (error) {
559
- MessagePlugin.error({
560
- content: '获取员工列表失败',
561
- duration: 3000
562
- });
563
- } finally {
564
- loading.value = false;
565
- }
566
- };
567
-
568
- // 根据ID列表批量获取员工信息
569
- const fetchEmployeesByIds = async (ids) => {
570
- if (!ids || ids.length === 0) {
571
- selectedItems.value = [];
572
- return;
573
- }
574
- if (!(ids instanceof Array)) {
575
- ids = [ids];
576
- }
577
-
578
- loading.value = true;
579
- try {
580
- const response = await dataService.fetch(
581
- {
582
- userIds: ids // 使用新的接口参数格式
583
- },
584
- {},
585
- '/process/userList' // 直接使用新的API路径
586
- );
587
-
588
- if (response && Array.isArray(response)) {
589
- selectedItems.value = response;
590
- } else {
591
- selectedItems.value = [];
592
- MessagePlugin.warning({
593
- content: '获取员工详情返回的数据格式不正确',
594
- duration: 3000
595
- });
596
- }
597
- } catch (error) {
598
- selectedItems.value = [];
599
- MessagePlugin.error({
600
- content: '获取员工详情失败: ' + (error.message || '未知错误'),
601
- duration: 3000
602
- });
603
- } finally {
604
- loading.value = false;
605
- }
606
- };
607
-
608
- // 处理节点激活
609
- const handleActive = (value, context) => {
610
- console.log("value", value)
611
- currentActive.value = [value];
612
- currentNodeName.value = context.node?.label || '';
613
-
614
- // 获取该节点下的员工
615
- fetchEmployeesByNode(value, activeTab.value);
616
- };
617
-
618
- // 选择部门
619
- const selectDepartment = (department) => {
620
- currentNodeName.value = department.name;
621
- fetchEmployeesByNode(department.id, activeTab.value);
622
- };
623
-
624
- // 处理全选
625
- const handleSelectAll = (checked) => {
626
- if (!checked) {
627
- // 移除当前页的选择
628
- employeeList.value.forEach(item => {
629
- console.log("item", item, (tempSelectedEmployees.value.indexOf(item.id) !== -1))
630
- if (tempSelectedEmployeeIds.value.indexOf(item.id) !== -1) {
631
- tempSelectedEmployeeIds.value.splice(tempSelectedEmployeeIds.value.indexOf(item.id), 1);
632
- }
633
- });
634
- handleCheckChange()
635
- } else {
636
- employeeList.value.forEach(item => {
637
-
638
- // 如果选中,确保添加到临时选中列表
639
- if (!tempSelectedEmployees.value.some(emp => emp.id === item.id)) {
640
- tempSelectedEmployees.value.push(item);
641
- tempSelectedEmployeeIds.value.push(item.id);
642
- }
643
- });
644
- }
645
-
646
- };
647
-
648
- // 处理选中状态变更
649
- const handleCheckChange = () => {
650
- console.log("tempSelectedEmployeeIds", tempSelectedEmployeeIds.value)
651
- // 单选模式下,取消其他选中
652
- const selectedEmployees = []
653
-
654
- if (props.single) {
655
- console.log("single", tempSelectedEmployeeId.value)
656
- employeeList.value.forEach(emp => {
657
- if (Number(emp.id) === Number(tempSelectedEmployeeId.value)) {
658
- selectedEmployees.push(emp)
659
- }
660
- });
661
- if (selectedEmployees.length === 0) {
662
- selectedItems.value.forEach(emp => {
663
- if (Number(emp.id) === Number(tempSelectedEmployeeId.value)) {
664
- selectedEmployees.push(emp)
665
- }
666
- });
667
- }
668
- if (selectedEmployees.length === 0) {
669
- tempSelectedEmployees.value.forEach(emp => {
670
- if (Number(emp.id) === Number(tempSelectedEmployeeId.value)) {
671
- selectedEmployees.push(emp)
672
- }
673
- });
674
- }
675
-
676
- } else {
677
- const handled = [];
678
- console.log("multi", tempSelectedEmployeeIds.value)
679
-
680
- tempSelectedEmployees.value.forEach(emp => {
681
- if (tempSelectedEmployeeIds.value.indexOf(emp.id) !== -1) {
682
- selectedEmployees.push(emp)
683
- handled.push(emp.id)
684
- }
685
- });
686
- employeeList.value.forEach(emp => {
687
- if (tempSelectedEmployeeIds.value.indexOf(emp.id) !== -1 && handled.indexOf(emp.id) === -1) {
688
- selectedEmployees.push(emp)
689
- handled.push(emp.id)
690
- }
691
- });
692
- selectedItems.value.forEach(emp => {
693
- if (tempSelectedEmployeeIds.value.indexOf(emp.id) !== -1 && handled.indexOf(emp.id) === -1) {
694
- selectedEmployees.push(emp)
695
- handled.push(emp.id)
696
- }
697
- });
698
- }
699
- tempSelectedEmployees.value = selectedEmployees
700
- updateSelectAllStatus();
701
- };
702
-
703
- // 移除已选择的项目
704
- const removeItem = (index, id) => {
705
- // 移除ID
706
- const newIds = [...computedModelValue.value];
707
- const idIndex = newIds.indexOf(id);
708
- if (idIndex !== -1) {
709
- newIds.splice(idIndex, 1);
710
- emit('update:modelValue', newIds);
711
- emit('change', newIds);
712
- }
713
- // 移除展示项
714
- selectedItems.value.splice(index, 1);
715
- };
716
-
717
- // 从已选列表中移除员工
718
- const removeSelectedEmployee = (employee) => {
719
- // 从临时选中列表中移除
720
- const index = tempSelectedEmployeeIds.value.findIndex(id => employee.id === id);
721
- if (index !== -1) {
722
- tempSelectedEmployeeIds.value.splice(index, 1);
723
- }
724
-
725
- handleCheckChange()
726
-
727
- // 更新全选状态
728
- updateSelectAllStatus();
729
- };
730
-
731
- // 初始化选择器
732
- const initSelector = async () => {
733
- // 获取数据
734
- if (activeTab.value === 'organization' && organizationData.value.length === 0) {
735
- await fetchOrganizationData();
736
- } else if (activeTab.value === 'role' && roleData.value.length === 0) {
737
- await fetchRoleData();
738
- } else if (activeTab.value === 'position' && positionData.value.length === 0) {
739
- await fetchPositionData();
740
- } else if (activeTab.value === 'department' && departmentData.value.length === 0) {
741
- await fetchDepartmentData();
742
- } else if (activeTab.value === 'subordinate' && subordinateData.value.length === 0) {
743
- await fetchSubordinateData();
744
- }
745
- };
746
-
747
- // 显示对话框
748
- const showDialog = () => {
749
- // 初始化临时选中列表
750
- if (props.single) {
751
- tempSelectedEmployeeId.value = props.modelValue || []
752
- } else {
753
- tempSelectedEmployeeIds.value = props.modelValue || []
754
- }
755
-
756
- // 初始化数据
757
- if (props.visible == null) {
758
- initSelector();
759
- }
760
-
761
- handleCheckChange()
762
-
763
- dialogVisible.value = true;
764
-
765
- };
766
-
767
- // 确认选择
768
- const handleConfirm = () => {
769
- console.log("tempSelectedEmployees", tempSelectedEmployees.value)
770
- const selectedEmployeeIds = tempSelectedEmployees.value.map(item => item.id);
771
-
772
- computedModelValue.value = selectedEmployeeIds;
773
- if (props.single) {
774
- emit('change', selectedEmployeeIds[0], tempSelectedEmployees.value);
775
- emit('confirm', selectedEmployeeIds[0], tempSelectedEmployees.value);
776
- } else {
777
- emit('change', selectedEmployeeIds, tempSelectedEmployees.value);
778
- emit('confirm', selectedEmployeeIds, tempSelectedEmployees.value);
779
- }
780
- dialogVisible.value = false;
781
- };
782
-
783
- // 取消选择
784
- const handleCancel = () => {
785
- // 放弃临时选择
786
- tempSelectedEmployees.value = [];
787
- dialogVisible.value = false;
788
- };
789
-
790
- // 监听标签页切换
791
- watch(activeTab, () => {
792
- // 切换标签页时重新加载数据
793
- initSelector();
794
- });
795
-
796
- // 监听modelValue变化,更新展示的员工信息
797
- watch(() => props.modelValue, (newIds, oldIds) => {
798
- // 判断值是否真的变化了 (通过比较JSON字符串)
799
- const newIdsStr = JSON.stringify(newIds || []);
800
- const oldIdsStr = JSON.stringify(oldIds || []);
801
-
802
- if (newIdsStr !== oldIdsStr) {
803
- // 获取员工详情数据
804
- fetchEmployeesByIds(newIds);
805
- }
806
- }, { immediate: true, deep: true });
807
- watch(() => props.visible, (val) => {
808
- tempSelectedEmployees.value = [];
809
- currentActive.value = [];
810
- currentNodeName.value = '';
811
-
812
- if (val) {
813
- fetchOrganizationData()
814
- }
815
- }, { immediate: true })
816
-
817
- // 监听子部门查询开关变化
818
- watch(childDeptEnable, () => {
819
- // 如果当前在组织架构页面且有选中节点,重新加载员工列表
820
- if (activeTab.value === 'organization' && currentActive.value && currentActive.value.length > 0) {
821
- fetchEmployeesByNode(currentActive.value[0], activeTab.value);
822
- }
823
- });
824
-
825
- // 防抖函数
826
- const debounce = (fn, delay) => {
827
- let timer = null;
828
- return function (...args) {
829
- if (timer) clearTimeout(timer);
830
- timer = setTimeout(() => {
831
- fn.apply(this, args);
832
- }, delay);
833
- };
834
- };
835
-
836
- // 防抖处理过的搜索函数
837
- const debouncedSearch = debounce((keyword) => {
838
- if (keyword) {
839
- const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
840
- const type = nodeId ? activeTab.value : null;
841
- fetchEmployeesByNode(nodeId, type, keyword);
842
- } else if (currentActive.value && currentActive.value.length > 0) {
843
- // 如果搜索框清空,恢复显示当前选中节点的员工列表
844
- fetchEmployeesByNode(currentActive.value[0], activeTab.value);
845
- } else {
846
- // 如果没有选中节点,清空员工列表
847
- employeeList.value = [];
848
- }
849
- }, 300); // 300ms防抖
850
-
851
- // 监听搜索文本变化,触发搜索
852
- watch(searchText, (newValue) => {
853
- debouncedSearch(newValue);
854
- }, { immediate: false });
855
-
856
- // 组件挂载时执行
857
- onMounted(() => {
858
- // 获取已选员工详情
859
- fetchEmployeesByIds(computedModelValue.value);
860
- });
861
-
862
- // 处理搜索图标点击
863
- const handleSearchClick = () => {
864
- if (searchText.value) {
865
- const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
866
- const type = nodeId ? activeTab.value : null;
867
- fetchEmployeesByNode(nodeId, type, searchText.value);
868
- }
869
- };
870
-
871
- // 处理回车键搜索
872
- const handleSearchEnter = () => {
873
- if (searchText.value) {
874
- const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
875
- const type = nodeId ? activeTab.value : null;
876
- fetchEmployeesByNode(nodeId, type, searchText.value);
877
- }
878
- };
879
-
880
- // 清除搜索
881
- const clearSearch = () => {
882
- searchText.value = '';
883
- if (currentActive.value && currentActive.value.length > 0) {
884
- fetchEmployeesByNode(currentActive.value[0], activeTab.value);
885
- }
886
- };
887
- </script>
888
-
889
- <style scoped>
890
- .ebiz-employee-selector {
891
- width: 100%;
892
- display: flex;
893
- flex-direction: column;
894
- }
895
-
896
- /* 选择框展示区 */
897
- .employee-selector-container {
898
- min-height: 32px;
899
- width: 100%;
900
- border: 1px solid #dcdcdc;
901
- border-radius: 3px;
902
- padding: 4px 8px;
903
- display: flex;
904
- flex-wrap: wrap;
905
- gap: 8px;
906
- align-items: center;
907
- }
908
-
909
- .selected-items {
910
- display: flex;
911
- flex-wrap: wrap;
912
- gap: 8px;
913
- }
914
-
915
- .selected-item {
916
- display: flex;
917
- align-items: center;
918
- background-color: #f0f0f0;
919
- border-radius: 3px;
920
- padding: 2px 8px 2px 2px;
921
- gap: 8px;
922
- }
923
-
924
- .item-info {
925
- display: flex;
926
- align-items: center;
927
- gap: 4px;
928
- }
929
-
930
- .item-code {
931
- color: #999;
932
- font-size: 12px;
933
- }
934
-
935
- .item-name {
936
- font-size: 14px;
937
- }
938
-
939
- .item-remove {
940
- cursor: pointer;
941
- color: #999;
942
- font-size: 12px;
943
- }
944
-
945
- .item-remove:hover {
946
- color: #E34D59;
947
- }
948
-
949
- /* 选择弹窗 */
950
- .selector-dialog-content {
951
- display: flex;
952
- height: 500px;
953
- }
954
-
955
- .left-panel,
956
- .right-panel {
957
- height: 100%;
958
- overflow: hidden;
959
- display: flex;
960
- flex-direction: column;
961
- }
962
-
963
- .left-panel {
964
- width: 40%;
965
- border-right: 1px solid #dcdcdc;
966
- padding-right: 16px;
967
- }
968
-
969
- .right-panel {
970
- width: 60%;
971
- padding-left: 16px;
972
- }
973
-
974
- .search-box {
975
- margin-bottom: 16px;
976
- }
977
-
978
- .right-panel .search-box {
979
- margin-top: 8px;
980
- margin-bottom: 16px;
981
- display: flex;
982
- align-items: center;
983
- gap: 8px;
984
- }
985
-
986
- .right-panel .search-box .t-input {
987
- width: 100%;
988
- border-radius: 4px;
989
- }
990
-
991
- .right-panel .search-box .t-input__suffix-icon {
992
- cursor: pointer;
993
- }
994
-
995
- .right-panel .search-box .t-input__suffix-icon:hover {
996
- color: var(--td-brand-color);
997
- }
998
-
999
- .selector-tabs {
1000
- margin-bottom: 16px;
1001
- }
1002
-
1003
- .content-area {
1004
- flex: 1;
1005
- overflow: auto;
1006
- position: relative;
1007
- }
1008
-
1009
- .loading-container {
1010
- position: absolute;
1011
- top: 0;
1012
- left: 0;
1013
- right: 0;
1014
- bottom: 0;
1015
- display: flex;
1016
- justify-content: center;
1017
- align-items: center;
1018
- background-color: rgba(255, 255, 255, 0.6);
1019
- z-index: 1;
1020
- }
1021
-
1022
- .tab-content {
1023
- height: 100%;
1024
- overflow: auto;
1025
- }
1026
-
1027
- .department-item {
1028
- cursor: pointer;
1029
- padding: 8px;
1030
- }
1031
-
1032
- .department-item:hover {
1033
- background-color: #f5f5f5;
1034
- }
1035
-
1036
- .employee-header {
1037
- display: flex;
1038
- justify-content: space-between;
1039
- align-items: center;
1040
- margin-bottom: 16px;
1041
- }
1042
-
1043
- .employee-title {
1044
- font-weight: bold;
1045
- font-size: 16px;
1046
- display: flex;
1047
- align-items: center;
1048
- gap: 10px;
1049
- }
1050
-
1051
- .sub-dept-option {
1052
- margin-left: 10px;
1053
- font-weight: normal;
1054
- font-size: 14px;
1055
- }
1056
-
1057
- .employee-count {
1058
- display: flex;
1059
- align-items: center;
1060
- gap: 8px;
1061
- }
1062
-
1063
- .count-info {
1064
- color: #999;
1065
- font-size: 14px;
1066
- }
1067
-
1068
- .employee-list {
1069
- flex: 1;
1070
- overflow: auto;
1071
- display: flex;
1072
- flex-direction: column;
1073
- gap: 8px;
1074
- height: 400px;
1075
- }
1076
-
1077
- .employee-item {
1078
- display: flex;
1079
- align-items: center;
1080
- gap: 12px;
1081
- padding: 8px;
1082
- border-radius: 4px;
1083
- }
1084
-
1085
- .employee-item:hover {
1086
- background-color: #f5f5f5;
1087
- }
1088
-
1089
- .employee-avatar {
1090
- display: flex;
1091
- align-items: center;
1092
- }
1093
-
1094
- .employee-info {
1095
- display: flex;
1096
- gap: 8px;
1097
- align-items: center;
1098
- }
1099
-
1100
- .employee-code {
1101
- color: #999;
1102
- font-size: 12px;
1103
- }
1104
-
1105
- .employee-name {
1106
- font-size: 14px;
1107
- }
1108
-
1109
- .empty-data {
1110
- display: flex;
1111
- justify-content: center;
1112
- align-items: center;
1113
- height: 200px;
1114
- }
1115
-
1116
- .dialog-footer {
1117
- display: flex;
1118
- justify-content: space-between;
1119
- align-items: center;
1120
- padding: 16px 0;
1121
- }
1122
-
1123
- .selected-preview {
1124
- color: #666;
1125
- }
1126
-
1127
- .dialog-actions {
1128
- display: flex;
1129
- gap: 8px;
1130
- }
1131
-
1132
- .selected-people-list {
1133
- margin-top: 8px;
1134
- display: flex;
1135
- flex-wrap: wrap;
1136
- gap: 8px;
1137
- }
1138
-
1139
- .selected-people-item {
1140
- display: flex;
1141
- align-items: center;
1142
- background-color: #f0f0f0;
1143
- border-radius: 3px;
1144
- padding: 2px 8px 2px 2px;
1145
- gap: 8px;
1146
- }
1147
-
1148
- .selected-people-item:hover {
1149
- background-color: #e0e0e0;
1150
- }
1151
-
1152
- .selected-people-item .item-remove {
1153
- cursor: pointer;
1154
- color: #999;
1155
- font-size: 12px;
1156
- }
1157
-
1158
- .selected-people-item .item-remove:hover {
1159
- color: #E34D59;
1160
- }
1
+ <template>
2
+ <div class="ebiz-employee-selector">
3
+ <!-- 选择框展示区 -->
4
+ <div v-if="showDefault" style="display: flex; flex-direction: column; align-items: flex-start; gap: 10px;">
5
+ <slot name="selected-items" :event="{ remove: removeItem }" :data="selectedItems">
6
+ <div class="selected-items" v-if="selectedItems && selectedItems.length">
7
+ <div v-for="(item, index) in selectedItems" :key="index" class="selected-item">
8
+ <t-avatar v-if="item.avatar" :image="item.avatar" size="small" />
9
+ <t-avatar v-else size="small">{{ getAvatarText(item.name) }}</t-avatar>
10
+ <span class="item-info">
11
+ <span class="item-code">{{ item.no }} - </span>
12
+ <span class="item-name">{{ item.name }}</span>
13
+ </span>
14
+ <t-icon name="close" class="item-remove" @click="removeItem(index, item.id)"></t-icon>
15
+ </div>
16
+ </div>
17
+ </slot>
18
+
19
+ <t-button @click="showDialog" variant="text" theme="primary">{{ props.content }}</t-button>
20
+ </div>
21
+
22
+ <!-- 选择弹窗 -->
23
+ <t-dialog v-model:visible="dialogVisible" :header="props.content" :width="800" footer :close-btn="true"
24
+ :close-on-esc-keydown="true" :close-on-overlay-click="true" destroyOnClose>
25
+
26
+ <!-- 选项卡 -->
27
+ <t-tabs v-model="activeTab" class="selector-tabs">
28
+ <t-tab-panel value="organization" label="组织架构" :destroyOnHide="false"></t-tab-panel>
29
+ <t-tab-panel value="role" label="角色" :destroyOnHide="false"></t-tab-panel>
30
+ <!-- <t-tab-panel value="position" label="岗位" :destroyOnHide="false"></t-tab-panel> -->
31
+ <!-- <t-tab-panel value="department" label="同部门" :destroyOnHide="false"></t-tab-panel> -->
32
+ <!-- <t-tab-panel value="subordinate" label="我的下属" :destroyOnHide="false"></t-tab-panel> -->
33
+ </t-tabs>
34
+
35
+
36
+ <div>
37
+
38
+ <div class="selector-dialog-content">
39
+ <!-- 左侧选择区域 -->
40
+ <div class="left-panel">
41
+ <!-- 内容区域 -->
42
+ <div class="content-area">
43
+ <div v-if="loading" class="loading-container">
44
+ <t-loading />
45
+ </div>
46
+ <!-- 组织架构 -->
47
+ <div v-show="activeTab === 'organization'" class="tab-content">
48
+ <t-tree ref="organizationTree" :data="organizationData"
49
+ :keys="{ label: 'name', value: 'id', children: 'children' }" hover activable :active="currentActive"
50
+ @active="handleActive" />
51
+ </div>
52
+
53
+ <!-- 角色 -->
54
+ <div v-show="activeTab === 'role'" class="tab-content">
55
+ <t-tree ref="roleTree" :data="roleData" :keys="{ label: 'name', value: 'code' }" hover activable
56
+ :active="currentActive" @active="handleActive" />
57
+ </div>
58
+
59
+ <!-- 岗位 -->
60
+ <div v-show="activeTab === 'position'" class="tab-content">
61
+ <t-tree ref="positionTree" :data="positionData" :keys="{ label: 'name', value: 'id' }" hover activable
62
+ :active="currentActive" @active="handleActive" />
63
+ </div>
64
+
65
+ <!-- 同部门 -->
66
+ <div v-show="activeTab === 'department'" class="tab-content">
67
+ <t-list :split="true" size="small">
68
+ <t-list-item v-for="(item, index) in departmentData" :key="index">
69
+ <div class="department-item" @click="selectDepartment(item)">
70
+ {{ item.name }}
71
+ </div>
72
+ </t-list-item>
73
+ </t-list>
74
+ </div>
75
+
76
+ <!-- 我的下属 -->
77
+ <div v-show="activeTab === 'subordinate'" class="tab-content">
78
+ <t-list :split="true" size="small">
79
+ <t-list-item v-for="(item, index) in subordinateData" :key="index">
80
+ <div class="department-item" @click="selectDepartment(item)">
81
+ {{ item.name }}
82
+ </div>
83
+ </t-list-item>
84
+ </t-list>
85
+ </div>
86
+ </div>
87
+ </div>
88
+
89
+ <!-- 右侧人员列表区域 -->
90
+ <div class="right-panel">
91
+ <div class="employee-header">
92
+ <div class="employee-title">
93
+ {{ currentNodeName || '人员列表' }}
94
+ <div v-if="activeTab === 'organization'" class="sub-dept-option">
95
+ <t-checkbox v-model="childDeptEnable">包含子部门</t-checkbox>
96
+ </div>
97
+ </div>
98
+ <div class="employee-count" v-if="!single">
99
+ <t-checkbox v-model="selectAll" @change="handleSelectAll">全选</t-checkbox>
100
+ <span class="count-info">共 {{ employeeList.length }} 人</span>
101
+ </div>
102
+ </div>
103
+
104
+ <!-- 搜索框 -->
105
+ <div class="search-box">
106
+ <t-input v-model="searchText" placeholder="请输入姓名/拼音/工号搜索" clearable @change="handleSearchEnter">
107
+ <template #suffix-icon>
108
+ <t-icon name="search" @click="handleSearchClick"></t-icon>
109
+ </template>
110
+ </t-input>
111
+ <t-button v-if="searchText" size="small" theme="default" class="clear-search-btn"
112
+ @click="clearSearch">清除搜索</t-button>
113
+ </div>
114
+
115
+ <t-checkbox-group v-if="!single" v-model="tempSelectedEmployeeIds" style="width: 100%;"
116
+ @change="handleCheckChange">
117
+ <div class="employee-list">
118
+ <div v-for="(item, index) in filteredEmployeeList" :key="index" class="employee-item"
119
+ style="cursor: pointer;">
120
+ <t-checkbox :key="item.id" :value="item.id">
121
+ <div style="display: flex; align-items: center; gap: 10px; flex: 1;">
122
+ <div class="employee-avatar">
123
+ <t-avatar v-if="item.avatar" :image="item.avatar" size="small" />
124
+ <t-avatar v-else size="small">{{ getAvatarText(item.name) }}</t-avatar>
125
+ </div>
126
+ <div style="display: flex; align-items: center; justify-content: space-between; width: 300px;">
127
+ <div class="employee-info">
128
+ <div class="employee-code">{{ item.no }} - </div>
129
+ <div class="employee-name">{{ item.name }}</div>
130
+ </div>
131
+ <div class="employee-dept">
132
+ <small style="color: #999;">{{ item.postName }}</small>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ </t-checkbox>
137
+
138
+ </div>
139
+ </div>
140
+
141
+ </t-checkbox-group>
142
+
143
+ <t-radio-group v-else style="width: 100%;" v-model="tempSelectedEmployeeId" @change="handleCheckChange">
144
+ <div class="employee-list">
145
+ <div v-for="(item, index) in filteredEmployeeList" :key="index" class="employee-item"
146
+ style="cursor: pointer;">
147
+ <t-radio :value="item.id">
148
+ <div style="display: flex; align-items: center; gap: 10px; flex: 1;">
149
+ <div class="employee-avatar">
150
+ <t-avatar v-if="item.avatar" :image="item.avatar" size="small" />
151
+ <t-avatar v-else size="small">{{ getAvatarText(item.name) }}</t-avatar>
152
+ </div>
153
+ <div style="display: flex; align-items: center; justify-content: space-between;width: 300px;">
154
+ <div class="employee-info">
155
+ <div class="employee-code">{{ item.no }} - </div>
156
+ <div class="employee-name">{{ item.name }}</div>
157
+ </div>
158
+ <div class="employee-dept">
159
+ <small style="color: #999;">{{ item.postName }}</small>
160
+ </div>
161
+ </div>
162
+
163
+ </div>
164
+ </t-radio>
165
+
166
+ </div>
167
+
168
+ </div>
169
+
170
+ </t-radio-group>
171
+
172
+
173
+ <div v-if="filteredEmployeeList.length === 0" class="empty-data">
174
+ <t-empty />
175
+ </div>
176
+ </div>
177
+ </div>
178
+ </div>
179
+
180
+
181
+ <!-- 底部按钮区域 -->
182
+ <template #footer>
183
+ <div class="dialog-footer">
184
+ <div class="selected-preview">
185
+ <div class="selected-people-count" v-if="!single">
186
+ 已选: {{ tempSelectedEmployees.length }} 人
187
+ </div>
188
+ <div class="selected-people-list" v-if="tempSelectedEmployees.length > 0">
189
+ <div v-for="(item, index) in tempSelectedEmployees" :key="index" class="selected-people-item">
190
+ <t-avatar v-if="item.avatar" :image="item.avatar" size="small" />
191
+ <t-avatar v-else size="small">{{ getAvatarText(item.name) }}</t-avatar>
192
+ <span class="item-info">
193
+ <span class="item-code">{{ item.no }}</span>
194
+ <span class="item-name">{{ item.name }}</span>
195
+ </span>
196
+ <t-icon v-if="!single" name="close" class="item-remove" @click="removeSelectedEmployee(item)"></t-icon>
197
+ </div>
198
+ </div>
199
+ </div>
200
+ <div class="dialog-actions">
201
+ <t-button theme="default" @click="handleCancel">取消</t-button>
202
+ <t-button theme="primary" @click="handleConfirm">确定</t-button>
203
+ </div>
204
+ </div>
205
+ </template>
206
+ </t-dialog>
207
+ </div>
208
+ </template>
209
+
210
+ <script setup>
211
+ import { ref, computed, watch, onMounted } from 'vue';
212
+ import {
213
+ Dialog as TDialog,
214
+ Button as TButton,
215
+ Icon as TIcon,
216
+ Input as TInput,
217
+ Tabs as TTabs,
218
+ TabPanel as TTabPanel,
219
+ Loading as TLoading,
220
+ Tree as TTree,
221
+ Avatar as TAvatar,
222
+ Checkbox as TCheckbox,
223
+ CheckboxGroup as TCheckboxGroup,
224
+ Empty as TEmpty,
225
+ List as TList,
226
+ ListItem as TListItem,
227
+ MessagePlugin,
228
+ Radio as TRadio,
229
+ RadioGroup as TRadioGroup
230
+ } from 'tdesign-vue-next';
231
+ import dataService from '../apiService/simpleDataService';
232
+
233
+ // 定义组件属性
234
+ const props = defineProps({
235
+ // 选中的数据,支持v-model,只存储ID列表
236
+ showDefault: {
237
+ type: Boolean,
238
+ default: true
239
+ },
240
+ modelValue: {
241
+ type: Array,
242
+ default: undefined
243
+ },
244
+ // 单选模式
245
+ single: {
246
+ type: Boolean,
247
+ default: false
248
+ },
249
+ // 是否展示默认标签页
250
+ showDefaultTab: {
251
+ type: Boolean,
252
+ default: true
253
+ },
254
+ visible: {
255
+ type: Boolean,
256
+ default: null
257
+ },
258
+ // 是否包含部门
259
+ includeDepartment: {
260
+ type: Boolean,
261
+ default: false
262
+ },
263
+ // 默认标签页
264
+ defaultTab: {
265
+ type: String,
266
+ default: 'organization'
267
+ },
268
+ // 是否展示顶层组织
269
+ showRootOrg: {
270
+ type: Boolean,
271
+ default: true
272
+ },
273
+ // 最大选择数量,0表示不限制
274
+ maxCount: {
275
+ type: Number,
276
+ default: 0
277
+ },
278
+ content: {
279
+ type: String,
280
+ default: '选择人员'
281
+ },
282
+ // 是否显示已离职员工
283
+ showResigned: {
284
+ type: Boolean,
285
+ default: false
286
+ }
287
+ });
288
+
289
+ // 定义组件事件
290
+ const emit = defineEmits(['update:modelValue', 'change', 'update:visible', 'confirm']);
291
+ const tempVisible = ref(false);
292
+
293
+ const tempSelectedEmployeeIds = ref([])
294
+ const tempSelectedEmployeeId = ref("")
295
+
296
+ // 内部状态变量
297
+ const dialogVisible = computed({
298
+ set(val) {
299
+ if (props.visible == null) {
300
+ tempVisible.value = val;
301
+ return
302
+ }
303
+ emit('update:visible', val)
304
+ },
305
+ get() {
306
+ return props.visible ?? tempVisible.value
307
+ }
308
+ });
309
+
310
+ const searchText = ref('');
311
+ const activeTab = ref(props.defaultTab);
312
+ const loading = ref(false);
313
+ const selectedItems = ref([]);
314
+ // 对话框中临时保存的选中员工列表
315
+ const tempSelectedEmployees = ref([]);
316
+ // 是否查询子部门
317
+ const childDeptEnable = ref(true);
318
+
319
+ // 数据源
320
+ const organizationData = ref([]);
321
+ const roleData = ref([]);
322
+ const positionData = ref([]);
323
+ const departmentData = ref([]);
324
+ const subordinateData = ref([]);
325
+ const employeeList = ref([]);
326
+ const currentActive = ref([]);
327
+ const currentNodeName = ref('');
328
+ const selectAll = ref(false);
329
+
330
+ // 从名称中获取头像显示文本
331
+ const getAvatarText = (name) => {
332
+ return name ? name.substring(0, 1) : '';
333
+ };
334
+
335
+ const computedModelValue = computed({
336
+ set(val) {
337
+ if (props.single) {
338
+ if (val.length > 0) {
339
+ emit("update:modelValue", val[0]);
340
+ } else {
341
+ emit("update:modelValue", "");
342
+ }
343
+ return;
344
+ }
345
+ emit("update:modelValue", val);
346
+ },
347
+ get() {
348
+
349
+ let value = props.modelValue
350
+
351
+ if (props.single) {
352
+ if (Array.isArray(props.modelValue)) {
353
+ value = props.modelValue ? props.modelValue : [];
354
+ } else {
355
+ value = props.modelValue ? [props.modelValue] : [];
356
+ }
357
+ } else {
358
+ if (!value) {
359
+ value = [];
360
+ }
361
+ }
362
+ console.log(props.single, value)
363
+ value.forEach((val) => {
364
+ return Number(val);
365
+ })
366
+ return value;
367
+ }
368
+ });
369
+
370
+ // 更新全选状态
371
+ const updateSelectAllStatus = () => {
372
+ selectAll.value = employeeList.value.length > 0 && employeeList.value.every(item => item.checked);
373
+ };
374
+
375
+ const updateSelectStatus = () => {
376
+ employeeList.value.forEach(item => {
377
+ item.checked = computedModelValue.value.includes(item.id);
378
+ })
379
+ }
380
+
381
+ // 选中的员工列表
382
+ const selectedEmployees = computed(() => {
383
+ return employeeList.value.filter((item) => item.checked);
384
+ });
385
+
386
+ // 根据搜索文本过滤的员工列表
387
+ const filteredEmployeeList = computed(() => {
388
+ return employeeList.value
389
+ });
390
+
391
+
392
+ // 获取组织架构数据
393
+ const fetchOrganizationData = async () => {
394
+ loading.value = true;
395
+ try {
396
+ const response = await dataService.fetch(
397
+ {},
398
+ {
399
+ apiId: 1933,
400
+ key: 'organizationalStructure'
401
+ }, "/process/deptList"
402
+ );
403
+ organizationData.value = response;
404
+ handleActive(null, 'organization')
405
+ // organizationData.value = processOrgData(response.data || []);
406
+ } catch (error) {
407
+ MessagePlugin.error({
408
+ content: '获取组织架构数据失败',
409
+ duration: 3000
410
+ });
411
+ } finally {
412
+ loading.value = false;
413
+ }
414
+ };
415
+
416
+ // 获取角色数据
417
+ const fetchRoleData = async () => {
418
+ loading.value = true;
419
+ try {
420
+ const response = await dataService.fetch(
421
+ {},
422
+ {},
423
+ '/process/roleList'
424
+ );
425
+ roleData.value = response || [];
426
+ } catch (error) {
427
+ MessagePlugin.error({
428
+ content: '获取角色数据失败',
429
+ duration: 3000
430
+ });
431
+ } finally {
432
+ loading.value = false;
433
+ }
434
+ };
435
+
436
+ // 获取岗位数据
437
+ const fetchPositionData = async () => {
438
+ loading.value = true;
439
+ try {
440
+ const response = await dataService.fetch(
441
+ {},
442
+ {
443
+ },
444
+ '/process/roleList'
445
+ );
446
+ positionData.value = response?.data || [];
447
+ } catch (error) {
448
+ MessagePlugin.error({
449
+ content: '获取岗位数据失败',
450
+ duration: 3000
451
+ });
452
+ } finally {
453
+ loading.value = false;
454
+ }
455
+ };
456
+
457
+ // 获取部门数据
458
+ const fetchDepartmentData = async () => {
459
+ loading.value = true;
460
+ try {
461
+ const response = await dataService.fetch(
462
+ {},
463
+ {
464
+ apiId: 1933,
465
+ key: 'departmentList',
466
+ apiType: 'MULTIPLE_DATA_SEARCH'
467
+ }
468
+ );
469
+ departmentData.value = response?.data || [];
470
+ } catch (error) {
471
+ MessagePlugin.error({
472
+ content: '获取部门数据失败',
473
+ duration: 3000
474
+ });
475
+ } finally {
476
+ loading.value = false;
477
+ }
478
+ };
479
+
480
+ // 获取下属数据
481
+ const fetchSubordinateData = async () => {
482
+ loading.value = true;
483
+ try {
484
+ const response = await dataService.fetch(
485
+ {},
486
+ {
487
+ apiKey: 'subordinateList',
488
+ apiType: 'MULTIPLE_DATA_SEARCH'
489
+ }
490
+ );
491
+ subordinateData.value = response?.data || [];
492
+ } catch (error) {
493
+ MessagePlugin.error({
494
+ content: '获取下属数据失败',
495
+ duration: 3000
496
+ });
497
+ } finally {
498
+ loading.value = false;
499
+ }
500
+ };
501
+
502
+ // 根据节点ID获取员工列表
503
+ const fetchEmployeesByNode = async (nodeId, type, keyword = searchText.value) => {
504
+ loading.value = true;
505
+ try {
506
+ const params = {};
507
+
508
+ // 只有当nodeId不为空且type有效时,添加对应参数
509
+ if (nodeId && type) {
510
+ // 添加是否显示已离职员工参数
511
+ params.showResigned = props.showResigned;
512
+ // 根据不同类型设置不同的查询参数
513
+ switch (type) {
514
+ case 'organization':
515
+ params.deptId = Array.isArray(nodeId) ? nodeId[0] : nodeId;
516
+ // 添加子部门查询参数
517
+ params.childDeptEnable = childDeptEnable.value;
518
+ break;
519
+ case 'role':
520
+ params.roleKeyWork = nodeId[0];
521
+ break;
522
+ case 'position':
523
+ params.positionId = nodeId;
524
+ break;
525
+ case 'department':
526
+ params.departmentId = nodeId;
527
+ break;
528
+ case 'subordinate':
529
+ params.managerId = nodeId;
530
+ break;
531
+ }
532
+ }
533
+
534
+ // 如果有搜索关键词,添加到查询参数中
535
+ if (keyword) {
536
+ params.keyWord = keyword;
537
+ }
538
+
539
+ const response = await dataService.fetch(
540
+ params,
541
+ {},
542
+ '/process/userList'
543
+ );
544
+ // 获取当前已选择的员工ID列表
545
+ const selectedIds = [...new Set(tempSelectedEmployees.value.map(emp => emp.id))];
546
+
547
+ // 处理返回数据,添加checked属性,保留已选状态
548
+ const employees = (response || []).map(emp => ({
549
+ ...emp,
550
+ checked: selectedIds.includes(emp.id)
551
+ }));
552
+
553
+ employeeList.value = employees;
554
+
555
+ handleCheckChange()
556
+
557
+ updateSelectAllStatus();
558
+ } catch (error) {
559
+ MessagePlugin.error({
560
+ content: '获取员工列表失败',
561
+ duration: 3000
562
+ });
563
+ } finally {
564
+ loading.value = false;
565
+ }
566
+ };
567
+
568
+ // 根据ID列表批量获取员工信息
569
+ const fetchEmployeesByIds = async (ids) => {
570
+ if (!ids || ids.length === 0) {
571
+ selectedItems.value = [];
572
+ return;
573
+ }
574
+ if (!(ids instanceof Array)) {
575
+ ids = [ids];
576
+ }
577
+
578
+ loading.value = true;
579
+ try {
580
+ const response = await dataService.fetch(
581
+ {
582
+ userIds: ids // 使用新的接口参数格式
583
+ },
584
+ {},
585
+ '/process/userList' // 直接使用新的API路径
586
+ );
587
+
588
+ if (response && Array.isArray(response)) {
589
+ selectedItems.value = response;
590
+ } else {
591
+ selectedItems.value = [];
592
+ MessagePlugin.warning({
593
+ content: '获取员工详情返回的数据格式不正确',
594
+ duration: 3000
595
+ });
596
+ }
597
+ } catch (error) {
598
+ selectedItems.value = [];
599
+ MessagePlugin.error({
600
+ content: '获取员工详情失败: ' + (error.message || '未知错误'),
601
+ duration: 3000
602
+ });
603
+ } finally {
604
+ loading.value = false;
605
+ }
606
+ };
607
+
608
+ // 处理节点激活
609
+ const handleActive = (value, context) => {
610
+ console.log("value", value)
611
+ currentActive.value = [value];
612
+ currentNodeName.value = context.node?.label || '';
613
+
614
+ // 获取该节点下的员工
615
+ fetchEmployeesByNode(value, activeTab.value);
616
+ };
617
+
618
+ // 选择部门
619
+ const selectDepartment = (department) => {
620
+ currentNodeName.value = department.name;
621
+ fetchEmployeesByNode(department.id, activeTab.value);
622
+ };
623
+
624
+ // 处理全选
625
+ const handleSelectAll = (checked) => {
626
+ if (!checked) {
627
+ // 移除当前页的选择
628
+ employeeList.value.forEach(item => {
629
+ console.log("item", item, (tempSelectedEmployees.value.indexOf(item.id) !== -1))
630
+ if (tempSelectedEmployeeIds.value.indexOf(item.id) !== -1) {
631
+ tempSelectedEmployeeIds.value.splice(tempSelectedEmployeeIds.value.indexOf(item.id), 1);
632
+ }
633
+ });
634
+ handleCheckChange()
635
+ } else {
636
+ employeeList.value.forEach(item => {
637
+
638
+ // 如果选中,确保添加到临时选中列表
639
+ if (!tempSelectedEmployees.value.some(emp => emp.id === item.id)) {
640
+ tempSelectedEmployees.value.push(item);
641
+ tempSelectedEmployeeIds.value.push(item.id);
642
+ }
643
+ });
644
+ }
645
+
646
+ };
647
+
648
+ // 处理选中状态变更
649
+ const handleCheckChange = () => {
650
+ console.log("tempSelectedEmployeeIds", tempSelectedEmployeeIds.value)
651
+ // 单选模式下,取消其他选中
652
+ const selectedEmployees = []
653
+
654
+ if (props.single) {
655
+ console.log("single", tempSelectedEmployeeId.value)
656
+ employeeList.value.forEach(emp => {
657
+ if (Number(emp.id) === Number(tempSelectedEmployeeId.value)) {
658
+ selectedEmployees.push(emp)
659
+ }
660
+ });
661
+ if (selectedEmployees.length === 0) {
662
+ selectedItems.value.forEach(emp => {
663
+ if (Number(emp.id) === Number(tempSelectedEmployeeId.value)) {
664
+ selectedEmployees.push(emp)
665
+ }
666
+ });
667
+ }
668
+ if (selectedEmployees.length === 0) {
669
+ tempSelectedEmployees.value.forEach(emp => {
670
+ if (Number(emp.id) === Number(tempSelectedEmployeeId.value)) {
671
+ selectedEmployees.push(emp)
672
+ }
673
+ });
674
+ }
675
+
676
+ } else {
677
+ const handled = [];
678
+ console.log("multi", tempSelectedEmployeeIds.value)
679
+
680
+ tempSelectedEmployees.value.forEach(emp => {
681
+ if (tempSelectedEmployeeIds.value.indexOf(emp.id) !== -1) {
682
+ selectedEmployees.push(emp)
683
+ handled.push(emp.id)
684
+ }
685
+ });
686
+ employeeList.value.forEach(emp => {
687
+ if (tempSelectedEmployeeIds.value.indexOf(emp.id) !== -1 && handled.indexOf(emp.id) === -1) {
688
+ selectedEmployees.push(emp)
689
+ handled.push(emp.id)
690
+ }
691
+ });
692
+ selectedItems.value.forEach(emp => {
693
+ if (tempSelectedEmployeeIds.value.indexOf(emp.id) !== -1 && handled.indexOf(emp.id) === -1) {
694
+ selectedEmployees.push(emp)
695
+ handled.push(emp.id)
696
+ }
697
+ });
698
+ }
699
+ tempSelectedEmployees.value = selectedEmployees
700
+ updateSelectAllStatus();
701
+ };
702
+
703
+ // 移除已选择的项目
704
+ const removeItem = (index, id) => {
705
+ // 移除ID
706
+ const newIds = [...computedModelValue.value];
707
+ const idIndex = newIds.indexOf(id);
708
+ if (idIndex !== -1) {
709
+ newIds.splice(idIndex, 1);
710
+ emit('update:modelValue', newIds);
711
+ emit('change', newIds);
712
+ }
713
+ // 移除展示项
714
+ selectedItems.value.splice(index, 1);
715
+ };
716
+
717
+ // 从已选列表中移除员工
718
+ const removeSelectedEmployee = (employee) => {
719
+ // 从临时选中列表中移除
720
+ const index = tempSelectedEmployeeIds.value.findIndex(id => employee.id === id);
721
+ if (index !== -1) {
722
+ tempSelectedEmployeeIds.value.splice(index, 1);
723
+ }
724
+
725
+ handleCheckChange()
726
+
727
+ // 更新全选状态
728
+ updateSelectAllStatus();
729
+ };
730
+
731
+ // 初始化选择器
732
+ const initSelector = async () => {
733
+ // 获取数据
734
+ if (activeTab.value === 'organization' && organizationData.value.length === 0) {
735
+ await fetchOrganizationData();
736
+ } else if (activeTab.value === 'role' && roleData.value.length === 0) {
737
+ await fetchRoleData();
738
+ } else if (activeTab.value === 'position' && positionData.value.length === 0) {
739
+ await fetchPositionData();
740
+ } else if (activeTab.value === 'department' && departmentData.value.length === 0) {
741
+ await fetchDepartmentData();
742
+ } else if (activeTab.value === 'subordinate' && subordinateData.value.length === 0) {
743
+ await fetchSubordinateData();
744
+ }
745
+ };
746
+
747
+ // 显示对话框
748
+ const showDialog = () => {
749
+ // 初始化临时选中列表
750
+ if (props.single) {
751
+ tempSelectedEmployeeId.value = props.modelValue || []
752
+ } else {
753
+ tempSelectedEmployeeIds.value = props.modelValue || []
754
+ }
755
+
756
+ // 初始化数据
757
+ if (props.visible == null) {
758
+ initSelector();
759
+ }
760
+
761
+ handleCheckChange()
762
+
763
+ dialogVisible.value = true;
764
+
765
+ };
766
+
767
+ // 确认选择
768
+ const handleConfirm = () => {
769
+ console.log("tempSelectedEmployees", tempSelectedEmployees.value)
770
+ const selectedEmployeeIds = tempSelectedEmployees.value.map(item => item.id);
771
+
772
+ computedModelValue.value = selectedEmployeeIds;
773
+ if (props.single) {
774
+ emit('change', selectedEmployeeIds[0], tempSelectedEmployees.value);
775
+ emit('confirm', selectedEmployeeIds[0], tempSelectedEmployees.value);
776
+ } else {
777
+ emit('change', selectedEmployeeIds, tempSelectedEmployees.value);
778
+ emit('confirm', selectedEmployeeIds, tempSelectedEmployees.value);
779
+ }
780
+ dialogVisible.value = false;
781
+ };
782
+
783
+ // 取消选择
784
+ const handleCancel = () => {
785
+ // 放弃临时选择
786
+ tempSelectedEmployees.value = [];
787
+ dialogVisible.value = false;
788
+ };
789
+
790
+ // 监听标签页切换
791
+ watch(activeTab, () => {
792
+ // 切换标签页时重新加载数据
793
+ initSelector();
794
+ });
795
+
796
+ // 监听modelValue变化,更新展示的员工信息
797
+ watch(() => props.modelValue, (newIds, oldIds) => {
798
+ // 判断值是否真的变化了 (通过比较JSON字符串)
799
+ const newIdsStr = JSON.stringify(newIds || []);
800
+ const oldIdsStr = JSON.stringify(oldIds || []);
801
+
802
+ if (newIdsStr !== oldIdsStr) {
803
+ // 获取员工详情数据
804
+ fetchEmployeesByIds(newIds);
805
+ }
806
+ }, { immediate: true, deep: true });
807
+ watch(() => props.visible, (val) => {
808
+ tempSelectedEmployees.value = [];
809
+ currentActive.value = [];
810
+ currentNodeName.value = '';
811
+
812
+ if (val) {
813
+ fetchOrganizationData()
814
+ }
815
+ }, { immediate: true })
816
+
817
+ // 监听子部门查询开关变化
818
+ watch(childDeptEnable, () => {
819
+ // 如果当前在组织架构页面且有选中节点,重新加载员工列表
820
+ if (activeTab.value === 'organization' && currentActive.value && currentActive.value.length > 0) {
821
+ fetchEmployeesByNode(currentActive.value[0], activeTab.value);
822
+ }
823
+ });
824
+
825
+ // 防抖函数
826
+ const debounce = (fn, delay) => {
827
+ let timer = null;
828
+ return function (...args) {
829
+ if (timer) clearTimeout(timer);
830
+ timer = setTimeout(() => {
831
+ fn.apply(this, args);
832
+ }, delay);
833
+ };
834
+ };
835
+
836
+ // 防抖处理过的搜索函数
837
+ const debouncedSearch = debounce((keyword) => {
838
+ if (keyword) {
839
+ const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
840
+ const type = nodeId ? activeTab.value : null;
841
+ fetchEmployeesByNode(nodeId, type, keyword);
842
+ } else if (currentActive.value && currentActive.value.length > 0) {
843
+ // 如果搜索框清空,恢复显示当前选中节点的员工列表
844
+ fetchEmployeesByNode(currentActive.value[0], activeTab.value);
845
+ } else {
846
+ // 如果没有选中节点,清空员工列表
847
+ employeeList.value = [];
848
+ }
849
+ }, 300); // 300ms防抖
850
+
851
+ // 监听搜索文本变化,触发搜索
852
+ watch(searchText, (newValue) => {
853
+ debouncedSearch(newValue);
854
+ }, { immediate: false });
855
+
856
+ // 组件挂载时执行
857
+ onMounted(() => {
858
+ // 获取已选员工详情
859
+ fetchEmployeesByIds(computedModelValue.value);
860
+ });
861
+
862
+ // 处理搜索图标点击
863
+ const handleSearchClick = () => {
864
+ if (searchText.value) {
865
+ const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
866
+ const type = nodeId ? activeTab.value : null;
867
+ fetchEmployeesByNode(nodeId, type, searchText.value);
868
+ }
869
+ };
870
+
871
+ // 处理回车键搜索
872
+ const handleSearchEnter = () => {
873
+ if (searchText.value) {
874
+ const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
875
+ const type = nodeId ? activeTab.value : null;
876
+ fetchEmployeesByNode(nodeId, type, searchText.value);
877
+ }
878
+ };
879
+
880
+ // 清除搜索
881
+ const clearSearch = () => {
882
+ searchText.value = '';
883
+ if (currentActive.value && currentActive.value.length > 0) {
884
+ fetchEmployeesByNode(currentActive.value[0], activeTab.value);
885
+ }
886
+ };
887
+ </script>
888
+
889
+ <style scoped>
890
+ .ebiz-employee-selector {
891
+ width: 100%;
892
+ display: flex;
893
+ flex-direction: column;
894
+ }
895
+
896
+ /* 选择框展示区 */
897
+ .employee-selector-container {
898
+ min-height: 32px;
899
+ width: 100%;
900
+ border: 1px solid #dcdcdc;
901
+ border-radius: 3px;
902
+ padding: 4px 8px;
903
+ display: flex;
904
+ flex-wrap: wrap;
905
+ gap: 8px;
906
+ align-items: center;
907
+ }
908
+
909
+ .selected-items {
910
+ display: flex;
911
+ flex-wrap: wrap;
912
+ gap: 8px;
913
+ }
914
+
915
+ .selected-item {
916
+ display: flex;
917
+ align-items: center;
918
+ background-color: #f0f0f0;
919
+ border-radius: 3px;
920
+ padding: 2px 8px 2px 2px;
921
+ gap: 8px;
922
+ }
923
+
924
+ .item-info {
925
+ display: flex;
926
+ align-items: center;
927
+ gap: 4px;
928
+ }
929
+
930
+ .item-code {
931
+ color: #999;
932
+ font-size: 12px;
933
+ }
934
+
935
+ .item-name {
936
+ font-size: 14px;
937
+ }
938
+
939
+ .item-remove {
940
+ cursor: pointer;
941
+ color: #999;
942
+ font-size: 12px;
943
+ }
944
+
945
+ .item-remove:hover {
946
+ color: #E34D59;
947
+ }
948
+
949
+ /* 选择弹窗 */
950
+ .selector-dialog-content {
951
+ display: flex;
952
+ height: 500px;
953
+ }
954
+
955
+ .left-panel,
956
+ .right-panel {
957
+ height: 100%;
958
+ overflow: hidden;
959
+ display: flex;
960
+ flex-direction: column;
961
+ }
962
+
963
+ .left-panel {
964
+ width: 40%;
965
+ border-right: 1px solid #dcdcdc;
966
+ padding-right: 16px;
967
+ }
968
+
969
+ .right-panel {
970
+ width: 60%;
971
+ padding-left: 16px;
972
+ }
973
+
974
+ .search-box {
975
+ margin-bottom: 16px;
976
+ }
977
+
978
+ .right-panel .search-box {
979
+ margin-top: 8px;
980
+ margin-bottom: 16px;
981
+ display: flex;
982
+ align-items: center;
983
+ gap: 8px;
984
+ }
985
+
986
+ .right-panel .search-box .t-input {
987
+ width: 100%;
988
+ border-radius: 4px;
989
+ }
990
+
991
+ .right-panel .search-box .t-input__suffix-icon {
992
+ cursor: pointer;
993
+ }
994
+
995
+ .right-panel .search-box .t-input__suffix-icon:hover {
996
+ color: var(--td-brand-color);
997
+ }
998
+
999
+ .selector-tabs {
1000
+ margin-bottom: 16px;
1001
+ }
1002
+
1003
+ .content-area {
1004
+ flex: 1;
1005
+ overflow: auto;
1006
+ position: relative;
1007
+ }
1008
+
1009
+ .loading-container {
1010
+ position: absolute;
1011
+ top: 0;
1012
+ left: 0;
1013
+ right: 0;
1014
+ bottom: 0;
1015
+ display: flex;
1016
+ justify-content: center;
1017
+ align-items: center;
1018
+ background-color: rgba(255, 255, 255, 0.6);
1019
+ z-index: 1;
1020
+ }
1021
+
1022
+ .tab-content {
1023
+ height: 100%;
1024
+ overflow: auto;
1025
+ }
1026
+
1027
+ .department-item {
1028
+ cursor: pointer;
1029
+ padding: 8px;
1030
+ }
1031
+
1032
+ .department-item:hover {
1033
+ background-color: #f5f5f5;
1034
+ }
1035
+
1036
+ .employee-header {
1037
+ display: flex;
1038
+ justify-content: space-between;
1039
+ align-items: center;
1040
+ margin-bottom: 16px;
1041
+ }
1042
+
1043
+ .employee-title {
1044
+ font-weight: bold;
1045
+ font-size: 16px;
1046
+ display: flex;
1047
+ align-items: center;
1048
+ gap: 10px;
1049
+ }
1050
+
1051
+ .sub-dept-option {
1052
+ margin-left: 10px;
1053
+ font-weight: normal;
1054
+ font-size: 14px;
1055
+ }
1056
+
1057
+ .employee-count {
1058
+ display: flex;
1059
+ align-items: center;
1060
+ gap: 8px;
1061
+ }
1062
+
1063
+ .count-info {
1064
+ color: #999;
1065
+ font-size: 14px;
1066
+ }
1067
+
1068
+ .employee-list {
1069
+ flex: 1;
1070
+ overflow: auto;
1071
+ display: flex;
1072
+ flex-direction: column;
1073
+ gap: 8px;
1074
+ height: 400px;
1075
+ }
1076
+
1077
+ .employee-item {
1078
+ display: flex;
1079
+ align-items: center;
1080
+ gap: 12px;
1081
+ padding: 8px;
1082
+ border-radius: 4px;
1083
+ }
1084
+
1085
+ .employee-item:hover {
1086
+ background-color: #f5f5f5;
1087
+ }
1088
+
1089
+ .employee-avatar {
1090
+ display: flex;
1091
+ align-items: center;
1092
+ }
1093
+
1094
+ .employee-info {
1095
+ display: flex;
1096
+ gap: 8px;
1097
+ align-items: center;
1098
+ }
1099
+
1100
+ .employee-code {
1101
+ color: #999;
1102
+ font-size: 12px;
1103
+ }
1104
+
1105
+ .employee-name {
1106
+ font-size: 14px;
1107
+ }
1108
+
1109
+ .empty-data {
1110
+ display: flex;
1111
+ justify-content: center;
1112
+ align-items: center;
1113
+ height: 200px;
1114
+ }
1115
+
1116
+ .dialog-footer {
1117
+ display: flex;
1118
+ justify-content: space-between;
1119
+ align-items: center;
1120
+ padding: 16px 0;
1121
+ }
1122
+
1123
+ .selected-preview {
1124
+ color: #666;
1125
+ }
1126
+
1127
+ .dialog-actions {
1128
+ display: flex;
1129
+ gap: 8px;
1130
+ }
1131
+
1132
+ .selected-people-list {
1133
+ margin-top: 8px;
1134
+ display: flex;
1135
+ flex-wrap: wrap;
1136
+ gap: 8px;
1137
+ }
1138
+
1139
+ .selected-people-item {
1140
+ display: flex;
1141
+ align-items: center;
1142
+ background-color: #f0f0f0;
1143
+ border-radius: 3px;
1144
+ padding: 2px 8px 2px 2px;
1145
+ gap: 8px;
1146
+ }
1147
+
1148
+ .selected-people-item:hover {
1149
+ background-color: #e0e0e0;
1150
+ }
1151
+
1152
+ .selected-people-item .item-remove {
1153
+ cursor: pointer;
1154
+ color: #999;
1155
+ font-size: 12px;
1156
+ }
1157
+
1158
+ .selected-people-item .item-remove:hover {
1159
+ color: #E34D59;
1160
+ }
1161
1161
  </style>