salary-management-front/pc4mobx/hrmSalary/pages/custom-pages/lingyue/vouncherSummary/acctBookDialog.js

85 lines
2.7 KiB
JavaScript
Raw Normal View History

2024-10-10 16:29:36 +08:00
/*
* 领悦二开
* 核算账簿-推送弹框
* @Author: 黎永顺
* @Date: 2024/10/10
* @Wechat:
* @Email: 971387674@qq.com
* @description:
*/
import React, { Component } from "react";
import { inject, observer } from "mobx-react";
2025-01-13 13:20:41 +08:00
import { WeaDialog, WeaLocaleProvider, WeaTools } from "ecCom";
2025-04-21 16:04:53 +08:00
import { getHszb } from "../../../../apis/custom-apis/lingyue";
2024-10-10 16:29:36 +08:00
import { acctBookConditions } from "./conditions";
import { getSearchs } from "../../../../util";
2025-04-21 16:04:53 +08:00
import { Button } from "antd";
import moment from "moment";
2024-10-10 16:29:36 +08:00
const getLabel = WeaLocaleProvider.getLabel;
2025-01-10 15:47:50 +08:00
const getKey = WeaTools.getKey;
2024-10-10 16:29:36 +08:00
@inject("LYStore")
@observer
class AcctBookDialog extends Component {
constructor(props) {
super(props);
this.state = { conditions: [] };
}
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.visible !== this.props.visible && nextProps.visible) this.acctBookForm();
if (nextProps.visible !== this.props.visible && !nextProps.visible) nextProps.LYStore.initAcctBookForm();
}
2025-04-21 16:04:53 +08:00
acctBookForm = async () => {
const { data } = await getHszb({ ffgsqc: decodeURI(WeaTools.getUrlParams().ffgsqc) });
2024-10-10 16:29:36 +08:00
this.setState({
conditions: _.map(acctBookConditions, item => ({
2025-01-10 15:47:50 +08:00
...item, items: _.map(item.items, o => {
if (getKey(o) === "zdrq") {
return { ...o, label: getLabel(o.lanId, o.label), value: moment().format("YYYY-MM-DD") };
2025-04-21 16:04:53 +08:00
} else if (getKey(o) === "zbbm") {
return {
...o, label: getLabel(o.lanId, o.label),
browserConditionParam: { ...o.browserConditionParam, replaceDatas: [data] }
};
2025-01-10 15:47:50 +08:00
}
return { ...o, label: getLabel(o.lanId, o.label) };
})
2024-10-10 16:29:36 +08:00
}))
}, () => {
const { LYStore: { acctBookForm } } = this.props;
acctBookForm.initFormFields(this.state.conditions);
});
};
save = () => {
const { LYStore: { acctBookForm } } = this.props;
acctBookForm.validateForm().then(f => {
if (f.isValid) {
this.props.onPushNotifications();
} else {
f.showErrors();
}
});
};
render() {
const { conditions } = this.state;
const { LYStore: { acctBookForm }, loading } = this.props;
return (
<WeaDialog
2025-04-21 16:04:53 +08:00
{...this.props} initLoadCss title={getLabel(111, "凭证推送")}
style={{ width: 480, height: _.reduce(conditions, (pre, cur) => (pre += cur.items.length), 0) * 47 + 33 }}
2024-10-10 16:29:36 +08:00
buttons={[
<Button type="primary" onClick={this.save} loading={loading}>{getLabel(111, "推送")}</Button>
]}
>
<div className="form-dialog-layout">{getSearchs(acctBookForm, conditions, 1, false)}</div>
</WeaDialog>
);
}
}
export default AcctBookDialog;