index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <ContentWrap>
  3. <!-- 订单信息 -->
  4. <el-descriptions title="订单信息">
  5. <el-descriptions-item label="订单号: ">{{ formData.no }}</el-descriptions-item>
  6. <el-descriptions-item label="买家: ">{{ formData?.user?.nickname }}</el-descriptions-item>
  7. <el-descriptions-item label="订单类型: ">
  8. <dict-tag :type="DICT_TYPE.TRADE_ORDER_TYPE" :value="formData.type!" />
  9. </el-descriptions-item>
  10. <el-descriptions-item label="订单来源: ">
  11. <dict-tag :type="DICT_TYPE.TERMINAL" :value="formData.terminal!" />
  12. </el-descriptions-item>
  13. <el-descriptions-item label="买家留言: ">{{ formData.userRemark }}</el-descriptions-item>
  14. <el-descriptions-item label="商家备注: ">{{ formData.remark }}</el-descriptions-item>
  15. <el-descriptions-item label="支付单号: ">{{ formData.payOrderId }}</el-descriptions-item>
  16. <el-descriptions-item label="付款方式: ">
  17. <dict-tag :type="DICT_TYPE.PAY_CHANNEL_CODE" :value="formData.payChannelCode!" />
  18. </el-descriptions-item>
  19. <el-descriptions-item label="推广用户: " v-if="formData.brokerageUser">
  20. {{ formData.brokerageUser?.nickname }}
  21. </el-descriptions-item>
  22. </el-descriptions>
  23. <!-- 订单状态 -->
  24. <el-descriptions :column="1" title="订单状态">
  25. <el-descriptions-item label="订单状态: ">
  26. <dict-tag :type="DICT_TYPE.TRADE_ORDER_STATUS" :value="formData.status!" />
  27. </el-descriptions-item>
  28. <el-descriptions-item label-class-name="no-colon">
  29. <el-button v-if="formData.status! === 0" type="primary" @click="updatePrice">
  30. 调整价格
  31. </el-button>
  32. <el-button type="primary" @click="remark">备注</el-button>
  33. <el-button
  34. v-if="formData.status! === 10 && formData.deliveryType === DeliveryTypeEnum.EXPRESS.type"
  35. type="primary"
  36. @click="delivery"
  37. >
  38. 发货
  39. </el-button>
  40. <el-button
  41. v-if="formData.status! === 10 && formData.deliveryType === DeliveryTypeEnum.EXPRESS.type"
  42. type="primary"
  43. @click="updateAddress"
  44. >
  45. 修改地址
  46. </el-button>
  47. </el-descriptions-item>
  48. <el-descriptions-item>
  49. <template #label><span style="color: red">提醒: </span></template>
  50. 买家付款成功后,货款将直接进入您的商户号(微信、支付宝)<br />
  51. 请及时关注你发出的包裹状态,确保可以配送至买家手中 <br />
  52. 如果买家表示没收到货或货物有问题,请及时联系买家处理,友好协商
  53. </el-descriptions-item>
  54. </el-descriptions>
  55. <!-- 商品信息 -->
  56. <el-descriptions title="商品信息">
  57. <el-descriptions-item labelClassName="no-colon">
  58. <el-row :gutter="20">
  59. <el-col :span="15">
  60. <el-table :data="formData.items" border>
  61. <el-table-column label="商品" prop="spuName" width="auto">
  62. <template #default="{ row }">
  63. {{ row.spuName }}
  64. <el-tag v-for="property in row.properties" :key="property.propertyId">
  65. {{ property.propertyName }}: {{ property.valueName }}
  66. </el-tag>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="商品原价" prop="price" width="150">
  70. <template #default="{ row }">{{ fenToYuan(row.price) }}元</template>
  71. </el-table-column>
  72. <el-table-column label="数量" prop="count" width="100" />
  73. <el-table-column label="合计" prop="payPrice" width="150">
  74. <template #default="{ row }">{{ fenToYuan(row.payPrice) }}元</template>
  75. </el-table-column>
  76. <el-table-column label="售后状态" prop="afterSaleStatus" width="120">
  77. <template #default="{ row }">
  78. <dict-tag
  79. :type="DICT_TYPE.TRADE_ORDER_ITEM_AFTER_SALE_STATUS"
  80. :value="row.afterSaleStatus"
  81. />
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. </el-col>
  86. <el-col :span="10" />
  87. </el-row>
  88. </el-descriptions-item>
  89. </el-descriptions>
  90. <el-descriptions :column="4">
  91. <!-- 第一层 -->
  92. <el-descriptions-item label="商品总额: ">
  93. {{ fenToYuan(formData.totalPrice!) }} 元
  94. </el-descriptions-item>
  95. <el-descriptions-item label="运费金额: ">
  96. {{ fenToYuan(formData.deliveryPrice!) }} 元
  97. </el-descriptions-item>
  98. <el-descriptions-item label="订单调价: ">
  99. {{ fenToYuan(formData.adjustPrice!) }} 元
  100. </el-descriptions-item>
  101. <el-descriptions-item v-for="item in 1" :key="item" label-class-name="no-colon" />
  102. <!-- 第二层 -->
  103. <el-descriptions-item>
  104. <template #label><span style="color: red">优惠劵优惠: </span></template>
  105. {{ fenToYuan(formData.couponPrice!) }} 元
  106. </el-descriptions-item>
  107. <el-descriptions-item>
  108. <template #label><span style="color: red">VIP 优惠: </span></template>
  109. {{ fenToYuan(formData.vipPrice!) }} 元
  110. </el-descriptions-item>
  111. <el-descriptions-item>
  112. <template #label><span style="color: red">活动优惠: </span></template>
  113. {{ fenToYuan(formData.discountPrice!) }} 元
  114. </el-descriptions-item>
  115. <el-descriptions-item>
  116. <template #label><span style="color: red">积分抵扣: </span></template>
  117. {{ fenToYuan(formData.pointPrice!) }} 元
  118. </el-descriptions-item>
  119. <!-- 第三层 -->
  120. <el-descriptions-item v-for="item in 3" :key="item" label-class-name="no-colon" />
  121. <el-descriptions-item label="应付金额: ">
  122. {{ fenToYuan(formData.payPrice!) }} 元
  123. </el-descriptions-item>
  124. </el-descriptions>
  125. <!-- 物流信息 -->
  126. <el-descriptions :column="4" title="收货信息">
  127. <el-descriptions-item label="配送方式: ">
  128. <dict-tag :type="DICT_TYPE.TRADE_DELIVERY_TYPE" :value="formData.deliveryType!" />
  129. </el-descriptions-item>
  130. <el-descriptions-item label="收货人: ">{{ formData.receiverName }}</el-descriptions-item>
  131. <el-descriptions-item label="联系电话: ">{{ formData.receiverMobile }}</el-descriptions-item>
  132. <!-- 快递配送 -->
  133. <div v-if="formData.deliveryType === DeliveryTypeEnum.EXPRESS.type">
  134. <el-descriptions-item label="收货地址: " v-if="formData.receiverDetailAddress">
  135. {{ formData.receiverAreaName }} {{ formData.receiverDetailAddress }}
  136. <el-link
  137. v-clipboard:copy="formData.receiverAreaName + ' ' + formData.receiverDetailAddress"
  138. v-clipboard:success="clipboardSuccess"
  139. icon="ep:document-copy"
  140. type="primary"
  141. />
  142. </el-descriptions-item>
  143. <el-descriptions-item label="物流公司: " v-if="formData.logisticsId">
  144. {{ deliveryExpressList.find((item) => item.id === formData.logisticsId)?.name }}
  145. </el-descriptions-item>
  146. <el-descriptions-item label="运单号: " v-if="formData.logisticsId">
  147. {{ formData.logisticsNo }}
  148. </el-descriptions-item>
  149. <el-descriptions-item label="发货时间: " v-if="formatDate.deliveryTime">
  150. {{ formatDate(formData.deliveryTime) }}
  151. </el-descriptions-item>
  152. <el-descriptions-item v-for="item in 2" :key="item" label-class-name="no-colon" />
  153. <el-descriptions-item label="物流详情: " v-if="expressTrackList.length > 0">
  154. <el-timeline>
  155. <el-timeline-item
  156. v-for="(express, index) in expressTrackList"
  157. :key="index"
  158. :timestamp="formatDate(express.time)"
  159. >
  160. {{ express.content }}
  161. </el-timeline-item>
  162. </el-timeline>
  163. </el-descriptions-item>
  164. </div>
  165. <!-- 自提门店 -->
  166. <div v-if="formData.deliveryType === DeliveryTypeEnum.PICK_UP.type">
  167. <el-descriptions-item label="自提门店: " v-if="formData.pickUpStoreId">
  168. {{ pickUpStore.name }}
  169. </el-descriptions-item>
  170. </div>
  171. </el-descriptions>
  172. <!-- 订单日志 -->
  173. <el-descriptions title="订单操作日志">
  174. <el-descriptions-item labelClassName="no-colon">
  175. <el-timeline>
  176. <el-timeline-item
  177. v-for="(log, index) in formData.logs"
  178. :key="index"
  179. :timestamp="formatDate(log.createTime!)"
  180. placement="top"
  181. >
  182. <div class="el-timeline-right-content">
  183. {{ log.content }}
  184. </div>
  185. <template #dot>
  186. <span
  187. :style="{ backgroundColor: getUserTypeColor(log.userType!) }"
  188. class="dot-node-style"
  189. >
  190. {{ getDictLabel(DICT_TYPE.USER_TYPE, log.userType)[0] }}
  191. </span>
  192. </template>
  193. </el-timeline-item>
  194. </el-timeline>
  195. </el-descriptions-item>
  196. </el-descriptions>
  197. </ContentWrap>
  198. <!-- 各种操作的弹窗 -->
  199. <OrderDeliveryForm ref="deliveryFormRef" @success="getDetail" />
  200. <OrderUpdateRemarkForm ref="updateRemarkForm" @success="getDetail" />
  201. <OrderUpdateAddressForm ref="updateAddressFormRef" @success="getDetail" />
  202. <OrderUpdatePriceForm ref="updatePriceFormRef" @success="getDetail" />
  203. </template>
  204. <script lang="ts" setup>
  205. import * as TradeOrderApi from '@/api/mall/trade/order'
  206. import { fenToYuan } from '@/utils'
  207. import { formatDate } from '@/utils/formatTime'
  208. import { DICT_TYPE, getDictLabel, getDictObj } from '@/utils/dict'
  209. import OrderUpdateRemarkForm from '@/views/mall/trade/order/form/OrderUpdateRemarkForm.vue'
  210. import OrderDeliveryForm from '@/views/mall/trade/order/form/OrderDeliveryForm.vue'
  211. import OrderUpdateAddressForm from '@/views/mall/trade/order/form/OrderUpdateAddressForm.vue'
  212. import OrderUpdatePriceForm from '@/views/mall/trade/order/form/OrderUpdatePriceForm.vue'
  213. import * as DeliveryExpressApi from '@/api/mall/trade/delivery/express'
  214. import { useTagsViewStore } from '@/store/modules/tagsView'
  215. import { DeliveryTypeEnum } from '@/utils/constants'
  216. import * as DeliveryPickUpStoreApi from '@/api/mall/trade/delivery/pickUpStore'
  217. defineOptions({ name: 'TradeOrderDetail' })
  218. const message = useMessage() // 消息弹窗
  219. /** 获得 userType 颜色 */
  220. const getUserTypeColor = (type: number) => {
  221. const dict = getDictObj(DICT_TYPE.USER_TYPE, type)
  222. switch (dict?.colorType) {
  223. case 'success':
  224. return '#67C23A'
  225. case 'info':
  226. return '#909399'
  227. case 'warning':
  228. return '#E6A23C'
  229. case 'danger':
  230. return '#F56C6C'
  231. }
  232. return '#409EFF'
  233. }
  234. // 订单详情
  235. const formData = ref<TradeOrderApi.OrderVO>({
  236. logs: []
  237. })
  238. /** 各种操作 */
  239. const updateRemarkForm = ref() // 订单备注表单 Ref
  240. const remark = () => {
  241. updateRemarkForm.value?.open(formData.value)
  242. }
  243. const deliveryFormRef = ref() // 发货表单 Ref
  244. const delivery = () => {
  245. deliveryFormRef.value?.open(formData.value)
  246. }
  247. const updateAddressFormRef = ref() // 收货地址表单 Ref
  248. const updateAddress = () => {
  249. updateAddressFormRef.value?.open(formData.value)
  250. }
  251. const updatePriceFormRef = ref() // 订单调价表单 Ref
  252. const updatePrice = () => {
  253. updatePriceFormRef.value?.open(formData.value)
  254. }
  255. /** 获得详情 */
  256. const { params } = useRoute() // 查询参数
  257. const getDetail = async () => {
  258. const id = params.id as unknown as number
  259. if (id) {
  260. const res = (await TradeOrderApi.getOrder(id)) as TradeOrderApi.OrderVO
  261. // 没有表单信息则关闭页面返回
  262. if (!res) {
  263. message.error('交易订单不存在')
  264. close()
  265. }
  266. formData.value = res
  267. }
  268. }
  269. /** 关闭 tag */
  270. const { delView } = useTagsViewStore() // 视图操作
  271. const { push, currentRoute } = useRouter() // 路由
  272. const close = () => {
  273. delView(unref(currentRoute))
  274. push({ name: 'TradeOrder' })
  275. }
  276. /** 复制 */
  277. const clipboardSuccess = () => {
  278. message.success('复制成功')
  279. }
  280. /** 初始化 **/
  281. const deliveryExpressList = ref([]) // 物流公司
  282. const expressTrackList = ref([]) // 物流详情
  283. const pickUpStore = ref({}) // 自提门店
  284. onMounted(async () => {
  285. await getDetail()
  286. // 如果配送方式为快递,则查询物流公司
  287. if (formData.value.deliveryType === DeliveryTypeEnum.EXPRESS.type) {
  288. deliveryExpressList.value = await DeliveryExpressApi.getSimpleDeliveryExpressList()
  289. if (form.value.logisticsId) {
  290. expressTrackList.value = await TradeOrderApi.getExpressTrackList(formData.value.id!)
  291. }
  292. } else if (formData.value.deliveryType === DeliveryTypeEnum.PICK_UP.type) {
  293. pickUpStore.value = await DeliveryPickUpStoreApi.getDeliveryPickUpStore(
  294. formData.value.pickUpStoreId
  295. )
  296. }
  297. })
  298. </script>
  299. <style lang="scss" scoped>
  300. :deep(.el-descriptions) {
  301. &:not(:nth-child(1)) {
  302. margin-top: 20px;
  303. }
  304. .el-descriptions__title {
  305. display: flex;
  306. align-items: center;
  307. &::before {
  308. display: inline-block;
  309. width: 3px;
  310. height: 20px;
  311. margin-right: 10px;
  312. background-color: #409eff;
  313. content: '';
  314. }
  315. }
  316. .el-descriptions-item__container {
  317. margin: 0 10px;
  318. .no-colon {
  319. margin: 0;
  320. &::after {
  321. content: '';
  322. }
  323. }
  324. }
  325. }
  326. // 时间线样式调整
  327. :deep(.el-timeline) {
  328. margin: 10px 0 0 160px;
  329. .el-timeline-item__wrapper {
  330. position: relative;
  331. top: -20px;
  332. .el-timeline-item__timestamp {
  333. position: absolute !important;
  334. top: 10px;
  335. left: -150px;
  336. }
  337. }
  338. .el-timeline-right-content {
  339. display: flex;
  340. align-items: center;
  341. min-height: 30px;
  342. padding: 10px;
  343. background-color: #f7f8fa;
  344. &::before {
  345. content: ''; /* 必须设置 content 属性 */
  346. position: absolute;
  347. top: 10px;
  348. left: 13px; /* 将伪元素水平居中 */
  349. border-width: 8px; /* 调整尖角大小 */
  350. border-style: solid;
  351. border-color: transparent #f7f8fa transparent transparent; /* 尖角颜色,左侧朝向 */
  352. }
  353. }
  354. .dot-node-style {
  355. width: 20px;
  356. height: 20px;
  357. position: absolute;
  358. left: -5px;
  359. display: flex;
  360. justify-content: center;
  361. align-items: center;
  362. border-radius: 50%;
  363. color: #fff;
  364. font-size: 10px;
  365. }
  366. }
  367. </style>