Merge branch 'master' into feature/业务线管理

# Conflicts:
#	src/pages/unitTable/renderColsOpts.tsx
release/2.19.1.2503.01-业务线个税
lys 8 months ago
commit 597c00af41

@ -13,8 +13,9 @@ export type extraType = {
permission: boolean; permission: boolean;
scrollHeight: number; scrollHeight: number;
rowKey: string; rowKey: string;
showTotalCell: boolean showTotalCell: boolean;
} isSpecial: boolean;
};
const UnitTable: FC = (props) => { const UnitTable: FC = (props) => {
const [unitTableType, setUnitTableType] = useState<string>(""); const [unitTableType, setUnitTableType] = useState<string>("");
const [columns, setColumns] = useState<Array<any>>([]); const [columns, setColumns] = useState<Array<any>>([]);
@ -35,8 +36,19 @@ const UnitTable: FC = (props) => {
const data: any = exceptStr(event.data); const data: any = exceptStr(event.data);
if (!_.isEmpty(data)) { if (!_.isEmpty(data)) {
const { const {
columns, dataSource, pageInfo, scrollHeight, i18n, showOperateBtn: permission, unitTableType = "welfareRecord", columns,
selectedRowKeys: rowKeys = [], selectedKey, rowKey, showTotalCell = false, sumDataSource = {} dataSource,
pageInfo,
scrollHeight,
i18n,
showOperateBtn: permission,
unitTableType = "welfareRecord",
selectedRowKeys: rowKeys = [],
selectedKey,
rowKey,
showTotalCell = false,
sumDataSource = {},
isSpecial = false
} = data; } = data;
setI18n(i18n); setI18n(i18n);
setColumns(columns); setColumns(columns);
@ -45,8 +57,13 @@ const UnitTable: FC = (props) => {
setUnitTableType(unitTableType); setUnitTableType(unitTableType);
setSumRow(sumDataSource); setSumRow(sumDataSource);
setExtraParams({ setExtraParams({
selectedKey, scrollHeight, permission, rowKey, showTotalCell, selectedKey,
selectedRowKeys: [...extraParams.selectedRowKeys as string[] | number[], ...rowKeys] scrollHeight,
permission,
rowKey,
showTotalCell,
isSpecial,
selectedRowKeys: [...(extraParams.selectedRowKeys as string[] | number[]), ...rowKeys]
}); });
} }
}; };
@ -64,37 +81,49 @@ const UnitTable: FC = (props) => {
}); });
}; };
const rowSelection = { const rowSelection = {
columnWidth: 60, selectedRowKeys: extraParams.selectedRowKeys, columnWidth: 60,
selectedRowKeys: extraParams.selectedRowKeys,
preserveSelectedRowKeys: true, preserveSelectedRowKeys: true,
onChange: (selectedRowKeys: React.Key[]) => { onChange: (selectedRowKeys: React.Key[]) => {
// @ts-ignore // @ts-ignore
setExtraParams({ ...extraParams, selectedRowKeys: selectedRowKeys }); setExtraParams({ ...extraParams, selectedRowKeys: selectedRowKeys });
window.parent.postMessage( window.parent.postMessage({ type: "turn", payload: { id: "CHECKBOX", params: { selectedRowKeys } } }, "*");
{ type: "turn", payload: { id: "CHECKBOX", params: { selectedRowKeys } } }, "*"
);
} }
}; };
return <Table rowKey={extraParams.rowKey || "id"} className={styles.multi_fun_table} dataSource={dataSource} return (
size="middle" columns={renderCols(columns, unitTableType, i18n, extraParams)} <Table
rowKey={extraParams.rowKey || "id"}
className={styles.multi_fun_table}
dataSource={dataSource}
size="middle"
columns={renderCols(columns, unitTableType, i18n, extraParams)}
scroll={{ x: 1200, y: `calc(100vh - ${extraParams?.scrollHeight || 109}px)` }} scroll={{ x: 1200, y: `calc(100vh - ${extraParams?.scrollHeight || 109}px)` }}
bordered={_.some(columns, k => k.children)} bordered={_.some(columns, (k) => k.children)}
rowSelection={!_.isNil(extraParams?.selectedRowKeys) ? rowSelection : undefined} rowSelection={!_.isNil(extraParams?.selectedRowKeys) ? rowSelection : undefined}
pagination={!_.isNil(pageInfo) ? { pagination={
!_.isNil(pageInfo)
? {
...paginationAction(pageInfo, i18n, onChange), ...paginationAction(pageInfo, i18n, onChange),
size: "default" size: "default"
} : false} }
summary={() => ( : false
!extraParams.showTotalCell ? <></> : }
summary={() =>
!extraParams.showTotalCell ? (
<></>
) : (
<Table.Summary fixed={true}> <Table.Summary fixed={true}>
<Table.Summary.Row> <Table.Summary.Row>
<Table.Summary.Cell index={0} align="center"><Text <Table.Summary.Cell index={0} align="center">
type="danger">{i18n["总计"]}</Text></Table.Summary.Cell> <Text type="danger">{i18n["总计"]}</Text>
<CaclFixedTotal columns={!_.isNil(extraParams?.selectedRowKeys) ? columns : columns.slice(1)} </Table.Summary.Cell>
dataSourceUrl="" payload={{}} sumRow={sumRow}/> <CaclFixedTotal columns={!_.isNil(extraParams?.selectedRowKeys) ? columns : columns.slice(1)} dataSourceUrl="" payload={{}} sumRow={sumRow} />
</Table.Summary.Row> </Table.Summary.Row>
</Table.Summary> </Table.Summary>
)} )
/>; }
/>
);
}; };
export default UnitTable; export default UnitTable;

@ -14,7 +14,10 @@ const { Text } = Typography;
export function renderCols(initialState: any[], type: string, i18n?: AnyObject, extraParams?: Partial<extraType>) { export function renderCols(initialState: any[], type: string, i18n?: AnyObject, extraParams?: Partial<extraType>) {
return React.useMemo(() => { return React.useMemo(() => {
if (type === "welfareRecord") { if (type === "welfareRecord") {
return [..._.map(_.filter(initialState, o => o.dataIndex !== "id"), g => { return [
..._.map(
_.filter(initialState, (o) => o.dataIndex !== "id"),
(g) => {
let col = { ...g, ellipsis: true, fixed: g.dataIndex === "billMonth", width: 180 }; let col = { ...g, ellipsis: true, fixed: g.dataIndex === "billMonth", width: 180 };
switch (g.dataIndex) { switch (g.dataIndex) {
case "billMonth": case "billMonth":
@ -23,14 +26,19 @@ export function renderCols(initialState: any[], type: string, i18n?: AnyObject,
width: 120, width: 120,
render: (text: string, record: any) => { render: (text: string, record: any) => {
const { billStatus } = record; const { billStatus } = record;
return (<Button type="link" return (
onClick={() => postMessageToParent((billStatus === "0" && record?.opts.includes("admin")) ? "CALC" : "VIEW", record)}>{text}</Button>); <Button type="link" onClick={() => postMessageToParent(billStatus === "0" && record?.opts.includes("admin") ? "CALC" : "VIEW", record)}>
{text}
</Button>
);
} }
}; };
break; break;
case "billStatus": case "billStatus":
col = { col = {
...col, width: 100, render: (text: string) => ( ...col,
width: 100,
render: (text: string) => (
<Text style={{ maxWidth: "100%" }} ellipsis> <Text style={{ maxWidth: "100%" }} ellipsis>
{text === "1" ? i18n?.["已归档"] : i18n?.["未归档"]} {text === "1" ? i18n?.["已归档"] : i18n?.["未归档"]}
</Text> </Text>
@ -53,8 +61,13 @@ export function renderCols(initialState: any[], type: string, i18n?: AnyObject,
break; break;
} }
return col; return col;
}), { }
dataIndex: "operate", title: i18n?.["操作"], width: 185, fixed: "right", ),
{
dataIndex: "operate",
title: i18n?.["操作"],
width: 185,
fixed: "right",
render: (__: string, record: any) => { render: (__: string, record: any) => {
const { billStatus } = record; const { billStatus } = record;
const items: MenuProps["items"] = [ const items: MenuProps["items"] = [
@ -71,39 +84,51 @@ export function renderCols(initialState: any[], type: string, i18n?: AnyObject,
]; ];
return ( return (
<Space> <Space>
{ {!record?.opts.includes("admin") ? (
!record?.opts.includes("admin") ?
<Space> <Space>
<Button type="link" onClick={() => postMessageToParent("VIEW", record)}>{i18n?.["查看"]}</Button> <Button type="link" onClick={() => postMessageToParent("VIEW", record)}>
<Dropdown menu={{ {i18n?.["查看"]}
</Button>
<Dropdown
menu={{
items: [ items: [
{ key: "Log", label: i18n?.["操作日志"], onClick: () => postMessageToParent("log", record) } {
key: "Log",
label: i18n?.["操作日志"],
onClick: () => postMessageToParent("log", record)
}
] ]
}} placement="bottomRight"> }}
placement="bottomRight"
>
<Button type="link" icon={<MoreOutlined />} /> <Button type="link" icon={<MoreOutlined />} />
</Dropdown> </Dropdown>
</Space> : </Space>
) : (
<> <>
{ {billStatus === "0" && (
billStatus === "0" &&
<> <>
<Button type="link" <Button type="link" onClick={() => postMessageToParent("CALC", record)}>
onClick={() => postMessageToParent("CALC", record)}>{i18n?.["核算"]}</Button> {i18n?.["核算"]}
<Button type="link" </Button>
onClick={() => postMessageToParent("FILE", record)}>{i18n?.["归档"]}</Button> <Button type="link" onClick={() => postMessageToParent("FILE", record)}>
{i18n?.["归档"]}
</Button>
<Dropdown menu={{ items }} placement="bottomRight"> <Dropdown menu={{ items }} placement="bottomRight">
<Button type="link" icon={<MoreOutlined />} /> <Button type="link" icon={<MoreOutlined />} />
</Dropdown> </Dropdown>
</> </>
} )}
{ {billStatus === "1" && (
billStatus === "1" &&
<> <>
<Button type="link" <Button type="link" onClick={() => postMessageToParent("VIEW", record)}>
onClick={() => postMessageToParent("VIEW", record)}>{i18n?.["查看"]}</Button> {i18n?.["查看"]}
<Button type="link" </Button>
onClick={() => postMessageToParent("RECALC", record)}>{i18n?.["重新核算"]}</Button> <Button type="link" onClick={() => postMessageToParent("RECALC", record)}>
<Dropdown menu={{ {i18n?.["重新核算"]}
</Button>
<Dropdown
menu={{
items: [ items: [
{ {
key: "Log", key: "Log",
@ -111,19 +136,23 @@ export function renderCols(initialState: any[], type: string, i18n?: AnyObject,
onClick: () => postMessageToParent("log", record) onClick: () => postMessageToParent("log", record)
} }
] ]
}} placement="bottomRight"> }}
placement="bottomRight"
>
<Button type="link" icon={<MoreOutlined />} /> <Button type="link" icon={<MoreOutlined />} />
</Dropdown> </Dropdown>
</> </>
} )}
</> </>
} )}
</Space> </Space>
); );
} }
}]; }
];
} else if (type === "bonusplan") { } else if (type === "bonusplan") {
return [..._.map(initialState, g => { return [
..._.map(initialState, (g) => {
let col = { ...g, ellipsis: true, fixed: false, width: 150 }; let col = { ...g, ellipsis: true, fixed: false, width: 150 };
switch (g.dataIndex) { switch (g.dataIndex) {
case "taxYear": case "taxYear":
@ -132,7 +161,9 @@ export function renderCols(initialState: any[], type: string, i18n?: AnyObject,
break; break;
case "billStatus": case "billStatus":
col = { col = {
...col, width: 100, render: (text: string) => ( ...col,
width: 100,
render: (text: string) => (
<Text style={{ maxWidth: "100%" }} ellipsis> <Text style={{ maxWidth: "100%" }} ellipsis>
{text === "1" ? i18n?.["已归档"] : i18n?.["未归档"]} {text === "1" ? i18n?.["已归档"] : i18n?.["未归档"]}
</Text> </Text>
@ -144,13 +175,15 @@ export function renderCols(initialState: any[], type: string, i18n?: AnyObject,
break; break;
case "employeeCount": case "employeeCount":
col = { col = {
...col, title: <Space> ...col,
title: (
<Space>
<Text>{g.title}</Text> <Text>{g.title}</Text>
<Tooltip placement="top" <Tooltip placement="top" title={i18n?.["若同一个人 在两个个税扣缴义务人下 同一纳税年度 同时发年终奖,统计为两个人"]}>
title={i18n?.["若同一个人 在两个个税扣缴义务人下 同一纳税年度 同时发年终奖,统计为两个人"]}>
<QuestionCircleFilled /> <QuestionCircleFilled />
</Tooltip> </Tooltip>
</Space> </Space>
)
}; };
break; break;
default: default:
@ -158,8 +191,12 @@ export function renderCols(initialState: any[], type: string, i18n?: AnyObject,
break; break;
} }
return col; return col;
}), { }),
dataIndex: "operate", title: i18n?.["操作"], width: 185, fixed: "right", {
dataIndex: "operate",
title: i18n?.["操作"],
width: 185,
fixed: "right",
render: (__: string, record: any) => { render: (__: string, record: any) => {
const { fileStatus } = record; const { fileStatus } = record;
const items: MenuProps["items"] = [ const items: MenuProps["items"] = [
@ -181,32 +218,37 @@ export function renderCols(initialState: any[], type: string, i18n?: AnyObject,
]; ];
return ( return (
<Space> <Space>
{ {!extraParams?.permission ? (
!extraParams?.permission ?
<Space> <Space>
<Button type="link" <Button type="link" onClick={() => postMessageToParent("VIEW", record)}>
onClick={() => postMessageToParent("VIEW", record)}>{i18n?.["查看详情"]}</Button> {i18n?.["查看详情"]}
</Button>
<Dropdown menu={{ items: items.slice(-1) }} placement="bottomRight"> <Dropdown menu={{ items: items.slice(-1) }} placement="bottomRight">
<Button type="link" icon={<MoreOutlined />} /> <Button type="link" icon={<MoreOutlined />} />
</Dropdown> </Dropdown>
</Space> : </Space>
) : (
<> <>
<Button type="link" <Button type="link" onClick={() => postMessageToParent("VIEW", record)}>
onClick={() => postMessageToParent("VIEW", record)}>{i18n?.["查看详情"]}</Button> {i18n?.["查看详情"]}
<Button type="link" </Button>
onClick={() => postMessageToParent("EDIT", record)}>{i18n?.["编辑"]}</Button> <Button type="link" onClick={() => postMessageToParent("EDIT", record)}>
{i18n?.["编辑"]}
</Button>
<Dropdown menu={{ items }} placement="bottomRight"> <Dropdown menu={{ items }} placement="bottomRight">
<Button type="link" icon={<MoreOutlined />} /> <Button type="link" icon={<MoreOutlined />} />
</Dropdown> </Dropdown>
</> </>
} )}
</Space> </Space>
); );
} }
}]; }
];
} else if (type === "bonusStrategy") { } else if (type === "bonusStrategy") {
const { selectedKey } = extraParams as { selectedKey: string }; const { selectedKey } = extraParams as { selectedKey: string };
return [..._.map(initialState, g => { return [
..._.map(initialState, (g) => {
let col = { ...g, ellipsis: true, fixed: false, width: 120 }; let col = { ...g, ellipsis: true, fixed: false, width: 120 };
switch (g.dataIndex) { switch (g.dataIndex) {
case "username": case "username":
@ -224,26 +266,30 @@ export function renderCols(initialState: any[], type: string, i18n?: AnyObject,
case "originalIncome": case "originalIncome":
col = { col = {
...col, ...col,
render: (text: string) => (<div style={{ color: "rgb(93, 156, 236)" }}>{text}</div>) render: (text: string) => <div style={{ color: "rgb(93, 156, 236)" }}>{text}</div>
}; };
break; break;
case "optimizedTaxTypeDesc": case "optimizedTaxTypeDesc":
case "optimizedBonus": case "optimizedBonus":
case "optimizedTax": case "optimizedTax":
case "optimizedIncome": case "optimizedIncome":
col = { ...col, render: (text: string) => (<Text type="success">{text}</Text>) }; col = { ...col, render: (text: string) => <Text type="success">{text}</Text> };
break; break;
case "companySave": case "companySave":
case "employeeGain": case "employeeGain":
col = { ...col, render: (text: string) => (<Text type="warning">{text}</Text>) }; col = { ...col, render: (text: string) => <Text type="warning">{text}</Text> };
break; break;
default: default:
col = { ...col }; col = { ...col };
break; break;
} }
return col; return col;
}), { }),
dataIndex: "operate", title: i18n?.["操作"], width: 185, fixed: "right", {
dataIndex: "operate",
title: i18n?.["操作"],
width: 185,
fixed: "right",
render: (__: string, record: any) => { render: (__: string, record: any) => {
let items: MenuProps["items"] = [ let items: MenuProps["items"] = [
{ {
@ -260,55 +306,130 @@ export function renderCols(initialState: any[], type: string, i18n?: AnyObject,
selectedKey === "getAnnualbonusaddupList" && items.shift(); selectedKey === "getAnnualbonusaddupList" && items.shift();
return ( return (
<Space> <Space>
{ {!extraParams?.permission ? (
!extraParams?.permission ?
<Space> <Space>
{ {selectedKey === "getAnnualbonusstrategyList" && (
selectedKey === "getAnnualbonusstrategyList" && <Button type="link" onClick={() => postMessageToParent("VIEW", record)}>
<Button type="link" {i18n?.["查看详情"]}
onClick={() => postMessageToParent("VIEW", record)}>{i18n?.["查看详情"]}</Button> </Button>
} )}
<Button type="link" <Button type="link" onClick={() => postMessageToParent("log", record)}>
onClick={() => postMessageToParent("log", record)}>{i18n?.["操作日志"]}</Button> {i18n?.["操作日志"]}
</Space> : </Button>
</Space>
) : (
<> <>
<Button type="link" <Button type="link" onClick={() => postMessageToParent("EDIT", record)}>
onClick={() => postMessageToParent("EDIT", record)}>{i18n?.["编辑"]}</Button> {i18n?.["编辑"]}
{ </Button>
selectedKey === "getAnnualbonusstrategyList" && {selectedKey === "getAnnualbonusstrategyList" && (
<Button type="link" <Button type="link" onClick={() => postMessageToParent("VIEW", record)}>
onClick={() => postMessageToParent("VIEW", record)}>{i18n?.["查看详情"]}</Button> {i18n?.["查看详情"]}
} </Button>
{ )}
selectedKey === "getAnnualbonusaddupList" && {selectedKey === "getAnnualbonusaddupList" && (
<Button type="link" <Button type="link" onClick={() => postMessageToParent("DEL", record)}>
onClick={() => postMessageToParent("DEL", record)}>{i18n?.["删除"]}</Button> {i18n?.["删除"]}
} </Button>
)}
<Dropdown menu={{ items }} placement="bottomRight"> <Dropdown menu={{ items }} placement="bottomRight">
<Button type="link" icon={<MoreOutlined />} /> <Button type="link" icon={<MoreOutlined />} />
</Dropdown> </Dropdown>
</> </>
} )}
</Space> </Space>
); );
} }
}]; }
];
} else if (type === "variableSalary") { } else if (type === "variableSalary") {
return [..._.map(initialState, g => { return [
..._.map(initialState, (g) => {
return { ...g, ellipsis: true, fixed: false, width: 150 }; return { ...g, ellipsis: true, fixed: false, width: 150 };
}), { }),
dataIndex: "operate", title: i18n?.["操作"], width: 185, fixed: "right", {
dataIndex: "operate",
title: i18n?.["操作"],
width: 185,
fixed: "right",
render: (__: string, record: any) => {
return (
<Space>
<Button type="link" onClick={() => postMessageToParent("EDIT", record)}>
{i18n?.["编辑"]}
</Button>
<Button type="link" onClick={() => postMessageToParent("DEL", record)}>
{i18n?.["删除"]}
</Button>
</Space>
);
}
}
];
} else if (type === "dataAcquisition") {
const { isSpecial } = extraParams as { isSpecial: boolean };
return [
..._.map(initialState, (g) => {
let col = { ...g, ellipsis: true, width: 110 };
switch (g.dataIndex) {
case "username":
case "departmentName":
col = { ...col, fixed: true };
break;
case "taxAgentName":
col = { ...col, fixed: true, width: 180 };
break;
case "mobile":
col = { ...col, width: 125 };
break;
case "operate":
col = {
...col,
width: 176,
fixed: "right",
render: (__: string, record: any) => { render: (__: string, record: any) => {
let items: MenuProps["items"] = [
{
key: "DeleteList",
label: i18n?.["删除"],
onClick: () => postMessageToParent("DEL", record)
},
{
key: "Log",
label: i18n?.["操作日志"],
onClick: () => postMessageToParent("log", record)
}
];
isSpecial && items.shift();
return ( return (
<Space> <Space>
<Button type="link" <Button type="link" onClick={() => postMessageToParent("EDIT", record)}>
onClick={() => postMessageToParent("EDIT", record)}>{i18n?.["编辑"]}</Button> {i18n?.["编辑"]}
<Button type="link" </Button>
onClick={() => postMessageToParent("DEL", record)}>{i18n?.["删除"]}</Button> {isSpecial ? (
<Button type="link" onClick={() => postMessageToParent("DEL", record)}>
{i18n?.["删除"]}
</Button>
) : (
<Button type="link" onClick={() => postMessageToParent("VIEW", record)}>
{i18n?.["查看明细"]}
</Button>
)}
<Dropdown menu={{ items }} placement="bottomRight">
<Button type="link" icon={<MoreOutlined />} />
</Dropdown>
</Space> </Space>
); );
} }
}]; };
break;
default:
col = { ...col };
break;
}
return col;
})
];
} }
return initialState; return initialState;
}, [initialState, type, i18n, extraParams]); }, [initialState, type, i18n, extraParams]);

Loading…
Cancel
Save