feature/2.9.42310.01-工资单发放页面重构

This commit is contained in:
黎永顺 2023-10-13 15:53:43 +08:00
parent 53ddc607b3
commit c2efaf193b
2 changed files with 39 additions and 13 deletions

View File

@ -7,8 +7,8 @@
import React, { Component } from "react";
import { inject, observer } from "mobx-react";
import { WeaLocaleProvider, WeaSelect, WeaTable } from "ecCom";
import { Dropdown, Menu, message } from "antd";
import { changePayrollDefaultUse, getPayrollTemplateList } from "../../../../apis/payroll";
import { Dropdown, Menu, message, Modal } from "antd";
import { changePayrollDefaultUse, deletePayroll, getPayrollTemplateList } from "../../../../apis/payroll";
import PayrollCopyDialog from "../payrollCopyDialog";
const getLabel = WeaLocaleProvider.getLabel;
@ -19,8 +19,8 @@ class Index extends Component {
constructor(props) {
super(props);
this.state = {
loading: false, columns: [], dataSource: [],
pageInfo: { current: 1, pageSize: 10, total: 0 },
loading: false, columns: [], dataSource: [], selectedRowKeys: [],
pageInfo: { current: 1, pageSize: 10, total: 0 }, delLoading: false,
copyDialog: { visible: false, title: "", copyId: "" }
};
}
@ -74,11 +74,10 @@ class Index extends Component {
});
};
handleOpts = ({ key }, record) => {
const { copyDialog } = this.state;
const { id, templateId } = record;
const { copyDialog, selectedRowKeys } = this.state;
const { id } = record;
switch (key) {
case "edit":
console.log(templateId);
break;
case "copy":
this.setState({
@ -86,7 +85,24 @@ class Index extends Component {
});
break;
case "del":
console.log(templateId);
Modal.confirm({
title: getLabel(131329, "信息确认"),
content: getLabel(388758, "确认要删除吗?"),
onOk: () => {
this.setState({ delLoading: true });
const payload = id ? [id] : selectedRowKeys;
deletePayroll(payload).then(({ status, errormsg }) => {
this.setState({ delLoading: false });
if (status) {
message.success(getLabel(502230, "删除成功!"));
this.getPayrollTemplateList(this.props);
!_.isEmpty(selectedRowKeys) && this.setState({ selectedRowKeys: [] });
} else {
message.error(errormsg);
}
}).catch(() => this.setState({ delLoading: false }));
}
});
break;
default:
break;
@ -94,8 +110,8 @@ class Index extends Component {
};
render() {
const { loading, dataSource, columns, pageInfo, copyDialog } = this.state;
const { taxAgentStore: { showOperateBtn } } = this.props;
const { loading, dataSource, columns, pageInfo, copyDialog, selectedRowKeys } = this.state;
const { taxAgentStore: { showOperateBtn }, forceUpdate } = this.props;
const pagination = {
...pageInfo,
showTotal: total => `${getLabel(18609, "共")} ${total} ${getLabel(18256, "条")}`,
@ -113,10 +129,14 @@ class Index extends Component {
}, () => this.getPayrollTemplateList(this.props));
}
};
const rowSelection = {
selectedRowKeys,
onChange: selectedRowKeys => this.setState({ selectedRowKeys }, () => forceUpdate())
};
return (
<React.Fragment>
<WeaTable
rowKey="id"
rowKey="id" rowSelection={rowSelection}
dataSource={dataSource} loading={loading} pagination={pagination}
columns={[
...columns,

View File

@ -32,6 +32,7 @@ class Index extends Component {
]
}
};
this.templateRef = null;
}
renderReqBtns = () => {
@ -49,9 +50,13 @@ class Index extends Component {
];
break;
case "template":
const loading = this.templateRef ? this.templateRef.wrappedInstance.state.delLoading : false;
const delDisabled = !this.templateRef || _.isEmpty(this.templateRef.wrappedInstance.state.selectedRowKeys);
const btns = [
<Button type="primary">{getLabel(365, "新建")}</Button>,
<Button type="ghost">{getLabel(32136, "批量删除")}</Button>
<Button type="ghost" loading={loading} disabled={delDisabled} onClick={() => {
this.templateRef.wrappedInstance.handleOpts({ key: "del" }, {});
}}>{getLabel(32136, "批量删除")}</Button>
];
const queryBtns = [
<TemplateQuery queryParams={queryParams} onSearch={() => this.setState({ isRefresh: !isRefresh })}
@ -75,7 +80,8 @@ class Index extends Component {
dom = <GrantTableList queryParams={queryParams} isRefresh={isRefresh}/>;
break;
case "template":
dom = <PayrollTemplateTableList queryParams={queryParams} isRefresh={isRefresh}/>;
dom = <PayrollTemplateTableList ref={dom => this.templateRef = dom} queryParams={queryParams}
isRefresh={isRefresh} forceUpdate={() => this.forceUpdate()}/>;
break;
default:
break;