Procházet zdrojové kódy

全局公式增加判断公式保存。

duy před 3 dny
rodič
revize
d9cce73936
1 změnil soubory, kde provedl 241 přidání a 3 odebrání
  1. 241 3
      src/views/formula/edit1.vue

+ 241 - 3
src/views/formula/edit1.vue

@@ -213,7 +213,24 @@
           <template v-else>
             <div class="flex" >
               <div class=" flex-d-c"  style="width:40%">
-                <component ref="dynamiccomponent" v-bind:is="componentMap[item.name]" :formulainfo="item" :curele="equationSelectEle" :formulamap="formulaMap" @uncheck="unCheckEleComp" class="flex1"></component>
+                <component 
+                  ref="dynamiccomponent" 
+                  v-bind:is="componentMap[item.name]" 
+                  :formulainfo="item" :curele="equationSelectEle" 
+                  :formulamap="formulaMap" 
+                    :map="formulaDetailMap"
+                  @uncheck="unCheckEleComp" 
+                  class="flex1"
+                  :moreConditions="moreConditions" 
+                  :isMore="isMore"
+                  :isGetData="isGetData"
+                  :dataListGet="dataListGet"
+                  :isDataChange="isDataChange"
+                  :dataForm="dataForm"
+                  :remark="remark"
+                  
+                  >
+                </component>
                 <div class="flex1" v-show="item.showSelectEle" style="margin-top:10px;margin-bottom:30px">
                   <div class="flex">
                       <el-input
@@ -491,7 +508,7 @@ import {formulaStringToArray} from "./formulaStringToArray"
 
 import draggable from 'vuedraggable'
 
-
+import {formatArrayMore,restoreArrayMore,generateResult} from './component/funComponent/multiIfElseTools'
 export default {
   components: {
     draggable,
@@ -663,7 +680,14 @@ export default {
       inputele:'',
       inputelepian:'',
       inputelejudge:'',
-
+      moreConditions:[],//多条件判断数组
+      isMore:false,//是否多条件
+      isGetData:false,//是否获取数据
+      dataListGet:[],//获取的数据列表
+      isDataChange:false,//数据是否变化
+      dataForm:'',
+      remark:'',
+      formulaDetailMap:{},//公式详情map
 
     };
   },
@@ -1425,6 +1449,185 @@ export default {
     saveFormula(){
       console.log('保存1',this.pid);
       // let obj = formulaArrayToString(this.processFormula,this.resultFormula);
+      if(this.$refs.dynamiccomponent&&this.$refs.dynamiccomponent.length>0&&this.$refs.dynamiccomponent[0]&& this.$refs.dynamiccomponent[0].symbol=='more'){
+        //多条件保存公式
+
+        console.log('this.$refs.conditionList[0]',this.$refs.dynamiccomponent[0].conditionList);
+        let resMore=formatArrayMore(this.$refs.dynamiccomponent[0].conditionList);
+        const resJson=generateResult(this.$refs.dynamiccomponent[0].conditionList);
+        let remark=this.$refs.dynamiccomponent[0].remark;
+        console.log(remark,'remark');
+
+        console.log(resJson,'resJson');
+        
+     
+            if(this.formulaid){
+              updateFormula({
+                id:this.formulaid,
+                formula:'',
+                formulas:resMore,
+                remark:remark,
+                nodeId:this.nodeid,
+                elementId:this.eleid,
+                scale:this.isRetain?this.retainNum:'',
+                number:number,
+                map:JSON.stringify(resJson),
+                scope:this.globaltype,
+                // projectId:this.curProjiect.id||this.projectId,
+                projectId:this.curProjiect.id||this.pid,
+                dev:deviationRangeText
+              }).then(()=>{
+                this.formulaStringToArray();
+                this.$message({
+                  type: "success",
+                  message: "修改成功"
+                });
+              })
+            }else{
+              saveFormula({
+                formula:'',
+                formulas:resMore,
+                remark:remark,
+                nodeId:this.nodeid,
+                elementId:this.eleid,
+                scale:this.isRetain?this.retainNum:'',
+                number:number,
+                map:JSON.stringify(resJson),
+                scope:this.globaltype,
+                dev:deviationRangeText,
+               
+                projectId:this.curProjiect.id||this.pid,
+                ver:this.version
+              }).then((res)=>{
+                if(res.data.data){
+                  this.formulaid = res.data.data;
+                }
+                this.formulaStringToArray();
+                this.$message({
+                  type: "success",
+                  message: "保存成功"
+                });
+              })
+            }
+            
+            return;
+        
+        
+      }else if(this.$refs.dynamiccomponent&&this.$refs.dynamiccomponent.length>0&&this.$refs.dynamiccomponent[0]&& this.$refs.dynamiccomponent[0].symbol=='getData'){
+       //数据获取保存公式
+        const dataRes = this.$refs.dynamiccomponent[0].getDataConditionData();
+       console.log(dataRes,'dataRes');
+       const result =dataRes.result;
+       const mapEle = JSON.stringify(dataRes.mapEle);
+       console.log(mapEle,'mapEle');
+       
+
+            if(this.formulaid){
+              updateFormula({
+                id:this.formulaid,
+               formula:"FC.switchCase"+'('+result+')',
+             
+                remark:'',
+                nodeId:this.nodeid,
+                elementId:this.eleid,
+                scale:this.isRetain?this.retainNum:'',
+                number:number,
+                map:mapEle,
+                scope:this.globaltype,
+                // projectId:this.curProjiect.id||this.projectId,
+                projectId:this.curProjiect.id||this.pid,
+                dev:deviationRangeText
+              }).then(()=>{
+                this.formulaStringToArray();
+                this.$message({
+                  type: "success",
+                  message: "修改成功"
+                });
+              })
+            }else{
+              saveFormula({
+                  formula:"FC.switchCase" +'('+result+')',
+          
+                remark:'',
+                nodeId:this.nodeid,
+                elementId:this.eleid,
+                scale:this.isRetain?this.retainNum:'',
+                number:number,
+                map:mapEle,
+                scope:this.globaltype,
+                dev:deviationRangeText,
+                // projectId:this.curProjiect.id||this.projectId,
+                projectId:this.curProjiect.id||this.pid,
+                ver:this.version
+              }).then((res)=>{
+                if(res.data.data){
+                  this.formulaid = res.data.data;
+                }
+                this.formulaStringToArray();
+                this.$message({
+                  type: "success",
+                  message: "保存成功"
+                });
+              })
+            }
+            
+            return;
+       
+      }else if(this.$refs.dynamiccomponent&&this.$refs.dynamiccomponent.length>0&&this.$refs.dynamiccomponent[0]&& this.$refs.dynamiccomponent[0].formData){
+        console.log(this.$refs.dynamiccomponent[0],'this.$refs.dynamiccomponent[0');
+        const resForm=this.$refs.dynamiccomponent[0].getDataChangeList();
+        console.log(resForm,'resForm');
+        
+        //数据自变保存
+
+             if(this.formulaid){
+              updateFormula({
+                id:this.formulaid,
+                formula:resForm.test,
+                remark:'',
+                nodeId:this.nodeid,
+                elementId:this.eleid,
+                scale:this.isRetain?this.retainNum:'',
+                number:number,
+                map:JSON.stringify(resForm.map),
+                scope:this.globaltype,
+                // projectId:this.curProjiect.id||this.projectId,
+                projectId:this.curProjiect.id||this.pid,
+                dev:deviationRangeText
+              }).then(()=>{
+                this.formulaStringToArray();
+                this.$message({
+                  type: "success",
+                  message: "修改成功"
+                });
+              })
+            }else{
+              saveFormula({
+                formula:resForm.test,
+                remark:'',
+                nodeId:this.nodeid,
+                elementId:this.eleid,
+                scale:this.isRetain?this.retainNum:'',
+                number:number,
+                map:JSON.stringify(resForm.map),
+                scope:this.globaltype,
+                dev:deviationRangeText,
+                // projectId:this.curProjiect.id||this.projectId,
+                projectId:this.curProjiect.id||this.pid,
+                ver:this.version
+              }).then((res)=>{
+                if(res.data.data){
+                  this.formulaid = res.data.data;
+                }
+                this.formulaStringToArray();
+                this.$message({
+                  type: "success",
+                  message: "保存成功"
+                });
+              })
+            }
+            return
+      }
        let arr=JSON.parse(JSON.stringify(this.processFormula));
       let filteredArr = arr.filter(item => item.id ===this.checkGsId);
       //  let obj = formulaArrayToString(filteredArr,this.resultFormula);
@@ -1531,6 +1734,41 @@ export default {
     async formulaStringToArray(){
       let detail = (await formulaDetail({elementId:this.eleid,scope:this.globaltype,nodeId:this.nodeid,projectId:this.curProjiect.id||this.pid})).data.data;
       console.log(detail);
+      this.remark== detail.remark;
+      //判断公式特殊处理
+      if(detail&&detail.formula.includes('FC.ifelseMulti')){
+        detail.formula = detail.formula.replace('FC.ifelseMulti','FC.ifelse');
+        this.isMore = true;
+            this.formulaDetailMap = detail.map;
+        this.moreConditions =  restoreArrayMore(detail.formulas,this.formulaDetailMap)
+    
+      }else if(detail&&detail.formula.includes('FC.switchCase')){
+        //数据获取
+        this.formulaDetailMap = detail.map;
+         detail.formula = detail.formula.replace('FC.switchCase','FC.ifelse');
+         this.isGetData = true;
+         this.dataListGet=detail.formula
+         console.log( this.dataListGet,' this.dataListGet');
+         
+      }else if(detail&&detail.formula.includes('FC.dataChange')){
+        //数据自变
+        this.formulaDetailMap = detail.map;
+      
+         this.isDataChange = true;
+         this.dataForm=detail.formula
+         console.log( this.dataForm,' this.dataListGet');
+         
+      }
+      else{
+        this.isMore = false;
+        this.moreConditions = []
+        this.formulaDetailMap ={}
+        this.isGetData = false;
+        this.dataListGet=''
+        this.isDataChange = false;
+        this.dataForm='';
+
+      }
       if(detail&&detail.id){
         //获取右边元素的字典
         let dictMap=detail.dict