From d02b30d6e411a0fc7319978264b318d0b7fac3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Mon, 5 Dec 2022 10:53:05 +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/api/calculate.service.ts | 12 ++++++- src/pages/atdTable/components/antdTable.tsx | 36 +++++++++++++-------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/api/calculate.service.ts b/src/api/calculate.service.ts index 6cf638a..4fea0b3 100644 --- a/src/api/calculate.service.ts +++ b/src/api/calculate.service.ts @@ -7,9 +7,10 @@ class CalculateService extends BasicService { constructor() { super(); } + //获取人员确认列表信息 getPCDataList = async ({ url, queryParams }: any) => { - const { departmentIds = "", positionIds = "", subcompanyIds="", ...extraParams } = queryParams || {}; + const { departmentIds = "", positionIds = "", subcompanyIds = "", ...extraParams } = queryParams || {}; queryParams = { ...extraParams, departmentIds: departmentIds ? departmentIds.split(",") : undefined, @@ -26,6 +27,15 @@ class CalculateService extends BasicService { queryParams ); }; + //获取系统配置项 + getSysconfcode = async ({ code }: any) => { + return this.get(`/api/bs/hrmsalary/sys/conf/code?code=${code}`); + }; + //合计行 + getAcctresultsum = async (params: any) => { + return this.post(`/api/bs/hrmsalary/salaryacct/acctresult/sum`, params); + }; + } const calculateService = new CalculateService(); diff --git a/src/pages/atdTable/components/antdTable.tsx b/src/pages/atdTable/components/antdTable.tsx index 46ee980..0b1b42f 100644 --- a/src/pages/atdTable/components/antdTable.tsx +++ b/src/pages/atdTable/components/antdTable.tsx @@ -1,7 +1,7 @@ import React, { FC, useEffect, useState } from "react"; import { exceptStr, paginationFun } from "@/utils/common"; import { defaultPage, ILoading, IPage } from "@/common/types/page"; -import { message, Table, Typography } from "antd"; +import { message, Spin, Table, Typography } from "antd"; import { LockOutlined, UnlockOutlined } from "@ant-design/icons"; import API from "@/api"; import styles from "./index.less"; @@ -20,6 +20,7 @@ const AntdTable: FC = (props) => { const [columns, setColumns] = useState([]); const [dataSource, setDataSource] = useState([]); const [sumRow, setSumRow] = useState>({});//薪资核算总计行数据 + const [showSumrow, setShowSumrow] = useState(false);//薪资核算总计行是否隐藏 useEffect(() => { window.parent.postMessage( { @@ -40,7 +41,7 @@ const AntdTable: FC = (props) => { setLoading({ query: true }); setTab(type); setUsertab(listType); - API.CalculateService.getPCDataList(extraParams).then(({ success, data, errorMsg }) => { + API.CalculateService.getPCDataList(extraParams).then(async ({ success, data, errorMsg }) => { setLoading({ query: false }); if (success) { const { data: dataCopy } = data; @@ -57,12 +58,19 @@ const AntdTable: FC = (props) => { setPageParams({ ...pageParams, total, size, pageNum }); } } else { - const { columns = [], pageInfo = {}, sumRow = {} } = dataCopy; + const { columns = [], pageInfo = {} } = dataCopy; const { list = [], total, pageSize: size, pageNum } = pageInfo; setColumns(getColumns(columns)); setDataSource(list); - setSumRow(sumRow); setPageParams({ ...pageParams, total, size, pageNum }); + const confCode: any = await API.CalculateService.getSysconfcode({ code: "OPEN_ACCT_RESULT_SUM" }); + setShowSumrow(confCode.data.status && confCode.data.data === "1"); + if (confCode.data.status && confCode.data.data === "1") { + const sumRowlist: any = await API.CalculateService.getAcctresultsum({ salaryAcctRecordId: extraParams.queryParams.salaryAcctRecordId }); + if (sumRowlist.data.status && !_.isEmpty(sumRowlist.data.data.sumRow)) { + setSumRow(sumRowlist.data.data.sumRow); + } + } } } else { message.error(errorMsg || ""); @@ -290,7 +298,7 @@ const AntdTable: FC = (props) => { y: tab !== "PR" ? "calc(100vh - 96px)" : !_.isEmpty(sumRow) ? "calc(100vh - 192px)" : "calc(100vh - 156px)" }} summary={() => { - if (tab !== "PR" || _.isEmpty(sumRow)) return; + if (tab !== "PR" || !showSumrow) return; let totalColumns: any[] = []; _.forEach(columns, it => { if (!it.children) { @@ -303,14 +311,16 @@ const AntdTable: FC = (props) => { { - _.map([{},...totalColumns], (item, index) => { - if (index === 0) { - return 总计; - } - return - {sumRow[item.dataIndex] || "-"} - ; - }) + _.isEmpty(sumRow) ? : + _.map([{}, ...totalColumns], (item, index) => { + console.log(sumRow[item.dataIndex]); + if (index === 0) { + return 总计; + } + return + {sumRow[item.dataIndex] || "-"} + ; + }) }