Merge branch 'master' into feature/低版本火狐浏览器

feature/低版本火狐浏览器
黎永顺 1 year ago
commit 0f97ae555b

@ -54,6 +54,12 @@
<div class="content unicode" style="display: block;">
<ul class="icon_lists dib-box">
<li class="dib">
<span class="icon iconfont">&#xe696;</span>
<div class="name">批量更新</div>
<div class="code-name">&amp;#xe696;</div>
</li>
<li class="dib">
<span class="icon iconfont">&#xe603;</span>
<div class="name">全部</div>
@ -138,9 +144,9 @@
<pre><code class="language-css"
>@font-face {
font-family: 'iconfont';
src: url('iconfont.woff2?t=1698914262517') format('woff2'),
url('iconfont.woff?t=1698914262517') format('woff'),
url('iconfont.ttf?t=1698914262517') format('truetype');
src: url('iconfont.woff2?t=1701833672416') format('woff2'),
url('iconfont.woff?t=1701833672416') format('woff'),
url('iconfont.ttf?t=1701833672416') format('truetype');
}
</code></pre>
<h3 id="-iconfont-">第二步:定义使用 iconfont 的样式</h3>
@ -166,6 +172,15 @@
<div class="content font-class">
<ul class="icon_lists dib-box">
<li class="dib">
<span class="icon iconfont icon-pilianggengxin"></span>
<div class="name">
批量更新
</div>
<div class="code-name">.icon-pilianggengxin
</div>
</li>
<li class="dib">
<span class="icon iconfont icon-quanbu"></span>
<div class="name">
@ -292,6 +307,14 @@
<div class="content symbol">
<ul class="icon_lists dib-box">
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-pilianggengxin"></use>
</svg>
<div class="name">批量更新</div>
<div class="code-name">#icon-pilianggengxin</div>
</li>
<li class="dib">
<svg class="icon svg-icon" aria-hidden="true">
<use xlink:href="#icon-quanbu"></use>

@ -1,8 +1,8 @@
@font-face {
font-family: "iconfont"; /* Project id 4257468 */
src: url('iconfont.woff2?t=1698914262517') format('woff2'),
url('iconfont.woff?t=1698914262517') format('woff'),
url('iconfont.ttf?t=1698914262517') format('truetype');
src: url('iconfont.woff2?t=1701833672416') format('woff2'),
url('iconfont.woff?t=1701833672416') format('woff'),
url('iconfont.ttf?t=1701833672416') format('truetype');
}
.iconfont {
@ -13,6 +13,10 @@
-moz-osx-font-smoothing: grayscale;
}
.icon-pilianggengxin:before {
content: "\e696";
}
.icon-quanbu:before {
content: "\e603";
}

File diff suppressed because one or more lines are too long

@ -5,6 +5,13 @@
"css_prefix_text": "icon-",
"description": "",
"glyphs": [
{
"icon_id": "2442443",
"name": "批量更新",
"font_class": "pilianggengxin",
"unicode": "e696",
"unicode_decimal": 59030
},
{
"icon_id": "5925304",
"name": "全部",

Binary file not shown.

Binary file not shown.

@ -73,9 +73,7 @@ class CalculateService extends BasicService {
return this.post(`/api/bs/hrmsalary/salaryacct/acctresult/sum`, queryParams);
};
//合计行
getAcctResultsum = async (params: any) => {
return this.post(`/api/bs/hrmsalary/salaryacct/acctresult/sum`, params);
};
getAcctResultsum = async (url: string, params: any) => (this.post(url, params));
//社保合计行
getSyMixSum = async (params: any) => {
return this.post(`/api/bs/hrmsalary/siaccount/detail/list/syMixSum`, params);

@ -16,7 +16,10 @@ module.exports = {
"/welfareLedgerTable.*": "blank",
"/payrollFilesTable.*": "blank",
"/employeeDeclareTable.*": "blank",
"/taxDeclareTable.*": "blank",
"/welfareArchiveTable.*": "blank",
"/salaryFileTable.*": "blank",
"/OCTable.*": "blank",
"/manage.*": "manage",
"/portal.*": "template",
"/passport/oauth-in": "blank",

@ -0,0 +1,115 @@
/*
* Author:
* name: -线
* Description:
* Date: 2023/11/28
*/
import React, { FC, useEffect, useState } from "react";
import { Table } from "antd";
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 OCTable: FC = (props) => {
const [columns, setColumns] = useState<Array<any>>([]);
const [pageInfo, setPageInfo] = useState<IPage>(defaultPage);
const [dataSource, setDataSource] = useState<Array<any>>([]);
const [i18n, setI18n] = useState<any>({});
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, pageInfo, i18n: i18nRes = {} } = data;
const { current: pageNum, pageSize: size, total } = pageInfo;
setDataSource(dataSource);
setI18n(i18nRes);
setPageInfo({ pageNum, size, total });
setColumns(convertColumns(columns, i18nRes));
}
};
const convertColumns: any = (cols: any[], lanObj: any) => {
return _.map(cols, item => {
if (_.isNaN(parseInt(item.dataIndex))) {
return { ...item };
} else {
return {
...item, children: convertColumns(item.children, lanObj),
render: (__: any, record: any) => {
const formulaDesc = record["customParameters"][`${item["dataIndex"]}`];
const showDifference = record[`${item["dataIndex"]}_type`] === "number";
const { acctResultValue, excelResultValue } = record[item["dataIndex"]] || {};
return <div className={styles["comparison-column-item-container"]}
onClick={() => {
window.parent.postMessage(
{
type: "turn",
payload: { id: "FORMULA", params: { formulaDesc } }
},
"*"
);
}}>
<div className={styles["comparison-single-row"]}>
<span>{lanObj["系统值"]}</span>
<span>{acctResultValue}</span>
</div>
<div className={styles["comparison-single-row"]}>
<span>{lanObj["线下值"]}</span>
<span>{excelResultValue}</span>
</div>
{
showDifference &&
<div className={cs(styles["danger"], styles["comparison-single-row"])}>
<span>{lanObj["差值"]}</span>
<span>{calculateDifference(acctResultValue, excelResultValue)}</span>
</div>
}
</div>;
}
};
}
});
};
// 计算差值
const calculateDifference = (systemValue: string, excelValue: string) => {
if (_.isNil(systemValue) || _.isNil(excelValue)) return "";
const systemNum = Number(systemValue);
const excelNum = Number(excelValue);
return (systemNum - excelNum).toFixed(2);
};
const sizeChange = (pageobj: IPage) => {
};
const onChange = (pageobj: IPage) => {
const { pageNum, size: pageSize } = pageobj;
setPageInfo((prevState) => {
const { size } = prevState;
window.parent.postMessage(
{
type: "turn",
payload: { id: "PAGEINFO", params: { ...pageInfo, pageNum: size === pageSize ? pageNum : 1, size: pageSize } }
},
"*"
);
return { ...pageInfo, current: size === pageSize ? pageNum : 1, size: pageSize };
});
};
return <Table
rowKey="id" className={styles.tableWrapper}
columns={columns} dataSource={dataSource} bordered size="small"
scroll={{ x: 1200, y: `calc(100vh - 137px)` }}
pagination={{
...paginationFun(pageInfo, sizeChange, onChange, i18n),
size: "default"
}}
/>;
};
export default OCTable;

@ -86,7 +86,7 @@
.expand-th:hover {
.toogle-lock-tool {
width: 30%;
display: flex;
}
}
@ -102,23 +102,21 @@
height: 100%;
.title-text {
width: 90%;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1 1;
cursor: pointer;
}
.toogle-lock-tool {
display: flex;
width: 0;
display: none;
overflow: hidden;
height: 100%;
justify-content: center;
align-items: center;
& > :first-child {
& > :not(:last-child) {
margin-right: 4px;
}
@ -153,6 +151,24 @@
}
}
.comparison-column-item-container {
cursor: pointer;
.comparison-single-row {
margin: 4px 0;
}
.danger {
color: #ff4d4f;
}
}
tr:hover .editable-cell {
padding: 4px 11px;
border: 1px solid #d9d9d9;
border-radius: 2px;
}
:global {
.ant-btn-link {
height: inherit !important;
@ -248,7 +264,15 @@
}
th, td {
font-size: 12px
font-size: 12px;
.ant-form-item {
margin-bottom: 0;
.ant-input-number {
width: 100%;
}
}
}
}
}

@ -29,6 +29,10 @@ const CalcExplainFooter: FunctionComponent<Props> = (props) => {
<UnlockOutlined/>
<span>{i18n["当前状态未锁定,点击锁定"]}</span>
</div>
<div className={styles["icon-item"]}>
<Icon type="icon-pilianggengxin"/>
<span>{i18n["批量更新"]}</span>
</div>
</div>
);
};

@ -15,6 +15,7 @@ interface OwnProps {
columns: ColumnType<any>[];
dataSourceUrl: string;
payload: any;
sumRow: Partial<{}>;
}
type Props = OwnProps;
@ -34,22 +35,24 @@ const calcFixedTotal: FunctionComponent<Props> = (props) => {
return !_.isEmpty(props.columns) ? flattenFn(props.columns) : [];
}, [props.columns]);
const dataSourceUrl = useCallback((payload) => {
return API.CalculateService.getAcctResultsum(payload);
return API.CalculateService.getAcctResultsum(props.dataSourceUrl, payload);
}, [props.dataSourceUrl]);
useEffect(() => {
if (!_.isEmpty(props.payload)) {
if (!_.isEmpty(props.payload) && !props.sumRow) {
setLoading(true);
dataSourceUrl(props.payload).then(({ data }) => {
setLoading(false);
const { data: result, status } = data;
if (status) setSumRow(result.sumRow || {});
});
} else {
setSumRow(props.sumRow);
}
}, [props.payload]);
}, [props.payload, props.sumRow]);
return (<>
{
_.map(columns, (item: any, index) => {
return <Table.Summary.Cell index={index + 1} key={index + 1}>
return <Table.Summary.Cell index={index + 1} key={index + 1} align="center">
{
loading ? <Spin spinning={loading} size="small"></Spin> :
<Text type="danger">{sumRow[item.dataIndex] || "-"}</Text>

@ -13,20 +13,23 @@ interface OwnProps {
dataIndex?: string;
title?: string;
lockStatus?: string;
dataType?: string;
onHandleFormulatd?: any;
i18n?: any;
pattern?: number;
calcDetail?: boolean; //查看详情页面
}
type Props = OwnProps;
const customTableTitle: FunctionComponent<Props> = (props) => {
const { dataIndex, title, lockStatus, onHandleFormulatd, i18n = {} } = props;
const { dataIndex, title, lockStatus, onHandleFormulatd, i18n = {}, pattern, dataType, calcDetail } = props;
const handleToggleSalaryItemVal = (salaryItemId: string, type: string) => {
const handleToggleSalaryItemVal = (salaryItemId: string, type: string, updateParams: any = {}) => {
window.parent.postMessage(
{
type: "turn",
payload: { id: "LOCKING", params: { lockType: type, salaryItemId } }
payload: { id: "LOCKING", params: { lockType: type, salaryItemId, ...updateParams } }
},
"*"
);
@ -36,12 +39,16 @@ const customTableTitle: FunctionComponent<Props> = (props) => {
<div className={classnames(styles["expand-th"])}>
<div className={styles["title-text"]} title={title} onClick={() => onHandleFormulatd(dataIndex)}>{title}</div>
{
!!lockStatus &&
!!lockStatus && !calcDetail &&
<div className={styles["toogle-lock-tool"]}>
<Icon type="icon-piliangsuoding" title={i18n["点击锁定所有解锁的项目值"]}
onClick={() => handleToggleSalaryItemVal(dataIndex as string, "LOCK")}/>
<Icon type="icon-piliangjiesuo" title={i18n["点击解锁所有锁定的项目值"]}
onClick={() => handleToggleSalaryItemVal(dataIndex as string, "UNLOCK")}/>
<Icon type="icon-pilianggengxin" title={i18n["批量更新"]}
onClick={() => handleToggleSalaryItemVal(dataIndex as string, "BATCHUPDATE", {
pattern, salaryItemName: title, dataType
})}/>
</div>
}
</div>

@ -20,6 +20,7 @@ interface OwnProps {
}
type Props = OwnProps;
type fixedProps = boolean | "top" | "bottom";
const { Text } = Typography;
const index: FunctionComponent<Props> = (props) => {
@ -29,8 +30,12 @@ const index: FunctionComponent<Props> = (props) => {
const [pageInfo, setPageInfo] = useState<Partial<PaginationData>>({});
const [i18n, setI18n] = useState<any>({});
const [showTotalCell, setShowTotalCell] = useState<boolean>(false);
const [isDetailTable, setIsDetailTable] = useState<boolean>(false);
const [sumRowlistUrl, setSumRowlistUrl] = useState<string>("");
const [tableScrollHeight, setTableScrollHeight] = useState<Number>(0);
const [payload, setPayload] = useState<string>("");
const [fixed, setFixed] = useState<fixedProps>(true);
const [sumRow, setSumRow] = useState<Partial<{}>>({});//总计行数据
useEffect(() => {
window.parent.postMessage({ type: "init" }, "*");
@ -44,15 +49,20 @@ const index: FunctionComponent<Props> = (props) => {
if (!_.isEmpty(data)) {
const {
columns, dataSource, pageInfo, selectedRowKeys, i18n: i18nRes = {},
showTotalCell = false, sumRowlistUrl = "", payload = {}
showTotalCell = false, sumRowlistUrl = "", payload = {}, calcDetail,
fixed = true, tableScrollHeight, sumRow
} = data;
setSumRowlistUrl(sumRowlistUrl);
setShowTotalCell(showTotalCell);
setIsDetailTable(calcDetail);
setI18n(i18nRes);
setPayload(payload);
setFixed(fixed);
setSumRow(sumRow);
setPageInfo(pageInfo);
setDataSource(dataSource);
setSelectedRowKeys(selectedRowKeys);
setTableScrollHeight(tableScrollHeight);
setColumns([...convertColumns(_.map(columns, o => ({ ...o, i18n: i18nRes }))), {
title: i18nRes["操作"], dataIndex: "operate", fixed: "right", width: 120,
render: (__, record) => (<Button type="link" onClick={() => handleEdit(record?.id)}>{i18nRes["编辑"]}</Button>)
@ -113,7 +123,9 @@ const index: FunctionComponent<Props> = (props) => {
});
};
const rowSelection = {
columnWidth: 60,
columnWidth: 60, hideSelectAll: isDetailTable,
renderCell: (value: boolean, record: any, index: number, originNode: React.ReactNode) => (isDetailTable ?
<span>{index + 1}</span> : originNode),
selectedRowKeys: selectedRowKeys,
onChange: (selectedRowKeys: React.Key[]) => {
setSelectedRowKeys(selectedRowKeys);
@ -128,19 +140,20 @@ const index: FunctionComponent<Props> = (props) => {
};
return (<Table
rowKey="id" size="small" bordered className={styles.tableWrapper}
columns={columns} dataSource={dataSource} rowSelection={rowSelection}
scroll={{ x: 1200, y: `calc(100vh - ${!showTotalCell ? 165 : 200}px)` }}
footer={() => <CalcExplainFooter i18n={i18n}/>}
pagination={{
dataSource={dataSource} rowSelection={rowSelection}
scroll={{ x: 1200, y: `calc(100vh - ${tableScrollHeight || (!showTotalCell ? 165 : 200)}px)` }}
columns={!isDetailTable ? columns : _.filter(columns, o => o.dataIndex !== "operate")}
footer={() => !isDetailTable ? <CalcExplainFooter i18n={i18n}/> : null}
pagination={!_.isNil(pageInfo) ? {
...paginationFun(pageInfo, sizeChange, onChange, i18n),
size: "default"
}}
} : false}
summary={() => (
!showTotalCell ? <></> :
<Table.Summary fixed>
<Table.Summary fixed={fixed}>
<Table.Summary.Row>
<Table.Summary.Cell index={0} align="center"><Text type="danger">{i18n["总计"]}</Text></Table.Summary.Cell>
<CaclFixedTotal columns={columns} dataSourceUrl={sumRowlistUrl} payload={payload}/>
<CaclFixedTotal columns={columns} dataSourceUrl={sumRowlistUrl} payload={payload} sumRow={sumRow}/>
</Table.Summary.Row>
</Table.Summary>
)}

@ -26,15 +26,15 @@ const ReportTable: FC = (props) => {
setSumRow(countResult);
setColumns(_.map(columns, (item, index: number) => {
if (index === 0) {
return { ...item, fixed: "left" };
return { ...item, fixed: "left", ellipsis: true };
}
return {
...item,
children: _.map(item.children, child => {
return {
...child,
...child, ellipsis: true,
render: (text: string, record: any) => {
return <Button type="link" onClick={() => {
return <Button type="link" block onClick={() => {
window.parent.postMessage(
{
type: "turn",

@ -0,0 +1,204 @@
/*
* Author:
* name: -
* Description:
* Date: 2024/1/8
*/
import React, { FunctionComponent, useEffect, useMemo, useState } from "react";
import { ColumnType } from "antd/lib/table";
import { PaginationData } from "rc-pagination";
import styles from "@/pages/atdTable/components/index.less";
import { exceptStr, paginationAction } from "@/utils/common";
import { Button, Dropdown, MenuProps, Space, Table } from "antd";
import { MoreOutlined } from "@ant-design/icons";
interface OwnProps {
}
type Props = OwnProps;
const Index: FunctionComponent<Props> = (props) => {
const [columns, setColumns] = useState<ColumnType<any>[]>([]);
const [dataSource, setDataSource] = useState<any[]>([]);
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
const [pageInfo, setPageInfo] = useState<Partial<PaginationData>>({});
const [i18n, setI18n] = useState<any>({});
const [runStatuses, setRunStatuses] = useState<string>("");
const [showOperateBtn, setShowOperateBtn] = useState<boolean>(false);
const [showDelSalaryFileBtn, setShowDelSalaryFileBtn] = 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, pageInfo, selectedRowKeys, i18n: i18nRes = {},
selectedKey, showOperateBtn, showDelSalaryFileBtn
} = data;
setShowOperateBtn(showOperateBtn);
setRunStatuses(selectedKey);
setI18n(i18nRes);
setPageInfo(pageInfo);
setDataSource(dataSource);
setSelectedRowKeys(selectedRowKeys);
setColumns(columns);
setShowDelSalaryFileBtn(showDelSalaryFileBtn);
}
};
const onChange = (current: number, pageSize: number) => {
setPageInfo((prevState) => {
const { pageSize: size } = prevState;
window.parent.postMessage(
{
type: "turn",
payload: { id: "PAGEINFO", params: { ...pageInfo, current: size === pageSize ? current : 1, pageSize } }
},
"*"
);
return { ...pageInfo, current: size === pageSize ? current : 1, pageSize };
});
};
const rowSelection = {
columnWidth: 60,
selectedRowKeys: selectedRowKeys,
onChange: (selectedRowKeys: React.Key[]) => {
setSelectedRowKeys(selectedRowKeys);
window.parent.postMessage(
{
type: "turn",
payload: { id: "ROWSELECTION", params: { selectedRowKeys } }
},
"*"
);
}
};
const handleSalaryFileOperate = (type: string, record: any, interfaceParams?: any) => {
window.parent.postMessage(
{
type: "turn",
payload: { id: type, params: { record, interfaceParams } }
},
"*"
);
};
const cols: any = useMemo(() => {
if (!_.isEmpty(columns)) {
let opts: any = _.find(columns, o => o.dataIndex === "operate");
switch (runStatuses) {
case "pending":
opts = {
...opts,
render: (__: any, record: any) => {
let items: MenuProps["items"] = [
{
key: "DeleteTodoList",
label: i18n["删除待办"],
onClick: () => handleSalaryFileOperate("DEL-PENDITNG-TO-DO", record, [record?.id])
},
{
key: "DeleteFiles",
label: i18n["删除档案"],
onClick: () => handleSalaryFileOperate("DEL-SALARY-FILES", record, [record?.id])
}
];
!showDelSalaryFileBtn && (items = _.dropRight(items));
return (<Space>
<Button type="link" onClick={() => handleSalaryFileOperate("EDIT", record)}>{i18n["编辑"]}</Button>
<Button type="link"
onClick={() => handleSalaryFileOperate("ADD-TO-SALARYPAYMENT", record, [record?.id])}>{i18n["设为发薪人员"]}</Button>
<Dropdown menu={{ items }} placement="bottomRight">
<Button type="link" icon={<MoreOutlined/>}/>
</Dropdown>
</Space>);
}
};
break;
case "fixed":
case "ext":
opts = {
...opts,
render: (__: any, record: any) => (
<Button type="link"
onClick={() => handleSalaryFileOperate("CHANGE-SALARY", record)}>{i18n["调薪"]}</Button>)
};
break;
case "suspend":
opts = {
...opts,
render: (__: any, record: any) => {
const downsizingItems: MenuProps["items"] = [
{
key: "DeleteTodoList",
label: i18n["删除待办"],
onClick: () => handleSalaryFileOperate("DEL-SUSPEND-TO-DO", record, [record?.id])
}
];
return (<Space>
<Button type="link" onClick={() => handleSalaryFileOperate("EDIT", record)}>{i18n["编辑"]}</Button>
<Button type="link"
onClick={() => handleSalaryFileOperate("SALARY-SUSPENSION", record, [record?.id])}>{i18n["停薪"]}</Button>
<Dropdown menu={{ items: downsizingItems }} placement="bottomRight">
<Button type="link" icon={<MoreOutlined/>}/>
</Dropdown>
</Space>);
}
};
break;
case "stop":
opts = {
...opts,
render: (__: any, record: any) => {
let stopItems: MenuProps["items"] = [
{
key: "CancelSuspension",
label: i18n["删除档案"],
onClick: () => handleSalaryFileOperate("DEL-SALARY-FILES", record, [record?.id])
}
];
!showDelSalaryFileBtn && (stopItems = _.dropRight(stopItems));
return (<Space>
<Button type="link" onClick={() => handleSalaryFileOperate("VIEW", record)}>{i18n["查看"]}</Button>
<Button type="link"
onClick={() => handleSalaryFileOperate("CANCEL-SALARY-SUSPENSION", record, [record?.id])}>{i18n["取消停薪"]}</Button>
{
!_.isEmpty(stopItems) &&
<Dropdown menu={{ items: stopItems }} placement="bottomRight">
<Button type="link" icon={<MoreOutlined/>}/>
</Dropdown>
}
</Space>);
}
};
break;
default:
break;
}
return showOperateBtn ? [..._.filter(columns, o => o.dataIndex !== "operate"), opts] :
[..._.filter(columns, o => o.dataIndex !== "operate"), {
...opts,
render: (__: any, record: any) => (
<Button type="link" onClick={() => handleSalaryFileOperate("VIEW", record)}>{i18n["查看"]}</Button>)
}];
} else {
return [];
}
}, [columns, runStatuses, i18n, showOperateBtn, showDelSalaryFileBtn]);
return (<Table
rowKey="id" size="small" className={styles.tableWrapper}
columns={cols} dataSource={dataSource} rowSelection={rowSelection}
scroll={{ x: 1200, y: `calc(100vh - 103px)` }}
pagination={{
...paginationAction(pageInfo, i18n, onChange),
size: "default"
}}
/>);
};
export default Index;

@ -0,0 +1,80 @@
/*
* Author:
* name: -
* Description:
* Date: 2023/12/27
*/
import React, { FC, useEffect, useState } from "react";
import { Button, Space, Table } from "antd";
import { exceptStr, paginationAction } from "@/utils/common";
import styles from "@/pages/atdTable/components/index.less";
import { PaginationData } from "rc-pagination";
const TaxDeclareTable: FC = (props) => {
const [pageInfo, setPageInfo] = useState<Partial<PaginationData>>({});
const [columns, setColumns] = useState<Array<any>>([]);
const [dataSource, setDataSource] = useState<Array<any>>([]);
const [i18n, setI18n] = useState<Partial<{}>>({});
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, pageInfo, i18n, declareStatus } = data;
setDataSource(dataSource);
setI18n(i18n);
setPageInfo(pageInfo);
setColumns(["NOT_DECLARE", "DECLARE_FAIL"].includes(declareStatus) ? [
...columns,
{
title: i18n["操作"],
dataIndex: "operate",
fixed: "right",
width: 120,
render: (_: any, record: any) => (
<Space>
<Button type="link" onClick={() => handleEdit(record)}>{i18n["编辑"]}</Button>
{/*<Button type="link" onClick={() => handleDelete(record)}>{i18n["删除"]}</Button>*/}
</Space>
)
}
] : columns);
}
};
const handleEdit = (record: any) => {
window.parent.postMessage({ type: "turn", payload: { id: "EDIT", params: { ...record } } }, "*");
};
const handleDelete = (record: any) => {
window.parent.postMessage({ type: "turn", payload: { id: "DELETE", params: { ...record } } }, "*");
};
const onChange = (current: number, pageSize: number) => {
setPageInfo((prevState) => {
const { pageSize: size } = prevState;
window.parent.postMessage(
{
type: "turn",
payload: { id: "PAGEINFO", params: { ...pageInfo, current: size === pageSize ? current : 1, pageSize } }
},
"*"
);
return { ...pageInfo, current: size === pageSize ? current : 1, pageSize };
});
};
return <Table
rowKey="id" className={styles.tableWrapper} size="small"
columns={columns} dataSource={dataSource} bordered
scroll={{ x: 1200, y: `calc(100vh - 100px)` }}
pagination={{
...paginationAction(pageInfo, i18n, onChange),
size: "default"
}}
/>;
};
export default TaxDeclareTable;

@ -110,3 +110,16 @@ export const paginationAction = (pageInfo = {}, i18n = {}, onChange, onShowSizeC
showSizeChanger: true
};
};
/*
* Author: 黎永顺
* Description:
* Params: 格式化钱
* Date: 2023/12/6
*/
export const toDecimal_n = (num, decimalPlaces) => {
if (num === null || !isFinite(num)) return null
if (decimalPlaces < 0) return null;
const multiplier = Math.pow(10, decimalPlaces);
const roundedNum = Math.round(num * multiplier) / multiplier;
return roundedNum.toFixed(decimalPlaces);
};

Loading…
Cancel
Save