feat(shopOrder): 优化订单搜索和管理功能

- 添加订单编号、用户ID、手机号、昵称等搜索条件
- 修改订单删除条件,仅允许删除已取消的订单
- 更新已退款订单的状态显示为"退货/售后"- 移除多余的环境变量配置
This commit is contained in:
2025-08-12 11:32:35 +08:00
parent df910e4344
commit cc8b8faf63
5 changed files with 69 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
VITE_APP_NAME=后台管理(开发环境)
#VITE_API_URL=http://127.0.0.1:9200/api
VITE_API_URL=http://127.0.0.1:9200/api
#VITE_SERVER_API_URL=http://127.0.0.1:8000/api
VITE_API_URL=https://cms-api.websoft.top/api
#VITE_API_URL=https://cms-api.s209.websoft.top/api

View File

@@ -157,6 +157,9 @@ export interface ShopOrderParam extends PageParam {
orderNo?: string;
type?: number;
phone?: string;
userId?: number;
payUserId?: number;
nickname?: string;
payStatus?: number;
orderStatus?: number;
payType?: number;

View File

@@ -836,8 +836,8 @@ const isRefundStatus = (orderStatus?: number) => {
// 判断是否可以删除订单
const canDeleteOrder = (order: ShopOrder) => {
// 已完成、已取消、退款成功的订单可以删除
return [1, 2, 6].includes(order.orderStatus || 0);
// 已完成、已取消、退款成功的订单可以删除 (原来是[1, 2, 6],后面改成只有取消的订单能删除)
return [2].includes(order.orderStatus || 0);
};
// 判断是否可以申请退款

View File

@@ -13,6 +13,14 @@
<!-- </template>-->
<!-- <span>批量删除</span>-->
<!-- </a-button>-->
<a-input-search
allow-clear
v-model:value="where.orderNo"
placeholder="订单编号"
style="width: 240px"
@search="reload"
@pressEnter="reload"
/>
<a-select
v-model:value="where.type"
style="width: 150px"
@@ -64,11 +72,30 @@
/>
<a-input-search
allow-clear
placeholder="请输入关键词"
style="width: 280px"
:placeholder="getSearchPlaceholder()"
style="width: 320px"
v-model:value="where.keywords"
@search="reload"
/>
>
<template #addonBefore>
<a-select
v-model:value="type"
style="width: 88px;"
@change="onType"
>
<a-select-option value="">全部</a-select-option>
<a-select-option value="userId">
用户ID
</a-select-option>
<a-select-option value="phone">
手机号
</a-select-option>
<a-select-option value="nickname">
昵称
</a-select-option>
</a-select>
</template>
</a-input-search>
<a-button @click="reset">重置</a-button>
<a-button @click="handleExport">导出</a-button>
</a-space>
@@ -106,6 +133,8 @@
createTimeStart: undefined,
createTimeEnd: undefined,
userId: undefined,
payUserId: undefined,
nickname: undefined,
phone: undefined,
payStatus: undefined,
orderStatus: undefined,
@@ -113,7 +142,7 @@
});
const reload = () => {
emit('search', where);
emit('search', {...where, keywords: type.value == '' ? where.keywords : undefined});
};
// 批量删除
@@ -121,6 +150,27 @@
emit('remove');
};
const onType = () => {
resetFields();
};
// 获取搜索框placeholder
const getSearchPlaceholder = () => {
switch (type.value){
case 'userId':
where.userId = Number(where.keywords);
return '请输入用户ID';
case 'phone':
where.phone = where.keywords;
return '请输入手机号';
case 'nickname':
where.nickname = where.keywords;
return '请输入用户昵称';
default:
return '请输入搜索内容';
}
}
/* 搜索 */
const search = () => {
const [d1, d2] = dateRange.value ?? [];
@@ -143,6 +193,7 @@
const loading = ref(false);
const orders = ref<ShopOrder[]>([])
const xlsFileName = ref<string>();
const type = ref('');
// 导出
const handleExport = async () => {

View File

@@ -16,7 +16,7 @@
<a-tab-pane key="undelivered" tab="待发货"/>
<a-tab-pane key="unreceived" tab="待收货"/>
<a-tab-pane key="completed" tab="已完成"/>
<a-tab-pane key="refunded" tab="已退款"/>
<a-tab-pane key="refunded" tab="退货/售后"/>
<a-tab-pane key="cancelled" tab="已取消"/>
</a-tabs>
<ele-pro-table
@@ -113,7 +113,7 @@
</a>
<a-divider type="vertical"/>
<a
@click.stop="openEdit(record)"
@click.stop="handleCancelOrder(record)"
>
<a class="ele-text-warning">
<CloseOutlined /> 取消
@@ -179,9 +179,9 @@
<a-divider type="vertical"/>
<a-popconfirm
title="确定要删除此订单吗?删除后无法恢复。"
@confirm.stop="remove(record)"
@confirm="remove(record)"
>
<a class="ele-text-danger">
<a class="ele-text-danger" @click.stop>
<DeleteOutlined /> 删除
</a>
</a-popconfirm>
@@ -399,7 +399,7 @@ const onTabs = () => {
filterParams.statusFilter = 8;
break;
case 'refunded':
// 退款order_status = 6
// 退款/售后order_status = 6
filterParams.statusFilter = 6;
break;
case 'deleted':
@@ -464,8 +464,8 @@ const isRefundStatus = (orderStatus?: number) => {
// 判断是否可以删除订单
const canDeleteOrder = (order: ShopOrder) => {
// 已完成、已取消、退款成功的订单可以删除
return [1, 2, 6].includes(order.orderStatus || 0);
// 已完成、已取消、退款成功的订单可以删除 (原来是[1, 2, 6],后面改成只有取消的订单能删除)
return [2].includes(order.orderStatus || 0);
};
/* 订单操作方法 */