refactor(dashboard): 重构基本信息面板数据源及运行天数计算
- 统一从 app_product.product_id=65 和 app_subscription 获取面板数据,替代原硬编码和 tenant/siteStore - 字段映射调整,软件名称、版本号、运行状态、创建时间等均改用 product 与 subscription 字段 - 删除硬编码的 systemInfo reactive,移除不必要的 reactive 导入 - 新增 productStatusText 计算属性,对 publishStatus 状态做文字和颜色映射 - 重写运行天数计算,改用订阅生效时间 startTime,修正续费重置计数的边界响应 - 模板绑定全部字段,增加骨架屏 loading 状态,避免界面闪烁 - 添加「系统运行」字段提示信息,明确起算时间语义 - 保持 loadSubscriptionInfo 调用 getProductDetail,无新增接口请求 - 确保 vue-tsc 类型校验无新增错误
This commit is contained in:
@@ -146,3 +146,23 @@
|
|||||||
- form reactive 默认值新增 `paymentVoucher: undefined`,对齐 `ShopOrder` model。
|
- form reactive 默认值新增 `paymentVoucher: undefined`,对齐 `ShopOrder` model。
|
||||||
- `ShopOrder` model 中 `paymentVoucher?: string` 字段早就存在(payTime 之后),无需改 model/API。
|
- `ShopOrder` model 中 `paymentVoucher?: string` 字段早就存在(payTime 之后),无需改 model/API。
|
||||||
- 用户场景:仅线下付款(payType=9)的订单才有此凭证图,条件渲染自然处理。
|
- 用户场景:仅线下付款(payType=9)的订单才有此凭证图,条件渲染自然处理。
|
||||||
|
|
||||||
|
## Dashboard 基本信息 6 字段数据源重构(product + subscription)
|
||||||
|
|
||||||
|
- 需求:dashboard「基本信息」面板原先混用硬编码/tenant/siteStore,改为统一从 `app_product.product_id=65` + `app_subscription` 读取,语义更准确。
|
||||||
|
- 字段映射决策(用户确认):
|
||||||
|
- 系统名称 → `currentProduct.productName`(原硬编码 '小程序商城')
|
||||||
|
- 版本号 → `currentProduct.version`(原硬编码 '2.0.0')
|
||||||
|
- 运行状态 → `currentProduct.publishStatus` + 中文映射 + a-tag 颜色(原 `siteStore.statusText`)
|
||||||
|
- 创建时间 → `currentSubscription.startTime`(原 `tenantStore.company?.createTime`)
|
||||||
|
- 到期时间 → `currentSubscription.expireTime`(保持不变,原本就是这个)
|
||||||
|
- 系统运行天数 → 自 `currentSubscription.startTime` 起累计(原自 `tenantStore.company?.createTime`;后改为 startTime,与"创建时间"行同源,语义统一)
|
||||||
|
- 改动 `src/views/shop/dashboard/index.vue`:
|
||||||
|
- 删除硬编码 `systemInfo` reactive(已确认 cms 那两个 systemInfo 是独立 const,互不影响)。
|
||||||
|
- import 移除 `reactive`。
|
||||||
|
- 新增 `productStatusText` computed:publishStatus → {text,color} 映射(published=已发布/green、pending_review=审核中/orange、developing=开发中/blue、rejected=已驳回/red、deprecated=已下架/red),未知状态显示原始值,无 product 显示 '-'。
|
||||||
|
- 重写 `runDays` computed:数据源由 `tenantStore.company?.createTime` 改为 `currentSubscription.value?.startTime`(与"创建时间"行同源),注释说明续费新增订阅记录会重置计数的边界行为。
|
||||||
|
- 模板 6 个字段全部重绑,每个字段加 `subscriptionLoading` 骨架屏分支(避免空白/老数据闪现)。
|
||||||
|
- 「系统运行」加 `a-tooltip title="自您首次开通小程序商城起"`(用户要求)。
|
||||||
|
- 数据流复用:`loadSubscriptionInfo()` 原本就调 `getProductDetail(65)` 填充 `currentProduct`,无需新增接口调用。
|
||||||
|
- 类型校验:vue-tsc 对 `shop/dashboard/index.vue` 行级错误 0 条;cms 那批历史错误与本次无关。
|
||||||
|
|||||||
@@ -158,7 +158,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="padding: 16px 18px;">
|
<div style="padding: 16px 18px;">
|
||||||
<a-descriptions :column="1" size="small">
|
<a-descriptions :column="1" size="small">
|
||||||
<a-descriptions-item label="系统名称">
|
<a-descriptions-item label="软件名称">
|
||||||
<template v-if="subscriptionLoading">
|
<template v-if="subscriptionLoading">
|
||||||
<a-skeleton-input :active="true" size="small" style="width: 160px" />
|
<a-skeleton-input :active="true" size="small" style="width: 160px" />
|
||||||
</template>
|
</template>
|
||||||
@@ -620,14 +620,15 @@ const onPayModalClose = () => {
|
|||||||
// 计算属性
|
// 计算属性
|
||||||
const now = ref(Date.now());
|
const now = ref(Date.now());
|
||||||
let runDaysTimer: ReturnType<typeof setInterval>;
|
let runDaysTimer: ReturnType<typeof setInterval>;
|
||||||
// 系统运行天数:自首次开通订阅起累计
|
// 系统运行天数:自订阅生效时间起累计
|
||||||
|
// 锚定 currentSubscription.startTime(与"创建时间"行同源,语义统一)。
|
||||||
// 注意:若后端续费为新增订阅记录,此处取的是 expireTime 最新的 active 订阅,
|
// 注意:若后端续费为新增订阅记录,此处取的是 expireTime 最新的 active 订阅,
|
||||||
// createTime 可能是该续费订单的创建时间,runDays 会从续费日重新计数。
|
// startTime 可能是续费生效日,runDays 会从续费日重新计数。
|
||||||
// 如需"累计运行天数",应改用最早的 active 订阅 createTime 或后端额外提供字段。
|
// 如需"累计运行天数",应改用最早的 active 订阅 startTime 或后端额外提供字段。
|
||||||
const runDays = computed(() => {
|
const runDays = computed(() => {
|
||||||
const createTime = currentSubscription.value?.createTime;
|
const startTime = currentSubscription.value?.startTime;
|
||||||
if (!createTime) return 0;
|
if (!startTime) return 0;
|
||||||
return Math.floor((now.value - new Date(createTime).getTime()) / (24 * 60 * 60 * 1000));
|
return Math.floor((now.value - new Date(startTime).getTime()) / (24 * 60 * 60 * 1000));
|
||||||
});
|
});
|
||||||
const userCount = computed(() => statisticsStore.userCount);
|
const userCount = computed(() => statisticsStore.userCount);
|
||||||
const orderCount = computed(() => statisticsStore.orderCount);
|
const orderCount = computed(() => statisticsStore.orderCount);
|
||||||
|
|||||||
Reference in New Issue
Block a user