index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <ContentWrap>
  3. <!-- 订单信息 -->
  4. <el-descriptions title="订单信息">
  5. <el-descriptions-item label="订单号: ">{{ formData.orderNo }}</el-descriptions-item>
  6. <el-descriptions-item label="配送方式: ">
  7. <dict-tag :type="DICT_TYPE.TRADE_DELIVERY_TYPE" :value="formData.order.deliveryType" />
  8. </el-descriptions-item>
  9. <el-descriptions-item label="订单类型: ">
  10. <dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="formData.order.type" />
  11. </el-descriptions-item>
  12. <el-descriptions-item label="收货人: ">
  13. {{ formData.order.receiverName }}
  14. </el-descriptions-item>
  15. <el-descriptions-item label="买家留言: ">
  16. {{ formData.order.userRemark }}
  17. </el-descriptions-item>
  18. <el-descriptions-item label="订单来源: ">
  19. <dict-tag :type="DICT_TYPE.TERMINAL" :value="formData.order.terminal" />
  20. </el-descriptions-item>
  21. <el-descriptions-item label="联系电话: ">
  22. {{ formData.order.receiverMobile }}
  23. </el-descriptions-item>
  24. <el-descriptions-item label="商家备注: ">{{ formData.order.remark }}</el-descriptions-item>
  25. <el-descriptions-item label="支付单号: ">
  26. {{ formData.order.payOrderId }}
  27. </el-descriptions-item>
  28. <el-descriptions-item label="付款方式: ">
  29. <dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="formData.order.payChannelCode" />
  30. </el-descriptions-item>
  31. <el-descriptions-item label="买家: ">{{ formData?.user?.nickname }}</el-descriptions-item>
  32. </el-descriptions>
  33. <!-- 售后信息 -->
  34. <el-descriptions title="售后信息">
  35. <el-descriptions-item label="退款编号: ">{{ formData.no }}</el-descriptions-item>
  36. <el-descriptions-item label="申请时间: ">
  37. {{ formatDate(formData.auditTime) }}
  38. </el-descriptions-item>
  39. <el-descriptions-item label="售后类型: ">
  40. <dict-tag :type="DICT_TYPE.TRADE_AFTER_SALE_TYPE" :value="formData.type" />
  41. </el-descriptions-item>
  42. <el-descriptions-item label="售后方式: ">
  43. <dict-tag :type="DICT_TYPE.TRADE_AFTER_SALE_WAY" :value="formData.way" />
  44. </el-descriptions-item>
  45. <el-descriptions-item label="退款金额: ">
  46. {{ fenToYuan(formData.refundPrice) }}
  47. </el-descriptions-item>
  48. <el-descriptions-item label="退款原因: ">{{ formData.applyReason }}</el-descriptions-item>
  49. <el-descriptions-item label="补充描述: ">
  50. {{ formData.applyDescription }}
  51. </el-descriptions-item>
  52. <el-descriptions-item label="凭证图片: ">
  53. <el-image
  54. v-for="(item, index) in formData.applyPicUrls"
  55. :key="index"
  56. :src="item.url"
  57. class="mr-10px h-60px w-60px"
  58. @click="imagePreview(formData.applyPicUrls)"
  59. />
  60. </el-descriptions-item>
  61. </el-descriptions>
  62. <!-- 退款状态 -->
  63. <el-descriptions :column="1" title="退款状态">
  64. <el-descriptions-item label="退款状态: ">
  65. <dict-tag :type="DICT_TYPE.TRADE_AFTER_SALE_STATUS" :value="formData.status" />
  66. </el-descriptions-item>
  67. <el-descriptions-item label-class-name="no-colon">
  68. <el-button v-if="formData.status === 10" type="primary" @click="agree">同意售后</el-button>
  69. <el-button v-if="formData.status === 10" type="primary" @click="disagree">
  70. 拒绝售后
  71. </el-button>
  72. <el-button v-if="formData.status === 30" type="primary" @click="receive">
  73. 确认收货
  74. </el-button>
  75. <el-button v-if="formData.status === 30" type="primary" @click="refuse">拒绝收货</el-button>
  76. <el-button v-if="formData.status === 40" type="primary" @click="refund">确认退款</el-button>
  77. </el-descriptions-item>
  78. <el-descriptions-item>
  79. <template #label><span style="color: red">提醒: </span></template>
  80. 如果未发货,请点击同意退款给买家。<br />
  81. 如果实际已发货,请主动与买家联系。<br />
  82. 如果订单整体退款后,优惠券和余额会退还给买家.
  83. </el-descriptions-item>
  84. </el-descriptions>
  85. <!-- 商品信息 -->
  86. <el-descriptions title="商品信息">
  87. <el-descriptions-item labelClassName="no-colon">
  88. <el-row :gutter="20">
  89. <el-col :span="15">
  90. <el-table :data="[formData.orderItem]" border>
  91. <el-table-column label="商品" prop="spuName" width="auto">
  92. <template #default="{ row }">
  93. {{ row.spuName }}
  94. <el-tag v-for="property in row.properties" :key="property.propertyId">
  95. {{ property.propertyName }}: {{ property.valueName }}
  96. </el-tag>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="商品原价" prop="price" width="150">
  100. <template #default="{ row }">{{ fenToYuan(row.price) }} 元</template>
  101. </el-table-column>
  102. <el-table-column label="数量" prop="count" width="100" />
  103. <el-table-column label="合计" prop="payPrice" width="150">
  104. <template #default="{ row }">{{ fenToYuan(row.payPrice) }} 元</template>
  105. </el-table-column>
  106. </el-table>
  107. </el-col>
  108. <el-col :span="10" />
  109. </el-row>
  110. </el-descriptions-item>
  111. </el-descriptions>
  112. <!-- 操作日志 -->
  113. <el-descriptions title="售后日志">
  114. <el-descriptions-item labelClassName="no-colon">
  115. <el-timeline>
  116. <el-timeline-item
  117. v-for="saleLog in formData.logs"
  118. :key="saleLog.id"
  119. :timestamp="formatDate(saleLog.createTime)"
  120. placement="top"
  121. >
  122. <div class="el-timeline-right-content">
  123. <span>{{ saleLog.content }}</span>
  124. </div>
  125. <template #dot>
  126. <span
  127. :style="{ backgroundColor: getUserTypeColor(saleLog.userType) }"
  128. class="dot-node-style"
  129. >
  130. {{ getDictLabel(DICT_TYPE.USER_TYPE, saleLog.userType)[0] || '系' }}
  131. </span>
  132. </template>
  133. </el-timeline-item>
  134. </el-timeline>
  135. </el-descriptions-item>
  136. </el-descriptions>
  137. </ContentWrap>
  138. <!-- 各种操作的弹窗 -->
  139. <UpdateAuditReasonForm ref="updateAuditReasonFormRef" @success="getDetail" />
  140. </template>
  141. <script lang="ts" setup>
  142. import * as AfterSaleApi from '@/api/mall/trade/afterSale/index'
  143. import { fenToYuan } from '@/utils'
  144. import { DICT_TYPE, getDictLabel, getDictObj } from '@/utils/dict'
  145. import { formatDate } from '@/utils/formatTime'
  146. import UpdateAuditReasonForm from '@/views/mall/trade/afterSale/form/AfterSaleDisagreeForm.vue'
  147. import { createImageViewer } from '@/components/ImageViewer'
  148. import { isArray } from '@/utils/is'
  149. import { useTagsViewStore } from '@/store/modules/tagsView'
  150. defineOptions({ name: 'TradeAfterSaleDetail' })
  151. const { t } = useI18n() // 国际化
  152. const message = useMessage() // 消息弹窗
  153. const { params } = useRoute() // 查询参数
  154. const { push, currentRoute } = useRouter() // 路由
  155. const formData = ref({
  156. order: {},
  157. logs: []
  158. })
  159. const updateAuditReasonFormRef = ref() // 拒绝售后表单 Ref
  160. /** 获得 userType 颜色 */
  161. const getUserTypeColor = (type: number) => {
  162. const dict = getDictObj(DICT_TYPE.USER_TYPE, type)
  163. switch (dict?.colorType) {
  164. case 'success':
  165. return '#67C23A'
  166. case 'info':
  167. return '#909399'
  168. case 'warning':
  169. return '#E6A23C'
  170. case 'danger':
  171. return '#F56C6C'
  172. }
  173. return '#409EFF'
  174. }
  175. /** 获得详情 */
  176. const getDetail = async () => {
  177. const id = params.id as unknown as number
  178. if (id) {
  179. const res = await AfterSaleApi.getAfterSale(id)
  180. // 没有表单信息则关闭页面返回
  181. if (res == null) {
  182. message.notifyError('售后订单不存在')
  183. close()
  184. }
  185. formData.value = res
  186. }
  187. }
  188. /** 同意售后 */
  189. const agree = async () => {
  190. try {
  191. // 二次确认
  192. await message.confirm('是否同意售后?')
  193. await AfterSaleApi.agree(formData.value.id)
  194. // 提示成功
  195. message.success(t('common.success'))
  196. await getDetail()
  197. } catch {}
  198. }
  199. /** 拒绝售后 */
  200. const disagree = async () => {
  201. updateAuditReasonFormRef.value?.open(formData.value)
  202. }
  203. /** 确认收货 */
  204. const receive = async () => {
  205. try {
  206. // 二次确认
  207. await message.confirm('是否确认收货?')
  208. await AfterSaleApi.receive(formData.value.id)
  209. // 提示成功
  210. message.success(t('common.success'))
  211. await getDetail()
  212. } catch {}
  213. }
  214. /** 拒绝收货 */
  215. const refuse = async () => {
  216. try {
  217. // 二次确认
  218. await message.confirm('是否拒绝收货?')
  219. await AfterSaleApi.refuse(formData.value.id)
  220. // 提示成功
  221. message.success(t('common.success'))
  222. await getDetail()
  223. } catch {}
  224. }
  225. /** 确认退款 */
  226. const refund = async () => {
  227. try {
  228. // 二次确认
  229. await message.confirm('是否确认退款?')
  230. await AfterSaleApi.refund(formData.value.id)
  231. // 提示成功
  232. message.success(t('common.success'))
  233. await getDetail()
  234. } catch {}
  235. }
  236. /** 图片预览 */
  237. const imagePreview = (args) => {
  238. const urlList = []
  239. if (isArray(args)) {
  240. args.forEach((item) => {
  241. urlList.push(item.url)
  242. })
  243. } else {
  244. urlList.push(args)
  245. }
  246. createImageViewer({
  247. urlList
  248. })
  249. }
  250. const { delView } = useTagsViewStore() // 视图操作
  251. /** 关闭 tag */
  252. const close = () => {
  253. delView(unref(currentRoute))
  254. push({ name: 'TradeAfterSale' })
  255. }
  256. onMounted(async () => {
  257. await getDetail()
  258. })
  259. </script>
  260. <style lang="scss" scoped>
  261. :deep(.el-descriptions) {
  262. &:not(:nth-child(1)) {
  263. margin-top: 20px;
  264. }
  265. .el-descriptions__title {
  266. display: flex;
  267. align-items: center;
  268. &::before {
  269. display: inline-block;
  270. width: 3px;
  271. height: 20px;
  272. margin-right: 10px;
  273. background-color: #409eff;
  274. content: '';
  275. }
  276. }
  277. .el-descriptions-item__container {
  278. margin: 0 10px;
  279. .no-colon {
  280. margin: 0;
  281. &::after {
  282. content: '';
  283. }
  284. }
  285. }
  286. }
  287. // 时间线样式调整
  288. :deep(.el-timeline) {
  289. margin: 10px 0 0 160px;
  290. .el-timeline-item__wrapper {
  291. position: relative;
  292. top: -20px;
  293. .el-timeline-item__timestamp {
  294. position: absolute !important;
  295. top: 10px;
  296. left: -150px;
  297. }
  298. }
  299. .el-timeline-right-content {
  300. display: flex;
  301. align-items: center;
  302. min-height: 30px;
  303. padding: 10px;
  304. background-color: #f7f8fa;
  305. &::before {
  306. position: absolute;
  307. top: 10px;
  308. left: 13px;
  309. border-color: transparent #f7f8fa transparent transparent; /* 尖角颜色,左侧朝向 */
  310. border-style: solid;
  311. border-width: 8px; /* 调整尖角大小 */
  312. content: '';
  313. }
  314. }
  315. .dot-node-style {
  316. position: absolute;
  317. left: -5px;
  318. display: flex;
  319. width: 20px;
  320. height: 20px;
  321. font-size: 10px;
  322. color: #fff;
  323. border-radius: 50%;
  324. justify-content: center;
  325. align-items: center;
  326. }
  327. }
  328. </style>