71 lines
2.1 KiB
JavaScript
71 lines
2.1 KiB
JavaScript
/*
|
|
* Author: 黎永顺
|
|
* name: 统计弹框
|
|
* Description:
|
|
* Date: 2023/4/10
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { Button, message, Modal } from "antd";
|
|
import { WeaDialog, WeaLocaleProvider } from "ecCom";
|
|
import { reportStatisticsReportSave } from "../../../apis/ruleconfig";
|
|
import "../index.less";
|
|
|
|
const { getLabel } = WeaLocaleProvider;
|
|
|
|
class StatisticsModal extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
loading: false
|
|
};
|
|
}
|
|
|
|
handleSaveReportList = () => {
|
|
const { form, id, onCancel } = this.props;
|
|
form.validateForm().then(f => {
|
|
if (f.isValid) {
|
|
const { dimensionIds, reportName } = form.getFormParams();
|
|
const payload = { id, reportName, dimensionIds: dimensionIds.split(",") };
|
|
this.setState({ loading: true });
|
|
reportStatisticsReportSave(payload).then(({ status, errormsg }) => {
|
|
this.setState({ loading: false });
|
|
if (status) {
|
|
onCancel(true);
|
|
message.success(getLabel(22619, "保存成功"));
|
|
form.resetForm();
|
|
} else {
|
|
message.error(errormsg || getLabel(22620, "保存失败"));
|
|
}
|
|
}).catch(() => this.setState({ loading: false }));
|
|
} else {
|
|
Modal.warning({
|
|
title: getLabel(131329, "信息确认"),
|
|
content: getLabel(111, "必要信息不完整,红色*为必填项!")
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
render() {
|
|
const { loading } = this.state;
|
|
const { typeKey, onCancel } = this.props;
|
|
const buttons = typeKey === "addReport" ? [
|
|
<Button type="primary" onClick={this.handleSaveReportList} loading={loading}>{getLabel(111, "保存")}</Button>
|
|
] : [];
|
|
return (
|
|
<WeaDialog
|
|
{...this.props} hasScroll
|
|
style={typeKey === "addReport" ? { width: 600 } : { width: 640, height: 540 }}
|
|
buttons={buttons}
|
|
onCancel={onCancel}
|
|
initLoadCss
|
|
className="dimensionModalWrapper"
|
|
>
|
|
{this.props.children}
|
|
</WeaDialog>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default StatisticsModal;
|