index.vue 9.3 KB

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