From 9915eab368584a9ebcdb46dec4feb8ef911ff06b Mon Sep 17 00:00:00 2001 From: xingyu Date: Sun, 15 Oct 2023 17:41:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84ApiTree=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E9=87=8D=E7=BD=AE=E5=9B=9E=E6=98=BE=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Form/src/components/ApiTree.vue | 15 +++++++++++++-- src/components/Form/src/hooks/useFormEvents.ts | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/Form/src/components/ApiTree.vue b/src/components/Form/src/components/ApiTree.vue index 20c8abd..7588346 100644 --- a/src/components/Form/src/components/ApiTree.vue +++ b/src/components/Form/src/components/ApiTree.vue @@ -6,6 +6,7 @@ import type { DataNode } from 'ant-design-vue/es/tree' import { isArray, isFunction } from '@/utils/is' import { handleTree as handleTreeFn } from '@/utils/tree' import { propTypes } from '@/utils/propTypes' +import { useRuleFormItem } from '@/hooks/component/useFormItem' defineOptions({ name: 'ApiTree' }) @@ -17,14 +18,17 @@ const props = defineProps({ afterFetch: { type: Function as PropType }, handleTree: propTypes.string.def(''), alwaysLoad: propTypes.bool.def(true), + value: [Array, Object, String, Number], }) -const emit = defineEmits(['optionsChange', 'change']) +const emit = defineEmits(['optionsChange', 'change', 'update:value']) const attrs = useAttrs() const slots = useSlots() const treeData = ref([]) const isFirstLoaded = ref(false) const loading = ref(false) +const emitData = ref([]) +const [state] = useRuleFormItem(props, 'value', 'change', emitData) const getAttrs = computed(() => { return { @@ -37,6 +41,13 @@ function handleChange(...args) { emit('change', ...args) } +watch( + () => state.value, + (v) => { + emit('update:value', v) + }, +) + watch( () => props.params, () => { @@ -96,7 +107,7 @@ async function fetch() {