diff --git a/packages/renderless/src/tree-select/index.ts b/packages/renderless/src/tree-select/index.ts index a9a901731f..b3da78569e 100644 --- a/packages/renderless/src/tree-select/index.ts +++ b/packages/renderless/src/tree-select/index.ts @@ -17,16 +17,23 @@ export const nodeClick = } }) + emit('change', data[props.valueField]) + emit('update:modelValue', data[props.valueField]) + vm.$refs.baseSelectRef.hidePanel() } } export const check = - ({ props, vm }) => + ({ props, vm, emit }) => (data, { checkedNodes }) => { if (props.multiple) { + const currentValue = [] + vm.$refs.baseSelectRef.updateSelectedData( checkedNodes.map((node) => { + currentValue.push(node[props.valueField]) + return { ...node, currentLabel: node[props.textField], @@ -34,5 +41,8 @@ export const check = } }) ) + + emit('change', currentValue) + emit('update:modelValue', currentValue) } } diff --git a/packages/renderless/src/tree-select/vue.ts b/packages/renderless/src/tree-select/vue.ts index 5c01c87d41..ebb2d51237 100644 --- a/packages/renderless/src/tree-select/vue.ts +++ b/packages/renderless/src/tree-select/vue.ts @@ -2,11 +2,11 @@ import { filter, nodeClick, check } from './index' export const api = ['state', 'filter', 'nodeClick', 'check'] -export const renderless = (props, { reactive }, { vm }) => { +export const renderless = (props, { reactive, computed }, { vm, emit }) => { const api = {} const state = reactive({ - value: props.modelValue, + value: computed(() => props.modelValue), treeData: props.treeOp.data }) @@ -14,7 +14,7 @@ export const renderless = (props, { reactive }, { vm }) => { state, filter: filter({ vm }), nodeClick: nodeClick({ props, vm }), - check: check({ props, vm }) + check: check({ props, vm, emit }) }) return api