Detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <template>
  2. <div>
  3. <!-- 加载中 -->
  4. <a-spin :spinning="isLoading" />
  5. <!-- 订单内容 -->
  6. <div v-if="!isLoading" class="order-content">
  7. <!-- 订单进度步骤条 -->
  8. <a-card :bordered="false">
  9. <div class="order-progress" :class="`progress-${progress}`">
  10. <ul>
  11. <li>
  12. <span>下单时间</span>
  13. <div class="tip">{{ record.create_time }}</div>
  14. </li>
  15. <li>
  16. <span>付款</span>
  17. <div
  18. v-if="record.pay_status == PayStatusEnum.SUCCESS.value"
  19. class="tip"
  20. >付款于 {{ record.pay_time }}</div>
  21. </li>
  22. <li>
  23. <span>发货</span>
  24. <div
  25. v-if="record.delivery_status == DeliveryStatusEnum.DELIVERED.value"
  26. class="tip"
  27. >发货于 {{ record.delivery_time }}</div>
  28. </li>
  29. <li>
  30. <span>收货</span>
  31. <div
  32. v-if="record.receipt_status == ReceiptStatusEnum.RECEIVED.value"
  33. class="tip"
  34. >收货于 {{ record.receipt_time }}</div>
  35. </li>
  36. <li>
  37. <span>完成</span>
  38. <div
  39. v-if="record.order_status == OrderStatusEnum.COMPLETED.value"
  40. class="tip"
  41. >完成于 {{ record.receipt_time }}</div>
  42. </li>
  43. </ul>
  44. </div>
  45. </a-card>
  46. <!-- 订单信息 -->
  47. <a-card class="mt-20" :bordered="false">
  48. <!-- 订单操作 -->
  49. <template v-if="record.order_status != OrderStatusEnum.CANCELLED.value">
  50. <div class="ant-descriptions-title">订单操作</div>
  51. <!-- 提示栏 -->
  52. <div class="alerts mt-10 mb-15">
  53. <a-alert
  54. v-if="record.order_status== OrderStatusEnum.APPLY_CANCEL.value"
  55. message="当前买家已付款并申请取消订单,请审核是否同意,如同意则自动退回付款金额(原路退款)并关闭订单。"
  56. banner
  57. />
  58. </div>
  59. <!-- 操作栏 -->
  60. <div class="actions clearfix mt-10">
  61. <div class="action-item" v-if="$auth('/order/detail.updatePrice')">
  62. <a-button
  63. v-if="record.pay_status == PayStatusEnum.PENDING.value"
  64. @click="handleUpdatePrice"
  65. >订单改价</a-button>
  66. </div>
  67. <div class="action-item" v-if="$auth('/order/list/all.deliver')">
  68. <a-button
  69. v-if="(
  70. record.pay_status == PayStatusEnum.SUCCESS.value
  71. && record.delivery_type == DeliveryTypeEnum.EXPRESS.value
  72. && record.delivery_status == DeliveryStatusEnum.NOT_DELIVERED.value
  73. && !inArray(record.order_status, [OrderStatusEnum.CANCELLED.value, OrderStatusEnum.APPLY_CANCEL.value])
  74. )"
  75. type="primary"
  76. @click="handleDelivery"
  77. >发货</a-button>
  78. </div>
  79. <div class="action-item" v-if="$auth('/order/list/all.cancel')">
  80. <a-button
  81. v-if="record.order_status == OrderStatusEnum.APPLY_CANCEL.value"
  82. type="primary"
  83. @click="handleCancel"
  84. >审核取消订单</a-button>
  85. </div>
  86. </div>
  87. <a-divider class="o-divider" />
  88. </template>
  89. <!-- 订单信息 -->
  90. <a-descriptions title="订单信息">
  91. <a-descriptions-item label="订单号">{{ record.order_no }}</a-descriptions-item>
  92. <a-descriptions-item label="实付款金额">¥{{ record.pay_price }}</a-descriptions-item>
  93. <a-descriptions-item label="支付方式">
  94. <a-tag color="green">{{ PayTypeEnum[record.pay_type].name }}</a-tag>
  95. </a-descriptions-item>
  96. <a-descriptions-item label="配送方式">
  97. <a-tag color="green">{{ DeliveryTypeEnum[record.delivery_type].name }}</a-tag>
  98. </a-descriptions-item>
  99. <a-descriptions-item label="运费金额">¥{{ record.express_price }}</a-descriptions-item>
  100. <a-descriptions-item label="订单状态">
  101. <a-tag
  102. :color="renderOrderStatusColor(record.order_status)"
  103. >{{ OrderStatusEnum[record.order_status].name }}</a-tag>
  104. </a-descriptions-item>
  105. <a-descriptions-item label="买家信息">
  106. <a-tooltip>
  107. <template slot="title">会员ID: {{ record.user.user_id }}</template>
  108. <span class="c-p">{{ record.user.nick_name }}</span>
  109. </a-tooltip>
  110. </a-descriptions-item>
  111. <a-descriptions-item label="买家留言">
  112. <strong v-if="record.buyer_remark">{{ record.buyer_remark }}</strong>
  113. <span v-else>--</span>
  114. </a-descriptions-item>
  115. </a-descriptions>
  116. </a-card>
  117. <!-- 商品信息 -->
  118. <a-card class="mt-20" :bordered="false">
  119. <div class="ant-descriptions-title">订单商品</div>
  120. <div class="goods-list">
  121. <a-table
  122. rowKey="order_goods_id"
  123. :columns="goodsColumns"
  124. :dataSource="record.goods"
  125. :pagination="false"
  126. >
  127. <!-- 商品信息 -->
  128. <template slot="goodsInfo" slot-scope="text, item">
  129. <GoodsItem
  130. :data="{
  131. image: item.goods_image,
  132. imageAlt: '商品图片',
  133. title: item.goods_name,
  134. goodsProps: item.goods_props
  135. }"
  136. />
  137. </template>
  138. <!-- 商品编码 -->
  139. <span slot="goods_no" slot-scope="text">{{ text ? text : '--' }}</span>
  140. <!-- 单价 -->
  141. <template slot="goods_price" slot-scope="text, item">
  142. <p :class="{ 'f-through': item.is_user_grade }">¥{{ text }}</p>
  143. <p v-if="item.is_user_grade">
  144. <a-tooltip>
  145. <template slot="title">
  146. <span class="f-13">会员等级折扣价</span>
  147. </template>
  148. <strong>会员价:</strong>
  149. <span>¥{{ item.grade_goods_price }}</span>
  150. </a-tooltip>
  151. </p>
  152. </template>
  153. <!-- 购买数量 -->
  154. <span slot="total_num" slot-scope="text">x{{ text }}</span>
  155. <!-- 商品总价 -->
  156. <span slot="total_price" slot-scope="text">¥{{ text }}</span>
  157. </a-table>
  158. <!-- 订单价格明细 -->
  159. <div class="order-price">
  160. <table class="fl-r">
  161. <tbody>
  162. <tr>
  163. <td>订单总额:</td>
  164. <td>¥{{ record.total_price }}</td>
  165. </tr>
  166. <tr v-if="record.coupon_money > 0">
  167. <td>优惠券抵扣:</td>
  168. <td>-¥{{ record.coupon_money }}</td>
  169. </tr>
  170. <tr v-if="record.points_money > 0">
  171. <td>积分抵扣:</td>
  172. <td>-¥{{ record.points_money }}</td>
  173. </tr>
  174. <tr v-if="record.update_price.value != 0">
  175. <td>商家改价:</td>
  176. <td>{{ record.update_price.symbol }}¥{{ record.update_price.value }}</td>
  177. </tr>
  178. <tr>
  179. <td>运费金额:</td>
  180. <td>+¥{{ record.express_price }}</td>
  181. </tr>
  182. <tr>
  183. <td>实付款金额:</td>
  184. <td>
  185. <strong>¥{{ record.pay_price }}</strong>
  186. </td>
  187. </tr>
  188. </tbody>
  189. </table>
  190. </div>
  191. </div>
  192. </a-card>
  193. <!-- 快递配送 -->
  194. <a-card
  195. v-if="record.delivery_type == DeliveryTypeEnum.EXPRESS.value"
  196. class="mt-20"
  197. :bordered="false"
  198. >
  199. <!-- 收货信息 -->
  200. <a-descriptions title="收货信息">
  201. <a-descriptions-item label="收货人姓名">{{ record.address.name }}</a-descriptions-item>
  202. <a-descriptions-item label="联系电话">{{ record.address.phone }}</a-descriptions-item>
  203. <a-descriptions-item label="收货地区">
  204. {{ record.address.region.province }}
  205. {{ record.address.region.city }}
  206. {{ record.address.region.region }}
  207. </a-descriptions-item>
  208. <a-descriptions-item label="详细地址">{{ record.address.detail }}</a-descriptions-item>
  209. </a-descriptions>
  210. <!-- 发货信息 -->
  211. <template
  212. v-if="(
  213. record.pay_status == PayStatusEnum.SUCCESS.value
  214. && record.delivery_status == DeliveryStatusEnum.DELIVERED.value
  215. && !inArray(record.order_status, [OrderStatusEnum.CANCELLED.value, OrderStatusEnum.APPLY_CANCEL.value])
  216. )"
  217. >
  218. <a-divider class="o-divider" />
  219. <a-descriptions title="发货信息">
  220. <a-descriptions-item label="物流公司">{{ record.express.express_name }}</a-descriptions-item>
  221. <a-descriptions-item label="物流单号">{{ record.express_no }}</a-descriptions-item>
  222. <a-descriptions-item label="发货状态">
  223. <a-tag
  224. :color="record.delivery_status == DeliveryStatusEnum.DELIVERED.value ? 'green' : ''"
  225. >{{ DeliveryStatusEnum[record.delivery_status].name }}</a-tag>
  226. </a-descriptions-item>
  227. <a-descriptions-item label="发货时间">{{ record.delivery_time }}</a-descriptions-item>
  228. </a-descriptions>
  229. </template>
  230. </a-card>
  231. </div>
  232. <DeliveryForm ref="DeliveryForm" @handleSubmit="handleRefresh" />
  233. <CancelForm ref="CancelForm" @handleSubmit="handleRefresh" />
  234. <PriceForm ref="PriceForm" @handleSubmit="handleRefresh" />
  235. </div>
  236. </template>
  237. <script>
  238. import { inArray } from '@/utils/util'
  239. import * as Api from '@/api/order'
  240. import { GoodsItem, UserItem } from '@/components/Table'
  241. import { DeliveryForm, CancelForm, PriceForm } from './modules'
  242. import {
  243. DeliveryStatusEnum,
  244. DeliveryTypeEnum,
  245. OrderSourceEnum,
  246. OrderStatusEnum,
  247. PayStatusEnum,
  248. PayTypeEnum,
  249. ReceiptStatusEnum
  250. } from '@/common/enum/order'
  251. // 商品内容表头
  252. const goodsColumns = [
  253. {
  254. title: '商品信息',
  255. scopedSlots: { customRender: 'goodsInfo' }
  256. },
  257. {
  258. title: '商品编码',
  259. dataIndex: 'goods_no',
  260. scopedSlots: { customRender: 'goods_no' }
  261. },
  262. {
  263. title: '重量(Kg)',
  264. dataIndex: 'goods_weight',
  265. scopedSlots: { customRender: 'goods_weight' }
  266. },
  267. {
  268. title: '单价',
  269. dataIndex: 'goods_price',
  270. scopedSlots: { customRender: 'goods_price' }
  271. },
  272. {
  273. title: '购买数量',
  274. dataIndex: 'total_num',
  275. scopedSlots: { customRender: 'total_num' }
  276. },
  277. {
  278. title: '商品总价',
  279. dataIndex: 'total_price',
  280. scopedSlots: { customRender: 'total_price' }
  281. }
  282. ]
  283. export default {
  284. name: 'Index',
  285. components: {
  286. GoodsItem,
  287. UserItem,
  288. DeliveryForm,
  289. CancelForm,
  290. PriceForm
  291. },
  292. data () {
  293. return {
  294. // 枚举类
  295. DeliveryStatusEnum,
  296. DeliveryTypeEnum,
  297. OrderSourceEnum,
  298. OrderStatusEnum,
  299. PayStatusEnum,
  300. PayTypeEnum,
  301. ReceiptStatusEnum,
  302. // 外部方法
  303. inArray,
  304. // 正在加载
  305. isLoading: true,
  306. // 订单ID
  307. orderId: null,
  308. // 订单详情
  309. record: {},
  310. // 订单步骤位置
  311. progress: 2,
  312. // 商品内容表头
  313. goodsColumns
  314. }
  315. },
  316. created () {
  317. // 记录订单ID
  318. this.orderId = this.$route.query.orderId
  319. // 刷新页面
  320. this.handleRefresh()
  321. },
  322. methods: {
  323. // 刷新页面
  324. handleRefresh () {
  325. // 获取当前记录
  326. this.getDetail()
  327. },
  328. // 获取当前记录
  329. getDetail () {
  330. const { orderId } = this
  331. this.isLoading = true
  332. Api.detail({ orderId })
  333. .then(result => {
  334. // 当前记录
  335. this.record = result.data.detail
  336. // 初始化数据
  337. this.initData()
  338. })
  339. .finally(() => {
  340. this.isLoading = false
  341. })
  342. },
  343. // 初始化数据
  344. initData () {
  345. // 步骤条位置
  346. this.initProgress()
  347. },
  348. // 步骤条位置
  349. initProgress () {
  350. const { record } = this
  351. this.progress = 2
  352. record.pay_status === PayStatusEnum.SUCCESS.value && (this.progress += 1)
  353. record.delivery_status === DeliveryStatusEnum.DELIVERED.value && (this.progress += 1)
  354. record.receipt_status === ReceiptStatusEnum.RECEIVED.value && (this.progress += 1)
  355. },
  356. // 渲染订单状态标签颜色
  357. renderOrderStatusColor (orderStatus) {
  358. const { OrderStatusEnum } = this
  359. const ColorEnum = {
  360. [OrderStatusEnum.NORMAL.value]: '',
  361. [OrderStatusEnum.CANCELLED.value]: 'red',
  362. [OrderStatusEnum.APPLY_CANCEL.value]: 'red',
  363. [OrderStatusEnum.COMPLETED.value]: 'green'
  364. }
  365. return ColorEnum[orderStatus]
  366. },
  367. // 订单发货
  368. handleDelivery () {
  369. const { record } = this
  370. this.$refs.DeliveryForm.show(record)
  371. },
  372. // 审核取消订单
  373. handleCancel () {
  374. const { record } = this
  375. this.$refs.CancelForm.show(record)
  376. },
  377. // 订单改价
  378. handleUpdatePrice () {
  379. const { record } = this
  380. this.$refs.PriceForm.show(record)
  381. }
  382. }
  383. }
  384. </script>
  385. <style lang="less" scoped>
  386. @import '~ant-design-vue/es/style/themes/default.less';
  387. // 订单详情页
  388. .order-content {
  389. margin-bottom: 70px;
  390. /deep/.ant-descriptions-item > span {
  391. vertical-align: middle;
  392. }
  393. // 分割线
  394. .o-divider {
  395. margin-bottom: 32px;
  396. }
  397. // 步骤条
  398. .order-progress {
  399. height: 26px;
  400. line-height: 26px;
  401. background: #f8f8f8;
  402. border-radius: 13px;
  403. font-size: 14px;
  404. text-align: center;
  405. position: relative;
  406. &:before,
  407. &:after {
  408. content: '';
  409. position: absolute;
  410. z-index: 2;
  411. left: 0;
  412. top: 0;
  413. bottom: 0;
  414. border-radius: 13px;
  415. background: @primary-color;
  416. }
  417. &:after {
  418. background: ~`colorPalette('@{primary-color}', 3) `;
  419. z-index: 1;
  420. }
  421. &.progress-1 {
  422. &:before {
  423. width: 0;
  424. }
  425. &:after {
  426. width: 20%;
  427. }
  428. }
  429. &.progress-2 {
  430. &:before {
  431. width: 20%;
  432. }
  433. &:after {
  434. width: 40%;
  435. }
  436. }
  437. &.progress-3 {
  438. &:before {
  439. width: 40%;
  440. }
  441. &:after {
  442. width: 60%;
  443. }
  444. }
  445. &.progress-4 {
  446. &:before {
  447. width: 60%;
  448. }
  449. &:after {
  450. width: 80%;
  451. }
  452. }
  453. &.progress-5 {
  454. &:before {
  455. width: 100%;
  456. }
  457. &:after {
  458. width: 100%;
  459. }
  460. li {
  461. &:nth-child(5) {
  462. color: #fff;
  463. }
  464. }
  465. }
  466. li {
  467. width: 20%;
  468. float: left;
  469. border-radius: 13px;
  470. position: relative;
  471. z-index: 3;
  472. }
  473. .tip {
  474. font-size: 12px;
  475. padding-top: 10px;
  476. color: #8c8c8c;
  477. }
  478. &.progress-1 li:nth-child(1),
  479. &.progress-2 li:nth-child(1),
  480. &.progress-3 li:nth-child(1),
  481. &.progress-4 li:nth-child(1),
  482. &.progress-5 li:nth-child(1) {
  483. color: #fff;
  484. }
  485. &.progress-2 li:nth-child(2),
  486. &.progress-3 li:nth-child(2),
  487. &.progress-4 li:nth-child(2),
  488. &.progress-5 li:nth-child(2) {
  489. color: #fff;
  490. }
  491. &.progress-3 li:nth-child(3),
  492. &.progress-4 li:nth-child(3),
  493. &.progress-5 li:nth-child(3) {
  494. color: #fff;
  495. }
  496. &.progress-4 li:nth-child(4),
  497. &.progress-5 li:nth-child(4) {
  498. color: #fff;
  499. }
  500. }
  501. // 商品列表
  502. .goods-list {
  503. /deep/table {
  504. table-layout: auto;
  505. }
  506. .order-price {
  507. padding: 8px 20px;
  508. text-align: right;
  509. }
  510. }
  511. // 操作栏
  512. .actions {
  513. .action-item {
  514. float: left;
  515. margin-right: 8px;
  516. }
  517. }
  518. }
  519. </style>