From 2464bf8e8f9d4d1bdc6453ead82937d82557ec79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=83=E8=B4=A7?= <252048765@qq.com> Date: Mon, 7 Jul 2025 08:24:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=95=86=E5=93=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=92=8C=E8=A1=A8=E5=8D=95=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E7=A7=BB=E9=99=A4=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-ele/src/utils/index.ts | 1 - .../views/mall/product/spu/modules/detail.vue | 500 +++++++++++++++++- .../views/mall/product/spu/modules/form.vue | 30 +- 3 files changed, 506 insertions(+), 25 deletions(-) diff --git a/apps/web-ele/src/utils/index.ts b/apps/web-ele/src/utils/index.ts index f07b644b..162976e7 100644 --- a/apps/web-ele/src/utils/index.ts +++ b/apps/web-ele/src/utils/index.ts @@ -6,6 +6,5 @@ export * from './rangePickerProps'; export * from './routerHelper'; export * from './validator'; export * from './tree'; -export * from './formatNum'; export * from './is'; export * from './bean'; diff --git a/apps/web-ele/src/views/mall/product/spu/modules/detail.vue b/apps/web-ele/src/views/mall/product/spu/modules/detail.vue index c28ebc68..147f1566 100644 --- a/apps/web-ele/src/views/mall/product/spu/modules/detail.vue +++ b/apps/web-ele/src/views/mall/product/spu/modules/detail.vue @@ -1,3 +1,499 @@ - + + + + + + 商品详情 + + + + + + + 编辑商品 + + + + 返回列表 + + + + + + + + + {{ formData.name }} + + {{ formData.introduction || '暂无简介' }} + + + 多规格 + 单规格 + 分销 + 库存: + {{ + formData.skus?.reduce( + (sum, sku) => sum + (sku.stock || 0), + 0, + ) || 0 + }} + 分类: {{ getCategoryNameById(formData.categoryId) }} + + + + + + + + + + + {{ + formData.name + }} + + {{ + getCategoryNameById(formData.categoryId) + }} + + + {{ + getBrandNameById(formData.brandId) + }} + + + {{ formData.keyword || '无' }} + {{ + formData.giveIntegral + }} + {{ + formData.virtualSalesCount + }} + {{ + formData.sort + }} + + + {{ formData.specType ? '多规格' : '单规格' }} + + + + + {{ formData.subCommissionType ? '单独设置' : '默认设置' }} + + + + + + + + + + + + {{ getDeliveryTypeName(type) }} + + + 暂无配送方式 + + + + {{ + formData.deliveryTemplateId || '未设置' + }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 价格信息 + + + 销售价: + + ¥{{ sku.price }} + + 市场价: + ¥{{ sku.marketPrice }} + 成本价: + ¥{{ sku.costPrice }} + + + + + + + 库存信息 + + + 库存: + {{ sku.stock }} 件 + 条码: + {{ sku.barCode || '未设置' }} + + + + + + + 物流信息 + + + 重量: + {{ sku.weight }} kg + 体积: + {{ sku.volume }} m³ + + + + + + + + + 分销佣金 + + + 一级佣金: + ¥{{ sku.firstBrokeragePrice }} + 二级佣金: + ¥{{ sku.secondBrokeragePrice }} + + + + + + 规格属性 + + + {{ prop.propertyName }}: {{ prop.valueName }} + + + + + + + + + + + + + + + + + + + + + + + diff --git a/apps/web-ele/src/views/mall/product/spu/modules/form.vue b/apps/web-ele/src/views/mall/product/spu/modules/form.vue index 9df12176..a1619905 100644 --- a/apps/web-ele/src/views/mall/product/spu/modules/form.vue +++ b/apps/web-ele/src/views/mall/product/spu/modules/form.vue @@ -4,7 +4,7 @@ import { onMounted, ref, unref } from 'vue'; import { cloneDeep } from '@vben/utils'; import type { MallSpuApi } from '#/api/mall/product/spu'; import { useRouter, useRoute } from 'vue-router'; -import { floatToFixed2, formatToFraction, convertToInteger } from '@vben/utils'; +import { formatToFraction, convertToInteger } from '@vben/utils'; import * as ProductSpuApi from '#/api/mall/product/spu'; import { ElMessage } from 'element-plus'; @@ -51,36 +51,22 @@ const formData = ref({ }); const formLoading = ref(false); // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 -const isDetail = ref(false); // 是否查看详情 const { push } = useRouter(); // 路由 -const { params, name } = useRoute(); // 查询参数 +const { params } = useRoute(); // 查询参数 /** 获得详情 */ const getDetail = async () => { - if ('ProductSpuDetail' === name) { - isDetail.value = true; - } const id = params.id as unknown as number; if (id) { formLoading.value = true; try { const res = (await ProductSpuApi.getSpu(id)) as MallSpuApi.Spu; res.skus?.forEach((item: MallSpuApi.Sku) => { - if (isDetail.value) { - item.price = floatToFixed2(item.price); - item.marketPrice = floatToFixed2(item.marketPrice); - item.costPrice = floatToFixed2(item.costPrice); - item.firstBrokeragePrice = floatToFixed2(item.firstBrokeragePrice); - item.secondBrokeragePrice = floatToFixed2(item.secondBrokeragePrice); - } else { - // 回显价格分转元 - item.price = formatToFraction(item.price); - item.marketPrice = formatToFraction(item.marketPrice); - item.costPrice = formatToFraction(item.costPrice); - item.firstBrokeragePrice = formatToFraction(item.firstBrokeragePrice); - item.secondBrokeragePrice = formatToFraction( - item.secondBrokeragePrice, - ); - } + // 回显价格分转元 + item.price = formatToFraction(item.price); + item.marketPrice = formatToFraction(item.marketPrice); + item.costPrice = formatToFraction(item.costPrice); + item.firstBrokeragePrice = formatToFraction(item.firstBrokeragePrice); + item.secondBrokeragePrice = formatToFraction(item.secondBrokeragePrice); }); formData.value = res; } finally {