订单列表:列表重构: 完善订单发货、修改地址、订单调价、订单备注

This commit is contained in:
puhui999 2023-08-22 17:36:47 +08:00
parent ebcbe63d9b
commit be143ea21b
9 changed files with 263 additions and 77 deletions

View File

@ -109,3 +109,13 @@ export const delivery = async (data: DeliveryVO) => {
export const remark = async (data) => { export const remark = async (data) => {
return await request.post({ url: `/trade/order/remark`, data }) return await request.post({ url: `/trade/order/remark`, data })
} }
// 订单调价
export const adjustPrice = async (data) => {
return await request.post({ url: `/trade/order/adjust-price`, data })
}
// 修改订单地址
export const adjustAddress = async (data) => {
return await request.post({ url: `/trade/order/adjust-address`, data })
}

View File

@ -421,7 +421,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
children: [ children: [
{ {
path: 'detail/:orderId(\\d+)', path: 'detail/:orderId(\\d+)',
component: () => import('@/views/mall/trade/order/detail/index.vue'), component: () => import('@/views/mall/trade/order/components/OrderDetailForm.vue'),
name: 'TradeOrderDetailForm', name: 'TradeOrderDetailForm',
meta: { title: '订单详情', icon: '', activeMenu: '/trade/trade/order' } meta: { title: '订单详情', icon: '', activeMenu: '/trade/trade/order' }
} }

View File

@ -164,5 +164,8 @@ export enum DICT_TYPE {
PROMOTION_COUPON_STATUS = 'promotion_coupon_status', // 优惠劵的状态 PROMOTION_COUPON_STATUS = 'promotion_coupon_status', // 优惠劵的状态
PROMOTION_COUPON_TAKE_TYPE = 'promotion_coupon_take_type', // 优惠劵的领取方式 PROMOTION_COUPON_TAKE_TYPE = 'promotion_coupon_take_type', // 优惠劵的领取方式
PROMOTION_ACTIVITY_STATUS = 'promotion_activity_status', // 优惠活动的状态 PROMOTION_ACTIVITY_STATUS = 'promotion_activity_status', // 优惠活动的状态
PROMOTION_CONDITION_TYPE = 'promotion_condition_type' // 营销的条件类型枚举 PROMOTION_CONDITION_TYPE = 'promotion_condition_type', // 营销的条件类型枚举
// ========== MALL - 物流模块 ==========
DELIVERY_TYPE = 'delivery_type' // 配送方式
} }

View File

@ -0,0 +1,80 @@
<template>
<Dialog v-model="dialogVisible" title="修改订单收货地址" width="35%">
<el-form ref="formRef" v-loading="formLoading" :model="formData" label-width="120px">
<el-form-item label="收件人名称">
<el-input v-model="formData.receiverName" />
</el-form-item>
<el-form-item label="收件人手机">
<el-input v-model="formData.receiverMobile" />
</el-form-item>
<el-form-item label="收件人地区编号">
<el-input v-model="formData.receiverAreaId" />
</el-form-item>
<el-form-item label="收件人详细地址">
<el-input v-model="formData.receiverDetailAddress" />
</el-form-item>
</el-form>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import * as TradeOrderApi from '@/api/mall/trade/order'
import { copyValueToTarget } from '@/utils'
defineOptions({ name: 'OrderAdjustAddressForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const formLoading = ref(false) // 12
const formData = ref({
id: 0, //
receiverName: '', //
receiverMobile: '', //
receiverAreaId: null, //
receiverDetailAddress: '' //
})
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (row: TradeOrderApi.OrderVO) => {
resetForm()
//
copyValueToTarget(formData.value, row)
dialogVisible.value = true
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
formLoading.value = true
try {
const data = unref(formData)
await TradeOrderApi.adjustAddress(data)
message.success(t('common.updateSuccess'))
dialogVisible.value = false
//
emit('success', true)
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: 0, //
receiverName: '', //
receiverMobile: '', //
receiverAreaId: null, //
receiverDetailAddress: '' //
}
formRef.value?.resetFields()
}
</script>

View File

@ -0,0 +1,89 @@
<template>
<Dialog v-model="dialogVisible" title="订单调价" width="25%">
<el-form ref="formRef" v-loading="formLoading" :model="formData" label-width="100px">
<el-form-item label="应付金额(总)">
<el-input v-model="formData.payPrice" disabled />
</el-form-item>
<el-form-item label="订单调价">
<el-input-number v-model="formData.adjustPrice" :precision="2" :step="0.1" class="w-100%" />
<el-tag class="mt-10px" type="warning">订单调价 正数加价负数减价</el-tag>
</el-form-item>
<el-form-item label="调价后">
<el-input v-model="formData.newPayPrice" disabled />
</el-form-item>
</el-form>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import * as TradeOrderApi from '@/api/mall/trade/order'
import { convertToInteger, formatToFraction } from '@/utils'
import { cloneDeep } from 'lodash-es'
defineOptions({ name: 'OrderAdjustPriceForm' })
const { t } = useI18n() //
const message = useMessage() //
const dialogVisible = ref(false) //
const formLoading = ref(false) // 12
const formData = ref({
id: 0, //
adjustPrice: 0, //
payPrice: '', // ()
newPayPrice: '' // ()
})
watch(
() => formData.value.adjustPrice,
(data: number) => {
formData.value.newPayPrice = formData.value.payPrice.replace('元', '') * 1 + data + '元'
}
)
const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (row: TradeOrderApi.OrderVO) => {
resetForm()
formData.value.id = row.id
//
formData.value.adjustPrice = formatToFraction(row.adjustPrice)
formData.value.payPrice = formatToFraction(row.payPrice) + '元'
dialogVisible.value = true
}
defineExpose({ open }) // open
/** 提交表单 */
const emit = defineEmits(['success']) // success
const submitForm = async () => {
//
formLoading.value = true
try {
const data = cloneDeep(unref(formData))
data.adjustPrice = convertToInteger(data.adjustPrice)
delete data.payPrice
delete data.newPayPrice
await TradeOrderApi.adjustPrice(data)
message.success(t('common.updateSuccess'))
dialogVisible.value = false
//
emit('success', true)
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: 0, //
adjustPrice: 0, //
payPrice: '', // ()
newPayPrice: '' // ()
}
formRef.value?.resetFields()
}
</script>

View File

@ -3,10 +3,11 @@
<!-- 订单信息 --> <!-- 订单信息 -->
<el-descriptions title="订单信息"> <el-descriptions title="订单信息">
<el-descriptions-item label="订单号: ">{{ orderInfo.no }}</el-descriptions-item> <el-descriptions-item label="订单号: ">{{ orderInfo.no }}</el-descriptions-item>
<el-descriptions-item label="配送方式: ">物流配送</el-descriptions-item> <el-descriptions-item label="配送方式: ">
<!-- TODO 芋艿待实现 --> <dict-tag :type="DICT_TYPE.DELIVERY_TYPE" :value="orderInfo.deliveryType" />
<el-descriptions-item label="营销活动: ">物流配送</el-descriptions-item> </el-descriptions-item>
<!-- TODO 芋艿待实现 --> <!-- TODO 营销活动待实现 -->
<el-descriptions-item label="营销活动: ">秒杀活动</el-descriptions-item>
<el-descriptions-item label="订单类型: "> <el-descriptions-item label="订单类型: ">
<dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="orderInfo.type" /> <dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="orderInfo.type" />
</el-descriptions-item> </el-descriptions-item>
@ -37,22 +38,17 @@
<!-- 订单状态 --> <!-- 订单状态 -->
<el-descriptions :column="1" title="订单状态"> <el-descriptions :column="1" title="订单状态">
<el-descriptions-item label="订单状态: "> <el-descriptions-item label="订单状态: ">
<!-- TODO xiaobaistatus 一定有值哈不用判断 --> <dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="orderInfo.status" />
<dict-tag
v-if="orderInfo.status !== ''"
: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 size="small" type="primary">调整价格</el-button> <el-button size="small" type="primary" @click="openForm('adjustPrice')">调整价格</el-button>
<el-button size="small" type="primary" @click="openForm('remark')">备注</el-button> <el-button size="small" type="primary" @click="openForm('remark')">备注</el-button>
<el-button size="small" type="primary" @click="openForm('delivery')">发货</el-button> <el-button size="small" type="primary" @click="openForm('delivery')">发货</el-button>
<!-- TODO 芋艿待实现 --> <el-button size="small" type="primary" @click="openForm('adjustAddress')">
<el-button size="small" type="primary">修改地址</el-button> 修改地址
<!-- TODO 芋艿待实现 --> </el-button>
<!-- TODO 后台商家也需要收货功能吗 -->
<el-button size="small" type="primary">确认收货</el-button> <el-button size="small" type="primary">确认收货</el-button>
<!-- TODO 芋艿待实现 -->
</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>
@ -62,8 +58,6 @@
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
<!-- 物流信息 TODO -->
<!-- 商品信息 --> <!-- 商品信息 -->
<el-descriptions title="商品信息"> <el-descriptions title="商品信息">
<el-descriptions-item labelClassName="no-colon"> <el-descriptions-item labelClassName="no-colon">
@ -98,8 +92,6 @@
<el-col :span="10" /> <el-col :span="10" />
</el-row> </el-row>
</el-descriptions-item> </el-descriptions-item>
<!-- 占位 -->
<!-- <el-descriptions-item v-for="item in 5" label-class-name="no-colon" :key="item" /> -->
</el-descriptions> </el-descriptions>
<el-descriptions :column="6"> <el-descriptions :column="6">
<el-descriptions-item label="商品总额: "> <el-descriptions-item label="商品总额: ">
@ -114,8 +106,7 @@
<el-descriptions-item> <el-descriptions-item>
<template #label><span style="color: red">商品优惠: </span></template> <template #label><span style="color: red">商品优惠: </span></template>
<!-- 没理解TODO orderInfo.totalPrice - orderInfo.totalPrice --> {{ formatToFraction(orderInfo.couponPrice) }}
{{ formatToFraction(orderInfo.totalPrice - orderInfo.totalPrice) }}
</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>
@ -149,7 +140,7 @@
</el-timeline> </el-timeline>
</el-descriptions-item> </el-descriptions-item>
<!-- 物流信息 --> <!-- 物流信息 TODO 等物流接口搞定重构一下 -->
<!-- TODO @xiaobai改成一个包裹哈目前只允许发货一次 --> <!-- TODO @xiaobai改成一个包裹哈目前只允许发货一次 -->
<el-descriptions-item v-if="group.key === 'expressInfo'" labelClassName="no-colon"> <el-descriptions-item v-if="group.key === 'expressInfo'" labelClassName="no-colon">
<!-- 循环包裹物流信息 --> <!-- 循环包裹物流信息 -->
@ -210,15 +201,19 @@
</el-descriptions> </el-descriptions>
</div> </div>
</ContentWrap> </ContentWrap>
<DeliveryOrderForm ref="deliveryOrderFormRef" @success="getDetail" /> <DeliveryOrderForm ref="deliveryFormRef" @success="getDetail" />
<OrderRemarksForm ref="orderRemarksFormRef" @success="getDetail" /> <OrderRemarksForm ref="remarksFormRef" @success="getDetail" />
<OrderAdjustAddressForm ref="adjustAddressFormRef" @success="getDetail" />
<OrderAdjustPriceForm ref="adjustPriceFormRef" @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 { formatToFraction } from '@/utils'
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
import OrderRemarksForm from '@/views/mall/trade/order/OrderRemarksForm.vue' import OrderRemarksForm from '@/views/mall/trade/order/components/OrderRemarksForm.vue'
import DeliveryOrderForm from '@/views/mall/trade/order/DeliveryOrderForm.vue' import DeliveryOrderForm from '@/views/mall/trade/order/components/DeliveryOrderForm.vue'
import OrderAdjustAddressForm from '@/views/mall/trade/order/components/OrderAdjustAddressForm.vue'
import OrderAdjustPriceForm from '@/views/mall/trade/order/components/OrderAdjustPriceForm.vue'
defineOptions({ name: 'TradeOrderDetailForm' }) defineOptions({ name: 'TradeOrderDetailForm' })
@ -287,9 +282,8 @@ const detailGroups = ref([
]) ])
const detailInfo = ref({ const detailInfo = ref({
expressInfo:
// //
{ expressInfo: {
label: '包裹1', label: '包裹1',
name: 'bg1', name: 'bg1',
fhsj: '2022-11-03 16:50:45', fhsj: '2022-11-03 16:50:45',
@ -333,16 +327,23 @@ const detailInfo = ref({
goodsInfo: [] // tableData goodsInfo: [] // tableData
}) })
const deliveryOrderFormRef = ref() // Ref const deliveryFormRef = ref() // Ref
const orderRemarksFormRef = ref() // Ref const remarksFormRef = ref() // Ref
const adjustAddressFormRef = ref() // Ref
const adjustPriceFormRef = ref() // Ref
const openForm = (type: string) => { const openForm = (type: string) => {
switch (type) { switch (type) {
case 'remark': case 'remark':
orderRemarksFormRef.value?.open(orderInfo) remarksFormRef.value?.open(orderInfo.value)
break break
case 'delivery': case 'delivery':
deliveryOrderFormRef.value?.open(orderInfo.id) deliveryFormRef.value?.open(orderInfo.value.id)
break
case 'adjustAddress':
adjustAddressFormRef.value?.open(orderInfo.value)
break
case 'adjustPrice':
adjustPriceFormRef.value?.open(orderInfo.value)
break break
} }
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<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-input v-model="formData.remark" /> <el-input v-model="formData.remark" />
@ -44,6 +44,7 @@ const submitForm = async () => {
formLoading.value = true formLoading.value = true
try { try {
const data = unref(formData) const data = unref(formData)
console.log(data)
await TradeOrderApi.remark(data) await TradeOrderApi.remark(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
dialogVisible.value = false dialogVisible.value = false
@ -58,8 +59,7 @@ const submitForm = async () => {
const resetForm = () => { const resetForm = () => {
formData.value = { formData.value = {
id: 0, // id: 0, //
logisticsId: null, // remark: '' //
logisticsNo: '' //
} }
formRef.value?.resetFields() formRef.value?.resetFields()
} }

View File

@ -130,10 +130,11 @@
</div> </div>
</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 }">
{{ formatToFraction(row.price) }} * {{ row.count }}
</template>
</el-table-column> </el-table-column>
<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 }">{{ formatToFraction(row.payPrice) }}</template>
</el-table-column> </el-table-column>
@ -150,7 +151,7 @@
{{ formatToFraction(scope.row.payPrice) + '元' }} {{ formatToFraction(scope.row.payPrice) + '元' }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="买家/收货人" min-width="120"> <el-table-column label="买家/收货人" min-width="160">
<template #default> <template #default>
<div class="flex flex-col"> <div class="flex flex-col">
<span>买家{{ scope.row.user.nickname }}</span> <span>买家{{ scope.row.user.nickname }}</span>
@ -161,8 +162,10 @@
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="配送方式" prop="deliveryType" width="120"> <el-table-column align="center" label="配送方式" width="120">
<template #default> 快递</template> <template #default>
<span>{{ scope.row.deliveryType || '快递' }}</span>
</template>
</el-table-column> </el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="160"> <el-table-column align="center" fixed="right" label="操作" width="160">
<template #default> <template #default>
@ -259,8 +262,8 @@
<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 './DeliveryOrderForm.vue' import DeliveryOrderForm from './components/DeliveryOrderForm.vue'
import OrderRemarksForm from './OrderRemarksForm.vue' import OrderRemarksForm from './components/OrderRemarksForm.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'
import { OrderItemRespVO, OrderVO } from '@/api/mall/trade/order' import { OrderItemRespVO, OrderVO } from '@/api/mall/trade/order'
@ -293,7 +296,7 @@ interface SpanMethodProps {
} }
const spanMethod = ({ rowIndex, columnIndex }: SpanMethodProps) => { const spanMethod = ({ rowIndex, columnIndex }: SpanMethodProps) => {
const colIndex = [5, 6, 7, 8] const colIndex = [4, 5, 6, 7]
// //
if (colIndex.includes(columnIndex)) { if (colIndex.includes(columnIndex)) {
// //