feat: 优化后台列表高度与分页容量
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page table-page">
|
||||
<div class="page-toolbar">
|
||||
<n-button quaternary @click="router.back()">
|
||||
<template #icon><n-icon :component="ArrowBackOutline" /></template>
|
||||
@@ -25,7 +25,7 @@
|
||||
</n-descriptions>
|
||||
</n-card>
|
||||
|
||||
<n-card :title="t('pages.artwork.traceCodes')" :bordered="false">
|
||||
<n-card :title="t('pages.artwork.traceCodes')" :bordered="false" class="table-card">
|
||||
<trace-code-panel :artwork-id="artworkId" />
|
||||
</n-card>
|
||||
</div>
|
||||
@@ -65,6 +65,19 @@ onMounted(loadArtwork);
|
||||
}
|
||||
.summary-card {
|
||||
margin-bottom: 16px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.table-card {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.table-card :deep(.n-card__content) {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.summary-title {
|
||||
display: flex;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page table-page">
|
||||
<div class="page-toolbar">
|
||||
<n-input
|
||||
v-model:value="query.keyword"
|
||||
@@ -32,9 +32,11 @@
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
class="table-fill"
|
||||
flex-height
|
||||
paginate-single-page
|
||||
remote
|
||||
:row-key="(r) => r.id"
|
||||
@update:page="onPage"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -49,6 +51,7 @@ import { ArtworkStatus } from '@artveris/shared';
|
||||
import { artworkApi } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
@@ -56,13 +59,11 @@ const auth = useAuthStore();
|
||||
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const query = reactive<{ keyword: string; status: string | null; page: number; pageSize: number }>({
|
||||
const query = reactive<{ keyword: string; status: string | null }>({
|
||||
keyword: '',
|
||||
status: null,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const statusOptions = Object.values(ArtworkStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||
|
||||
const columns: DataTableColumns<any> = [
|
||||
@@ -137,22 +138,17 @@ async function load() {
|
||||
const res: any = await artworkApi.list({
|
||||
keyword: query.keyword,
|
||||
status: query.status || undefined,
|
||||
page: query.page,
|
||||
pageSize: query.pageSize,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
});
|
||||
rows.value = res.list;
|
||||
pagination.itemCount = res.total;
|
||||
pagination.page = res.page;
|
||||
setPageResult(res);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
function onSearch() {
|
||||
query.page = 1;
|
||||
load();
|
||||
}
|
||||
function onPage(p: number) {
|
||||
query.page = p;
|
||||
resetPage();
|
||||
load();
|
||||
}
|
||||
function goCreate() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page table-page">
|
||||
<div class="page-toolbar">
|
||||
<n-input
|
||||
v-model:value="query.keyword"
|
||||
@@ -27,9 +27,11 @@
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
class="table-fill"
|
||||
flex-height
|
||||
paginate-single-page
|
||||
remote
|
||||
:row-key="(r) => r.id"
|
||||
@update:page="onPage"
|
||||
/>
|
||||
|
||||
<n-modal v-model:show="rejectModal" preset="card" :title="t('pages.audit.reject')" style="width: 420px">
|
||||
@@ -58,6 +60,7 @@ import { AuditStatus } from '@artveris/shared';
|
||||
import { auditApi } from '@/api';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
@@ -65,13 +68,11 @@ const router = useRouter();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const acting = ref(false);
|
||||
const query = reactive<{ keyword: string; auditStatus: string | null; page: number; pageSize: number }>({
|
||||
const query = reactive<{ keyword: string; auditStatus: string | null }>({
|
||||
keyword: '',
|
||||
auditStatus: AuditStatus.PENDING,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const auditStatusOptions = Object.values(AuditStatus).map((v) => ({ label: t(`common.auditStatus.${v}`), value: v }));
|
||||
|
||||
function auditTagType(s: string) {
|
||||
@@ -121,22 +122,17 @@ async function load() {
|
||||
const res: any = await auditApi.list({
|
||||
keyword: query.keyword || undefined,
|
||||
auditStatus: query.auditStatus || undefined,
|
||||
page: query.page,
|
||||
pageSize: query.pageSize,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
});
|
||||
rows.value = res.list;
|
||||
pagination.itemCount = res.total;
|
||||
pagination.page = res.page;
|
||||
setPageResult(res);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
function onSearch() {
|
||||
query.page = 1;
|
||||
load();
|
||||
}
|
||||
function onPage(p: number) {
|
||||
query.page = p;
|
||||
resetPage();
|
||||
load();
|
||||
}
|
||||
function approve(r: any) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page table-page">
|
||||
<div class="page-toolbar">
|
||||
<n-input
|
||||
v-model:value="query.keyword"
|
||||
@@ -48,9 +48,11 @@
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
class="table-fill"
|
||||
flex-height
|
||||
paginate-single-page
|
||||
remote
|
||||
:row-key="(r) => r.id"
|
||||
@update:page="onPage"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -64,20 +66,19 @@ import dayjs from 'dayjs';
|
||||
import { QueryResult } from '@artveris/shared';
|
||||
import { queryLogApi } from '@/api';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
|
||||
const { t } = useI18n();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const range = ref<[number, number] | null>(null);
|
||||
const query = reactive<{ keyword: string; archiveNo: string; batchNo: string; result: string | null; startTime?: string; endTime?: string; page: number; pageSize: number }>({
|
||||
const query = reactive<{ keyword: string; archiveNo: string; batchNo: string; result: string | null; startTime?: string; endTime?: string }>({
|
||||
keyword: '',
|
||||
archiveNo: '',
|
||||
batchNo: '',
|
||||
result: null,
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
});
|
||||
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const resultOptions = Object.values(QueryResult).map((v) => ({ label: t(`common.queryResult.${v}`), value: v }));
|
||||
|
||||
const columns: DataTableColumns<any> = [
|
||||
@@ -117,12 +118,11 @@ async function load() {
|
||||
result: query.result || undefined,
|
||||
startTime: query.startTime,
|
||||
endTime: query.endTime,
|
||||
page: query.page,
|
||||
pageSize: query.pageSize,
|
||||
page: page.value,
|
||||
pageSize: pageSize.value,
|
||||
});
|
||||
rows.value = res.list;
|
||||
pagination.itemCount = res.total;
|
||||
pagination.page = res.page;
|
||||
setPageResult(res);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -138,11 +138,7 @@ function onRange(val: [number, number] | null) {
|
||||
onSearch();
|
||||
}
|
||||
function onSearch() {
|
||||
query.page = 1;
|
||||
load();
|
||||
}
|
||||
function onPage(p: number) {
|
||||
query.page = p;
|
||||
resetPage();
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page table-page">
|
||||
<div class="page-toolbar">
|
||||
<n-input
|
||||
v-model:value="query.keyword"
|
||||
:placeholder="t('common.label.keyword')"
|
||||
clearable
|
||||
style="width: 220px"
|
||||
@keyup.enter="load"
|
||||
@keyup.enter="onSearch"
|
||||
/>
|
||||
<n-button type="primary" @click="load">
|
||||
<n-button type="primary" @click="onSearch">
|
||||
<template #icon><n-icon :component="SearchOutline" /></template>
|
||||
{{ t('common.action.search') }}
|
||||
</n-button>
|
||||
@@ -24,9 +24,11 @@
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
class="table-fill"
|
||||
flex-height
|
||||
paginate-single-page
|
||||
remote
|
||||
:row-key="(r) => r.id"
|
||||
@update:page="onPage"
|
||||
/>
|
||||
|
||||
<n-modal
|
||||
@@ -104,14 +106,15 @@ import { templateApi } from '@/api';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
|
||||
const { t } = useI18n();
|
||||
const auth = useAuthStore();
|
||||
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const query = reactive({ keyword: '', page: 1, pageSize: 10 });
|
||||
const pagination = reactive({ page: 1, pageCount: 1, pageSize: 10, itemCount: 0 });
|
||||
const query = reactive({ keyword: '' });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
|
||||
const fieldTypeOptions = Object.values(FieldType).map((v) => ({ label: t(`common.fieldType.${v}`), value: v }));
|
||||
|
||||
@@ -182,17 +185,15 @@ async function toggleStatus(r: any) {
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res: any = await templateApi.list({ keyword: query.keyword, page: query.page, pageSize: query.pageSize });
|
||||
const res: any = await templateApi.list({ keyword: query.keyword, page: page.value, pageSize: pageSize.value });
|
||||
rows.value = res.list;
|
||||
pagination.itemCount = res.total;
|
||||
pagination.page = res.page;
|
||||
pagination.pageSize = res.pageSize;
|
||||
setPageResult(res);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
function onPage(p: number) {
|
||||
query.page = p;
|
||||
function onSearch() {
|
||||
resetPage();
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="page table-page">
|
||||
<div class="page-toolbar">
|
||||
<n-input v-model:value="query.keyword" :placeholder="t('common.label.keyword')" clearable style="width: 200px" @keyup.enter="onSearch" />
|
||||
<n-button type="primary" @click="onSearch">
|
||||
@@ -13,7 +13,17 @@
|
||||
</n-button>
|
||||
</div>
|
||||
|
||||
<n-data-table :columns="columns" :data="rows" :loading="loading" :pagination="pagination" remote :row-key="(r) => r.id" @update:page="onPage" />
|
||||
<n-data-table
|
||||
:columns="columns"
|
||||
:data="rows"
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
class="table-fill"
|
||||
flex-height
|
||||
paginate-single-page
|
||||
remote
|
||||
:row-key="(r) => r.id"
|
||||
/>
|
||||
|
||||
<n-modal v-model:show="showModal" preset="card" :title="editing ? t('pages.user.edit') : t('pages.user.create')" style="width: 460px">
|
||||
<n-form ref="formRef" :model="form" :rules="rules" label-placement="top">
|
||||
@@ -62,12 +72,13 @@ import { RoleType, UserStatus } from '@artveris/shared';
|
||||
import { userApi } from '@/api';
|
||||
import { message, dialog } from '@/utils/feedback';
|
||||
import { fmt, statusType } from '@/utils/format';
|
||||
import { useTablePage } from '@/composables/useTablePage';
|
||||
|
||||
const { t } = useI18n();
|
||||
const rows = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const query = reactive({ keyword: '', page: 1, pageSize: 10 });
|
||||
const pagination = reactive({ page: 1, pageSize: 10, itemCount: 0 });
|
||||
const query = reactive({ keyword: '' });
|
||||
const { pagination, page, pageSize, resetPage, setPageResult } = useTablePage(load);
|
||||
const roleOptions = Object.values(RoleType).map((v) => ({ label: t(`common.role.${v}`), value: v }));
|
||||
const statusOptions = Object.values(UserStatus).map((v) => ({ label: t(`common.status.${v}`), value: v }));
|
||||
|
||||
@@ -113,20 +124,15 @@ const columns: DataTableColumns<any> = [
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res: any = await userApi.list({ keyword: query.keyword, page: query.page, pageSize: query.pageSize });
|
||||
const res: any = await userApi.list({ keyword: query.keyword, page: page.value, pageSize: pageSize.value });
|
||||
rows.value = res.list;
|
||||
pagination.itemCount = res.total;
|
||||
pagination.page = res.page;
|
||||
setPageResult(res);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
function onSearch() {
|
||||
query.page = 1;
|
||||
load();
|
||||
}
|
||||
function onPage(p: number) {
|
||||
query.page = p;
|
||||
resetPage();
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user