diff --git a/pc4mobx/hrmSalary/apis/cumDeduct.js b/pc4mobx/hrmSalary/apis/cumDeduct.js index f7a094e6..18ddb1a5 100644 --- a/pc4mobx/hrmSalary/apis/cumDeduct.js +++ b/pc4mobx/hrmSalary/apis/cumDeduct.js @@ -107,6 +107,10 @@ export const importCumDeductPreview = (params) => { export const createAddUpDeduction = (params) => { return postFetch('/api/bs/hrmsalary/addUpDeduction/createAddUpDeduction', params); } +//查看信息 +export const getAddUpDeduction = (params) => { + return postFetch('/api/bs/hrmsalary/addUpDeduction/getAddUpDeduction', params); +} //编辑累计专项附加扣除 export const editAddUpDeduction = (params) => { return postFetch('/api/bs/hrmsalary/addUpDeduction/editAddUpDeduction', params); diff --git a/pc4mobx/hrmSalary/apis/otherDeduct.js b/pc4mobx/hrmSalary/apis/otherDeduct.js index 4b8fa0a9..b7f2ad31 100644 --- a/pc4mobx/hrmSalary/apis/otherDeduct.js +++ b/pc4mobx/hrmSalary/apis/otherDeduct.js @@ -111,6 +111,10 @@ export const importOtherDeductionPreview = (params) => { export const createData = (params) => { return postFetch('/api/bs/hrmsalary/otherDeduction/createData', params); } +//查看信息 +export const getData = (params) => { + return postFetch('/api/bs/hrmsalary/otherDeduction/getData', params); +} //编辑其他免税扣除 export const editData = (params) => { return postFetch('/api/bs/hrmsalary/otherDeduction/editData', params); diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/addItems.js b/pc4mobx/hrmSalary/pages/dataAcquisition/addItems.js index a9ee5124..5ed7b58a 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/addItems.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/addItems.js @@ -19,6 +19,7 @@ class AddItems extends Component { taxAgentId: "", taxAgentName: "", employeeId: "", + employeeName: "", personArea: "", username: "", idcard: "" @@ -26,18 +27,37 @@ class AddItems extends Component { }; } - componentDidMount() { - console.log('123',this.props.editId); + componentWillReceiveProps(nextProps, nextContext) { + if (nextProps.editId !== this.props.editId) { + this.setState({ + baseInfo: { + ...this.state.baseInfo, + declareMonth: nextProps.editId.declareMonth, + taxAgentId: nextProps.editId.taxAgentId, + taxAgentName: nextProps.editId.taxAgentName, + employeeId: nextProps.editId.employeeId, + employeeName: nextProps.editId.username, + } + }); + const fields= _.map(nextProps.condition[0].items, it =>{ + return it.domkey[0] + }) + fields.map(item => { + nextProps.form.updateFields({ + [item]: nextProps.editId[item] + }) + }) + } } render() { - const { taxAgentOption = [], form, condition = [], isCum } = this.props; + const { taxAgentOption = [], form, condition = [], isCum, editId } = this.props; const { baseInfo } = this.state; const items = [ { com: PickDate({ label: "税款所属期", - viewAttr: 3, + viewAttr: _.isEmpty(editId) ? 3 : 1, labelCol: { span: 6 }, wrapperCol: { span: 18 }, format: "YYYY-MM", @@ -50,7 +70,7 @@ class AddItems extends Component { { com: Select({ label: "个税扣缴义务人", - viewAttr: 3, + viewAttr: _.isEmpty(editId) ? 3 : 1, options: taxAgentOption, value: baseInfo.taxAgentId, onChange: (data) => { @@ -61,9 +81,11 @@ class AddItems extends Component { { com: Browser({ label: "人员", - viewAttr: 3, - onChange: (employeeId) => { - this.setState({ baseInfo: { ...baseInfo, employeeId } }); + viewAttr: _.isEmpty(editId) ? 3 : 1, + value: baseInfo.employeeId, + valueSpan: baseInfo.employeeName, + onChange: ({ids, names}) => { + this.setState({ baseInfo: { ...baseInfo, employeeId: ids, employeeName: names } }); } }) } @@ -98,7 +120,7 @@ class AddItems extends Component { label: "人员范围", viewAttr: 3, options: [ - { key: "ORGANIZATION", showname: "内部人员" }, + { key: "ORGANIZATION", showname: "内部人员" } // { key: "EXT_EMPLOYEE", showname: "非系统人员" } ], value: baseInfo.personArea, @@ -112,8 +134,8 @@ class AddItems extends Component { com: Browser({ label: "人员", viewAttr: 3, - onChange: (employeeId) => { - this.setState({ baseInfo: { ...baseInfo, employeeId } }); + onChange: ({ids, names}) => { + this.setState({ baseInfo: { ...baseInfo, employeeId: ids, employeeName: names } }); } }) }]; @@ -142,7 +164,7 @@ class AddItems extends Component {
{ getSearchs(form, condition, 2) @@ -156,13 +178,15 @@ class AddItems extends Component { export default AddItems; export const Browser = payload => { - const { label, onChange, viewAttr = 3 } = payload; + const { label, onChange, viewAttr = 3, value, valueSpan } = payload; return ( + value={value} + valueSpan={valueSpan} + onChange={(ids, names)=> onChange({ids, names})}/> ); }; diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/components/editSlideContent.js b/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/components/editSlideContent.js index 63f96c64..becf4328 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/components/editSlideContent.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/cumDeduct/components/editSlideContent.js @@ -144,7 +144,7 @@ export default class EditSlideContent extends React.Component { {currentRecord.username} - 申报月份 + 税款所属期
- 申报月份: + 税款所属期: { + handleSaveDeduction = (payload) => { + const { editId } = this.state; this.setState({ saveLoading: true }); - API.createAddUpDeduction(payload).then(({ status }) => { - this.setState({ saveLoading: false }); - if (status) { - message.success("新增成功"); - this.setState({ - addVisible: false - }, () => { - const { cumDeductStore: { doSearch, addForm } } = this.props; - const { monthValue, taxAgentId } = this.state; - doSearch({ - declareMonth: [monthValue], - taxAgentId: taxAgentId === "All" ? "" : taxAgentId + if (!_.isEmpty(editId)) { + API.editAddUpDeduction({ ...payload, id: editId.id }).then(({ status }) => { + this.setState({ saveLoading: false }); + if (status) { + message.success("编辑成功"); + this.setState({ + addVisible: false, + editId: {} + }, () => { + const { cumDeductStore: { doSearch, addForm } } = this.props; + const { monthValue, taxAgentId } = this.state; + doSearch({ + declareMonth: [monthValue], + taxAgentId: taxAgentId === "All" ? "" : taxAgentId + }); + addForm.resetForm(); }); - addForm.resetForm(); - }); - } else { - message.error("新增失败"); - } - }); + } else { + message.error("编辑成功"); + } + }); + } else { + API.createAddUpDeduction(payload).then(({ status }) => { + this.setState({ saveLoading: false }); + if (status) { + message.success("新增成功"); + this.setState({ + addVisible: false, + editId: {} + }, () => { + const { cumDeductStore: { doSearch, addForm } } = this.props; + const { monthValue, taxAgentId } = this.state; + doSearch({ + declareMonth: [monthValue], + taxAgentId: taxAgentId === "All" ? "" : taxAgentId + }); + addForm.resetForm(); + }); + } else { + message.error("新增失败"); + } + }); + } }; deleteSelectAddUpDeduction = () => { const { monthValue: declareMonth, taxAgentId, selectedKey } = this.state; @@ -354,8 +379,13 @@ export default class CumDeduct extends React.Component { const { cumDeductStore: { doSearch } } = this.props; if (key === "edit") { this.setState({ - addVisible: true, - editId: row.id + addVisible: true + }, () => { + API.getAddUpDeduction({ id: row.id }).then(({ status, data }) => { + if (status) { + this.setState({ editId: data }); + } + }); }); } else if (key === "delete") { const payload = { @@ -502,8 +532,8 @@ export default class CumDeduct extends React.Component { onClick={() => { this.setState({ addVisible: true, - editId: "" - }); + editId: {} + },()=>addForm.resetForm()); }}> 新建 , @@ -723,12 +753,12 @@ export default class CumDeduct extends React.Component { measure="%" title={ { const { baseInfo } = this.addItemRef.state; const bool = _.every(_.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId"]), v => !_.isEmpty(v)); - if (!bool) { + if (!bool && _.isEmpty(editId)) { Modal.warning({ title: "信息确认", content: "必要信息不完整,红色*为必填项!" @@ -739,7 +769,7 @@ export default class CumDeduct extends React.Component { ..._.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId", "taxAgentName"]), ...addForm.getFormParams() }; - this.createAddUpDeduction(payload); + this.handleSaveDeduction(payload); }} editable={!!addVisible} showOperateBtn={showOperateBtn} @@ -766,7 +796,7 @@ export default class CumDeduct extends React.Component { setSlideVisiable(false); this.setState({ addVisible: false, - editId: "" + editId: {} }); }} showMask={true} @@ -774,7 +804,7 @@ export default class CumDeduct extends React.Component { setSlideVisiable(false); this.setState({ addVisible: false, - editId: "" + editId: {} }); }} /> diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/index.js b/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/index.js index 265385d2..bd4241e2 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/index.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/cumSituation/index.js @@ -30,6 +30,7 @@ export default class CumSituation extends React.Component { visiable: false, inited: false, monthValue: moment(new Date()).format("YYYY"), + taxYearMonth: moment(new Date()).format("YYYY-MM"), taxAgentId: "All", modalParam: { taxYearMonth: "" @@ -202,14 +203,6 @@ export default class CumSituation extends React.Component { setStep(0); } - onOperatesClick = (record, index, operate, flag) => { - switch (operate.index.toString()) { - case "0": // 查看明细 - this.onEdit(record); - break; - } - }; - showColumn = () => { const { cumSituationStore: { tableStore } } = this.props; tableStore.setColSetVisible(true); @@ -360,7 +353,7 @@ export default class CumSituation extends React.Component { render() { const { cumSituationStore, taxAgentStore } = this.props; - const { slideSelectedKey, addVisible, editId, saveLoading } = this.state; + const { slideSelectedKey, addVisible, editId, saveLoading, taxYearMonth } = this.state; const { loading, dataSource, @@ -713,7 +706,8 @@ export default class CumSituation extends React.Component { return; } const payload = { - ..._.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId", "taxAgentName"]), + taxYearMonth: baseInfo.declareMonth, + ..._.pick(baseInfo, ["taxAgentId", "employeeId", "taxAgentName"]), ...addForm.getFormParams() }; this.createAddUpSituation(payload); diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/otherDeduct/editSlideContent.js b/pc4mobx/hrmSalary/pages/dataAcquisition/otherDeduct/editSlideContent.js index 96d3f6b4..dcb1709d 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/otherDeduct/editSlideContent.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/otherDeduct/editSlideContent.js @@ -144,7 +144,7 @@ export default class EditSlideContent extends React.Component { {currentRecord.username} - 申报月份 + 税款所属期
- 申报月份: + 税款所属期: { + handleCreateData = (payload) => { + const { editId }= this.state; this.setState({ saveLoading: true }); - API.createData(payload).then(({ status }) => { - this.setState({ saveLoading: false }); - if (status) { - message.success("新增成功"); - this.setState({ - addVisible: false, - editId: "" - }, () => { - const { otherDeductStore: { doSearch, addForm } } = this.props; - const { monthValue, taxAgentId } = this.state; - doSearch({ - declareMonth: [monthValue], - taxAgentId: taxAgentId === "All" ? "" : taxAgentId + if (!_.isEmpty(editId)) { + API.editData({ ...payload, id: editId.id }).then(({ status }) => { + this.setState({ saveLoading: false }); + if (status) { + message.success("编辑成功"); + this.setState({ + addVisible: false, + editId: {} + }, () => { + const { otherDeductStore: { doSearch, addForm } } = this.props; + const { monthValue, taxAgentId } = this.state; + doSearch({ + declareMonth: [monthValue], + taxAgentId: taxAgentId === "All" ? "" : taxAgentId + }); + addForm.resetForm(); }); - addForm.resetForm(); - }); - } else { - message.error("新增失败"); - } - }); + } else { + message.error("编辑失败"); + } + }); + } else { + API.createData(payload).then(({ status }) => { + this.setState({ saveLoading: false }); + if (status) { + message.success("新增成功"); + this.setState({ + addVisible: false, + editId: {} + }, () => { + const { otherDeductStore: { doSearch, addForm } } = this.props; + const { monthValue, taxAgentId } = this.state; + doSearch({ + declareMonth: [monthValue], + taxAgentId: taxAgentId === "All" ? "" : taxAgentId + }); + addForm.resetForm(); + }); + } else { + message.error("新增失败"); + } + }); + } }; handleOperate = ({ key }, row) => { const { monthValue: declareMonth, taxAgentId } = this.state; const { otherDeductStore: { doSearch } } = this.props; if (key === "edit") { this.setState({ - addVisible: true, - editId: row.id + addVisible: true + },()=>{ + API.getData({ id: row.id }).then(({ status, data }) => { + if (status) { + this.setState({ editId: data }); + } + }); }); } else if (key === "delete") { const payload = { @@ -487,8 +516,8 @@ export default class OtherDeduct extends React.Component { onClick={() => { this.setState({ addVisible: true, - editId: "" - }); + editId: {} + },()=>addForm.resetForm()); }}> 新建 , @@ -694,11 +723,11 @@ export default class OtherDeduct extends React.Component { measure="%" title={ { const { baseInfo } = this.addItemRef.state; const bool = _.every(_.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId"]), v => !_.isEmpty(v)); - if (!bool) { + if (!bool && _.isEmpty(editId)) { Modal.warning({ title: "信息确认", content: "必要信息不完整,红色*为必填项!" @@ -709,7 +738,7 @@ export default class OtherDeduct extends React.Component { ..._.pick(baseInfo, ["declareMonth", "taxAgentId", "employeeId", "taxAgentName"]), ...addForm.getFormParams() }; - this.createData(payload); + this.handleCreateData(payload); }} loading={saveLoading} editable={!!addVisible} @@ -736,7 +765,7 @@ export default class OtherDeduct extends React.Component { setSlideVisiable(false); this.setState({ addVisible: false, - editId: "" + editId: {} }); }} showMask={true} @@ -744,7 +773,7 @@ export default class OtherDeduct extends React.Component { setSlideVisiable(false); this.setState({ addVisible: false, - editId: "" + editId: {} }); }} />}