diff --git a/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryApproval/index.js b/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryApproval/index.js new file mode 100644 index 00000000..a967a73d --- /dev/null +++ b/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryApproval/index.js @@ -0,0 +1,149 @@ +/* + * 杭州五院二开 + * 工资申请表流程审批列表 + * @Author: 黎永顺 + * @Date: 2025/4/29 + * @Wechat: + * @Email: 971387674@qq.com + * @description: +*/ +import React, { Component } from "react"; +import { WeaLocaleProvider } from "ecCom"; +import { Spin } from "antd"; +import EditCalcAdvanceSearchPannel from "../salaryEditCalc/editCalcAdvanceSearchPannel"; +import { postFetch } from "../../../../../util/request"; +import { traverse } from "../salaryEditCalc/editCalcTable"; +import cs from "classnames"; + +const getLabel = WeaLocaleProvider.getLabel; + +class Index extends Component { + constructor(props) { + super(props); + this.state = { + showSearchAd: false, showTotalCell: false, pageInfo: { current: 1, pageSize: 10, total: 0 }, + loading: false, sumRow: {} + }; + } + + componentDidMount() { + window.addEventListener("message", this.handleReceive, false); + } + + componentWillUnmount() { + window.removeEventListener("message", this.handleReceive, false); + } + + handleReceive = async ({ data }) => { + const { type, payload: { id, params } = {} } = data; + if (type === "init") { + this.getAcctresultList(); + } else if (type === "turn") { + switch (id) { + case "PAGEINFO": + const { size: pageSize, pageNum: current } = params; + this.setState({ + pageInfo: { ...this.state.pageInfo, current, pageSize } + }, () => this.getAcctresultList(true)); + break; + default: + break; + } + } + }; + getAcctresultList = (isPageChange = false) => { + const { pageInfo } = this.state, + { calculateStore: { ECSearchForm, otherConditions }, routeParams: { salaryAcctRecordId } } = this.props; + this.setState({ loading: true }); + const { subcompanyIds, departmentIds, positionIds, statuses, ...extra } = ECSearchForm.getFormParams(); + const payload = { + salaryAcctRecordId, ...pageInfo, ...extra, otherConditions, + departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : [], + positionIds: !_.isEmpty(positionIds) ? positionIds.split(",") : [], + subcompanyIds: !_.isEmpty(subcompanyIds) ? subcompanyIds.split(",") : [], + statuses: !_.isEmpty(statuses) ? statuses.split(",") : [] + }; + postFetch("/api/bs/hrmsalary/salarysob/salaryApproval/acctresult/list", payload) + .then(({ status, data }) => { + this.setState({ loading: false }); + if (status && !_.isEmpty(data)) { + const { columns, pageInfo: { pageNum: current, pageSize, total, list: dataSource } } = data; + this.setState({ pageInfo: { current, pageSize, total } }, () => { + const { pageInfo, sumRow } = this.state; + this.postMessageToChild({ + dataSource, pageInfo, showTotalCell: true, sumRowlistUrl: "", calcDetail: true, tableScrollHeight: 179, + sumRow, + columns: _.every(traverse(columns, true), (it, idx) => !it.fixed) ? _.map(traverse(columns, true), (it, idx) => ({ + ...it, fixed: idx < 2 ? "left" : false + })) : traverse(columns, true) + }); + }); + !isPageChange && this.getAcctresultListSum({ + dataSource, pageInfo: { current, pageSize, total }, showTotalCell: true, sumRowlistUrl: "", + calcDetail: true, tableScrollHeight: 179, + columns: _.every(traverse(columns, true), (it, idx) => !it.fixed) ? _.map(traverse(columns, true), (it, idx) => ({ + ...it, fixed: idx < 2 ? "left" : false + })) : traverse(columns, true) + }); + } + }).catch(() => this.setState({ loading: false })); + }; + getAcctresultListSum = (tableData) => { + const { calculateStore: { ECSearchForm, otherConditions }, routeParams: { salaryAcctRecordId } } = this.props; + const { subcompanyIds, departmentIds, positionIds, statuses, ...extra } = ECSearchForm.getFormParams(); + const payload = { + salaryAcctRecordId, ...extra, otherConditions, + departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : [], + positionIds: !_.isEmpty(positionIds) ? positionIds.split(",") : [], + subcompanyIds: !_.isEmpty(subcompanyIds) ? subcompanyIds.split(",") : [], + statuses: !_.isEmpty(statuses) ? statuses.split(",") : [] + }; + postFetch("/api/bs/hrmsalary/salaryacct/acctresult/sum", payload) + .then(({ status, data }) => { + if (status) { + const { sumRow } = data; + this.setState({ sumRow }, () => { + this.postMessageToChild({ ...tableData, sumRow }); + }); + } + }); + }; + openAdvanceSearch = () => this.setState({ showSearchAd: !this.state.showSearchAd }); + onAdSearch = (bool = true) => { + this.getAcctresultList(); + bool && this.openAdvanceSearch(); + }; + postMessageToChild = (payload = {}) => { + const i18n = { + "共": getLabel(18609, "共"), "条": getLabel(18256, "条"), + "总计": getLabel(523, "总计") + }; + const childFrameObj = document.getElementById("approvalTable"); + childFrameObj.contentWindow.postMessage(JSON.stringify({ ...payload, i18n }), "*"); + }; + + render() { + const { showSearchAd, loading, pageInfo } = this.state, { routeParams: { salaryAcctRecordId } } = this.props; + const { pageSize, total } = pageInfo; + const columnNum = total > pageSize ? pageSize : total; + return (
+
+ +
+
+ +