diff --git a/src/api/calculate.service.ts b/src/api/calculate.service.ts index 4fea0b3..0de7712 100644 --- a/src/api/calculate.service.ts +++ b/src/api/calculate.service.ts @@ -31,11 +31,26 @@ class CalculateService extends BasicService { getSysconfcode = async ({ code }: any) => { return this.get(`/api/bs/hrmsalary/sys/conf/code?code=${code}`); }; + //获取职级信息 + getRankInfo = async () => { + return this.get(`/api/ais/tupu/getRankInfo`); + }; //合计行 getAcctresultsum = async (params: any) => { - return this.post(`/api/bs/hrmsalary/salaryacct/acctresult/sum`, params); + const { departmentIds = "", positionIds = "", subcompanyIds = "", ...extraParams } = params || {}; + let queryParams = { + ...extraParams, + departmentIds: departmentIds ? departmentIds.split(",") : undefined, + positionIds: positionIds ? positionIds.split(",") : undefined, + subcompanyIds: subcompanyIds ? subcompanyIds.split(",") : undefined + }; + for (let key in queryParams) { + if (queryParams[key] === "" || queryParams[key] === "0") { + delete queryParams[key]; + } + } + return this.post(`/api/bs/hrmsalary/salaryacct/acctresult/sum`, queryParams); }; - } const calculateService = new CalculateService(); diff --git a/src/layouts/config.js b/src/layouts/config.js index e9b21a0..535553c 100644 --- a/src/layouts/config.js +++ b/src/layouts/config.js @@ -9,6 +9,7 @@ module.exports = { '/previewTable.*': 'blank', '/standingbookTable.*': 'blank', '/fileTable.*': 'blank', + '/rankMapTable.*': '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 b6ab71f..65e40a2 100644 --- a/src/pages/atdTable/components/index.less +++ b/src/pages/atdTable/components/index.less @@ -155,3 +155,18 @@ } } } + +:global{ + .rankMapWrapper{ + .ant-table-thead>tr>th{ + background: #ED7D31; + } + } + .bg_1_Cols { + background: #ED7D31!important; + } + .bg_2_Cols { + background: #DEE0E3!important; + } +} + diff --git a/src/pages/rankMapTable/index.tsx b/src/pages/rankMapTable/index.tsx new file mode 100644 index 0000000..66c0c79 --- /dev/null +++ b/src/pages/rankMapTable/index.tsx @@ -0,0 +1,84 @@ +import React, { useEffect, useState } from "react"; +import { Table } from "antd"; +import API from "@/api"; +import "../atdTable/components/index.less"; + +const RankMapTable: React.FC = () => { + const [cols, setCols] = useState>([]); + const [dataSource, setDataSource] = useState>([]); + useEffect(() => { + getRankInfo(); + }, []); + useEffect(() => { + if (!_.isEmpty(dataSource)) { + setCols( + _.map(cols, item => { + const dataIndex = item.dataIndex + "_rowSpan"; + const colsIndex = item.dataIndex.split("_")[1]; + return { + ...item, + align: "center", + className: colsIndex === "1" ? "bg_1_Cols" : colsIndex === "2" ? "bg_2_Cols" : "", + render: (text: string, _: any) => { + return { + children: {text}, + props: { + rowSpan: _[dataIndex] + } + }; + } + }; + }) + ); + } + }, [dataSource]); + + const changeData = (data: any, field: any) => { + let count = 0, indexCount = 1; + const rowSpan = field + "_rowSpan"; + try { + while (indexCount < data.length) { + let item = data.slice(count, count + 1)[0]; + if (!item[rowSpan]) { + item[rowSpan] = 1; + } + if (item[field] === data[indexCount][field]) { + item[rowSpan]++; + data[indexCount][rowSpan] = 0; + } else { + count = indexCount; + } + indexCount++; + } + } catch { + } + return data; + }; + const getRankInfo = () => { + API.CalculateService.getRankInfo().then(({ success, data }) => { + if (success) { + const { data: dataCopy } = data; + const { col: columns, data: list } = dataCopy; + let tmpV: any = []; + _.forEach(_.reduce(columns, (pre: any, cur: any) => ([...pre, cur["dataIndex"]]), []), item => { + tmpV = changeData(list, item); + }); + setCols(columns); + setDataSource(tmpV); + } + }); + }; + return
+ ; + ; + } +; + +export default RankMapTable;