feat(web-admin): add useServerColumnFilters for list column queries.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
36afab503a
commit
e492cedab9
3 files changed
+220
-8
No files matched your search
@@ -118,6 +118,7 @@
|
||||
size="small"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
@visible-change="onDatePickerVisibleChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="field">
|
||||
@@ -130,6 +131,7 @@
|
||||
size="small"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
@visible-change="onDatePickerVisibleChange"
|
||||
/>
|
||||
</div>
|
||||
<p class="field-tip">闭区间:含起止当天</p>
|
||||
@@ -154,7 +156,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { computed, onUnmounted, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { Filter, Delete, Close, Check } from '@element-plus/icons-vue'
|
||||
import {
|
||||
@@ -192,6 +194,9 @@
|
||||
const draftMax = ref('')
|
||||
const draftFrom = ref('')
|
||||
const draftTo = ref('')
|
||||
/** 日期面板 teleport 到 body,点选日期会被 popover 当成外部点击;短暂抑制关闭 */
|
||||
const holdPopoverOpen = ref(false)
|
||||
let holdPopoverTimer: ReturnType<typeof setTimeout> | undefined
|
||||
|
||||
const typeHint = computed(() => {
|
||||
if (props.type === 'text') return '文本:搜索并勾选本页出现的值'
|
||||
@@ -212,7 +217,7 @@
|
||||
function resetDraftFromModel() {
|
||||
const m = props.modelValue
|
||||
if (props.type === 'text' || props.type === 'enum') {
|
||||
const s = (m || { selected: [], keyword: '' }) as TextColumnFilterState
|
||||
const s = (m || { text: '', selected: [], keyword: '' }) as TextColumnFilterState
|
||||
draftSelected.value = [...(s.selected || [])]
|
||||
draftKeyword.value = s.keyword || ''
|
||||
return
|
||||
@@ -232,12 +237,35 @@
|
||||
}
|
||||
}
|
||||
|
||||
function onDatePickerVisibleChange(open: boolean) {
|
||||
if (holdPopoverTimer !== undefined) {
|
||||
clearTimeout(holdPopoverTimer)
|
||||
holdPopoverTimer = undefined
|
||||
}
|
||||
if (open) {
|
||||
holdPopoverOpen.value = true
|
||||
return
|
||||
}
|
||||
// 选中日期后,同一轮点击会触发 popover 的 click-outside,延迟释放抑制
|
||||
holdPopoverOpen.value = true
|
||||
holdPopoverTimer = setTimeout(() => {
|
||||
holdPopoverOpen.value = false
|
||||
holdPopoverTimer = undefined
|
||||
}, 200)
|
||||
}
|
||||
|
||||
function onVisibleChange(next: boolean) {
|
||||
if (!next && holdPopoverOpen.value) return
|
||||
if (next) resetDraftFromModel()
|
||||
visible.value = next
|
||||
}
|
||||
|
||||
function close() {
|
||||
holdPopoverOpen.value = false
|
||||
if (holdPopoverTimer !== undefined) {
|
||||
clearTimeout(holdPopoverTimer)
|
||||
holdPopoverTimer = undefined
|
||||
}
|
||||
visible.value = false
|
||||
}
|
||||
|
||||
@@ -263,6 +291,7 @@
|
||||
function buildState(): ColumnFilterState {
|
||||
if (props.type === 'text' || props.type === 'enum') {
|
||||
return {
|
||||
text: '',
|
||||
selected: [...draftSelected.value],
|
||||
keyword: draftKeyword.value
|
||||
}
|
||||
@@ -321,6 +350,13 @@
|
||||
if (visible.value) resetDraftFromModel()
|
||||
}
|
||||
)
|
||||
|
||||
onUnmounted(() => {
|
||||
if (holdPopoverTimer !== undefined) {
|
||||
clearTimeout(holdPopoverTimer)
|
||||
holdPopoverTimer = undefined
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in new issue
Block a user