feat(shopOrder): 添加订单商品明细展开功能并优化订单状态显示

- 在订单列表中增加商品明细的展开/收起功能,默认显示2条商品信息
- 支持点击“展开全部 N 件”切换显示全部或折叠商品明细
- 优化订单状态栏支付状态、发货状态、开票状态及操作按钮中的分隔线统一风格
- 将shop/dashboard运行天数改为基于租户创建时间,而非订阅生效时间,保证准确性
- 调整订单列表表格列宽及显示顺序,改善界面布局和信息展示
- 注释和代码格式微调,删除无用的组件显示及注释代码,提升代码整洁度
- 修复了部分变量定义和模板标签排版,完善代码可维护性
This commit is contained in:
2026-07-29 00:44:54 +08:00
parent 4ab90c9d89
commit e87e60fd6a
5 changed files with 795 additions and 784 deletions

View File

@@ -4,3 +4,21 @@
- 文件:`src/views/shop/shopOrder/index.vue``column.key === 'action'` 操作列模板。
- 改动:原本操作列按钮只用 `<a-space>` 包裹、无分隔线;现按 `shop/shopGoods` 的写法,在「详情」与各条件块之间、以及块内多个按钮之间加入 `<a-divider type="vertical" />`
- 分隔线放在各 `<template v-if>` 条件块内部,仅当对应操作出现时才渲染,避免多余竖线。
## 订单列表商品明细展开/收起(方案一已落地)
- 文件:`src/views/shop/shopOrder/index.vue`
- 需求:商品明细较多时列表行被撑高,加「展开/收起」。采用方案一(单元格内展开),已确认执行。
- 实现:
- 新增 `expandedOrderIds: ref<Set<string>>`(用 `String(record.orderId)` 作 key因 orderId 为 number|undefined
- 新增 `collapsedGoodsCount = 2``isOrderGoodsExpanded(record)``toggleOrderGoodsExpanded(record)`
- 改写 `column.key === 'orderGoods'` 模板:默认 `record.orderGoods.slice(0, 2)`,超过 2 件显示「展开全部 N 件」,点击切换,展开后文案变「收起」。
- 类型检查:`vue-tsc --noEmit` 仅有的 3 处报错line 2 `$router`/page-header、line 696/734 未用变量)均为项目既有,与本次改动无关。
## shop/dashboard 运行天数改为取租户创建时间
- 文件:`src/views/shop/dashboard/index.vue`
- 需求:/dashboard 的"运行天数"要改用「租户创建时间」而不是订阅生效时间。
- 现状调查:
- `cms/dashboard`(站点控制台,标题"系统运行天数")已在提交 894592c 改为 `getTenantInfo().createTime`(租户创建时间),已是目标行为。
- `shop/dashboard`(商城后台,标签"运行天数")原用 `currentSubscription.startTime`(订阅生效时间)。
- 改动:将 shop/dashboard 的 `runDays` computed 改为取 `tenantStore.company?.createTime`loadData 已 `tenantStore.fetchTenantInfo()` 写入 company。同步更新顶部数据来源注释。
- 数据源说明:`getTenantInfo()` 返回 `Company`,其 `createTime` 字段即租户创建时间(`src/api/system/company/model/index.ts` line 164`site.ts``runDays` getter 仍用 `siteInfo.createTime`(站点创建时间),目前 cms/dashboard 已不依赖它。

View File

@@ -344,10 +344,10 @@ const { loading: statisticsLoading } = storeToRefs(statisticsStore);
// ============================================================
// 基本信息:数据来源拆分
// - 身份信息(系统名称/版本号/运行状态)来自 app_product (productId=65)
// - 时间线(创建时间/到期时间/系统运行天数)来自 app_subscription
// · 创建时间 = subscription.startTime订阅生效时间
// - 时间线(开通时间/到期时间)来自 app_subscription
// · 开通时间 = subscription.startTime订阅生效时间
// · 到期时间 = subscription.expireTime
// · 系统运行天数 = 自 subscription.createTime 起累计
// - 系统运行天数 = 自租户创建时间起累计tenantStore.company.createTime
// ============================================================
// 当前应用产品(按固定 productId=65 查询)
const currentProduct = ref<AppProduct | null>(null);
@@ -643,15 +643,13 @@ const onPayModalClose = () => {
// 计算属性
const now = ref(Date.now());
let runDaysTimer: ReturnType<typeof setInterval>;
// 系统运行天数:自订阅生效时间起累计
// 锚定 currentSubscription.startTime与"创建时间"行同源,语义统一)
// 注意:若后端续费为新增订阅记录,此处取的是 expireTime 最新的 active 订阅,
// startTime 可能是续费生效日runDays 会从续费日重新计数。
// 如需"累计运行天数",应改用最早的 active 订阅 startTime 或后端额外提供字段。
// 系统运行天数:自租户创建时间起累计
// 锚定 tenantStore.company.createTime租户建档时间与后台租户创建时间一致
// 数据来源loadData 中已调用 tenantStore.fetchTenantInfo() 写入 tenantStore.company。
const runDays = computed(() => {
const startTime = currentSubscription.value?.startTime;
if (!startTime) return 0;
return Math.floor((now.value - new Date(startTime).getTime()) / (24 * 60 * 60 * 1000));
const createTime = tenantStore.company?.createTime;
if (!createTime) return 0;
return Math.floor((now.value - new Date(createTime).getTime()) / (24 * 60 * 60 * 1000));
});
const userCount = computed(() => statisticsStore.userCount);
const orderCount = computed(() => statisticsStore.orderCount);

View File

@@ -17,7 +17,7 @@
allow-clear
v-model:value="where.orderNo"
placeholder="订单编号"
style="width: 260px"
style="width: 240px"
@search="reload"
@pressEnter="reload"
/>
@@ -31,39 +31,37 @@
<!-- <a-select-option :value="1">普通订单</a-select-option>-->
<!-- <a-select-option :value="2">秒杀订单</a-select-option>-->
<!-- <a-select-option :value="3">拼团订单</a-select-option>-->
<!-- </a-select>-->
<!-- <a-select-->
<!-- v-model:value="where.payStatus"-->
<!-- style="width: 150px"-->
<!-- placeholder="付款状态"-->
<!-- @change="search"-->
<!-- >-->
<!-- <a-select-option value="">全部</a-select-option>-->
<!-- <a-select-option :value="1">已付款</a-select-option>-->
<!-- <a-select-option :value="0">未付款</a-select-option>-->
<!-- </a-select>-->
<a-select
v-model:value="where.orderStatus"
v-model:value="where.payStatus"
style="width: 150px"
placeholder="订单状态"
placeholder="付款状态"
@change="search"
>
<a-select-option value="">全部</a-select-option>
<a-select-option :value="1">完成</a-select-option>
<!-- <a-select-option :value="0">完成</a-select-option>-->
<!-- <a-select-option :value="2">未使用</a-select-option>-->
<a-select-option :value="3">已取消</a-select-option>
<a-select-option :value="4">退款中</a-select-option>
<a-select-option :value="5">退款被拒</a-select-option>
<a-select-option :value="6">退款成功</a-select-option>
<a-select-option :value="1">付款</a-select-option>
<a-select-option :value="0">付款</a-select-option>
</a-select>
<!-- <a-select-->
<!-- :options="getPayType()"-->
<!-- v-model:value="where.payType"-->
<!-- v-model:value="where.orderStatus"-->
<!-- style="width: 150px"-->
<!-- placeholder="付款方式"-->
<!-- placeholder="订单状态"-->
<!-- @change="search"-->
<!-- />-->
<!-- >-->
<!-- <a-select-option value="">全部</a-select-option>-->
<!-- <a-select-option :value="1">已完成</a-select-option>-->
<!-- <a-select-option :value="3">已取消</a-select-option>-->
<!-- <a-select-option :value="4">退款中</a-select-option>-->
<!-- <a-select-option :value="5">退款被拒</a-select-option>-->
<!-- <a-select-option :value="6">退款成功</a-select-option>-->
<!-- </a-select>-->
<a-select
:options="getPayType()"
v-model:value="where.payType"
style="width: 150px"
placeholder="付款方式"
@change="search"
/>
<a-range-picker
v-model:value="dateRange"

View File

@@ -1,6 +1,6 @@
<template>
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
<a-card style="margin-bottom: 20px">
<div class="p-3 mb-2 bg-white">
<search
@search="reload"
:selection="selection"
@@ -9,32 +9,32 @@
@remove="removeBatch"
@batchMove="openMove"
/>
</a-card>
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<div class="order-notify-bar">
<a-space>
<span class="order-notify-label">新订单提醒</span>
<a-switch
v-model:checked="notifyEnabled"
checked-children=""
un-checked-children=""
@change="onNotifyToggle"
/>
<a-tooltip
title="开启后每60秒自动检测新订单检测到后播放叮声并语音播报"
>
<InfoCircleOutlined class="order-notify-tip" />
</a-tooltip>
<a-button
type="link"
size="small"
:disabled="!notifyEnabled"
@click="onTestNotify"
>
测试提醒
</a-button>
</a-space>
</div>
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<!-- <div class="order-notify-bar">-->
<!-- <a-space>-->
<!-- <span class="order-notify-label">新订单提醒</span>-->
<!-- <a-switch-->
<!-- v-model:checked="notifyEnabled"-->
<!-- checked-children="开"-->
<!-- un-checked-children="关"-->
<!-- @change="onNotifyToggle"-->
<!-- />-->
<!-- <a-tooltip-->
<!-- title="开启后每60秒自动检测新订单检测到后播放叮声并语音播报"-->
<!-- >-->
<!-- <InfoCircleOutlined class="order-notify-tip" />-->
<!-- </a-tooltip>-->
<!-- <a-button-->
<!-- type="link"-->
<!-- size="small"-->
<!-- :disabled="!notifyEnabled"-->
<!-- @click="onTestNotify"-->
<!-- >-->
<!-- 测试提醒-->
<!-- </a-button>-->
<!-- </a-space>-->
<!-- </div>-->
<a-tabs type="card" v-model:activeKey="activeKey" @change="onTabs">
<a-tab-pane key="all" tab="全部"/>
<a-tab-pane key="unpaid" tab="待付款"/>
@@ -50,7 +50,8 @@
:columns="columns"
:datasource="datasource"
:customRow="customRow"
:scroll="{ x: 1800 }"
v-model:selection="selection"
:scroll="{ x: 1600 }"
size="small"
cache-key="proShopOrderTable"
:toolbar="false"
@@ -70,10 +71,7 @@
<div class="leading-tight">
<div class="cursor-pointer" @click.stop="onSearch(record)">
{{
record.nickname ||
record.realName ||
record.name ||
'匿名'
record.realName
}}
</div>
<div
@@ -91,16 +89,6 @@
<template v-if="column.key === 'statusInfo'">
<div class="py-1">
<a-space :size="6" wrap>
<!-- 货到付款标识 -->
<a-tag
v-if="record.payType === 8"
color="blue"
>货到付款</a-tag>
<!-- 线下付款标识 -->
<a-tag
v-if="record.payType === 9"
color="orange"
>线下付款</a-tag>
<!-- 支付状态 -->
<a-tag
@@ -108,54 +96,63 @@
color="green"
@click.stop="updatePayStatus(record)"
class="cursor-pointer"
>已付款</a-tag
>已付款
</a-tag
>
<a-tag
v-else-if="record.payStatus == 1 && record.payType === 8"
color="green"
@click.stop="updatePayStatus(record)"
class="cursor-pointer"
>待收货付款</a-tag
>待收货付款
</a-tag
>
<a-tag
v-else-if="record.payStatus == 1 && record.payType === 9"
color="green"
@click.stop="updatePayStatus(record)"
class="cursor-pointer"
>已确认收款</a-tag
>已确认收款
</a-tag
>
<a-tag
v-else-if="record.payStatus == 0 && record.payType === 9"
color="orange"
@click.stop="updatePayStatus(record)"
class="cursor-pointer"
>待确认收款</a-tag
>待确认收款
</a-tag
>
<a-tag
v-else-if="record.payStatus == 0 || record.payStatus == null"
@click.stop="updatePayStatus(record)"
class="cursor-pointer"
>未付款</a-tag
>未付款
</a-tag
>
<a-tag
v-else-if="record.payStatus == 3"
color="orange"
@click.stop="updatePayStatus(record)"
class="cursor-pointer"
>占场中</a-tag
>占场中
</a-tag
>
<!-- 发货状态 -->
<a-tag
v-if="record.deliveryStatus == 10"
class="cursor-pointer"
>未发货</a-tag
>未发货
</a-tag
>
<a-tag v-if="record.deliveryStatus == 20" color="green"
>已发货</a-tag
>已发货
</a-tag
>
<a-tag v-if="record.deliveryStatus == 30" color="blue"
>部分发货</a-tag
>部分发货
</a-tag
>
<!-- 开票状态 -->
@@ -166,23 +163,29 @@
<!-- 订单状态 -->
<a-tag v-if="record.orderStatus === 0">未完成</a-tag>
<a-tag v-if="record.orderStatus === 1" color="green"
>已完成</a-tag
>已完成
</a-tag
>
<a-tag v-if="record.orderStatus === 2">已关闭</a-tag>
<a-tag v-if="record.orderStatus === 3" color="red"
>关闭中</a-tag
>关闭中
</a-tag
>
<a-tag v-if="record.orderStatus === 4" color="red"
>退款申请中</a-tag
>退款申请中
</a-tag
>
<a-tag v-if="record.orderStatus === 5" color="red"
>退款被拒绝</a-tag
>退款被拒绝
</a-tag
>
<a-tag v-if="record.orderStatus === 6" color="orange"
>已退款</a-tag
>已退款
</a-tag
>
<a-tag v-if="record.orderStatus === 7" color="pink"
>客户端申请退款</a-tag
>客户端申请退款
</a-tag
>
<!-- 结算状态 -->
<!-- <a-tag v-if="record.isSettled === 0">未结算</a-tag>-->
@@ -193,24 +196,23 @@
</div>
</template>
<template v-if="column.key === 'orderGoods'">
<template
<a-space
v-for="(item, index) in isOrderGoodsExpanded(record)
? record.orderGoods
: (record.orderGoods || []).slice(0, collapsedGoodsCount)"
:key="index"
>
<div class="item py-1">
<a-space :id="`g-${index}`">
<a-avatar :src="getCompressedImageUrl(item.image,{ width: 100 })" shape="square" :size="50"/>
<div class="flex flex-col">
<span>{{ item.goodsName }}</span>
</a-space>
<span class="text-gray-400 text-xs"> x {{ item.totalNum }} </span>
</div>
</template>
</a-space>
<div
v-if="record.orderGoods && record.orderGoods.length > collapsedGoodsCount"
class="mt-1"
>
<a @click.stop="toggleOrderGoodsExpanded(record)">
<a @click.stop="toggleOrderGoodsExpanded(record)" class="text-xs">
<template v-if="isOrderGoodsExpanded(record)">收起</template>
<template v-else>展开全部 {{ record.orderGoods.length }} 件</template>
</a>
@@ -219,11 +221,11 @@
<template v-if="column.key === 'payType'">
<!-- 货到付款特殊标识 -->
<template v-if="record.payType === 8">
<a-tag color="blue">货到付款</a-tag>
<span>货到付款</span>
</template>
<!-- 线下付款特殊标识 -->
<template v-else-if="record.payType === 9">
<a-tag color="orange">线下付款</a-tag>
<span class="text-sm">线下付款</span>
</template>
<template v-else>
<template v-for="item in getPayType()">
@@ -283,7 +285,8 @@
</template>
<!-- 线下付款·待确认收款状态的操作(支持先发货后结款) -->
<template v-if="!record.payStatus && record.orderStatus === 0 && record.payType === 9 && record.deliveryStatus === 10">
<template
v-if="!record.payStatus && record.orderStatus === 0 && record.payType === 9 && record.deliveryStatus === 10">
<a-divider type="vertical"/>
<a @click.stop="handleConfirmOfflinePayment(record)" class="ele-text-success">
确认收款
@@ -299,7 +302,8 @@
</template>
<!-- 线下付款·已发货未收款状态的操作(先发货后结款) -->
<template v-if="!record.payStatus && record.orderStatus === 0 && record.payType === 9 && record.deliveryStatus === 20">
<template
v-if="!record.payStatus && record.orderStatus === 0 && record.payType === 9 && record.deliveryStatus === 20">
<a-divider type="vertical"/>
<a @click.stop="handleConfirmOfflinePayment(record)" class="ele-text-success">
确认收款
@@ -431,7 +435,6 @@
} from 'ele-admin-pro/es/ele-pro-table/types';
import {
ExclamationCircleOutlined,
InfoCircleOutlined
} from '@ant-design/icons-vue';
import Search from './components/search.vue';
import {getPageTitle} from '@/utils/common';
@@ -562,52 +565,45 @@
title: '订单编号',
dataIndex: 'orderNo',
key: 'orderNo',
width: 200,
align: 'center'
width: 150
},
{
title: '用户信息',
title: '买家信息',
dataIndex: 'userId',
key: 'userInfo'
key: 'userInfo',
width: 150
},
{
title: '商品信息',
dataIndex: 'orderGoods',
key: 'orderGoods'
key: 'orderGoods',
width: 300,
},
{
title: '实付金额',
dataIndex: 'payPrice',
key: 'payPrice',
align: 'center',
width: 120,
customRender: ({text}) => '¥' + text
},
// {
// title: '支付方式',
// dataIndex: 'payType',
// key: 'payType',
// align: 'center',
// width: 120,
// },
{
title: '支付方式',
dataIndex: 'payType',
key: 'payType'
},
{
title: '状态',
dataIndex: 'orderStatus',
key: 'statusInfo',
align: 'center'
},
// {
// title: '备注',
// dataIndex: 'comments',
// key: 'comments',
// align: 'center',
// },
{
title: '创建时间',
dataIndex: 'createTime',
key: 'createTime',
width: 180,
align: 'center',
sorter: true,
customRender: ({text}) => toDateString(text)
},
@@ -663,7 +659,8 @@
updateUser({
userId: record.userId,
realName: record.realName
}).then(() => {});
}).then(() => {
});
}
reload();
});

View File

@@ -2,7 +2,7 @@
<a-page-header :title="getPageTitle()" @back="() => $router.go(-1)">
<!-- 高级筛选 -->
<a-form layout="inline" class="ele-form-inline" style="margin-bottom: 16px">
<a-form-item label="角色">
<a-form-item>
<a-select
v-model:value="searchWhere.roleId"
placeholder="全部角色"
@@ -17,7 +17,7 @@
>
</a-select>
</a-form-item>
<a-form-item label="注册来源">
<a-form-item>
<a-select
v-model:value="searchWhere.platform"
placeholder="全部来源"
@@ -29,7 +29,7 @@
<a-select-option value="WEB">Web</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="类型">
<a-form-item>
<a-select
v-model:value="searchWhere.isAdmin"
placeholder="全部"