增加导出
This commit is contained in:
parent
33db3e0ea2
commit
1995f9b078
@ -212,6 +212,17 @@ export async function getClsGoldRunningWater(params: Record<string, any>) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function exportClsGoldRunningWater(
|
||||||
|
params: Record<string, any>,
|
||||||
|
filename = 'GmGoldRunningWater',
|
||||||
|
) {
|
||||||
|
return downloadLegacyExcel(
|
||||||
|
'/user-wallet/gold/running-water/cls/export',
|
||||||
|
params,
|
||||||
|
filename,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export async function getPurchaseTable(params: Record<string, any>) {
|
export async function getPurchaseTable(params: Record<string, any>) {
|
||||||
return requestClient.get<LegacyPageResult<Record<string, any>>>(
|
return requestClient.get<LegacyPageResult<Record<string, any>>>(
|
||||||
'/order/purchase/history/page',
|
'/order/purchase/history/page',
|
||||||
|
|||||||
@ -43,12 +43,23 @@ export interface LegacyUser {
|
|||||||
}>;
|
}>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LegacyBackUserOption {
|
||||||
|
id: number | string;
|
||||||
|
loginName?: string;
|
||||||
|
nickname?: string;
|
||||||
|
status?: number | string;
|
||||||
|
}
|
||||||
|
|
||||||
export async function pageUsers(params: Record<string, any>) {
|
export async function pageUsers(params: Record<string, any>) {
|
||||||
return requestClient.get<LegacyPageResult<LegacyUser>>('/users', {
|
return requestClient.get<LegacyPageResult<LegacyUser>>('/users', {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function listBackUserOptions() {
|
||||||
|
return requestClient.get<LegacyBackUserOption[]>('/users/list/combo');
|
||||||
|
}
|
||||||
|
|
||||||
export async function switchUserStatus(
|
export async function switchUserStatus(
|
||||||
id: number | string,
|
id: number | string,
|
||||||
status: number | string,
|
status: number | string,
|
||||||
|
|||||||
@ -216,11 +216,14 @@ export async function pageFreightRunningWater(params: Record<string, any>) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function exportFreightWaters(params: Record<string, any>) {
|
export async function exportFreightWaters(
|
||||||
|
params: Record<string, any>,
|
||||||
|
filename = 'ExportFreightWaters',
|
||||||
|
) {
|
||||||
return downloadLegacyExcel(
|
return downloadLegacyExcel(
|
||||||
'/freight/running-water/export',
|
'/freight/running-water/export',
|
||||||
params,
|
params,
|
||||||
'ExportFreightWaters',
|
filename,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,9 +21,12 @@ import {
|
|||||||
} from 'antdv-next';
|
} from 'antdv-next';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { submitGmGoldOperation } from '#/api/legacy/gm';
|
import { pageGmGoldOperation, submitGmGoldOperation } from '#/api/legacy/gm';
|
||||||
import { getClsGoldRunningWater } from '#/api/legacy/operate';
|
import {
|
||||||
import { listMembers } from '#/api/legacy/team';
|
exportClsGoldRunningWater,
|
||||||
|
getClsGoldRunningWater,
|
||||||
|
} from '#/api/legacy/operate';
|
||||||
|
import { listBackUserOptions } from '#/api/legacy/system';
|
||||||
import { getUserBaseInfoBySysOriginAccount } from '#/api/legacy/user';
|
import { getUserBaseInfoBySysOriginAccount } from '#/api/legacy/user';
|
||||||
import AccountInput from '#/components/account-input.vue';
|
import AccountInput from '#/components/account-input.vue';
|
||||||
import UserProfileLink from '#/views/operate/components/user-profile-link.vue';
|
import UserProfileLink from '#/views/operate/components/user-profile-link.vue';
|
||||||
@ -56,6 +59,8 @@ const DEFAULT_PAGE_SIZE = 100;
|
|||||||
const open = ref(false);
|
const open = ref(false);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const loadMoreLoading = ref(false);
|
const loadMoreLoading = ref(false);
|
||||||
|
const operatorsLoading = ref(false);
|
||||||
|
const exporting = ref(false);
|
||||||
const submitting = ref(false);
|
const submitting = ref(false);
|
||||||
const list = ref<Array<Record<string, any>>>([]);
|
const list = ref<Array<Record<string, any>>>([]);
|
||||||
const notMore = ref(false);
|
const notMore = ref(false);
|
||||||
@ -64,7 +69,7 @@ const rangeDate = ref<[string, string] | null>(null);
|
|||||||
const operators = ref<Array<Record<string, any>>>([]);
|
const operators = ref<Array<Record<string, any>>>([]);
|
||||||
|
|
||||||
const query = reactive<Record<string, any>>({
|
const query = reactive<Record<string, any>>({
|
||||||
backOperationUser: undefined,
|
backOperationUsers: [],
|
||||||
context: '',
|
context: '',
|
||||||
endTime: '',
|
endTime: '',
|
||||||
lastId: '',
|
lastId: '',
|
||||||
@ -103,10 +108,14 @@ const showUsdQuantity = computed(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const operatorOptions = computed(() =>
|
const operatorOptions = computed(() =>
|
||||||
operators.value.map((item) => ({
|
operators.value.map((item) => {
|
||||||
label: `${item.nickname || item.loginName || item.id} / ${item.loginName || item.id}`,
|
const name = item.nickname || item.loginName || item.name || item.id;
|
||||||
value: item.id,
|
const account = item.loginName && item.loginName !== name ? ` / ${item.loginName}` : '';
|
||||||
})),
|
return {
|
||||||
|
label: `${name}${account}`,
|
||||||
|
value: item.id,
|
||||||
|
};
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const currentPageList = computed(() => {
|
const currentPageList = computed(() => {
|
||||||
@ -259,22 +268,81 @@ function filterOperatorOption(input: string, option: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadOperators() {
|
async function loadOperators() {
|
||||||
operators.value = (await listMembers()) || [];
|
operatorsLoading.value = true;
|
||||||
|
try {
|
||||||
|
let backUsers: Array<Record<string, any>> = [];
|
||||||
|
try {
|
||||||
|
const result = await listBackUserOptions();
|
||||||
|
backUsers = Array.isArray(result) ? result : [];
|
||||||
|
} catch {
|
||||||
|
backUsers = [];
|
||||||
|
}
|
||||||
|
operators.value =
|
||||||
|
backUsers.length > 0
|
||||||
|
? normalizeOperators(backUsers)
|
||||||
|
: await loadRecentGmOperators().catch(() => []);
|
||||||
|
} finally {
|
||||||
|
operatorsLoading.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadData(reset = false) {
|
function normalizeOperators(items: Array<Record<string, any>>) {
|
||||||
if (loading.value || loadMoreLoading.value) {
|
const operatorMap = new Map<string, Record<string, any>>();
|
||||||
return;
|
items.forEach((item) => {
|
||||||
}
|
const id = item.id || item.applicantId;
|
||||||
|
if (!id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
operatorMap.set(String(id), {
|
||||||
|
id,
|
||||||
|
loginName: item.loginName,
|
||||||
|
name: item.name,
|
||||||
|
nickname: item.nickname || item.applicantName,
|
||||||
|
status: item.status,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return [...operatorMap.values()];
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadRecentGmOperators() {
|
||||||
|
const result = await pageGmGoldOperation({ cursor: 1, limit: 500 });
|
||||||
|
return normalizeOperators(result?.records || []);
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateQueryTimeRange() {
|
||||||
if (!query.startTime || !query.endTime) {
|
if (!query.startTime || !query.endTime) {
|
||||||
message.warning('请选择时间范围');
|
message.warning('请选择时间范围');
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const startYear = new Date(Number(query.startTime)).getFullYear();
|
const startYear = new Date(Number(query.startTime)).getFullYear();
|
||||||
const endYear = new Date(Number(query.endTime)).getFullYear();
|
const endYear = new Date(Number(query.endTime)).getFullYear();
|
||||||
if (startYear !== endYear) {
|
if (startYear !== endYear) {
|
||||||
message.warning('不允许跨年查询');
|
message.warning('不允许跨年查询');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildRunningWaterParams() {
|
||||||
|
const backOperationUsers = Array.isArray(query.backOperationUsers)
|
||||||
|
? query.backOperationUsers.filter(Boolean).join(',')
|
||||||
|
: '';
|
||||||
|
return {
|
||||||
|
backOperationUsers: backOperationUsers || undefined,
|
||||||
|
endTime: query.endTime,
|
||||||
|
queryBackOperationUser: true,
|
||||||
|
startTime: query.startTime,
|
||||||
|
type: query.type,
|
||||||
|
userId: query.userId || undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadData(reset = false) {
|
||||||
|
if (loading.value || loadMoreLoading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!validateQueryTimeRange()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,15 +362,10 @@ async function loadData(reset = false) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await getClsGoldRunningWater({
|
const result = await getClsGoldRunningWater({
|
||||||
backOperationUser: query.backOperationUser || undefined,
|
...buildRunningWaterParams(),
|
||||||
context: query.context || undefined,
|
context: query.context || undefined,
|
||||||
endTime: query.endTime,
|
|
||||||
lastId: query.lastId || undefined,
|
lastId: query.lastId || undefined,
|
||||||
limit: query.limit,
|
limit: query.limit,
|
||||||
queryBackOperationUser: true,
|
|
||||||
startTime: query.startTime,
|
|
||||||
type: query.type,
|
|
||||||
userId: query.userId || undefined,
|
|
||||||
});
|
});
|
||||||
const waters = result?.waters || [];
|
const waters = result?.waters || [];
|
||||||
const nextList = reset ? waters : [...list.value, ...waters];
|
const nextList = reset ? waters : [...list.value, ...waters];
|
||||||
@ -352,6 +415,21 @@ async function handleSearch() {
|
|||||||
await loadData(true);
|
await loadData(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleExport() {
|
||||||
|
if (exporting.value || !validateQueryTimeRange()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
exporting.value = true;
|
||||||
|
try {
|
||||||
|
await exportClsGoldRunningWater(
|
||||||
|
buildRunningWaterParams(),
|
||||||
|
`GmGoldRunningWater_${dayjs(Number(query.startTime)).format('YYYYMMDD')}_${dayjs(Number(query.endTime)).format('YYYYMMDD')}`,
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
exporting.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
if (!validateForm()) {
|
if (!validateForm()) {
|
||||||
return;
|
return;
|
||||||
@ -420,15 +498,19 @@ void loadData(true);
|
|||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
v-model:value="query.backOperationUser"
|
v-model:value="query.backOperationUsers"
|
||||||
allow-clear
|
allow-clear
|
||||||
|
mode="multiple"
|
||||||
show-search
|
show-search
|
||||||
|
max-tag-count="responsive"
|
||||||
placeholder="操作人"
|
placeholder="操作人"
|
||||||
style="width: 220px"
|
style="width: 220px"
|
||||||
:filter-option="filterOperatorOption"
|
:filter-option="filterOperatorOption"
|
||||||
|
:loading="operatorsLoading"
|
||||||
:options="operatorOptions"
|
:options="operatorOptions"
|
||||||
/>
|
/>
|
||||||
<Button :loading="loading" type="primary" @click="handleSearch">查询</Button>
|
<Button :loading="loading" type="primary" @click="handleSearch">查询</Button>
|
||||||
|
<Button :loading="exporting" @click="handleExport">导出Excel</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Table
|
<Table
|
||||||
|
|||||||
@ -1,9 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {
|
import { computed, reactive, ref, watch } from 'vue';
|
||||||
computed,
|
|
||||||
reactive,
|
|
||||||
ref,
|
|
||||||
watch } from 'vue';
|
|
||||||
|
|
||||||
import { Page } from '@vben/common-ui';
|
import { Page } from '@vben/common-ui';
|
||||||
import { useAccessStore } from '@vben/stores';
|
import { useAccessStore } from '@vben/stores';
|
||||||
@ -11,10 +7,10 @@ import { useAccessStore } from '@vben/stores';
|
|||||||
import {
|
import {
|
||||||
exportFreightWaters,
|
exportFreightWaters,
|
||||||
pageFreightRunningWater,
|
pageFreightRunningWater,
|
||||||
} from '#/api/legacy/user';
|
} from '#/api/legacy/user';
|
||||||
|
import { listBackUserOptions } from '#/api/legacy/system';
|
||||||
import AccountInput from '#/components/account-input.vue';
|
import AccountInput from '#/components/account-input.vue';
|
||||||
import { formatDate,
|
import { formatDate, getAllowedSysOrigins } from '#/views/system/shared';
|
||||||
getAllowedSysOrigins } from '#/views/system/shared';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@ -23,7 +19,7 @@ import {
|
|||||||
Pagination,
|
Pagination,
|
||||||
Select,
|
Select,
|
||||||
Table,
|
Table,
|
||||||
message
|
message,
|
||||||
} from 'antdv-next';
|
} from 'antdv-next';
|
||||||
|
|
||||||
import UserProfileLink from './components/user-profile-link.vue';
|
import UserProfileLink from './components/user-profile-link.vue';
|
||||||
@ -50,11 +46,14 @@ const loading = ref(false);
|
|||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
const list = ref<Array<Record<string, any>>>([]);
|
const list = ref<Array<Record<string, any>>>([]);
|
||||||
const exporting = ref(false);
|
const exporting = ref(false);
|
||||||
|
const operatorsLoading = ref(false);
|
||||||
|
const operators = ref<Array<Record<string, any>>>([]);
|
||||||
const rangeDate = ref<[string, string] | null>(null);
|
const rangeDate = ref<[string, string] | null>(null);
|
||||||
|
|
||||||
const query = reactive<Record<string, any>>({
|
const query = reactive<Record<string, any>>({
|
||||||
acceptUserId: '',
|
acceptUserId: '',
|
||||||
cursor: 1,
|
cursor: 1,
|
||||||
|
createUsers: [],
|
||||||
endTime: '',
|
endTime: '',
|
||||||
limit: 20,
|
limit: 20,
|
||||||
origin: undefined,
|
origin: undefined,
|
||||||
@ -76,6 +75,17 @@ const columns = [
|
|||||||
{ dataIndex: 'createTime', key: 'createTime', title: '创建时间', width: 180 },
|
{ dataIndex: 'createTime', key: 'createTime', title: '创建时间', width: 180 },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const operatorOptions = computed(() =>
|
||||||
|
operators.value.map((item) => {
|
||||||
|
const name = item.nickname || item.loginName || item.name || item.id;
|
||||||
|
const account = item.loginName && item.loginName !== name ? ` / ${item.loginName}` : '';
|
||||||
|
return {
|
||||||
|
label: `${name}${account}`,
|
||||||
|
value: item.id,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
sysOriginOptions,
|
sysOriginOptions,
|
||||||
(options) => {
|
(options) => {
|
||||||
@ -103,6 +113,63 @@ watch(
|
|||||||
{ immediate: true },
|
{ immediate: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function normalizeOperators(items: Array<Record<string, any>>) {
|
||||||
|
const operatorMap = new Map<string, Record<string, any>>();
|
||||||
|
items.forEach((item) => {
|
||||||
|
const id = item.id || item.applicantId;
|
||||||
|
if (!id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
operatorMap.set(String(id), {
|
||||||
|
id,
|
||||||
|
loginName: item.loginName,
|
||||||
|
name: item.name,
|
||||||
|
nickname: item.nickname || item.applicantName,
|
||||||
|
status: item.status,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return [...operatorMap.values()];
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterOperatorOption(input: string, option: any) {
|
||||||
|
return String(option?.label || '')
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(input.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadOperators() {
|
||||||
|
operatorsLoading.value = true;
|
||||||
|
try {
|
||||||
|
const result = await listBackUserOptions();
|
||||||
|
operators.value = normalizeOperators(Array.isArray(result) ? result : []);
|
||||||
|
} catch {
|
||||||
|
operators.value = [];
|
||||||
|
} finally {
|
||||||
|
operatorsLoading.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildFreightRunningWaterParams(withPage = true) {
|
||||||
|
const createUsers = Array.isArray(query.createUsers)
|
||||||
|
? query.createUsers.filter(Boolean).join(',')
|
||||||
|
: '';
|
||||||
|
const params: Record<string, any> = {
|
||||||
|
acceptUserId: query.acceptUserId || undefined,
|
||||||
|
createUsers: createUsers || undefined,
|
||||||
|
endTime: query.endTime || undefined,
|
||||||
|
origin: query.origin || undefined,
|
||||||
|
queryBackOperationUser: query.queryBackOperationUser,
|
||||||
|
startTime: query.startTime || undefined,
|
||||||
|
sysOrigin: query.sysOrigin,
|
||||||
|
userId: query.userId || undefined,
|
||||||
|
};
|
||||||
|
if (withPage) {
|
||||||
|
params.cursor = query.cursor;
|
||||||
|
params.limit = query.limit;
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
async function loadData(reset = false) {
|
async function loadData(reset = false) {
|
||||||
if (!query.sysOrigin) {
|
if (!query.sysOrigin) {
|
||||||
return;
|
return;
|
||||||
@ -112,7 +179,7 @@ async function loadData(reset = false) {
|
|||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
const result = await pageFreightRunningWater({ ...query });
|
const result = await pageFreightRunningWater(buildFreightRunningWaterParams());
|
||||||
list.value = result.records || [];
|
list.value = result.records || [];
|
||||||
total.value = result.total || 0;
|
total.value = result.total || 0;
|
||||||
} finally {
|
} finally {
|
||||||
@ -137,19 +204,26 @@ async function handleExport() {
|
|||||||
}
|
}
|
||||||
exporting.value = true;
|
exporting.value = true;
|
||||||
try {
|
try {
|
||||||
await exportFreightWaters({ ...query });
|
await exportFreightWaters(
|
||||||
|
buildFreightRunningWaterParams(false),
|
||||||
|
`ExportFreightWaters_${query.startTime || 'all'}_${query.endTime || 'all'}`,
|
||||||
|
);
|
||||||
message.success('导出成功');
|
message.success('导出成功');
|
||||||
} finally {
|
} finally {
|
||||||
exporting.value = false;
|
exporting.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loadOperators();
|
||||||
void loadData(true);
|
void loadData(true);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page v-if="!queryBackOperation" title="货运代理流水">
|
<component
|
||||||
<Card>
|
:is="queryBackOperation ? 'div' : Page"
|
||||||
|
:title="queryBackOperation ? undefined : '货运代理流水'"
|
||||||
|
>
|
||||||
|
<component :is="queryBackOperation ? 'div' : Card">
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
<SysOriginSelect
|
<SysOriginSelect
|
||||||
v-model:value="query.sysOrigin"
|
v-model:value="query.sysOrigin"
|
||||||
@ -175,9 +249,21 @@ void loadData(true);
|
|||||||
allow-clear
|
allow-clear
|
||||||
placeholder="来源"
|
placeholder="来源"
|
||||||
style="width: 140px"
|
style="width: 140px"
|
||||||
|
|
||||||
:options="FREIGHT_BALANCE_ORIGIN_OPTIONS.map((item) => ({ label: `${item.name}`, value: item.value as any }))"
|
:options="FREIGHT_BALANCE_ORIGIN_OPTIONS.map((item) => ({ label: `${item.name}`, value: item.value as any }))"
|
||||||
/>
|
/>
|
||||||
|
<Select
|
||||||
|
v-model:value="query.createUsers"
|
||||||
|
allow-clear
|
||||||
|
mode="multiple"
|
||||||
|
show-search
|
||||||
|
max-tag-count="responsive"
|
||||||
|
option-label-prop="label"
|
||||||
|
placeholder="操作人"
|
||||||
|
style="width: 220px"
|
||||||
|
:filter-option="filterOperatorOption"
|
||||||
|
:loading="operatorsLoading"
|
||||||
|
:options="operatorOptions"
|
||||||
|
/>
|
||||||
<DatePicker.RangePicker
|
<DatePicker.RangePicker
|
||||||
v-model:value="rangeDate"
|
v-model:value="rangeDate"
|
||||||
show-time
|
show-time
|
||||||
@ -234,8 +320,8 @@ void loadData(true);
|
|||||||
@showSizeChange="handlePageChange"
|
@showSizeChange="handlePageChange"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</component>
|
||||||
</Page>
|
</component>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user