/* * Author: 黎永顺 * name: 新建自定义统计项目弹框 * Description: * Date: 2023/4/10 */ import React, { Component } from "react"; import { Button } from "antd"; import { WeaCheckbox, WeaDialog, WeaError, WeaFormItem, WeaHelpfulTip, WeaInput, WeaInputNumber, WeaLocaleProvider, WeaTable } from "ecCom"; import { statisticsItemGetform } from "../../../apis/statistics"; import "../index.less"; const { getLabel } = WeaLocaleProvider; class CustomStatisticsItemsModal extends Component { constructor(props) { super(props); this.state = { loading: false, columns: [], dataSource: [], formData: {} }; } componentWillReceiveProps(nextProps, nextContext) { if (nextProps.visible !== this.props.visible && nextProps.visible) { this.statisticsItemGetform(); } } statisticsItemGetform = (payload) => { statisticsItemGetform(payload).then(({ status, data }) => { if (status) { const { ruleData } = data; const { columns, data: dataSource } = ruleData; this.setState({ columns, dataSource }); } }); }; handleChangeColumnCheckBox = (key, value, id) => { const { dataSource } = this.state; this.setState({ dataSource: _.map(dataSource, it => { if (it.id === id) { return { ...it, [key]: Number(value) }; } return { ...it }; }) }); }; handleChangeColumnAllChecked = (key, val) => { const { dataSource } = this.state; this.setState({ dataSource: _.map(dataSource, it => { return { ...it, [key]: Number(val) }; }) }); }; handleChangeColumnM2MValue = (key, value, id) => { const { dataSource } = this.state; this.setState({ dataSource: _.map(dataSource, it => { if (it.id === id) { return { ...it, [key]: value }; } return { ...it }; }) }); }; render() { const { loading, columns, dataSource, formData } = this.state; const { itemName } = formData; const cols = _.map(columns, it => { const { text, column } = it; if (column === "ruleName" || column === "ratio" || column === "m2m" || column === "y2y") { const key = column === "ruleName" ? "total" : column; return { ...it, title: !!child[`${key}Value`])} onChange={val => this.handleChangeColumnAllChecked(`${key}Value`, val)} /> {text} , render: (txt, record) => { return this.handleChangeColumnCheckBox(`${key}Value`, val, record.id)} /> {column === "ruleName" ? record["ruleName"] : text} ; } }; } else if (column === "m2mLimit") { return { ...it, title: {text} 10%,差值和增幅标记为红色,增幅<-10%标记为绿色")} placement="top" width={200}/> , render: (txt, record) => { return !!record["m2mValue"] && this.handleChangeColumnM2MValue(`${column.replace("Limit", "")}${type === "min" ? "LowerLimit" : "UpperLimit"}`, val, record.id)} />; } }; } else if (column === "y2yLimit") { return { ...it, title: {text} 10%,差值和增幅标记为红色,增幅<-10%标记为绿色")} placement="top" width={200}/> , render: (txt, record) => { return !!record["y2yValue"] && this.handleChangeColumnM2MValue(`${column.replace("Limit", "")}${type === "min" ? "LowerLimit" : "UpperLimit"}`, val, record.id)} />; } }; } }); return ( {getLabel(111, "新建自定义统计项目")} } style={{ width: 900, height: 500 }} className="statisticItemsWrapper" >
); } } export default CustomStatisticsItemsModal; /* * Author: 黎永顺 * Description: 区间设置 * Params: * Date: 2023/4/23 */ const IntervalSettingsComp = (props) => { const { LowerLimit, UpperLimit, onChange } = props; return
onChange("min", val)}/> {`% <${getLabel(111, "增幅")}<`} onChange("max", val)}/> %
; };