|
@@ -63,7 +63,16 @@
|
|
|
<div> <el-button @click="addList()">+增加</el-button> </div>
|
|
|
<div style="border:1px solid #C0C0C0;border-radius:4px;overflow:auto;min-height:200px;padding:20px">
|
|
|
<el-row :gutter="24" v-for="(item,i) in list" :key="i">
|
|
|
- <el-col :span="3"><span><el-input v-model="item.logicOpr" ></el-input></span></el-col>
|
|
|
+ <el-col :span="3" style="padding:0"><input type="text" name="" id="" style="border:0;backgroud:white;" v-if="i==0" :disabled="true">
|
|
|
+ <el-select v-else v-model="item.logicOpr" placeholder="请选择">
|
|
|
+ <el-option
|
|
|
+ v-for="item in options"
|
|
|
+ :key="item.label"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.label">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-col>
|
|
|
<el-col :span="7"><el-input v-model="item.field"></el-input></el-col>
|
|
|
<el-col :span="3"><el-input v-model="item.opr"></el-input></el-col>
|
|
|
<el-col :span="7"><el-input v-model="item.value"></el-input></el-col>
|
|
@@ -102,7 +111,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
-
|
|
|
+ options:[{label:'你好',value:1},{label:'你好1',value:2},{label:'你好2',value:3}],
|
|
|
visible: false,
|
|
|
loading: false,
|
|
|
btnLoading: false,
|
|
@@ -125,7 +134,26 @@ export default {
|
|
|
name: [{ required: true, message: '请输入部门名称', trigger: 'blur' },],
|
|
|
parentId: [{ required: true, message: '请选择所属部门', trigger: 'change' },],
|
|
|
},
|
|
|
- list:[],
|
|
|
+ list:[{
|
|
|
+ logicOpr:'and',
|
|
|
+ field:'姓名',
|
|
|
+ opr:'=',
|
|
|
+ value:'你好'},
|
|
|
+ {
|
|
|
+ logicOpr:'你好1',
|
|
|
+ field:'年龄',
|
|
|
+ opr:'=',
|
|
|
+ value:'4'},
|
|
|
+ {
|
|
|
+ logicOpr:'or',
|
|
|
+ field:'性别',
|
|
|
+ opr:'=',
|
|
|
+ value:'男'},
|
|
|
+ {
|
|
|
+ logicOpr:'not',
|
|
|
+ field:'爱好',
|
|
|
+ opr:'=',
|
|
|
+ value:'篮球'},],
|
|
|
dataList:
|
|
|
{
|
|
|
"nodeType": "logic",
|
|
@@ -162,6 +190,7 @@ export default {
|
|
|
mounted() {
|
|
|
this.getList()
|
|
|
this.getFunctionList()
|
|
|
+ this.ListToTree()
|
|
|
},
|
|
|
computed: {
|
|
|
|
|
@@ -174,15 +203,36 @@ export default {
|
|
|
this.list.push({})
|
|
|
},
|
|
|
ListToTree(){
|
|
|
-
|
|
|
+ console.log(this.dataList)
|
|
|
+ var a =[]
|
|
|
+ if(this.list.length==1){
|
|
|
+ a = this.list[0]
|
|
|
+ a.nodeType='logic'
|
|
|
+ }else{
|
|
|
+ a[0]=this.list[0]
|
|
|
+ a[0].nodeType='exp'
|
|
|
+ for(var i =1;i<this.list.length;i++){
|
|
|
+ this.list[i].nodeType='exp'
|
|
|
+ a[i]={}
|
|
|
+ a[i].left=a[i-1]
|
|
|
+ a[i].nodeType='logic'
|
|
|
+ a[i].right=this.list[i]
|
|
|
+ a[i].logicOpr = this.list[i].logicOpr
|
|
|
+ // delete a[i].right.logicOpr
|
|
|
+ // delete a[i].left.logicOpr
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(a)
|
|
|
+ this.TreeToList(a[a.length-1])
|
|
|
},
|
|
|
- TreeToList(){
|
|
|
- var root = this.dataList
|
|
|
+ TreeToList(data){
|
|
|
+ var root = data
|
|
|
var a=[]
|
|
|
const result = [];
|
|
|
function l(root){
|
|
|
const stack = [];
|
|
|
- let last = null; // 标记上一个访问的节点
|
|
|
+ let last = null;
|
|
|
let current = root;
|
|
|
while (current || stack.length > 0) {
|
|
|
while (current) {
|
|
@@ -194,17 +244,17 @@ export default {
|
|
|
current = stack.pop();
|
|
|
result.push(current);
|
|
|
last = current;
|
|
|
- current = null; // 继续弹栈
|
|
|
+ current = null;
|
|
|
} else {
|
|
|
current = current.right;
|
|
|
}
|
|
|
}
|
|
|
- console.log(result)
|
|
|
+ // console.log(result)
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
l(root)
|
|
|
- console.log(result)
|
|
|
+ // console.log(result)
|
|
|
var i=0
|
|
|
var c=0
|
|
|
function s(i){
|
|
@@ -217,7 +267,7 @@ export default {
|
|
|
}
|
|
|
if(i%2==1){
|
|
|
a.push(result[i])
|
|
|
- console.log(a[c])
|
|
|
+ // console.log(a[c])
|
|
|
a[c]['logicOpr'] = result[i+1].logicOpr
|
|
|
i+=2
|
|
|
c+=1
|