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