mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
feat(table): action hook配置加入index参数
This commit is contained in:
parent
af393e34fb
commit
26835f6a29
@ -6,7 +6,7 @@
|
|||||||
v-show="display(action.display, scope.row) && !editState[scope.$index]"
|
v-show="display(action.display, scope.row) && !editState[scope.$index]"
|
||||||
class="action-btn"
|
class="action-btn"
|
||||||
text
|
text
|
||||||
type="primary"
|
:type="action.buttonType || 'primary'"
|
||||||
size="small"
|
size="small"
|
||||||
:icon="action.icon"
|
:icon="action.icon"
|
||||||
:key="actionIndex"
|
:key="actionIndex"
|
||||||
@ -72,13 +72,13 @@ const formatter = (fuc: string | Function | undefined, row: any) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const actionHandler = async (action: ColumnActionConfig, row: any, index: number) => {
|
const actionHandler = async (action: ColumnActionConfig, row: any, index: number) => {
|
||||||
await action.before?.(row);
|
await action.before?.(row, index);
|
||||||
if (action.type === 'edit') {
|
if (action.type === 'edit') {
|
||||||
props.editState[index] = row;
|
props.editState[index] = row;
|
||||||
} else {
|
} else {
|
||||||
await action.handler?.(row);
|
await action.handler?.(row, index);
|
||||||
}
|
}
|
||||||
action.after?.(row);
|
action.after?.(row, index);
|
||||||
};
|
};
|
||||||
|
|
||||||
const save = async (index: number, config: ColumnConfig) => {
|
const save = async (index: number, config: ColumnConfig) => {
|
||||||
|
@ -20,13 +20,14 @@ import { FormConfig, FormValue } from '@tmagic/form';
|
|||||||
|
|
||||||
export interface ColumnActionConfig {
|
export interface ColumnActionConfig {
|
||||||
type?: 'delete' | 'copy' | 'edit';
|
type?: 'delete' | 'copy' | 'edit';
|
||||||
|
buttonType: string;
|
||||||
display?: (row: any) => boolean;
|
display?: (row: any) => boolean;
|
||||||
text: string | ((row: any) => string);
|
text: string | ((row: any) => string);
|
||||||
name: string;
|
name: string;
|
||||||
icon?: any;
|
icon?: any;
|
||||||
handler?: (row: any) => Promise<any> | any;
|
handler?: (row: any, index: number) => Promise<any> | any;
|
||||||
before?: (row: any) => void;
|
before?: (row: any, index: number) => void;
|
||||||
after?: (row: any) => void;
|
after?: (row: any, index: number) => void;
|
||||||
action?: (data: { data: any }) => void;
|
action?: (data: { data: any }) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user