duy 1 тиждень тому
батько
коміт
6348918841

+ 63 - 59
src/views/formula/component/funComponent/ifelse.vue

@@ -194,65 +194,68 @@
               <el-button  size="small" type="primary" @click="addCondition(conditionIndex)">添加其他条件</el-button>
           </div>
         </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': isCurFocus(conditionIndex, null, 'formula1')}" 
-                 @click="setMultiFocus(conditionIndex, null, 'formula1')">
-              <div class="flex jc-sb mg-b-20">
-                <div class="icon-box">
-                  <el-link :underline="false" icon="el-icon-delete" type="danger" @click="removeSelectMulti(conditionIndex, 'formula1')"></el-link>
-                  <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '+', 'formula1')" icon="el-icon-circle-plus-outline"></el-link>
-                  <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '-', 'formula1')" icon="el-icon-remove-outline"></el-link>
-                  <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '*', 'formula1')" icon="el-icon-circle-close"></el-link>
-                  <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '%', 'formula1')">÷</el-link>
-                </div>
-                <div>
-                  <el-link :underline="false" type="primary" class="mg-r-10" @click="addBracketsMulti(conditionIndex, '(', false, 'formula1')">(</el-link>
-                  <el-link :underline="false" type="primary" class="mg-r-10" @click="addBracketsMulti(conditionIndex, ')', true, 'formula1')">)</el-link>
-                  <el-link :underline="false" type="primary" @click="addTextMulti(conditionIndex, 'formula1')">输入值</el-link>
-                </div>
+            <template v-if="result == 2">
+              <div class="mg-t-20"  >
+                    <div class="flex">
+                      <span class="textblod mg-r-10">满足</span>
+                      <div class="border-grey sele-ele-box flex1" 
+                          :class="{'border-green': isCurFocus(conditionIndex, null, 'formula1')}" 
+                          @click="setMultiFocus(conditionIndex, null, 'formula1')">
+                        <div class="flex jc-sb mg-b-20">
+                          <div class="icon-box">
+                            <el-link :underline="false" icon="el-icon-delete" type="danger" @click="removeSelectMulti(conditionIndex, 'formula1')"></el-link>
+                            <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '+', 'formula1')" icon="el-icon-circle-plus-outline"></el-link>
+                            <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '-', 'formula1')" icon="el-icon-remove-outline"></el-link>
+                            <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '*', 'formula1')" icon="el-icon-circle-close"></el-link>
+                            <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '%', 'formula1')">÷</el-link>
+                          </div>
+                          <div>
+                            <el-link :underline="false" type="primary" class="mg-r-10" @click="addBracketsMulti(conditionIndex, '(', false, 'formula1')">(</el-link>
+                            <el-link :underline="false" type="primary" class="mg-r-10" @click="addBracketsMulti(conditionIndex, ')', true, 'formula1')">)</el-link>
+                            <el-link :underline="false" type="primary" @click="addTextMulti(conditionIndex, 'formula1')">输入值</el-link>
+                          </div>
+                        </div>
+                        <draggable v-model="conditionList[conditionIndex].formula1">
+                          <formula-item 
+                            v-for="(item,index) in conditionList[conditionIndex].formula1" :key="index" 
+                            :item="item" @click="obj => eleFormulaClickMulti(obj, index, conditionIndex, 'formula1')"
+                          >
+                          </formula-item>
+                        </draggable>
+                      </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': isCurFocus(conditionIndex, null, 'formula2')}" 
+                          @click="setMultiFocus(conditionIndex, null, 'formula2')">
+                        <div class="flex jc-sb mg-b-20">
+                          <div class="icon-box">
+                            <el-link :underline="false" icon="el-icon-delete" type="danger" @click="removeSelectMulti(conditionIndex, 'formula2')"></el-link>
+                            <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '+', 'formula2')" icon="el-icon-circle-plus-outline"></el-link>
+                            <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '-', 'formula2')" icon="el-icon-remove-outline"></el-link>
+                            <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '*', 'formula2')" icon="el-icon-circle-close"></el-link>
+                            <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '%', 'formula2')">÷</el-link>
+                          </div>
+                          <div>
+                            <el-link :underline="false" type="primary" class="mg-r-10" @click="addBracketsMulti(conditionIndex, '(', false, 'formula2')">(</el-link>
+                            <el-link :underline="false" type="primary" class="mg-r-10" @click="addBracketsMulti(conditionIndex, ')', true, 'formula2')">)</el-link>
+                            <el-link :underline="false" type="primary" @click="addTextMulti(conditionIndex, 'formula2')">输入值</el-link>
+                          </div>
+                        </div>
+                        <draggable v-model="conditionList[conditionIndex].formula2">
+                          <formula-item 
+                            v-for="(item,index) in conditionList[conditionIndex].formula2" :key="index" 
+                            :item="item" @click="obj => eleFormulaClickMulti(obj, index, conditionIndex, 'formula2')"
+                          >
+                          </formula-item>
+                        </draggable>
+                      </div>
+                    </div>
+                  <el-button size="small" @click="addCondition(conditionIndex)" type="primary">添加条件</el-button>
               </div>
-              <draggable v-model="conditionList[conditionIndex].formula1">
-                <formula-item 
-                  v-for="(item,index) in conditionList[conditionIndex].formula1" :key="index" 
-                  :item="item" @click="obj => eleFormulaClickMulti(obj, index, conditionIndex, 'formula1')"
-                >
-                </formula-item>
-              </draggable>
-            </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': isCurFocus(conditionIndex, null, 'formula2')}" 
-                 @click="setMultiFocus(conditionIndex, null, 'formula2')">
-              <div class="flex jc-sb mg-b-20">
-                <div class="icon-box">
-                  <el-link :underline="false" icon="el-icon-delete" type="danger" @click="removeSelectMulti(conditionIndex, 'formula2')"></el-link>
-                  <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '+', 'formula2')" icon="el-icon-circle-plus-outline"></el-link>
-                  <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '-', 'formula2')" icon="el-icon-remove-outline"></el-link>
-                  <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '*', 'formula2')" icon="el-icon-circle-close"></el-link>
-                  <el-link :underline="false" type="primary" @click="addOperatorMulti(conditionIndex, '%', 'formula2')">÷</el-link>
-                </div>
-                <div>
-                  <el-link :underline="false" type="primary" class="mg-r-10" @click="addBracketsMulti(conditionIndex, '(', false, 'formula2')">(</el-link>
-                  <el-link :underline="false" type="primary" class="mg-r-10" @click="addBracketsMulti(conditionIndex, ')', true, 'formula2')">)</el-link>
-                  <el-link :underline="false" type="primary" @click="addTextMulti(conditionIndex, 'formula2')">输入值</el-link>
-                </div>
-              </div>
-              <draggable v-model="conditionList[conditionIndex].formula2">
-                <formula-item 
-                  v-for="(item,index) in conditionList[conditionIndex].formula2" :key="index" 
-                  :item="item" @click="obj => eleFormulaClickMulti(obj, index, conditionIndex, 'formula2')"
-                >
-                </formula-item>
-              </draggable>
-            </div>
-          </div>
-        
-        </div>
+        </template>
+      
       </div>
      </template>
 
@@ -728,6 +731,7 @@ export default {
     // 多条件下点选公式中的元素
     eleFormulaClickMulti({selected,item}, index, conditionIndex, formulaType) {
       const eleFormula = this.conditionList[conditionIndex][formulaType];
+      console.log(eleFormula,'eleFormula');
       
       if(selected){
         eleFormula.forEach((ele)=>{
@@ -900,7 +904,7 @@ export default {
       this.multiFocus.field = formulaType;
       this.inputVisible = true;
     },
-
+    
     setELe(ele){
       // 处理多条件情况
       if (this.symbol === 'more' && this.multiFocus.conditionIndex !== -1) {

+ 381 - 0
src/views/formula/component/funComponent/multiIfElseTools.js

@@ -0,0 +1,381 @@
+/**
+ * 将数组转换为表达式字符串
+ * @param {Array} arr 输入的数组,包含不同类型的元素
+ * @returns {string} 拼接后的表达式字符串
+ */
+export function convertArrayToExpression(arr) {
+  const result = [];
+  
+  // 遍历输入数组的每个元素
+  arr.forEach(item => {
+    switch (item.type) {
+      case 'Element':
+        // 对于Element类型,提取tableElementKey并包裹在E[]中
+        result.push(`E[${item.tableElementKey}]`);
+        break;
+      case 'Operator':
+        // 对于Operator类型,提取ft属性
+        result.push(item.template.ft || item.ft || '');
+        break;
+      case 'Text':
+        // 对于Text类型,直接使用name属性
+        result.push(item.name);
+        break;
+      default:
+        // 处理未知类型
+        console.warn('未知类型:', item.type);
+    }
+  });
+  
+  // 将结果数组拼接成字符串并返回
+  return result.join('');
+}
+
+export function formatArrayMore(inputArray) {
+  console.log(inputArray, 'inputArray');
+  
+  // 定义字段映射关系
+  const fieldMappings = {
+      'tag2': 'parameter1',
+      'tag3': 'parameter2',
+      'symbol1': 'symbol',
+      'logicSymbol': 'groupTerm',
+      'tag4': 'trueData',
+      'tag5': 'falseData'
+  };
+  
+  // 处理值的格式化,将特定格式字符串包裹在E[]中
+  function formatValue(value) {
+      // 检查是否是符合格式的字符串(包含:key_)
+      if (typeof value === 'string' && value.includes(':key_')) {
+          return `E[${value}]`;
+      }
+      return value;
+  }
+
+  // 处理单个对象的函数
+  function processObject(obj) {
+      const result = {};
+      
+      // 处理formulaIfElse(如果存在)
+      if (obj.formulaIfElse && Array.isArray(obj.formulaIfElse)) {
+          result.formulaIfElse = obj.formulaIfElse.map(item => processObject(item));
+      }
+      
+      // 处理formula1和formula2,转换后赋值给trueData和falseData
+      if (obj.formula1 && Array.isArray(obj.formula1) && obj.formula1.length > 0) {
+          result.trueData = convertArrayToExpression(obj.formula1);
+          result.trueDataArray = obj.formula1;
+      }
+      
+      if (obj.formula2 && Array.isArray(obj.formula2) && obj.formula2.length > 0) {
+          result.falseData = convertArrayToExpression(obj.formula2);
+          result.falseDataArray = obj.formula2;
+      }
+      
+      // 处理其他字段映射
+      Object.keys(obj).forEach(key => {
+          // 特殊处理tags2、tags3、tags4和tags5
+          if (key === 'tags2' && Array.isArray(obj.tags2) && obj.tags2.length > 0) {
+              const value = obj.tags2[0].tableElementKey || '';
+              if (!result.parameter1) {
+                  result.parameter1 = formatValue(value);
+              }
+          } 
+          else if (key === 'tags3' && Array.isArray(obj.tags3) && obj.tags3.length > 0) {
+              const value = obj.tags3[0].tableElementKey || '';
+              if (!result.parameter2) {
+                  result.parameter2 = formatValue(value);
+              }
+          }
+          else if (key === 'tags4' && Array.isArray(obj.tags4) && obj.tags4.length > 0) {
+              const value = obj.tags4[0].tableElementKey || '';
+              if (!result.trueData) {
+                  result.trueData = formatValue(value);
+              }
+          }
+          else if (key === 'tags5' && Array.isArray(obj.tags5) && obj.tags5.length > 0) {
+              const value = obj.tags5[0].tableElementKey || '';
+              if (!result.falseData) {
+                  result.falseData = formatValue(value);
+              }
+          }
+          // 处理其他映射字段
+          else if (fieldMappings[key]) {
+              if ((key === 'tag2' && !result.parameter1) || 
+                  (key === 'tag3' && !result.parameter2) ||
+                  (key === 'tag4' && !result.trueData) ||
+                  (key === 'tag5' && !result.falseData) ||
+                  !['tag2', 'tag3', 'tag4', 'tag5'].includes(key)) {
+                  result[fieldMappings[key]] = formatValue(obj[key]);
+              }
+          }
+      });
+      
+      return result;
+  }
+  
+  // 处理整个数组
+  return inputArray.map(item => processObject(item));
+}
+
+export function restoreArrayMore(processedArray, formulaDetailMap) {
+  // 定义反转的字段映射关系(与原方法相反)
+  const reverseMappings = {
+      'parameter1': 'tag2',
+      'parameter2': 'tag3',
+      'symbol': 'symbol1',
+      'groupTerm': 'logicSymbol',
+      'trueData': 'tag4',
+      'falseData': 'tag5'
+  };
+  
+  // 从map获取完整元素信息并构建tags对象
+  const getTagElement = (tableElementKey) => {
+      try {
+          const objTargetData = typeof formulaDetailMap === 'string' 
+              ? JSON.parse(formulaDetailMap) 
+              : formulaDetailMap;
+          const baseData = objTargetData[tableElementKey] || {};
+          return {
+              "type": baseData.type || "Element",
+              "name": baseData.name || "",
+              "id": baseData.id || "",
+              "selected": false,
+              "tableElementKey": tableElementKey,
+              "children": [],
+              "text": baseData.name || "",
+              "style": "background-color: #409EFF"
+          };
+      } catch (error) {
+          console.error('Error parsing formulaDetailMap:', error);
+          return {
+              "type": "Element",
+              "name": "",
+              "id": "",
+              "selected": false,
+              "tableElementKey": tableElementKey,
+              "children": [],
+              "text": "",
+              "style": "background-color: #409EFF"
+          };
+      }
+  };
+  
+  // 解析表达式字符串为公式数组(修复符号与数字拆分问题)
+  function parseExpressionToFormula(expression) {
+      if (typeof expression !== 'string') return [];
+      
+      const formula = [];
+      const len = expression.length;
+      let currentPos = 0;
+      
+      // 定义所有运算符
+const operators = new Set(['+', '-', '*', '/', '%', '=', '>', '<', '!', '&', '|', '≥', '≤', '≠', '(', ')']);
+      
+      // 检查是否为运算符
+      const isOperatorChar = (char) => operators.has(char);
+      
+      // 跳过空白字符
+      const skipWhitespace = () => {
+          while (currentPos < len && /\s/.test(expression[currentPos])) {
+              currentPos++;
+          }
+      };
+      
+      while (currentPos < len) {
+          skipWhitespace();
+          if (currentPos >= len) break;
+          
+          const currentChar = expression[currentPos];
+          
+          // 处理元素 (E[...])
+          if (currentChar === 'E' && currentPos + 1 < len && expression[currentPos + 1] === '[') {
+              const endPos = expression.indexOf(']', currentPos + 2);
+              if (endPos !== -1) {
+                  const key = expression.substring(currentPos + 2, endPos);
+                  formula.push(getTagElement(key));
+                  currentPos = endPos + 1;
+              } else {
+                  // 无效格式,作为文本处理
+                  formula.push({ type: 'Text', name: expression.substring(currentPos) });
+                  break;
+              }
+          }
+          // 处理运算符
+          else if (isOperatorChar(currentChar)) {
+              let operator = currentChar;
+              currentPos++;
+              
+              // 处理多字符运算符 (如>=、<=、&&、||等)
+              while (currentPos < len && isOperatorChar(expression[currentPos])) {
+                  operator += expression[currentPos];
+                  currentPos++;
+              }
+              
+              formula.push({
+                  type: 'Operator',
+                  ft: operator,
+                  template: { ft: operator },
+                  name: operator,
+                  selected: false,
+                 
+                 
+                  
+              });
+          }
+          // 处理文本(数字或其他字符)
+          else {
+              let textEndPos = currentPos;
+              
+              // 收集所有非运算符、非元素的字符
+              while (textEndPos < len) {
+                  const char = expression[textEndPos];
+                  // 遇到运算符或元素开始则停止
+                  if (isOperatorChar(char) || (char === 'E' && textEndPos + 1 < len && expression[textEndPos + 1] === '[')) {
+                      break;
+                  }
+                  textEndPos++;
+              }
+              
+              const text = expression.substring(currentPos, textEndPos).trim();
+              if (text) {
+                  formula.push({
+                      type: 'Text',
+                      name: text,
+                        selected: false,
+                  });
+              }
+              
+              currentPos = textEndPos;
+          }
+      }
+      
+      return formula;
+  }
+  
+  // 还原值的格式化,去掉E[]包裹
+  function restoreValue(value) {
+      if (typeof value === 'string' && value.startsWith('E[') && value.endsWith(']')) {
+          const innerValue = value.slice(2, -1);
+          if (innerValue.includes(':key_')) {
+              return innerValue;
+          }
+      }
+      return value;
+  }
+
+  // 还原单个对象的函数
+  function restoreObject(obj) {
+      const result = {};
+      
+      // 递归还原formulaIfElse(如果存在)
+      if (obj.formulaIfElse && Array.isArray(obj.formulaIfElse)) {
+          result.formulaIfElse = obj.formulaIfElse.map(item => restoreObject(item));
+      }
+      
+      // 还原formula1和formula2
+      if (obj.trueData) {
+          result.formula1 = parseExpressionToFormula(obj.trueData);
+      }
+      if (obj.falseData) {
+          result.formula2 = parseExpressionToFormula(obj.falseData);
+      }
+      
+      // 处理参数与tags数组的还原
+      Object.keys(obj).forEach(key => {
+          const restoredValue = restoreValue(obj[key]);
+          
+          if (key === 'parameter1') {
+              result.tags2 = [getTagElement(restoredValue)];
+              result[reverseMappings[key]] = restoredValue;
+          }
+          else if (key === 'parameter2') {
+              result.tags3 = [getTagElement(restoredValue)];
+              result[reverseMappings[key]] = restoredValue;
+          }
+          else if (key === 'trueData') {
+              result.tags4 = [getTagElement(restoredValue)];
+              result[reverseMappings[key]] = restoredValue;
+          }
+          else if (key === 'falseData') {
+              result.tags5 = [getTagElement(restoredValue)];
+              result[reverseMappings[key]] = restoredValue;
+          }
+          else if (reverseMappings[key]) {
+              result[reverseMappings[key]] = restoredValue;
+          }
+      });
+      
+      return result;
+  }
+  
+  // 还原整个数组
+  return processedArray.map(item => restoreObject(item));
+}
+
+export function generateResult(input) {
+  // 检查输入是否有效
+  if (!Array.isArray(input) || input.length === 0) {
+      return null;
+  }
+  
+  // 构建结果对象
+  const result = {};
+  
+  // 处理标签的通用函数
+  const processTags = (tags) => {
+      if (tags && Array.isArray(tags)) {
+          tags.forEach(tag => {
+              const key = tag.tableElementKey;
+              if (key) {
+                  result[key] = {
+                      id: tag.id,
+                      name: tag.name,
+                      tableElementKey: key,
+                      type: tag.type
+                  };
+              }
+          });
+      }
+  };
+  
+  // 处理公式数组(formula1和formula2)中的元素
+  const processFormula = (formula) => {
+      if (formula && Array.isArray(formula)) {
+          formula.forEach(item => {
+              if (item.type === 'Element' && item.tableElementKey) {
+                  const key = item.tableElementKey;
+                  result[key] = {
+                      id: item.id,
+                      name: item.name,
+                      tableElementKey: key,
+                      type: item.type
+                  };
+              }
+          });
+      }
+  };
+  
+  // 遍历输入数组中的每一个对象元素
+  input.forEach(data => {
+      if (data.formulaIfElse && Array.isArray(data.formulaIfElse)) {
+          data.formulaIfElse.forEach(formulaItem => {
+              processTags(formulaItem.tags2);
+              processTags(formulaItem.tags3);
+          });
+      }
+      
+      processTags(data.tags4);
+      processTags(data.tags5);
+      
+      processFormula(data.formula1);
+      processFormula(data.formula2);
+  });
+  
+  if (Object.keys(result).length === 0) {
+      return null;
+  }
+  
+  return result;
+}

+ 82 - 284
src/views/formula/edit.vue

@@ -66,24 +66,16 @@
       </div>
     </div>
     <div v-show="operationVisible" class="operation-box flex1 flex flex-d-c ov-hidden">
-      <div>选择参数设置</div>
+      <div class="flex ">
+        <div>选择参数设置</div>
+        <div style="margin-left: 29%;font-weight: 700;">公式配置</div>
+      </div>
       <div class="flex flex-d-c flex1 ov-hidden">
         <el-row :gutter="20" class="flex1 ov-hidden">
           <el-col :span="8" class="h-100p">
             <el-card shadow="never" v-loading="treeLoad" class="h-100p ov-auto">
               <el-scrollbar style="height: 100%">
-                <!-- <el-tree
-                  class="filter-tree"
-                  lazy
-                  :load="loadNode"
-                  @node-click="getNodeDetail"
-                  :props="defaultProps"
-                  :expand-on-click-node="false"
-                  highlight-current
-                  node-key="id"
-                  ref="tree"
-                >
-                </el-tree> -->
+              
                 <el-tree
                   class="filter-tree"
                   :data="treeData"
@@ -100,70 +92,77 @@
             </el-card>
           </el-col>
           <el-col :span="16" class="h-100p flex flex-d-c ov-hidden">
-            <div class="flex" style="justify-content: space-between;width:100%">
-               <el-select v-model="eleTableId" @change="getTableEle" placeholder="请选择元素表1" style="width:45%">
-                <el-option v-if="paramDataList.length" label="选择节点参数2" value="选择节点参数"></el-option>
-                <el-option  v-for="item in eleTableList" :key="item.id" :label="item.tableName" :value="(item.pkeyId!==null&&item.pkeyId!==-1)?item.pkeyId:item.id"></el-option>
-              </el-select>
-              <!-- 搜索元素下拉框 -->
-              <el-select v-model="input3" filterable clearable placeholder="搜索元素字段"  @change="getInput" style="width:45%">
-              <el-option
-                v-for="item in eleList1"
-                :key="item.id"
-                :label="item.eName"
-                :value="item.eName">
-              </el-option>
-              </el-select>
-            </div>
-           
-            <div class="mg-t-10 no-mb-col flex1 ov-hidden">
-              <el-scrollbar style="height: 100%">
-                <el-row v-loading="eleListable"  v-if="eleList.length>0">
-                  <el-col :span="6" v-for="item in eleList" :key="item.id" >
-                    <div class="ele-box">
-                      <span v-if="item.k">{{item.name}}</span>
-                      <span v-else>{{item.eName}}</span>
-                      <el-checkbox v-model="item.checked" @change="value => eleChang(value,item)"></el-checkbox>
-                    </div>
+            <div class="operation-box">
+              <!-- 运算符选择区域 -->
+                  <div class="flex jc-sb operation-symbol-box">
                     
-                  </el-col>
-                </el-row>
-                <el-row v-else style="text-align: center;line-height: 328px;border:1px solid #bbb">暂无数据</el-row>
-              </el-scrollbar>
-            </div>
-            <div class="flex jc-sb">
-              <!-- <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 class="border-grey sele-ele-box" style="height:50px">
-              <draggable v-model="selectEleFormula">
-                <formula-item
-                  v-for="(item,index) in selectEleFormula" :key="index"
-                  :item="item" @click="obj => eleFormulaClick(obj,index)"
-                >
-                </formula-item>
-              </draggable>
+                    <div class="icon-box ">
+                        <span class="text-sm" >插入运算符:</span>
+                    
+                      <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>
+                       <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>
+                      操作
+                    <el-link :underline="false" icon="el-icon-delete" type="danger" @click="removeSelect"></el-link>
+                    </div>
+                  </div>
+      
+                  
+                <div class="border-grey sele-ele-box1" >
+                    <draggable v-model="selectEleFormula">
+                      <formula-item
+                        v-for="(item,index) in selectEleFormula" :key="index"
+                        :item="item" @click="obj => eleFormulaClick(obj,index)"
+                      >
+                      </formula-item>
+                    </draggable>
+                  </div>
+                  <div class="flex mg-t-10" style="justify-content: space-between;width:100%;">
+                    <el-select v-model="eleTableId" @change="getTableEle" placeholder="请选择元素表1" style="width:45%">
+                      <el-option v-if="paramDataList.length" label="选择节点参数2" value="选择节点参数"></el-option>
+                      <el-option  v-for="item in eleTableList" :key="item.id" :label="item.tableName" :value="(item.pkeyId!==null&&item.pkeyId!==-1)?item.pkeyId:item.id"></el-option>
+                    </el-select>
+                    <!-- 搜索元素下拉框 -->
+                    <!-- <el-select v-model="input3" filterable clearable placeholder="搜索元素字段"  @change="getInput" style="width:45%">
+                      <el-option
+                        v-for="item in eleList1"
+                        :key="item.id"
+                        :label="item.eName"
+                        :value="item.eName">
+                      </el-option>
+                    </el-select> -->
+                     <div class="text-align-c">
+                      <el-button size="small" @click="canceloperationVisible ">取消</el-button>
+                      <el-button size="small" @click="operationHandle" type="primary">保存</el-button>
+                    </div>
+                  </div>
+           
+                <div class="mg-t-10 no-mb-col flex1" >
+                  <el-scrollbar style="height: 350px">
+                    <el-row v-loading="eleListable"  v-if="eleList.length>0">
+                      <el-col :span="6" v-for="item in eleList" :key="item.id" >
+                        <div class="ele-box">
+                          <span v-if="item.k">{{item.name}}</span>
+                          <span v-else>{{item.eName}}</span>
+                          <el-checkbox v-model="item.checked" @change="value => eleChang(value,item)"></el-checkbox>
+                        </div>
+                        
+                      </el-col>
+                    </el-row>
+                    <el-row v-else style="text-align: center;line-height: 328px;border:1px solid #bbb">暂无数据</el-row>
+                  </el-scrollbar>
+                </div>
+         
             </div>
           </el-col>
         </el-row>
-        <div class="text-align-c">
-          <el-button size="small" @click="operationHandle" type="primary">保存</el-button>
-          <el-button size="small" @click="canceloperationVisible ">取消</el-button>
-        </div>
+       
       </div>
     </div>
     <div v-show="!operationVisible && !showFunDetail && !deviationRange.show">
@@ -457,6 +456,7 @@ import {formulaArrayToString} from "./formulaArrayToString"
 import {formulaStringToArray} from "./formulaStringToArray"
 
 import draggable from 'vuedraggable'
+import {formatArrayMore,restoreArrayMore,generateResult} from './component/funComponent/multiIfElseTools'
 
 export default {
   components: {
@@ -1372,215 +1372,11 @@ export default {
 
       return true;
     },
-  formatArrayMore(inputArray) {
-    console.log(inputArray,'inputArray');
-    
-   // 定义字段映射关系
-    const fieldMappings = {
-        'tag2': 'parameter1',
-        'tag3': 'parameter2',
-        'symbol1': 'symbol',
-        'logicSymbol': 'groupTerm',
-        'tag4': 'trueData',
-        'tag5': 'falseData'
-    };
-    
-    // 处理值的格式化,将特定格式字符串包裹在E[]中
-    function formatValue(value) {
-        // 检查是否是符合格式的字符串(包含:key_)
-        if (typeof value === 'string' && value.includes(':key_')) {
-            return `E[${value}]`;
-        }
-        return value;
-    }
 
-    // 处理单个对象的函数
-    function processObject(obj) {
-        const result = {};
-        
-            // 处理formulaIfElse(如果存在)
-            if (obj.formulaIfElse && Array.isArray(obj.formulaIfElse)) {
-                result.formulaIfElse = obj.formulaIfElse.map(item => processObject(item));
-            }
-            
-            // 处理其他字段映射
-            Object.keys(obj).forEach(key => {
-                // 特殊处理tags2、tags3、tags4和tags5
-                if (key === 'tags2' && Array.isArray(obj.tags2) && obj.tags2.length > 0) {
-                    // 如果tags2有值,取第一个对象的tableElementKey作为parameter1的值,并格式化
-                    const value = obj.tags2[0].tableElementKey || '';
-                    result.parameter1 = formatValue(value);
-                } 
-                else if (key === 'tags3' && Array.isArray(obj.tags3) && obj.tags3.length > 0) {
-                    // 如果tags3有值,取第一个对象的tableElementKey作为parameter2的值,并格式化
-                    const value = obj.tags3[0].tableElementKey || '';
-                    result.parameter2 = formatValue(value);
-                }
-                else if (key === 'tags4' && Array.isArray(obj.tags4) && obj.tags4.length > 0) {
-                    // 如果tags4有值,取第一个对象的tableElementKey作为trueData的值,并格式化
-                    const value = obj.tags4[0].tableElementKey || '';
-                    result.trueData = formatValue(value);
-                }
-                else if (key === 'tags5' && Array.isArray(obj.tags5) && obj.tags5.length > 0) {
-                    // 如果tags5有值,取第一个对象的tableElementKey作为falseData的值,并格式化
-                    const value = obj.tags5[0].tableElementKey || '';
-                    result.falseData = formatValue(value);
-                }
-                // 处理其他映射字段
-                else if (fieldMappings[key]) {
-                    // 只有当对应的tags数组没有提供值时,才使用原始字段值
-                    if ((key === 'tag2' && !result.parameter1) || 
-                        (key === 'tag3' && !result.parameter2) ||
-                        (key === 'tag4' && !result.trueData) ||
-                        (key === 'tag5' && !result.falseData) ||
-                        !['tag2', 'tag3', 'tag4', 'tag5'].includes(key)) {
-                        // 对原始字段值也进行格式化处理
-                        result[fieldMappings[key]] = formatValue(obj[key]);
-                    }
-                }
-            });
-            
-            return result;
-        }
-        
-        // 处理整个数组
-        return inputArray.map(item => processObject(item));
-  },
-restoreArrayMore(processedArray) {
-    // 定义反转的字段映射关系(与原方法相反)
-    const reverseMappings = {
-        'parameter1': 'tag2',
-        'parameter2': 'tag3',
-        'symbol': 'symbol1',
-        'groupTerm': 'logicSymbol',
-        'trueData': 'tag4',
-        'falseData': 'tag5'
-    };
-    
-    // 从this.map获取完整元素信息并构建tags对象
-    const getTagElement = (tableElementKey) => {
-        const objTargetData = JSON.parse(this.formulaDetailMap);
-        const baseData = objTargetData[tableElementKey] || {};
-        // 返回完整的tags元素结构
-        return {
-            "type": baseData.type || "Element",
-            "name": baseData.name || "",
-            "id": baseData.id || "",
-            "selected": false,
-            "tableElementKey": tableElementKey,
-            "children": [],
-            "text": baseData.name || "", // text与name保持一致
-            "style": "background-color: #409EFF" // 保持示例中的样式
-        };
-    };
-    
-    // 还原值的格式化,去掉E[]包裹
-    function restoreValue(value) {
-        if (typeof value === 'string' && value.startsWith('E[') && value.endsWith(']')) {
-            const innerValue = value.slice(2, -1);
-            if (innerValue.includes(':key_')) {
-                return innerValue;
-            }
-        }
-        return value;
-    }
 
-    // 还原单个对象的函数
-    function restoreObject(obj) {
-        const result = {};
-        
-        // 递归还原formulaIfElse(如果存在)
-        if (obj.formulaIfElse && Array.isArray(obj.formulaIfElse)) {
-            result.formulaIfElse = obj.formulaIfElse.map(item => restoreObject(item));
-        }
-        
-        // 处理参数与tags数组的还原
-        Object.keys(obj).forEach(key => {
-            const restoredValue = restoreValue(obj[key]);
-            
-            // parameter1对应tags2和tag2
-            if (key === 'parameter1') {
-                result.tags2 = [getTagElement(restoredValue)];
-                result[reverseMappings[key]] = restoredValue;
-            }
-            // parameter2对应tags3和tag3
-            else if (key === 'parameter2') {
-                result.tags3 = [getTagElement(restoredValue)];
-                result[reverseMappings[key]] = restoredValue;
-            }
-            // trueData对应tags4和tag4
-            else if (key === 'trueData') {
-                result.tags4 = [getTagElement(restoredValue)];
-                result[reverseMappings[key]] = restoredValue;
-            }
-            // falseData对应tags5和tag5
-            else if (key === 'falseData') {
-                result.tags5 = [getTagElement(restoredValue)];
-                result[reverseMappings[key]] = restoredValue;
-            }
-            // 处理其他映射字段
-            else if (reverseMappings[key]) {
-                result[reverseMappings[key]] = restoredValue;
-            }
-        });
-        
-        return result;
-    }
-    
-    // 还原整个数组
-    return processedArray.map(item => restoreObject(item));
-},
-  generateResult(input) {
-     // 检查输入是否有效
-    if (!Array.isArray(input) || input.length === 0) {
-        return null;
-    }
-    
-    // 构建结果对象
-    const result = {};
-    
-    // 处理标签的通用函数
-    const processTags = (tags) => {
-        if (tags && Array.isArray(tags)) {
-            tags.forEach(tag => {
-                const key = tag.tableElementKey;
-                if (key) {
-                    // 如果存在相同的key,这里会覆盖之前的值
-                    // 如有需要,可以修改为数组或其他处理方式
-                    result[key] = {
-                        id: tag.id,
-                        name: tag.name,
-                        tableElementKey: key,
-                        type: tag.type
-                    };
-                }
-            });
-        }
-    };
-    
-    // 遍历输入数组中的每一个对象元素
-    input.forEach(data => {
-        // 处理当前对象中的所有formulaIfElse元素
-        if (data.formulaIfElse && Array.isArray(data.formulaIfElse)) {
-            data.formulaIfElse.forEach(formulaItem => {
-                // 处理每个formulaIfElse元素中的标签
-                processTags(formulaItem.tags2);
-                processTags(formulaItem.tags3);
-            });
-        }
-        
-        // 处理当前对象根级别的标签
-        processTags(data.tags4);
-        processTags(data.tags5);
-    });
-    
-    // 检查是否有数据
-    if (Object.keys(result).length === 0) {
-        return null;
-    }
-    
-    return result;
-},
+
+
+
     //保存公式
     saveFormula(){
       console.log('保存',this.pid);
@@ -1591,9 +1387,11 @@ restoreArrayMore(processedArray) {
       if(this.$refs.dynamiccomponent&&this.$refs.dynamiccomponent.length>0&&this.$refs.dynamiccomponent[0]&& this.$refs.dynamiccomponent[0].symbol=='more'){
         //多条件保存公式
 
-        console.log('this.$refs.dynamiccomponent[0]',this.$refs.dynamiccomponent[0].conditionList);
-        let resMore=this.formatArrayMore(this.$refs.dynamiccomponent[0].conditionList);
-        const resJson=this.generateResult(this.$refs.dynamiccomponent[0].conditionList);
+        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);
+        console.log(resJson,'resJson');
+        
      
             if(this.formulaid){
               updateFormula({
@@ -1755,7 +1553,7 @@ restoreArrayMore(processedArray) {
         detail.formula = detail.formula.replace('FC.ifelseMulti','FC.ifelse');
         this.isMore = true;
             this.formulaDetailMap = detail.map;
-        this.moreConditions =  this.restoreArrayMore(detail.formulas)
+        this.moreConditions =  restoreArrayMore(detail.formulas,this.formulaDetailMap)
     
       }else{
         this.isMore = false;