diff --git a/pc4mobx/hrmSalary/pages/salary/components/personalScope.js b/pc4mobx/hrmSalary/pages/salary/components/personalScope.js index 451fbda8..b051642f 100644 --- a/pc4mobx/hrmSalary/pages/salary/components/personalScope.js +++ b/pc4mobx/hrmSalary/pages/salary/components/personalScope.js @@ -30,7 +30,9 @@ class PersonalScope extends Component { this.state = { searchValue: "", selectedKey: "listInclude", rowKeys: [], loading: false, extEmpsWitch: "1", //非系统人员开关, 1: 开启, 0:关闭 - personalAddModal: { visible: false, externalVisible: false, title: getLabel(111, "关联人员"), includeType: "" }, + personalAddModal: { + visible: false, externalVisible: false, title: getLabel(111, "关联人员"), includeType: "", record: {} + }, importParams: { visible: false, title: getLabel(111, "数据导入"), nextloading: false, importResult: {}, imageId: "", link: `/api/bs/hrmsalary/taxAgent/range/downloadTemplate?taxAgentId=${props.taxAgentId}`, @@ -89,11 +91,11 @@ class PersonalScope extends Component { * Params: * Date: 2022/11/30 */ - handleAddPersonal = () => { + handleAddPersonal = (record = {}) => { const { personalAddModal, selectedKey } = this.state; this.setState({ personalAddModal: { - ...personalAddModal, + ...personalAddModal, record, visible: selectedKey !== "listExt", externalVisible: selectedKey === "listExt", includeType: selectedKey === "listInclude" ? 1 : 0 @@ -166,7 +168,7 @@ class PersonalScope extends Component { disabled={_.isEmpty(rowKeys)} onClick={this.taxAgentRangeDelete} />, - , + this.handleAddPersonal()}/>, this.setState({ rowKeys })} + onEditScope={this.handleAddPersonal} /> {/*非系统人员添加*/} this.personalScopeTableRef.getPersonalScopeList()} onCancel={(callback) => this.setState({ - personalAddModal: { ...personalAddModal, visible: false, includeType: "" } + personalAddModal: { ...personalAddModal, visible: false, includeType: "", record: {} } }, () => callback && callback()) } /> diff --git a/pc4mobx/hrmSalary/pages/salary/components/personalScopeModal.js b/pc4mobx/hrmSalary/pages/salary/components/personalScopeModal.js index 3e649880..040db1e1 100644 --- a/pc4mobx/hrmSalary/pages/salary/components/personalScopeModal.js +++ b/pc4mobx/hrmSalary/pages/salary/components/personalScopeModal.js @@ -9,7 +9,7 @@ import { inject, observer } from "mobx-react"; import { WeaSwitch } from "comsMobx"; import { WeaCheckbox, WeaDialog, WeaFormItem, WeaLocaleProvider, WeaSearchGroup, WeaTools } from "ecCom"; import { Button, message } from "antd"; -import { getTaxAgentRangeForm, taxAgentRangeSave } from "../../../apis/taxAgent"; +import { getTaxAgentRangeForm, taxAgentRangeEdit, taxAgentRangeSave } from "../../../apis/taxAgent"; import { personScopeConditions, scopeSelectLinkageDatas } from "./constants"; const getKey = WeaTools.getKey; @@ -26,11 +26,12 @@ class PersonalScopeModal extends Component { } componentWillReceiveProps(nextProps, nextContext) { - if (nextProps.visible !== this.props.visible && nextProps.visible) this.getTaxAgentRangeForm(); + if (nextProps.visible !== this.props.visible && nextProps.visible) this.getTaxAgentRangeForm(nextProps); if (nextProps.visible !== this.props.visible && !nextProps.visible) this.props.taxAgentStore.initPersonScopeForm(); } - getTaxAgentRangeForm = () => { + getTaxAgentRangeForm = (props) => { + const { record } = props; getTaxAgentRangeForm().then(({ status, data }) => { if (status) { const { employeeStatus, targetTypeList } = data; @@ -39,16 +40,39 @@ class PersonalScopeModal extends Component { ...item, items: _.map(item.items, o => { if (getKey(o) === "employeeStatus") { return { - ...o, label: getLabel(o.lanId, o.label), + ...o, label: getLabel(o.lanId, o.label), value: !_.isEmpty(record) ? record.status : "", options: _.map(employeeStatus, it => ({ key: it.id, showname: it.name })) }; } return { - ...o, label: getLabel(o.lanId, o.label), + ...o, label: getLabel(o.lanId, o.label), viewAttr: !_.isEmpty(record) ? 1 : 3, options: _.map(targetTypeList, it => ({ - key: it.id, showname: it.name, selected: it.id === "EMPLOYEE" + key: it.id, showname: it.name, + selected: !_.isEmpty(record) ? it.id === record.targetType : it.id === "EMPLOYEE" })), - selectLinkageDatas: { ...scopeSelectLinkageDatas } + selectLinkageDatas: { + ..._.reduce(_.keys(scopeSelectLinkageDatas), (pre, cur) => { + if (cur !== "SQL") { + return { + ...pre, + [cur]: { + ...scopeSelectLinkageDatas[cur], + browserConditionParam: { + ...scopeSelectLinkageDatas[cur].browserConditionParam, + isSingle: true, + replaceDatas: !_.isEmpty(record) ? [{ + id: String(record.targetId), + name: record.targetName + }] : [] + } + } + }; + } + return { + ...pre, [cur]: { ...scopeSelectLinkageDatas[cur], value: !_.isEmpty(record) ? record.target : "" } + }; + }, {}) + } }; }) })) @@ -57,20 +81,21 @@ class PersonalScopeModal extends Component { }); }; taxAgentRangeSave = () => { - const { taxAgentStore: { personScopeForm } } = this.props; + const { taxAgentStore: { personScopeForm }, record = {} } = this.props; personScopeForm.validateForm().then(f => { if (f.isValid) { const { employeeStatus, targetType, target } = personScopeForm.getFormParams(); const { includeType, taxAgentId } = this.props; const payload = { - includeType, taxAgentId, employeeStatus: employeeStatus.split(","), + includeType, taxAgentId, employeeStatus: employeeStatus.split(","), id: record.id, targetParams: _.map(target.split(","), it => ({ targetType, targetId: targetType === "SQL" ? "0" : it, target: targetType === "SQL" ? target : "" })) }; this.setState({ loading: true }); - taxAgentRangeSave(payload).then(({ status, errormsg }) => { + const API = !_.isEmpty(record) ? taxAgentRangeEdit : taxAgentRangeSave; + API(payload).then(({ status, errormsg }) => { this.setState({ loading: false }); if (status) { message.success(getLabel(111, "操作成功!")); diff --git a/pc4mobx/hrmSalary/pages/salary/components/personalScopeTable.js b/pc4mobx/hrmSalary/pages/salary/components/personalScopeTable.js index 87bf46cb..e09e2ea9 100644 --- a/pc4mobx/hrmSalary/pages/salary/components/personalScopeTable.js +++ b/pc4mobx/hrmSalary/pages/salary/components/personalScopeTable.js @@ -64,7 +64,10 @@ class PersonalScopeTable extends Component { columns: _.map(columns, item => { return { ...item, - render: (text) => { + render: (text, record) => { + if (item.dataIndex === "targetName") { + return this.props.onEditScope(record)}>{text}; + } return {text}; } };