/* * Author: 黎永顺 * name: 同步到薪资账套 * Description: * Date: 2023/8/31 */ import React, { Component } from "react"; import { inject, observer } from "mobx-react"; import { WeaDialog, WeaLocaleProvider } from "ecCom"; import { Button, message } from "antd"; import { getSearchs } from "../../util"; import { getSalarySobBySalaryItem, syncSalaryItemToSalarySobItem } from "../../apis/item"; import { salarySetConditions } from "./columns"; const getLabel = WeaLocaleProvider.getLabel; @inject("salaryItemStore") @observer class SyncToSalaryAccountSetDialog extends Component { constructor(props) { super(props); this.state = { loading: false, conditions: [] }; } componentWillReceiveProps(nextProps, nextContext) { const { salaryItemStore: { salarySetform } } = nextProps; if (nextProps.visible !== this.props.visible && nextProps.visible) this.getSalarySobBySalaryItem(nextProps); if (nextProps.visible !== this.props.visible && !nextProps.visible) salarySetform.resetForm(); } getSalarySobBySalaryItem = (props) => { const { id, salaryItemStore: { salarySetform } } = props; getSalarySobBySalaryItem({ id }).then(({ status, data }) => { if (status) { this.setState({ conditions: _.map(salarySetConditions, item => { return { ...item, items: _.map(item.items, o => ({ ...o, options: _.map(data, it => ({ key: it.id, showname: it.content })) })) }; }) }, () => { salarySetform.initFormFields(this.state.conditions); }); } }); }; save = () => { const { salaryItemStore: { salarySetform }, id: salaryItemId } = this.props; salarySetform.validateForm().then(f => { if (f.isValid) { const { salarySobIds } = salarySetform.getFormParams(); this.setState({ loading: true }); syncSalaryItemToSalarySobItem({ salaryItemId, salarySobIds: salarySobIds.split(",") }) .then(({ status, errormsg }) => { this.setState({ loading: false }); if (status) { message.success(getLabel(38462, "同步成功!")); this.props.onCancel(); } else { message.error(errormsg || getLabel(81556, "同步失败!")); } }).catch(() => this.setState({ loading: false })); } else { f.showErrors(); } }); }; render() { const { salaryItemStore: { salarySetform } } = this.props; const { conditions } = this.state; return ( {getLabel(537558, "确定")}]} >
{getSearchs(salarySetform, conditions, 1)}
); } } export default SyncToSalaryAccountSetDialog;