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
  | <template> 
 |    <div class="qk-search" :class="[formLen == 1 ? 'form-1' : '', hasDate ? 'date-form' : 'qk-form']"> 
 |      <vol-form ref="searchForm" size="default" labelPosition="left" :load-key="false" :label-width="labelWidth" 
 |        :formRules="formOptions" :formFields="searchFormFields" :select2Count="select2Count"> 
 |      </vol-form> 
 |    </div> 
 |  </template> 
 |  <script> 
 |  import VolForm from "@/components/basic/VolForm.vue"; 
 |  export default { 
 |    components: { 
 |      VolForm 
 |    }, 
 |    props: { 
 |      select2Count: { 
 |        type: Number, 
 |        default: 2000 
 |      }, 
 |      labelWidth: { 
 |        type: Number, 
 |        default: 100 
 |      }, 
 |      searchFormOptions: { 
 |        type: Array, 
 |        default: () => { 
 |          return [] 
 |        }, 
 |      }, 
 |      searchFormFields: { 
 |        type: Object, 
 |        default: () => { 
 |          return {}; 
 |        }, 
 |      }, 
 |      tiggerPress: { 
 |        type: Function, 
 |        default: () => { }, 
 |      }, 
 |      queryFields: { //快捷查询的字段 
 |        type: Array, 
 |        default: () => { 
 |          return [] 
 |        }, 
 |      } 
 |    }, 
 |    methods: { 
 |    
 |    }, 
 |    data() { 
 |      return { 
 |        formLen: 1, 
 |        formOptions: [], 
 |        hasDate: false 
 |      } 
 |    }, 
 |    created() { 
 |      let ops = []; 
 |      if (this.queryFields.length) { 
 |        for (let index = 0; index < this.queryFields.length; index++) { 
 |          const field = this.queryFields[index]; 
 |          this.searchFormOptions.forEach(options => { 
 |            options.forEach(x => { 
 |              if (field == x.field) { 
 |                ops.push(x); 
 |              } 
 |            }) 
 |          }) 
 |        } 
 |        // this.formOptions.push(ops); 
 |        this.formLen = ops.length; 
 |      } 
 |      else if (this.searchFormOptions.length) { 
 |        ops.push(this.searchFormOptions[0][0]); 
 |        //  this.formOptions.push([this.searchFormOptions[0][0]]); 
 |      } 
 |      ops.forEach(x => { 
 |        if (!x.onKeyPress) { 
 |          x.onKeyPress = ($event) => { 
 |            if ($event && $event.keyCode == 13) { 
 |              this.$emit('tiggerPress', $event) 
 |            } 
 |          } 
 |        } 
 |      }) 
 |      this.formOptions.push(ops); 
 |      //tiggerPress 
 |      this.hasDate = ops.some(x => { return (x.type == 'date' || x.type == 'datetime') && x.range == true }) 
 |    }, 
 |  }; 
 |  </script> 
 |  <style lang="less" scoped> 
 |  .qk-search ::v-deep(.el-form-item__label) { 
 |    // display: none; 
 |    width: auto !important; 
 |    margin-left: 10px; 
 |  } 
 |    
 |  .form-1::v-deep(.el-form-item__label) { 
 |    display: none; 
 |  } 
 |    
 |  .qk-search { 
 |    overflow: hidden; 
 |    height: 38px; 
 |    position: relative; 
 |    top: 1px; 
 |    right: -5px; 
 |  } 
 |    
 |  .qk-search ::v-deep(.el-form-item) { 
 |    width: auto !important; 
 |  } 
 |    
 |  .qk-search ::v-deep(.el-input--large .el-input__wrapper) { 
 |    padding: 0px 15px; 
 |  } 
 |    
 |  .qk-form ::v-deep(.el-form-item__content) { 
 |    width: 140px; 
 |  } 
 |    
 |  .date-form ::v-deep(.v-date-range) { 
 |    width: 205px; 
 |    margin-top: 1px; 
 |  } 
 |  </style> 
 |  
  |