Ver Fonte

feat: 修改select选择后会变多的问题

sunxiao há 1 semana atrás
pai
commit
373da0c477
1 ficheiros alterados com 7 adições e 5 exclusões
  1. 7 5
      src/views/control/components/TheEchartPanel.vue

+ 7 - 5
src/views/control/components/TheEchartPanel.vue

@@ -112,8 +112,9 @@ const handleSwitchTab = (index) => {
 // select option change
 const handleSelectOptions = (selectOptionList) => {
   let tempArr = selectOptionList;
+  console.log( "selectOptionList", selectOptionList );
   if ( activeIndex.value === 0 ) {
-    if ( selectOptionList.length <= 1 && selectOptionList.every(item => item > 11) ) {
+    if ( selectOptionList.length <= 1 && selectOptionList.every(item => item > 21) ) {
       const [item] = selectOptionList;
       if ( (item == 22 || item == 23) || (!item && item != 0) ) {
         selectOptions.value.forEach(item => {
@@ -132,13 +133,14 @@ const handleSelectOptions = (selectOptionList) => {
     }
     
     if ( selectOptionList.length > 3 ) {
-      selectValue.value = tempArr.slice(0, -1);
+      const newArr = tempArr.slice(0, -1);
+      selectValue.value = newArr;
       return message.warning("数据看板最大选择项为3个")
     }
     
     localStorage.setItem('selectValue', JSON.stringify(tempArr));
   }
-
+ 
   selectValue.value = tempArr;
 
   activeIndex.value === 0 ? initWaterEchart() : intiCoefficientEchartData();
@@ -147,7 +149,6 @@ const handleSelectOptions = (selectOptionList) => {
 const initWaterEchart = async () => {
   
   const tempArr = [];
-  
   const tempResult = selectValue.value.map(key => {
     if (key == 22 || key == 23) return null;
     const data = echartDataSource.value[key] || [];
@@ -158,6 +159,7 @@ const initWaterEchart = async () => {
       data
     });
   }).filter(Boolean);
+  console.log( "tempResult", tempResult );
 
   const xAxis = tempArr.flat(Infinity).reduce((acc, curr) => {
     if (!acc.some(item => item.time === curr.time)) {
@@ -212,7 +214,7 @@ const getWaterEchartOptions = ({ data, xAxis = [] }) => {
     });
   }
 
-  if (selectValue.value.includes('13')) {
+  if (selectValue.value.includes('23')) {
     const data = xAxis.map(time => [time, props.htfksdTwo]);
     series.push({
       name: '南池-后反馈设定',