feat(订单管理): 添加订单导出功能并优化查询参数
在订单管理模块中新增了订单导出功能,支持将订单数据导出为Excel文件。同时,优化了查询参数的处理逻辑,新增了支付方式和支付时间的查询条件,提升了查询的灵活性和准确性。
This commit is contained in:
parent
885e1aa8d1
commit
5059eeca54
|
@ -1,27 +1,78 @@
|
||||||
import { http } from "@/utils/http";
|
import { http } from "@/utils/http";
|
||||||
|
|
||||||
export interface OrderQuery extends BasePageQuery {
|
export interface OrderQuery extends BasePageQuery {
|
||||||
|
/** 订单编号 */
|
||||||
orderNumber?: string;
|
orderNumber?: string;
|
||||||
|
/**
|
||||||
|
* 订单状态
|
||||||
|
* @remarks
|
||||||
|
* 1-待付款 | 2-已付款 | 3-已发货 | 4-已完成 | 5-已取消
|
||||||
|
*/
|
||||||
status?: number;
|
status?: number;
|
||||||
|
/**
|
||||||
|
* 支付状态
|
||||||
|
* @remarks
|
||||||
|
* 1-未支付 | 2-已支付 | 3-退款中 | 4-已退款
|
||||||
|
*/
|
||||||
payStatus?: number;
|
payStatus?: number;
|
||||||
|
/** 订单开始时间(查询范围) */
|
||||||
startTime?: string;
|
startTime?: string;
|
||||||
|
/** 订单结束时间(查询范围) */
|
||||||
endTime?: string;
|
endTime?: string;
|
||||||
|
/** 支付时间(精确查询) */
|
||||||
|
payTime?: string;
|
||||||
|
/**
|
||||||
|
* 支付方式
|
||||||
|
* @remarks
|
||||||
|
* wechat-微信支付 | balance-余额支付
|
||||||
|
*/
|
||||||
|
paymentMethod?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrderDTO {
|
export interface OrderDTO {
|
||||||
|
/** 订单唯一ID */
|
||||||
orderId: number;
|
orderId: number;
|
||||||
|
/** ucid */
|
||||||
ucid?: string;
|
ucid?: string;
|
||||||
|
/** openid */
|
||||||
openid?: string;
|
openid?: string;
|
||||||
|
/** 支付网关交易id */
|
||||||
tradeId?: string;
|
tradeId?: string;
|
||||||
|
/** 手机号码 */
|
||||||
mobile?: string;
|
mobile?: string;
|
||||||
|
/** 企业微信用户ID或汇邦云用户ID */
|
||||||
userid?: string;
|
userid?: string;
|
||||||
|
/** 用户姓名 */
|
||||||
name?: string;
|
name?: string;
|
||||||
|
/**
|
||||||
|
* 是否内部用户
|
||||||
|
* @remarks
|
||||||
|
* 0-否 | 1-汇邦云用户 | 2-企业微信用户
|
||||||
|
*/
|
||||||
isInternal?: number;
|
isInternal?: number;
|
||||||
|
/** 业务系统订单ID(对接外部系统) */
|
||||||
bizOrderId?: string;
|
bizOrderId?: string;
|
||||||
|
/** 订单总金额 */
|
||||||
totalAmount: number;
|
totalAmount: number;
|
||||||
|
/**
|
||||||
|
* 订单状态
|
||||||
|
* @remarks
|
||||||
|
* 1-待付款 | 2-已付款 | 3-已发货 | 4-已完成 | 5-已取消
|
||||||
|
*/
|
||||||
status: number;
|
status: number;
|
||||||
|
/**
|
||||||
|
* 支付状态
|
||||||
|
* @remarks
|
||||||
|
* 1-未支付 | 2-已支付 | 3-退款中 | 4-已退款
|
||||||
|
*/
|
||||||
payStatus: number;
|
payStatus: number;
|
||||||
|
/**
|
||||||
|
* 支付方式
|
||||||
|
* @remarks
|
||||||
|
* wechat-微信支付 | balance-余额支付
|
||||||
|
*/
|
||||||
paymentMethod?: string;
|
paymentMethod?: string;
|
||||||
|
/** 支付时间 */
|
||||||
payTime?: string;
|
payTime?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +81,22 @@ export const getOrderListApi = (params?: OrderQuery) => {
|
||||||
params: {
|
params: {
|
||||||
...params,
|
...params,
|
||||||
// 处理时间范围参数格式
|
// 处理时间范围参数格式
|
||||||
startTime: params?.startTime ? new Date(params.startTime).toISOString() : undefined,
|
startTime: params?.startTime ? params.startTime : undefined,
|
||||||
endTime: params?.endTime ? new Date(params.endTime).toISOString() : undefined
|
endTime: params?.endTime ? params.endTime : undefined,
|
||||||
|
payTime: params?.payTime ? params.payTime : undefined
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 批量导出订单 */
|
||||||
|
export const exportOrderExcelApi = (params: OrderQuery, fileName: string) => {
|
||||||
|
return http.download("/shop/order/excel", fileName, {
|
||||||
|
params: {
|
||||||
|
...params,
|
||||||
|
// 处理时间范围参数格式
|
||||||
|
startTime: params?.startTime ? params.startTime : undefined,
|
||||||
|
endTime: params?.endTime ? params.endTime : undefined,
|
||||||
|
payTime: params?.payTime ? params.payTime : undefined
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
|
@ -2,7 +2,7 @@
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { PureTableBar } from "@/components/RePureTableBar";
|
import { PureTableBar } from "@/components/RePureTableBar";
|
||||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
||||||
import { getOrderListApi, type OrderDTO } from "@/api/shop/order";
|
import { getOrderListApi, exportOrderExcelApi, type OrderDTO } from "@/api/shop/order";
|
||||||
import Search from "@iconify-icons/ep/search";
|
import Search from "@iconify-icons/ep/search";
|
||||||
import Refresh from "@iconify-icons/ep/refresh";
|
import Refresh from "@iconify-icons/ep/refresh";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
|
@ -18,8 +18,10 @@ const searchFormParams = ref({
|
||||||
orderNumber: "",
|
orderNumber: "",
|
||||||
status: null,
|
status: null,
|
||||||
payStatus: null,
|
payStatus: null,
|
||||||
|
paymentMethod: null,
|
||||||
startTime: "",
|
startTime: "",
|
||||||
endTime: ""
|
endTime: "",
|
||||||
|
payTime: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
const pagination = ref({
|
const pagination = ref({
|
||||||
|
@ -66,6 +68,28 @@ const onCurrentChange = (val: number) => {
|
||||||
getList();
|
getList();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const exportLoading = ref(false);
|
||||||
|
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
exportLoading.value = true;
|
||||||
|
const dateSuffix = searchFormParams.value.payTime
|
||||||
|
? `_${searchFormParams.value.payTime.split(' ')[0].replace(/-/g, '')}`
|
||||||
|
: '';
|
||||||
|
const fileName = `订单列表${dateSuffix}.xlsx`;
|
||||||
|
await exportOrderExcelApi({
|
||||||
|
...searchFormParams.value,
|
||||||
|
pageSize: pagination.value.pageSize,
|
||||||
|
pageNum: pagination.value.currentPage
|
||||||
|
}, fileName);
|
||||||
|
ElMessage.success('导出任务已开始,请稍后查看下载文件');
|
||||||
|
} catch (e) {
|
||||||
|
ElMessage.error('导出失败');
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
getList();
|
getList();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -73,11 +97,15 @@ getList();
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<el-form ref="formRef" :inline="true" :model="searchFormParams"
|
<el-form ref="formRef" :inline="true" :model="searchFormParams"
|
||||||
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]">
|
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]">
|
||||||
<el-form-item label="时间范围:">
|
<!-- <el-form-item label="时间范围:">
|
||||||
<el-date-picker v-model="searchFormParams.startTime" type="datetime" placeholder="开始时间"
|
<el-date-picker v-model="searchFormParams.startTime" type="date" placeholder="开始时间"
|
||||||
value-format="YYYY-MM-DD HH:mm:ss" class="!w-[200px]" />
|
value-format="YYYY-MM-DD HH:mm:ss" class="!w-[200px]" />
|
||||||
<span class="mx-2">至</span>
|
<span class="mx-2">至</span>
|
||||||
<el-date-picker v-model="searchFormParams.endTime" type="datetime" placeholder="结束时间"
|
<el-date-picker v-model="searchFormParams.endTime" type="date" placeholder="结束时间"
|
||||||
|
value-format="YYYY-MM-DD HH:mm:ss" class="!w-[200px]" />
|
||||||
|
</el-form-item> -->
|
||||||
|
<el-form-item label="支付日期:">
|
||||||
|
<el-date-picker v-model="searchFormParams.payTime" type="date" placeholder="支付时间"
|
||||||
value-format="YYYY-MM-DD HH:mm:ss" class="!w-[200px]" />
|
value-format="YYYY-MM-DD HH:mm:ss" class="!w-[200px]" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="订单编号:" prop="orderNumber">
|
<el-form-item label="订单编号:" prop="orderNumber">
|
||||||
|
@ -100,6 +128,12 @@ getList();
|
||||||
<el-option label="已退款" :value="4" />
|
<el-option label="已退款" :value="4" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="支付方式:" prop="paymentMethod">
|
||||||
|
<el-select v-model="searchFormParams.paymentMethod" placeholder="请选择支付方式" clearable class="!w-[180px]">
|
||||||
|
<el-option label="微信支付" value="wechat" />
|
||||||
|
<el-option label="余额支付" value="balance" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" :icon="useRenderIcon(Search)" @click="onSearch">
|
<el-button type="primary" :icon="useRenderIcon(Search)" @click="onSearch">
|
||||||
搜索
|
搜索
|
||||||
|
@ -107,6 +141,10 @@ getList();
|
||||||
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm">
|
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm">
|
||||||
重置
|
重置
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button type="success" :loading="exportLoading" :icon="useRenderIcon('vscode-icons:file-type-excel2')"
|
||||||
|
@click="handleExport">
|
||||||
|
导出Excel
|
||||||
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue