feature/核算表格双击编辑

This commit is contained in:
lys 2025-10-14 17:25:59 +08:00
parent c8fc78ac0f
commit 09132cf87b
1 changed files with 49 additions and 45 deletions

View File

@ -97,49 +97,8 @@ const Index: FunctionComponent<Props> = (props) => {
setSelectedRowKeys([...selectedRowKeys, ...rowKeys]);
setTableScrollHeight(tableScrollHeight);
setMzgOptPermission(mzgOptPermission);
setColumns([
...convertColumns(_.map(columns, (o) => ({ ...o, i18n: i18nRes }))),
{
title: i18nRes["操作"],
dataIndex: "operate",
fixed: "right",
width: optWidth || 120,
render: (__, record) => (
<Space>
<Button type="link" onClick={() => handleEdit(record?.id, showSee)}>
{showSee ? i18nRes["查看"] : i18nRes["编辑"]}
</Button>
{optWidth && (
<>
<Button
type="link"
onClick={() =>
handleLockEmp({
lockStatus: "LOCK",
acctEmpIds: [record?.id]
})
}
>
{i18nRes["锁定"]}
</Button>
<Button
type="link"
onClick={() =>
handleLockEmp({
lockStatus: "UNLOCK",
acctEmpIds: [record?.id]
})
}
>
{i18nRes["解锁"]}
</Button>
</>
)}
{record?.lockTime && <Text>{record?.lockTime}</Text>}
</Space>
)
}
]);
setColumns(_.map(columns, (o) => ({ ...o, i18n: i18nRes })));
setEditCell({});
}
};
const convertColumns: any = (cols: any[]) => {
@ -353,6 +312,51 @@ const Index: FunctionComponent<Props> = (props) => {
);
}
};
const cols = useMemo(() => {
return [
...convertColumns(columns),
{
title: i18n["操作"],
dataIndex: "operate",
fixed: "right",
width: optWidth || 120,
render: (__: any, record: any) => (
<Space>
<Button type="link" onClick={() => handleEdit(record?.id, showSee)}>
{showSee ? i18n["查看"] : i18n["编辑"]}
</Button>
{optWidth && (
<>
<Button
type="link"
onClick={() =>
handleLockEmp({
lockStatus: "LOCK",
acctEmpIds: [record?.id]
})
}
>
{i18n["锁定"]}
</Button>
<Button
type="link"
onClick={() =>
handleLockEmp({
lockStatus: "UNLOCK",
acctEmpIds: [record?.id]
})
}
>
{i18n["解锁"]}
</Button>
</>
)}
{record?.lockTime && <Text>{record?.lockTime}</Text>}
</Space>
)
}
];
}, [columns, editCell, i18n]);
const components = {
body: {
row: EditableRow,
@ -373,7 +377,7 @@ const Index: FunctionComponent<Props> = (props) => {
x: 1200,
y: `calc(100vh - ${tableScrollHeight || (!showTotalCell ? 165 : 200)}px)`
}}
columns={(!isDetailTable || showSee) && !mzgOptPermission ? columns : _.filter(columns, (o) => o.dataIndex !== "operate")}
columns={(!isDetailTable || showSee) && !mzgOptPermission ? cols : _.filter(cols, (o) => o.dataIndex !== "operate")}
footer={() => (!isDetailTable ? <CalcExplainFooter i18n={i18n} /> : null)}
pagination={
!_.isNil(pageInfo)
@ -392,7 +396,7 @@ const Index: FunctionComponent<Props> = (props) => {
<Table.Summary.Cell index={0} align="center">
<Text type="danger">{i18n["总计"]}</Text>
</Table.Summary.Cell>
<CaclFixedTotal columns={columns} dataSourceUrl={sumRowlistUrl} payload={payload} sumRow={sumRow} />
<CaclFixedTotal columns={cols} dataSourceUrl={sumRowlistUrl} payload={payload} sumRow={sumRow} />
</Table.Summary.Row>
</Table.Summary>
)