完善 code review 提到的问题

(cherry picked from commit 7db6c121bb)
This commit is contained in:
puhui999 2023-08-23 15:04:46 +08:00 committed by shizhong
parent 295d04e1f3
commit 9d9ccaa1b8
16 changed files with 184 additions and 189 deletions

View File

@ -9,18 +9,19 @@ export interface Property {
export interface Sku { export interface Sku {
id?: number // 商品 SKU 编号 id?: number // 商品 SKU 编号
name?: string // 商品 SKU 名称
spuId?: number // SPU 编号 spuId?: number // SPU 编号
properties?: Property[] // 属性数组 properties?: Property[] // 属性数组
price?: number // 商品价格 price?: number | string // 商品价格
marketPrice?: number // 市场价 marketPrice?: number | string // 市场价
costPrice?: number // 成本价 costPrice?: number | string // 成本价
barCode?: string // 商品条码 barCode?: string // 商品条码
picUrl?: string // 图片地址 picUrl?: string // 图片地址
stock?: number // 库存 stock?: number // 库存
weight?: number // 商品重量单位kg 千克 weight?: number // 商品重量单位kg 千克
volume?: number // 商品体积单位m^3 平米 volume?: number // 商品体积单位m^3 平米
subCommissionFirstPrice?: number // 一级分销的佣金 subCommissionFirstPrice?: number | string // 一级分销的佣金
subCommissionSecondPrice?: number // 二级分销的佣金 subCommissionSecondPrice?: number | string // 二级分销的佣金
salesCount?: number // 商品销量 salesCount?: number // 商品销量
} }

View File

@ -102,20 +102,20 @@ export interface DeliveryVO {
// 订单发货 // 订单发货
export const delivery = async (data: 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) => { export const updateRemark = async (data: any) => {
return await request.post({ url: `/trade/order/remark`, data }) return await request.put({ url: `/trade/order/update-remark`, data })
} }
// 订单调价 // 订单调价
export const adjustPrice = async (data) => { export const updatePrice = async (data: any) => {
return await request.post({ url: `/trade/order/adjust-price`, data }) return await request.put({ url: `/trade/order/update-price`, data })
} }
// 修改订单地址 // 修改订单地址
export const adjustAddress = async (data) => { export const updateAddress = async (data: any) => {
return await request.post({ url: `/trade/order/adjust-address`, data }) return await request.put({ url: `/trade/order/update-address`, data })
} }

View File

@ -347,7 +347,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
] ]
}, },
{ {
path: '/property', // TODO @puhui999这里的 path 有问题,应该是 /product/property path: '/product/property',
component: Layout, component: Layout,
name: 'Property', name: 'Property',
meta: { meta: {
@ -421,7 +421,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
children: [ children: [
{ {
path: 'detail/:orderId(\\d+)', path: 'detail/:orderId(\\d+)',
component: () => import('@/views/mall/trade/order/components/OrderDetailForm.vue'), component: () => import('@/views/mall/trade/order/detail/index.vue'),
name: 'TradeOrderDetailForm', name: 'TradeOrderDetailForm',
meta: { title: '订单详情', icon: '', activeMenu: '/trade/trade/order' } meta: { title: '订单详情', icon: '', activeMenu: '/trade/trade/order' }
} }

View File

@ -132,7 +132,7 @@ export enum DICT_TYPE {
BPM_OA_LEAVE_TYPE = 'bpm_oa_leave_type', BPM_OA_LEAVE_TYPE = 'bpm_oa_leave_type',
// ========== PAY 模块 ========== // ========== PAY 模块 ==========
PAY_CHANNEL_CODE = 'pay_channel_code', // 支付渠道编码类型 PAY_CHANNEL_CODE = 'pay_channel_code_type', // 支付渠道编码类型
PAY_ORDER_STATUS = 'pay_order_status', // 商户支付订单状态 PAY_ORDER_STATUS = 'pay_order_status', // 商户支付订单状态
PAY_REFUND_STATUS = 'pay_refund_status', // 退款订单状态 PAY_REFUND_STATUS = 'pay_refund_status', // 退款订单状态
PAY_NOTIFY_STATUS = 'pay_notify_status', // 商户支付回调状态 PAY_NOTIFY_STATUS = 'pay_notify_status', // 商户支付回调状态
@ -157,7 +157,7 @@ export enum DICT_TYPE {
TRADE_ORDER_TYPE = 'trade_order_type', // 订单 - 类型 TRADE_ORDER_TYPE = 'trade_order_type', // 订单 - 类型
TRADE_ORDER_STATUS = 'trade_order_status', // 订单 - 状态 TRADE_ORDER_STATUS = 'trade_order_status', // 订单 - 状态
TRADE_ORDER_ITEM_AFTER_SALE_STATUS = 'trade_order_item_after_sale_status', // 订单项 - 售后状态 TRADE_ORDER_ITEM_AFTER_SALE_STATUS = 'trade_order_item_after_sale_status', // 订单项 - 售后状态
TRADE_DELIVERY_TYPE = 'trade_delivery_type', // 配送方式 TRADE_DELIVERY_TYPE = 'delivery_type', // 配送方式
// ========== MALL - 营销模块 ========== // ========== MALL - 营销模块 ==========
PROMOTION_DISCOUNT_TYPE = 'promotion_discount_type', // 优惠类型 PROMOTION_DISCOUNT_TYPE = 'promotion_discount_type', // 优惠类型

View File

@ -174,7 +174,6 @@ export const copyValueToTarget = (target, source) => {
Object.assign(target, newObj) Object.assign(target, newObj)
} }
// TODO @puhui999返回要带上 .00 哈.例如说 1.00
/** /**
* *
* @param num * @param num
@ -185,6 +184,31 @@ export const formatToFraction = (num: number | string | undefined): number => {
return parseFloat((parsedNumber / 100).toFixed(2)) 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 * @param num

View File

@ -101,6 +101,7 @@
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import * as PropertyApi from '@/api/mall/product/property' import * as PropertyApi from '@/api/mall/product/property'
import PropertyForm from './PropertyForm.vue' import PropertyForm from './PropertyForm.vue'
const { push } = useRouter() const { push } = useRouter()
const message = useMessage() // const message = useMessage() //
@ -162,7 +163,7 @@ const handleDelete = async (id: number) => {
/** 跳转商品属性列表 */ /** 跳转商品属性列表 */
const goValueList = (id: number) => { const goValueList = (id: number) => {
push({ path: '/property/value/' + id }) push({ path: '/product/property/value/' + id })
} }
/** 初始化 **/ /** 初始化 **/

View File

@ -42,7 +42,7 @@ import { useTagsViewStore } from '@/store/modules/tagsView'
import { BasicInfoForm, DescriptionForm, OtherSettingsForm } from './components' import { BasicInfoForm, DescriptionForm, OtherSettingsForm } from './components'
// api // api
import * as ProductSpuApi from '@/api/mall/product/spu' import * as ProductSpuApi from '@/api/mall/product/spu'
import { convertToInteger, formatToFraction } from '@/utils' import { convertToInteger, floatToFixed2, formatToFraction } from '@/utils'
defineOptions({ name: 'ProductSpuForm' }) defineOptions({ name: 'ProductSpuForm' })
@ -107,12 +107,20 @@ const getDetail = async () => {
try { try {
const res = (await ProductSpuApi.getSpu(id)) as ProductSpuApi.Spu const res = (await ProductSpuApi.getSpu(id)) as ProductSpuApi.Spu
res.skus?.forEach((item) => { res.skus?.forEach((item) => {
// if (isDetail.value === true) {
item.price = formatToFraction(item.price) item.price = floatToFixed2(item.price)
item.marketPrice = formatToFraction(item.marketPrice) item.marketPrice = floatToFixed2(item.marketPrice)
item.costPrice = formatToFraction(item.costPrice) item.costPrice = floatToFixed2(item.costPrice)
item.subCommissionFirstPrice = formatToFraction(item.subCommissionFirstPrice) item.subCommissionFirstPrice = floatToFixed2(item.subCommissionFirstPrice)
item.subCommissionSecondPrice = formatToFraction(item.subCommissionSecondPrice) 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 formData.value = res
} finally { } finally {
@ -132,19 +140,19 @@ const submitForm = async () => {
await unref(descriptionRef)?.validate() await unref(descriptionRef)?.validate()
await unref(otherSettingsRef)?.validate() await unref(otherSettingsRef)?.validate()
// , server // , server
const deepCopyFormData = cloneDeep(unref(formData.value)) const deepCopyFormData = cloneDeep(unref(formData.value)) as ProductSpuApi.Spu
// sku // sku
formData.value.skus!.forEach((sku) => { formData.value.skus!.forEach((sku) => {
// //
if (sku.barCode === '') { if (sku.barCode === '') {
const index = deepCopyFormData.skus.findIndex( const index = deepCopyFormData.skus!.findIndex(
(item) => JSON.stringify(item.properties) === JSON.stringify(sku.properties) (item) => JSON.stringify(item.properties) === JSON.stringify(sku.properties)
) )
// sku // sku
deepCopyFormData.skus.splice(index, 1) deepCopyFormData.skus!.splice(index, 1)
} }
}) })
deepCopyFormData.skus.forEach((item) => { deepCopyFormData.skus!.forEach((item) => {
// sku name // sku name
item.name = deepCopyFormData.name item.name = deepCopyFormData.name
// sku // sku
@ -156,7 +164,7 @@ const submitForm = async () => {
}) })
// //
const newSliderPicUrls: any[] = [] const newSliderPicUrls: any[] = []
deepCopyFormData.sliderPicUrls.forEach((item: any) => { deepCopyFormData.sliderPicUrls!.forEach((item: any) => {
// //
typeof item === 'object' ? newSliderPicUrls.push(item.url) : newSliderPicUrls.push(item) typeof item === 'object' ? newSliderPicUrls.push(item.url) : newSliderPicUrls.push(item)
}) })

View File

@ -7,7 +7,6 @@ import SkuList from './SkuList.vue'
import { Spu } from '@/api/mall/product/spu' import { Spu } from '@/api/mall/product/spu'
// TODO @puhui999Properties 改成 Property 更合适Property 在 Spu 中已存在避免冲突 PropertyAndValues
interface PropertyAndValues { interface PropertyAndValues {
id: number id: number
name: string name: string

View File

@ -80,7 +80,7 @@
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column type="expand" width="30"> <el-table-column type="expand" width="30">
<template #default="{ row }"> <template #default="{ row }">
<el-form class="demo-table-expand" label-position="left"> <el-form class="spu-table-expand" label-position="left">
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-row> <el-row>
@ -91,12 +91,12 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="市场价:"> <el-form-item label="市场价:">
<span>{{ formatToFraction(row.marketPrice) }}</span> <span>{{ floatToFixed2(row.marketPrice) }}</span>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="成本价:"> <el-form-item label="成本价:">
<span>{{ formatToFraction(row.costPrice) }}</span> <span>{{ floatToFixed2(row.costPrice) }}</span>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -130,9 +130,7 @@
</el-table-column> </el-table-column>
<el-table-column :show-overflow-tooltip="true" label="商品名称" min-width="300" prop="name" /> <el-table-column :show-overflow-tooltip="true" label="商品名称" min-width="300" prop="name" />
<el-table-column align="center" label="商品售价" min-width="90" prop="price"> <el-table-column align="center" label="商品售价" min-width="90" prop="price">
<template #default="{ row }"> <template #default="{ row }"> {{ floatToFixed2(row.price) }}</template>
{{ formatToFraction(row.price) }}
</template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="销量" min-width="90" prop="salesCount" /> <el-table-column align="center" label="销量" min-width="90" prop="salesCount" />
<el-table-column align="center" label="库存" min-width="90" prop="stock" /> <el-table-column align="center" label="库存" min-width="90" prop="stock" />
@ -229,7 +227,7 @@ import { createImageViewer } from '@/components/ImageViewer'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import { checkSelectedNode, defaultProps, handleTree, treeToString } from '@/utils/tree' import { checkSelectedNode, defaultProps, handleTree, treeToString } from '@/utils/tree'
import { ProductSpuStatusEnum } from '@/utils/constants' import { ProductSpuStatusEnum } from '@/utils/constants'
import { formatToFraction } from '@/utils' import { floatToFixed2 } from '@/utils'
import download from '@/utils/download' import download from '@/utils/download'
import * as ProductSpuApi from '@/api/mall/product/spu' import * as ProductSpuApi from '@/api/mall/product/spu'
import * as ProductCategoryApi from '@/api/mall/product/category' import * as ProductCategoryApi from '@/api/mall/product/category'
@ -392,7 +390,7 @@ const resetQuery = () => {
const openForm = (id?: number) => { const openForm = (id?: number) => {
// //
if (typeof id === 'number') { if (typeof id === 'number') {
push('/product/spu/edit/' + id) push({ name: 'ProductSpuEdit', params: { spuId: id } })
return return
} }
// //
@ -402,8 +400,8 @@ const openForm = (id?: number) => {
/** /**
* 查看商品详情 * 查看商品详情
*/ */
const openDetail = (id?: number) => { const openDetail = (id: number) => {
push('/product/spu/detail/' + id) push({ name: 'ProductSpuDetail', params: { spuId: id } })
} }
/** 导出按钮操作 */ /** 导出按钮操作 */
@ -458,7 +456,7 @@ onMounted(async () => {
}) })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.demo-table-expand { .spu-table-expand {
padding-left: 42px; padding-left: 42px;
:deep(.el-form-item__label) { :deep(.el-form-item__label) {

View File

@ -193,16 +193,4 @@ const resetForm = async () => {
await nextTick() await nextTick()
formRef.value.getElFormRef().resetFields() formRef.value.getElFormRef().resetFields()
} }
// TODO @puhui999 css demo-table-expand
</script> </script>
<style lang="scss" scoped>
.demo-table-expand {
padding-left: 42px;
:deep(.el-form-item__label) {
width: 82px;
font-weight: bold;
color: #99a9bf;
}
}
</style>

View File

@ -2,12 +2,12 @@
<Dialog v-model="dialogVisible" title="订单发货" width="25%"> <Dialog v-model="dialogVisible" title="订单发货" width="25%">
<el-form ref="formRef" v-loading="formLoading" :model="formData" label-width="80px"> <el-form ref="formRef" v-loading="formLoading" :model="formData" label-width="80px">
<el-form-item label="发货方式"> <el-form-item label="发货方式">
<el-radio-group v-model="radio"> <el-radio-group v-model="expressType">
<el-radio border label="1">快递物流</el-radio> <el-radio border label="express">快递物流</el-radio>
<el-radio border label="2">无需发货</el-radio> <el-radio border label="none">无需发货</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<template v-if="radio === '1'"> <template v-if="expressType === 'express'">
<el-form-item label="物流公司"> <el-form-item label="物流公司">
<el-select v-model="formData.logisticsId" placeholder="请选择" style="width: 100%"> <el-select v-model="formData.logisticsId" placeholder="请选择" style="width: 100%">
<el-option <el-option
@ -32,16 +32,16 @@
<script lang="ts" setup> <script lang="ts" setup>
import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express' import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express'
import * as TradeOrderApi from '@/api/mall/trade/order' import * as TradeOrderApi from '@/api/mall/trade/order'
import { copyValueToTarget } from '@/utils'
// TODO @puhui999 OrderDeliveryForm defineOptions({ name: 'OrderDeliveryForm' })
defineOptions({ name: 'DeliveryOrderForm' })
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
const dialogVisible = ref(false) // const dialogVisible = ref(false) //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const radio = ref('1') // TODO @puhui999 radio expressType expressnone const expressType = ref('express') // expressnone
const formData = ref<TradeOrderApi.DeliveryVO>({ const formData = ref<TradeOrderApi.DeliveryVO>({
id: 0, // id: 0, //
logisticsId: null, // logisticsId: null, //
@ -49,12 +49,14 @@ const formData = ref<TradeOrderApi.DeliveryVO>({
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
// TODO @puhui999
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (orderId: number) => { const open = async (row: TradeOrderApi.OrderVO) => {
resetForm() resetForm()
// //
formData.value.id = orderId copyValueToTarget(formData.value, row)
if (row.logisticsId === null || row.logisticsId === 0) {
expressType.value = 'none'
}
dialogVisible.value = true dialogVisible.value = true
} }
defineExpose({ open }) // open defineExpose({ open }) // open
@ -66,7 +68,7 @@ const submitForm = async () => {
formLoading.value = true formLoading.value = true
try { try {
const data = unref(formData) const data = unref(formData)
if (radio.value === '2') { if (expressType.value === 'none') {
// //
data.logisticsId = 0 data.logisticsId = 0
data.logisticsNo = '' data.logisticsNo = ''

View File

@ -1,18 +1,27 @@
<template> <template>
<Dialog v-model="dialogVisible" title="修改订单收货地址" width="35%"> <Dialog v-model="dialogVisible" title="修改订单收货地址" width="35%">
<el-form ref="formRef" v-loading="formLoading" :model="formData" label-width="120px"> <el-form ref="formRef" v-loading="formLoading" :model="formData" label-width="120px">
<el-form-item label="收件人名称"> <el-form-item label="收件人">
<el-input v-model="formData.receiverName" /> <el-input v-model="formData.receiverName" placeholder="请输入收件人名称" />
</el-form-item> </el-form-item>
<el-form-item label="收件人手机"> <el-form-item label="手机">
<el-input v-model="formData.receiverMobile" /> <el-input v-model="formData.receiverMobile" placeholder="请输入收件人手机号" />
</el-form-item> </el-form-item>
<!-- TODO @puhui999应该是个地区下拉框可以看下 UserForm 所在地 --> <el-form-item label="所在地">
<el-form-item label="收件人地区编号"> <el-tree-select
<el-input v-model="formData.receiverAreaId" /> v-model="formData.receiverAreaId"
:data="areaList"
:props="defaultProps"
:render-after-expand="true"
/>
</el-form-item> </el-form-item>
<el-form-item label="收件人详细地址"> <el-form-item label="详细地址">
<el-input v-model="formData.receiverDetailAddress" /> <el-input
v-model="formData.receiverDetailAddress"
:rows="3"
placeholder="请输入收件人详细地址"
type="textarea"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
@ -23,10 +32,11 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import * as TradeOrderApi from '@/api/mall/trade/order' import * as TradeOrderApi from '@/api/mall/trade/order'
import { getAreaTree } from '@/api/system/area'
import { copyValueToTarget } from '@/utils' import { copyValueToTarget } from '@/utils'
import { defaultProps } from '@/utils/tree'
// TODO @puhui999OrderAdjustAddressForm OrderUpdateAddressForm defineOptions({ name: 'OrderUpdateAddressForm' })
defineOptions({ name: 'OrderAdjustAddressForm' })
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
@ -40,6 +50,7 @@ const formData = ref({
receiverAreaId: null, // receiverAreaId: null, //
receiverDetailAddress: '' // receiverDetailAddress: '' //
}) })
const areaList = ref([]) //
const formRef = ref() // Ref const formRef = ref() // Ref
/** 打开弹窗 */ /** 打开弹窗 */
@ -58,7 +69,7 @@ const submitForm = async () => {
formLoading.value = true formLoading.value = true
try { try {
const data = unref(formData) const data = unref(formData)
await TradeOrderApi.adjustAddress(data) await TradeOrderApi.updateAddress(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
dialogVisible.value = false dialogVisible.value = false
// //
@ -79,4 +90,9 @@ const resetForm = () => {
} }
formRef.value?.resetFields() formRef.value?.resetFields()
} }
onMounted(async () => {
//
areaList.value = await getAreaTree()
})
</script> </script>

View File

@ -23,8 +23,7 @@ import * as TradeOrderApi from '@/api/mall/trade/order'
import { convertToInteger, formatToFraction } from '@/utils' import { convertToInteger, formatToFraction } from '@/utils'
import { cloneDeep } from 'lodash-es' import { cloneDeep } from 'lodash-es'
// TODO @puhui999OrderAdjustPriceForm OrderUpdatePriceForm defineOptions({ name: 'OrderUpdatePriceForm' })
defineOptions({ name: 'OrderAdjustPriceForm' })
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
@ -53,6 +52,7 @@ const open = async (row: TradeOrderApi.OrderVO) => {
// //
formData.value.adjustPrice = formatToFraction(row.adjustPrice) formData.value.adjustPrice = formatToFraction(row.adjustPrice)
formData.value.payPrice = formatToFraction(row.payPrice) + '元' formData.value.payPrice = formatToFraction(row.payPrice) + '元'
formData.value.newPayPrice = formData.value.payPrice
dialogVisible.value = true dialogVisible.value = true
} }
defineExpose({ open }) // open defineExpose({ open }) // open
@ -67,7 +67,7 @@ const submitForm = async () => {
data.adjustPrice = convertToInteger(data.adjustPrice) data.adjustPrice = convertToInteger(data.adjustPrice)
delete data.payPrice delete data.payPrice
delete data.newPayPrice delete data.newPayPrice
await TradeOrderApi.adjustPrice(data) await TradeOrderApi.updatePrice(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
dialogVisible.value = false dialogVisible.value = false
// //

View File

@ -1,8 +1,13 @@
<template> <template>
<Dialog v-model="dialogVisible" title="商家备注" width="25%"> <Dialog v-model="dialogVisible" title="商家备注" width="45%">
<el-form ref="formRef" v-loading="formLoading" :model="formData" label-width="80px"> <el-form ref="formRef" v-loading="formLoading" :model="formData" label-width="80px">
<el-form-item label="备注"> <el-form-item label="备注">
<el-input v-model="formData.remark" /> <el-input
v-model="formData.remark"
:rows="3"
placeholder="请输入订单备注"
type="textarea"
/>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
@ -14,8 +19,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import * as TradeOrderApi from '@/api/mall/trade/order' import * as TradeOrderApi from '@/api/mall/trade/order'
// TODO @puhui999OrderRemarksForm OrderUpdateRemarkForm defineOptions({ name: 'OrderUpdateRemarkForm' })
defineOptions({ name: 'OrderRemarksForm' })
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
@ -46,7 +50,7 @@ const submitForm = async () => {
try { try {
const data = unref(formData) const data = unref(formData)
console.log(data) console.log(data)
await TradeOrderApi.remark(data) await TradeOrderApi.updateRemark(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
dialogVisible.value = false dialogVisible.value = false
// //

View File

@ -41,10 +41,10 @@
<dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="orderInfo.status" /> <dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="orderInfo.status" />
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label-class-name="no-colon"> <el-descriptions-item label-class-name="no-colon">
<el-button type="primary" @click="openForm('adjustPrice')">调整价格</el-button> <el-button type="primary" @click="openForm('updatePrice')">调整价格</el-button>
<el-button type="primary" @click="openForm('remark')">备注</el-button> <el-button type="primary" @click="openForm('remark')">备注</el-button>
<el-button type="primary" @click="openForm('delivery')">发货</el-button> <el-button type="primary" @click="openForm('delivery')">发货</el-button>
<el-button type="primary" @click="openForm('adjustAddress')">修改地址</el-button> <el-button type="primary" @click="openForm('updateAddress')">修改地址</el-button>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label><span style="color: red">提醒: </span></template> <template #label><span style="color: red">提醒: </span></template>
@ -68,12 +68,12 @@
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="商品原价(元)" prop="price" width="150"> <el-table-column label="商品原价" prop="price" width="150">
<template #default="{ row }">{{ formatToFraction(row.price) }}</template> <template #default="{ row }">{{ floatToFixed2(row.price) }}</template>
</el-table-column> </el-table-column>
<el-table-column label="数量" prop="count" width="100" /> <el-table-column label="数量" prop="count" width="100" />
<el-table-column label="合计(元)" prop="payPrice" width="150"> <el-table-column label="合计" prop="payPrice" width="150">
<template #default="{ row }">{{ formatToFraction(row.payPrice) }}</template> <template #default="{ row }">{{ floatToFixed2(row.payPrice) }}</template>
</el-table-column> </el-table-column>
<el-table-column label="售后状态" prop="afterSaleStatus" width="120"> <el-table-column label="售后状态" prop="afterSaleStatus" width="120">
<template #default="{ row }"> <template #default="{ row }">
@ -91,32 +91,32 @@
</el-descriptions> </el-descriptions>
<el-descriptions :column="6"> <el-descriptions :column="6">
<el-descriptions-item label="商品总额: "> <el-descriptions-item label="商品总额: ">
{{ formatToFraction(orderInfo.totalPrice) }} {{ floatToFixed2(orderInfo.totalPrice) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="运费金额: "> <el-descriptions-item label="运费金额: ">
{{ formatToFraction(orderInfo.deliveryPrice) }} {{ floatToFixed2(orderInfo.deliveryPrice) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item label="订单调价: "> <el-descriptions-item label="订单调价: ">
{{ formatToFraction(orderInfo.adjustPrice) }} {{ floatToFixed2(orderInfo.updatePrice) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label><span style="color: red">商品优惠: </span></template> <template #label><span style="color: red">商品优惠: </span></template>
{{ formatToFraction(orderInfo.couponPrice) }} {{ floatToFixed2(orderInfo.couponPrice) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label><span style="color: red">订单优惠: </span></template> <template #label><span style="color: red">订单优惠: </span></template>
{{ formatToFraction(orderInfo.discountPrice) }} {{ floatToFixed2(orderInfo.discountPrice) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template #label><span style="color: red">积分抵扣: </span></template> <template #label><span style="color: red">积分抵扣: </span></template>
{{ formatToFraction(orderInfo.pointPrice) }} {{ floatToFixed2(orderInfo.pointPrice) }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item v-for="item in 5" :key="item" label-class-name="no-colon" /> <el-descriptions-item v-for="item in 5" :key="item" label-class-name="no-colon" />
<!-- 占位 --> <!-- 占位 -->
<el-descriptions-item label="应付金额: "> <el-descriptions-item label="应付金额: ">
{{ formatToFraction(orderInfo.payPrice) }} {{ floatToFixed2(orderInfo.payPrice) }}
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
@ -199,69 +199,25 @@
</ContentWrap> </ContentWrap>
<!-- 各种操作的弹窗 --> <!-- 各种操作的弹窗 -->
<DeliveryOrderForm ref="deliveryFormRef" @success="getDetail" /> <OrderDeliveryForm ref="deliveryFormRef" @success="getDetail" />
<OrderRemarksForm ref="remarksFormRef" @success="getDetail" /> <OrderUpdateRemarkForm ref="updateRemarkForm" @success="getDetail" />
<OrderAdjustAddressForm ref="adjustAddressFormRef" @success="getDetail" /> <OrderUpdateAddressForm ref="updateAddressFormRef" @success="getDetail" />
<OrderAdjustPriceForm ref="adjustPriceFormRef" @success="getDetail" /> <OrderUpdatePriceForm ref="updatePriceFormRef" @success="getDetail" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import * as TradeOrderApi from '@/api/mall/trade/order' import * as TradeOrderApi from '@/api/mall/trade/order'
import { formatToFraction } from '@/utils' import { floatToFixed2 } from '@/utils'
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
import OrderRemarksForm from '@/views/mall/trade/order/components/OrderRemarksForm.vue' import OrderUpdateRemarkForm from '@/views/mall/trade/order/components/OrderUpdateRemarkForm.vue'
import DeliveryOrderForm from '@/views/mall/trade/order/components/DeliveryOrderForm.vue' import OrderDeliveryForm from '@/views/mall/trade/order/components/OrderDeliveryForm.vue'
import OrderAdjustAddressForm from '@/views/mall/trade/order/components/OrderAdjustAddressForm.vue' import OrderUpdateAddressForm from '@/views/mall/trade/order/components/OrderUpdateAddressForm.vue'
import OrderAdjustPriceForm from '@/views/mall/trade/order/components/OrderAdjustPriceForm.vue' import OrderUpdatePriceForm from '@/views/mall/trade/order/components/OrderUpdatePriceForm.vue'
// TODO @puhui999TradeOrderDetailForm order/detail/index.vue vue
defineOptions({ name: 'TradeOrderDetailForm' }) defineOptions({ name: 'TradeOrderDetailForm' })
const message = useMessage() // const message = useMessage() //
const { params } = useRoute() // const { params } = useRoute() //
// TODO @puhui999orderInfo const orderInfo = ref<TradeOrderApi.OrderVO>({})
const orderInfo = ref<TradeOrderApi.OrderVO>({
no: '',
createTime: null,
type: null,
terminal: null,
userId: null,
userIp: '',
userRemark: '',
status: null,
productCount: null,
finishTime: null,
cancelTime: null,
cancelType: null,
remark: '',
payOrderId: null,
payed: false,
payTime: null,
payChannelCode: '',
originalPrice: null,
orderPrice: null,
discountPrice: null,
deliveryPrice: null,
adjustPrice: null,
payPrice: null,
deliveryTemplateId: null,
logisticsId: null,
logisticsNo: '',
deliveryStatus: null,
deliveryTime: null,
receiveTime: null,
receiverName: '',
receiverMobile: '',
receiverAreaId: null,
receiverPostCode: null,
receiverDetailAddress: '',
afterSaleStatus: null,
refundPrice: null,
couponPrice: null,
pointPrice: null,
receiverAreaName: '',
items: [],
user: {}
})
// TODO @puhui999 // TODO @puhui999
const detailGroups = ref([ const detailGroups = ref([
@ -330,22 +286,22 @@ const detailInfo = ref({
}) })
const deliveryFormRef = ref() // Ref const deliveryFormRef = ref() // Ref
const remarksFormRef = ref() // Ref const updateRemarkForm = ref() // Ref
const adjustAddressFormRef = ref() // Ref const updateAddressFormRef = ref() // Ref
const adjustPriceFormRef = ref() // Ref const updatePriceFormRef = ref() // Ref
const openForm = (type: string) => { const openForm = (type: string) => {
switch (type) { switch (type) {
case 'remark': case 'remark':
remarksFormRef.value?.open(orderInfo.value) updateRemarkForm.value?.open(orderInfo.value)
break break
case 'delivery': case 'delivery':
deliveryFormRef.value?.open(orderInfo.value.id) deliveryFormRef.value?.open(orderInfo.value)
break break
case 'adjustAddress': case 'updateAddress':
adjustAddressFormRef.value?.open(orderInfo.value) updateAddressFormRef.value?.open(orderInfo.value)
break break
case 'adjustPrice': case 'updatePrice':
adjustPriceFormRef.value?.open(orderInfo.value) updatePriceFormRef.value?.open(orderInfo.value)
break break
} }
} }

View File

@ -100,7 +100,7 @@
placeholder="请输入" placeholder="请输入"
> >
<template #prepend> <template #prepend>
<el-select v-model="queryType.k" clearable placeholder="全部" class="!w-110px"> <el-select v-model="queryType.k" class="!w-110px" clearable placeholder="全部">
<el-option <el-option
v-for="dict in searchList" v-for="dict in searchList"
:key="dict.value" :key="dict.value"
@ -164,11 +164,11 @@
<el-table-column label="商品原价*数量" prop="price" width="150"> <el-table-column label="商品原价*数量" prop="price" width="150">
<template #default="{ row }"> <template #default="{ row }">
<!-- TODO @puhui999价格要有 xxx.00 这种格式 --> <!-- TODO @puhui999价格要有 xxx.00 这种格式 -->
{{ formatToFraction(row.price) }} * {{ row.count }} {{ floatToFixed2(row.price) }} * {{ row.count }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="合计" prop="payPrice" width="150"> <el-table-column label="合计" prop="payPrice" width="150">
<template #default="{ row }">{{ formatToFraction(row.payPrice) }}</template> <template #default="{ row }">{{ floatToFixed2(row.payPrice) }}</template>
</el-table-column> </el-table-column>
<el-table-column label="售后状态" prop="afterSaleStatus" width="120"> <el-table-column label="售后状态" prop="afterSaleStatus" width="120">
<template #default="{ row }"> <template #default="{ row }">
@ -181,7 +181,7 @@
<el-table-column align="center" label="实际支付" min-width="120" prop="payPrice"> <el-table-column align="center" label="实际支付" min-width="120" prop="payPrice">
<template #default> <template #default>
<!-- TODO @puhui999价格要有 xxx.00 这种格式 --> <!-- TODO @puhui999价格要有 xxx.00 这种格式 -->
{{ formatToFraction(scope.row.payPrice) + '元' }} {{ floatToFixed2(scope.row.payPrice) + '元' }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="买家/收货人" min-width="160"> <el-table-column label="买家/收货人" min-width="160">
@ -307,22 +307,19 @@
</ContentWrap> </ContentWrap>
<!-- 各种操作的弹窗 --> <!-- 各种操作的弹窗 -->
<DeliveryOrderForm ref="deliveryOrderFormRef" @success="getList" /> <OrderDeliveryForm ref="deliveryFormRef" @success="getList" />
<OrderRemarksForm ref="orderRemarksFormRef" @success="getList" /> <OrderUpdateRemarkForm ref="updateRemarkForm" @success="getList" />
</template> </template>
<script lang="ts" name="Order" setup> <script lang="ts" name="Order" setup>
import type { FormInstance, TableColumnCtx } from 'element-plus' import type { FormInstance, TableColumnCtx } from 'element-plus'
import DeliveryOrderForm from './components/DeliveryOrderForm.vue' import OrderDeliveryForm from './components/OrderDeliveryForm.vue'
import OrderRemarksForm from './components/OrderRemarksForm.vue' import OrderUpdateRemarkForm from './components/OrderUpdateRemarkForm.vue'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import * as TradeOrderApi from '@/api/mall/trade/order' import * as TradeOrderApi from '@/api/mall/trade/order'
// @puhui999 TradeOrderApi VO import * as PickUpStoreApi from '@/api/mall/trade/delivery/pickUpStore'
import { OrderItemRespVO, OrderVO } from '@/api/mall/trade/order' import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
// @puhui999使 XXXApi import { floatToFixed2 } from '@/utils'
import { getListAllSimple } from '@/api/mall/trade/delivery/pickUpStore'
import { DICT_TYPE, getStrDictOptions, getIntDictOptions } from '@/utils/dict'
import { formatToFraction } from '@/utils'
import { createImageViewer } from '@/components/ImageViewer' import { createImageViewer } from '@/components/ImageViewer'
import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express' import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express'
@ -330,7 +327,7 @@ const { currentRoute, push } = useRouter() // 路由跳转
const loading = ref(true) // const loading = ref(true) //
const total = ref(2) // const total = ref(2) //
const list = ref<OrderVO[]>([]) // const list = ref<TradeOrderApi.OrderVO[]>([]) //
const queryFormRef = ref<FormInstance>() // const queryFormRef = ref<FormInstance>() //
// //
const queryParams = reactive({ const queryParams = reactive({
@ -368,11 +365,12 @@ const searchList = ref([
]) ])
interface SpanMethodProps { interface SpanMethodProps {
row: OrderItemRespVO row: TradeOrderApi.OrderItemRespVO
column: TableColumnCtx<OrderItemRespVO> column: TableColumnCtx<TradeOrderApi.OrderItemRespVO>
rowIndex: number rowIndex: number
columnIndex: number columnIndex: number
} }
const spanMethod = ({ rowIndex, columnIndex }: SpanMethodProps) => { const spanMethod = ({ rowIndex, columnIndex }: SpanMethodProps) => {
const colIndex = [4, 5, 6, 7] const colIndex = [4, 5, 6, 7]
// //
@ -384,6 +382,7 @@ const spanMethod = ({ rowIndex, columnIndex }: SpanMethodProps) => {
colspan: 0 colspan: 0
} }
} }
// TODO puhui
return { return {
rowspan: 2, rowspan: 2,
colspan: 1 colspan: 1
@ -422,27 +421,26 @@ const imagePreview = (imgUrl: string) => {
}) })
} }
/** 查看商品详情 */ /** 查看订单详情 */
const openForm = (id: number) => { const openForm = (id: number) => {
// TODO @puhui999 name url push({ name: 'TradeOrderDetailForm', params: { orderId: id } })
push('/trade/order/detail/' + id)
} }
/** 操作分发 */ /** 操作分发 */
const deliveryOrderFormRef = ref() const deliveryFormRef = ref()
const orderRemarksFormRef = ref() const updateRemarkForm = ref()
const handleCommand = (command: string, row: OrderVO) => { const handleCommand = (command: string, row: TradeOrderApi.OrderVO) => {
switch (command) { switch (command) {
case 'orderRemarks': // TODO @puhui999orderRemarks remark case 'remark':
orderRemarksFormRef.value?.open(row) updateRemarkForm.value?.open(row)
break break
case 'delivery': case 'delivery':
deliveryOrderFormRef.value?.open(row.id) deliveryFormRef.value?.open(row)
break break
} }
} }
// // /
watch( watch(
() => currentRoute.value, () => currentRoute.value,
() => { () => {
@ -455,7 +453,7 @@ const deliveryExpressList = ref([]) // 物流公司
/** 初始化 **/ /** 初始化 **/
onMounted(async () => { onMounted(async () => {
await getList() await getList()
pickUpStoreList.value = await getListAllSimple() pickUpStoreList.value = await PickUpStoreApi.getListAllSimple()
deliveryExpressList.value = await DeliveryExpressApi.getSimpleDeliveryExpressList() deliveryExpressList.value = await DeliveryExpressApi.getSimpleDeliveryExpressList()
}) })
</script> </script>