diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/addItems.js b/pc4mobx/hrmSalary/pages/dataAcquisition/addItems.js index 463f1562..6ce5d59d 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/addItems.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/addItems.js @@ -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({ diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/index.js b/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/index.js index 5714053f..a0a98009 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/index.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/index.js @@ -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: 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 ( this.tableRef = dom} diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/dataTables.js b/pc4mobx/hrmSalary/pages/dataAcquisition/dataTables.js index 289479b0..9c0900cd 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/dataTables.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/dataTables.js @@ -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 } }); diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/layout.js b/pc4mobx/hrmSalary/pages/dataAcquisition/layout.js index 0a335857..d57176aa 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/layout.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/layout.js @@ -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 (
{ - // 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={[]}