custom/陕西万众-薪资账套薪资核算配置

新增模板查询功能
This commit is contained in:
黎永顺 2024-01-05 18:56:03 +08:00
parent 8361220614
commit bc1fd3f5dc
3 changed files with 39 additions and 15 deletions

View File

@ -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);
};

View File

@ -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 {
<WeaTab
datas={tabInfo} keyParam="tabKey" selectedKey={selectedKey} showAddBtn
buttons={[
<WeaButtonIcon buttonType="batchEdit" type="primary"/>,
<WeaButtonIcon buttonType="batchEdit" type="primary"
onClick={() => this.handleTabEdit(selectedKey, "edit")}/>,
<div>
<span>{getLabel(542604, "薪资所属月")}</span>
<span>{salarySobCycle.salaryMonth}</span>
@ -142,8 +155,10 @@ class Index extends Component {
{/*陕西万众项目-创建薪资核算模板弹框*/}
<SxwzEstablishTempDialog {...sxwzTemplDialog}
onCancel={(isRefresh) => this.setState({
sxwzTemplDialog: { ...sxwzTemplDialog, visible: false }
}, () => isRefresh && this.init())}/>
sxwzTemplDialog: { ...sxwzTemplDialog, visible: false, templateId: "" }
}, () => {
isRefresh && this.init(isRefresh);
})}/>
</div>
);
}

View File

@ -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 (
<WeaDialog
{...this.props} style={{ width: 480, height: 128 }} initLoadCss title={getLabel(1421, "新增")}
{...this.props} style={{ width: 480, height: 128 }} initLoadCss
buttons={[
<Button type="primary" onClick={this.save} loading={loading}>{getLabel(826, "确定")}</Button>
]}