From a97d7820989e0935e50d1d95fc73800515fa6b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Wed, 29 Nov 2023 15:03:49 +0800 Subject: [PATCH] =?UTF-8?q?custom/=E4=B8=8A=E6=B5=B7=E6=B8=AF=E6=B9=BE-?= =?UTF-8?q?=E5=B7=A5=E8=B5=84=E5=8D=95=E6=9F=A5=E7=9C=8B=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=A2=86=E5=AF=BC=E6=9F=A5=E8=AF=A2=E4=B8=8B=E5=B1=9E=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pc4mobx/hrmSalary/apis/mySalaryBenefits.js | 4 +-- .../components/payrollTable/index.js | 36 +++++++++++++++---- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/pc4mobx/hrmSalary/apis/mySalaryBenefits.js b/pc4mobx/hrmSalary/apis/mySalaryBenefits.js index 6f99b8cb..9eb03209 100644 --- a/pc4mobx/hrmSalary/apis/mySalaryBenefits.js +++ b/pc4mobx/hrmSalary/apis/mySalaryBenefits.js @@ -56,6 +56,6 @@ export const saveSecondaryPwd = params => { export const salaryBillGetToken = params => { return WeaTools.callApi("/api/bs/hrmsalary/salaryBill/getToken", "GET", params); }; -export const getMyJuniorMap = params => { - return WeaTools.callApi("/api/bs/hrmsalary/salaryBill/myJuniorMap", "GET", params); +export const myJuniorTree = params => { + return WeaTools.callApi("/api/bs/hrmsalary/salaryBill/myJuniorTree", "GET", params); }; diff --git a/pc4mobx/hrmSalary/pages/mySalaryBenefits/components/payrollTable/index.js b/pc4mobx/hrmSalary/pages/mySalaryBenefits/components/payrollTable/index.js index df8e1e27..d6fbc200 100644 --- a/pc4mobx/hrmSalary/pages/mySalaryBenefits/components/payrollTable/index.js +++ b/pc4mobx/hrmSalary/pages/mySalaryBenefits/components/payrollTable/index.js @@ -6,7 +6,8 @@ */ import React, { Component } from "react"; import { WeaLeftRightLayout, WeaLocaleProvider, WeaTable, WeaTree } from "ecCom"; -import { getMyJuniorMap, mySalaryBillList } from "../../../../apis/mySalaryBenefits"; +import { message } from "antd"; +import { myJuniorTree, mySalaryBillList } from "../../../../apis/mySalaryBenefits"; import moment from "moment"; const getLabel = WeaLocaleProvider.getLabel; @@ -21,7 +22,7 @@ class Index extends Component { } componentDidMount() { - this.getMyJuniorMap(); + this.getMyJuniorTree(); this.getMySalaryBillList(this.props); } @@ -29,22 +30,38 @@ class Index extends Component { if (nextProps.salaryYearMonth !== this.props.salaryYearMonth) this.getMySalaryBillList(nextProps); } - getMyJuniorMap = () => { - getMyJuniorMap().then(({ status, data }) => { + getMyJuniorTree = () => { + myJuniorTree().then(({ status, data }) => { if (status) { this.setState({ - juniorMapList: _.map(_.keys(data), o => ({ id: o, name: data[o] })) + juniorMapList: this.convertToTreeDatas(data) }); } }); }; + convertToTreeDatas = (datas, pid = "0") => { + return _.map(datas, item => { + if (_.isEmpty(item.children)) { + return { + id: item.employeeId.toString(), name: item.username, + isParent: false, pid + }; + } else { + return { + id: item.employeeId.toString(), name: item.username, + isParent: true, pid, + subs: this.convertToTreeDatas(item.children, item.employeeId.toString()) + }; + } + }); + }; getMySalaryBillList = (props) => { this.setState({ loading: true }); const { pageInfo, employeeId } = this.state; const { salaryYearMonth } = props; - mySalaryBillList({ salaryYearMonth, employeeId, ...pageInfo }).then(({ status, data }) => { + mySalaryBillList({ salaryYearMonth, employeeId, ...pageInfo }).then(({ status, data, errormsg }) => { this.setState({ loading: false }); - if (status) { + if (status && !_.isEmpty(data)) { const { columns, datas: dataSource, pageInfo: { pageNum: current, pageSize, total } } = data; this.setState({ dataSource, pageInfo: { ...pageInfo, current, pageSize, total }, @@ -60,6 +77,11 @@ class Index extends Component { }; }) }); + } else { + message.error(errormsg); + this.setState({ + dataSource: [], pageInfo: { ...pageInfo, total: 0 }, columns: [] + }); } }).catch(() => this.setState({ loading: false })); };