泛微薪资核算iframe表格

custom-新弘农业/V2-薪资核算表格添加序号列
黎永顺 2 years ago
parent 1f0f016a56
commit b65038b77f

@ -11,6 +11,8 @@ module.exports = {
"/fileTable.*": "blank",
"/rankMapTable.*": "blank",
"/reportTable.*": "blank",
"/commonTable.*": "blank",
"/payrollFilesTable.*": "blank",
"/manage.*": "manage",
"/portal.*": "template",
"/passport/oauth-in": "blank",

@ -0,0 +1,102 @@
import React, { FC, useEffect, useState } from "react";
import { Table, Tag, Typography } from "antd";
import { exceptStr, paginationFun } from "@/utils/common";
import styles from "@/pages/atdTable/components/index.less";
import { defaultPage, IPage } from "@/common/types";
const { Text } = Typography;
const CommonTable: FC = (props) => {
const [columns, setColumns] = useState<Array<any>>([]);
const [sumRow, setSumRow] = useState<Partial<{}>>({});
const [pageInfo, setPageInfo] = useState<IPage>(defaultPage);
const [dataSource, setDataSource] = useState<Array<any>>([]);
const [showSumrow, setShowSumrow] = useState<boolean>(false);
useEffect(() => {
window.parent.postMessage({ type: "init" }, "*");
window.addEventListener("message", receiveMessageFromIndex, false);
return () => {
window.removeEventListener("message", receiveMessageFromIndex, false);
};
}, []);
const receiveMessageFromIndex = (event: any) => {
const data: any = exceptStr(event.data);
if (!_.isEmpty(data)) {
const { columns, dataSource, countResult, showSum, pageInfo } = data;
const { current: pageNum, pageSize: size, total } = pageInfo;
setDataSource(dataSource);
setColumns(_.map(columns, item => {
if (item.dataIndex === "salarySob") {
return {
...item,
render: (text: string, r: { acctTimes?: number }) => {
return <div className={styles.customSpan} title={text}>
<span className={styles.title}>{text}</span>
<Tag color="#4d7ad8">{`${r?.acctTimes}`}</Tag>
</div>;
}
};
}
return { ...item };
}));
setShowSumrow(showSum);
setSumRow(countResult);
setPageInfo({ pageNum, size, total });
}
};
const sizeChange = (pageobj: IPage) => {
};
const onChange = (pageobj: IPage) => {
setPageInfo({ ...pageInfo, ...pageobj });
window.parent.postMessage(
{
type: "turn",
payload: { id: "PAGEINFO", params: { ...pageInfo, ...pageobj } }
},
"*"
);
};
return <Table
rowKey="id"
className={styles.tableWrapper}
columns={columns}
dataSource={dataSource}
bordered
size="small"
scroll={{ x: 1200, y: `calc(100vh - 109px)` }}
pagination={{
...paginationFun(pageInfo, sizeChange, onChange),
size: "default"
}}
summary={() => {
if (!showSumrow) return;
let totalColumns: any[] = [];
_.forEach(columns, it => {
if (!it.children) {
totalColumns.push(it);
} else {
totalColumns = [...totalColumns, ...it.children];
}
});
return (
<Table.Summary fixed>
<Table.Summary.Row>
{
_.map([...totalColumns], (item, index) => {
if (index === 0) {
return <Table.Summary.Cell index={0} key={index}><Text
type="danger"></Text></Table.Summary.Cell>;
}
return <Table.Summary.Cell index={index} key={index}>
<Text type="danger">{!_.isNil(sumRow[item.dataIndex]) ? sumRow[item.dataIndex] : "-"}</Text>
</Table.Summary.Cell>;
})
}
</Table.Summary.Row>
</Table.Summary>
);
}}
/>;
};
export default CommonTable;

@ -0,0 +1,249 @@
import React, { FC, useEffect, useState } from "react";
import { Button, Dropdown, Menu, Space, Spin, Table, Typography } from "antd";
import { DownOutlined } from "@ant-design/icons";
import { exceptStr, paginationFun } from "@/utils/common";
import styles from "@/pages/atdTable/components/index.less";
import { defaultPage, IPage } from "@/common/types";
import cs from "classnames";
const { Text } = Typography;
const payrollFilesTable: FC = (props) => {
const [columns, setColumns] = useState<Array<any>>([]);
const [sumRow, setSumRow] = useState<any>({});
const [pageInfo, setPageInfo] = useState<IPage>(defaultPage);
const [dataSource, setDataSource] = useState<Array<any>>([]);
const [showSumrow, setShowSumrow] = useState<boolean>(false);
const [selected, setSelected] = useState<Array<string>>([]);
useEffect(() => {
window.parent.postMessage({ type: "init" }, "*");
window.addEventListener("message", receiveMessageFromIndex, false);
return () => {
window.removeEventListener("message", receiveMessageFromIndex, false);
};
}, []);
const receiveMessageFromIndex = (event: any) => {
const data: any = exceptStr(event.data);
if (!_.isEmpty(data)) {
const {
columns,
dataSource,
countResult,
showSum,
pageInfo,
showOperateBtn,
selectedKey,
selectedRowKeys
} = data;
const { current: pageNum, pageSize: size, total } = pageInfo;
setDataSource(dataSource);
setColumns(_.map(columns, item => {
if (item.dataIndex === "operate") {
return {
...item,
render: (text: string, r: { id?: string }) => {
let dom = null;
if (!showOperateBtn) {
dom = <Button type="link" style={{ padding: "0" }}
onClick={() => window.parent.postMessage(
{
type: "turn",
payload: { id: "EDIT", params: { record: r } }
},
"*"
)}
>
</Button>;
} else {
if (selectedKey === "pending") {
dom = <Space>
<Button type="link" style={{ padding: "0" }}
onClick={() => window.parent.postMessage(
{
type: "turn",
payload: { id: "EDIT", params: { record: r } }
},
"*"
)}
>
</Button>
<Dropdown
overlay={
<Menu>
<Menu.Item key="payroll">
<Button type="link" style={{ padding: "0", fontSize: 12 }}
onClick={() => handleMenuClick({ key: "payroll" }, r?.id)}
>
</Button>
</Menu.Item>
<Menu.Item key="deletePendingTodo">
<Button type="link" style={{ padding: "0", fontSize: 12 }}
onClick={() => handleMenuClick({ key: "deletePendingTodo" }, r?.id)}>
</Button>
</Menu.Item>
</Menu>
}
>
<a><DownOutlined/></a>
</Dropdown>
</Space>;
} else if (selectedKey === "fixed") {
dom = <Button type="link" style={{ padding: "0" }} onClick={() => window.parent.postMessage(
{
type: "turn",
payload: { id: "EDIT", params: { record: r } }
},
"*"
)}>
</Button>;
} else if (selectedKey === "suspend") {
dom = <Space>
<Button type="link" style={{ padding: "0" }} onClick={() => window.parent.postMessage(
{
type: "turn",
payload: { id: "EDIT", params: { record: r } }
},
"*"
)}>
</Button>
<Dropdown
overlay={
<Menu>
<Menu.Item key="payroll">
<Button type="link" style={{ padding: "0", fontSize: 12 }}
onClick={() => handleMenuClick({ key: "stopSalary" }, r?.id)}
>
</Button>
</Menu.Item>
<Menu.Item key="deletePendingTodo">
<Button type="link" style={{ padding: "0", fontSize: 12 }}
onClick={() => handleMenuClick({ key: "deleteSuspendTodo" }, r?.id)}>
</Button>
</Menu.Item>
</Menu>
}
>
<a><DownOutlined/></a>
</Dropdown>
</Space>;
} else {
dom = <Space>
<Button type="link" style={{ padding: "0" }} onClick={() => window.parent.postMessage(
{
type: "turn",
payload: { id: "CANCELSTOP", params: { id: r?.id } }
},
"*"
)}>
</Button>
<Button type="link" style={{ padding: "0" }}
onClick={() => handleMenuClick({ key: "view" }, r as string)}>
</Button>
</Space>;
}
}
return dom;
}
};
}
return { ...item };
}));
setShowSumrow(showSum);
setSumRow(_.isEmpty(countResult) ? { [new Date().getTime()]: new Date().getTime() } : countResult);
setPageInfo({ pageNum, size, total });
setSelected(selectedRowKeys);
}
};
const handleMenuClick = (event: any, id?: string) => {
window.parent.postMessage(
{
type: "turn",
payload: { id: "MOREOPT", params: { id, event } }
},
"*"
);
};
const sizeChange = (pageobj: IPage) => {
};
const onChange = (pageobj: IPage) => {
setPageInfo({ ...pageInfo, ...pageobj });
window.parent.postMessage(
{
type: "turn",
payload: { id: "PAGEINFO", params: { ...pageInfo, ...pageobj } }
},
"*"
);
};
const rowSelection = {
selectedRowKeys: selected,
onChange: (selectedRowKeys: Array<any>) => {
setSelected(selectedRowKeys);
window.parent.postMessage(
{
type: "turn",
payload: { id: "ROWSELECTION", params: { selectedRowKeys } }
},
"*"
);
}
};
return <Table
rowKey="id"
className={cs({
[styles.tableWrapper]: true,
[styles.tableTotalWrapper]: true
})}
columns={columns}
dataSource={dataSource}
size="small"
rowSelection={rowSelection}
scroll={{ x: 1200, y: !showSumrow ? `calc(100vh - 100px)` : "calc(100vh - 129px)" }}
pagination={{
...paginationFun(pageInfo, sizeChange, onChange),
size: "default"
}}
summary={() => {
if (!showSumrow) return;
let totalColumns: any[] = [];
_.forEach(columns, it => {
if (!it.children) {
totalColumns.push(it);
} else {
totalColumns = [...totalColumns, ...it.children];
}
});
return (
<Table.Summary fixed>
<Table.Summary.Row>
{
sumRow.loading ? <Spin tip="加载中"/> :
_.map([...totalColumns], (item, index) => {
if (index === 0) {
return <Table.Summary.Cell index={0} key={index} colSpan={2}><Text
type="danger"></Text></Table.Summary.Cell>;
}
return <Table.Summary.Cell index={index} key={index}>
<Text type="danger">{!_.isNil(sumRow[item.dataIndex]) ? sumRow[item.dataIndex] : "-"}</Text>
</Table.Summary.Cell>;
})
}
</Table.Summary.Row>
</Table.Summary>
);
}}
/>;
};
export default payrollFilesTable;

@ -4,7 +4,7 @@ import { exceptStr } from "@/utils/common";
import styles from "@/pages/atdTable/components/index.less";
const { Text } = Typography;
const PreviewTable: FC = (props) => {
const ReportTable: FC = (props) => {
const [columns, setColumns] = useState<Array<any>>([]);
const [sumRow, setSumRow] = useState<Partial<{}>>({});
const [dataSource, setDataSource] = useState<Array<any>>([]);
@ -67,4 +67,4 @@ const PreviewTable: FC = (props) => {
/>;
};
export default PreviewTable;
export default ReportTable;

@ -23,7 +23,6 @@ const StandingbookTable: FC = (props) => {
}, []);
const receiveMessageFromIndex = async (event: any) => {
const data: any = exceptStr(event.data);
console.log("antd4", data);
if (!_.isEmpty(data)) {
const {
columns, dataSource, pageInfo, showOperates, selectedRowKeys,

Loading…
Cancel
Save