@ebiz/designer-components 0.1.78 → 0.1.79

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 (219) hide show
  1. package/README.md +29 -29
  2. package/dist/designer-components.css +1 -1
  3. package/dist/index.mjs +20744 -20701
  4. package/package.json +1 -1
  5. package/src/App.vue +26 -26
  6. package/src/apiService/SIMPLE_DATA_SERVICE.md +284 -284
  7. package/src/apiService/mockDataService.js +115 -115
  8. package/src/apiService/simpleDataService.js +299 -299
  9. package/src/assets/base.css +86 -86
  10. package/src/assets/logo.svg +1 -1
  11. package/src/components/Button.vue +149 -149
  12. package/src/components/DataContainer.vue +40 -40
  13. package/src/components/EbizApproval.vue +335 -335
  14. package/src/components/EbizApprovalForm.vue +507 -507
  15. package/src/components/EbizAutoForm.vue +596 -596
  16. package/src/components/EbizAvatar.vue +115 -115
  17. package/src/components/EbizCheckbox.vue +93 -93
  18. package/src/components/EbizCheckboxGroup.vue +69 -69
  19. package/src/components/EbizDepartmentSelector.vue +149 -149
  20. package/src/components/EbizDescriptions.vue +340 -340
  21. package/src/components/EbizDescriptionsItem.vue +47 -47
  22. package/src/components/EbizDetailBlock.vue +81 -81
  23. package/src/components/EbizDetailItem.vue +559 -559
  24. package/src/components/EbizDetailView.md +438 -438
  25. package/src/components/EbizDetailView.vue +355 -355
  26. package/src/components/EbizDialog.vue +260 -260
  27. package/src/components/EbizDiv.vue +40 -40
  28. package/src/components/EbizDivider.vue +96 -96
  29. package/src/components/EbizDropdown.vue +135 -135
  30. package/src/components/EbizDropdownItem.vue +85 -85
  31. package/src/components/EbizEmployeeInfo.vue +138 -138
  32. package/src/components/EbizEmployeeSelector.vue +1159 -1159
  33. package/src/components/EbizFileList.vue +466 -466
  34. package/src/components/EbizMap.vue +541 -541
  35. package/src/components/EbizMeetingRoomSelector.vue +664 -664
  36. package/src/components/EbizMobileMeetingRoomSelector.vue +727 -727
  37. package/src/components/EbizOkrTree.vue +99 -99
  38. package/src/components/EbizPageHeader.vue +95 -95
  39. package/src/components/EbizPagination.vue +162 -162
  40. package/src/components/EbizPdfViewer.vue +540 -540
  41. package/src/components/EbizPopconfirm.vue +47 -47
  42. package/src/components/EbizQrCode.vue +73 -73
  43. package/src/components/EbizRadio.vue +86 -86
  44. package/src/components/EbizRadioGroup.vue +83 -83
  45. package/src/components/EbizRemoteSelect.vue +232 -232
  46. package/src/components/EbizRichTextEditor.vue +275 -275
  47. package/src/components/EbizRouteBreadcrumb.vue +46 -46
  48. package/src/components/EbizSApprovalProcess.vue +1429 -1429
  49. package/src/components/EbizSelect.vue +85 -85
  50. package/src/components/EbizSpace.vue +100 -100
  51. package/src/components/EbizStatistic.vue +149 -149
  52. package/src/components/EbizStatsCard.vue +113 -113
  53. package/src/components/EbizSwiper.vue +113 -113
  54. package/src/components/EbizSwiperItem.vue +13 -13
  55. package/src/components/EbizSwitch.vue +85 -85
  56. package/src/components/EbizTabHeader.vue +132 -132
  57. package/src/components/EbizTabPanel.vue +22 -22
  58. package/src/components/EbizTable.vue +469 -469
  59. package/src/components/EbizTableColumn.vue +116 -116
  60. package/src/components/EbizTableSort.vue +179 -179
  61. package/src/components/EbizTabs.vue +142 -142
  62. package/src/components/EbizTdesignButtonDialog.vue +332 -332
  63. package/src/components/EbizTdesignLoading.vue +107 -107
  64. package/src/components/EbizTimePicker.vue +143 -143
  65. package/src/components/EbizTitle.vue +91 -91
  66. package/src/components/EbizTree.vue +141 -141
  67. package/src/components/EbizTreeMergeTable.vue +1494 -1494
  68. package/src/components/EbizTreeSelector.vue +418 -418
  69. package/src/components/EbizVideo.vue +553 -553
  70. package/src/components/EbizVxeTable.vue +290 -290
  71. package/src/components/Form.vue +28 -28
  72. package/src/components/Home.vue +7 -7
  73. package/src/components/MyComponent.vue +39 -39
  74. package/src/components/Table.vue +45 -45
  75. package/src/components/TdesignAlert.vue +115 -115
  76. package/src/components/TdesignButton.vue +135 -135
  77. package/src/components/TdesignCalendar/index.vue +145 -145
  78. package/src/components/TdesignCard.vue +195 -195
  79. package/src/components/TdesignCol.vue +101 -101
  80. package/src/components/TdesignCollapse.vue +142 -142
  81. package/src/components/TdesignCollapsePanel.vue +79 -79
  82. package/src/components/TdesignDatePicker.vue +124 -124
  83. package/src/components/TdesignDescriptions.vue +74 -74
  84. package/src/components/TdesignDescriptionsItem.vue +50 -50
  85. package/src/components/TdesignDialog.vue +225 -225
  86. package/src/components/TdesignForm.vue +138 -138
  87. package/src/components/TdesignFormItem.vue +105 -105
  88. package/src/components/TdesignGrid.vue +55 -55
  89. package/src/components/TdesignIcon.vue +67 -67
  90. package/src/components/TdesignImage.vue +162 -162
  91. package/src/components/TdesignImageViewer.vue +200 -200
  92. package/src/components/TdesignInput.vue +242 -242
  93. package/src/components/TdesignSelect.vue +446 -446
  94. package/src/components/TdesignTag.vue +117 -117
  95. package/src/components/TdesignTextarea.vue +142 -142
  96. package/src/components/TdesignTimeline.vue +58 -58
  97. package/src/components/TdesignTimelineItem.vue +71 -71
  98. package/src/components/TdesignUpload.vue +414 -414
  99. package/src/components/TdesignWatermark.vue +107 -107
  100. package/src/components/ebiz-form/components/cascader.vue +61 -61
  101. package/src/components/ebiz-form/components/checkbox.vue +37 -37
  102. package/src/components/ebiz-form/components/city.vue +137 -137
  103. package/src/components/ebiz-form/components/date-panel.vue +52 -52
  104. package/src/components/ebiz-form/components/date-range-panel.vue +52 -52
  105. package/src/components/ebiz-form/components/date-range.vue +56 -56
  106. package/src/components/ebiz-form/components/date.vue +52 -52
  107. package/src/components/ebiz-form/components/editor-multi-language.vue +47 -47
  108. package/src/components/ebiz-form/components/editor.vue +78 -78
  109. package/src/components/ebiz-form/components/file-multi-language.vue +52 -52
  110. package/src/components/ebiz-form/components/file.vue +149 -149
  111. package/src/components/ebiz-form/components/images-multi-language.vue +52 -52
  112. package/src/components/ebiz-form/components/images.vue +129 -129
  113. package/src/components/ebiz-form/components/img-multi-language.vue +51 -51
  114. package/src/components/ebiz-form/components/img.vue +129 -129
  115. package/src/components/ebiz-form/components/number.vue +50 -50
  116. package/src/components/ebiz-form/components/radio.vue +28 -28
  117. package/src/components/ebiz-form/components/select.vue +119 -119
  118. package/src/components/ebiz-form/components/switch.vue +23 -23
  119. package/src/components/ebiz-form/components/text-multi-language.vue +47 -47
  120. package/src/components/ebiz-form/components/text.vue +52 -52
  121. package/src/components/ebiz-form/components/textarea-multi-language.vue +48 -48
  122. package/src/components/ebiz-form/components/textarea.vue +29 -29
  123. package/src/components/ebiz-form/components/video-multi-language.vue +51 -51
  124. package/src/components/ebiz-form/components/video.vue +97 -97
  125. package/src/components/ebiz-form/index.vue +157 -157
  126. package/src/components/examples/PopconfirmExample.vue +149 -149
  127. package/src/components/icons/IconCommunity.vue +7 -7
  128. package/src/components/icons/IconDocumentation.vue +7 -7
  129. package/src/components/icons/IconEcosystem.vue +7 -7
  130. package/src/components/icons/IconSupport.vue +7 -7
  131. package/src/components/icons/IconTooling.vue +19 -19
  132. package/src/components/mItems/UserInfo.vue +342 -342
  133. package/src/components/senior/EbizSData/index.vue +273 -273
  134. package/src/components/senior/EbizSDialog/index.vue +770 -772
  135. package/src/components/senior/EbizSForm/README.md +157 -157
  136. package/src/components/senior/EbizSForm/index.vue +667 -667
  137. package/src/components/senior/EbizSForm/item.vue +971 -971
  138. package/src/components/senior/EbizSForm/mItems/DateTimePicker.vue +51 -51
  139. package/src/components/senior/EbizSForm/mItems/Picker.vue +63 -63
  140. package/src/index.js +255 -255
  141. package/src/main.js +55 -55
  142. package/src/router/index.js +415 -415
  143. package/src/utils/formatCode.js +24 -24
  144. package/src/utils/generateImportStatement.js +52 -52
  145. package/src/utils/hasJsx.js +25 -25
  146. package/src/utils/index.js +166 -166
  147. package/src/utils/mergeOptions.js +29 -29
  148. package/src/utils/parseRequiredBlocks.js +18 -18
  149. package/src/utils/vue-sfc-validator.js +155 -155
  150. package/src/views/Button.vue +23 -23
  151. package/src/views/CheckboxDemo.vue +104 -104
  152. package/src/views/DataContainer.vue +19 -19
  153. package/src/views/DialogDemo.vue +125 -125
  154. package/src/views/EbizApprovalDemo.vue +87 -87
  155. package/src/views/EbizApprovalFormDemo.vue +207 -207
  156. package/src/views/EbizAutoFormDemo.vue +129 -129
  157. package/src/views/EbizAvatar.vue +223 -223
  158. package/src/views/EbizDepartmentSelectorDemo.vue +169 -169
  159. package/src/views/EbizDetailBlockDemo.vue +30 -30
  160. package/src/views/EbizDetailViewDemo.vue +412 -412
  161. package/src/views/EbizEmployeeInfo.vue +249 -249
  162. package/src/views/EbizEmployeeSelector.vue +85 -85
  163. package/src/views/EbizFileListDemo.vue +339 -339
  164. package/src/views/EbizMap.vue +201 -201
  165. package/src/views/EbizMeetingRoomSelectorDemo.vue +293 -293
  166. package/src/views/EbizMobileMeetingRoomSelectorDemo.vue +566 -566
  167. package/src/views/EbizRadioDemo.vue +151 -151
  168. package/src/views/EbizSDataDemo.vue +136 -136
  169. package/src/views/EbizSDialogDemo.vue +303 -303
  170. package/src/views/EbizSForm/index.vue +351 -351
  171. package/src/views/EbizSFormDemo.vue +420 -420
  172. package/src/views/EbizSpace.vue +185 -185
  173. package/src/views/EbizSwiper.vue +157 -157
  174. package/src/views/EbizTdesignButtonDialogExample.vue +437 -437
  175. package/src/views/Form.vue +19 -19
  176. package/src/views/GridDemo.vue +238 -238
  177. package/src/views/Home.vue +153 -153
  178. package/src/views/Mindmap.vue +17 -17
  179. package/src/views/MyComponent.vue +19 -19
  180. package/src/views/OkrTree.vue +19 -19
  181. package/src/views/PageHeaderDemo.vue +104 -104
  182. package/src/views/PaginationDemo.vue +96 -96
  183. package/src/views/PdfViewerDemo.vue +433 -433
  184. package/src/views/PermissionBoxDemo.vue +85 -85
  185. package/src/views/PopconfirmDemo.vue +80 -80
  186. package/src/views/RemoteSelect.vue +350 -350
  187. package/src/views/StatisticDemo.vue +190 -190
  188. package/src/views/SwitchDemo.vue +79 -79
  189. package/src/views/Table.vue +19 -19
  190. package/src/views/TableDemo.vue +334 -334
  191. package/src/views/TableSortDemo.vue +143 -143
  192. package/src/views/TableView.vue +68 -68
  193. package/src/views/TabsDemo.vue +282 -282
  194. package/src/views/TagDemo.vue +101 -101
  195. package/src/views/TdesignAlert.vue +98 -98
  196. package/src/views/TdesignButton.vue +190 -190
  197. package/src/views/TdesignCalendar.vue +94 -94
  198. package/src/views/TdesignCard.vue +296 -296
  199. package/src/views/TdesignCollapse.vue +293 -293
  200. package/src/views/TdesignDatePicker.vue +187 -187
  201. package/src/views/TdesignDescriptions.vue +101 -101
  202. package/src/views/TdesignForm.vue +248 -248
  203. package/src/views/TdesignIcon.vue +203 -203
  204. package/src/views/TdesignImage.vue +215 -215
  205. package/src/views/TdesignImageViewer.vue +198 -198
  206. package/src/views/TdesignInput.vue +252 -252
  207. package/src/views/TdesignSelect.vue +473 -473
  208. package/src/views/TdesignSwiper.vue +157 -157
  209. package/src/views/TextareaDemo.vue +93 -93
  210. package/src/views/TimePickerDemo.vue +146 -146
  211. package/src/views/TimelineDemo.vue +160 -160
  212. package/src/views/Title.vue +19 -19
  213. package/src/views/TreeDemo.vue +254 -254
  214. package/src/views/TreeMergeTableDemo.vue +239 -239
  215. package/src/views/TreeSelectorDemo.vue +245 -245
  216. package/src/views/UploadDemo.vue +128 -128
  217. package/src/views/VideoDemo.vue +245 -245
  218. package/src/views/VxeTableDemo.vue +279 -279
  219. package/src/views/WatermarkDemo.vue +85 -85
@@ -1,1160 +1,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 @keyup.enter="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
- const selectedEmployeeIds = tempSelectedEmployees.value.map(item => item.id);
770
-
771
- computedModelValue.value = selectedEmployeeIds;
772
- if (props.single) {
773
- emit('change', selectedEmployeeIds[0]);
774
- emit('confirm', selectedEmployeeIds[0]);
775
- } else {
776
- emit('change', selectedEmployeeIds);
777
- emit('confirm', selectedEmployeeIds);
778
- }
779
- dialogVisible.value = false;
780
- };
781
-
782
- // 取消选择
783
- const handleCancel = () => {
784
- // 放弃临时选择
785
- tempSelectedEmployees.value = [];
786
- dialogVisible.value = false;
787
- };
788
-
789
- // 监听标签页切换
790
- watch(activeTab, () => {
791
- // 切换标签页时重新加载数据
792
- initSelector();
793
- });
794
-
795
- // 监听modelValue变化,更新展示的员工信息
796
- watch(() => props.modelValue, (newIds, oldIds) => {
797
- // 判断值是否真的变化了 (通过比较JSON字符串)
798
- const newIdsStr = JSON.stringify(newIds || []);
799
- const oldIdsStr = JSON.stringify(oldIds || []);
800
-
801
- if (newIdsStr !== oldIdsStr) {
802
- // 获取员工详情数据
803
- fetchEmployeesByIds(newIds);
804
- }
805
- }, { immediate: true, deep: true });
806
- watch(() => props.visible, (val) => {
807
- tempSelectedEmployees.value = [];
808
- currentActive.value = [];
809
- currentNodeName.value = '';
810
-
811
- if (val) {
812
- fetchOrganizationData()
813
- }
814
- }, { immediate: true })
815
-
816
- // 监听子部门查询开关变化
817
- watch(childDeptEnable, () => {
818
- // 如果当前在组织架构页面且有选中节点,重新加载员工列表
819
- if (activeTab.value === 'organization' && currentActive.value && currentActive.value.length > 0) {
820
- fetchEmployeesByNode(currentActive.value[0], activeTab.value);
821
- }
822
- });
823
-
824
- // 防抖函数
825
- const debounce = (fn, delay) => {
826
- let timer = null;
827
- return function (...args) {
828
- if (timer) clearTimeout(timer);
829
- timer = setTimeout(() => {
830
- fn.apply(this, args);
831
- }, delay);
832
- };
833
- };
834
-
835
- // 防抖处理过的搜索函数
836
- const debouncedSearch = debounce((keyword) => {
837
- if (keyword) {
838
- const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
839
- const type = nodeId ? activeTab.value : null;
840
- fetchEmployeesByNode(nodeId, type, keyword);
841
- } else if (currentActive.value && currentActive.value.length > 0) {
842
- // 如果搜索框清空,恢复显示当前选中节点的员工列表
843
- fetchEmployeesByNode(currentActive.value[0], activeTab.value);
844
- } else {
845
- // 如果没有选中节点,清空员工列表
846
- employeeList.value = [];
847
- }
848
- }, 300); // 300ms防抖
849
-
850
- // 监听搜索文本变化,触发搜索
851
- watch(searchText, (newValue) => {
852
- debouncedSearch(newValue);
853
- }, { immediate: false });
854
-
855
- // 组件挂载时执行
856
- onMounted(() => {
857
- // 获取已选员工详情
858
- fetchEmployeesByIds(computedModelValue.value);
859
- });
860
-
861
- // 处理搜索图标点击
862
- const handleSearchClick = () => {
863
- if (searchText.value) {
864
- const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
865
- const type = nodeId ? activeTab.value : null;
866
- fetchEmployeesByNode(nodeId, type, searchText.value);
867
- }
868
- };
869
-
870
- // 处理回车键搜索
871
- const handleSearchEnter = () => {
872
- if (searchText.value) {
873
- const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
874
- const type = nodeId ? activeTab.value : null;
875
- fetchEmployeesByNode(nodeId, type, searchText.value);
876
- }
877
- };
878
-
879
- // 清除搜索
880
- const clearSearch = () => {
881
- searchText.value = '';
882
- if (currentActive.value && currentActive.value.length > 0) {
883
- fetchEmployeesByNode(currentActive.value[0], activeTab.value);
884
- }
885
- };
886
- </script>
887
-
888
- <style scoped>
889
- .ebiz-employee-selector {
890
- width: 100%;
891
- display: flex;
892
- flex-direction: column;
893
- }
894
-
895
- /* 选择框展示区 */
896
- .employee-selector-container {
897
- min-height: 32px;
898
- width: 100%;
899
- border: 1px solid #dcdcdc;
900
- border-radius: 3px;
901
- padding: 4px 8px;
902
- display: flex;
903
- flex-wrap: wrap;
904
- gap: 8px;
905
- align-items: center;
906
- }
907
-
908
- .selected-items {
909
- display: flex;
910
- flex-wrap: wrap;
911
- gap: 8px;
912
- }
913
-
914
- .selected-item {
915
- display: flex;
916
- align-items: center;
917
- background-color: #f0f0f0;
918
- border-radius: 3px;
919
- padding: 2px 8px 2px 2px;
920
- gap: 8px;
921
- }
922
-
923
- .item-info {
924
- display: flex;
925
- align-items: center;
926
- gap: 4px;
927
- }
928
-
929
- .item-code {
930
- color: #999;
931
- font-size: 12px;
932
- }
933
-
934
- .item-name {
935
- font-size: 14px;
936
- }
937
-
938
- .item-remove {
939
- cursor: pointer;
940
- color: #999;
941
- font-size: 12px;
942
- }
943
-
944
- .item-remove:hover {
945
- color: #E34D59;
946
- }
947
-
948
- /* 选择弹窗 */
949
- .selector-dialog-content {
950
- display: flex;
951
- height: 500px;
952
- }
953
-
954
- .left-panel,
955
- .right-panel {
956
- height: 100%;
957
- overflow: hidden;
958
- display: flex;
959
- flex-direction: column;
960
- }
961
-
962
- .left-panel {
963
- width: 40%;
964
- border-right: 1px solid #dcdcdc;
965
- padding-right: 16px;
966
- }
967
-
968
- .right-panel {
969
- width: 60%;
970
- padding-left: 16px;
971
- }
972
-
973
- .search-box {
974
- margin-bottom: 16px;
975
- }
976
-
977
- .right-panel .search-box {
978
- margin-top: 8px;
979
- margin-bottom: 16px;
980
- display: flex;
981
- align-items: center;
982
- gap: 8px;
983
- }
984
-
985
- .right-panel .search-box .t-input {
986
- width: 100%;
987
- border-radius: 4px;
988
- }
989
-
990
- .right-panel .search-box .t-input__suffix-icon {
991
- cursor: pointer;
992
- }
993
-
994
- .right-panel .search-box .t-input__suffix-icon:hover {
995
- color: var(--td-brand-color);
996
- }
997
-
998
- .selector-tabs {
999
- margin-bottom: 16px;
1000
- }
1001
-
1002
- .content-area {
1003
- flex: 1;
1004
- overflow: auto;
1005
- position: relative;
1006
- }
1007
-
1008
- .loading-container {
1009
- position: absolute;
1010
- top: 0;
1011
- left: 0;
1012
- right: 0;
1013
- bottom: 0;
1014
- display: flex;
1015
- justify-content: center;
1016
- align-items: center;
1017
- background-color: rgba(255, 255, 255, 0.6);
1018
- z-index: 1;
1019
- }
1020
-
1021
- .tab-content {
1022
- height: 100%;
1023
- overflow: auto;
1024
- }
1025
-
1026
- .department-item {
1027
- cursor: pointer;
1028
- padding: 8px;
1029
- }
1030
-
1031
- .department-item:hover {
1032
- background-color: #f5f5f5;
1033
- }
1034
-
1035
- .employee-header {
1036
- display: flex;
1037
- justify-content: space-between;
1038
- align-items: center;
1039
- margin-bottom: 16px;
1040
- }
1041
-
1042
- .employee-title {
1043
- font-weight: bold;
1044
- font-size: 16px;
1045
- display: flex;
1046
- align-items: center;
1047
- gap: 10px;
1048
- }
1049
-
1050
- .sub-dept-option {
1051
- margin-left: 10px;
1052
- font-weight: normal;
1053
- font-size: 14px;
1054
- }
1055
-
1056
- .employee-count {
1057
- display: flex;
1058
- align-items: center;
1059
- gap: 8px;
1060
- }
1061
-
1062
- .count-info {
1063
- color: #999;
1064
- font-size: 14px;
1065
- }
1066
-
1067
- .employee-list {
1068
- flex: 1;
1069
- overflow: auto;
1070
- display: flex;
1071
- flex-direction: column;
1072
- gap: 8px;
1073
- height: 400px;
1074
- }
1075
-
1076
- .employee-item {
1077
- display: flex;
1078
- align-items: center;
1079
- gap: 12px;
1080
- padding: 8px;
1081
- border-radius: 4px;
1082
- }
1083
-
1084
- .employee-item:hover {
1085
- background-color: #f5f5f5;
1086
- }
1087
-
1088
- .employee-avatar {
1089
- display: flex;
1090
- align-items: center;
1091
- }
1092
-
1093
- .employee-info {
1094
- display: flex;
1095
- gap: 8px;
1096
- align-items: center;
1097
- }
1098
-
1099
- .employee-code {
1100
- color: #999;
1101
- font-size: 12px;
1102
- }
1103
-
1104
- .employee-name {
1105
- font-size: 14px;
1106
- }
1107
-
1108
- .empty-data {
1109
- display: flex;
1110
- justify-content: center;
1111
- align-items: center;
1112
- height: 200px;
1113
- }
1114
-
1115
- .dialog-footer {
1116
- display: flex;
1117
- justify-content: space-between;
1118
- align-items: center;
1119
- padding: 16px 0;
1120
- }
1121
-
1122
- .selected-preview {
1123
- color: #666;
1124
- }
1125
-
1126
- .dialog-actions {
1127
- display: flex;
1128
- gap: 8px;
1129
- }
1130
-
1131
- .selected-people-list {
1132
- margin-top: 8px;
1133
- display: flex;
1134
- flex-wrap: wrap;
1135
- gap: 8px;
1136
- }
1137
-
1138
- .selected-people-item {
1139
- display: flex;
1140
- align-items: center;
1141
- background-color: #f0f0f0;
1142
- border-radius: 3px;
1143
- padding: 2px 8px 2px 2px;
1144
- gap: 8px;
1145
- }
1146
-
1147
- .selected-people-item:hover {
1148
- background-color: #e0e0e0;
1149
- }
1150
-
1151
- .selected-people-item .item-remove {
1152
- cursor: pointer;
1153
- color: #999;
1154
- font-size: 12px;
1155
- }
1156
-
1157
- .selected-people-item .item-remove:hover {
1158
- color: #E34D59;
1159
- }
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 @keyup.enter="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
+ const selectedEmployeeIds = tempSelectedEmployees.value.map(item => item.id);
770
+
771
+ computedModelValue.value = selectedEmployeeIds;
772
+ if (props.single) {
773
+ emit('change', selectedEmployeeIds[0]);
774
+ emit('confirm', selectedEmployeeIds[0]);
775
+ } else {
776
+ emit('change', selectedEmployeeIds);
777
+ emit('confirm', selectedEmployeeIds);
778
+ }
779
+ dialogVisible.value = false;
780
+ };
781
+
782
+ // 取消选择
783
+ const handleCancel = () => {
784
+ // 放弃临时选择
785
+ tempSelectedEmployees.value = [];
786
+ dialogVisible.value = false;
787
+ };
788
+
789
+ // 监听标签页切换
790
+ watch(activeTab, () => {
791
+ // 切换标签页时重新加载数据
792
+ initSelector();
793
+ });
794
+
795
+ // 监听modelValue变化,更新展示的员工信息
796
+ watch(() => props.modelValue, (newIds, oldIds) => {
797
+ // 判断值是否真的变化了 (通过比较JSON字符串)
798
+ const newIdsStr = JSON.stringify(newIds || []);
799
+ const oldIdsStr = JSON.stringify(oldIds || []);
800
+
801
+ if (newIdsStr !== oldIdsStr) {
802
+ // 获取员工详情数据
803
+ fetchEmployeesByIds(newIds);
804
+ }
805
+ }, { immediate: true, deep: true });
806
+ watch(() => props.visible, (val) => {
807
+ tempSelectedEmployees.value = [];
808
+ currentActive.value = [];
809
+ currentNodeName.value = '';
810
+
811
+ if (val) {
812
+ fetchOrganizationData()
813
+ }
814
+ }, { immediate: true })
815
+
816
+ // 监听子部门查询开关变化
817
+ watch(childDeptEnable, () => {
818
+ // 如果当前在组织架构页面且有选中节点,重新加载员工列表
819
+ if (activeTab.value === 'organization' && currentActive.value && currentActive.value.length > 0) {
820
+ fetchEmployeesByNode(currentActive.value[0], activeTab.value);
821
+ }
822
+ });
823
+
824
+ // 防抖函数
825
+ const debounce = (fn, delay) => {
826
+ let timer = null;
827
+ return function (...args) {
828
+ if (timer) clearTimeout(timer);
829
+ timer = setTimeout(() => {
830
+ fn.apply(this, args);
831
+ }, delay);
832
+ };
833
+ };
834
+
835
+ // 防抖处理过的搜索函数
836
+ const debouncedSearch = debounce((keyword) => {
837
+ if (keyword) {
838
+ const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
839
+ const type = nodeId ? activeTab.value : null;
840
+ fetchEmployeesByNode(nodeId, type, keyword);
841
+ } else if (currentActive.value && currentActive.value.length > 0) {
842
+ // 如果搜索框清空,恢复显示当前选中节点的员工列表
843
+ fetchEmployeesByNode(currentActive.value[0], activeTab.value);
844
+ } else {
845
+ // 如果没有选中节点,清空员工列表
846
+ employeeList.value = [];
847
+ }
848
+ }, 300); // 300ms防抖
849
+
850
+ // 监听搜索文本变化,触发搜索
851
+ watch(searchText, (newValue) => {
852
+ debouncedSearch(newValue);
853
+ }, { immediate: false });
854
+
855
+ // 组件挂载时执行
856
+ onMounted(() => {
857
+ // 获取已选员工详情
858
+ fetchEmployeesByIds(computedModelValue.value);
859
+ });
860
+
861
+ // 处理搜索图标点击
862
+ const handleSearchClick = () => {
863
+ if (searchText.value) {
864
+ const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
865
+ const type = nodeId ? activeTab.value : null;
866
+ fetchEmployeesByNode(nodeId, type, searchText.value);
867
+ }
868
+ };
869
+
870
+ // 处理回车键搜索
871
+ const handleSearchEnter = () => {
872
+ if (searchText.value) {
873
+ const nodeId = currentActive.value && currentActive.value.length > 0 ? currentActive.value[0] : null;
874
+ const type = nodeId ? activeTab.value : null;
875
+ fetchEmployeesByNode(nodeId, type, searchText.value);
876
+ }
877
+ };
878
+
879
+ // 清除搜索
880
+ const clearSearch = () => {
881
+ searchText.value = '';
882
+ if (currentActive.value && currentActive.value.length > 0) {
883
+ fetchEmployeesByNode(currentActive.value[0], activeTab.value);
884
+ }
885
+ };
886
+ </script>
887
+
888
+ <style scoped>
889
+ .ebiz-employee-selector {
890
+ width: 100%;
891
+ display: flex;
892
+ flex-direction: column;
893
+ }
894
+
895
+ /* 选择框展示区 */
896
+ .employee-selector-container {
897
+ min-height: 32px;
898
+ width: 100%;
899
+ border: 1px solid #dcdcdc;
900
+ border-radius: 3px;
901
+ padding: 4px 8px;
902
+ display: flex;
903
+ flex-wrap: wrap;
904
+ gap: 8px;
905
+ align-items: center;
906
+ }
907
+
908
+ .selected-items {
909
+ display: flex;
910
+ flex-wrap: wrap;
911
+ gap: 8px;
912
+ }
913
+
914
+ .selected-item {
915
+ display: flex;
916
+ align-items: center;
917
+ background-color: #f0f0f0;
918
+ border-radius: 3px;
919
+ padding: 2px 8px 2px 2px;
920
+ gap: 8px;
921
+ }
922
+
923
+ .item-info {
924
+ display: flex;
925
+ align-items: center;
926
+ gap: 4px;
927
+ }
928
+
929
+ .item-code {
930
+ color: #999;
931
+ font-size: 12px;
932
+ }
933
+
934
+ .item-name {
935
+ font-size: 14px;
936
+ }
937
+
938
+ .item-remove {
939
+ cursor: pointer;
940
+ color: #999;
941
+ font-size: 12px;
942
+ }
943
+
944
+ .item-remove:hover {
945
+ color: #E34D59;
946
+ }
947
+
948
+ /* 选择弹窗 */
949
+ .selector-dialog-content {
950
+ display: flex;
951
+ height: 500px;
952
+ }
953
+
954
+ .left-panel,
955
+ .right-panel {
956
+ height: 100%;
957
+ overflow: hidden;
958
+ display: flex;
959
+ flex-direction: column;
960
+ }
961
+
962
+ .left-panel {
963
+ width: 40%;
964
+ border-right: 1px solid #dcdcdc;
965
+ padding-right: 16px;
966
+ }
967
+
968
+ .right-panel {
969
+ width: 60%;
970
+ padding-left: 16px;
971
+ }
972
+
973
+ .search-box {
974
+ margin-bottom: 16px;
975
+ }
976
+
977
+ .right-panel .search-box {
978
+ margin-top: 8px;
979
+ margin-bottom: 16px;
980
+ display: flex;
981
+ align-items: center;
982
+ gap: 8px;
983
+ }
984
+
985
+ .right-panel .search-box .t-input {
986
+ width: 100%;
987
+ border-radius: 4px;
988
+ }
989
+
990
+ .right-panel .search-box .t-input__suffix-icon {
991
+ cursor: pointer;
992
+ }
993
+
994
+ .right-panel .search-box .t-input__suffix-icon:hover {
995
+ color: var(--td-brand-color);
996
+ }
997
+
998
+ .selector-tabs {
999
+ margin-bottom: 16px;
1000
+ }
1001
+
1002
+ .content-area {
1003
+ flex: 1;
1004
+ overflow: auto;
1005
+ position: relative;
1006
+ }
1007
+
1008
+ .loading-container {
1009
+ position: absolute;
1010
+ top: 0;
1011
+ left: 0;
1012
+ right: 0;
1013
+ bottom: 0;
1014
+ display: flex;
1015
+ justify-content: center;
1016
+ align-items: center;
1017
+ background-color: rgba(255, 255, 255, 0.6);
1018
+ z-index: 1;
1019
+ }
1020
+
1021
+ .tab-content {
1022
+ height: 100%;
1023
+ overflow: auto;
1024
+ }
1025
+
1026
+ .department-item {
1027
+ cursor: pointer;
1028
+ padding: 8px;
1029
+ }
1030
+
1031
+ .department-item:hover {
1032
+ background-color: #f5f5f5;
1033
+ }
1034
+
1035
+ .employee-header {
1036
+ display: flex;
1037
+ justify-content: space-between;
1038
+ align-items: center;
1039
+ margin-bottom: 16px;
1040
+ }
1041
+
1042
+ .employee-title {
1043
+ font-weight: bold;
1044
+ font-size: 16px;
1045
+ display: flex;
1046
+ align-items: center;
1047
+ gap: 10px;
1048
+ }
1049
+
1050
+ .sub-dept-option {
1051
+ margin-left: 10px;
1052
+ font-weight: normal;
1053
+ font-size: 14px;
1054
+ }
1055
+
1056
+ .employee-count {
1057
+ display: flex;
1058
+ align-items: center;
1059
+ gap: 8px;
1060
+ }
1061
+
1062
+ .count-info {
1063
+ color: #999;
1064
+ font-size: 14px;
1065
+ }
1066
+
1067
+ .employee-list {
1068
+ flex: 1;
1069
+ overflow: auto;
1070
+ display: flex;
1071
+ flex-direction: column;
1072
+ gap: 8px;
1073
+ height: 400px;
1074
+ }
1075
+
1076
+ .employee-item {
1077
+ display: flex;
1078
+ align-items: center;
1079
+ gap: 12px;
1080
+ padding: 8px;
1081
+ border-radius: 4px;
1082
+ }
1083
+
1084
+ .employee-item:hover {
1085
+ background-color: #f5f5f5;
1086
+ }
1087
+
1088
+ .employee-avatar {
1089
+ display: flex;
1090
+ align-items: center;
1091
+ }
1092
+
1093
+ .employee-info {
1094
+ display: flex;
1095
+ gap: 8px;
1096
+ align-items: center;
1097
+ }
1098
+
1099
+ .employee-code {
1100
+ color: #999;
1101
+ font-size: 12px;
1102
+ }
1103
+
1104
+ .employee-name {
1105
+ font-size: 14px;
1106
+ }
1107
+
1108
+ .empty-data {
1109
+ display: flex;
1110
+ justify-content: center;
1111
+ align-items: center;
1112
+ height: 200px;
1113
+ }
1114
+
1115
+ .dialog-footer {
1116
+ display: flex;
1117
+ justify-content: space-between;
1118
+ align-items: center;
1119
+ padding: 16px 0;
1120
+ }
1121
+
1122
+ .selected-preview {
1123
+ color: #666;
1124
+ }
1125
+
1126
+ .dialog-actions {
1127
+ display: flex;
1128
+ gap: 8px;
1129
+ }
1130
+
1131
+ .selected-people-list {
1132
+ margin-top: 8px;
1133
+ display: flex;
1134
+ flex-wrap: wrap;
1135
+ gap: 8px;
1136
+ }
1137
+
1138
+ .selected-people-item {
1139
+ display: flex;
1140
+ align-items: center;
1141
+ background-color: #f0f0f0;
1142
+ border-radius: 3px;
1143
+ padding: 2px 8px 2px 2px;
1144
+ gap: 8px;
1145
+ }
1146
+
1147
+ .selected-people-item:hover {
1148
+ background-color: #e0e0e0;
1149
+ }
1150
+
1151
+ .selected-people-item .item-remove {
1152
+ cursor: pointer;
1153
+ color: #999;
1154
+ font-size: 12px;
1155
+ }
1156
+
1157
+ .selected-people-item .item-remove:hover {
1158
+ color: #E34D59;
1159
+ }
1160
1160
  </style>