86 lines
2.9 KiB
JavaScript
86 lines
2.9 KiB
JavaScript
/*
|
|
* 数据采集-其他免税扣除
|
|
* 明细设置弹框
|
|
* @Author: 黎永顺
|
|
* @Date: 2024/12/24
|
|
* @Wechat:
|
|
* @Email: 971387674@qq.com
|
|
* @description:
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { inject, observer } from "mobx-react";
|
|
import { WeaDialog, WeaLocaleProvider } from "ecCom";
|
|
import { WeaSwitch } from "comsMobx";
|
|
import FormInfo from "../../../components/FormInfo";
|
|
import { taxDetailSettingsConditions } from "./columns";
|
|
import * as API from "../../../apis/otherDeduct";
|
|
import { Button, message } from "antd";
|
|
import { toDecimal_n } from "../../../util";
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
@inject("otherDeductStore")
|
|
@observer
|
|
class DetailSettingsDialog extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
loading: false
|
|
};
|
|
}
|
|
|
|
componentWillReceiveProps(nextProps, nextContext) {
|
|
if (nextProps.visible !== this.props.visible && nextProps.visible) {
|
|
this.props.otherDeductStore.settingsForm.initFormFields(taxDetailSettingsConditions[nextProps.dataType]);
|
|
} else if (nextProps.visible !== this.props.visible && !nextProps.visible) {
|
|
this.props.otherDeductStore.settingsForm.resetForm();
|
|
}
|
|
}
|
|
|
|
save = () => {
|
|
const { otherDeductStore: { settingsForm }, mainId } = this.props;
|
|
settingsForm.validateForm().then(f => {
|
|
if (f.isValid) {
|
|
const payload = settingsForm.getFormParams();
|
|
this.setState({ loading: true });
|
|
API.saveFreeIncome({ ...payload, mainId }).then(({ status, errormsg }) => {
|
|
this.setState({ loading: false });
|
|
if (status) {
|
|
message.success(getLabel(111, "操作成功!"));
|
|
this.props.onCancel(this.props.onSuccess());
|
|
} else {
|
|
message.error(errormsg);
|
|
}
|
|
});
|
|
} else {
|
|
f.showErrors();
|
|
}
|
|
});
|
|
};
|
|
|
|
render() {
|
|
const { otherDeductStore: { settingsForm }, dataType } = this.props, { loading } = this.state;
|
|
const itemRender = {
|
|
freeAmount: (field, textAreaProps, form, formParams) => {
|
|
return (<WeaSwitch fieldConfig={{ ...field, ...textAreaProps }}
|
|
form={form} formParams={formParams}
|
|
onBlur={(v) => v && form.updateFields({ freeAmount: { value: toDecimal_n(v, 2) } })}/>);
|
|
}
|
|
};
|
|
return (
|
|
<WeaDialog
|
|
{...this.props} style={{ width: 480, height: 174 }} initLoadCss title={getLabel(111, "明细设置")}
|
|
buttons={[
|
|
<Button type="primary" onClick={this.save} loading={loading}>{getLabel(111, "确定")}</Button>,
|
|
<Button type="ghost" onClick={this.props.onCancel}>{getLabel(111, "取消")}</Button>
|
|
]}
|
|
>
|
|
<FormInfo className="form-dialog-layout" center={false} itemRender={itemRender}
|
|
form={settingsForm} formFields={taxDetailSettingsConditions[dataType] || []}/>
|
|
</WeaDialog>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default DetailSettingsDialog;
|