Skip to content

Commit a509631

Browse files
author
283591387@qq.com
committed
增加vue3版本快捷查询支持级联、日期组件,查询只有一选项时强制隐藏高级查询
1 parent e051a2d commit a509631

File tree

4 files changed

+46
-26
lines changed

4 files changed

+46
-26
lines changed

Vol.Vue3版本/src/components/basic/QuickSearch.vue

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,25 @@
1818
>
1919
</el-option>
2020
</el-select>
21-
<span
22-
v-else-if="['date', 'datetime'].indexOf(singleSearch.type) != -1"
23-
></span>
24-
<!--<el-date-picker
21+
<el-date-picker
2522
clearable
26-
style="width: 100%"
2723
size="small"
2824
v-else-if="['date', 'datetime'].indexOf(singleSearch.type) != -1"
29-
v-model="formFields[singleSearch.field]"
30-
:type="item.type"
25+
v-model="searchFormFields[singleSearch.field]"
26+
type="daterange"
27+
:value-format="getDateFormat(singleSearch)"
3128
:placeholder="singleSearch.title"
32-
:disabledDate="(val) => getDateOptions(val, singleSearch.item)"
33-
:value-format="getDateFormat(singleSearch.item)"
3429
>
35-
</el-date-picker> -->
36-
30+
</el-date-picker>
31+
<el-cascader
32+
clearable
33+
size="small"
34+
v-model="searchFormFields[singleSearch.field]"
35+
v-else-if="singleSearch.type == 'cascader'"
36+
:options="singleSearch.data"
37+
:props="{ checkStrictly: true}"
38+
>
39+
</el-cascader>
3740
<el-input
3841
clearable
3942
v-else
@@ -72,6 +75,10 @@ export default {
7275
(typeof date2 == "number" ? date2 : new Date(date2).valueOf())
7376
);
7477
},
78+
getDateFormat(item) {
79+
//见https://day.js.org/docs/zh-CN/display/format
80+
return item.type == 'date' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss';
81+
},
7582
getDateOptions(date, item) {
7683
if ((!item.min && !item.max) || !date) {
7784
return false;

Vol.Vue3版本/src/components/basic/ViewGrid/methods.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ let methods = {
3030
return x.value == 'Search';
3131
});
3232
//添加高级查询
33-
34-
if (searchIndex != -1) {
33+
let hasOneFormItem = this.searchFormOptions.length==1&&this.searchFormOptions[0].length==1;
34+
if (searchIndex != -1&&!hasOneFormItem) {
3535
this.buttons.splice(searchIndex + 1, 0, {
3636
icon: this.fiexdSearchForm ? 'el-icon-refresh-left' : 'el-icon-search',
3737
name: this.fiexdSearchForm ? '重置' : '高级查询',
@@ -45,6 +45,9 @@ let methods = {
4545
}
4646
});
4747
}
48+
if (hasOneFormItem) {
49+
this.fiexdSearchForm=false;
50+
}
4851
this.maxBtnLength += searchIndex == -1 ? 0 : 1;
4952
if (this.buttons.length <= this.maxBtnLength) return this.buttons;
5053
let btns = this.buttons.slice(0, this.maxBtnLength);

开发版dev/Vue.NetCore/Vol.Vue3版本/src/components/basic/QuickSearch.vue

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,25 @@
1818
>
1919
</el-option>
2020
</el-select>
21-
<span
22-
v-else-if="['date', 'datetime'].indexOf(singleSearch.type) != -1"
23-
></span>
24-
<!--<el-date-picker
21+
<el-date-picker
2522
clearable
26-
style="width: 100%"
2723
size="small"
2824
v-else-if="['date', 'datetime'].indexOf(singleSearch.type) != -1"
29-
v-model="formFields[singleSearch.field]"
30-
:type="item.type"
25+
v-model="searchFormFields[singleSearch.field]"
26+
type="daterange"
27+
:value-format="getDateFormat(singleSearch)"
3128
:placeholder="singleSearch.title"
32-
:disabledDate="(val) => getDateOptions(val, singleSearch.item)"
33-
:value-format="getDateFormat(singleSearch.item)"
3429
>
35-
</el-date-picker> -->
36-
30+
</el-date-picker>
31+
<el-cascader
32+
clearable
33+
size="small"
34+
v-model="searchFormFields[singleSearch.field]"
35+
v-else-if="singleSearch.type == 'cascader'"
36+
:options="singleSearch.data"
37+
:props="{ checkStrictly: true}"
38+
>
39+
</el-cascader>
3740
<el-input
3841
clearable
3942
v-else
@@ -72,6 +75,10 @@ export default {
7275
(typeof date2 == "number" ? date2 : new Date(date2).valueOf())
7376
);
7477
},
78+
getDateFormat(item) {
79+
//见https://day.js.org/docs/zh-CN/display/format
80+
return item.type == 'date' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss';
81+
},
7582
getDateOptions(date, item) {
7683
if ((!item.min && !item.max) || !date) {
7784
return false;

开发版dev/Vue.NetCore/Vol.Vue3版本/src/components/basic/ViewGrid/methods.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ let methods = {
3030
return x.value == 'Search';
3131
});
3232
//添加高级查询
33-
34-
if (searchIndex != -1) {
33+
let hasOneFormItem = this.searchFormOptions.length==1&&this.searchFormOptions[0].length==1;
34+
if (searchIndex != -1&&!hasOneFormItem) {
3535
this.buttons.splice(searchIndex + 1, 0, {
3636
icon: this.fiexdSearchForm ? 'el-icon-refresh-left' : 'el-icon-search',
3737
name: this.fiexdSearchForm ? '重置' : '高级查询',
@@ -45,6 +45,9 @@ let methods = {
4545
}
4646
});
4747
}
48+
if (hasOneFormItem) {
49+
this.fiexdSearchForm=false;
50+
}
4851
this.maxBtnLength += searchIndex == -1 ? 0 : 1;
4952
if (this.buttons.length <= this.maxBtnLength) return this.buttons;
5053
let btns = this.buttons.slice(0, this.maxBtnLength);

0 commit comments

Comments
 (0)