数据采集页面重构

This commit is contained in:
黎永顺 2023-02-20 14:28:08 +08:00
parent 6cff75a9b5
commit b6849400d7
4 changed files with 88 additions and 27 deletions

View File

@ -26,7 +26,26 @@ class AddItems extends Component {
}
};
}
componentDidMount() {
this.setState({
baseInfo: {
...this.state.baseInfo,
declareMonth: this.props.editId.declareMonth,
taxAgentId: this.props.editId.taxAgentId,
taxAgentName: this.props.editId.taxAgentName,
employeeId: this.props.editId.employeeId,
employeeName: this.props.editId.username
}
});
const fields = _.map(this.props.condition[0].items, it => {
return it.domkey[0];
});
fields.map(item => {
this.props.form.updateFields({
[item]: this.props.editId[item] || ""
});
});
}
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.editId !== this.props.editId) {
this.setState({

View File

@ -4,8 +4,10 @@ import { WeaDatePicker, WeaFormItem, WeaHelpfulTip, WeaSearchGroup, WeaSelect }
import { Button, Dropdown, Menu, message, Modal } from "antd";
import {
autoAddAll,
createAddUpDeduction,
deleteAllAddUpDeduction,
deleteSelectAddUpDeduction,
editAddUpDeduction,
getAddUpDeduction
} from "../../../apis/cumDeduct";
import DataTables from "../dataTables";
@ -24,11 +26,12 @@ class Index extends Component {
taxAgentId: "",
innerWidth: window.innerWidth,
addAllLoading: false,
saveLoading: false,
slidePayload: {
visible: false,
title: "",
children: null,
id: ""
data: {}
}
};
this.tableRef = null;
@ -109,7 +112,59 @@ class Index extends Component {
}
});
};
/*
* Author: 黎永顺
* Description: 数据采集-信息保存
* Params:
* Date: 2023/2/20
*/
handleSaveDeduction = (payload) => {
const { slidePayload } = this.state;
const { data } = slidePayload;
const { id } = data;
this.setState({ saveLoading: true });
if (!_.isEmpty(data)) {
editAddUpDeduction({ ...payload, id }).then(({ status, errormsg }) => {
this.setState({ saveLoading: false });
if (status) {
message.success("编辑成功");
this.handleCloseSlide();
this.tableRef.getTableDate();
} else {
message.error(errormsg || "编辑失败");
}
});
} else {
createAddUpDeduction(payload).then(({ status, errormsg }) => {
this.setState({ saveLoading: false });
if (status) {
message.success("新增成功");
this.handleCloseSlide();
this.tableRef.getTableDate();
} else {
message.error(errormsg || "新增失败");
}
});
}
};
handleSaveData = () => {
const { cumDeductStore: { addForm } } = this.props;
const { baseInfo } = this.addItemRef.state;
const bool = _.every(_.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId"]), v => !!v);
if (!bool) {
Modal.warning({
title: "信息确认",
content: "必要信息不完整,红色*为必填项!"
});
return;
}
const payload = {
..._.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId", "taxAgentName"]),
...addForm.getFormParams()
};
this.handleSaveDeduction(payload);
};
handleResize = (innerWidth) => this.setState({ innerWidth });
/*
* Author: 黎永顺
@ -127,6 +182,7 @@ class Index extends Component {
...slidePayload,
visible: true,
title,
data: editId,
children: <AddItems
ref={(dom) => this.addItemRef = dom}
taxAgentOption={taxAgentOption}
@ -157,7 +213,7 @@ class Index extends Component {
visible: false,
title: "",
chidren: null,
id: ""
data: {}
}
});
};
@ -193,7 +249,7 @@ class Index extends Component {
col={innerWidth < 900 ? 1 : 2}/>;
};
screenChange = ({ key, value }) => {
this.setState({ [key]: value }, () => this.tableRef.getTableDate());
this.setState({ [key]: value }, () => this.tableRef.getTableDate({ current: 1 }));
};
/*
* Author: 黎永顺
@ -225,12 +281,13 @@ class Index extends Component {
render() {
const { taxAgentStore: { showOperateBtn } } = this.props;
const { declareMonth, taxAgentId, slidePayload } = this.state;
const { declareMonth, taxAgentId, slidePayload, saveLoading } = this.state;
const tablePayload = { declareMonth: [declareMonth], taxAgentId };
return (
<Layout title="累计专项附加扣除" btns={this.getTopBtns()} leftComp={this.getScreen()}
onResizeWindowInnerWidth={this.handleResize} slidePayload={slidePayload}
onClose={this.handleCloseSlide}
onClose={this.handleCloseSlide} onSave={this.handleSaveData}
slideLoading={saveLoading}
>
<DataTables
ref={dom => this.tableRef = dom}

View File

@ -29,10 +29,10 @@ class DataTables extends Component {
this.getTableDate();
}
getTableDate = () => {
getTableDate = (extraPayload = {}) => {
const { loading, pageInfo } = this.state;
const { url, payload } = this.props;
const module = { ...pageInfo, url, ...payload };
const module = { ...pageInfo, url, ...payload, ...extraPayload };
this.setState({ loading: { ...loading, query: true } });
getTableDate(module).then(({ status, data }) => {
this.setState({ loading: { ...loading, query: false } });

View File

@ -39,9 +39,9 @@ class Layout extends Component {
const { showSearchAd } = this.state;
const {
title, btns, leftComp, children, taxAgentStore: { showOperateBtn },
slidePayload, onClose
slidePayload, onClose, onSave, slideLoading
} = this.props;
const { visible, title: subtitle, children: slideChildren, id } = slidePayload;
const { visible, title: subtitle, children: slideChildren } = slidePayload;
return (
<div className="layoutWrapper">
<WeaTop title={title} buttons={showOperateBtn ? btns : []}
@ -71,23 +71,8 @@ class Layout extends Component {
title={
<SlideModalTitle
subtitle={subtitle}
loading={false}
onSave={() => {
// const { baseInfo } = this.addItemRef.state;
// const bool = _.every(_.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId"]), v => !_.isEmpty(v));
// if (!bool && _.isEmpty(editId)) {
// Modal.warning({
// title: "信息确认",
// content: "必要信息不完整,红色*为必填项!"
// });
// return;
// }
// const payload = {
// ..._.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId", "taxAgentName"]),
// ...addForm.getFormParams()
// };
// this.handleSaveDeduction(payload);
}}
loading={slideLoading}
onSave={onSave}
editable={true}
showOperateBtn={showOperateBtn}
customOperate={[]}