index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col
  5. :span="24"
  6. class="main animate__animated animate__backInRight"
  7. v-loading="loadings"
  8. element-loading-text="拼命加载中"
  9. element-loading-spinner="el-icon-loading"
  10. >
  11. <span v-show="view === 'list'">
  12. <el-col :span="24" class="one"> <span>订单管理</span> </el-col>
  13. <el-col :span="24" class="four">
  14. <el-tabs v-model="activeName" @tab-click="handleClick" type="border-card">
  15. <el-tab-pane name="1" label="待付款"> </el-tab-pane>
  16. <el-tab-pane name="2" label="待发货"> </el-tab-pane>
  17. <el-tab-pane name="3" label="部分发货"> </el-tab-pane>
  18. <el-tab-pane name="4" label="待收货"> </el-tab-pane>
  19. <el-tab-pane name="5" label="已收货"> </el-tab-pane>
  20. <el-tab-pane name="6" label="取消订单"> </el-tab-pane>
  21. <!-- 待付款 -->
  22. <el-col :span="24" v-if="activeName == '1'">
  23. <card-1 :statusList="statusList" @toDetail="toDetail" @toSales="toSales"></card-1>
  24. </el-col>
  25. <!-- 待发货 -->
  26. <el-col :span="24" v-else-if="activeName == '2'">
  27. <card-2 :statusList="statusList" @toDetails="toDetail_t" @toSaless="toSales_t"></card-2>
  28. </el-col>
  29. <el-col :span="24" v-else-if="activeName == '3' || activeName == '4' || activeName == '5' || activeName == '6'">
  30. <el-col :span="24" class="one">
  31. <search-1 :form="searchForm" @onSubmit="search" @querySearch="querySearch" @toReset="toClose" :shopList="shopList"> </search-1>
  32. </el-col>
  33. <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @detail="toDetails" @sales="toSaless">
  34. <template #is_afterSale="{ row }">
  35. <span :style="{ color: row.is_afterSale === true ? 'red' : '' }">
  36. {{ row.is_afterSale === true ? '该订单有商品申请售后' : '未申请售后' }}
  37. </span>
  38. </template>
  39. </data-table>
  40. </el-col>
  41. </el-tabs>
  42. </el-col>
  43. </span>
  44. <order v-if="view === 'order'" :id="order_id" @toBack="toBack"></order>
  45. <orderDetaile v-else-if="view === 'orderDetaile'" :id="order_id" @toBack="toBack"></orderDetaile>
  46. <salseOrder v-else-if="view === 'salseOrder'" :id="sales_id" @toBack="toBack"></salseOrder>
  47. <salseOrderDetail v-else-if="view === 'salseOrderDetail'" :id="sales_id" :status="status" @toBack="toBack"></salseOrderDetail>
  48. </el-col>
  49. </el-row>
  50. </div>
  51. </template>
  52. <script>
  53. const _ = require('lodash');
  54. import { mapState, mapGetters, createNamespacedHelpers } from 'vuex';
  55. const { mapActions: dictData } = createNamespacedHelpers('dictData');
  56. const { mapActions: shop } = createNamespacedHelpers('shop');
  57. const { mapActions } = createNamespacedHelpers('orderDetail');
  58. export default {
  59. name: 'index',
  60. props: {},
  61. components: {
  62. card1: () => import('@/components/orderParts/card/card-2.vue'),
  63. card2: () => import('@/components/orderParts/card/card-3.vue'),
  64. // 未付款---详情
  65. order: () => import('@/components/orderParts/detail/order.vue'),
  66. // 待发货,待收货,已收货---详情
  67. orderDetaile: () => import('@/components/orderParts/detail/orderDetaile.vue'),
  68. // 未付款----申请售后
  69. salseOrder: () => import('@/components/orderParts/detail/salseOrder.vue'),
  70. // 待发货,待收货,已收货----申请售后
  71. salseOrderDetail: () => import('@/components/orderParts/detail/salseOrderDetail.vue'),
  72. search1: () => import('@/components/orderParts/search/search-2.vue'),
  73. },
  74. data: function () {
  75. const that = this;
  76. return {
  77. loadings: true,
  78. view: 'list',
  79. activeName: '2',
  80. // 类型列表
  81. statusList: [],
  82. // 店铺列表
  83. shopList: [],
  84. order_id: '',
  85. sales_id: '',
  86. status: '',
  87. searchForm: {},
  88. list: [],
  89. total: 0,
  90. opera: [
  91. { label: '详情', method: 'detail' },
  92. { label: '售后', method: 'sales', type: 'danger', display: (i) => i.status == '1' || i.status == '2' || i.status == '2-' || i.status == '3' },
  93. // { label: '联系', method: 'message', type: 'warning' },
  94. ],
  95. fields: [
  96. { label: '订单号', model: 'no', showTip: false },
  97. { label: '下单时间', model: 'buy_time' },
  98. { label: '顾客', model: 'customer.name' },
  99. { label: '收货人', model: 'address', showTip: false, format: (i) => this.getAddress(i) },
  100. { label: '支付金额', model: 'real_pay' },
  101. { label: '商品数量', model: 'buy_num_total' },
  102. { label: '是否售后', model: 'is_afterSale', format: (i) => (i === true ? '该订单有商品申请售后' : '未申请售后'), custom: true },
  103. ],
  104. };
  105. },
  106. async created() {
  107. await this.searchOther();
  108. await this.search();
  109. },
  110. methods: {
  111. ...dictData({ dictQuery: 'query' }),
  112. ...shop({ shopQuery: 'query' }),
  113. ...mapActions(['query', 'fetch', 'create', 'update', 'delete']),
  114. // 查询
  115. async search({ skip = 0, limit = this.$limit, ...info } = {}) {
  116. if (this.$route.query.id) {
  117. let data = this.$route.query.id;
  118. this.toDetail_t(data);
  119. } else {
  120. if (this.active) this.$set(this, 'activeName', this.active);
  121. let condition = _.cloneDeep(this.searchForm);
  122. if (condition.buy_time) {
  123. condition[`buy_time@start`] = _.head(condition.buy_time);
  124. condition[`buy_time@end`] = _.last(condition.buy_time);
  125. delete condition.buy_time;
  126. }
  127. if (this.activeName == '3') info.status = '2-';
  128. else if (this.activeName == '2') info.status = '1';
  129. else if (this.activeName == '1') info.status = '0';
  130. else if (this.activeName == '4') info.status = '2';
  131. else if (this.activeName == '5') info.status = '3';
  132. else if (this.activeName == '6') info.status = '-1';
  133. info.shop = this.user.shop.id;
  134. let res = await this.query({ skip, limit, ...condition, ...info });
  135. if (this.$checkRes(res)) {
  136. this.$set(this, 'list', res.data);
  137. this.$set(this, 'total', res.total);
  138. }
  139. }
  140. this.loadings = false;
  141. },
  142. // 未付款
  143. toDetail(val) {
  144. this.$set(this, `order_id`, val);
  145. this.$set(this, `view`, 'order');
  146. },
  147. toSales(val) {
  148. this.$set(this, `sales_id`, val);
  149. this.$set(this, `view`, 'salseOrder');
  150. },
  151. // 待收货,已收货
  152. toDetails({ data }) {
  153. this.$set(this, `order_id`, data._id);
  154. this.$set(this, `view`, 'orderDetaile');
  155. },
  156. toSaless({ data }) {
  157. this.$set(this, `sales_id`, data._id);
  158. this.$set(this, `status`, data.status);
  159. this.$set(this, `view`, 'salseOrderDetail');
  160. },
  161. // 待发货
  162. toDetail_t(data) {
  163. this.$set(this, `order_id`, data);
  164. this.$set(this, `view`, 'orderDetaile');
  165. },
  166. toSales_t(data) {
  167. this.$set(this, `sales_id`, data.id);
  168. this.$set(this, `status`, data.status);
  169. this.$set(this, `view`, 'salseOrderDetail');
  170. },
  171. handleClick(tab) {
  172. this.loadings = true;
  173. this.search();
  174. },
  175. toBack() {
  176. this.view = 'list';
  177. this.loadings = true;
  178. if (this.$route.query.id) {
  179. delete this.$route.query.id;
  180. }
  181. this.search(this.searchQuery);
  182. },
  183. getAddress(i) {
  184. let name = i.name + ',' + i.phone;
  185. return name;
  186. },
  187. // 店铺名称
  188. getShopName(i) {
  189. let shopname = i.map((e) => e.shop_name);
  190. return shopname.join(',');
  191. },
  192. // 重置
  193. toClose() {
  194. this.searchForm = {};
  195. this.search();
  196. },
  197. // 店铺名称远程查询
  198. async querySearch(value) {
  199. let res = await this.shopQuery({ name: value });
  200. if (this.$checkRes(res)) this.$set(this, 'shopList', res.data);
  201. },
  202. // 查询其他信息
  203. async searchOther() {
  204. let res;
  205. // 类型
  206. res = await this.dictQuery({ code: 'order_process' });
  207. if (this.$checkRes(res)) this.$set(this, `statusList`, res.data);
  208. // 店铺
  209. res = await this.shopQuery();
  210. if (this.$checkRes(res)) this.$set(this, `shopList`, res.data);
  211. },
  212. },
  213. computed: {
  214. ...mapState(['user']),
  215. active() {
  216. return this.$route.query.activeName;
  217. },
  218. orders_id() {
  219. return this.$route.query.id;
  220. },
  221. },
  222. metaInfo() {
  223. return { title: this.$route.meta.title };
  224. },
  225. watch: {
  226. test: {
  227. deep: true,
  228. immediate: true,
  229. handler(val) {},
  230. },
  231. },
  232. };
  233. </script>
  234. <style lang="less" scoped>
  235. .main {
  236. .one {
  237. margin: 0 0 10px 0;
  238. span:nth-child(1) {
  239. font-size: 20px;
  240. font-weight: 700;
  241. margin-right: 10px;
  242. }
  243. }
  244. .two {
  245. margin: 0 0 10px 0;
  246. }
  247. .thr {
  248. margin: 0 0 10px 0;
  249. }
  250. }
  251. .el-col {
  252. margin: 10px 0;
  253. }
  254. </style>