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