Bladeren bron

Merge branch 'need_pool49'

Karsa 6 maanden geleden
bovenliggende
commit
51b150a8be

+ 133 - 43
src/views/datasheet_manage/components/MixedTable.vue

@@ -597,61 +597,24 @@ export default {
       if(!haveRelationArr.length) return
 
       //去处理每一组关联的情况
-      haveRelationArr.forEach( async(relation) => {
+      haveRelationArr.forEach(relation => {
         const { relation_date,relation_edb,type } = relation;
   
         if((relation_date.key === key && cell.DataType === 1) || (relation_edb.key === key && cell.DataType === 2)) { //单元格类型不变只变值仍有关联关系 更新值
-
-          //类型4的表格插值才调接口刷数据 之后关联的有其他类型插值 区分一下
-          if(type === 4) {
-
-            //刷新插入值结果
-            let params = null;
-            if(relation_date.key === key && cell.DataType === 1) { //修改的是依赖日期格
-              let { EdbInfoId } = findCellByKey(this.config.data,relation.key)
-              params = {
-                EdbInfoId,
-                Date: cell.ShowValue
-              }
-    
-            } else if( relation_edb.key === key && cell.DataType === 2) { //修改的依赖指标格
-              let {ShowValue} = findCellByKey(this.config.data,relation_date.key)
-              params = {
-                EdbInfoId: cell.EdbInfoId,
-                Date: ShowValue
-              }
-            }
-    
-            const res = await sheetInterface.insertData(params)
-            if(res.Ret !==200) return
-  
-            //现在日期无值也不清除关系了
-            // !res.Data && this.updateInsertCell(relation.key);
-            
-            this.config.data.forEach(row => {
-              row.forEach(cell => {
-                if(cell.Uid === relation.key) {
-                    cell.DataType = relation.type;
-                    cell.ShowValue = res.Data;
-                    cell.Value = res.Data;
-                    cell.EdbInfoId = params.EdbInfoId;
-                    cell.DataTime = params.Date;
-                }
-              })
-            })
-          }
+          // 根据关系关联数组去更新每种单元格类型的值
+          this.updateRelationCell(relation,cell)
   
   
         }else {
           // 清除插入值单元格式和关联关系
-          this.updateInsertCell(relation.key);
+          this.clearInsertCell(relation.key);
         }
       })
  
     },
 
     // 清除插入值单元格式和关联关系
-    updateInsertCell(key) {
+    clearInsertCell(key) {
       this.config.data.forEach(row => {
         row.forEach(cell => {
           if(cell.Uid === key) {
@@ -669,6 +632,133 @@ export default {
       this.insertRelationArr.splice(relationIndex,1)
     },
 
+    /* 单元格更新时去更新有依赖关系单元格的值 目前只更4 5 7*/
+    updateRelationCell(relation,cell) {
+      const cellTypeMap = {
+        4: this.refreshRelationInsertCell,
+        5: this.refreshRelationByEdbInsertCell,
+        7: this.refreshRelationByEdbCalculateCell,
+      }
+
+      cellTypeMap[relation.type]&& cellTypeMap[relation.type](relation,cell)
+      
+    },
+
+    //关联类型4的单元格值刷新
+    async refreshRelationInsertCell({relation_date,relation_edb},cell) {
+        //刷新插入值结果
+        let params = null;
+        if(relation_date.key === key && cell.DataType === 1) { //修改的是依赖日期格
+          let { EdbInfoId } = findCellByKey(this.config.data,relation.key)
+          params = {
+            EdbInfoId,
+            Date: cell.ShowValue
+          }
+
+        } else if( relation_edb.key === key && cell.DataType === 2) { //修改的依赖指标格
+          let {ShowValue} = findCellByKey(this.config.data,relation_date.key)
+          params = {
+            EdbInfoId: cell.EdbInfoId,
+            Date: ShowValue
+          }
+        }
+
+        const res = await sheetInterface.insertData(params)
+        if(res.Ret !==200) return
+
+        //现在日期无值也不清除关系了
+        // !res.Data && this.clearInsertCell(relation.key);
+        
+        this.config.data.forEach(row => {
+          row.forEach(cell => {
+            if(cell.Uid === relation.key) {
+                cell.DataType = relation.type;
+                cell.ShowValue = res.Data;
+                cell.Value = res.Data;
+                cell.EdbInfoId = params.EdbInfoId;
+                cell.DataTime = params.Date;
+            }
+          })
+        })
+    },
+
+    //关联类型5的弹窗插值单元格值刷新
+    async refreshRelationByEdbInsertCell(relation,cell) {
+
+      let { EdbInfoId,Value } = findCellByKey(this.config.data,relation.key)
+
+      let params = {
+        EdbInfoId,
+        MoveForward: JSON.parse(Value).MoveForward,
+        DateChange: JSON.parse(Value).DateChange,
+        Date: cell.ShowValue
+      }
+      const res = await sheetInterface.getDateLatelyData(params)
+      if(res.Ret !== 200) return
+
+      let value = (res.Data.List&&res.Data.List.length)
+        ? res.Data.List.find(_ => _.DataTime===res.Data.Date) 
+          ? res.Data.List.find(_ => _.DataTime===res.Data.Date).Value.toString() 
+          : ''
+        : ''
+
+      this.config.data.forEach(row => {
+        row.forEach(cell => {
+          if(cell.Uid === relation.key) {
+              cell.ShowValue = value;
+              cell.ShowFormatValue = cell.ShowStyle ? transDecimalPlace(value,JSON.parse(cell.ShowStyle)) : '';
+          }
+        })
+      })
+       
+    },
+
+    //关联类型7的指标计算单元格值刷新
+    async refreshRelationByEdbCalculateCell(relation,cell) {
+      console.log(relation,cell)
+      
+      console.log(findCellByKey(this.config.data,relation.key))
+      let { Value } = findCellByKey(this.config.data,relation.key)
+
+      const {
+        Source,
+        Frequency,
+        Formula,
+        EdbInfoId,
+        MoveFrequency,
+        MoveType, 
+        Calendar,
+        MoveForward,
+        DateChange
+      } = JSON.parse(Value);
+
+      let params = {
+        DataTime: cell.ShowValue,
+        Source,
+        Frequency,
+        Formula,
+        EdbInfoId,
+        MoveFrequency,
+        MoveType, 
+        Calendar,
+        MoveForward,
+        DateChange,
+      }
+      const res = await sheetInterface.getMixedCalculateData(params)
+      if(res.Ret !== 200) return
+
+      let value = res.Data.ShowValue||"";
+
+      this.config.data.forEach(row => {
+        row.forEach(cell => {
+          if(cell.Uid === relation.key) {
+              cell.ShowValue = value;
+              cell.ShowFormatValue = cell.ShowStyle ? transDecimalPlace(value,JSON.parse(cell.ShowStyle)) : '';
+          }
+        })
+      })
+    },
+
     /* 输入公式的计算值 */
     async getValueByFormula(val) {
 
@@ -895,7 +985,7 @@ export default {
       // console.log(haveRelationArr)
 
       haveRelationArr.forEach(relation => {
-        !delCellIds.includes(relation)&&this.updateInsertCell(relation.key);
+        !delCellIds.includes(relation)&&this.clearInsertCell(relation.key);
       })
 
       this.insertRelationArr = this.insertRelationArr.filter(_ => !delCellIds.includes(_.key)&&!delCellIds.includes(_.relation_date.key)&&!delCellIds.includes(_.relation_edb.key))

+ 0 - 1
src/views/datasheet_manage/components/calculateEdbDia.vue

@@ -505,7 +505,6 @@ export default {
       if(res.Ret !== 200) return
 
       const { EdbInfoId,EdbInfoType,EdbName,Frequency,HaveOperaAuth } = res.Data;
-
       if(!HaveOperaAuth) return this.$message.warning(this.$t('MsgPrompt.no_edb_auth'))
 
       if(this.formData.source===1&&Frequency!=='月度') return this.$message.warning(this.$t('ETableChildren.only_select_msg') )