diff --git a/pc4mobx/hrmSalary/apis/mySalaryBenefits.js b/pc4mobx/hrmSalary/apis/mySalaryBenefits.js index d28d7ed7..9eb03209 100644 --- a/pc4mobx/hrmSalary/apis/mySalaryBenefits.js +++ b/pc4mobx/hrmSalary/apis/mySalaryBenefits.js @@ -56,3 +56,6 @@ export const saveSecondaryPwd = params => { export const salaryBillGetToken = params => { return WeaTools.callApi("/api/bs/hrmsalary/salaryBill/getToken", "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 33cb6873..01140f4f 100644 --- a/pc4mobx/hrmSalary/pages/mySalaryBenefits/components/payrollTable/index.js +++ b/pc4mobx/hrmSalary/pages/mySalaryBenefits/components/payrollTable/index.js @@ -5,8 +5,9 @@ * Date: 2023/11/13 */ import React, { Component } from "react"; -import { WeaLocaleProvider, WeaTable } from "ecCom"; -import { mySalaryBillList } from "../../../../apis/mySalaryBenefits"; +import { WeaLeftRightLayout, WeaLocaleProvider, WeaTable, WeaTree } from "ecCom"; +import { message } from "antd"; +import { myJuniorTree, mySalaryBillList } from "../../../../apis/mySalaryBenefits"; import moment from "moment"; const getLabel = WeaLocaleProvider.getLabel; @@ -21,20 +22,46 @@ class Index extends Component { } componentDidMount() { - this.getMySalaryBillList(this.props); + this.getMyJuniorTree(); } componentWillReceiveProps(nextProps, nextContext) { if (nextProps.salaryYearMonth !== this.props.salaryYearMonth) this.getMySalaryBillList(nextProps); } + getMyJuniorTree = () => { + myJuniorTree().then(({ status, data }) => { + if (status) { + this.setState({ + juniorMapList: this.convertToTreeDatas(data), + employeeId: !_.isNil(data) ? _.head(data).employeeId : "" + }, () => this.getMySalaryBillList(this.props)); + } + }); + }; + 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 }, @@ -50,12 +77,17 @@ class Index extends Component { }; }) }); + } else { + message.error(errormsg); + this.setState({ + dataSource: [], pageInfo: { ...pageInfo, total: 0 }, columns: [] + }); } }).catch(() => this.setState({ loading: false })); }; render() { - const { juniorMapList, dataSource, loading, columns, pageInfo } = this.state; + const { juniorMapList, dataSource, loading, columns, pageInfo, employeeId } = this.state; const pagination = { ...pageInfo, showTotal: total => `${getLabel(18609, "共")} ${total} ${getLabel(18256, "条")}`, @@ -74,17 +106,28 @@ class Index extends Component { } }; return ( - ({getLabel(33564, "查看")}) - }]} - /> + + this.setState({ employeeId }, () => this.getMySalaryBillList(this.props))}/> + + } + > + ({getLabel(33564, "查看")}) + }]} + /> + ); } } diff --git a/pc4mobx/hrmSalary/pages/mySalaryBenefits/components/subPayroll/index.js b/pc4mobx/hrmSalary/pages/mySalaryBenefits/components/subPayroll/index.js new file mode 100644 index 00000000..f7d23660 --- /dev/null +++ b/pc4mobx/hrmSalary/pages/mySalaryBenefits/components/subPayroll/index.js @@ -0,0 +1,92 @@ +/* + * Author: 黎永顺 + * name: 下属工资单 + * Description: + * Date: 2023/11/13 + */ +import React, { Component } from "react"; +import { WeaLocaleProvider, WeaTable } from "ecCom"; +import { mySalaryBillList } from "../../../../apis/mySalaryBenefits"; +import moment from "moment"; + +const getLabel = WeaLocaleProvider.getLabel; + +class Index extends Component { + constructor(props) { + super(props); + this.state = { + dataSource: [], columns: [], pageInfo: { current: 1, pageSize: 10, total: 0 }, + loading: false + }; + } + + componentDidMount() { + this.getMySalaryBillList(this.props); + } + + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.salaryYearMonth !== this.props.salaryYearMonth) this.getMySalaryBillList(nextProps); + } + + getMySalaryBillList = (props) => { + this.setState({ loading: true }); + const { pageInfo } = this.state; + const { salaryYearMonth } = props; + mySalaryBillList({ salaryYearMonth, ...pageInfo }).then(({ status, data }) => { + this.setState({ loading: false }); + if (status) { + const { columns, datas: dataSource, pageInfo: { pageNum: current, pageSize, total } } = data; + this.setState({ + dataSource, pageInfo: { ...pageInfo, current, pageSize, total }, + columns: _.map(columns, it => { + if (it.column === "salaryYearMonth" || it.column === "sendTime") { + return { + dataIndex: it.column, title: it.text, width: it.width, + render: (__, record) => ({moment(record[it["column"]]).format("YYYY-MM")}) + }; + } + return { + dataIndex: it.column, title: it.text, width: it.width + }; + }) + }); + } + }).catch(() => this.setState({ loading: false })); + }; + + render() { + const { dataSource, loading, columns, pageInfo } = this.state; + const pagination = { + ...pageInfo, + showTotal: total => `${getLabel(18609, "共")} ${total} ${getLabel(18256, "条")}`, + showQuickJumper: true, + showSizeChanger: true, + pageSizeOptions: ["10", "20", "50", "100"], + onShowSizeChange: (current, pageSize) => { + this.setState({ + pageInfo: { ...pageInfo, current, pageSize } + }, () => this.getMySalaryBillList(this.props)); + }, + onChange: current => { + this.setState({ + pageInfo: { ...pageInfo, current } + }, () => this.getMySalaryBillList(this.props)); + } + }; + return ( + ({getLabel(33564, "查看")}) + }]} + /> + ); + } +} + +export default Index; diff --git a/pc4mobx/hrmSalary/pages/mySalaryBenefits/index.js b/pc4mobx/hrmSalary/pages/mySalaryBenefits/index.js index 8e53ffec..2a1922a5 100644 --- a/pc4mobx/hrmSalary/pages/mySalaryBenefits/index.js +++ b/pc4mobx/hrmSalary/pages/mySalaryBenefits/index.js @@ -6,8 +6,9 @@ */ import React, { Component } from "react"; import { WeaLocaleProvider, WeaReqTop } from "ecCom"; -import Payroll from "./components/payrollTable"; +import SubPayroll from "./components/payrollTable"; import SalaryAdjustmentRecords from "./components/SalaryAdjustmentRecords"; +import Payroll from "./components/subPayroll"; import { MonthRangePicker } from "../reportView/components/statisticalMicroSettingsSlide"; import moment from "moment"; import "./index.less"; @@ -32,6 +33,9 @@ class Index extends Component { case "2": Dom = ; break; + case "3": + Dom = ; + break; default: break; } @@ -42,7 +46,8 @@ class Index extends Component { const { selectedKey, salaryYearMonth } = this.state; const tabs = [ { key: "1", title: getLabel(503, "工资单") }, - { key: "2", title: getLabel(543150, "调薪记录") } + { key: "2", title: getLabel(543150, "调薪记录") }, + { key: "3", title: getLabel(111, "下属工资单") } ]; const btns = [
@@ -53,9 +58,9 @@ class Index extends Component { ]; return ( } + title={getLabel(537998, "薪资福利")} icon={} iconBgcolor="#F14A2D" tabDatas={tabs} className="mySalary_wrapper" - buttons={selectedKey === "1" ? btns : []} buttonSpace={10} selectedKey={selectedKey} + buttons={selectedKey !== "2" ? btns : []} buttonSpace={10} selectedKey={selectedKey} onChange={selectedKey => this.setState({ selectedKey })} > {this.renderContent()}