From 52686f838ff01eac0bb745aca514f23a0ba8a2f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Fri, 31 Mar 2023 09:50:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=9B=E5=BE=AE=E8=96=AA=E8=B5=84=E6=A0=B8?= =?UTF-8?q?=E7=AE=97iframe=E8=A1=A8=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/config.js | 1 + src/pages/atdTable/components/index.less | 44 +++++- src/pages/fileTable/index.tsx | 187 +++++++++++++++++++++++ 3 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 src/pages/fileTable/index.tsx diff --git a/src/layouts/config.js b/src/layouts/config.js index 52c0001..e9b21a0 100644 --- a/src/layouts/config.js +++ b/src/layouts/config.js @@ -8,6 +8,7 @@ module.exports = { '/atdTable.*': 'blank', '/previewTable.*': 'blank', '/standingbookTable.*': 'blank', + '/fileTable.*': '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 010a04f..596586c 100644 --- a/src/pages/atdTable/components/index.less +++ b/src/pages/atdTable/components/index.less @@ -50,16 +50,26 @@ } } + .optWrapper { + .mr10 { + margin-right: 10px; + } + } + :global { .ant-table-tbody > tr.ant-table-row:hover > td { background: #e9f7ff; } - + .anticon-more{ + font-size: 16px; + cursor: pointer; + } .ant-spin-container { .ant-pagination { font-size: 12px; align-items: center; margin-right: 8px; + .ant-pagination-item, .ant-pagination-prev, .ant-pagination-next { min-width: 28px; height: 28px; @@ -78,6 +88,15 @@ .ant-select-selector { height: 28px; border-radius: 6px; + + .ant-select-selection-search-input { + height: 26px; + line-height: 26px; + } + + .ant-select-selection-item { + line-height: 26px; + } } .ant-select-item { @@ -107,3 +126,26 @@ } } } + +.moreIconWrapper { + :global { + .ant-popover-inner { + min-width: 106px + } + + .ant-popover-inner-content { + padding: 0; + + .ant-menu { + .ant-menu-item { + border-right: none; + height: 30px; + line-height: 30px; + text-align: center; + padding: 0; + font-size: 12px; + } + } + } + } +} diff --git a/src/pages/fileTable/index.tsx b/src/pages/fileTable/index.tsx new file mode 100644 index 0000000..5261571 --- /dev/null +++ b/src/pages/fileTable/index.tsx @@ -0,0 +1,187 @@ +import React, { FC, useEffect, useState } from "react"; +import { exceptStr, paginationFun } from "@/utils/common"; +import { defaultPage, ILoading, IPage } from "@/common/types/page"; +import { Menu, Popover, Table, Typography } from "antd"; +import { MoreOutlined } from "@ant-design/icons"; +import styles from "@/pages/atdTable/components/index.less"; + +const { Text } = Typography; + +interface ITableProps { +} + +const FileTable: FC = (props) => { + const [selected, setSelected] = useState>([]); //列表选中的数据 + const [pageInfo, setPageInfo] = useState(defaultPage); + const [loading, setLoading] = useState({}); + const [columns, setColumns] = useState([]); + const [dataSource, setDataSource] = useState([]); + const [sumRow, setSumRow] = 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, showOperateBtn, selectedRowKeys, selectedKey } = data; + const { current: pageNum, pageSize: size, total } = pageInfo; + setColumns(getColumns(columns, selectedKey, showOperateBtn)); + setDataSource(_.filter(dataSource, it => !!it.id)); + setSelected(selectedRowKeys); + // @ts-ignore + setSumRow(_.last(dataSource)); + setPageInfo({ pageNum, size, total }); + } + }; + const getColumns = (columns: any, selectedKey: string, showOperateBtn: boolean) => { + let tmpV = _.map(columns.filter((item: any) => item.display === "TRUE"), (item: any, index: number) => { + return { + ...item, + ellipsis: true, + dataIndex: item.column, + title: item.text + }; + }); + return tmpV.length > 0 ? [ + ...tmpV, { + title: "操作", + dataIndex: "operate", + fixed: "right", + width: 120, + render: (text: string, record: any) => { + return ( + record.id ? +
+ handleEditFile(record)} + >{(showOperateBtn && selectedKey !== "stop") ? "编辑" : "查看"} + { + showOperateBtn && selectedKey === "pending" && + handleFileMenu(menu, record)}> + 增员 + 删除待办 + } title=""> + + + } + { + showOperateBtn && selectedKey === "suspend" && + handleSuspendFileMenu(menu, record)}> + 减员 + 删除待办 + } title=""> + + + } + { + showOperateBtn && selectedKey === "stop" && + handleStopFileMenu(menu, record)}> + 取消停缴 + } title=""> + + + } +
: +
+ ); + } + }] : []; + }; + const handleEditFile = (record: any) => { + window.parent.postMessage({ type: "turn", payload: { id: "EDIT", params: { ...record } } }, "*"); + }; + const handleFileMenu = ({ key }: any, record: any) => { + if (key === "addMember") { + window.parent.postMessage({ type: "turn", payload: { id: "ADDMEMBER", params: { ...record } } }, "*"); + } else { + window.parent.postMessage({ type: "turn", payload: { id: "STOPSALARY", params: { ...record } } }, "*"); + } + }; + const handleSuspendFileMenu = ({ key }: any, record: any) => { + if (key === "stopSalary") { + window.parent.postMessage({ type: "turn", payload: { id: "STOPSUSPENDSALARY", params: { ...record } } }, "*"); + } else { + window.parent.postMessage({ type: "turn", payload: { id: "STAYDELTOSTOP", params: { ...record } } }, "*"); + } + }; + const handleStopFileMenu = ({ key }: any, record: any) => { + if (key === "stopPaying") { + window.parent.postMessage({ type: "turn", payload: { id: "STOPPAYING", 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, + onChange: (selectedRowKeys: Array) => { + setSelected(selectedRowKeys); + window.parent.postMessage( + { + type: "turn", + payload: { id: "ROWSELECT", params: { selectedRowKeys } } + }, + "*" + ); + } + }; + return { + if (_.isEmpty(columns) || _.isEmpty(sumRow)) return; + return ( + + + { + _.map(columns, (item: any, index) => { + if (index === 0) { + return 总计; + } + return + {sumRow[item.dataIndex] || "-"} + ; + }) + } + + + ); + }} + />; +}; + +export default FileTable;