import { onMounted, reactive, ref, watch } from 'vue';
|
import type { State, UseTreeTransfer, TransferProps, TransferData } from '../types/transfer';
|
|
export function useTransfer(props: TransferProps): UseTreeTransfer {
|
const state = reactive<State>({
|
transferRef: undefined,
|
targetKeys: [],
|
originTargetKeys: [],
|
dataSource: props.dataSource,
|
emitKeys: [],
|
leftColumns: [],
|
rightColumns: [],
|
editKey: [],
|
titles: [],
|
});
|
|
//const disabled = ref<boolean>(false);
|
//const showSearch = ref<boolean>(false);
|
|
// watch(props.titles, (newVal, oldVal) => {
|
// state.titles = newVal;
|
// console.log('old', oldVal);
|
// });
|
|
onMounted(() => {
|
//processTreeData();
|
});
|
|
/** 穿梭更改 */
|
const onChange = (nextTargetKeys: string[]) => {
|
console.log('nextTargetKeys', nextTargetKeys);
|
state.targetKeys = nextTargetKeys;
|
};
|
|
const seDatas = (
|
titles: string[],
|
DataSource: TransferData[],
|
originTargetKeys: string[],
|
RightColumns: [],
|
LeftColumns: [],
|
) => {
|
state.titles = titles;
|
state.dataSource = DataSource;
|
state.originTargetKeys = originTargetKeys;
|
state.targetKeys = state.originTargetKeys;
|
// state.originTargetKeys = state.dataSource
|
// .filter((item) => item.key == 'CK011')
|
// .map((item) => item.key);
|
// state.targetKeys = state.originTargetKeys;
|
state.leftColumns = LeftColumns; //props.leftColumns;
|
state.rightColumns = RightColumns; //props.rightColumns;
|
};
|
|
return {
|
state,
|
onChange,
|
seDatas,
|
};
|
}
|