Merge branch 'refs/heads/dev_1.0.0_beta4' into preview
This commit is contained in:
commit
6a2103cb13
@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { $t } from '@/locales';
|
import { $t } from '@/locales';
|
||||||
import { useAppStore } from '@/store/modules/app';
|
import { useAppStore } from '@/store/modules/app';
|
||||||
import { useNaiveForm } from '@/hooks/common/form';
|
import { useNaiveForm } from '@/hooks/common/form';
|
||||||
@ -12,7 +12,7 @@ interface Props {
|
|||||||
model: Record<string, any>;
|
model: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
interface Emits {
|
interface Emits {
|
||||||
(e: 'reset'): void;
|
(e: 'reset'): void;
|
||||||
@ -29,13 +29,20 @@ const { formRef, validate, restoreValidation } = useNaiveForm();
|
|||||||
|
|
||||||
async function reset() {
|
async function reset() {
|
||||||
await restoreValidation();
|
await restoreValidation();
|
||||||
|
Object.assign(props.model, { ...props.model, page: 1 });
|
||||||
emit('reset');
|
emit('reset');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function search() {
|
async function search() {
|
||||||
await validate();
|
await validate();
|
||||||
|
Object.assign(props.model, { ...props.model, page: 1 });
|
||||||
emit('search');
|
emit('search');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const btnSpan = computed(() => {
|
||||||
|
const keyNum = Object.keys(props.model).length - 2;
|
||||||
|
return `24 m:12 m:${(4 - (keyNum % 4)) * 6}`;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -43,7 +50,7 @@ async function search() {
|
|||||||
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80" :show-feedback="appStore.isMobile">
|
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80" :show-feedback="appStore.isMobile">
|
||||||
<NGrid responsive="screen" item-responsive :y-gap="5">
|
<NGrid responsive="screen" item-responsive :y-gap="5">
|
||||||
<slot></slot>
|
<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">
|
<NSpace class="min-w-172px w-full" justify="end">
|
||||||
<NButton @click="reset">
|
<NButton @click="reset">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
|
@ -32,7 +32,7 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
|
|||||||
getData,
|
getData,
|
||||||
searchParams,
|
searchParams,
|
||||||
updateSearchParams,
|
updateSearchParams,
|
||||||
resetSearchParams
|
resetSearchParams: resetSearchParams0
|
||||||
} = useHookTable<A, GetTableData<A>, TableColumn<NaiveUI.TableDataWithIndex<GetTableData<A>>>>({
|
} = useHookTable<A, GetTableData<A>, TableColumn<NaiveUI.TableDataWithIndex<GetTableData<A>>>>({
|
||||||
apiFn,
|
apiFn,
|
||||||
apiParams,
|
apiParams,
|
||||||
@ -172,6 +172,11 @@ export function useTable<A extends NaiveUI.TableApiFn>(config: NaiveUI.NaiveTabl
|
|||||||
scope.stop();
|
scope.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const resetSearchParams = () => {
|
||||||
|
resetSearchParams0();
|
||||||
|
getData();
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loading,
|
loading,
|
||||||
empty,
|
empty,
|
||||||
|
@ -25,8 +25,7 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
|
|||||||
size: 10,
|
size: 10,
|
||||||
// if you want to use the searchParams in Form, you need to define the following properties, and the value is null
|
// 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
|
// the value can not be undefined, otherwise the property in Form will not be reactive
|
||||||
username: null,
|
username: null
|
||||||
role: null
|
|
||||||
},
|
},
|
||||||
columns: () => [
|
columns: () => [
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user