feat: CrudTable 新增重置事件,并优化查询栏日期范围的重置处理
This commit is contained in:
parent
8972ead5b9
commit
4b945339d0
@ -77,7 +77,7 @@ const props = defineProps({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['update:queryItems', 'onChecked', 'onDataChange'])
|
const emit = defineEmits(['update:queryItems', 'onChecked', 'onDataChange', 'onReset'])
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const initQuery = { ...props.queryItems }
|
const initQuery = { ...props.queryItems }
|
||||||
const tableData = ref([])
|
const tableData = ref([])
|
||||||
@ -132,6 +132,7 @@ async function handleReset() {
|
|||||||
queryItems[key] = null
|
queryItems[key] = null
|
||||||
}
|
}
|
||||||
emit('update:queryItems', { ...queryItems, ...initQuery })
|
emit('update:queryItems', { ...queryItems, ...initQuery })
|
||||||
|
emit('onReset')
|
||||||
await nextTick()
|
await nextTick()
|
||||||
pagination.page = 1
|
pagination.page = 1
|
||||||
handleQuery()
|
handleQuery()
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { h, onMounted, ref, resolveDirective, withDirectives } from 'vue'
|
import { h, onMounted, ref, resolveDirective, withDirectives } from 'vue'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
import { NButton, NForm, NFormItem, NInput, NDatePicker } from 'naive-ui'
|
import { NButton, NForm, NFormItem, NInput, NDatePicker } from 'naive-ui'
|
||||||
|
|
||||||
import CommonPage from '@/components/page/CommonPage.vue'
|
import CommonPage from '@/components/page/CommonPage.vue'
|
||||||
@ -18,6 +19,7 @@ defineOptions({ name: '用户管理' })
|
|||||||
|
|
||||||
const $table = ref(null)
|
const $table = ref(null)
|
||||||
const queryItems = ref({})
|
const queryItems = ref({})
|
||||||
|
const createdDateRange = ref(null)
|
||||||
const vPermission = resolveDirective('permission')
|
const vPermission = resolveDirective('permission')
|
||||||
|
|
||||||
// 次数设置弹窗相关状态
|
// 次数设置弹窗相关状态
|
||||||
@ -56,6 +58,21 @@ onMounted(() => {
|
|||||||
$table.value?.handleSearch()
|
$table.value?.handleSearch()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const handleDateRangeChange = (val) => {
|
||||||
|
if (val && val.length === 2) {
|
||||||
|
queryItems.value.created_start = dayjs(val[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss')
|
||||||
|
queryItems.value.created_end = dayjs(val[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
|
||||||
|
} else {
|
||||||
|
queryItems.value.created_start = null
|
||||||
|
queryItems.value.created_end = null
|
||||||
|
}
|
||||||
|
$table.value?.handleSearch()
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleReset = () => {
|
||||||
|
createdDateRange.value = null
|
||||||
|
}
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: 'ID',
|
title: 'ID',
|
||||||
@ -232,6 +249,7 @@ const validateForm = {
|
|||||||
v-model:query-items="queryItems"
|
v-model:query-items="queryItems"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:get-data="api.getAppUserList"
|
:get-data="api.getAppUserList"
|
||||||
|
@on-reset="handleReset"
|
||||||
>
|
>
|
||||||
<template #queryBar>
|
<template #queryBar>
|
||||||
<QueryBarItem label="手机号" :label-width="60">
|
<QueryBarItem label="手机号" :label-width="60">
|
||||||
@ -266,12 +284,12 @@ const validateForm = {
|
|||||||
</QueryBarItem>
|
</QueryBarItem>
|
||||||
<QueryBarItem label="注册时间" :label-width="70">
|
<QueryBarItem label="注册时间" :label-width="70">
|
||||||
<NDatePicker
|
<NDatePicker
|
||||||
v-model:value="queryItems.created_at"
|
v-model:value="createdDateRange"
|
||||||
type="daterange"
|
type="daterange"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请选择注册时间"
|
placeholder="请选择注册时间"
|
||||||
style="width: 280px"
|
style="width: 280px"
|
||||||
@update:value="$table?.handleSearch()"
|
@update:value="handleDateRangeChange"
|
||||||
/>
|
/>
|
||||||
</QueryBarItem>
|
</QueryBarItem>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -55,6 +55,11 @@ const handleAuditedDateRangeChange = (val) => {
|
|||||||
$table.value?.handleSearch()
|
$table.value?.handleSearch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleReset = () => {
|
||||||
|
submittedDateRange.value = null
|
||||||
|
auditedDateRange.value = null
|
||||||
|
}
|
||||||
|
|
||||||
// 列表与详情公共方法
|
// 列表与详情公共方法
|
||||||
const renderStatus = (status) => {
|
const renderStatus = (status) => {
|
||||||
const config = getStatusConfig(status)
|
const config = getStatusConfig(status)
|
||||||
@ -313,6 +318,7 @@ watch(
|
|||||||
v-model:query-items="queryItems"
|
v-model:query-items="queryItems"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
:get-data="api.getValuationList"
|
:get-data="api.getValuationList"
|
||||||
|
@on-reset="handleReset"
|
||||||
>
|
>
|
||||||
<template #queryBar>
|
<template #queryBar>
|
||||||
<QueryBarItem label="手机号" :label-width="80">
|
<QueryBarItem label="手机号" :label-width="80">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user