yuxc
2025-01-15 2bea732496b4f5051233ed94e206160992351596
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
<template>
  <div style="padding: 0 10px">
    <div style="text-align: center;margin-bottom: 10px">
      <avue-radio v-model="radioForm" :dic="radioDic" :disabled="readOnly"
                  style="margin: 0 20px 0 0;display: inline-block"></avue-radio>
      <el-button v-if="!readOnly" plain size="mini" type="primary" @click="clearValue">清空值</el-button>
      <el-button v-if="!readOnly" plain size="mini" type="primary" @click="delAll">删除全部条件</el-button>
    </div>
    <div v-if="radioForm==0" style="height: calc(100% - 75px);text-align: center;" @drop="drop" @dragover.prevent>
      <div v-for="(condition,index) in conditionList" :key="index" class="el-input--small"
           style="margin-bottom: 5px; text-align:left">
        <span :title="condition.clause"
              style="width: 32%;display: inline-block;text-align: right;word-break: break-all">{{ condition.clause }}</span>
        <avue-select v-model="condition.operator" :clearable="false" :dic="condition.operatorDic" :disabled="readOnly"
                     style="width: 80px;margin: 0 5px;" type="tree"></avue-select>
        <el-date-picker v-if="condition.type=='VTDate'" v-model="condition.ordinaryValue" :disabled="readOnly"
                        style="width:36%;margin-right: 5px;display: inline-block;" type="date"
                        value-format="YYYY-MM-DD">
        </el-date-picker>
        <el-date-picker v-else-if="condition.type=='VTDateTime'" v-model="condition.ordinaryValue" :disabled="readOnly"
                        style="width:36%;margin-right: 5px;display: inline-block;"
                        type="datetime">
        </el-date-picker>
        <el-time-select v-else-if="condition.type=='VTTime'" v-model="condition.ordinaryValue" :disabled="readOnly"
                        style="width:36%;margin-right: 5px;display: inline-block;" value-format="HH:mm:ss">
        </el-time-select>
        <!--<avue-input-number v-else-if="condition.type=='VTInteger'" v-model="condition.ordinaryValue"
                           :disabled="readOnly"
                           precision="0"
                           style="width:300px;margin-right: 5px;display: inline-block;"></avue-input-number>
        <avue-input-number v-else-if="condition.type=='VTLong' || condition.type=='VTDouble'"
                           v-model="condition.ordinaryValue"
                           :disabled="readOnly"
                           style="width:300px;margin-right: 5px;display: inline-block;"></avue-input-number>
        <avue-input v-else v-model="condition.ordinaryValue" :disabled="readOnly" placeholder=""
                    style="width: 300px;margin-right: 5px;"></avue-input>-->
        <avue-input v-else v-model="condition.ordinaryValue" :disabled="readOnly" placeholder=""
                    style="width: 36%;margin-right: 5px;"></avue-input>
        <el-button v-if="!readOnly" plain size="mini" type="primary" @click="checkTemp(index)">选择查询模板</el-button>
        <el-button v-if="!readOnly" icon="el-icon-delete" size="mini" style="padding: 7px 8px" type="danger"
                   @click="delCondition(index)"></el-button>
      </div>
    </div>
    <div v-else style="height: 220px;text-align: left" @drop="drop" @dragover.prevent>
      <avue-tree ref="tree" :data="treeData" :option="treeOption"
                 node-key="value"
                 style="height: 220px" @node-drag-end="handleDragEnd" @node-drag-leave="handleDragLeave"
                 @node-drag-over="handleDragOver"
                 @node-click="nodeClick"></avue-tree>
    </div>
    <div v-if="!readOnly" style="text-align: right;margin-top: 10px;">
      <el-button v-show="radioForm==1" plain size="mini" type="primary" @click="addHandler">增加逻辑</el-button>
      <el-button v-show="radioForm==1" plain size="mini" type="primary" @click="editHandler">修改条件</el-button>
      <el-button v-show="radioForm==1" plain size="mini" type="primary" @click="delHandler">删除</el-button>
      <el-button plain size="mini" type="primary" @click="queryHandler">查询</el-button>
      <!--<el-button plain size="mini" type="primary" @click="">取消</el-button>-->
    </div>
 
    <!--修改条件-->
    <el-dialog v-dialogDrag
               :append-to-body="true"
               :close-on-click-modal="false"
               :destroy-on-close="true"
               :title="dialog.title"
               :visible.sync="dialog.showDialog"
               class="avue-dialog"
               width="550px"
               @close="dialog.showDialog=false">
      <div style="height: 200px;">
        {{ clickNode.showLabel }}
        <avue-select v-if="['VTInteger','VTDouble','VTLong'].includes(clickNode.type)" v-model="clickNode.operator"
                     :clearable="false" :dic="operatorIntDic" style="width: 80px;margin: 0 5px;"
                     type="tree"></avue-select>
        <avue-select v-else-if="['VTDateTime','VTDate','VTTime'].includes(clickNode.type)" v-model="clickNode.operator"
                     :clearable="false" :dic="operatorDateDic" style="width: 80px;margin: 0 5px;"
                     type="tree"></avue-select>
        <avue-select v-else v-model="clickNode.operator" :clearable="false" :dic="operatorDic"
                     style="width: 80px;margin: 0 5px;"
                     type="tree"></avue-select>
        <el-date-picker v-if="clickNode.type=='VTDate'" v-model="clickNode.inputValue"
                        style="width:300px;display: inline-block;" type="date"
                        value-format="YYYY-MM-DD">
        </el-date-picker>
        <el-date-picker v-else-if="clickNode.type=='VTDateTime'" v-model="clickNode.inputValue"
                        style="width:350px;display: inline-block;"
                        type="datetime">
        </el-date-picker>
        <el-time-select v-else-if="clickNode.type=='VTTime'" v-model="clickNode.inputValue"
                        style="width:300px;display: inline-block;"
                        value-format="HH:mm:ss">
        </el-time-select>
        <avue-input-number v-else-if="clickNode.type=='VTInteger'" v-model="clickNode.inputValue" precision="0"
                           style="width:300px;display: inline-block;"></avue-input-number>
        <avue-input-number v-else-if="clickNode.type=='VTLong' || clickNode.type=='VTDouble'"
                           v-model="clickNode.inputValue"
                           style="width:300px;display: inline-block;"></avue-input-number>
        <avue-input v-else v-model="clickNode.inputValue" style="width: 300px;margin-right: 5px;vertical-align: top;"
                    type="textarea"></avue-input>
      </div>
      <div class="dialog-footer avue-dialog__footer">
        <el-button v-if="!['VTInteger','VTDouble','VTLong','VTDateTime','VTDate','VTTime'].includes(clickNode.type)"
                   size="small"
                   @click="checkTemp">
          选择查询模板
        </el-button>
        <el-button plain size="small" type="primary" @click="submitDialog">保 存</el-button>
        <el-button size="small" @click="dialog.showDialog=false">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog v-dialogDrag
               :append-to-body="true"
               :close-on-click-modal="false"
               :destroy-on-close="true"
               :title="queryDialog.title"
               :visible.sync="queryDialog.showDialog"
               class="avue-dialog"
               width="800px"
               @close="cancleQueryDialog">
      <div class="el-input--small">
        输入查询字段:
        <avue-input v-model="queryField" style="width: 500px;margin-bottom: 10px"></avue-input>
        <avue-crud ref="crud" :data="crudData" :option="crudOption"
                   :page.sync="page"
                   :table-loading="tableLoading"
                   @selection-change="selectionChange"
                   @row-click="rowClick"
                   @size-change="sizeChange"
                   @current-change="currentChange">
        </avue-crud>
      </div>
      <div class="dialog-footer avue-dialog__footer">
        <el-button plain size="small" type="primary" @click="submitQueryDialog">确 定</el-button>
        <el-button size="small" @click="cancleQueryDialog">取 消</el-button>
      </div>
    </el-dialog>
    <!--查询-->
    <el-dialog v-dialogDrag
               :append-to-body="true"
               :close-on-click-modal="false"
               :destroy-on-close="true"
               :title="queryResultDialog.title"
               :visible.sync="queryResultDialog.showDialog"
               class="avue-dialog"
               width="900px"
               @close="queryResultDialog.showDialog=false">
      <div class="el-input--small">
        <avue-crud ref="crud" :data="resultData" :option="resultOption"
                   :table-loading="queryResultDialog.loading">
        </avue-crud>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import basicOption from "@/util/basic-option";
import {getAllQTs} from "@/api/queryTemplate/queryDefine";
import {dateFormat} from "@/util/date"
 
export default {
  name: "formQueryDialog",
  props: {
    queryCondition: {
      type: Array,
      default: []
    },
    queryTree: {
      type: Object,
      default: {}
    },
    levelFlag: {
      type: Number,
      default: 0
    },
    readOnly: {
      type: Boolean,
      default: false
    },
    searchColumn: {
      type: Array,
      default: [
        {
          label: 'OID',
          prop: 'OID',
        },
        {
          label: 'CREATOR',
          prop: 'CREATOR'
        },
        {
          label: 'CREATETIME',
          prop: 'CREATETIME'
        },
      ]
    },
  },
  data() {
    return {
      dialog: {
        showDialog: false,
        title: "查询条件设置框",
        loading: false
      },
      queryDialog: {
        showDialog: false,
        title: "选择查询模板",
        loading: false
      },
      queryResultDialog: {
        showDialog: false,
        title: "查询结果",
        loading: false
      },
      radioDic: [{
        label: '普通',
        value: 0
      }, {
        label: '高级',
        value: 1
      }],
      conditionList: [],
      treeData: [],
      treeOption: {
        defaultExpandAll: true,
        menu: false,
        addBtn: false,
        filter: false,
        draggable: true,
        allowDrop: (draggingNode, dropNode, type) => {
          debugger;
          if (dropNode.data.label === '并且' || dropNode.data.label === '或者') {
            return true;
          } else {
            this.$message.error('请选中逻辑条件添加查询项');
            return false;
          }
        },
        allowDrag: (draggingNode) => {
          return false;
        },
      },
      page: {
        currentPage: 1,
        pageSize: 10,
        total: 0,
        pageSizes: [10, 30, 50, 100],
      },
      crudData: [],
      crudOption: {
        ...basicOption,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        tip: false,
        header: false,
        height: window.innerHeight - 220,
        menu: false,
        column: [{
          label: '查询模板名称',
          prop: 'qtName',
          sortable: true,
        }, {
          label: '链接类型或业务类型',
          prop: 'btmName',
          sortable: true,
        }]
      },
      tableLoading: false,
      selectionRow: [],
      queryField: '',
      resultData: [],
      resultOption: {
        ...basicOption,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        tip: false,
        header: false,
        height: window.innerHeight - 220,
        menu: false,
        column: this.searchColumn
      },
      clickNode: {},
      operatorIntDic: [{
        label: '=',
        value: '='
      }, {
        label: '!=',
        value: '!='
      }, {
        label: '包含',
        value: '包含'
      }, {
        label: 'in',
        value: 'in'
      }, {
        label: 'not in',
        value: 'not in'
      }, {
        label: '>=',
        value: '>='
      }, {
        label: '>',
        value: '>'
      }, {
        label: '<=',
        value: '<='
      }, {
        label: '<',
        value: '<'
      }],
      operatorDateDic: [{
        label: '=',
        value: '='
      }, {
        label: '!=',
        value: '!='
      }, {
        label: 'in',
        value: 'in'
      }, {
        label: 'not in',
        value: 'not in'
      }, {
        label: '>=',
        value: '>='
      }, {
        label: '<=',
        value: '<='
      }],
      operatorDic: [{
        label: '=',
        value: '='
      }, {
        label: '!=',
        value: '!='
      }, {
        label: '包含',
        value: '包含'
      }, {
        label: 'in',
        value: 'in'
      }, {
        label: 'not in',
        value: 'not in'
      }]
    }
  },
  computed: {
    radioForm: {
      get() {
        return this.levelFlag;
      },
      set(value) {
        this.$emit('update:levelFlag', value);
      }
    }
  },
  watch: {
    queryCondition: {
      handler(val) {
        if (val && val.cIMap) {
          let list = [];
          let that = this;
          let getValue = function (queryTemplate, item) {
            if(queryTemplate.id.indexOf('qt_')==0){
              item.clause += '.' + queryTemplate.condition.cIMap['ci1'].leafInfo.clause;
              item.ordinaryValue = queryTemplate.condition.cIMap['ci1'].leafInfo.value.ordinaryValue;
              item.type = queryTemplate.condition.cIMap['ci1'].leafInfo.type;
            }else {
              item.ordinaryValue = queryTemplate.id+';'+queryTemplate.clauseList.join(',');
              /*for (let key in queryTemplate.condition.cIMap) {
                if (queryTemplate.condition.cIMap[key].leaf) {
                  item.clause += '.' + queryTemplate.condition.cIMap[key].leafInfo.clause;
                  if (queryTemplate.condition.cIMap[key].leafInfo.value.queryTemplate) {
                    getValue(queryTemplate.condition.cIMap[key].leafInfo.value.queryTemplate, item)
                  } else {
                    item.ordinaryValue = queryTemplate.condition.cIMap[key].leafInfo.value.ordinaryValue;
                    item.type = queryTemplate.condition.cIMap[key].leafInfo.type;
                  }
                }
              }*/
            }
            if (['VTInteger', 'VTDouble', 'VTLong'].includes(item.type)) {
              item.operatorDic = that.operatorIntDic;
            } else if (['VTDateTime', 'VTDate', 'VTTime'].includes(item.type)) {
              item.operatorDic = that.operatorDateDic;
            } else {
              item.operatorDic = that.operatorDic;
            }
          }
          for (let key in val.cIMap) {
            if (this.queryCondition.cIMap[key].leaf) {
              let clause = this.queryCondition.cIMap[key].leafInfo.clause;
              let operator = this.queryCondition.cIMap[key].leafInfo.operator;
              let item = {
                clause: clause,
                operator: operator,
                ordinaryValue: '',
                operatorDic: []
              }
              if (this.queryCondition.cIMap[key].leafInfo.value.queryTemplate) {
                  getValue(this.queryCondition.cIMap[key].leafInfo.value.queryTemplate, item)
              } else {
                item.ordinaryValue = this.queryCondition.cIMap[key].leafInfo.value.ordinaryValue;
                item.type = this.queryCondition.cIMap[key].leafInfo.type;
                if (['VTInteger', 'VTDouble', 'VTLong'].includes(item.type)) {
                  item.operatorDic = that.operatorIntDic;
                } else if (['VTDateTime', 'VTDate', 'VTTime'].includes(item.type)) {
                  item.operatorDic = that.operatorDateDic;
                } else {
                  item.operatorDic = that.operatorDic;
                }
              }
              list.push(item)
            }
          }
          this.conditionList = list;
        } else {
          this.conditionList = []
        }
      },
      immediate: true,
      deep: true
    },
    queryTree: {
      handler(val) {
        this.treeIndex = 0;
        if (val && Object.keys(val).length > 0) {
          let treeData = [];
          let that = this;
 
          function initValue(nodeChild) {
            let children = [];
            if (nodeChild) {
              nodeChild.forEach((item, index) => {
                that.treeIndex++;
                if (item.column != null && item.column != undefined) {
                  const values = item.column.split(' ');
                  let inputValue = '';
                  let operator = '';
                  let showLabel = ''
                  if (item.column.indexOf('not in') != -1) {
                    operator = 'not in';
                    if (values.length > 3) {
                      inputValue = values[3];
                    }
                  } else {
                    if (values.length > 1) {
                      operator = values[1];
                      if (values.length > 2) {
                        inputValue = values[2];
                      }
                    }
                  }
 
                  if (values[0].indexOf('.') != -1) {
                    const labels = values[0].split('.')
                    showLabel = labels[labels.length - 1];
                  } else {
                    showLabel = values[0];
                  }
                  children.push({
                    label: item.column,
                    value: item.column + that.treeIndex,
                    type: item.type,
                    valueIndex: 'v' + that.treeIndex,
                    inputValue: inputValue,
                    operator: operator,
                    showLabel: showLabel
                  })
                } else {
                  children.push({
                    label: item.connector,
                    value: item.connector + that.treeIndex,
                    valueIndex: 'v' + that.treeIndex,
                    children: initValue(item.child)
                  })
                }
              })
            }
            return children;
          }
 
          const node = {
            label: val.connector,
            value: val.connector + this.treeIndex,
            valueIndex: 'v' + this.treeIndex,
            children: initValue(val.child)
          }
          treeData.push(node)
          this.treeData = treeData;
        } else {
          this.treeData = [{
            label: '并且',
            value: '并且' + this.treeIndex,
            valueIndex: 'v' + this.treeIndex,
            connector: '并且',
            children: []
          }]
        }
      },
      immediate: true,
      deep: true
    }
  },
  created() {
    if (!this.readOnly) {
      this.getTemp();
    }
  },
  methods: {
    // 拖拽到时
    drop(event) {
      // 使用 getData 方法获取数据
      const data = JSON.parse(event.dataTransfer.getData('item'));
      if (this.radioForm == 0) {
        const params = {
          clause: data.name,
          operator: '=',
          ordinaryValue: ''
        }
        if (data.vtDataType == 'VTInteger' || data.vtDataType == 'VTDouble' || data.vtDataType == 'VTLong') {
          params.operatorDic = JSON.parse(JSON.stringify(this.operatorIntDic));
        } else if (data.vtDataType == 'VTDateTime' || data.vtDataType == 'VTDate' || data.vtDataType == 'VTTime') {
          params.operatorDic = JSON.parse(JSON.stringify(this.operatorDateDic))
        } else {
          params.operatorDic = JSON.parse(JSON.stringify(this.operatorDic))
        }
        params.type = data.vtDataType;
        this.conditionList.push(params)
      } else {
        if (this.clickNode.label != '并且' && this.clickNode.label != '或者') {
          this.$message.error('请选中逻辑条件添加查询项');
          return;
        }
        this.$refs.tree.append(this.initItem(data), this.clickNode);
      }
    },
    initItem(data) {
      this.treeIndex++;
      let item = {
        label: data.name,
        value: data.name + this.treeIndex,
        valueIndex: 'v' + this.treeIndex,
        type: data.vtDataType,
        children: [],
        inputValue: '',
        operator: '=',
        showLabel: data.name
      };
      let showLabel = '';
      if (data.name.indexOf('.') != -1) {
        const labels = data.name.split('.')
        showLabel = labels[labels.length - 1];
      } else {
        showLabel = data.name;
      }
      item.showLabel = showLabel;
      return item
    },
    handleDragEnd(draggingNode, dropNode, dropType, ev) {
      console.log('tree drag end: ', dropNode && dropNode.label, dropType);
    },
    handleDragOver({event}) {
      // 阻止默认事件,允许放置
      event.preventDefault();
    },
    handleDragLeave({event}) {
      // 清除放置效果
      event.preventDefault();
    },
    //删除普通查询条件
    delCondition(index) {
      this.conditionList.splice(index, 1);
    },
    //清空值
    clearValue() {
      if (this.radioForm == 0) {
        this.conditionList.map(item => {
          item.ordinaryValue = '';
          return item;
        })
        this.conditionList = this.conditionList
      } else {
        if (this.treeData[0] && this.treeData[0].children) {
          this.clearTreeValue(this.treeData[0].children)
        }
      }
    },
    clearTreeValue(nodes) {
      nodes.forEach((node, index) => {
        if (node.children) {
          this.clearTreeValue(node.children)
        } else {
          if (node.label.indexOf('not in') != -1) {
            node.label = node.label.split(' ')[0] + ' not in'
          } else {
            let values = node.label.split(' ');
            if (values.length > 2) {
              node.label = values[0] + ' ' + values[1];
            }
          }
        }
      })
    },
    //删除全部条件
    delAll() {
      if (this.radioForm == 0) {
        this.conditionList = [];
      } else {
        this.treeIndex = 0;
        this.treeData = [];
        this.clickNode = {};
      }
    },
    nodeClick(data) {
      this.clickNode = data
    },
    //树 增加逻辑条件
    addHandler() {
      if (Object.keys(this.clickNode).length > 0) {
        if (this.clickNode.label == '并且' || this.clickNode.label == '或者') {
          this.treeIndex++;
          this.$refs.tree.append({
            label: '并且',
            value: '并且' + this.treeIndex,
            valueIndex: 'v' + this.treeIndex,
            children: []
          }, this.$refs.tree.getCurrentNode());
        } else {
          this.$message.error("只能对逻辑条件增加逻辑条件");
        }
      } else {
        if (this.treeData.length == 0) {
          this.treeIndex = 0;
          this.treeData = [{
            label: '并且',
            value: '并且' + this.treeIndex,
            valueIndex: 'v' + this.treeIndex,
            connector: '并且',
            children: []
          }]
        } else {
          this.$message.warning("请选择查询条件");
        }
      }
    },
    //树 修改条件
    editHandler() {
      if (Object.keys(this.clickNode).length > 0) {
        if (this.clickNode.label == '并且') {
          this.clickNode.label = '或者'
        } else if (this.clickNode.label == '或者') {
          this.clickNode.label = '并且'
        } else {
          this.dialog.showDialog = true;
        }
      } else {
        this.$message.warning("请选择查询条件");
      }
    },
    //树 删除条件
    delHandler() {
      if (Object.keys(this.clickNode).length > 0) {
        this.$confirm('您确定要删除所选择的条件吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$refs.tree.remove(this.clickNode);
          this.clickNode = {};
        })
      } else {
        this.$message.warning("请选择查询条件");
      }
    },
    //查询
    queryHandler() {
      this.$emit('queryHandler');
    },
    //选择查询模板
    checkTemp(index) {
      if (index >= 0) {
        if (['VTDateTime', 'VTDate', 'VTTime'].includes(this.conditionList[index].type)) {
          this.$message.warning("该属性类型不能选择查询模板");
          return false;
        }
      }
      this.queryIndex = index;
      this.queryDialog.showDialog = true;
      this.$nextTick(() => {
        this.$refs.crud.doLayout();
      });
    },
    //查询条件保存
    submitDialog() {
      const values = this.clickNode.label.split(' ');
      this.clickNode.label = values[0] + ' ' + this.clickNode.operator + ' ' + this.clickNode.inputValue;
      try {
        if (['VTDateTime'].includes(this.clickNode.type)) {
          this.clickNode.label = values[0] + ' ' + this.clickNode.operator + ' ' + dateFormat(this.clickNode.inputValue);
        } else if (['VTDate'].includes(this.clickNode.type)) {
          this.clickNode.label = values[0] + ' ' + this.clickNode.operator + ' ' + dateFormat(this.clickNode.inputValue, 'yyyy-MM-dd');
        } else if (['VTTime'].includes(this.clickNode.type)) {
          this.clickNode.label = values[0] + ' ' + this.clickNode.operator + ' ' + dateFormat(this.clickNode.inputValue, 'hh:mm:ss');
        }
      } catch (e) {
 
      }
 
      this.dialog.showDialog = false;
    },
    //获取查询模板列表
    getTemp() {
      getAllQTs(this.page.currentPage, this.page.pageSize).then(res => {
        this.crudData = res.data.data;
        this.tableLoading = false;
      })
    },
    rowClick(row) {
      this.$refs.crud.toggleSelection();
      this.$refs.crud.toggleRowSelection(row); //选中当前行
      this.selectionRow = [row];
    },
    selectionChange(list) {
      this.selectionRow = list;
    },
    selectionClear() {
      this.selectionRow = [];
      this.$refs.crud.toggleSelection();
    },
    //选择查询模板
    submitQueryDialog() {
      if (this.selectionRow.length == 0) {
        this.$message.error('请选择查询模板再进行操作');
        return;
      }
      if (this.queryField == '') {
        this.$message.error('请填写输入查询字段');
        return;
      }
      const value = this.selectionRow[0].qtName + ';' + this.queryField
      if (this.radioForm == 0) {
        //普通
        this.conditionList[this.queryIndex].ordinaryValue = value;
      } else {
        this.clickNode.inputValue = value;
      }
      this.cancleQueryDialog();
    },
    cancleQueryDialog() {
      this.queryDialog.showDialog = false;
      this.selectionClear();
      this.queryField = '';
      this.queryIndex = null;
    },
    sizeChange(val) {
      this.page.pageSize = val;
      this.getTemp();
    },
 
    // 页码
    currentChange(val) {
      this.page.currentPage = val;
      this.getTemp();
    },
  }
}
</script>
 
<style lang="scss" scoped>
::v-deep {
  .el-input--small .el-input__inner {
    height: 28px;
    line-height: 28px;
  }
 
  .el-radio {
    margin-right: 30px;
  }
}
</style>