Home.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <div class="mainContent">
  3. <el-row class="order_tab">
  4. <el-col :span="15">
  5. <div class="tabList">
  6. <div class="tab_item" @click="changeTab(i, item.status)" :class="{ tab_item_ac: tabNum == i ? true : false }" v-for="(item, i) in tabList" :key="i">
  7. <div class="point" v-show="item.num">{{ item.num }}</div>
  8. <span>{{ item.name }}</span>
  9. <div class="tab_line"></div>
  10. </div>
  11. </div>
  12. </el-col>
  13. <el-col :span="9" class="search">
  14. <div class="header_serch">
  15. <div class="search_inp">
  16. <el-input size="small" class="inp" v-model="searchKey" placeholder="请输入手机号/姓名/地址/订单编号" @keydown.enter.native="seachEnterFun" clearable></el-input>
  17. <el-button size="small" style="background: #0D1E40;color:#fff" type="info" @click.stop="search" slot="append" icon="el-icon-search"></el-button>
  18. </div>
  19. <!-- 1.0.0版本暂不开发该功能 -->
  20. <el-button class="btn" size='small' @click="$router.push({path:'/manualCreate'})">手动发单</el-button>
  21. </div>
  22. </el-col>
  23. </el-row>
  24. <el-row class="order_list">
  25. <el-col :span="24" v-loading="isLoading" v-if="orderList.length">
  26. <order-list class="list" :list="orderList" :tabNum="tabNum"></order-list>
  27. <div style="text-align: center">
  28. <el-pagination :current-page.sync="params.pageNum" @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-sizes="[10, 20, 50, 100]" :page-size="params.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total" background>
  29. </el-pagination>
  30. </div>
  31. </el-col>
  32. <el-col class="empty-data" v-else>
  33. <img src="../../static/image/empty-data.png" />
  34. <div class="no-data">暂无订单数据</div>
  35. </el-col>
  36. </el-row>
  37. </div>
  38. </template>
  39. <script>
  40. import bus from "../common/bus.js";
  41. import sendOrderPopup from "./orderComponents/sendOrderPopup.vue";
  42. import OrderList from "./orderComponents/orderList.vue";
  43. import { getOrderList, getOrderMarker, getRefreshOrder } from "../api/order.js";
  44. export default {
  45. data() {
  46. return {
  47. isLoading: false,
  48. total: 0,
  49. orderList: [],
  50. tabList: [
  51. {
  52. name: "新订单",
  53. num: 0,
  54. status: 0,
  55. },
  56. {
  57. name: "预约单",
  58. num: 0,
  59. status: 10,
  60. },
  61. {
  62. name: "待接单",
  63. num: 0,
  64. status: 1,
  65. },
  66. {
  67. name: "取货中",
  68. num: 0,
  69. status: 2,
  70. },
  71. {
  72. name: "配送中",
  73. num: 0,
  74. status: 3,
  75. },
  76. {
  77. name: "异常单",
  78. num: 0,
  79. status: -2,
  80. },
  81. {
  82. name: "已取消",
  83. num: 0,
  84. status: -1,
  85. },
  86. ],
  87. tabNum: 0,
  88. needTrack: false,
  89. orderDetailStutus: 1,
  90. params: {
  91. status: 0,
  92. searchType: 0,
  93. pageNum: 1,
  94. pageSize: 10,
  95. },
  96. markerNum: "",
  97. clickBool: false,
  98. timer: null,
  99. timer2: null,
  100. searchKey: "",
  101. };
  102. },
  103. components: {
  104. sendOrderPopup,
  105. OrderList,
  106. },
  107. created() {
  108. this.init();
  109. this.getOrder();
  110. this.getMarker();
  111. this.timer = setInterval(() => {
  112. this.getMarker();
  113. this.getRefreshOrder();
  114. }, 5000);
  115. // this.timer2 = setInterval(() => {
  116. // this.getMarker();
  117. // if (this.tabNum >= 2) {
  118. // this.getOrder();
  119. // }
  120. // }, 60000);
  121. },
  122. mounted() {},
  123. beforeDestroy() {
  124. clearInterval(this.timer);
  125. this.timer = null;
  126. clearInterval(this.timer2);
  127. this.timer2 = null;
  128. },
  129. destroyed() {
  130. bus.$off("pullData");
  131. bus.$off("refreshData");
  132. },
  133. methods: {
  134. init() {
  135. bus.$on("pullData", (index) => {
  136. this.tabNum = index;
  137. this.params.status = this.tabList[index].status;
  138. this.params.pageNum = 1;
  139. this.orderList = [];
  140. Promise.all([this.getOrder(), this.getMarker()]);
  141. });
  142. bus.$on("refreshData", () => {
  143. console.log("执行refreshData");
  144. this.params.pageNum = 1;
  145. this.orderList = [];
  146. Promise.all([this.getOrder(), this.getMarker()]);
  147. });
  148. },
  149. seachEnterFun(e) {
  150. var keyCode = window.event ? e.keyCode : e.which;
  151. if (keyCode == 13) {
  152. this.search();
  153. }
  154. },
  155. search() {
  156. this.$router.push({
  157. path: "/orderSearch",
  158. query: {
  159. searchKey: this.searchKey,
  160. },
  161. });
  162. // this.params.pageNum = 1;
  163. // this.orderList = [];
  164. // this.getOrder();
  165. },
  166. handleSizeChange(val) {
  167. this.params.pageNum = 1;
  168. this.params.pageSize = val;
  169. this.orderList = [];
  170. this.getOrder();
  171. },
  172. handleCurrentChange(val) {
  173. this.params.pageNum = val;
  174. this.orderList = [];
  175. this.getOrder();
  176. },
  177. getMarker() {
  178. getOrderMarker().then((res) => {
  179. if (res.code === 200) {
  180. this.markerNum = res.data;
  181. this.tabList[0].num = res.data.toBeBillNum;
  182. this.tabList[1].num = res.data.appointNum;
  183. this.tabList[2].num = res.data.toBeReceivedNum;
  184. this.tabList[3].num = res.data.toBePickedNum;
  185. this.tabList[4].num = res.data.inDeliveryNum;
  186. this.tabList[5].num = res.data.exceptionNum;
  187. this.tabList[6].num = res.data.cancelNum;
  188. } else {
  189. this.$message({
  190. type: "error",
  191. message: res.msg,
  192. });
  193. }
  194. });
  195. },
  196. sendOrder() {
  197. this.$refs.sendOrderPopup.init();
  198. },
  199. changeTab(i, status) {
  200. this.tabNum = i;
  201. this.params.status = status;
  202. this.orderList = [];
  203. this.params.pageNum = 1;
  204. this.getOrder();
  205. },
  206. getOrder() {
  207. let _this = this;
  208. var minute = 1000 * 60;
  209. var hour = minute * 60;
  210. var day = hour * 24;
  211. this.isLoading = true;
  212. getOrderList(this.params).then((res) => {
  213. this.isLoading = false;
  214. if (res.code == 200) {
  215. this.orderList = [];
  216. this.total = res.data.totalNums || 0;
  217. this.params.pageNum = res.data.pageNum;
  218. res.data.data.forEach((element) => {
  219. element.takeTimeTxt = this.$tool.timeago(
  220. new Date(element.sendTime).getTime()
  221. );
  222. if (element.exceptTime && element.delayTime) {
  223. element.timeTxt = _this.$tool.eosFormatTime2(
  224. element.exceptTime,
  225. element.delayTime
  226. );
  227. } else {
  228. element.timeTxt = "";
  229. }
  230. this.orderList.push(element);
  231. });
  232. } else {
  233. this.$message({
  234. message: res.msg,
  235. type: "error",
  236. });
  237. }
  238. });
  239. },
  240. getRefreshOrder() {
  241. let orderIds = this.orderList.map((v) => {
  242. return v.id;
  243. });
  244. let params = {
  245. orderIds: orderIds,
  246. status: this.tabList[this.tabNum].status,
  247. };
  248. getRefreshOrder(params).then((res) => {
  249. if (res.code === 200) {
  250. let newList = res.data.newList;
  251. let deliveryList = res.data.deliveryList;
  252. if (!newList.length && !deliveryList.length) return;
  253. // 根据exceptTime判断是新订单还是预约单
  254. let normalList = newList
  255. .filter((v) => {
  256. return !v.exceptTime;
  257. })
  258. .map((item) => {
  259. item.buttonStatus = 0;
  260. return item;
  261. });
  262. let appointList = newList
  263. .filter((v) => {
  264. return v.exceptTime;
  265. })
  266. .map((item) => {
  267. item.buttonStatus = 10;
  268. item.exceptTime = this.$tool.getFormatDate(
  269. item.exceptTime * 1000
  270. );
  271. return item;
  272. });
  273. // tabNum 0 是新订单 1是预约单
  274. if (this.tabNum === 1) {
  275. this.orderList = this.orderList.concat(appointList);
  276. } else if (this.tabNum === 0) {
  277. this.orderList = this.orderList.concat(normalList);
  278. } else {
  279. this.orderList = this.orderList.concat(newList);
  280. }
  281. console.log("1111", deliveryList);
  282. deliveryList.forEach((item) => {
  283. this.orderList = this.orderList.filter((v) => {
  284. console.log("2222", v, item);
  285. return v.id !== item;
  286. });
  287. });
  288. this.total = this.orderList.length;
  289. } else {
  290. this.$message({
  291. type: "error",
  292. message: res.msg,
  293. });
  294. }
  295. });
  296. },
  297. },
  298. };
  299. </script>
  300. <style lang="scss" scoped="scoped">
  301. /deep/ .el-input__inner {
  302. padding-right: 30px;
  303. }
  304. .mainContent {
  305. width: 100%;
  306. height: 100%;
  307. .order_tab {
  308. width: 100%;
  309. height: 74px;
  310. background: #fff;
  311. .tabList {
  312. display: flex;
  313. justify-content: space-around;
  314. width: 100%;
  315. padding-top: 20px;
  316. padding-left: 36px;
  317. box-sizing: border-box;
  318. overflow-x: auto;
  319. .tab_item {
  320. font-size: 16px;
  321. font-weight: 500;
  322. color: #b1b1b1;
  323. position: relative;
  324. text-align: center;
  325. cursor: pointer;
  326. .tab_line {
  327. width: 58px;
  328. height: 6px;
  329. background: #fff;
  330. border-radius: 3px;
  331. margin-top: 15px;
  332. }
  333. .point {
  334. width: 16px;
  335. height: 16px;
  336. border-radius: 50%;
  337. background: #f74141;
  338. font-size: 12px;
  339. font-weight: 400;
  340. color: #ffffff;
  341. position: absolute;
  342. top: -5px;
  343. right: -10px;
  344. text-align: center;
  345. line-height: 16px;
  346. }
  347. }
  348. .tab_item_ac {
  349. color: #fc7200;
  350. .tab_line {
  351. background: #fc7200;
  352. }
  353. }
  354. }
  355. .search {
  356. display: flex;
  357. justify-content: flex-end;
  358. .header_serch {
  359. width: 80%;
  360. height: 74px;
  361. padding-right: 25px;
  362. box-sizing: border-box;
  363. display: flex;
  364. align-items: center;
  365. justify-content: flex-end;
  366. .Manual {
  367. width: 118px;
  368. height: 44px;
  369. background: #fc7200;
  370. border-radius: 6px;
  371. font-size: 16px;
  372. font-weight: 500;
  373. color: #ffffff;
  374. text-align: center;
  375. line-height: 44px;
  376. margin-left: 18px;
  377. }
  378. .btn {
  379. background: #fc7200;
  380. border-color: #fc7200;
  381. color: #fff !important;
  382. margin-left: 10px;
  383. }
  384. .search_inp {
  385. width: 380px;
  386. height: 44px;
  387. display: flex;
  388. align-items: center;
  389. position: relative;
  390. .inp {
  391. width: 100%;
  392. // height: 44px;
  393. border: none;
  394. }
  395. .btn {
  396. font-size: 22px;
  397. position: absolute;
  398. right: 15px;
  399. }
  400. }
  401. }
  402. }
  403. }
  404. .order_list {
  405. width: 100%;
  406. height: calc(100vh - 180px);
  407. margin-top: 10px;
  408. .list {
  409. position: relative;
  410. height: calc(100vh - 210px);
  411. overflow: hidden;
  412. }
  413. .empty-data {
  414. display: flex;
  415. flex-direction: column;
  416. align-items: center;
  417. justify-content: center;
  418. background-color: #fff;
  419. height: 100%;
  420. img {
  421. width: 349px;
  422. height: 222px;
  423. }
  424. .no-data {
  425. color: #9EA7B7;
  426. }
  427. }
  428. }
  429. }
  430. </style>