|
|
|
@ -83,23 +83,28 @@ const Index: FunctionComponent<Props> = (props) => {
|
|
|
|
|
setSelectedRowKeys(selectedRowKeys);
|
|
|
|
|
editItemList.current = [];
|
|
|
|
|
setTableScrollHeight(tableScrollHeight);
|
|
|
|
|
setColumns([...convertColumns(_.map(columns, o => ({ ...o, i18n: i18nRes }))), {
|
|
|
|
|
setColumns([...convertColumns(_.map(columns, o => ({ ...o, i18n: i18nRes })), calcDetail), {
|
|
|
|
|
title: i18nRes["操作"], dataIndex: "operate", fixed: "right", width: 120,
|
|
|
|
|
render: (__, record) => (<Button type="link" onClick={() => handleEdit(record?.id)}>{i18nRes["编辑"]}</Button>)
|
|
|
|
|
}]);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const convertColumns: any = (cols: any[]) => {
|
|
|
|
|
const convertColumns: any = (cols: any[], editable: boolean) => {
|
|
|
|
|
return _.map(cols, item => {
|
|
|
|
|
if (_.isNaN(parseInt(item.dataIndex))) {
|
|
|
|
|
return { ...item, editable: false };
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
|
|
|
|
...item, title: <CustomTableTitle {...item} onHandleFormulatd={handleFormulaTd}/>,
|
|
|
|
|
children: convertColumns(_.map(item.children, o => ({ ...o, i18n: item.i18n }))),
|
|
|
|
|
className: styles["td_odd"], i18n: item.i18n, editable: true,
|
|
|
|
|
children: convertColumns(_.map(item.children, o => ({ ...o, i18n: item.i18n })), editable),
|
|
|
|
|
className: styles["td_odd"], i18n: item.i18n, editable: !editable,
|
|
|
|
|
onCell: (record: any, rowIndex: number) => ({
|
|
|
|
|
record, rowIndex, dataIndex: item.dataIndex, title: item.title, editable: true, pattern: item.pattern,
|
|
|
|
|
record,
|
|
|
|
|
rowIndex,
|
|
|
|
|
dataIndex: item.dataIndex,
|
|
|
|
|
title: item.title,
|
|
|
|
|
editable: !editable,
|
|
|
|
|
pattern: item.pattern,
|
|
|
|
|
handleSave
|
|
|
|
|
}),
|
|
|
|
|
render: (text: string) => (
|
|
|
|
|