From 3a9668d63268576906d8f041cfc78fe42e3ba76b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 1 Oct 2023 19:44:13 +0800 Subject: [PATCH] =?UTF-8?q?product=EF=BC=9A=E4=BC=98=E5=8C=96=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=97=E8=A1=A8=E7=9A=84=E6=A0=B7=E5=BC=8F=E3=80=81?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/modules/remaining.ts | 16 ++- src/utils/index.ts | 5 +- src/utils/tree.ts | 7 +- src/views/mall/product/spu/form/index.vue | 2 +- src/views/mall/product/spu/index.vue | 134 +++++++++------------- 5 files changed, 68 insertions(+), 96 deletions(-) diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index c6c95e80..50283e23 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -331,9 +331,8 @@ const remainingRouter: AppRouteRecordRaw[] = [ ] }, { - path: '/product', + path: '/mall/product', // 商品中心 component: Layout, - name: 'Product', meta: { hidden: true }, @@ -348,11 +347,11 @@ const remainingRouter: AppRouteRecordRaw[] = [ canTo: true, icon: 'ep:edit', title: '添加商品', - activeMenu: '/product/product-spu' + activeMenu: '/mall/product/spu' } }, { - path: 'spu/edit/:spuId(\\d+)', + path: 'spu/edit/:id(\\d+)', component: () => import('@/views/mall/product/spu/form/index.vue'), name: 'ProductSpuEdit', meta: { @@ -361,11 +360,11 @@ const remainingRouter: AppRouteRecordRaw[] = [ canTo: true, icon: 'ep:edit', title: '编辑商品', - activeMenu: '/product/product-spu' + activeMenu: '/mall/product/spu' } }, { - path: 'spu/detail/:spuId(\\d+)', + path: 'spu/detail/:id(\\d+)', component: () => import('@/views/mall/product/spu/form/index.vue'), name: 'ProductSpuDetail', meta: { @@ -374,7 +373,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ canTo: true, icon: 'ep:view', title: '商品详情', - activeMenu: '/product/product-spu' + activeMenu: '/mall/product/spu' } }, { @@ -393,9 +392,8 @@ const remainingRouter: AppRouteRecordRaw[] = [ ] }, { - path: '/trade', + path: '/trade', // 交易中心 component: Layout, - name: 'Order', meta: { hidden: true }, diff --git a/src/utils/index.ts b/src/utils/index.ts index c73b8d2f..c63f899a 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -230,6 +230,7 @@ export const yuanToFen = (amount: string | number): number => { /** * 分转元 */ -export const fenToYuan = (amount: string | number): number => { - return Number((Number(amount) / 100).toFixed(2)) +export const fenToYuan = (price: string | number): number => { + price = Number(price) + return (price / 100.0).toFixed(2) } diff --git a/src/utils/tree.ts b/src/utils/tree.ts index c8503f54..91059ef9 100644 --- a/src/utils/tree.ts +++ b/src/utils/tree.ts @@ -13,7 +13,8 @@ export const defaultProps = { children: 'children', label: 'name', value: 'id', - isLeaf: 'leaf' + isLeaf: 'leaf', + emitPath: false // 用于 cascader 组件:在选中节点改变时,是否返回由该节点所在的各级菜单的值所组成的数组,若设置 false,则只返回该节点的值 } const getConfig = (config: Partial) => Object.assign({}, DEFAULT_CONFIG, config) @@ -377,10 +378,10 @@ export const treeToString = (tree: any[], nodeId) => { function performAThoroughValidation(arr) { for (const item of arr) { if (item.id === nodeId) { - str += `/${item.name}` + str += ` / ${item.name}` return true } else if (typeof item.children !== 'undefined' && item.children.length !== 0) { - str += `/${item.name}` + str += ` / ${item.name}` if (performAThoroughValidation(item.children)) { return true } diff --git a/src/views/mall/product/spu/form/index.vue b/src/views/mall/product/spu/form/index.vue index e6364f5d..b55dd31f 100644 --- a/src/views/mall/product/spu/form/index.vue +++ b/src/views/mall/product/spu/form/index.vue @@ -102,7 +102,7 @@ const getDetail = async () => { if ('ProductSpuDetail' === name) { isDetail.value = true } - const id = params.spuId as unknown as number + const id = params.id as unknown as number if (id) { formLoading.value = true try { diff --git a/src/views/mall/product/spu/index.vue b/src/views/mall/product/spu/index.vue index 1596df3f..6fc14ca3 100644 --- a/src/views/mall/product/spu/index.vue +++ b/src/views/mall/product/spu/index.vue @@ -18,15 +18,14 @@ /> - @@ -78,7 +77,7 @@ /> - + - +