index.vue 11 KB

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