detail_orderDetail.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div id="form-1">
  3. <!-- 订单详情 -->
  4. <el-row>
  5. <el-col :span="24" class="top-btn">
  6. <el-button type="primary" size="mini" @click="toBack()">返回</el-button>
  7. </el-col>
  8. <el-col
  9. :span="24"
  10. class="main animate__animated animate__backInRight"
  11. v-loading="loadings"
  12. element-loading-text="拼命加载中"
  13. element-loading-spinner="el-icon-loading"
  14. >
  15. <el-tabs type="border-card">
  16. <el-tab-pane label="订单详情">
  17. <card-1 :address="address" :list="list" :pay="pay" :form="form" :total_detail="total_detail" :shop="shop"></card-1>
  18. </el-tab-pane>
  19. <el-tab-pane label="发货信息">
  20. <card-2
  21. :transport="transport"
  22. :list="list"
  23. :address="address"
  24. :form="form"
  25. :activities="activities"
  26. :shop_transport_typeList="shop_transport_typeList"
  27. :transport_typeList="transport_typeList"
  28. @querySearch="querySearch"
  29. @search="search"
  30. ></card-2>
  31. </el-tab-pane>
  32. </el-tabs>
  33. </el-col>
  34. </el-row>
  35. </div>
  36. </template>
  37. <script>
  38. const _ = require('lodash');
  39. const moment = require('moment');
  40. import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
  41. const { mapActions } = createNamespacedHelpers('orderDetail');
  42. const { mapActions: dictData } = createNamespacedHelpers('dictData');
  43. const { mapActions: sot } = createNamespacedHelpers('sot');
  44. export default {
  45. name: 'form-1',
  46. props: { id: { type: String } },
  47. components: {
  48. card1: () => import('./parts/card-1.vue'),
  49. card2: () => import('./parts/card-2.vue'),
  50. },
  51. data: function () {
  52. return {
  53. loadings: true,
  54. form: {},
  55. // 地址
  56. address: {},
  57. // 实付金额
  58. total_detail: [],
  59. // 商铺
  60. shop: {},
  61. // 运单号
  62. transport: [],
  63. pay: {},
  64. // 商品列表
  65. list: [],
  66. activities: [],
  67. // 订单状态
  68. order_processList: [],
  69. // 快递公司
  70. shop_transport_typeList: [],
  71. // 快递类型
  72. transport_typeList: [],
  73. };
  74. },
  75. async created() {
  76. await this.searchOther();
  77. await this.search();
  78. },
  79. methods: {
  80. ...dictData({ dictQuery: 'query' }),
  81. ...sot({ sotCreate: 'create' }),
  82. ...mapActions(['query', 'fetch', 'create', 'update']),
  83. // 查询
  84. async search() {
  85. let res;
  86. res = await this.fetch(this.id);
  87. if (this.$checkRes(res)) {
  88. let name = this.transport_typeList.find((i) => i.value == res.data.transport_type);
  89. if (name) res.data.transport_type_name = name.label;
  90. if (res.data.transport_type == undefined) res.data.transport_type = '0';
  91. this.$set(this, `form`, res.data);
  92. // 地址
  93. this.$set(this, `address`, res.data.address);
  94. this.$set(this, `shop`, res.data.shop);
  95. // 商品
  96. this.$set(this, `list`, res.data.goods);
  97. // 应付金额
  98. this.$set(this, `total_detail`, res.data.total_detail);
  99. this.$set(this, `pay`, res.data.order.pay);
  100. if (res.data.transport != undefined || res.data.transport.length > 0) {
  101. for (const p1 of res.data.transport) {
  102. if (p1.goods) {
  103. for (const p2 of p1.goods) {
  104. let goods = this.form.goods.find((i) => i.id == p2.goods_id);
  105. if (goods) p2.goods_name = goods.goods.name + ',' + goods.name;
  106. }
  107. }
  108. let arr = await this.dictQuery({ code: 'transport_company', value: p1.shop_transport_type });
  109. if (this.$checkRes(arr)) {
  110. let type = arr.data.find((i) => i.value == p1.shop_transport_type);
  111. if (type) {
  112. p1.shop_transport_name = type.label;
  113. this.querySearch(type.label);
  114. }
  115. }
  116. }
  117. this.$set(this, `transport`, res.data.transport);
  118. let info = { id: this.id };
  119. res = await this.sotCreate(info);
  120. if (this.$checkRes(res)) {
  121. if (res.errcode == '0') this.$set(this, `activities`, res.data);
  122. }
  123. }
  124. }
  125. this.loadings = false;
  126. },
  127. async querySearch(value) {
  128. let res = await this.dictQuery({ code: 'transport_company', label: value });
  129. if (this.$checkRes(res)) this.$set(this, 'shop_transport_typeList', res.data);
  130. },
  131. // 返回
  132. toBack() {
  133. this.$emit('toBack');
  134. },
  135. // 查询其他信息
  136. async searchOther() {
  137. let res;
  138. // 减免方式
  139. res = await this.dictQuery({ code: 'order_process' });
  140. if (this.$checkRes(res)) this.$set(this, `order_processList`, res.data);
  141. // 快递类型
  142. res = await this.dictQuery({ code: 'transport_type' });
  143. if (this.$checkRes(res)) this.$set(this, `transport_typeList`, res.data);
  144. },
  145. },
  146. computed: {},
  147. metaform() {
  148. return { title: this.$route.meta.title };
  149. },
  150. watch: {
  151. test: {
  152. deep: true,
  153. immediate: true,
  154. handler(val) {},
  155. },
  156. },
  157. };
  158. </script>
  159. <style lang="less" scoped>
  160. .top-btn {
  161. margin: 20px 0;
  162. }
  163. </style>