index.vue 9.2 KB

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