detail-1.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div id="card-1">
  3. <el-row>
  4. <!-- 自营店铺订单待发货列表 -->
  5. <el-col :span="24" class="main" v-loading="loadings" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading">
  6. <el-col :span="24" v-if="num == '1'">
  7. <el-col :span="24" class="one">
  8. <search-1 :form="searchForm" @onSubmit="toSearch" @querySearch="querySearch" @toReset="toClose" :shopList="shopList"> </search-1>
  9. </el-col>
  10. <el-col :span="24" class="one">
  11. <el-button type="primary" size="mini" @click="toDeliver()">生成发货清单</el-button>
  12. <p>(发货清单里不显示售后的订单)</p>
  13. </el-col>
  14. <data-table
  15. ref="dataTable"
  16. :select="true"
  17. :selected="selected"
  18. @handleSelect="handleSelect"
  19. :fields="fields"
  20. :opera="opera"
  21. @query="search"
  22. :data="list"
  23. :total="total"
  24. @detail="toDetail"
  25. @sales="toSales"
  26. >
  27. <template #is_afterSale="{ row }">
  28. <span :style="{ color: row.is_afterSale === true ? 'red' : '' }"> {{ row.is_afterSale === true ? '该订单有商品申请售后' : '未申请售后' }}</span>
  29. </template>
  30. </data-table>
  31. </el-col>
  32. </el-col>
  33. </el-row>
  34. </div>
  35. </template>
  36. <script>
  37. const _ = require('lodash');
  38. import { mapState, createNamespacedHelpers } from 'vuex';
  39. const { mapActions } = createNamespacedHelpers('orderDetail');
  40. const { mapActions: shop } = createNamespacedHelpers('shop');
  41. export default {
  42. name: 'card-1',
  43. props: { statusList: { type: Array } },
  44. components: { search1: () => import('../search-2.vue') },
  45. data: function () {
  46. return {
  47. loadings: true,
  48. num: '1',
  49. searchForm: {},
  50. list: [],
  51. total: 0,
  52. opera: [
  53. { label: '详情', method: 'detail' },
  54. { label: '售后', method: 'sales', type: 'danger' },
  55. ],
  56. fields: [
  57. { label: '订单号', model: 'no', showTip: false },
  58. { label: '下单时间', model: 'buy_time' },
  59. { label: '顾客', model: 'customer.name' },
  60. { label: '收货人', model: 'address', showTip: false, format: (i) => this.getAddress(i) },
  61. { label: '店铺名称', model: 'shop.name' },
  62. { label: '支付金额', model: 'real_pay' },
  63. { label: '商品数量', model: 'buy_num_total' },
  64. { label: '是否售后', model: 'is_afterSale', format: (i) => (i === true ? '该订单有商品申请售后' : '未申请售后'), custom: true },
  65. ],
  66. // 多选值
  67. selected: [],
  68. shopList: [],
  69. // 发货清单
  70. deliverList: [],
  71. deliver: '0',
  72. // 查询条件
  73. searchQuery: {},
  74. };
  75. },
  76. async created() {
  77. await this.search();
  78. },
  79. methods: {
  80. ...shop({ shopQuery: 'query' }),
  81. ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
  82. toSearch() {
  83. this.$refs.dataTable.resetPage();
  84. let res = this.$refs.dataTable.getPageConfig();
  85. this.search(res);
  86. },
  87. // 查询
  88. async search({ skip = 0, limit = this.$limit, ...info } = {}) {
  89. let condition = _.cloneDeep(this.searchForm);
  90. if (condition.buy_time) {
  91. condition[`buy_time@start`] = _.head(condition.buy_time);
  92. condition[`buy_time@end`] = _.last(condition.buy_time);
  93. delete condition.buy_time;
  94. }
  95. info.status = '1';
  96. info.shop = this.user.shop.id;
  97. let query = { skip, limit, ...info };
  98. if (Object.keys(condition).length > 0) query = { ...query, ...condition };
  99. let res = await this.query(query);
  100. if (this.$checkRes(res)) {
  101. this.$set(this, 'list', res.data);
  102. this.$set(this, 'total', res.total);
  103. this.$set(this, `searchQuery`, query);
  104. }
  105. this.loadings = false;
  106. },
  107. getAddress(i) {
  108. let name = i.name + ',' + i.phone;
  109. return name;
  110. },
  111. // 详情
  112. toDetail({ data }) {
  113. this.$emit('toDetails', data._id);
  114. },
  115. toSales({ data }) {
  116. this.$emit('toSaless', { id: data._id, status: '1' });
  117. },
  118. toClose() {
  119. this.searchForm = {};
  120. this.search();
  121. },
  122. // 多选
  123. handleSelect(data) {
  124. this.$set(this, 'deliverList', data);
  125. },
  126. // 生成发货清单
  127. toDeliver() {
  128. this.$emit('toDeliver', { data: this.deliverList });
  129. },
  130. // 店铺名称远程查询
  131. async querySearch(value) {
  132. let res = await this.shopQuery({ name: value });
  133. if (this.$checkRes(res)) this.$set(this, 'shopList', res.data);
  134. },
  135. },
  136. computed: {
  137. ...mapState(['user']),
  138. },
  139. metaInfo() {
  140. return { title: this.$route.meta.title };
  141. },
  142. watch: {
  143. test: {
  144. deep: true,
  145. immediate: true,
  146. handler(val) {},
  147. },
  148. },
  149. };
  150. </script>
  151. <style lang="less" scoped>
  152. .one {
  153. margin: 0 0 10px 0;
  154. p {
  155. font-size: 12px;
  156. color: #777;
  157. }
  158. }
  159. </style>