diff --git a/packages/renderless/src/transfer/index.ts b/packages/renderless/src/transfer/index.ts index 5da9d179ff..6baab19b72 100644 --- a/packages/renderless/src/transfer/index.ts +++ b/packages/renderless/src/transfer/index.ts @@ -217,7 +217,7 @@ export const clearQuery = (refs: ITransferRenderlessParams['refs']) => (which: ' /** SortableJs 插件的回调逻辑, 添加,删除,更新事件后,触发本函数 */ export const logicFun = - ({ props, emit, state }: Pick) => + ({ props, emit, state, vm }: Pick) => ({ event, isAdd, pullMode }: { event: any; isAdd?: boolean; pullMode?: 'sort' }) => { let currentValue = props.modelValue.slice() let movedKeys = [] @@ -225,9 +225,12 @@ export const logicFun = if (pullMode) { currentValue.splice(event.newIndex, 0, currentValue.splice(event.oldIndex, 1)[0]) } else { + const rightPanel = vm.$refs.rightPanel + const leftPanel = vm.$refs.leftPanel + const key = isAdd - ? state.targetData[event.oldIndex][props.props.key] - : state.sourceData[event.oldIndex][props.props.key] + ? rightPanel.state.filteredData[event.oldIndex][props.props.key] + : leftPanel.state.filteredData[event.oldIndex][props.props.key] const index = isAdd ? state.rightChecked.indexOf(key) : state.leftChecked.indexOf(key) const valueIndex = currentValue.indexOf(key) diff --git a/packages/renderless/src/transfer/vue.ts b/packages/renderless/src/transfer/vue.ts index 2e93eda907..6668c8ae0c 100644 --- a/packages/renderless/src/transfer/vue.ts +++ b/packages/renderless/src/transfer/vue.ts @@ -61,7 +61,7 @@ const initState = ({ reactive, computed, api, props, h, slots }): ITransferState export const renderless = ( props: ITransferProps, { computed, onMounted, reactive, h }: ISharedRenderlessParamHooks, - { $prefix, emit, refs, parent, slots }: ITransferRenderlessParamUtils + { $prefix, emit, refs, parent, slots, vm }: ITransferRenderlessParamUtils ) => { const api = {} as ITransferApi const Tree = $prefix + 'Tree' @@ -80,7 +80,7 @@ export const renderless = ( addToRight: addToRight({ emit, refs, props, state, Tree }), onTargetCheckedChange: onTargetCheckedChange({ emit, state }), onSourceCheckedChange: onSourceCheckedChange({ emit, state }), - logicFun: logicFun({ props, emit, state }), + logicFun: logicFun({ props, emit, state, vm }), getTargetData: getTargetData({ props, state, Tree, Table }), sortableEvent: sortableEvent({ api, droppanel: DROPPANEL, props, queryDom: TRANSFERPANEL, refs }) })