Merge branch 'refs/heads/dev_1.0.0_beta4' into preview

This commit is contained in:
xlsea 2024-06-04 15:47:24 +08:00
commit 6a2103cb13
3 changed files with 17 additions and 6 deletions

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref } from 'vue';
import { computed, ref } from 'vue';
import { $t } from '@/locales';
import { useAppStore } from '@/store/modules/app';
import { useNaiveForm } from '@/hooks/common/form';
@ -12,7 +12,7 @@ interface Props {
model: Record<string, any>;
}
defineProps<Props>();
const props = defineProps<Props>();
interface Emits {
(e: 'reset'): void;
@ -29,13 +29,20 @@ const { formRef, validate, restoreValidation } = useNaiveForm();
async function reset() {
await restoreValidation();
Object.assign(props.model, { ...props.model, page: 1 });
emit('reset');
}
async function search() {
await validate();
Object.assign(props.model, { ...props.model, page: 1 });
emit('search');
}
const btnSpan = computed(() => {
const keyNum = Object.keys(props.model).length - 2;
return `24 m:12 m:${(4 - (keyNum % 4)) * 6}`;
});
</script>
<template>
@ -43,7 +50,7 @@ async function search() {
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80" :show-feedback="appStore.isMobile">
<NGrid responsive="screen" item-responsive :y-gap="5">
<slot></slot>
<NFormItemGi :y-gap="8" span="24 m:12 m:6" class="pr-24px lg:p-t-0 md:p-t-16px">
<NFormItemGi :y-gap="8" :span="btnSpan" class="pr-24px lg:p-t-0 md:p-t-16px">
<NSpace class="min-w-172px w-full" justify="end">
<NButton @click="reset">
<template #icon>

View File

@ -32,7 +32,7 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
getData,
searchParams,
updateSearchParams,
resetSearchParams
resetSearchParams: resetSearchParams0
} = useHookTable<A, GetTableData<A>, TableColumn<NaiveUI.TableDataWithIndex<GetTableData<A>>>>({
apiFn,
apiParams,
@ -172,6 +172,11 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
scope.stop();
});
const resetSearchParams = () => {
resetSearchParams0();
getData();
};
return {
loading,
empty,

View File

@ -25,8 +25,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
size: 10,
// if you want to use the searchParams in Form, you need to define the following properties, and the value is null
// the value can not be undefined, otherwise the property in Form will not be reactive
username: null,
role: null
username: null
},
columns: () => [
{