Kaynağa Gözat

Merge branch 'master' of http://47.110.251.215:3000/web/saber into master

zhangh 2 yıl önce
ebeveyn
işleme
38db18fb0e

+ 3 - 1
package.json

@@ -11,10 +11,12 @@
     "test:e2e": "vue-cli-service test:e2e"
   },
   "dependencies": {
+    "@johmun/vue-tags-input": "^2.1.0",
     "avue-plugin-ueditor": "^0.1.4",
     "axios": "^0.18.0",
     "babel-polyfill": "^6.26.0",
-    "classlist-polyfill": "^1.2.0",    "crypto-js": "^4.0.0",
+    "classlist-polyfill": "^1.2.0",
+    "crypto-js": "^4.0.0",
     "element-ui": "^2.15.6",
     "js-base64": "^2.5.1",
     "js-cookie": "^2.2.0",

+ 6 - 0
src/styles/common.scss

@@ -95,6 +95,12 @@ a{
   border-bottom: 1px solid rgb(187, 187, 187);
 }
 
+.border-green{
+  border-color: #67C23A;
+  border-width: 1px;
+  border-style: solid;
+}
+
 .font-s-12{font-size: 12px;}
 .font-c-warning{color: rgb(240, 99, 10);}
 

+ 88 - 0
src/views/formula/component/funComponent/datasGetlist.vue

@@ -0,0 +1,88 @@
+<template>
+  <div>
+    <div>
+      <span class="mg-r-20">下标取数</span>
+      <!-- <el-button size="small" type="info" @click="showSelectEle">选择参数</el-button> -->
+      <div class="text-warning mg-t-10 mg-b-10">
+      请选择要取的某一位数据,N代表其中的某一个位,可被运算执行
+      </div>
+      <div>
+        <el-radio-group v-model="radio" @change="radioChange">
+          <el-radio :label="1">第一位</el-radio>
+          <el-radio :label="2">第N位</el-radio>
+          <el-radio :label="3">最后一位</el-radio>
+        </el-radio-group>
+      </div>
+      <div class="mg-t-20">
+        <el-input v-model="input" @change="inputChange" v-if="radio == 2" placeholder="请输入N值" size="medium" style="width:200px"></el-input>
+      </div>
+    </div>
+    
+  </div>
+</template>
+
+<script>
+export default {
+  name: "dateFormat",
+  props: {
+    formulainfo: {
+      type: Object,
+      default: function () {
+        return {};
+      }
+    },
+    curele: {
+      type: Object,
+      default: function () {
+        return {};
+      }
+    },
+  },
+  data(){
+    return{
+      radio:1,
+      input:'0'
+    }
+  },
+  mounted(){
+    //console.log(this.formulainfo.arguments[0])
+    //console.log(this.formulainfo.arguments[1])
+    let arg1 = this.formulainfo.arguments[1];
+    if(arg1 == '0' || arg1 == undefined){
+      this.radio = 1;
+    }else if(arg1 == 'last'){
+      this.radio = 3;
+    }else{
+      this.radio = 2;
+      this.input = arg1;
+      console.log(this.radio)
+    }
+  },
+  methods:{
+    showSelectEle(){
+      this.$set(this.formulainfo,'showSelectEle',!this.formulainfo.showSelectEle);
+    },
+
+    radioChange(value){
+      if(value == 1){
+        this.formulainfo.arguments[1] = '0';
+      }else if(value == 3){
+        this.formulainfo.arguments[1] = 'last';
+      }else if(value == 2){
+        this.formulainfo.arguments[1] = this.input;
+      }
+    },
+
+    inputChange(value){
+      this.formulainfo.arguments[1] = value;
+    },
+
+    setELe(){
+
+    }
+  }
+}
+</script>
+<style scoped lang="scss">
+  
+</style>

+ 66 - 0
src/views/formula/component/funComponent/datasJoin.vue

@@ -0,0 +1,66 @@
+<template>
+  <div>
+    <div>
+      <span class="mg-r-20">数组转字符串</span>
+      <!-- <el-button size="small" type="info" @click="showSelectEle">选择参数</el-button> -->
+      <el-switch
+        v-model="value1"
+        active-text="开"
+        inactive-text="关"
+        @change="switchChange"
+        >
+      </el-switch>
+    </div>
+    
+  </div>
+</template>
+
+<script>
+export default {
+  name: "dateFormat",
+  props: {
+    formulainfo: {
+      type: Object,
+      default: function () {
+        return {};
+      }
+    },
+    curele: {
+      type: Object,
+      default: function () {
+        return {};
+      }
+    },
+  },
+  data(){
+    return{
+      value1:true
+    }
+  },
+  mounted(){
+    //console.log(this.formulainfo.arguments[0])
+    //console.log(this.formulainfo.arguments[1])
+    if(this.formulainfo.isOn === false){
+      this.value1 = false;
+    }
+
+  },
+  methods:{
+    showSelectEle(){
+      this.$set(this.formulainfo,'showSelectEle',!this.formulainfo.showSelectEle);
+    },
+
+    switchChange(value){
+      this.formulainfo.isOn = value;
+      
+    },
+
+    setELe(){
+
+    }
+  }
+}
+</script>
+<style scoped lang="scss">
+  
+</style>

+ 550 - 0
src/views/formula/component/funComponent/ifelse.vue

@@ -0,0 +1,550 @@
+<template>
+  <div class="ifelse-box">
+    <div class="flex jc-al-c">
+      <span>IF条件执行</span>
+      <el-select v-model="symbol" @change="setCondition()" size="medium" placeholder="请选择">
+        <el-option label="大于等于" value=">="></el-option>
+        <el-option label="小于等于" value="<="></el-option>
+        <el-option label="大于" value=">"></el-option>
+        <el-option label="小于" value="<"></el-option>
+        <el-option label="等于" value="="></el-option>
+        <el-option label="小于且大于" value="<&&<"></el-option>
+        <el-option label="小于等于且大于等于" value="<=&&<="></el-option>
+      </el-select>
+      <span class="mg-l-20 mg-r-10">执行结果</span>
+      <el-select v-model="result" @change="setTF()" size="medium" placeholder="请选择">
+        <el-option label="真假值" value="1"></el-option>
+        <el-option label="运算" value="2"></el-option>
+      </el-select>
+      <el-button class="mg-l-10" size="small" type="info" @click="showSelectEle">选择参数</el-button>
+    </div>
+
+    <div class="mg-t-20 flex jc-al-c">
+      <span class="textblod mg-r-20">IF</span>
+      <div class="flex jc-al-c" v-if="symbol == '<&&<' || symbol == '<=&&<='">
+        <vue-tags-input v-model="tag1" :tags="tags1" @focus="curFocusIndex = 1" @blur="tags1 = [];setCondition()" placeholder="输入/参数" @before-adding-tag="beforeAddingTag"/>
+        <span v-if="symbol == '<&&<'" class="mg-l-20 mg-r-20">&lt;</span>
+        <span v-if="symbol == '<=&&<='" class="mg-l-20 mg-r-20">≤</span>
+      </div>
+      <vue-tags-input v-model="tag2" :tags="tags2" @focus="curFocusIndex = 2" @blur="tags2 = [];setCondition()" placeholder="输入/参数" @before-adding-tag="beforeAddingTag"/>
+      <span class="mg-l-20 mg-r-20">
+        <span v-if="symbol == '>='">≥</span>
+        <span v-if="symbol == '<='">≤</span>
+        <span v-if="symbol == '>'">&gt;</span>
+        <span v-if="symbol == '<'">&lt;</span>
+        <span v-if="symbol == '='">=</span>
+        <span v-if="symbol == '<&&<'">&lt;</span>
+        <span v-if="symbol == '<=&&<='">≤</span>
+      </span>
+      <vue-tags-input v-model="tag3" :tags="tags3" @focus="curFocusIndex = 3" @blur="tags3 = [];setCondition()" placeholder="输入/参数" @before-adding-tag="beforeAddingTag"/>
+    </div>
+
+    <div class="flex jc-al-c mg-t-20" v-if="result == 1">
+      <span class="textblod mg-r-10">真值</span>
+      <vue-tags-input v-model="tag4" :tags="tags4" @focus="curFocusIndex = 4" @blur="tags4 = [];setTF()" placeholder="输入/参数" @before-adding-tag="beforeAddingTag"/>
+      <span class="textblod mg-r-10 mg-l-20">假值</span>
+      <vue-tags-input v-model="tag5" :tags="tags5" @focus="curFocusIndex = 5" @blur="tags5 = [];setTF()" placeholder="输入/参数" @before-adding-tag="beforeAddingTag"/>
+    </div>
+    <div class="mg-t-20" v-if="result == 2">
+      <div class="flex">
+        <span class="textblod mg-r-10">真值</span>
+        <div class="border-grey sele-ele-box flex1" :class="{'border-green':curFocusIndex == 6}" @click="curFocusIndex = 6">
+          <div class="flex jc-sb mg-b-20">
+            <!-- <div>定位数据位置:</div> -->
+            <div class="icon-box">
+              <el-link :underline="false" icon="el-icon-delete" type="danger" @click="removeSelect"></el-link>
+              <el-link :underline="false" type="primary" @click="addOperator('+')" icon="el-icon-circle-plus-outline"></el-link>
+              <el-link :underline="false" type="primary" @click="addOperator('-')" icon="el-icon-remove-outline"></el-link>
+              <el-link :underline="false" type="primary" @click="addOperator('*')" icon="el-icon-circle-close"></el-link>
+              <el-link :underline="false" type="primary" @click="addOperator('%')">÷</el-link>
+            </div>
+            <div>
+              <!-- <el-link :underline="false" type="primary" class="mg-r-20" @click="eleAddFormula">元素添加到公式</el-link> -->
+              <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets('(',false)">(</el-link>
+              <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets(')',true)">)</el-link>
+              <!-- <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets('[',false)">【</el-link>
+              <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets(']',true)">】</el-link> -->
+              <el-link :underline="false" type="primary" @click="addText">输入值</el-link>
+            </div>
+          </div>
+          <div>
+            <formula-item 
+              v-for="(item,index) in selectEleFormula" :key="index" 
+              :item="item" @click="obj => eleFormulaClick(obj,index)"
+            >
+            </formula-item>
+          </div>
+        </div>
+      </div>
+      <div class="flex mg-t-10">
+        <span class="textblod mg-r-10">假值</span>
+        <div class="border-grey sele-ele-box flex1" :class="{'border-green':curFocusIndex == 7}" @click="curFocusIndex = 7">
+          <div class="flex jc-sb mg-b-20">
+            <!-- <div>定位数据位置:</div> -->
+            <div class="icon-box">
+              <el-link :underline="false" icon="el-icon-delete" type="danger" @click="removeSelect"></el-link>
+              <el-link :underline="false" type="primary" @click="addOperator('+')" icon="el-icon-circle-plus-outline"></el-link>
+              <el-link :underline="false" type="primary" @click="addOperator('-')" icon="el-icon-remove-outline"></el-link>
+              <el-link :underline="false" type="primary" @click="addOperator('*')" icon="el-icon-circle-close"></el-link>
+              <el-link :underline="false" type="primary" @click="addOperator('%')">÷</el-link>
+            </div>
+            <div>
+              <!-- <el-link :underline="false" type="primary" class="mg-r-20" @click="eleAddFormula">元素添加到公式</el-link> -->
+              <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets('(',false)">(</el-link>
+              <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets(')',true)">)</el-link>
+              <!-- <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets('[',false)">【</el-link>
+              <el-link :underline="false" type="primary" class="mg-r-10" @click="addBrackets(']',true)">】</el-link> -->
+              <el-link :underline="false" type="primary" @click="addText">输入值</el-link>
+            </div>
+          </div>
+          <div>
+            <formula-item 
+              v-for="(item,index) in selectEleFormula2" :key="index" 
+              :item="item" @click="obj => eleFormulaClick(obj,index)"
+            >
+            </formula-item>
+          </div>
+        </div>
+      </div>
+    </div>
+
+    <el-dialog title="输入值" :visible.sync="inputVisible" width="300px" append-to-body :close-on-click-modal="false">
+      <el-input v-model="inputText" placeholder="请输入内容"></el-input>
+      <div class="text-align-c mg-t-10">
+        <el-button size="small" @click="addTextHandle" type="primary">保存</el-button>
+        <el-button size="small" @click="inputVisible = false">取消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import VueTagsInput from '@johmun/vue-tags-input';
+import formulaItem from "../formulaItem"
+export default {
+  name: "dateFormat",
+  components: {
+    VueTagsInput,
+
+    formulaItem,
+  },
+  props: {
+    formulainfo: {
+      type: Object,
+      default: function () {
+        return {};
+      }
+    },
+    curele: {
+      type: Object,
+      default: function () {
+        return {};
+      }
+    },
+
+    formulamap:{
+      type: Object,
+      default: function () {
+        return {};
+      }
+    }
+  },
+  data(){
+    return{
+      symbol:'>=',
+      result:'1',
+
+      selectEleFormula:[],
+      selectEleFormula2:[],
+
+      curFocusIndex:0,//当前在哪个输入框
+      curSeleEleIndex:-1,//公式文字里面选中的元素索引
+      symbolReg:/(\+|-|\*|\/)(.+)/,
+      inputVisible:false,
+      inputText:'',
+
+      tag1: '',
+      tags1: [],
+      tag2: '',
+      tags2: [],
+      tag3: '',
+      tags3: [],
+      tag4: '',
+      tags4: [],
+      tag5: '',
+      tags5: [],
+    }
+  },
+  mounted(){
+    //console.log(this.formulainfo.arguments[0])
+    //console.log(this.formulainfo.arguments[1])
+    let args0 = this.formulainfo.arguments[0];
+    let args1 = this.formulainfo.arguments[1];
+    let args2 = this.formulainfo.arguments[2];
+    this.initCondition(args0);
+
+    if((typeof args1 == 'string' || (typeof args1 == 'object' && args1.type == 'Element')) &&
+      (typeof args2 == 'string' || (typeof args2 == 'object' && args2.type == 'Element'))
+    ){
+      this.initTFInput(args1,args2);
+    }else if(Array.isArray(args1) || Array.isArray(args2)){
+      this.result = '2';
+      this.initTFFormula(args1,args2)
+    }
+  },
+  methods:{
+    showSelectEle(){
+      this.$set(this.formulainfo,'showSelectEle',!this.formulainfo.showSelectEle);
+    },
+
+    beforeAddingTag(){
+
+    },
+
+    inputHook(){
+      console.log(111)
+    },
+
+    addText(){
+      this.inputVisible = true;
+    },
+
+    //把元素加到公式里
+    eleAddFormulaHandle(ele){
+      let eleFormula;
+      if(this.curFocusIndex == 6){
+        eleFormula = this.selectEleFormula;
+      }else if(this.curFocusIndex == 7){
+        eleFormula = this.selectEleFormula2;
+      }else{
+        return;
+      }
+
+      if(ele.tableElementKey){
+        //元素
+        eleFormula.push({
+          type:'Element',
+          name:ele.eName,
+          id:ele.id,
+          selected:false,
+          tableElementKey:ele.tableElementKey,
+          children:[],
+        })
+      }else if(ele.template && ele.example){
+        //运算符号
+        eleFormula.push({
+          type:'Operator',
+          name:this.symbolReg.exec(ele.name)[1],
+          selected:false,
+          template:ele.template
+        })
+      }else if(ele.type == 'Brackets'){
+        //括号
+        eleFormula.splice(ele.selectIndex,0,{
+          type:'Brackets',
+          name:ele.name,
+          selected:false,
+        })
+      }else if(ele.type == 'Text'){
+        //输入值
+        eleFormula.push({
+          type:'Text',
+          name:ele.name,
+          selected:false,
+        })
+      }
+
+      this.setTF();
+    },
+
+    //点选公式中的元素
+    eleFormulaClick({selected,item},index){
+      let eleFormula;
+      if(this.curFocusIndex == 6){
+        eleFormula = this.selectEleFormula;
+      }else if(this.curFocusIndex == 7){
+        eleFormula = this.selectEleFormula2;
+      }else{
+        return;
+      }
+
+      if(selected){
+        eleFormula.forEach((ele)=>{
+          ele.selected = false;
+        })
+        item.selected = true;
+        this.curSeleEleIndex = index;
+      }else{
+        this.curSeleEleIndex = -1;
+      }
+    },
+
+    //快捷添加运算符号
+    addOperator(operator){
+      this.eleAddFormulaHandle(this.formulamap[operator]);
+    },
+
+    //删除点选公式中的元素
+    removeSelect(){
+      let eleFormula;
+      if(this.curFocusIndex == 6){
+        eleFormula = this.selectEleFormula;
+      }else if(this.curFocusIndex == 7){
+        eleFormula = this.selectEleFormula2;
+      }else{
+        return;
+      }
+
+
+      if(this.curSeleEleIndex > -1){
+        eleFormula.splice(this.curSeleEleIndex,1);
+        this.curSeleEleIndex = -1;
+      }
+
+      this.setTF();
+    },
+
+    //添加括号
+    addBrackets(text,type){
+      //type 是true 表示在元素右边插入
+      if(this.curSeleEleIndex == Number(this.curSeleEleIndex)){
+        this.eleAddFormulaHandle({
+          type:'Brackets',
+          name:text,
+          selectIndex:type?Number(this.curSeleEleIndex)+1:this.curSeleEleIndex
+        })
+        //如果在左边插入index要增1
+        if(!type){
+          this.curSeleEleIndex = Number(this.curSeleEleIndex)+1;
+        }
+      }
+    },
+
+    //添加输入值
+    addTextHandle(){
+      this.eleAddFormulaHandle({
+        type:'Text',
+        name:this.inputText
+      })
+      this.inputVisible = false;
+    },
+
+    setELe(ele){
+      if(this.curFocusIndex){
+        let obj = {
+          type:'Element',
+          name:ele.eName,
+          id:ele.id,
+          selected:false,
+          tableElementKey:ele.tableElementKey,
+          children:[],
+        }
+
+        if(this.curFocusIndex == 6 || this.curFocusIndex ==7){
+          this.eleAddFormulaHandle(ele)
+        }else{
+          obj.text = ele.eName;
+          obj.style = 'background-color: #409EFF';
+          this['tags'+this.curFocusIndex] = [obj];
+          this['tag'+this.curFocusIndex] = '';
+
+          this.curFocusIndex = 0;
+          this.setCondition();
+        }
+      }
+    },
+
+    //初始化真假值判断if(xxx)部分
+    initCondition(args0){
+      if(args0){
+        if(args0.length == 3){
+          //运算符号
+          this.symbol = args0[1];
+
+          //第二个空
+          if((typeof args0[0]) == 'object' && args0[0].type == 'Element'){
+            let ele = args0[0];
+            this.tags2 =  [
+              Object.assign({
+                text:ele.name,
+                style:'background-color: #409EFF',
+              },ele)]
+          }else if((typeof args0[0]) == 'string'){
+            this.tag2 = args0[0];
+          }
+
+          //第三个空
+          if((typeof args0[2]) == 'object' && args0[2].type == 'Element'){
+            let ele = args0[2];
+            this.tags3 =  [
+              Object.assign({
+                text:ele.name,
+                style:'background-color: #409EFF',
+              },ele)]
+          }else if((typeof args0[2]) == 'string'){
+            this.tag3 = args0[2];
+          }
+        }else if(args0.length == 7){
+          //运算符号
+          this.symbol = args0[1]+args0[3]+args0[5];
+
+          //第一个空
+          if((typeof args0[0]) == 'object' && args0[0].type == 'Element'){
+            let ele = args0[0];
+            this.tags1 =  [
+              Object.assign({
+                text:ele.name,
+                style:'background-color: #409EFF',
+              },ele)]
+          }else if((typeof args0[0]) == 'string'){
+            this.tag1 = args0[0];
+          }
+
+          //第二个空
+          if((typeof args0[2]) == 'object' && args0[2].type == 'Element'){
+            let ele = args0[2];
+            this.tags2 =  [
+              Object.assign({
+                text:ele.name,
+                style:'background-color: #409EFF',
+              },ele)]
+          }else if((typeof args0[2]) == 'string'){
+            this.tag2 = args0[2];
+          }
+
+          //第三个空
+          if((typeof args0[6]) == 'object' && args0[6].type == 'Element'){
+            let ele = args0[6];
+            this.tags3 =  [
+              Object.assign({
+                text:ele.name,
+                style:'background-color: #409EFF',
+              },ele)]
+          }else if((typeof args0[6]) == 'string'){
+            this.tag3 = args0[6];
+          }
+        }
+      }
+    },
+
+    //写入参数真假值判断if(xxx)部分
+    setCondition(){
+      if(this.symbol == '<&&<' || this.symbol == '<=&&<='){
+        let arr = new Array(7).fill('');
+        let symbolArr = this.symbol.split('&&');
+        if(this.tags1.length == 0){
+          arr[0] = this.tag1;
+        }else{
+          arr[0] = this.tags1[0];
+        }
+        arr[1] = symbolArr[0];
+        if(this.tags2.length == 0){
+          arr[2] = this.tag2;
+          arr[4] = this.tag2;
+        }else{
+          arr[2] = this.tags2[0];
+          arr[4] = this.tags2[0];
+        }
+        arr[3] = '&&';
+        arr[5] = symbolArr[1];
+        if(this.tags3.length == 0){
+          arr[6] = this.tag3;
+        }else{
+          arr[6] = this.tags3[0];
+        }
+        this.formulainfo.arguments[0] = arr;
+      }else{
+        let arr = new Array(3).fill('');
+        if(this.tags2.length == 0){
+          arr[0] = this.tag2;
+        }else{
+          arr[0] = this.tags2[0];
+        }
+        arr[1] = this.symbol;
+        if(this.tags3.length == 0){
+          arr[2] = this.tag3;
+        }else{
+          arr[2] = this.tags3[0];
+        }
+        this.formulainfo.arguments[0] = arr;
+      }
+      //console.log(this.formulainfo.arguments[0])
+    },
+
+    //初始化输入框的真假值
+    initTFInput(args1,args2){
+      if((typeof args1) == 'object' && args1.type == 'Element'){
+        let ele = args1;
+        this.tags4 =  [
+          Object.assign({
+            text:ele.name,
+            style:'background-color: #409EFF',
+          },ele)]
+      }else if((typeof args1) == 'string'){
+        this.tag4 = args1;
+      }
+
+      if((typeof args2) == 'object' && args2.type == 'Element'){
+        let ele = args2;
+        this.tags5 =  [
+          Object.assign({
+            text:ele.name,
+            style:'background-color: #409EFF',
+          },ele)]
+      }else if((typeof args2) == 'string'){
+        this.tag5 = args2;
+      }
+    },
+
+    //初始化运算的真假值
+    initTFFormula(args1,args2){
+      if(Array.isArray(args1)){
+        this.selectEleFormula = args1;
+      }else if(typeof args1 == 'object' && args1.type == 'Element'){
+        this.selectEleFormula = [Object.assign({},args1)];
+      }
+
+      if(Array.isArray(args2)){
+        this.selectEleFormula2 = args1;
+      }else if(typeof args2 == 'object' && args2.type == 'Element'){
+        this.selectEleFormula2 = [Object.assign({},args2)];
+      }
+    },
+
+    //写入参数真假值
+    setTF(){
+      if(this.result == 1){
+        if(this.tags4.length == 0){
+          this.formulainfo.arguments[1] = this.tag4;
+        }else{
+          this.formulainfo.arguments[1] = this.tags4[0];
+        }
+        if(this.tags5.length == 0){
+          this.formulainfo.arguments[2] = this.tag5;
+        }else{
+          this.formulainfo.arguments[2] = this.tags5[0];
+        }
+      }else if(this.result == 2){
+        this.formulainfo.arguments[1] = this.selectEleFormula;
+        this.formulainfo.arguments[2] = this.selectEleFormula2;
+      }
+    },
+
+  }
+}
+</script>
+<style scoped lang="scss">
+  .textblod{
+    font-weight: bold;
+    font-size: 18px;
+  }
+  .sele-ele-box{
+    height: 100px;
+    padding: 10px;
+    // margin-top: 10px;
+  }
+  .icon-box .el-link{
+    font-size: 20px;
+    margin-right: 10px;
+  }
+</style>

+ 11 - 1
src/views/formula/edit.vue

@@ -168,7 +168,7 @@
           <template v-else>
             <div class="flex">
               <div class="flex flex-d-c">
-                <component ref="dynamiccomponent" v-bind:is="componentMap[item.name]" :formulainfo="item" :curele="equationSelectEle" class="flex1"></component>
+                <component ref="dynamiccomponent" v-bind:is="componentMap[item.name]" :formulainfo="item" :curele="equationSelectEle" :formulamap="formulaMap" class="flex1"></component>
                 <div v-show="item.showSelectEle">
                   <el-select v-model="eleTableId" @change="getTableEleComp" placeholder="请选择元素表" style="width:100%">
                     <el-option  v-for="item in eleTableList" :key="item.id" :label="item.tableName" :value="item.id"></el-option>
@@ -280,6 +280,9 @@ import dateDeviation from "./component/funComponent/dateDeviation"
 import dateFormat from "./component/funComponent/dateFormat"
 import datasRepeat from "./component/funComponent/datasRepeat"
 import datasReme from "./component/funComponent/datasReme"
+import datasGetlist from "./component/funComponent/datasGetlist"
+import datasJoin from "./component/funComponent/datasJoin"
+import ifelse from "./component/funComponent/ifelse"
 
 import {formulaArrayToString} from "./formulaArrayToString"
 import {formulaStringToArray} from "./formulaStringToArray"
@@ -292,6 +295,9 @@ export default {
     dateFormat,
     datasRepeat,
     datasReme,
+    datasGetlist,
+    datasJoin,
+    ifelse
   },
   data() {
     return {
@@ -344,6 +350,9 @@ export default {
         '日期格式化':'date-format',
         '去重':'datas-repeat',
         '去空':'datas-reme',
+        '下标取数':'datas-getlist',
+        '数组转字符串':"datas-join",
+        '判断':'ifelse'
       },
       eleListComp:[],
     };
@@ -750,6 +759,7 @@ export default {
       //console.log(detail);
       if(detail.id){
         this.formulaid = detail.id;
+        //let formula = formulaStringToArray('FC.sum(FC.repeat(E[测试测试_222]))+FC.ifelse(3<E[测试测试_333]&&E[测试测试_333]<10,E[测试测试_222]+E[测试测试_333],E[测试测试_333])',detail.map,this.formulaMap);
         let formula = formulaStringToArray(detail.formula,detail.map,this.formulaMap);
         this.processFormula = formula.processFormula;
         formula.resultFormula[0].id = this.resultFormula[0].id;

+ 34 - 2
src/views/formula/formulaStringToArray.js

@@ -63,8 +63,13 @@ function parseArguments(ele,funObj){
       //只用动态的
       if(argText.indexOf('#')>-1){
         if(argSpliceArr[index].length>1){
-          //是前面的计算结果
-          fun.arguments.push(ele)
+          if(fun.name == '判断'){
+            fun.arguments.push(ifFunArgumentsHandle(argSpliceArr[index]))
+          }else{
+            //是前面的计算结果
+            fun.arguments.push(ele)
+          }
+
         }else{
           let arg = argSpliceArr[index][0];
           if(arg.type == 'Element'){
@@ -104,6 +109,21 @@ function parseProcessFormula(funObj,ele){
 
 }
 
+//处理if方法的参数
+function ifFunArgumentsHandle(argArr){
+  let arr = [];
+
+  argArr.forEach((Element)=>{
+    if(Element.type == 'Text' || Element.type == 'Logical'){
+      arr.push(Element.tag)
+    }else{
+      arr.push(Element)
+    }
+  })
+
+  return arr;
+}
+
 export const formulaStringToArray = (text,elemap,formulaMap) => {
 
   // 匹配开始的FC.xxx(
@@ -114,6 +134,7 @@ export const formulaStringToArray = (text,elemap,formulaMap) => {
   const commaReg = /^,/;//逗号
   const operatorReg = /^(\+|-|\*|%)/;//加减乘除
   const wordReg = /^[\u4e00-\u9fa5\w0-9'"-]+/;//文本
+  const logicalReg = /^(>=|<=|>|<|=|&&)/;//逻辑符号
 
   let elementMap = JSON.parse(elemap);//元素字典
   //console.log(formulaMap)
@@ -244,6 +265,17 @@ export const formulaStringToArray = (text,elemap,formulaMap) => {
       });
 
       strIndex += comma.length;//索引移动
+    }else if(logicalReg.test(nuText)){
+      //console.log('逻辑符号')
+      let logical = nuText.match(logicalReg)[0];
+
+      contentStack[contentStack.length - 1].children.push({
+        type:'Logical',
+        tag:logical
+      });
+
+      strIndex += logical.length;//索引移动
+
     }else if(operatorReg.test(nuText)){
       //console.log('匹配加减乘除')
       //匹配加减乘除