diff --git a/pc4mobx/hrmSalary/apis/calculate.js b/pc4mobx/hrmSalary/apis/calculate.js index 90350f97..e115f84d 100644 --- a/pc4mobx/hrmSalary/apis/calculate.js +++ b/pc4mobx/hrmSalary/apis/calculate.js @@ -262,3 +262,7 @@ export const getListTemplate = (params) => { export const deleteTemplate = (params) => { return WeaTools.callApi("/api/bs/hrmsalary/salaryacct/acctresult/deleteTemplate", "get", params); }; +// 陕西万众-获取单个核算模板信息 +export const getTemplateForm = (params) => { + return WeaTools.callApi("/api/bs/hrmsalary/salaryacct/acctresult/templateForm", "get", params); +}; diff --git a/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalc/index.js b/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalc/index.js index 1507fb20..e4d84da9 100644 --- a/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalc/index.js +++ b/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalc/index.js @@ -24,7 +24,7 @@ class Index extends Component { this.state = { salarySobCycle: {}, showSearchAd: false, selectedKey: "calc%%", columnDesc: {}, formulaTd: "", showTotalCell: false, - sxwzTemplDialog: { visible: false, salaryAcctRecordId: "" }, + sxwzTemplDialog: { visible: false, salaryAcctRecordId: "", title: "", templateId: "" }, tabInfo: [ { tabKey: "calc%%", title: getLabel(111, "默认"), editable: false } ] @@ -40,7 +40,7 @@ class Index extends Component { this.calcTableRef.wrappedInstance.queryCalcResultList(); bool && this.openAdvanceSearch(); }; - init = async () => { + init = async (isRefresh) => { const { routeParams: { salaryAcctRecordId } } = this.props; const [salarySobCycle, columnDesc, confCode, sxwzTempl] = await Promise.all([ getSalarySobCycle({ salaryAcctRecordId }), getColumnDesc({ salaryAcctRecordId }), @@ -52,10 +52,14 @@ class Index extends Component { columnDesc: columnDesc.data, showTotalCell: confCode.data === "1", tabInfo: [ { tabKey: "calc%%", title: getLabel(111, "默认"), editable: false }, - ..._.map(_.keys(sxwzTempl.data), g => ({ - tabKey: `${g}%%${sxwzTempl.data[g]}`, title: g, editable: true + ..._.map(sxwzTempl.data, g => ({ + tabKey: `${g.templateName}%%${g.id}`, title: g.templateName, editable: true })) ] + }, () => { + isRefresh && this.setState({ + selectedKey: _.last(this.state.tabInfo).tabKey + }, () => this.calcTableRef.wrappedInstance.queryCalcResultList()); }); } }; @@ -78,15 +82,23 @@ class Index extends Component { if (status) { message.success(getLabel(502230, "删除成功")); const promise = this.init(); + this.setState({ selectedKey: "calc%%" }, () => { + this.calcTableRef.wrappedInstance.queryCalcResultList(); + }); } else { message.error(errormsg); } }).catch(() => message.destroy()); } }); - } else if (type === "add") { + } else if ((type === "add" || type === "edit") && tabKey !== "calc%%") { + const [__, templateId] = tabKey ? tabKey.split("%%") : ["", ""]; this.setState({ - sxwzTemplDialog: { ...sxwzTemplDialog, visible: true, salaryAcctRecordId } + sxwzTemplDialog: { + ...sxwzTemplDialog, visible: true, salaryAcctRecordId, + templateId: type === "edit" ? templateId : "", + title: type === "edit" ? getLabel(501169, "编辑") : getLabel(1421, "新增") + } }); } }; @@ -105,7 +117,8 @@ class Index extends Component { , + this.handleTabEdit(selectedKey, "edit")}/>,
{getLabel(542604, "薪资所属月")}: {salarySobCycle.salaryMonth} @@ -142,8 +155,10 @@ class Index extends Component { {/*陕西万众项目-创建薪资核算模板弹框*/} this.setState({ - sxwzTemplDialog: { ...sxwzTemplDialog, visible: false } - }, () => isRefresh && this.init())}/> + sxwzTemplDialog: { ...sxwzTemplDialog, visible: false, templateId: "" } + }, () => { + isRefresh && this.init(isRefresh); + })}/>
); } diff --git a/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalc/sxwzEstablishTempDialog.js b/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalc/sxwzEstablishTempDialog.js index 3167e62a..cf6d705d 100644 --- a/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalc/sxwzEstablishTempDialog.js +++ b/pc4mobx/hrmSalary/pages/calculate/doCalc/components/salaryEditCalc/sxwzEstablishTempDialog.js @@ -11,7 +11,7 @@ import { WeaSwitch } from "comsMobx"; import { Badge, Button, message } from "antd"; import { sxwzTempConditions } from "./condition"; import AddHeaderFieldsModal from "../../../../calculateDetail/acctResult/importModal/addHeaderFieldsModal"; -import { getImportField, saveTemplate } from "../../../../../apis/calculate"; +import { getImportField, getTemplateForm, saveTemplate } from "../../../../../apis/calculate"; import cs from "classnames"; const getLabel = WeaLocaleProvider.getLabel; @@ -30,9 +30,10 @@ class SxwzEstablishTempDialog extends Component { } async componentWillReceiveProps(nextProps, nextContext) { - const { calculateStore: { tmplForm, initTmplForm }, salaryAcctRecordId } = nextProps; + const { calculateStore: { tmplForm, initTmplForm }, salaryAcctRecordId, templateId } = nextProps; if (nextProps.visible !== this.props.visible && nextProps.visible) { const { data } = await getImportField({ salaryAcctRecordId }); + const { data: formData } = templateId ? await getTemplateForm({ templateId }) : { data: {} }; const { itemsByGroup } = data; this.setState({ conditions: _.map(sxwzTempConditions, item => ({ @@ -50,10 +51,14 @@ class SxwzEstablishTempDialog extends Component { checked: false })) }; - }) + }), + selectItems: formData.salaryItemIds || "" } }, () => { tmplForm.initFormFields(this.state.conditions); + tmplForm.updateFields({ + templateName: formData.templateName || "" + }); }); } else { this.setState({ @@ -105,7 +110,7 @@ class SxwzEstablishTempDialog extends Component { }; save = () => { const { headerFieldsDialog } = this.state; - const { calculateStore: { tmplForm } } = this.props; + const { calculateStore: { tmplForm }, templateId: id } = this.props; tmplForm.validateForm().then(f => { if (f.isValid) { const { selectItems } = headerFieldsDialog; @@ -114,7 +119,7 @@ class SxwzEstablishTempDialog extends Component { return; } const payload = { - ...tmplForm.getFormParams(), + ...tmplForm.getFormParams(), id, salaryItemIdList: selectItems.split(",") }; this.setState({ loading: true }); @@ -138,7 +143,7 @@ class SxwzEstablishTempDialog extends Component { const { calculateStore: { tmplForm } } = this.props; return ( {getLabel(826, "确定")} ]}