card-2.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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" class="one">
  7. <search-1 :form="searchForm" @onSubmit="toSearch" @querySearch="querySearch" @toReset="toClose" :shopList="shopList"> </search-1>
  8. </el-col>
  9. <data-table ref="dataTable" :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @detail="toDetail" @sales="toSales">
  10. </data-table>
  11. </el-col>
  12. </el-row>
  13. </div>
  14. </template>
  15. <script>
  16. const _ = require('lodash');
  17. import { mapState, createNamespacedHelpers } from 'vuex';
  18. const { mapActions } = createNamespacedHelpers('order');
  19. const { mapActions: shop } = createNamespacedHelpers('shop');
  20. export default {
  21. name: 'card-1',
  22. props: { statusList: { type: Array } },
  23. components: { search1: () => import('./search-2.vue') },
  24. data: function () {
  25. return {
  26. searchForm: {},
  27. list: [],
  28. total: 0,
  29. opera: [
  30. { label: '详情', method: 'detail' },
  31. { label: '售后', method: 'sales', type: 'danger' },
  32. ],
  33. fields: [
  34. { label: '订单号', model: 'no', showTip: false },
  35. { label: '下单时间', model: 'buy_time' },
  36. { label: '顾客', model: 'customer.name' },
  37. { label: '收货人', model: 'address', showTip: false, format: (i) => this.getAddress(i) },
  38. { label: '店铺名称', model: 'goods', format: (i) => this.getShopName(i) },
  39. { label: '需支付金额', model: 'real_pay' },
  40. { label: '商品数量', model: 'buy_num_total' },
  41. ],
  42. shopList: [],
  43. skip: 0,
  44. loadings: true,
  45. // 查询条件
  46. searchQuery: {},
  47. };
  48. },
  49. async created() {
  50. await this.search();
  51. },
  52. methods: {
  53. ...shop({ shopQuery: 'query' }),
  54. ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
  55. toSearch() {
  56. this.$refs.dataTable.resetPage();
  57. let res = this.$refs.dataTable.getPageConfig();
  58. this.search(res);
  59. },
  60. // 查询
  61. async search({ skip = 0, limit = this.$limit, ...info } = {}) {
  62. let condition = _.cloneDeep(this.searchForm);
  63. if (condition.buy_time) {
  64. condition[`buy_time@start`] = _.head(condition.buy_time);
  65. condition[`buy_time@end`] = _.last(condition.buy_time);
  66. delete condition.buy_time;
  67. }
  68. info.status = '0';
  69. info.shop = this.user.shop.id;
  70. let query = { skip, limit, ...info };
  71. if (Object.keys(condition).length > 0) query = { ...query, ...condition };
  72. let res = await this.query(query);
  73. if (this.$checkRes(res)) {
  74. this.$set(this, 'list', res.data);
  75. this.$set(this, 'total', res.total);
  76. this.$set(this, `searchQuery`, query);
  77. }
  78. this.loadings = false;
  79. },
  80. getAddress(i) {
  81. let name = i.name + ',' + i.phone;
  82. return name;
  83. },
  84. // 店铺名称
  85. getShopName(i) {
  86. let shopname = i.map((e) => e.shop_name);
  87. return shopname.join(',');
  88. },
  89. // 详情
  90. toDetail({ data }) {
  91. this.$emit('toDetail', data._id);
  92. },
  93. toSales({ data }) {
  94. this.$emit('toSales', data._id);
  95. },
  96. // 重置
  97. toClose() {
  98. this.searchForm = {};
  99. this.search();
  100. },
  101. // 店铺名称远程查询
  102. async querySearch(value) {
  103. let res = await this.shopQuery({ name: value });
  104. if (this.$checkRes(res)) this.$set(this, 'shopList', res.data);
  105. },
  106. },
  107. computed: {
  108. ...mapState(['user']),
  109. },
  110. metaInfo() {
  111. return { title: this.$route.meta.title };
  112. },
  113. watch: {
  114. test: {
  115. deep: true,
  116. immediate: true,
  117. handler(val) {},
  118. },
  119. },
  120. };
  121. </script>
  122. <style lang="less" scoped>
  123. .one {
  124. margin: 0 0 10px 0;
  125. }
  126. </style>