@ebiz/designer-components 0.1.11 → 0.1.13

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