diff --git a/src/layouts/config.js b/src/layouts/config.js index 2ba0867..5b47ec1 100644 --- a/src/layouts/config.js +++ b/src/layouts/config.js @@ -13,6 +13,7 @@ module.exports = { "/reportTable.*": "blank", "/commonTable.*": "blank", "/payrollFilesTable.*": "blank", + "/employeeDeclareTable.*": "blank", "/manage.*": "manage", "/portal.*": "template", "/passport/oauth-in": "blank", diff --git a/src/pages/atdTable/components/index.less b/src/pages/atdTable/components/index.less index 184ec20..4703822 100644 --- a/src/pages/atdTable/components/index.less +++ b/src/pages/atdTable/components/index.less @@ -79,6 +79,7 @@ :global { .ant-btn-link, .ant-dropdown-trigger { + padding: 0; font-size: 12px; color: #333; } diff --git a/src/pages/employeeDeclareTable/index.tsx b/src/pages/employeeDeclareTable/index.tsx new file mode 100644 index 0000000..5c41423 --- /dev/null +++ b/src/pages/employeeDeclareTable/index.tsx @@ -0,0 +1,112 @@ +import React, { FC, useEffect, useState } from "react"; +import { Button, Space, Table, Tooltip, Typography } from "antd"; +import { ExclamationCircleFilled } from "@ant-design/icons"; +import { exceptStr, paginationFun } from "@/utils/common"; +import { defaultPage, IPage } from "@/common/types"; +import styles from "@/pages/atdTable/components/index.less"; + +const { Text } = Typography; +const CommonTable: FC = (props) => { + const [pageInfo, setPageInfo] = useState(defaultPage); + const [columns, setColumns] = useState>([]); + const [dataSource, setDataSource] = useState>([]); + const [selected, setSelected] = useState>([]); + const [i18n, setI18n] = useState>({}); + + 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, selectedRowKeys } = data; + const { current: pageNum, pageSize: size, total } = pageInfo; + setDataSource(dataSource); + setI18n(i18n); + setPageInfo({ pageNum, size, total }); + setSelected(selectedRowKeys); + setColumns([ + ...columns, + { + title: i18n["操作"], + dataIndex: "operate", + fixed: "right", + width: 120, + render: (_: any, record: any) => { + return ( + + + + + ); + } + } + ]); + } + }; + 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 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, + columnWidth: 80, + onChange: (selectedRowKeys: Array) => { + setSelected(selectedRowKeys); + window.parent.postMessage( + { + type: "turn", + payload: { id: "ROWSELECT", params: { selectedRowKeys } } + }, + "*" + ); + } + }; + return { + if (it.dataIndex === "declareStatusDesc") { + return { + ...it, + render: (text: string, record: any) => ( + + + + + ) + }; + } + return { ...it }; + })} + dataSource={dataSource} + bordered + size="small" + scroll={{ x: 1200, y: `calc(100vh - 85px)` }} + pagination={{ + ...paginationFun(pageInfo, sizeChange, onChange, i18n), + size: "default" + }} + />; +}; + +export default CommonTable; diff --git a/src/utils/common.js b/src/utils/common.js index be7dc7c..891bb42 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -70,12 +70,12 @@ export const exceptStr = (str) => { } }; -export const paginationFun = (tableListPageObj, sizeChange, onChange) => { +export const paginationFun = (tableListPageObj, sizeChange, onChange, i18n = {}) => { return { current: tableListPageObj.pageNum, pageSize: tableListPageObj.size, total: tableListPageObj.total, - showTotal: (total) => `共 ${total} 条`, + showTotal: total => `${i18n["共"] ? i18n["共"] : "共"} ${total} ${i18n["条"] ? i18n["条"] : "条"}`, showQuickJumper: true, showSizeChanger: true, pageSizeOptions: ["10", "20", "50", "100"],