index.vue 8.2 KB

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