Commit b65b995bc83fb896ac1395c85829ffdb157af894

Authored by ww
1 parent 818e5320

perf: 优化组织下拉树选择器

... ... @@ -8,9 +8,10 @@
8 8
9 9 const [registerDrawer, { openDrawer }] = useDrawer();
10 10
11   - withDefaults(
  11 + const props = withDefaults(
12 12 defineProps<{
13   - apiTreeSelect?: Recordable;
  13 + value?: string | string[];
  14 + apiTreeSelectProps?: Recordable;
14 15 showCreate?: boolean;
15 16 }>(),
16 17 {
... ... @@ -18,6 +19,8 @@
18 19 }
19 20 );
20 21
  22 + const emit = defineEmits(['change']);
  23 +
21 24 const handleOpenCreate = () => {
22 25 openDrawer(true, { isUpdate: false });
23 26 };
... ... @@ -25,12 +28,20 @@
25 28 const timespan = ref(Date.now());
26 29
27 30 const getBindProps = computed(() => {
  31 + const { value, apiTreeSelectProps = {} } = props;
  32 + const { params = {} } = apiTreeSelectProps;
28 33 return {
29   - maxLength: 250,
  34 + replaceFields: { children: 'children', key: 'id', title: 'name', value: 'id' },
  35 + getPopupContainer: () => document.body,
30 36 placeholder: '请选择所属组织',
  37 + maxLength: 250,
  38 + ...apiTreeSelectProps,
  39 + value,
31 40 api: getOrganizationList,
32   - params: { _t: unref(timespan) },
33   - replaceFields: { children: 'children', key: 'id', title: 'name', value: 'id' },
  41 + params: { ...params, _t: unref(timespan) },
  42 + onChange: (...args: any[]) => {
  43 + emit('change', ...args);
  44 + },
34 45 };
35 46 });
36 47
... ...