mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-12-24 19:07:44 +08:00
feat(form,tdesign-vue-next-adapter): table 多选框放到默认的操作前面,支持配置copy的干预函数
This commit is contained in:
parent
f7811fdb24
commit
5fe91e89b7
@ -716,6 +716,7 @@ export interface TableConfig extends FormItem {
|
||||
selection?: (mForm: FormState | undefined, data: any) => boolean | boolean | 'single';
|
||||
/** 新增的默认行 */
|
||||
defaultAdd?: (mForm: FormState | undefined, data: any) => any;
|
||||
copyHandler?: (mForm: FormState | undefined, data: any) => any;
|
||||
onSelect?: (mForm: FormState | undefined, data: any) => any;
|
||||
defautSort?: SortProp;
|
||||
defaultSort?: SortProp;
|
||||
|
||||
@ -63,7 +63,18 @@ const removeHandler = (index: number) => {
|
||||
};
|
||||
|
||||
const copyHandler = (index: number) => {
|
||||
const inputs = cloneDeep(props.model[props.name][index]);
|
||||
let inputs = cloneDeep(props.model[props.name][index]);
|
||||
|
||||
if (typeof props.config.copyHandler === 'function') {
|
||||
const modelName = props.name || props.config.name || '';
|
||||
inputs = props.config.copyHandler(mForm, {
|
||||
model: props.model[modelName],
|
||||
prop: props.prop,
|
||||
formValue: mForm?.values,
|
||||
inputs,
|
||||
});
|
||||
}
|
||||
|
||||
const { length } = props.model[props.name];
|
||||
if (props.sortKey && length) {
|
||||
inputs[props.sortKey] = props.model[props.name][length - 1][props.sortKey] - 1;
|
||||
|
||||
@ -101,6 +101,17 @@ export const useTableColumns = (
|
||||
});
|
||||
}
|
||||
|
||||
if (selection.value) {
|
||||
columns.push({
|
||||
props: {
|
||||
align: 'center',
|
||||
headerAlign: 'center',
|
||||
type: 'selection',
|
||||
width: 45,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let actionFixed: 'left' | 'right' | undefined = props.config.fixed === false ? undefined : 'left';
|
||||
|
||||
if (typeof props.config.fixed === 'string' && ['left', 'right'].includes(props.config.fixed)) {
|
||||
@ -159,17 +170,6 @@ export const useTableColumns = (
|
||||
});
|
||||
}
|
||||
|
||||
if (selection.value) {
|
||||
columns.push({
|
||||
props: {
|
||||
align: 'center',
|
||||
headerAlign: 'center',
|
||||
type: 'selection',
|
||||
width: 45,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (props.showIndex && props.config.showIndex) {
|
||||
columns.push({
|
||||
props: {
|
||||
|
||||
@ -60,6 +60,10 @@ const tableColumns = computed(() => {
|
||||
align: item.props?.align,
|
||||
};
|
||||
|
||||
if (item.props.type === 'selection') {
|
||||
column.type = 'multiple';
|
||||
}
|
||||
|
||||
// 处理自定义单元格渲染
|
||||
if (item.cell) {
|
||||
column.cell = (h: any, { row, rowIndex }: any) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user