diff --git a/src/api/mall/product/comment.ts b/src/api/mall/product/comment.ts
new file mode 100644
index 00000000..defdbb93
--- /dev/null
+++ b/src/api/mall/product/comment.ts
@@ -0,0 +1,49 @@
+import request from '@/config/axios'
+
+export interface CommentVO {
+ id: number
+ userId: number
+ userNickname: string
+ userAvatar: string
+ anonymous: boolean
+ orderId: number
+ orderItemId: number
+ spuId: number
+ spuName: string
+ skuId: number
+ visible: boolean
+ scores: number
+ descriptionScores: number
+ benefitScores: number
+ content: string
+ picUrls: string
+ replyStatus: boolean
+ replyUserId: number
+ replyContent: string
+ replyTime: Date
+}
+
+// 查询商品评论列表
+export const getCommentPage = async (params) => {
+ return await request.get({ url: `/product/comment/page`, params })
+}
+
+// 查询商品评论详情
+export const getComment = async (id: number) => {
+ return await request.get({ url: `/product/comment/get?id=` + id })
+}
+
+// 添加自评
+export const createComment = async (data: CommentVO) => {
+ return await request.post({ url: `/product/comment/create`, data })
+}
+
+// 显示 / 隐藏评论
+export const updateCommentVisible = async (data: any) => {
+ return await request.put({ url: `/product/comment/update-visible`, data })
+}
+
+// 商家回复
+export const replyComment = async (data: any) => {
+ return await request.put({ url: `/product/comment/reply`, data })
+}
diff --git a/src/api/mall/product/spu.ts b/src/api/mall/product/spu.ts
index 0ea324b8..2ad9bc60 100644
--- a/src/api/mall/product/spu.ts
+++ b/src/api/mall/product/spu.ts
@@ -9,18 +9,19 @@ export interface Property {
export interface Sku {
id?: number // 商品 SKU 编号
+ name?: string // 商品 SKU 名称
spuId?: number // SPU 编号
properties?: Property[] // 属性数组
- price?: number // 商品价格
- marketPrice?: number // 市场价
- costPrice?: number // 成本价
+ price?: number | string // 商品价格
+ marketPrice?: number | string // 市场价
+ costPrice?: number | string // 成本价
barCode?: string // 商品条码
picUrl?: string // 图片地址
stock?: number // 库存
weight?: number // 商品重量,单位:kg 千克
volume?: number // 商品体积,单位:m^3 平米
- subCommissionFirstPrice?: number // 一级分销的佣金
- subCommissionSecondPrice?: number // 二级分销的佣金
+ subCommissionFirstPrice?: number | string // 一级分销的佣金
+ subCommissionSecondPrice?: number | string // 二级分销的佣金
salesCount?: number // 商品销量
}
diff --git a/src/api/mall/trade/order/index.ts b/src/api/mall/trade/order/index.ts
index e99b1338..9413b73c 100644
--- a/src/api/mall/trade/order/index.ts
+++ b/src/api/mall/trade/order/index.ts
@@ -102,20 +102,20 @@ export interface DeliveryVO {
// 订单发货
export const delivery = async (data: DeliveryVO) => {
- return await request.post({ url: `/trade/order/delivery`, data })
+ return await request.put({ url: `/trade/order/delivery`, data })
}
// 订单备注
-export const remark = async (data) => {
- return await request.post({ url: `/trade/order/remark`, data })
+export const updateRemark = async (data: any) => {
+ return await request.put({ url: `/trade/order/update-remark`, data })
}
// 订单调价
-export const adjustPrice = async (data) => {
- return await request.post({ url: `/trade/order/adjust-price`, data })
+export const updatePrice = async (data: any) => {
+ return await request.put({ url: `/trade/order/update-price`, data })
}
// 修改订单地址
-export const adjustAddress = async (data) => {
- return await request.post({ url: `/trade/order/adjust-address`, data })
+export const updateAddress = async (data: any) => {
+ return await request.put({ url: `/trade/order/update-address`, data })
}
diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts
index 40909f4a..87ffd1e5 100644
--- a/src/router/modules/remaining.ts
+++ b/src/router/modules/remaining.ts
@@ -346,22 +346,6 @@ const remainingRouter: AppRouteRecordRaw[] = [
}
]
},
- {
- path: '/property', // TODO @puhui999:这里的 path 有问题,应该是 /product/property
- component: Layout,
- name: 'Property',
- meta: {
- hidden: true
- },
- children: [
- {
- path: 'value/:propertyId(\\d+)',
- component: () => import('@/views/mall/product/property/value/index.vue'),
- name: 'ProductPropertyValue',
- meta: { title: '商品属性值', icon: '', activeMenu: '/product/property' }
- }
- ]
- },
{
path: '/product',
component: Layout,
@@ -408,6 +392,19 @@ const remainingRouter: AppRouteRecordRaw[] = [
title: '商品详情',
activeMenu: '/product/product-spu'
}
+ },
+ {
+ path: 'property/value/:propertyId(\\d+)',
+ component: () => import('@/views/mall/product/property/value/index.vue'),
+ name: 'ProductPropertyValue',
+ meta: {
+ noCache: true,
+ hidden: true,
+ canTo: true,
+ icon: 'ep:view',
+ title: '商品属性值',
+ activeMenu: '/product/property'
+ }
}
]
},
@@ -421,7 +418,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
children: [
{
path: 'detail/:orderId(\\d+)',
- component: () => import('@/views/mall/trade/order/components/OrderDetailForm.vue'),
+ component: () => import('@/views/mall/trade/order/detail/index.vue'),
name: 'TradeOrderDetailForm',
meta: { title: '订单详情', icon: '', activeMenu: '/trade/trade/order' }
}
diff --git a/src/utils/dict.ts b/src/utils/dict.ts
index 9ec2e994..6b163628 100644
--- a/src/utils/dict.ts
+++ b/src/utils/dict.ts
@@ -131,7 +131,7 @@ export enum DICT_TYPE {
BPM_OA_LEAVE_TYPE = 'bpm_oa_leave_type',
// ========== PAY 模块 ==========
- PAY_CHANNEL_CODE = 'pay_channel_code', // 支付渠道编码类型
+ PAY_CHANNEL_CODE = 'pay_channel_code_type', // 支付渠道编码类型
PAY_ORDER_STATUS = 'pay_order_status', // 商户支付订单状态
PAY_REFUND_STATUS = 'pay_refund_status', // 退款订单状态
PAY_NOTIFY_STATUS = 'pay_notify_status', // 商户支付回调状态
diff --git a/src/utils/index.ts b/src/utils/index.ts
index 3d596a36..c73b8d2f 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -174,7 +174,6 @@ export const copyValueToTarget = (target, source) => {
Object.assign(target, newObj)
}
-// TODO @puhui999:返回要带上 .00 哈.例如说 1.00
/**
* 将一个整数转换为分数保留两位小数
* @param num
@@ -185,6 +184,31 @@ export const formatToFraction = (num: number | string | undefined): number => {
return parseFloat((parsedNumber / 100).toFixed(2))
}
+/**
+ * 将一个数转换为 1.00 这样
+ * 数据呈现的时候使用
+ *
+ * @param num 整数
+ */
+export const floatToFixed2 = (num: number | string | undefined): string => {
+ let str = '0.00'
+ if (typeof num === 'undefined') {
+ return str
+ }
+ const f = formatToFraction(num)
+ const decimalPart = f.toString().split('.')[1]
+ const len = decimalPart ? decimalPart.length : 0
+ switch (len) {
+ case 0:
+ str = f.toString() + '.00'
+ break
+ case 1:
+ str = f.toString() + '0'
+ break
+ }
+ return str
+}
+
/**
* 将一个分数转换为整数
* @param num
diff --git a/src/views/mall/product/comment/CommentForm.vue b/src/views/mall/product/comment/CommentForm.vue
new file mode 100644
index 00000000..f4180f45
--- /dev/null
+++ b/src/views/mall/product/comment/CommentForm.vue
@@ -0,0 +1,199 @@
+
+
+
+
+
+
+
diff --git a/src/views/mall/product/comment/components/SkuTableSelect.vue b/src/views/mall/product/comment/components/SkuTableSelect.vue
new file mode 100644
index 00000000..f72870e4
--- /dev/null
+++ b/src/views/mall/product/comment/components/SkuTableSelect.vue
@@ -0,0 +1,95 @@
+
+
+
+
+
diff --git a/src/views/mall/product/comment/components/SpuTableSelect.vue b/src/views/mall/product/comment/components/SpuTableSelect.vue
new file mode 100644
index 00000000..2a62a2fa
--- /dev/null
+++ b/src/views/mall/product/comment/components/SpuTableSelect.vue
@@ -0,0 +1,168 @@
+
+
+
+
+
diff --git a/src/views/mall/product/comment/index.vue b/src/views/mall/product/comment/index.vue
new file mode 100644
index 00000000..7647aff1
--- /dev/null
+++ b/src/views/mall/product/comment/index.vue
@@ -0,0 +1,299 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+
+
+
+ 重置
+
+
+
+ 添加虚拟评论
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{{ scope.row.spuName }}
+
+
+
+
+
+
+
+
+ {{ scope.row.content }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 回复
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/mall/product/property/index.vue b/src/views/mall/product/property/index.vue
index dc79450b..042bc980 100644
--- a/src/views/mall/product/property/index.vue
+++ b/src/views/mall/product/property/index.vue
@@ -101,6 +101,7 @@
import { dateFormatter } from '@/utils/formatTime'
import * as PropertyApi from '@/api/mall/product/property'
import PropertyForm from './PropertyForm.vue'
+
const { push } = useRouter()
defineOptions({ name: 'ProductProperty' })
@@ -164,7 +165,7 @@ const handleDelete = async (id: number) => {
/** 跳转商品属性列表 */
const goValueList = (id: number) => {
- push({ path: '/property/value/' + id })
+ push({ path: '/product/property/value/' + id })
}
/** 初始化 **/
diff --git a/src/views/mall/product/spu/addForm.vue b/src/views/mall/product/spu/addForm.vue
index b577ece9..910bad4a 100644
--- a/src/views/mall/product/spu/addForm.vue
+++ b/src/views/mall/product/spu/addForm.vue
@@ -42,7 +42,9 @@ import { useTagsViewStore } from '@/store/modules/tagsView'
import { BasicInfoForm, DescriptionForm, OtherSettingsForm } from './components'
// 业务api
import * as ProductSpuApi from '@/api/mall/product/spu'
-import { convertToInteger, formatToFraction } from '@/utils'
+import { convertToInteger, floatToFixed2, formatToFraction } from '@/utils'
+
+// TODO @芋艿:后续稍微调整下;
defineOptions({ name: 'ProductSpuForm' })
@@ -107,12 +109,20 @@ const getDetail = async () => {
try {
const res = (await ProductSpuApi.getSpu(id)) as ProductSpuApi.Spu
res.skus?.forEach((item) => {
- // 回显价格分转元
- item.price = formatToFraction(item.price)
- item.marketPrice = formatToFraction(item.marketPrice)
- item.costPrice = formatToFraction(item.costPrice)
- item.subCommissionFirstPrice = formatToFraction(item.subCommissionFirstPrice)
- item.subCommissionSecondPrice = formatToFraction(item.subCommissionSecondPrice)
+ if (isDetail.value === true) {
+ item.price = floatToFixed2(item.price)
+ item.marketPrice = floatToFixed2(item.marketPrice)
+ item.costPrice = floatToFixed2(item.costPrice)
+ item.subCommissionFirstPrice = floatToFixed2(item.subCommissionFirstPrice)
+ item.subCommissionSecondPrice = floatToFixed2(item.subCommissionSecondPrice)
+ } else {
+ // 回显价格分转元
+ item.price = formatToFraction(item.price)
+ item.marketPrice = formatToFraction(item.marketPrice)
+ item.costPrice = formatToFraction(item.costPrice)
+ item.subCommissionFirstPrice = formatToFraction(item.subCommissionFirstPrice)
+ item.subCommissionSecondPrice = formatToFraction(item.subCommissionSecondPrice)
+ }
})
formData.value = res
} finally {
@@ -132,19 +142,19 @@ const submitForm = async () => {
await unref(descriptionRef)?.validate()
await unref(otherSettingsRef)?.validate()
// 深拷贝一份, 这样最终 server 端不满足,不需要恢复,
- const deepCopyFormData = cloneDeep(unref(formData.value))
+ const deepCopyFormData = cloneDeep(unref(formData.value)) as ProductSpuApi.Spu
// 兜底处理 sku 空数据
formData.value.skus!.forEach((sku) => {
// 因为是空数据这里判断一下商品条码是否为空就行
if (sku.barCode === '') {
- const index = deepCopyFormData.skus.findIndex(
+ const index = deepCopyFormData.skus!.findIndex(
(item) => JSON.stringify(item.properties) === JSON.stringify(sku.properties)
)
// 删除这条 sku
- deepCopyFormData.skus.splice(index, 1)
+ deepCopyFormData.skus!.splice(index, 1)
}
})
- deepCopyFormData.skus.forEach((item) => {
+ deepCopyFormData.skus!.forEach((item) => {
// 给sku name赋值
item.name = deepCopyFormData.name
// sku相关价格元转分
@@ -156,7 +166,7 @@ const submitForm = async () => {
})
// 处理轮播图列表
const newSliderPicUrls: any[] = []
- deepCopyFormData.sliderPicUrls.forEach((item: any) => {
+ deepCopyFormData.sliderPicUrls!.forEach((item: any) => {
// 如果是前端选的图
typeof item === 'object' ? newSliderPicUrls.push(item.url) : newSliderPicUrls.push(item)
})
diff --git a/src/views/mall/product/spu/components/index.ts b/src/views/mall/product/spu/components/index.ts
index 1160dbd1..405dfde5 100644
--- a/src/views/mall/product/spu/components/index.ts
+++ b/src/views/mall/product/spu/components/index.ts
@@ -7,7 +7,6 @@ import SkuList from './SkuList.vue'
import { Spu } from '@/api/mall/product/spu'
-// TODO @puhui999:Properties 改成 Property 更合适?Property 在 Spu 中已存在避免冲突 PropertyAndValues
interface PropertyAndValues {
id: number
name: string
diff --git a/src/views/mall/product/spu/index.vue b/src/views/mall/product/spu/index.vue
index 75bd02e0..9ea06cd5 100644
--- a/src/views/mall/product/spu/index.vue
+++ b/src/views/mall/product/spu/index.vue
@@ -80,7 +80,7 @@
-
+
@@ -91,12 +91,12 @@
- {{ formatToFraction(row.marketPrice) }}
+ {{ floatToFixed2(row.marketPrice) }}元
- {{ formatToFraction(row.costPrice) }}
+ {{ floatToFixed2(row.costPrice) }}元
@@ -130,9 +130,7 @@
-
- {{ formatToFraction(row.price) }}
-
+ {{ floatToFixed2(row.price) }}元
@@ -229,7 +227,7 @@ import { createImageViewer } from '@/components/ImageViewer'
import { dateFormatter } from '@/utils/formatTime'
import { checkSelectedNode, defaultProps, handleTree, treeToString } from '@/utils/tree'
import { ProductSpuStatusEnum } from '@/utils/constants'
-import { formatToFraction } from '@/utils'
+import { floatToFixed2 } from '@/utils'
import download from '@/utils/download'
import * as ProductSpuApi from '@/api/mall/product/spu'
import * as ProductCategoryApi from '@/api/mall/product/category'
@@ -392,7 +390,7 @@ const resetQuery = () => {
const openForm = (id?: number) => {
// 修改
if (typeof id === 'number') {
- push('/product/spu/edit/' + id)
+ push({ name: 'ProductSpuEdit', params: { spuId: id } })
return
}
// 新增
@@ -402,8 +400,8 @@ const openForm = (id?: number) => {
/**
* 查看商品详情
*/
-const openDetail = (id?: number) => {
- push('/product/spu/detail/' + id)
+const openDetail = (id: number) => {
+ push({ name: 'ProductSpuDetail', params: { spuId: id } })
}
/** 导出按钮操作 */
@@ -458,7 +456,7 @@ onMounted(async () => {
})
diff --git a/src/views/mall/trade/order/components/DeliveryOrderForm.vue b/src/views/mall/trade/order/components/OrderDeliveryForm.vue
similarity index 76%
rename from src/views/mall/trade/order/components/DeliveryOrderForm.vue
rename to src/views/mall/trade/order/components/OrderDeliveryForm.vue
index b061341f..6d4a07c4 100644
--- a/src/views/mall/trade/order/components/DeliveryOrderForm.vue
+++ b/src/views/mall/trade/order/components/OrderDeliveryForm.vue
@@ -2,12 +2,12 @@