diff --git a/src/api/calculate.service.ts b/src/api/calculate.service.ts index e0f5c1b..74fb62a 100644 --- a/src/api/calculate.service.ts +++ b/src/api/calculate.service.ts @@ -82,6 +82,14 @@ class CalculateService extends BasicService { getSalarysobItemTopology = async (params: any) => { return this.post(`/api/bs/hrmsalary/salarysob/item/topology`, params); }; + //工资发放数据 + getAcctresult = async (params: any) => { + return this.post(`/api/bs/hrmsalary/salaryacct/acctresult/sjjtReport`, params); + }; + //社保合计行 + getAcctresultSum = async (params: any) => { + return this.post(`/api/bs/hrmsalary/salaryacct/acctresult/sjjtReportSum`, params); + }; } const calculateService = new CalculateService(); diff --git a/src/layouts/config.js b/src/layouts/config.js index 987d097..19d1f71 100644 --- a/src/layouts/config.js +++ b/src/layouts/config.js @@ -24,6 +24,7 @@ module.exports = { "/salaryFileTable.*": "blank", "/OCTable.*": "blank", "/unitTable.*": "blank", + "/aliTable.*": "blank", "/custom-project.*": "blank", "/manage.*": "manage", "/portal.*": "template", diff --git a/src/pages/aliTable/dragColsTable/index.tsx b/src/pages/aliTable/dragColsTable/index.tsx new file mode 100644 index 0000000..7bee10c --- /dev/null +++ b/src/pages/aliTable/dragColsTable/index.tsx @@ -0,0 +1,117 @@ +import React, { FunctionComponent, useCallback, useEffect, useMemo, useState } from "react"; +import { Table, Typography } from "antd"; +import moment from "moment"; +import styles from "@/pages/atdTable/components/index.less"; +import { ColumnType } from "antd/lib/table"; +import API from "@/api"; + +const { Text } = Typography; + +interface OwnProps { + location: any; +} + +type Props = OwnProps; + +const index: FunctionComponent = (props) => { + const { location: { query } } = props; + const [loading, setLoading] = useState(false); + const [report, setReport] = useState({ columns: [], dataSource: [], sumRow: {} }); + + useEffect(() => { + setLoading(true); + dataSourceUrl({ ...query, isPrintf: true }).then(({ success, data }) => { + setLoading(false); + if (success) { + const { data: result } = data; + setReport({ + columns: traverse(result?.column), dataSource: result?.data?.list, sumRow: result?.sumRow + }); + } + }); + }, []); + useEffect(() => { + if (!_.isEmpty(report?.columns)) { + window.document.body.innerHTML = + window.document.getElementById("print")!.innerHTML; + const styleTag = document.createElement("style"); + styleTag.type = "text/css"; + styleTag.innerHTML = ` + .ant-table { + td, th, .ant-table-title, .ant-table-footer, table { + border-color: #333 !important; + } + } + `; + window.document.head.appendChild(styleTag); + window.print(); + // window.location.reload(); + } + return () => { + }; + }, [report?.columns]); + + + const dataSourceUrl = useCallback((payload) => { + return API.CalculateService.getAcctresult(payload); + }, []); + + const traverse: any = (arr: any[]) => { + return _.map(arr, item => { + if (!_.isEmpty(item.children)) { + return { dataIndex: item.column, title: item.text, children: traverse(item.children), align: "center" }; + } else { + return { dataIndex: item.column, title: item.text, align: "center" }; + } + }); + }; + const flattenFn = (source: ColumnType[]) => { + let res: ColumnType[] = []; + source.forEach((el: any) => { + _.isEmpty(el.children) && res.push(el); + el.children && res.push(...flattenFn(el.children)); + }); + return res; + }; + const rowSelection = { + columnWidth: 50, columnTitle: "序号", + renderCell: (value: boolean, record: any, index: number) => ({index + 1}) + }; + const columns = useMemo(() => { + return !_.isEmpty(report.columns) ? flattenFn(report.columns) : []; + }, [report.columns]); + return ( +
+
+ {`${moment(query?.startDate).format("YYYY")}年${moment(query?.startDate).format("M")}月份工资清单`} +
} + footer={() =>
+
制表:
+
审批:
+
批准:
+
} + summary={() => ( + + + 小计 + { + !_.isEmpty(report?.sumRow) && + _.map(columns, (item: any, index) => { + return + {report?.sumRow[item.dataIndex] || ""} + ; + }) + } + + + )} + /> + + ); +}; + +export default index; diff --git a/src/pages/atdTable/components/index.less b/src/pages/atdTable/components/index.less index 1a7eee8..07696f3 100644 --- a/src/pages/atdTable/components/index.less +++ b/src/pages/atdTable/components/index.less @@ -369,3 +369,17 @@ } } +//自适应表格样式 +.resizeTable { + width: 1920px; + height: 100%; + //height: 1080px; + //position: absolute; + //top: 50%; + //left: 50%; + ////transform: scale(0.5, 0.5) translate(-50%, -50%); + //transform: translate(-50%, -50%); + //transform-origin: left top; + overflow-y: hidden; +} + diff --git a/src/pages/calcTable/calcFixedTotal.tsx b/src/pages/calcTable/calcFixedTotal.tsx index 09ca74f..6e61bbd 100644 --- a/src/pages/calcTable/calcFixedTotal.tsx +++ b/src/pages/calcTable/calcFixedTotal.tsx @@ -61,7 +61,7 @@ const calcFixedTotal: FunctionComponent = (props) => { return { loading ? : - {sumRow[item.dataIndex] || "-"} + {!_.isNil(sumRow[item.dataIndex]) ? sumRow[item.dataIndex] : "-"} } ; }) diff --git a/src/pages/calcTable/index.tsx b/src/pages/calcTable/index.tsx index b14d72c..7eb09dd 100644 --- a/src/pages/calcTable/index.tsx +++ b/src/pages/calcTable/index.tsx @@ -51,7 +51,7 @@ const index: FunctionComponent = (props) => { const { columns, dataSource, pageInfo, selectedRowKeys, i18n: i18nRes = {}, showTotalCell = false, sumRowlistUrl = "", payload = {}, calcDetail, - fixed = true, tableScrollHeight, sumRow + fixed = true, tableScrollHeight, sumRow, optWidth } = data; setSumRowlistUrl(sumRowlistUrl); setShowTotalCell(showTotalCell); @@ -65,11 +65,12 @@ const index: FunctionComponent = (props) => { setSelectedRowKeys(selectedRowKeys); setTableScrollHeight(tableScrollHeight); setColumns([...convertColumns(_.map(columns, o => ({ ...o, i18n: i18nRes }))), { - title: i18nRes["操作"], dataIndex: "operate", fixed: "right", width: 120, + title: i18nRes["操作"], dataIndex: "operate", fixed: "right", width: optWidth || 120, render: (__, record) => ( + {record?.lockStatus === "LOCK" && {record?.lockTime}} ) }]); } @@ -85,7 +86,8 @@ const index: FunctionComponent = (props) => { className: styles["td_odd"], i18n: item.i18n, render: (text: string, record: any) => ( - {text} + {text} handleDiagramTd(item?.dataIndex, record?.id)} diff --git a/src/pages/reportTable/index.tsx b/src/pages/reportTable/index.tsx index 40d9066..25efc36 100644 --- a/src/pages/reportTable/index.tsx +++ b/src/pages/reportTable/index.tsx @@ -1,7 +1,8 @@ import React, { FC, useEffect, useState } from "react"; import { Button, Table, Typography } from "antd"; -import { exceptStr } from "@/utils/common"; +import { exceptStr, paginationAction } from "@/utils/common"; import styles from "@/pages/atdTable/components/index.less"; +import { PaginationData } from "rc-pagination"; const { Text, Paragraph } = Typography; const ReportTable: FC = (props) => { @@ -10,6 +11,8 @@ const ReportTable: FC = (props) => { const [dataSource, setDataSource] = useState>([]); const [showSumrow, setShowSumrow] = useState(false); const [SSHeaderInfo, setSSHeaderInfo] = useState(""); + const [pageInfo, setPageInfo] = useState>({}); + const [i18n, setI18n] = useState({}); useEffect(() => { window.parent.postMessage({ type: "init" }, "*"); @@ -21,11 +24,13 @@ const ReportTable: FC = (props) => { const receiveMessageFromIndex = (event: any) => { const data: any = exceptStr(event.data); if (!_.isEmpty(data)) { - const { columns, dataSource, countResult, showSum, SSHeaderInfo = "" } = data; + const { i18n, columns, dataSource, countResult, showSum, SSHeaderInfo = "", pageInfo } = data; + setI18n(i18n); setDataSource(dataSource); setShowSumrow(showSum); setSumRow(countResult); setSSHeaderInfo(SSHeaderInfo); + setPageInfo(pageInfo); setColumns(_.map(columns, (item, index: number) => { if (index === 0) { return { ...item, fixed: "left", ellipsis: true }; @@ -88,16 +93,33 @@ const ReportTable: FC = (props) => { })); } }; + const onChange = (current: number, pageSize: number) => { + setPageInfo((prevState) => { + const { pageSize: size } = prevState; + window.parent.postMessage( + { + type: "turn", + payload: { id: "PAGEINFO_REPORT", params: { ...pageInfo, current: size === pageSize ? current : 1, pageSize } } + }, + "*" + ); + return { ...pageInfo, current: size === pageSize ? current : 1, pageSize }; + }); + }; + return
{SSHeaderInfo}} + pagination={!_.isNil(pageInfo) ? { + ...paginationAction(pageInfo, i18n, onChange), + size: "default" + } : false} summary={() => { if (!showSumrow) return; let totalColumns: any[] = []; diff --git a/src/pages/unitTable/renderColsOpts.tsx b/src/pages/unitTable/renderColsOpts.tsx index 59d2fa6..479563f 100644 --- a/src/pages/unitTable/renderColsOpts.tsx +++ b/src/pages/unitTable/renderColsOpts.tsx @@ -295,6 +295,22 @@ export function renderCols(initialState: any[], type: string, i18n?: AnyObject, ); } }]; + } else if (type === "variableSalary") { + return [..._.map(initialState, g => { + return { ...g, ellipsis: true, fixed: false, width: 150 }; + }), { + dataIndex: "operate", title: i18n?.["操作"], width: 185, fixed: "right", + render: (__: string, record: any) => { + return ( + + + + + ); + } + }]; } return initialState; }, [initialState, type, i18n, extraParams]);