Commit 50207ad702ef3faca1e27c873c89132ab92fae8e
1 parent
4805ca26
feat(api-select): auto refetch after params changed
ApiSelect 组件在params改变后自动重新获取远程数据
Showing
1 changed file
with
9 additions
and
1 deletions
src/components/Form/src/components/ApiSelect.vue
@@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
20 | </Select> | 20 | </Select> |
21 | </template> | 21 | </template> |
22 | <script lang="ts"> | 22 | <script lang="ts"> |
23 | - import { defineComponent, PropType, ref, watchEffect, computed, unref } from 'vue'; | 23 | + import { defineComponent, PropType, ref, watchEffect, computed, unref, watch } from 'vue'; |
24 | import { Select } from 'ant-design-vue'; | 24 | import { Select } from 'ant-design-vue'; |
25 | import { isFunction } from '/@/utils/is'; | 25 | import { isFunction } from '/@/utils/is'; |
26 | import { useRuleFormItem } from '/@/hooks/component/useFormItem'; | 26 | import { useRuleFormItem } from '/@/hooks/component/useFormItem'; |
@@ -93,6 +93,14 @@ | @@ -93,6 +93,14 @@ | ||
93 | props.immediate && fetch(); | 93 | props.immediate && fetch(); |
94 | }); | 94 | }); |
95 | 95 | ||
96 | + watch( | ||
97 | + () => props.params, | ||
98 | + () => { | ||
99 | + !unref(isFirstLoad) && fetch(); | ||
100 | + }, | ||
101 | + { deep: true } | ||
102 | + ); | ||
103 | + | ||
96 | async function fetch() { | 104 | async function fetch() { |
97 | const api = props.api; | 105 | const api = props.api; |
98 | if (!api || !isFunction(api)) return; | 106 | if (!api || !isFunction(api)) return; |