增加联动
This commit is contained in:
		
							parent
							
								
									860a3d4c6e
								
							
						
					
					
						commit
						610ef6fc11
					
				@ -249,7 +249,9 @@ class BI013RiskAnalysisModel extends React.Component {
 | 
			
		||||
        // 你可以根据params执行任何你想做的操作,例如:
 | 
			
		||||
        if (params.componentType === 'series') {
 | 
			
		||||
          if (params.name == '一级') {
 | 
			
		||||
            that.chart13(that.subtractRandomNotLessThanSelf(that.state.ret.Data.CHARTLIST[1]))
 | 
			
		||||
            let newData = that.state.ret.Data.CHARTLIST[1];
 | 
			
		||||
            that.subtractRandomNotLessThanSelf(newData);
 | 
			
		||||
            that.chart13(newData)
 | 
			
		||||
          } else if (params.name == '二级') {
 | 
			
		||||
            that.subtractRandomNotLessThanSelf(that.state.ret.Data.CHARTLIST[1]);
 | 
			
		||||
          } else if (params.name == '三级') {
 | 
			
		||||
@ -872,37 +874,23 @@ class BI013RiskAnalysisModel extends React.Component {
 | 
			
		||||
        }, true);
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
  subtractRandomNotLessThanSelf = (data) => {
 | 
			
		||||
  subtractRandomNotLessThanSelf = (obj) => {
 | 
			
		||||
    function getRandomNotLessThan(num) {
 | 
			
		||||
      return Math.floor(Math.random() * num) + num;
 | 
			
		||||
      return Math.floor(Math.random() * num);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 处理数组的情况
 | 
			
		||||
    if (Array.isArray(data)) {
 | 
			
		||||
      return data.map(item => {
 | 
			
		||||
        if (typeof item === 'number') {
 | 
			
		||||
          const randomSubtraction = getRandomNotLessThan(item);
 | 
			
		||||
          return item - randomSubtraction;
 | 
			
		||||
        }
 | 
			
		||||
        // 同样地,这里假设对象有一个名为value的数字属性需要处理
 | 
			
		||||
        else if (typeof item === 'object' && typeof item.value === 'number') {
 | 
			
		||||
          const randomSubtraction = getRandomNotLessThan(item.value);
 | 
			
		||||
          return { ...item, value: item.value - randomSubtraction };
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
          return item;
 | 
			
		||||
        }
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
    // 处理非数组但为数字的情况
 | 
			
		||||
    else if (typeof data === 'number') {
 | 
			
		||||
      const randomSubtraction = getRandomNotLessThan(data);
 | 
			
		||||
      return data - randomSubtraction;
 | 
			
		||||
    }
 | 
			
		||||
    // 其他情况返回原数据
 | 
			
		||||
    else {
 | 
			
		||||
      return data;
 | 
			
		||||
    for (let key in obj) {
 | 
			
		||||
      if (Array.isArray(obj[key])) {
 | 
			
		||||
        obj[key] = obj[key].map(number => {
 | 
			
		||||
          if (typeof number === 'number') {
 | 
			
		||||
            const randomSubtraction = getRandomNotLessThan(number);
 | 
			
		||||
            return Math.floor(number - randomSubtraction); // 确保结果也为整数
 | 
			
		||||
          } else {
 | 
			
		||||
            return number;
 | 
			
		||||
          }
 | 
			
		||||
        });
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return obj;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //显示详情弹窗
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user