detail-3.vue 5.0 KB

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