@ebiz/designer-components 0.1.27 → 0.1.28
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.
package/package.json
CHANGED
|
@@ -110,16 +110,19 @@
|
|
|
110
110
|
</div>
|
|
111
111
|
|
|
112
112
|
<div class="employee-list">
|
|
113
|
-
<div v-for="(item, index) in filteredEmployeeList" :key="index" class="employee-item">
|
|
113
|
+
<div v-for="(item, index) in filteredEmployeeList" :key="index" class="employee-item" style="cursor: pointer;">
|
|
114
114
|
<t-checkbox v-model="item.checked" @change="handleCheckChange(item)"></t-checkbox>
|
|
115
|
-
<div
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
<div class="employee-
|
|
121
|
-
|
|
115
|
+
<div style="display: flex; align-items: center; gap: 10px; flex: 1;">
|
|
116
|
+
<div class="employee-avatar">
|
|
117
|
+
<t-avatar v-if="item.avatar" :image="item.avatar" size="small" />
|
|
118
|
+
<t-avatar v-else size="small">{{ getAvatarText(item.name) }}</t-avatar>
|
|
119
|
+
</div>
|
|
120
|
+
<div class="employee-info">
|
|
121
|
+
<div class="employee-code">{{ item.no }} - </div>
|
|
122
|
+
<div class="employee-name">{{ item.name }}</div>
|
|
123
|
+
</div>
|
|
122
124
|
</div>
|
|
125
|
+
|
|
123
126
|
</div>
|
|
124
127
|
<div v-if="filteredEmployeeList.length === 0" class="empty-data">
|
|
125
128
|
<t-empty />
|
|
@@ -176,6 +179,7 @@ import {
|
|
|
176
179
|
MessagePlugin
|
|
177
180
|
} from 'tdesign-vue-next';
|
|
178
181
|
import dataService from '../apiService/simpleDataService';
|
|
182
|
+
import { get } from 'lodash';
|
|
179
183
|
|
|
180
184
|
// 定义组件属性
|
|
181
185
|
const props = defineProps({
|
|
@@ -270,36 +274,37 @@ const getAvatarText = (name) => {
|
|
|
270
274
|
return name ? name.substring(0, 1) : '';
|
|
271
275
|
};
|
|
272
276
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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);
|
|
277
|
+
const computedModelValue = computed({
|
|
278
|
+
set(val) {
|
|
279
|
+
if( props.single ){
|
|
280
|
+
if( val.length > 0 ){
|
|
281
|
+
emit("update:modelValue", val[0]);
|
|
282
|
+
}else{
|
|
283
|
+
emit("update:modelValue", "");
|
|
297
284
|
}
|
|
285
|
+
return ;
|
|
298
286
|
}
|
|
299
|
-
|
|
287
|
+
emit("update:modelValue", val);
|
|
288
|
+
},
|
|
289
|
+
get() {
|
|
300
290
|
|
|
301
|
-
|
|
302
|
-
|
|
291
|
+
let value = props.modelValue
|
|
292
|
+
|
|
293
|
+
if (props.single) {
|
|
294
|
+
value = props.modelValue ? [props.modelValue] : [];
|
|
295
|
+
}
|
|
296
|
+
value.forEach((val)=>{
|
|
297
|
+
return Number(val);
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
employeeList.value.forEach(emp => {
|
|
301
|
+
if (!value.includes(Number(emp.id))) {
|
|
302
|
+
emp.checked = false;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
return value;
|
|
306
|
+
}
|
|
307
|
+
});
|
|
303
308
|
|
|
304
309
|
// 更新全选状态
|
|
305
310
|
const updateSelectAllStatus = () => {
|
|
@@ -308,7 +313,7 @@ const updateSelectAllStatus = () => {
|
|
|
308
313
|
|
|
309
314
|
const updateSelectStatus = () => {
|
|
310
315
|
employeeList.value.forEach(item => {
|
|
311
|
-
item.checked =
|
|
316
|
+
item.checked = computedModelValue.value.includes(item.id);
|
|
312
317
|
})
|
|
313
318
|
}
|
|
314
319
|
|
|
@@ -320,28 +325,8 @@ const selectedEmployees = computed(() => {
|
|
|
320
325
|
// 根据搜索文本过滤的员工列表
|
|
321
326
|
const filteredEmployeeList = computed(() => {
|
|
322
327
|
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
328
|
});
|
|
337
329
|
|
|
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
330
|
|
|
346
331
|
// 获取组织架构数据
|
|
347
332
|
const fetchOrganizationData = async () => {
|
|
@@ -520,7 +505,7 @@ const fetchEmployeesByIds = async (ids) => {
|
|
|
520
505
|
selectedItems.value = [];
|
|
521
506
|
return;
|
|
522
507
|
}
|
|
523
|
-
if (
|
|
508
|
+
if( !(ids instanceof Array) ){
|
|
524
509
|
ids = [ids];
|
|
525
510
|
}
|
|
526
511
|
|
|
@@ -628,14 +613,13 @@ const handleCheckChange = (item) => {
|
|
|
628
613
|
// 移除已选择的项目
|
|
629
614
|
const removeItem = (index, id) => {
|
|
630
615
|
// 移除ID
|
|
631
|
-
const newIds = [...
|
|
616
|
+
const newIds = [...computedModelValue.value];
|
|
632
617
|
const idIndex = newIds.indexOf(id);
|
|
633
618
|
if (idIndex !== -1) {
|
|
634
619
|
newIds.splice(idIndex, 1);
|
|
635
620
|
emit('update:modelValue', newIds);
|
|
636
621
|
emit('change', newIds);
|
|
637
622
|
}
|
|
638
|
-
|
|
639
623
|
// 移除展示项
|
|
640
624
|
selectedItems.value.splice(index, 1);
|
|
641
625
|
};
|
|
@@ -695,17 +679,14 @@ const showDialog = () => {
|
|
|
695
679
|
const handleConfirm = () => {
|
|
696
680
|
const selectedEmployeeIds = tempSelectedEmployees.value.map(item => item.id);
|
|
697
681
|
|
|
682
|
+
computedModelValue.value = selectedEmployeeIds;
|
|
698
683
|
if (props.single) {
|
|
699
|
-
emit('update:modelValue', selectedEmployeeIds[0]);
|
|
700
684
|
emit('change', selectedEmployeeIds[0]);
|
|
701
685
|
emit('confirm', selectedEmployeeIds[0]);
|
|
702
686
|
} else {
|
|
703
|
-
emit('update:modelValue', selectedEmployeeIds);
|
|
704
687
|
emit('change', selectedEmployeeIds);
|
|
705
688
|
emit('confirm', selectedEmployeeIds);
|
|
706
|
-
|
|
707
689
|
}
|
|
708
|
-
|
|
709
690
|
dialogVisible.value = false;
|
|
710
691
|
};
|
|
711
692
|
|
|
@@ -802,7 +783,7 @@ watch(searchText, (newValue) => {
|
|
|
802
783
|
// 组件挂载时执行
|
|
803
784
|
onMounted(() => {
|
|
804
785
|
// 获取已选员工详情
|
|
805
|
-
fetchEmployeesByIds(
|
|
786
|
+
fetchEmployeesByIds(computedModelValue.value);
|
|
806
787
|
});
|
|
807
788
|
|
|
808
789
|
// 处理搜索图标点击
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<div class="demo-section">
|
|
6
6
|
<h3>基础用法</h3>
|
|
7
7
|
<div class="demo-block">
|
|
8
|
-
<EbizEmployeeSelector v-model="selectedEmployees" />
|
|
8
|
+
<EbizEmployeeSelector v-model="selectedEmployees" single />
|
|
9
9
|
|
|
10
10
|
<div class="demo-info" v-if="selectedEmployees.length > 0">
|
|
11
11
|
<h4>已选员工:</h4>
|
|
@@ -23,7 +23,7 @@ import { EbizEmployeeSelector } from '../index.js';
|
|
|
23
23
|
import { Button as TButton } from 'tdesign-vue-next';
|
|
24
24
|
|
|
25
25
|
// 演示数据
|
|
26
|
-
const selectedEmployees = ref(
|
|
26
|
+
const selectedEmployees = ref("3176");
|
|
27
27
|
const singleEmployee = ref([]);
|
|
28
28
|
const roleEmployees = ref([]);
|
|
29
29
|
const limitedEmployees = ref([]);
|