Showing
1 changed file
with
18 additions
and
2 deletions
| @@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
| 5 | import { computed, ref, unref } from 'vue'; | 5 | import { computed, ref, unref } from 'vue'; |
| 6 | import OrganizationDrawer from '/@/views/system/organization/OrganizationDrawer.vue'; | 6 | import OrganizationDrawer from '/@/views/system/organization/OrganizationDrawer.vue'; |
| 7 | import { useDrawer } from '/@/components/Drawer'; | 7 | import { useDrawer } from '/@/components/Drawer'; |
| 8 | + import { OrganizationListItem } from '/@/api/system/model/systemModel'; | ||
| 8 | 9 | ||
| 9 | const [registerDrawer, { openDrawer }] = useDrawer(); | 10 | const [registerDrawer, { openDrawer }] = useDrawer(); |
| 10 | 11 | ||
| @@ -19,6 +20,8 @@ | @@ -19,6 +20,8 @@ | ||
| 19 | } | 20 | } |
| 20 | ); | 21 | ); |
| 21 | 22 | ||
| 23 | + const needReload = ref(true); | ||
| 24 | + | ||
| 22 | const emit = defineEmits(['change']); | 25 | const emit = defineEmits(['change']); |
| 23 | 26 | ||
| 24 | const handleOpenCreate = () => { | 27 | const handleOpenCreate = () => { |
| @@ -27,7 +30,9 @@ | @@ -27,7 +30,9 @@ | ||
| 27 | 30 | ||
| 28 | const timespan = ref(Date.now()); | 31 | const timespan = ref(Date.now()); |
| 29 | 32 | ||
| 30 | - const getBindProps = computed(() => { | 33 | + const orgList = ref<Recordable[]>([]); |
| 34 | + | ||
| 35 | + const getBindProps = computed<Recordable>(() => { | ||
| 31 | const { value, apiTreeSelectProps = {} } = props; | 36 | const { value, apiTreeSelectProps = {} } = props; |
| 32 | const { params = {} } = apiTreeSelectProps; | 37 | const { params = {} } = apiTreeSelectProps; |
| 33 | return { | 38 | return { |
| @@ -37,7 +42,17 @@ | @@ -37,7 +42,17 @@ | ||
| 37 | maxLength: 250, | 42 | maxLength: 250, |
| 38 | ...apiTreeSelectProps, | 43 | ...apiTreeSelectProps, |
| 39 | value, | 44 | value, |
| 40 | - api: getOrganizationList, | 45 | + api: async (params: OrganizationListItem) => { |
| 46 | + try { | ||
| 47 | + if (!unref(needReload)) return unref(orgList); | ||
| 48 | + const result = ((await getOrganizationList(params)) as unknown as Recordable[]) || []; | ||
| 49 | + orgList.value = result; | ||
| 50 | + needReload.value = false; | ||
| 51 | + return result; | ||
| 52 | + } catch (error) { | ||
| 53 | + return unref(orgList); | ||
| 54 | + } | ||
| 55 | + }, | ||
| 41 | params: { ...params, _t: unref(timespan) }, | 56 | params: { ...params, _t: unref(timespan) }, |
| 42 | onChange: (...args: any[]) => { | 57 | onChange: (...args: any[]) => { |
| 43 | emit('change', ...args); | 58 | emit('change', ...args); |
| @@ -46,6 +61,7 @@ | @@ -46,6 +61,7 @@ | ||
| 46 | }); | 61 | }); |
| 47 | 62 | ||
| 48 | const handleReload = () => { | 63 | const handleReload = () => { |
| 64 | + needReload.value = true; | ||
| 49 | timespan.value = Date.now(); | 65 | timespan.value = Date.now(); |
| 50 | }; | 66 | }; |
| 51 | </script> | 67 | </script> |