Skip to content

Commit dbfabcb

Browse files
YunaiVgitee-org
authored andcommitted
!238 完善订单详情和售后退款 TODO 提到的问题
Merge pull request !238 from puhui999/dev-to-dev
2 parents 1719deb + b363997 commit dbfabcb

File tree

7 files changed

+222
-47
lines changed

7 files changed

+222
-47
lines changed

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

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

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

6263
export interface OrderItemRespVO {

src/config/axios/service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ service.interceptors.response.use(
191191
}
192192
return Promise.reject('error')
193193
} else {
194+
// 前端处理 data 为 null 的情况,进行提示
195+
if (data.msg !== '') {
196+
ElNotification.error({ title: msg })
197+
}
194198
return data
195199
}
196200
},

src/utils/dict.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,33 @@ 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+
for (const dict of dictOptions) {
72+
if (dict.value === value + '') {
6773
return dict
6874
}
69-
})
75+
}
7076
}
7177

7278
/**
7379
* 获得字典数据的文本展示
7480
*
7581
* @param dictType 字典类型
7682
* @param value 字典数据的值
83+
* @return 字典名称
7784
*/
78-
export const getDictLabel = (dictType: string, value: any) => {
85+
export const getDictLabel = (dictType: string, value: any): string => {
7986
const dictOptions: DictDataType[] = getDictOptions(dictType)
8087
const dictLabel = ref('')
8188
dictOptions.forEach((dict: DictDataType) => {
82-
if (dict.value === value) {
89+
if (dict.value === value + '') {
8390
dictLabel.value = dict.label
8491
}
8592
})

src/views/mall/promotion/components/SpuAndSkuList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { SpuProperty } from '@/views/mall/promotion/components/index'
4141
defineOptions({ name: 'PromotionSpuAndSkuList' })
4242
4343
const props = defineProps<{
44-
spuList: T[] // TODO 为了方便兼容后续可能有需要展示多个 spu 的情况暂时保持,如果后续都是只操作一个 spu 的话则可更改为接受一个 spu 或保持
44+
spuList: T[]
4545
ruleConfig: RuleConfig[]
4646
spuPropertyListP: SpuProperty<T>[]
4747
}>()

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

Lines changed: 89 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,12 @@
126126
<el-descriptions-item labelClassName="no-colon">
127127
<el-timeline>
128128
<el-timeline-item
129-
v-for="saleLog in formData.afterSaleLog"
129+
v-for="saleLog in formData.logs"
130130
:key="saleLog.id"
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,28 +166,50 @@
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'
167173
import { isArray } from '@/utils/is'
174+
import { useTagsViewStore } from '@/store/modules/tagsView'
168175
169176
defineOptions({ name: 'TradeAfterSaleDetail' })
170177
171178
const { t } = useI18n() // 国际化
172179
const message = useMessage() // 消息弹窗
173180
const { params } = useRoute() // 查询参数
181+
const { push, currentRoute } = useRouter() // 路由
174182
const formData = ref({
175183
order: {},
176-
afterSaleLog: []
184+
logs: []
177185
})
178186
const updateAuditReasonFormRef = ref() // 拒绝售后表单 Ref
179187
188+
const updateStyles = (type: number) => {
189+
const dict = getDictObj(DICT_TYPE.USER_TYPE, type)
190+
switch (dict?.colorType) {
191+
case 'success':
192+
return '#67C23A'
193+
case 'info':
194+
return '#909399'
195+
case 'warning':
196+
return '#E6A23C'
197+
case 'danger':
198+
return '#F56C6C'
199+
}
200+
return '#409EFF'
201+
}
202+
180203
/** 获得详情 */
181204
const getDetail = async () => {
182205
const id = params.orderId as unknown as number
183206
if (id) {
184-
formData.value = await AfterSaleApi.getAfterSale(id)
207+
const res = await AfterSaleApi.getAfterSale(id)
208+
// 没有表单信息则关闭页面返回
209+
if (res === null) {
210+
close()
211+
}
212+
formData.value = res
185213
}
186214
}
187215
@@ -240,7 +268,12 @@ const imagePreview = (args) => {
240268
urlList
241269
})
242270
}
243-
271+
const { delView } = useTagsViewStore() // 视图操作
272+
/** 关闭 tag */
273+
const close = () => {
274+
delView(unref(currentRoute))
275+
push({ name: 'TradeAfterSale' })
276+
}
244277
onMounted(async () => {
245278
await getDetail()
246279
})
@@ -277,4 +310,51 @@ onMounted(async () => {
277310
}
278311
}
279312
}
313+
314+
// 时间线样式调整
315+
:deep(.el-timeline) {
316+
margin: 10px 0px 0px 160px;
317+
318+
.el-timeline-item__wrapper {
319+
position: relative;
320+
top: -20px;
321+
322+
.el-timeline-item__timestamp {
323+
position: absolute !important;
324+
top: 10px;
325+
left: -150px;
326+
}
327+
}
328+
329+
.el-timeline-right-content {
330+
display: flex;
331+
align-items: center;
332+
min-height: 30px;
333+
padding: 10px;
334+
background-color: #f7f8fa;
335+
336+
&::before {
337+
content: '';
338+
position: absolute;
339+
top: 10px;
340+
left: 13px;
341+
border-width: 8px; /* 调整尖角大小 */
342+
border-style: solid;
343+
border-color: transparent #f7f8fa transparent transparent; /* 尖角颜色,左侧朝向 */
344+
}
345+
}
346+
347+
.dot-node-style {
348+
width: 20px;
349+
height: 20px;
350+
position: absolute;
351+
left: -5px;
352+
display: flex;
353+
justify-content: center;
354+
align-items: center;
355+
border-radius: 50%;
356+
color: #fff;
357+
font-size: 10px;
358+
}
359+
}
280360
</style>

0 commit comments

Comments
 (0)