订单列表:优化订单列表页面结构

(cherry picked from commit 58502b1241)
This commit is contained in:
puhui999 2023-08-24 14:34:35 +08:00 committed by shizhong
parent 9d9ccaa1b8
commit 41be920135
3 changed files with 92 additions and 80 deletions

View File

@ -20,7 +20,7 @@
</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 { convertToInteger, formatToFraction } from '@/utils' import { convertToInteger, floatToFixed2, formatToFraction } from '@/utils'
import { cloneDeep } from 'lodash-es' import { cloneDeep } from 'lodash-es'
defineOptions({ name: 'OrderUpdatePriceForm' }) defineOptions({ name: 'OrderUpdatePriceForm' })
@ -39,7 +39,9 @@ const formData = ref({
watch( watch(
() => formData.value.adjustPrice, () => formData.value.adjustPrice,
(data: number) => { (data: number) => {
formData.value.newPayPrice = formData.value.payPrice.replace('元', '') * 1 + data + '元' const num = formData.value.payPrice!.replace('元', '')
// @ts-ignore
formData.value.newPayPrice = (num * 1 + data).toFixed(2) + '元'
} }
) )
@ -48,10 +50,10 @@ const formRef = ref() // 表单 Ref
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (row: TradeOrderApi.OrderVO) => { const open = async (row: TradeOrderApi.OrderVO) => {
resetForm() resetForm()
formData.value.id = row.id formData.value.id = row.id!
// //
formData.value.adjustPrice = formatToFraction(row.adjustPrice) formData.value.adjustPrice = formatToFraction(row.adjustPrice!)
formData.value.payPrice = formatToFraction(row.payPrice) + '元' formData.value.payPrice = floatToFixed2(row.payPrice!) + '元'
formData.value.newPayPrice = formData.value.payPrice formData.value.newPayPrice = formData.value.payPrice
dialogVisible.value = true dialogVisible.value = true
} }

View File

@ -219,7 +219,7 @@ const message = useMessage() // 消息弹窗
const { params } = useRoute() // const { params } = useRoute() //
const orderInfo = ref<TradeOrderApi.OrderVO>({}) const orderInfo = ref<TradeOrderApi.OrderVO>({})
// TODO @puhui999 // TODO @puhui999
const detailGroups = ref([ const detailGroups = ref([
{ {
title: '物流信息', title: '物流信息',
@ -238,7 +238,7 @@ const detailGroups = ref([
} }
]) ])
// TODO @puhui999 // TODO @puhui999
const detailInfo = ref({ const detailInfo = ref({
// //
expressInfo: { expressInfo: {

View File

@ -90,7 +90,7 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- TODO 考虑是否移除或重构这个还是需要的哈--> <!-- TODO 聚合搜索等售后结束后实现-->
<el-form-item label="聚合搜索"> <el-form-item label="聚合搜索">
<el-input <el-input
v-show="true" v-show="true"
@ -132,17 +132,53 @@
3然后点击展开和收拢订单项可以不做哈 3然后点击展开和收拢订单项可以不做哈
--> -->
<ContentWrap> <ContentWrap>
<el-table <el-table v-loading="loading" :data="list">
v-loading="loading" <el-table-column class-name="order-table-col">
:data="list" <template #header>
:show-overflow-tooltip="true" <div class="flex items-center" style="width: 100%">
:stripe="true" <div class="ml-100px mr-200px">商品信息</div>
default-expand-all <div class="mr-60px">单价()/数量</div>
> <div class="mr-60px">售后状态</div>
<el-table-column fixed="left" type="expand"> <div class="mr-60px">实付金额()</div>
<div class="mr-60px">买家/收货人</div>
<div class="mr-60px">配送方式</div>
<div class="mr-60px">订单状态</div>
<div class="mr-60px">操作</div>
</div>
</template>
<template #default="scope"> <template #default="scope">
<el-table :data="scope.row.items" :span-method="spanMethod" border style="width: 100%"> <el-table
<el-table-column label="商品信息" min-width="300" prop="spuName"> :data="scope.row.items"
:header-cell-style="headerStyle"
:span-method="spanMethod"
border
style="width: 100%"
>
<el-table-column min-width="300" prop="spuName">
<template #header>
<div
class="flex items-center"
style="height: 35px; background-color: #f7f7f7; width: 100%"
>
<span class="mr-20px">订单号{{ scope.row.no }} </span>
<span class="mr-20px">下单时间{{ formatDate(scope.row.createTime) }}</span>
<span>订单来源</span>
<dict-tag
:type="DICT_TYPE.TERMINAL"
:value="scope.row.terminal"
class="mr-20px"
/>
<span>支付方式</span>
<dict-tag
:type="DICT_TYPE.PAY_CHANNEL_CODE"
:value="scope.row.payChannelCode"
class="mr-20px"
/>
<span class="mr-20px">支付时间{{ formatDate(scope.row.payTime) }}</span>
<span>订单类型</span>
<dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="scope.row.type" />
</div>
</template>
<template #default="{ row }"> <template #default="{ row }">
<div class="flex items-center"> <div class="flex items-center">
<el-image <el-image
@ -163,13 +199,9 @@
</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 }"> <template #default="{ row }">
<!-- TODO @puhui999价格要有 xxx.00 这种格式 --> {{ floatToFixed2(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">
<template #default="{ row }">{{ floatToFixed2(row.payPrice) }}</template>
</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 }">
<dict-tag <dict-tag
@ -180,7 +212,6 @@
</el-table-column> </el-table-column>
<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 这种格式 -->
{{ floatToFixed2(scope.row.payPrice) + '元' }} {{ floatToFixed2(scope.row.payPrice) + '元' }}
</template> </template>
</el-table-column> </el-table-column>
@ -233,8 +264,11 @@
</el-button> </el-button>
<template #dropdown> <template #dropdown>
<el-dropdown-menu> <el-dropdown-menu>
<!-- TODO puhui999可以判断下状态 + 物流类型展示发货按钮 --> <!--判断下 物流类型 + 状态快递 + 待发货时展示发货按钮 -->
<el-dropdown-item command="delivery"> <el-dropdown-item
v-if="scope.row.deliveryType === 1 && scope.row.status === 10"
command="delivery"
>
<Icon icon="ep:takeaway-box" /> <Icon icon="ep:takeaway-box" />
发货 发货
</el-dropdown-item> </el-dropdown-item>
@ -251,51 +285,6 @@
</el-table> </el-table>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="订单号" min-width="110" prop="no" />
<el-table-column align="center" label="订单类型" min-width="100">
<template #default="{ row }">
<dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="row.type" />
</template>
</el-table-column>
<el-table-column align="center" label="订单来源" min-width="145">
<template #default="{ row }">
<dict-tag v-if="row.terminal" :type="DICT_TYPE.TERMINAL" :value="row.terminal" />
<span v-else>{{ row.terminal }}</span>
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="支付时间"
min-width="180"
prop="payTime"
/>
<el-table-column align="center" label="支付类型" min-width="120" prop="payChannelCode">
<template #default="{ row }">
<dict-tag
v-if="row.payChannelCode"
:type="DICT_TYPE.PAY_CHANNEL_CODE"
:value="row.payChannelCode"
/>
</template>
</el-table-column>
<el-table-column align="center" label="订单状态" min-width="100" prop="status">
<template #default="{ row }">
<dict-tag
v-if="row.status !== ''"
:type="DICT_TYPE.TRADE_ORDER_STATUS"
:value="row.status"
/>
<span v-else>{{ row.status }}</span>
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
min-width="180"
prop="createTime"
/>
</el-table> </el-table>
<!-- 分页 --> <!-- 分页 -->
<Pagination <Pagination
@ -315,10 +304,10 @@
import type { FormInstance, TableColumnCtx } from 'element-plus' import type { FormInstance, TableColumnCtx } from 'element-plus'
import OrderDeliveryForm from './components/OrderDeliveryForm.vue' import OrderDeliveryForm from './components/OrderDeliveryForm.vue'
import OrderUpdateRemarkForm from './components/OrderUpdateRemarkForm.vue' import OrderUpdateRemarkForm from './components/OrderUpdateRemarkForm.vue'
import { dateFormatter } from '@/utils/formatTime'
import * as TradeOrderApi from '@/api/mall/trade/order' import * as TradeOrderApi from '@/api/mall/trade/order'
import * as PickUpStoreApi from '@/api/mall/trade/delivery/pickUpStore' import * as PickUpStoreApi from '@/api/mall/trade/delivery/pickUpStore'
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime'
import { floatToFixed2 } from '@/utils' import { floatToFixed2 } 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'
@ -364,6 +353,19 @@ const searchList = ref([
{ value: 'userMobile', label: '用户电话' } { value: 'userMobile', label: '用户电话' }
]) ])
const headerStyle = ({ row, columnIndex }: any) => {
// 8
if (columnIndex === 0) {
row[columnIndex].colSpan = 8
} else {
//
row[columnIndex].colSpan = 0
return {
display: 'none'
}
}
}
interface SpanMethodProps { interface SpanMethodProps {
row: TradeOrderApi.OrderItemRespVO row: TradeOrderApi.OrderItemRespVO
column: TableColumnCtx<TradeOrderApi.OrderItemRespVO> column: TableColumnCtx<TradeOrderApi.OrderItemRespVO>
@ -371,20 +373,23 @@ interface SpanMethodProps {
columnIndex: number columnIndex: number
} }
const spanMethod = ({ rowIndex, columnIndex }: SpanMethodProps) => { const spanMethod = ({ row, rowIndex, columnIndex }: SpanMethodProps) => {
const colIndex = [4, 5, 6, 7] const len = list.value.find(
// (order) => order.items?.findIndex((item) => item.id === row.id) !== -1
)?.items?.length
//
const colIndex = [3, 4, 5, 6]
if (colIndex.includes(columnIndex)) { if (colIndex.includes(columnIndex)) {
// //
if (rowIndex !== 0) { if (rowIndex !== 0) {
return { return {
rowspan: 0, rowspan: 0,
colspan: 0 colspan: 0
} }
} }
// TODO puhui //
return { return {
rowspan: 2, rowspan: len,
colspan: 1 colspan: 1
} }
} }
@ -403,9 +408,9 @@ const getList = async () => {
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
const handleQuery = () => { const handleQuery = async () => {
queryParams.pageNo = 1 queryParams.pageNo = 1
getList() await getList()
} }
/** 重置按钮操作 */ /** 重置按钮操作 */
@ -457,3 +462,8 @@ onMounted(async () => {
deliveryExpressList.value = await DeliveryExpressApi.getSimpleDeliveryExpressList() deliveryExpressList.value = await DeliveryExpressApi.getSimpleDeliveryExpressList()
}) })
</script> </script>
<style lang="scss" scoped>
:deep(.order-table-col > .cell) {
padding: 0px;
}
</style>