mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-12-27 13:16:58 +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';
|
selection?: (mForm: FormState | undefined, data: any) => boolean | boolean | 'single';
|
||||||
/** 新增的默认行 */
|
/** 新增的默认行 */
|
||||||
defaultAdd?: (mForm: FormState | undefined, data: any) => any;
|
defaultAdd?: (mForm: FormState | undefined, data: any) => any;
|
||||||
|
copyHandler?: (mForm: FormState | undefined, data: any) => any;
|
||||||
onSelect?: (mForm: FormState | undefined, data: any) => any;
|
onSelect?: (mForm: FormState | undefined, data: any) => any;
|
||||||
defautSort?: SortProp;
|
defautSort?: SortProp;
|
||||||
defaultSort?: SortProp;
|
defaultSort?: SortProp;
|
||||||
|
|||||||
@ -63,7 +63,18 @@ const removeHandler = (index: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const copyHandler = (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];
|
const { length } = props.model[props.name];
|
||||||
if (props.sortKey && length) {
|
if (props.sortKey && length) {
|
||||||
inputs[props.sortKey] = props.model[props.name][length - 1][props.sortKey] - 1;
|
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';
|
let actionFixed: 'left' | 'right' | undefined = props.config.fixed === false ? undefined : 'left';
|
||||||
|
|
||||||
if (typeof props.config.fixed === 'string' && ['left', 'right'].includes(props.config.fixed)) {
|
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) {
|
if (props.showIndex && props.config.showIndex) {
|
||||||
columns.push({
|
columns.push({
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@ -60,6 +60,10 @@ const tableColumns = computed(() => {
|
|||||||
align: item.props?.align,
|
align: item.props?.align,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (item.props.type === 'selection') {
|
||||||
|
column.type = 'multiple';
|
||||||
|
}
|
||||||
|
|
||||||
// 处理自定义单元格渲染
|
// 处理自定义单元格渲染
|
||||||
if (item.cell) {
|
if (item.cell) {
|
||||||
column.cell = (h: any, { row, rowIndex }: any) => {
|
column.cell = (h: any, { row, rowIndex }: any) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user