feat(baTable):表格公共搜索支持日期和日期范围筛选(纯日期无时间)

This commit is contained in:
妙码生花 2022-08-25 12:38:18 +08:00
parent 57a8264fbd
commit af9c9678c4
3 changed files with 12 additions and 7 deletions

View File

@ -14,11 +14,11 @@
class="datetime-picker"
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()]"
type="datetimerange"
:type="item.comSearchRender == 'date' ? 'daterange' : 'datetimerange'"
range-separator="To"
start-placeholder="Start 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>
@ -48,10 +48,10 @@
<!-- 时间筛选 -->
<el-date-picker
class="datetime-picker"
v-if="item.render == 'datetime'"
v-if="item.render == 'datetime' || item.comSearchRender == 'date'"
v-model="baTable.comSearch.form[item.prop!]"
type="datetime"
value-format="YYYY-MM-DD HH:mm:ss"
:type="item.comSearchRender == 'date' ? 'date' : 'datetime'"
:value-format="item.comSearchRender == 'date' ? 'YYYY-MM-DD' : 'YYYY-MM-DD HH:mm:ss'"
:placeholder="item.operatorPlaceholder"
:default-value="baTable.comSearch.form[item.prop! + '-default'] ? baTable.comSearch.form[item.prop! + '-default']:new Date()"
></el-date-picker>
@ -153,8 +153,12 @@ const onComSearch = () => {
//
if (baTable.comSearch.form[key] && baTable.comSearch.form[key].length >= 2) {
// url
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') {
// baTablestartend
if (!baTable.comSearch.form[key + '-start'] && !baTable.comSearch.form[key + '-end']) {

View File

@ -560,6 +560,7 @@ export default class baTable {
this.comSearch.fieldData.set(prop, {
operator: field[key].operator,
render: field[key].render,
comSearchRender: field[key].comSearchRender,
})
}
}

View File

@ -111,7 +111,7 @@ declare global {
// 通用搜索框的placeholder
operatorPlaceholder?: string
// 公共搜索渲染方式:上方的 render=tag|switch 时公共搜索也会渲染为下拉,数字会渲染为范围筛选,时间渲染为时间选择器等
comSearchRender?: 'remoteSelect' | 'select' | 'customRender'
comSearchRender?: 'remoteSelect' | 'select' | 'date' | 'customRender'
// 公共搜索自定义组件/函数渲染
comSearchCustomRender?: string | Component
// 远程属性