refactor: reorganize files
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ndmCallLogDefaultExportByTemplate, postNdmCallLogPage, type NdmCallLogResultVO, type NdmCallLogVO, type PageQueryExtra } from '@/apis';
|
||||
import { exportCallLogApi, pageCallLogApi, type NdmCallLogResultVO, type NdmCallLog, type PageQueryExtra } from '@/apis';
|
||||
import { useStationStore } from '@/stores';
|
||||
import { downloadByData } from '@/utils';
|
||||
import { useMutation } from '@tanstack/vue-query';
|
||||
@@ -35,7 +35,7 @@ const stationSelectOptions = computed(() => {
|
||||
}));
|
||||
});
|
||||
|
||||
type SearchFields = PageQueryExtra<NdmCallLogVO> & { stationCode?: string; createdTime: [string, string] };
|
||||
type SearchFields = PageQueryExtra<NdmCallLog> & { stationCode?: string; createdTime: [string, string] };
|
||||
|
||||
const searchFields = reactive<SearchFields>({
|
||||
stationCode: undefined as string | undefined,
|
||||
@@ -101,26 +101,31 @@ const tablePagination = reactive<PaginationProps>({
|
||||
},
|
||||
onUpdatePage: (page: number) => {
|
||||
tablePagination.page = page;
|
||||
getCallLogList();
|
||||
getTableData();
|
||||
},
|
||||
onUpdatePageSize: (pageSize: number) => {
|
||||
tablePagination.pageSize = pageSize;
|
||||
tablePagination.page = 1;
|
||||
getCallLogList();
|
||||
getTableData();
|
||||
},
|
||||
});
|
||||
|
||||
const { mutate: getCallLogList, isPending: tableLoading } = useMutation({
|
||||
const { mutate: getTableData, isPending: tableLoading } = useMutation({
|
||||
mutationFn: async () => {
|
||||
if (!searchFields.stationCode) throw Error('请选择车站');
|
||||
const res = await postNdmCallLogPage(searchFields.stationCode, {
|
||||
model: {},
|
||||
extra: getExtraFields(),
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
});
|
||||
const res = await pageCallLogApi(
|
||||
{
|
||||
model: {},
|
||||
extra: getExtraFields(),
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
},
|
||||
{
|
||||
stationCode: searchFields.stationCode,
|
||||
},
|
||||
);
|
||||
return res;
|
||||
},
|
||||
onSuccess: (res) => {
|
||||
@@ -140,7 +145,7 @@ const onClickReset = () => {
|
||||
tablePagination.page = 1;
|
||||
tablePagination.pageSize = 10;
|
||||
tablePagination.itemCount = 0;
|
||||
getCallLogList();
|
||||
getTableData();
|
||||
};
|
||||
const onClickQuery = () => {
|
||||
if (searchFieldsChanged.value) {
|
||||
@@ -148,20 +153,25 @@ const onClickQuery = () => {
|
||||
tablePagination.pageSize = 10;
|
||||
searchFieldsChanged.value = false;
|
||||
}
|
||||
getCallLogList();
|
||||
getTableData();
|
||||
};
|
||||
|
||||
const { mutate: exportTableData, isPending: exporting } = useMutation({
|
||||
mutationFn: async () => {
|
||||
if (!searchFields.stationCode) throw Error('请选择车站');
|
||||
const data = await ndmCallLogDefaultExportByTemplate(searchFields.stationCode, {
|
||||
model: {},
|
||||
extra: getExtraFields(),
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
});
|
||||
const data = await exportCallLogApi(
|
||||
{
|
||||
model: {},
|
||||
extra: getExtraFields(),
|
||||
current: tablePagination.page ?? 1,
|
||||
size: tablePagination.pageSize ?? 10,
|
||||
order: 'descending',
|
||||
sort: 'id',
|
||||
},
|
||||
{
|
||||
stationCode: searchFields.stationCode,
|
||||
},
|
||||
);
|
||||
return data;
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
@@ -178,7 +188,7 @@ const defaultStation = computed(() => onlineStationList.value.at(0));
|
||||
watchEffect(() => {
|
||||
if (defaultStation.value?.code && !searchFields.stationCode) {
|
||||
searchFields.stationCode = defaultStation.value.code;
|
||||
getCallLogList();
|
||||
getTableData();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user