Skip to content

Commit 46fd154

Browse files
author
puhui999
committed
完善订单详情和售后退款日志展示样式重构
1 parent d10530c commit 46fd154

File tree

4 files changed

+161
-14
lines changed

4 files changed

+161
-14
lines changed

src/api/mall/trade/order/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ export interface OrderVO {
5151
avatar?: string
5252
}
5353
// 订单操作日志
54-
orderLog: orderLog[]
54+
orderLog?: orderLog[]
5555
}
5656

5757
export interface orderLog {
5858
content?: string
5959
createTime?: Date
60+
userType?: number
6061
}
6162

6263
export interface OrderItemRespVO {

src/utils/dict.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,34 @@ export const getBoolDictOptions = (dictType: string) => {
6060
return dictOption
6161
}
6262

63-
export const getDictObj = (dictType: string, value: any) => {
63+
/**
64+
* 获取指定字典类型的指定值对应的字典对象
65+
* @param dictType 字典类型
66+
* @param value 字典值
67+
* @return DictDataType 字典对象
68+
*/
69+
export const getDictObj = (dictType: string, value: any): DictDataType | undefined => {
6470
const dictOptions: DictDataType[] = getDictOptions(dictType)
65-
dictOptions.forEach((dict: DictDataType) => {
66-
if (dict.value === value.toString()) {
71+
console.log(dictOptions)
72+
for (const dict of dictOptions) {
73+
if (dict.value === value + '') {
6774
return dict
6875
}
69-
})
76+
}
7077
}
7178

7279
/**
7380
* 获得字典数据的文本展示
7481
*
7582
* @param dictType 字典类型
7683
* @param value 字典数据的值
84+
* @return 字典名称
7785
*/
78-
export const getDictLabel = (dictType: string, value: any) => {
86+
export const getDictLabel = (dictType: string, value: any): string => {
7987
const dictOptions: DictDataType[] = getDictOptions(dictType)
8088
const dictLabel = ref('')
8189
dictOptions.forEach((dict: DictDataType) => {
82-
if (dict.value === value) {
90+
if (dict.value === value + '') {
8391
dictLabel.value = dict.label
8492
}
8593
})

src/views/mall/trade/afterSale/detail/index.vue

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@
131131
:timestamp="formatDate(saleLog.createTime)"
132132
placement="top"
133133
>
134-
<el-card>
135-
<span>用户类型:</span>
136-
<dict-tag :type="DICT_TYPE.USER_TYPE" :value="saleLog.userType" class="mr-10px" />
134+
<div class="el-timeline-right-content">
137135
<span>售后状态(之前):</span>
138136
<dict-tag
139137
:type="DICT_TYPE.TRADE_AFTER_SALE_STATUS"
@@ -147,7 +145,15 @@
147145
class="mr-10px"
148146
/>
149147
<span>操作明细:{{ saleLog.content }}</span>
150-
</el-card>
148+
</div>
149+
<template #dot>
150+
<span
151+
:style="{ backgroundColor: updateStyles(saleLog.userType) }"
152+
class="dot-node-style"
153+
>
154+
{{ getDictLabel(DICT_TYPE.USER_TYPE, saleLog.userType)[0] }}
155+
</span>
156+
</template>
151157
</el-timeline-item>
152158
</el-timeline>
153159
</el-descriptions-item>
@@ -160,7 +166,7 @@
160166
<script lang="ts" setup>
161167
import * as AfterSaleApi from '@/api/mall/trade/afterSale/index'
162168
import { floatToFixed2 } from '@/utils'
163-
import { DICT_TYPE } from '@/utils/dict'
169+
import { DICT_TYPE, getDictLabel, getDictObj } from '@/utils/dict'
164170
import { formatDate } from '@/utils/formatTime'
165171
import UpdateAuditReasonForm from '@/views/mall/trade/afterSale/form/AfterSaleDisagreeForm.vue'
166172
import { createImageViewer } from '@/components/ImageViewer'
@@ -177,6 +183,21 @@ const formData = ref({
177183
})
178184
const updateAuditReasonFormRef = ref() // 拒绝售后表单 Ref
179185
186+
const updateStyles = (type: number) => {
187+
const dict = getDictObj(DICT_TYPE.USER_TYPE, type)
188+
switch (dict?.colorType) {
189+
case 'success':
190+
return '#67C23A'
191+
case 'info':
192+
return '#909399'
193+
case 'warning':
194+
return '#E6A23C'
195+
case 'danger':
196+
return '#F56C6C'
197+
}
198+
return '#409EFF'
199+
}
200+
180201
/** 获得详情 */
181202
const getDetail = async () => {
182203
const id = params.orderId as unknown as number
@@ -277,4 +298,51 @@ onMounted(async () => {
277298
}
278299
}
279300
}
301+
302+
// 时间线样式调整
303+
:deep(.el-timeline) {
304+
margin: 10px 0px 0px 160px;
305+
306+
.el-timeline-item__wrapper {
307+
position: relative;
308+
top: -20px;
309+
310+
.el-timeline-item__timestamp {
311+
position: absolute !important;
312+
top: 10px;
313+
left: -150px;
314+
}
315+
}
316+
317+
.el-timeline-right-content {
318+
display: flex;
319+
align-items: center;
320+
min-height: 30px;
321+
padding: 10px;
322+
background-color: #f7f8fa;
323+
324+
&::before {
325+
content: ''; /* 必须设置 content 属性 */
326+
position: absolute;
327+
top: 10px;
328+
left: 13px; /* 将伪元素水平居中 */
329+
border-width: 8px; /* 调整尖角大小 */
330+
border-style: solid;
331+
border-color: transparent #f7f8fa transparent transparent; /* 尖角颜色,左侧朝向 */
332+
}
333+
}
334+
335+
.dot-node-style {
336+
width: 20px;
337+
height: 20px;
338+
position: absolute;
339+
left: -5px;
340+
display: flex;
341+
justify-content: center;
342+
align-items: center;
343+
border-radius: 50%;
344+
color: #fff;
345+
font-size: 10px;
346+
}
347+
}
280348
</style>

src/views/mall/trade/order/detail/index.vue

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,16 @@
155155
v-for="(log, index) in formData.orderLog"
156156
:key="index"
157157
:timestamp="formatDate(log.createTime!)"
158+
placement="top"
158159
>
159-
{{ log.content }}
160+
<div class="el-timeline-right-content">
161+
{{ log.content }}
162+
</div>
163+
<template #dot>
164+
<span :style="{ backgroundColor: updateStyles(log.userType) }" class="dot-node-style">
165+
{{ getDictLabel(DICT_TYPE.USER_TYPE, log.userType)[0] }}
166+
</span>
167+
</template>
160168
</el-timeline-item>
161169
</el-timeline>
162170
</el-descriptions-item>
@@ -173,7 +181,7 @@
173181
import * as TradeOrderApi from '@/api/mall/trade/order'
174182
import { floatToFixed2 } from '@/utils'
175183
import { formatDate } from '@/utils/formatTime'
176-
import { DICT_TYPE } from '@/utils/dict'
184+
import { DICT_TYPE, getDictLabel, getDictObj } from '@/utils/dict'
177185
import OrderUpdateRemarkForm from '@/views/mall/trade/order/form/OrderUpdateRemarkForm.vue'
178186
import OrderDeliveryForm from '@/views/mall/trade/order/form/OrderDeliveryForm.vue'
179187
import OrderUpdateAddressForm from '@/views/mall/trade/order/form/OrderUpdateAddressForm.vue'
@@ -184,6 +192,21 @@ defineOptions({ name: 'TradeOrderDetail' })
184192
185193
const message = useMessage() // 消息弹窗
186194
195+
const updateStyles = (type: number) => {
196+
const dict = getDictObj(DICT_TYPE.USER_TYPE, type)
197+
switch (dict?.colorType) {
198+
case 'success':
199+
return '#67C23A'
200+
case 'info':
201+
return '#909399'
202+
case 'warning':
203+
return '#E6A23C'
204+
case 'danger':
205+
return '#F56C6C'
206+
}
207+
return '#409EFF'
208+
}
209+
187210
// 订单详情
188211
const formData = ref<TradeOrderApi.OrderVO>({
189212
orderLog: [] // TODO @puhui999:orderLogs
@@ -267,4 +290,51 @@ onMounted(async () => {
267290
}
268291
}
269292
}
293+
294+
// 时间线样式调整
295+
:deep(.el-timeline) {
296+
margin: 10px 0px 0px 160px;
297+
298+
.el-timeline-item__wrapper {
299+
position: relative;
300+
top: -20px;
301+
302+
.el-timeline-item__timestamp {
303+
position: absolute !important;
304+
top: 10px;
305+
left: -150px;
306+
}
307+
}
308+
309+
.el-timeline-right-content {
310+
display: flex;
311+
align-items: center;
312+
min-height: 30px;
313+
padding: 10px;
314+
background-color: #f7f8fa;
315+
316+
&::before {
317+
content: ''; /* 必须设置 content 属性 */
318+
position: absolute;
319+
top: 10px;
320+
left: 13px; /* 将伪元素水平居中 */
321+
border-width: 8px; /* 调整尖角大小 */
322+
border-style: solid;
323+
border-color: transparent #f7f8fa transparent transparent; /* 尖角颜色,左侧朝向 */
324+
}
325+
}
326+
327+
.dot-node-style {
328+
width: 20px;
329+
height: 20px;
330+
position: absolute;
331+
left: -5px;
332+
display: flex;
333+
justify-content: center;
334+
align-items: center;
335+
border-radius: 50%;
336+
color: #fff;
337+
font-size: 10px;
338+
}
339+
}
270340
</style>

0 commit comments

Comments
 (0)