|
@@ -12,17 +12,22 @@
|
|
|
<el-option label="小于等于且大于等于" value="<=&&<="></el-option>
|
|
|
<el-option label="试验判断" value="|"></el-option>
|
|
|
<el-option label="多条件" value="more"></el-option>
|
|
|
+ <el-option label="数据获取" value="getData"></el-option>
|
|
|
</el-select>
|
|
|
<span class="mg-l-20 mg-r-10" v-if="symbol!=='|'">执行结果</span>
|
|
|
- <el-select v-model="result" @change="setTF()" size="medium" placeholder="请选择" v-if="symbol!=='|'">
|
|
|
+ <el-select v-model="result" @change="setTF()" size="medium" placeholder="请选择" v-if="symbol!=='|'&&symbol!=='getData'" >
|
|
|
<el-option label="真假值" value="1"></el-option>
|
|
|
<el-option label="运算" value="2"></el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-select v-model="result" size="medium" placeholder="请选择" v-if="symbol=='getData'">
|
|
|
+ <el-option label="数据获取" value="3"></el-option>
|
|
|
+
|
|
|
</el-select>
|
|
|
<el-button class="mg-l-10" size="small" type="info" @click="showSelectEle">选择参数</el-button>
|
|
|
</div>
|
|
|
|
|
|
<!-- 多条件其他的 -->
|
|
|
- <template v-if="symbol !== 'more'">
|
|
|
+ <template v-if="symbol !== 'more'&&symbol !== 'getData'">
|
|
|
<div class="mg-t-20 flex jc-al-c">
|
|
|
<span class="textblod mg-r-20" v-if="symbol!=='|'">IF</span>
|
|
|
<div class="flex jc-al-c" v-if="symbol == '<&&<' || symbol == '<=&&<='">
|
|
@@ -105,7 +110,8 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<!-- 多条件 -->
|
|
|
- <template v-else>
|
|
|
+ <template v-if="symbol == 'more'">
|
|
|
+
|
|
|
<div v-for="(item, conditionIndex) in conditionList" :key="conditionIndex">
|
|
|
<!-- 从第二个条件开始显示“条件X”和删除按钮 -->
|
|
|
<div v-if="conditionIndex >= 1" class="condition-header flex al-c mg-t-20">
|
|
@@ -258,6 +264,111 @@
|
|
|
|
|
|
</div>
|
|
|
</template>
|
|
|
+ <!-- 数据获取配置框 - 修改部分 -->
|
|
|
+ <template v-if="symbol==='getData'">
|
|
|
+ <div class="mg-t-10">
|
|
|
+ <div v-for="(item, index) in getDataList" :key="index" class="mg-t-10">
|
|
|
+ <div class="flex jc-al-c">
|
|
|
+ <div class="textblod mg-r-10" :style="{ opacity: index === 0 ? 1 : 0 }">
|
|
|
+ 当
|
|
|
+ </div>
|
|
|
+ <div class="mg-r-10" :style="{ opacity: index === 0 ? 1 : 0 }">
|
|
|
+ <vue-tags-input
|
|
|
+ v-model="item.tagWhenLeft"
|
|
|
+ :tags="item.tagsWhenLeft"
|
|
|
+ @focus="setDataFocus(index, 'tagWhenLeft')"
|
|
|
+ @blur="dataInputBlur(index, 'tagWhenLeft')"
|
|
|
+ placeholder="输入/参数"
|
|
|
+ @before-adding-tag="beforeAddingTag"
|
|
|
+ @keyup.native="btKeyUp"
|
|
|
+
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div class="mg-r-10">
|
|
|
+ <el-select
|
|
|
+ v-model="item.condition"
|
|
|
+ @change="setDataCondition(index)"
|
|
|
+ size="medium"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width:120px"
|
|
|
+ >
|
|
|
+ <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-option label="不包含" value="不包含"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <div class="mg-r-10">
|
|
|
+ <vue-tags-input
|
|
|
+ v-model="item.tagWhenRight"
|
|
|
+ :tags="item.tagsWhenRight"
|
|
|
+ @focus="setDataFocus(index, 'tagWhenRight')"
|
|
|
+ @blur="dataInputBlur(index, 'tagWhenRight')"
|
|
|
+ placeholder="输入/参数"
|
|
|
+ @before-adding-tag="beforeAddingTag"
|
|
|
+ @keyup.native="btKeyUp"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="mg-r-10 textblod">则</div>
|
|
|
+ <vue-tags-input
|
|
|
+ v-model="item.tagThenLeft"
|
|
|
+ :tags="item.tagsThenLeft"
|
|
|
+ @focus="setDataFocus(index, 'tagThenLeft')"
|
|
|
+ @blur="dataInputBlur(index, 'tagThenLeft')"
|
|
|
+ placeholder="输入/参数"
|
|
|
+ @before-adding-tag="beforeAddingTag"
|
|
|
+ @keyup.native="btKeyUp"
|
|
|
+ />
|
|
|
+ <span class="mg-r-10 mg-l-10">=</span>
|
|
|
+ <div class="mg-r-10">
|
|
|
+ <vue-tags-input
|
|
|
+ v-model="item.tagThenRight"
|
|
|
+ :tags="item.tagsThenRight"
|
|
|
+ @focus="setDataFocus(index, 'tagThenRight')"
|
|
|
+ @blur="dataInputBlur(index, 'tagThenRight')"
|
|
|
+ placeholder="输入/参数"
|
|
|
+ @before-adding-tag="beforeAddingTag"
|
|
|
+ @keyup.native="btKeyUp"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <i class="el-icon-circle-plus-outline mg-l-20" style="color: #409EFF;cursor: pointer;" @click="addDataItem(index)"></i>
|
|
|
+ <i class="el-icon-delete mg-l-20" style="color: red;cursor: pointer;" @click="removeDataItem(index)" v-if="getDataList.length > 1"></i>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <div class="mg-t-10 ">
|
|
|
+ <div class="textblod " >否则</div>
|
|
|
+ <div class="flex jc-al-c " style="float: right; margin-top: -28px;" >
|
|
|
+ <vue-tags-input
|
|
|
+ v-model="elseTagLeft"
|
|
|
+ :tags="elseTagsLeft"
|
|
|
+ @focus="setElseFocus('left')"
|
|
|
+ @blur="elseInputBlur('left')"
|
|
|
+ placeholder="请选择参数"
|
|
|
+ @before-adding-tag="beforeAddingTag"
|
|
|
+ @keyup.native="btKeyUp"
|
|
|
+ class="mg-r-10"
|
|
|
+ />
|
|
|
+ <span class="mg-r-10">=</span>
|
|
|
+ <vue-tags-input
|
|
|
+ v-model="elseTagRight"
|
|
|
+ :tags="elseTagsRight"
|
|
|
+ @focus="setElseFocus('right')"
|
|
|
+ @blur="elseInputBlur('right')"
|
|
|
+ placeholder="请选择/输入参数"
|
|
|
+ @before-adding-tag="beforeAddingTag"
|
|
|
+ @keyup.native="btKeyUp"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
|
|
|
<el-dialog title="输入值" :visible.sync="inputVisible" width="300px" append-to-body :close-on-click-modal="false">
|
|
|
<el-input v-model="inputText" placeholder="请输入内容"></el-input>
|
|
@@ -273,6 +384,7 @@
|
|
|
import VueTagsInput from '@johmun/vue-tags-input';
|
|
|
import formulaItem from "../formulaItem";
|
|
|
import draggable from 'vuedraggable';
|
|
|
+import {transformData,generateElementMap,restoreData} from './multiIfElseTools'
|
|
|
|
|
|
export default {
|
|
|
name: "ifelse",
|
|
@@ -314,7 +426,21 @@ export default {
|
|
|
conditionIndex:{//当前是多条件中的哪一个
|
|
|
type: Number,
|
|
|
default: 0
|
|
|
- }
|
|
|
+ },
|
|
|
+ isGetData:{
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ dataListGet:{
|
|
|
+ type: String,
|
|
|
+ default:''
|
|
|
+ },
|
|
|
+ map:{
|
|
|
+ type: String,
|
|
|
+ default:''
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
data(){
|
|
|
return{
|
|
@@ -332,6 +458,11 @@ export default {
|
|
|
innerIndex: -1,
|
|
|
field: ''
|
|
|
},
|
|
|
+ // 数据获取部分的焦点信息
|
|
|
+ dataFocus: {
|
|
|
+ index: -1,
|
|
|
+ field: ''
|
|
|
+ },
|
|
|
symbolReg:/(\+|-|\*|\/)(.+)/,
|
|
|
inputVisible:false,
|
|
|
inputText:'',
|
|
@@ -367,9 +498,60 @@ export default {
|
|
|
formula1: [],
|
|
|
formula2: []
|
|
|
}
|
|
|
- ]//多条件的条件列表
|
|
|
+ ],//多条件的条件列表
|
|
|
+ // 修改getDataList结构,为每个项添加独立属性
|
|
|
+ getDataList:[
|
|
|
+ {
|
|
|
+ tagWhenLeft: '',
|
|
|
+ tagsWhenLeft: [],
|
|
|
+ condition: '',
|
|
|
+ tagWhenRight: '',
|
|
|
+ tagsWhenRight: [],
|
|
|
+ tagThenLeft: '',
|
|
|
+ tagsThenLeft: [],
|
|
|
+ tagThenRight: '',
|
|
|
+ tagsThenRight: []
|
|
|
+ }
|
|
|
+ ],//数据获取列表
|
|
|
+ // 否则部分的属性
|
|
|
+ elseTagLeft: '',
|
|
|
+ elseTagsLeft: [],
|
|
|
+ elseTagRight: '',
|
|
|
+ elseTagsRight: [],
|
|
|
+ elseFocus: '' // 用于跟踪否则部分的焦点
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ // 监视getDataList的变化
|
|
|
+ getDataList: {
|
|
|
+ deep: true,
|
|
|
+ handler(newVal) {
|
|
|
+ // 只有当数组中有至少一个元素时才处理
|
|
|
+ if (newVal.length > 0) {
|
|
|
+ // 获取第一个元素的tagWhenLeft值
|
|
|
+ const firstTagWhenLeft = newVal[0].tagWhenLeft;
|
|
|
+ const firstTagsWhenLeft = newVal[0].tagsWhenLeft;
|
|
|
+
|
|
|
+ // 如果第一个元素有值,同步到其他元素
|
|
|
+ if ((firstTagWhenLeft && firstTagWhenLeft.trim() !== '') ||
|
|
|
+ (firstTagsWhenLeft && firstTagsWhenLeft.length > 0)) {
|
|
|
+
|
|
|
+ // 遍历从第二个元素开始的所有元素
|
|
|
+ for (let i = 1; i < newVal.length; i++) {
|
|
|
+ // 避免触发不必要的watch循环
|
|
|
+ if (newVal[i].tagWhenLeft !== firstTagWhenLeft ||
|
|
|
+ JSON.stringify(newVal[i].tagsWhenLeft) !== JSON.stringify(firstTagsWhenLeft)) {
|
|
|
+
|
|
|
+ this.$set(newVal[i], 'tagWhenLeft', firstTagWhenLeft);
|
|
|
+ this.$set(newVal[i], 'tagsWhenLeft', [...firstTagsWhenLeft]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+},
|
|
|
mounted(){
|
|
|
console.log(this.formulainfo,'this.formulainfo333333');
|
|
|
|
|
@@ -394,12 +576,146 @@ export default {
|
|
|
|
|
|
|
|
|
|
|
|
- }else{
|
|
|
+ }else if(this.isGetData){
|
|
|
+ this.symbol = 'getData';
|
|
|
+ this.result = '3';
|
|
|
+ console.log(this.dataListGet,'dataListGet');
|
|
|
+ const str=this.dataListGet;
|
|
|
+ let resultStr=''
|
|
|
+ // 找到第一个左括号的位置
|
|
|
+ const startIndex = str.indexOf('(');
|
|
|
+ // 找到最后一个右括号的位置
|
|
|
+ const endIndex = str.lastIndexOf(')');
|
|
|
+
|
|
|
+ // 提取括号内的内容
|
|
|
+ if (startIndex !== -1 && endIndex !== -1 && startIndex < endIndex) {
|
|
|
+ const result = str.substring(startIndex + 1, endIndex);
|
|
|
+ resultStr=result
|
|
|
+ console.log(result);
|
|
|
+ } else {
|
|
|
+ console.log("未找到有效的括号对");
|
|
|
+ }
|
|
|
+
|
|
|
+ const resObj=restoreData(resultStr,JSON.parse(this.map))
|
|
|
+ console.log(resObj,'resObj');
|
|
|
+ this.getDataList=resObj.getDataList
|
|
|
+ this.elseTagLeft = resObj.elseTagLeft;
|
|
|
+ this.elseTagsLeft = resObj.elseTagsLeft;
|
|
|
+ this.elseTagRight = resObj.elseTagRight;
|
|
|
+ this.elseTagsRight = resObj.elseTagsRight;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else{
|
|
|
// this.conditionList=[]
|
|
|
}
|
|
|
|
|
|
+ // // 初始化数据获取列表
|
|
|
+ // if (this.symbol === 'getData' && this.formulainfo.arguments && this.formulainfo.arguments.length > 0) {
|
|
|
+ // console.log(this.dataListGet,'dataListGet');
|
|
|
+
|
|
|
+ // // this.initGetDataList(this.formulainfo.arguments[0]);
|
|
|
+ // }
|
|
|
},
|
|
|
methods:{
|
|
|
+ // 初始化数据获取列表
|
|
|
+ initGetDataList(data) {
|
|
|
+ if (Array.isArray(data)) {
|
|
|
+ this.getDataList = data.map(item => ({
|
|
|
+ tagWhenLeft: item.tagWhenLeft || '',
|
|
|
+ tagsWhenLeft: item.tagsWhenLeft || [],
|
|
|
+ condition: item.condition || '',
|
|
|
+ tagWhenRight: item.tagWhenRight || '',
|
|
|
+ tagsWhenRight: item.tagsWhenRight || [],
|
|
|
+ tagThenLeft: item.tagThenLeft || '',
|
|
|
+ tagsThenLeft: item.tagsThenLeft || [],
|
|
|
+ tagThenRight: item.tagThenRight || '',
|
|
|
+ tagsThenRight: item.tagsThenRight || []
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 设置数据获取部分的焦点
|
|
|
+ setDataFocus(index, field) {
|
|
|
+ this.elseFocus=false
|
|
|
+ this.dataFocus = { index, field };
|
|
|
+ },
|
|
|
+
|
|
|
+ // 数据获取部分输入框失焦处理
|
|
|
+ dataInputBlur(index, field) {
|
|
|
+ const item = this.getDataList[index];
|
|
|
+ const tagNumber = field.replace('tag', '');
|
|
|
+
|
|
|
+ if (item[field]) {
|
|
|
+ if (item[`tags${tagNumber}`] && item[`tags${tagNumber}`][0]) {
|
|
|
+ this.$emit('uncheck', item[`tags${tagNumber}`][0].id);
|
|
|
+ }
|
|
|
+ item[`tags${tagNumber}`] = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setGetDataCondition();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 添加数据获取项
|
|
|
+ addDataItem(index) {
|
|
|
+ // 获取第一个元素的值作为模板
|
|
|
+ const firstItem = this.getDataList[0];
|
|
|
+
|
|
|
+ const newItem = {
|
|
|
+ // 新添加的项直接使用第一个元素的tagWhenLeft相关值
|
|
|
+ tagWhenLeft: firstItem.tagWhenLeft,
|
|
|
+ tagsWhenLeft: [...firstItem.tagsWhenLeft],
|
|
|
+ condition: '',
|
|
|
+ tagWhenRight: '',
|
|
|
+ tagsWhenRight: [],
|
|
|
+ tagThenLeft: '',
|
|
|
+ tagsThenLeft: [],
|
|
|
+ tagThenRight: '',
|
|
|
+ tagsThenRight: []
|
|
|
+ };
|
|
|
+
|
|
|
+ this.getDataList.splice(index + 1, 0, newItem);
|
|
|
+ this.setGetDataCondition();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 删除数据获取项
|
|
|
+ removeDataItem(index) {
|
|
|
+ if (this.getDataList.length > 1) {
|
|
|
+ this.getDataList.splice(index, 1);
|
|
|
+ this.setGetDataCondition();
|
|
|
+ } else {
|
|
|
+ this.$message({ type: "warning", message: "至少保留一个数据获取条件" });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 设置数据获取条件
|
|
|
+ setDataCondition(index) {
|
|
|
+ this.setGetDataCondition();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 保存数据获取条件到公式信息
|
|
|
+ setGetDataCondition() {
|
|
|
+ this.formulainfo.arguments[0] = {
|
|
|
+ conditions: this.getDataList.map(item => ({
|
|
|
+ tagWhenLeft: item.tagWhenLeft,
|
|
|
+ tagsWhenLeft: item.tagsWhenLeft,
|
|
|
+ condition: item.condition,
|
|
|
+ tagWhenRight: item.tagWhenRight,
|
|
|
+ tagsWhenRight: item.tagsWhenRight,
|
|
|
+ tagThenLeft: item.tagThenLeft,
|
|
|
+ tagsThenLeft: item.tagsThenLeft,
|
|
|
+ tagThenRight: item.tagThenRight,
|
|
|
+ tagsThenRight: item.tagsThenRight
|
|
|
+ })),
|
|
|
+ elseCase: {
|
|
|
+ tagLeft: this.elseTagLeft,
|
|
|
+ tagsLeft: this.elseTagsLeft,
|
|
|
+ tagRight: this.elseTagRight,
|
|
|
+ tagsRight: this.elseTagsRight
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
|
|
|
clearTagsIfHasValue(obj) {
|
|
|
// 复制对象以避免修改原对象
|
|
@@ -860,6 +1176,48 @@ export default {
|
|
|
this.inputVisible = false;
|
|
|
this.inputText = '';
|
|
|
return;
|
|
|
+ }else if(this.symbol === 'getData' && this.dataFocus.index !== -1) {
|
|
|
+ // 数据获取部分处理
|
|
|
+ const { index, field } = this.dataFocus;
|
|
|
+ const item = this.getDataList[index];
|
|
|
+ const formulaType = field;
|
|
|
+
|
|
|
+ //简单语法判断
|
|
|
+ if(item[formulaType] && item[formulaType].length != 0){
|
|
|
+ let lastEle = item[formulaType][item[formulaType].length-1];
|
|
|
+ if(lastEle.type == 'Element'){
|
|
|
+ this.$message({ type: "warning", message: "输入值无法连续出现在元素后面" });
|
|
|
+ this.inputVisible = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(lastEle.type == 'Text'){
|
|
|
+ this.$message({ type: "warning", message: "输入值无法连续出现在输入值后面" });
|
|
|
+ this.inputVisible = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(lastEle.type == 'Brackets' && lastEle.name == ')'){
|
|
|
+ this.$message({ type: "warning", message: "输入值无法连续出现在右括号后面" });
|
|
|
+ this.inputVisible = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加输入值到相应字段
|
|
|
+ const tagField = field;
|
|
|
+ const tagsField = `tags${field.replace('tag', '')}`;
|
|
|
+
|
|
|
+ item[tagsField].push({
|
|
|
+ type: 'Text',
|
|
|
+ name: this.inputText,
|
|
|
+ text: this.inputText,
|
|
|
+ style: 'background-color: #409EFF'
|
|
|
+ });
|
|
|
+ item[tagField] = '';
|
|
|
+
|
|
|
+ this.setGetDataCondition();
|
|
|
+ this.inputVisible = false;
|
|
|
+ this.inputText = '';
|
|
|
+ return;
|
|
|
}else{
|
|
|
return;
|
|
|
}
|
|
@@ -906,6 +1264,92 @@ export default {
|
|
|
},
|
|
|
|
|
|
setELe(ele){
|
|
|
+
|
|
|
+ if (this.symbol === 'getData' && this.elseFocus) {
|
|
|
+ let obj = {};
|
|
|
+ if(ele.k){
|
|
|
+ obj = {
|
|
|
+ type:'ParamData',
|
|
|
+ name:ele.name,
|
|
|
+ id:ele.id,
|
|
|
+ selected:false,
|
|
|
+ v:ele.v,
|
|
|
+ k:ele.k,
|
|
|
+ children:[],
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ obj = {
|
|
|
+ type:'Element',
|
|
|
+ name:ele.eName,
|
|
|
+ id:ele.id,
|
|
|
+ selected:false,
|
|
|
+ tableElementKey:ele.tableElementKey,
|
|
|
+ children:[],
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据当前焦点位置设置对应的标签
|
|
|
+ const position = this.elseFocus;
|
|
|
+ const tagField = `elseTag${position.charAt(0).toUpperCase() + position.slice(1)}`;
|
|
|
+ const tagsField = `elseTags${position.charAt(0).toUpperCase() + position.slice(1)}`;
|
|
|
+
|
|
|
+ // 清除之前选择的元素
|
|
|
+ if (this[tagsField] && this[tagsField][0]) {
|
|
|
+ this.$emit('uncheck', this[tagsField][0].id);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置新选择的元素
|
|
|
+ obj.text = obj.name;
|
|
|
+ obj.style = 'background-color: #409EFF';
|
|
|
+ this[tagsField] = [obj];
|
|
|
+ this[tagField] = '';
|
|
|
+
|
|
|
+ this.setGetDataCondition();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 处理数据获取情况
|
|
|
+ if (this.symbol === 'getData' && this.dataFocus.index !== -1) {
|
|
|
+ const { index, field } = this.dataFocus;
|
|
|
+ const item = this.getDataList[index];
|
|
|
+
|
|
|
+ let obj = {};
|
|
|
+ if(ele.k){
|
|
|
+ obj = {
|
|
|
+ type:'ParamData',
|
|
|
+ name:ele.name,
|
|
|
+ id:ele.id,
|
|
|
+ selected:false,
|
|
|
+ v:ele.v,
|
|
|
+ k:ele.k,
|
|
|
+ children:[],
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ obj = {
|
|
|
+ type:'Element',
|
|
|
+ name:ele.eName,
|
|
|
+ id:ele.id,
|
|
|
+ selected:false,
|
|
|
+ tableElementKey:ele.tableElementKey,
|
|
|
+ children:[],
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 清除之前选择的元素
|
|
|
+ const tagsField = `tags${field.replace('tag', '')}`;
|
|
|
+ if (item[tagsField] && item[tagsField][0]) {
|
|
|
+ this.$emit('uncheck', item[tagsField][0].id);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置新选择的元素
|
|
|
+ obj.text = obj.name;
|
|
|
+ obj.style = 'background-color: #409EFF';
|
|
|
+ item[tagsField] = [obj];
|
|
|
+ item[field] = '';
|
|
|
+
|
|
|
+ this.setGetDataCondition();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
// 处理多条件情况
|
|
|
if (this.symbol === 'more' && this.multiFocus.conditionIndex !== -1) {
|
|
|
const { conditionIndex, innerIndex, field } = this.multiFocus;
|
|
@@ -1146,45 +1590,48 @@ export default {
|
|
|
|
|
|
//写入参数真假值判断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 if(this.symbol !== 'more'){
|
|
|
- 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;
|
|
|
+ if(this.symbol == '<&&<' || this.symbol == '<=&&<=' || this.symbol !== 'more' && this.symbol !== 'getData') {
|
|
|
+ // 处理单条件情况
|
|
|
+ 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{
|
|
|
- arr[2] = this.tags3[0];
|
|
|
+ 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;
|
|
|
}
|
|
|
- this.formulainfo.arguments[0] = arr;
|
|
|
- } else {
|
|
|
+ } else if(this.symbol == 'more'){
|
|
|
// 处理多条件情况
|
|
|
this.formulainfo.arguments[0] = this.conditionList.map(condition => ({
|
|
|
formulaIfElse: condition.formulaIfElse.map(inner => ({
|
|
@@ -1202,6 +1649,9 @@ export default {
|
|
|
formula1: condition.formula1,
|
|
|
formula2: condition.formula2
|
|
|
}));
|
|
|
+ } else if(this.symbol == 'getData'){
|
|
|
+ this.result='3'
|
|
|
+ // 数据获取情况已在setGetDataCondition中处理
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -1282,7 +1732,7 @@ export default {
|
|
|
|
|
|
//写入参数真假值
|
|
|
setTF(){
|
|
|
- if(this.symbol !== 'more') {
|
|
|
+ if(this.symbol !== 'more' && this.symbol !== 'getData') {
|
|
|
if(this.result == 1){
|
|
|
if(this.tags4.length == 0){
|
|
|
this.formulainfo.arguments[1] = this.tag4;
|
|
@@ -1366,7 +1816,57 @@ export default {
|
|
|
} else {
|
|
|
this.$message({ type: "warning", message: "至少保留一个条件项" });
|
|
|
}
|
|
|
+ },
|
|
|
+ // 设置否则部分的焦点
|
|
|
+ setElseFocus(position) {
|
|
|
+ this.elseFocus = position;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 否则部分输入框失焦处理
|
|
|
+ elseInputBlur(position) {
|
|
|
+ const tagField = `elseTag${position.charAt(0).toUpperCase() + position.slice(1)}`;
|
|
|
+ const tagsField = `elseTags${position.charAt(0).toUpperCase() + position.slice(1)}`;
|
|
|
+
|
|
|
+ if (this[tagField]) {
|
|
|
+ if (this[tagsField] && this[tagsField][0]) {
|
|
|
+ this.$emit('uncheck', this[tagsField][0].id);
|
|
|
+ }
|
|
|
+ this[tagsField] = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setGetDataCondition();
|
|
|
+ },
|
|
|
+ //返回数据获取相关的数据
|
|
|
+ getDataConditionData() {
|
|
|
+ const inputData = {
|
|
|
+ // 获取数据列表的函数
|
|
|
+ getDataList: this.getDataList,
|
|
|
+ // 左侧else标签
|
|
|
+ elseTagLeft: this.elseTagLeft,
|
|
|
+ elseTagsLeft: this.elseTagsLeft,
|
|
|
+ // 左侧else标签集合
|
|
|
+ elseTagRight:this.elseTagRight,
|
|
|
+ elseTagsRight:this.elseTagsRight,
|
|
|
}
|
|
|
+ console.log(inputData,'inputData');
|
|
|
+
|
|
|
+ const result = transformData(inputData);
|
|
|
+ const mapEle=generateElementMap(inputData)
|
|
|
+ return {
|
|
|
+ // 获取数据列表的函数
|
|
|
+ getDataList: this.getDataList,
|
|
|
+ elseTagsLeft: this.elseTagsLeft,
|
|
|
+ // 左侧else标签
|
|
|
+ elseTagLeft: this.elseTagLeft,
|
|
|
+ // 左侧else标签集合
|
|
|
+ elseTagRight:this.elseTagRight,
|
|
|
+ elseTagsRight:this.elseTagsRight,
|
|
|
+ result,
|
|
|
+ mapEle
|
|
|
+
|
|
|
+
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|