mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-22 15:24:09 +00:00
feat(baTable):表格公共搜索支持日期和日期范围筛选(纯日期无时间)
This commit is contained in:
parent
57a8264fbd
commit
af9c9678c4
@ -14,11 +14,11 @@
|
|||||||
class="datetime-picker"
|
class="datetime-picker"
|
||||||
v-model="baTable.comSearch.form[item.prop!]"
|
v-model="baTable.comSearch.form[item.prop!]"
|
||||||
:default-value="baTable.comSearch.form[item.prop! + '-default'] ? baTable.comSearch.form[item.prop! + '-default']:[new Date(), new Date()]"
|
:default-value="baTable.comSearch.form[item.prop! + '-default'] ? baTable.comSearch.form[item.prop! + '-default']:[new Date(), new Date()]"
|
||||||
type="datetimerange"
|
:type="item.comSearchRender == 'date' ? 'daterange' : 'datetimerange'"
|
||||||
range-separator="To"
|
range-separator="To"
|
||||||
start-placeholder="Start date"
|
start-placeholder="Start date"
|
||||||
end-placeholder="End date"
|
end-placeholder="End date"
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
:value-format="item.comSearchRender == 'date' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -48,10 +48,10 @@
|
|||||||
<!-- 时间筛选 -->
|
<!-- 时间筛选 -->
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
class="datetime-picker"
|
class="datetime-picker"
|
||||||
v-if="item.render == 'datetime'"
|
v-if="item.render == 'datetime' || item.comSearchRender == 'date'"
|
||||||
v-model="baTable.comSearch.form[item.prop!]"
|
v-model="baTable.comSearch.form[item.prop!]"
|
||||||
type="datetime"
|
:type="item.comSearchRender == 'date' ? 'date' : 'datetime'"
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
:value-format="item.comSearchRender == 'date' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'"
|
||||||
:placeholder="item.operatorPlaceholder"
|
:placeholder="item.operatorPlaceholder"
|
||||||
:default-value="baTable.comSearch.form[item.prop! + '-default'] ? baTable.comSearch.form[item.prop! + '-default']:new Date()"
|
:default-value="baTable.comSearch.form[item.prop! + '-default'] ? baTable.comSearch.form[item.prop! + '-default']:new Date()"
|
||||||
></el-date-picker>
|
></el-date-picker>
|
||||||
@ -153,7 +153,11 @@ const onComSearch = () => {
|
|||||||
// 时间范围组件返回的是时间数组
|
// 时间范围组件返回的是时间数组
|
||||||
if (baTable.comSearch.form[key] && baTable.comSearch.form[key].length >= 2) {
|
if (baTable.comSearch.form[key] && baTable.comSearch.form[key].length >= 2) {
|
||||||
// 数组转字符串,以实现通过url参数传递预设搜索值
|
// 数组转字符串,以实现通过url参数传递预设搜索值
|
||||||
val = baTable.comSearch.form[key][0] + ',' + baTable.comSearch.form[key][1]
|
if (fieldDataTemp.comSearchRender == 'date') {
|
||||||
|
val = baTable.comSearch.form[key][0] + ' 00:00:00' + ',' + baTable.comSearch.form[key][1] + ' 23:59:59'
|
||||||
|
} else {
|
||||||
|
val = baTable.comSearch.form[key][0] + ',' + baTable.comSearch.form[key][1]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (fieldDataTemp.operator == 'RANGE' || fieldDataTemp.operator == 'NOT RANGE') {
|
} else if (fieldDataTemp.operator == 'RANGE' || fieldDataTemp.operator == 'NOT RANGE') {
|
||||||
// 普通的范围筛选,baTable在初始化时已准备好start和end字段
|
// 普通的范围筛选,baTable在初始化时已准备好start和end字段
|
||||||
|
@ -560,6 +560,7 @@ export default class baTable {
|
|||||||
this.comSearch.fieldData.set(prop, {
|
this.comSearch.fieldData.set(prop, {
|
||||||
operator: field[key].operator,
|
operator: field[key].operator,
|
||||||
render: field[key].render,
|
render: field[key].render,
|
||||||
|
comSearchRender: field[key].comSearchRender,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
web/types/table.d.ts
vendored
2
web/types/table.d.ts
vendored
@ -111,7 +111,7 @@ declare global {
|
|||||||
// 通用搜索框的placeholder
|
// 通用搜索框的placeholder
|
||||||
operatorPlaceholder?: string
|
operatorPlaceholder?: string
|
||||||
// 公共搜索渲染方式:上方的 render=tag|switch 时公共搜索也会渲染为下拉,数字会渲染为范围筛选,时间渲染为时间选择器等
|
// 公共搜索渲染方式:上方的 render=tag|switch 时公共搜索也会渲染为下拉,数字会渲染为范围筛选,时间渲染为时间选择器等
|
||||||
comSearchRender?: 'remoteSelect' | 'select' | 'customRender'
|
comSearchRender?: 'remoteSelect' | 'select' | 'date' | 'customRender'
|
||||||
// 公共搜索自定义组件/函数渲染
|
// 公共搜索自定义组件/函数渲染
|
||||||
comSearchCustomRender?: string | Component
|
comSearchCustomRender?: string | Component
|
||||||
// 远程属性
|
// 远程属性
|
||||||
|
Loading…
Reference in New Issue
Block a user