Home.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. },
  116. mounted() {},
  117. beforeDestroy() {
  118. clearInterval(this.timer);
  119. this.timer = null;
  120. clearInterval(this.timer2);
  121. this.timer2 = null;
  122. },
  123. destroyed() {
  124. bus.$off("pullData");
  125. bus.$off("refreshData");
  126. },
  127. methods: {
  128. init() {
  129. bus.$on("pullData", (index) => {
  130. this.tabNum = index;
  131. this.params.status = this.tabList[index].status;
  132. this.params.pageNum = 1;
  133. this.orderList = [];
  134. Promise.all([this.getOrder(), this.getMarker()]);
  135. });
  136. bus.$on("refreshData", () => {
  137. console.log("执行refreshData");
  138. this.params.pageNum = 1;
  139. this.orderList = [];
  140. Promise.all([this.getOrder(), this.getMarker()]);
  141. });
  142. },
  143. seachEnterFun(e) {
  144. var keyCode = window.event ? e.keyCode : e.which;
  145. if (keyCode == 13) {
  146. this.search();
  147. }
  148. },
  149. search() {
  150. this.$router.push({
  151. path: "/orderSearch",
  152. query: {
  153. searchKey: this.searchKey,
  154. },
  155. });
  156. // this.params.pageNum = 1;
  157. // this.orderList = [];
  158. // this.getOrder();
  159. },
  160. handleSizeChange(val) {
  161. this.params.pageNum = 1;
  162. this.params.pageSize = val;
  163. this.orderList = [];
  164. this.getOrder();
  165. },
  166. handleCurrentChange(val) {
  167. this.params.pageNum = val;
  168. this.orderList = [];
  169. this.getOrder();
  170. },
  171. getMarker() {
  172. getOrderMarker().then((res) => {
  173. if (res.code === 200) {
  174. this.markerNum = res.data;
  175. this.tabList[0].num = res.data.toBeBillNum;
  176. this.tabList[1].num = res.data.appointNum;
  177. this.tabList[2].num = res.data.toBeReceivedNum;
  178. this.tabList[3].num = res.data.toBePickedNum;
  179. this.tabList[4].num = res.data.inDeliveryNum;
  180. this.tabList[5].num = res.data.exceptionNum;
  181. this.tabList[6].num = res.data.cancelNum;
  182. } else {
  183. this.$message({
  184. type: "error",
  185. message: res.msg,
  186. });
  187. }
  188. });
  189. },
  190. sendOrder() {
  191. this.$refs.sendOrderPopup.init();
  192. },
  193. changeTab(i, status) {
  194. this.tabNum = i;
  195. this.params.status = status;
  196. this.orderList = [];
  197. this.params.pageNum = 1;
  198. this.getOrder();
  199. },
  200. getOrder() {
  201. let _this = this;
  202. var minute = 1000 * 60;
  203. var hour = minute * 60;
  204. var day = hour * 24;
  205. this.isLoading = true;
  206. getOrderList(this.params).then((res) => {
  207. this.isLoading = false;
  208. if (res.code == 200) {
  209. this.orderList = [];
  210. this.total = res.data.totalNums || 0;
  211. this.params.pageNum = res.data.pageNum;
  212. res.data.data.forEach((element) => {
  213. element.takeTimeTxt = this.$tool.timeago(
  214. new Date(element.sendTime).getTime()
  215. );
  216. if (element.exceptTime && element.delayTime) {
  217. element.timeTxt = _this.$tool.eosFormatTime2(
  218. element.exceptTime,
  219. element.delayTime
  220. );
  221. } else {
  222. element.timeTxt = "";
  223. }
  224. this.orderList.push(element);
  225. });
  226. } else {
  227. this.$message({
  228. message: res.msg,
  229. type: "error",
  230. });
  231. }
  232. });
  233. },
  234. getRefreshOrder() {
  235. let orderIds = this.orderList.map((v) => {
  236. return v.id;
  237. });
  238. let params = {
  239. orderIds: orderIds,
  240. status: this.tabList[this.tabNum].status,
  241. };
  242. getRefreshOrder(params).then((res) => {
  243. if (res.code === 200) {
  244. let newList = res.data.newList;
  245. let deliveryList = res.data.deliveryList;
  246. if (!newList.length && !deliveryList.length) return;
  247. // 根据exceptTime判断是新订单还是预约单
  248. let normalList = newList
  249. .filter((v) => {
  250. return !v.exceptTime;
  251. })
  252. .map((item) => {
  253. item.buttonStatus = 0;
  254. return item;
  255. });
  256. let appointList = newList
  257. .filter((v) => {
  258. return v.exceptTime;
  259. })
  260. .map((item) => {
  261. item.buttonStatus = 10;
  262. item.exceptTime = this.$tool.getFormatDate(
  263. item.exceptTime * 1000
  264. );
  265. return item;
  266. });
  267. // tabNum 0 是新订单 1是预约单
  268. if (this.tabNum === 1) {
  269. this.orderList = this.orderList.concat(appointList);
  270. } else if (this.tabNum === 0) {
  271. this.orderList = this.orderList.concat(normalList);
  272. } else {
  273. this.orderList = this.orderList.concat(newList);
  274. }
  275. console.log("1111", deliveryList);
  276. deliveryList.forEach((item) => {
  277. this.orderList = this.orderList.filter((v) => {
  278. console.log("2222", v, item);
  279. return v.id !== item;
  280. });
  281. });
  282. this.total = this.orderList.length;
  283. } else {
  284. this.$message({
  285. type: "error",
  286. message: res.msg,
  287. });
  288. }
  289. });
  290. },
  291. },
  292. };
  293. </script>
  294. <style lang="scss" scoped="scoped">
  295. /deep/ .el-input__inner {
  296. padding-right: 30px;
  297. }
  298. .mainContent {
  299. width: 100%;
  300. height: 100%;
  301. .order_tab {
  302. width: 100%;
  303. height: 74px;
  304. background: #fff;
  305. .tabList {
  306. display: flex;
  307. justify-content: space-around;
  308. width: 100%;
  309. padding-top: 20px;
  310. padding-left: 36px;
  311. box-sizing: border-box;
  312. overflow-x: auto;
  313. .tab_item {
  314. font-size: 16px;
  315. font-weight: 500;
  316. color: #b1b1b1;
  317. position: relative;
  318. text-align: center;
  319. cursor: pointer;
  320. .tab_line {
  321. width: 58px;
  322. height: 6px;
  323. background: #fff;
  324. border-radius: 3px;
  325. margin-top: 15px;
  326. }
  327. .point {
  328. width: 16px;
  329. height: 16px;
  330. border-radius: 50%;
  331. background: #f74141;
  332. font-size: 12px;
  333. font-weight: 400;
  334. color: #ffffff;
  335. position: absolute;
  336. top: -5px;
  337. right: -10px;
  338. text-align: center;
  339. line-height: 16px;
  340. }
  341. }
  342. .tab_item_ac {
  343. color: #fc7200;
  344. .tab_line {
  345. background: #fc7200;
  346. }
  347. }
  348. }
  349. .search {
  350. display: flex;
  351. justify-content: flex-end;
  352. .header_serch {
  353. width: 80%;
  354. height: 74px;
  355. padding-right: 25px;
  356. box-sizing: border-box;
  357. display: flex;
  358. align-items: center;
  359. justify-content: flex-end;
  360. .Manual {
  361. width: 118px;
  362. height: 44px;
  363. background: #fc7200;
  364. border-radius: 6px;
  365. font-size: 16px;
  366. font-weight: 500;
  367. color: #ffffff;
  368. text-align: center;
  369. line-height: 44px;
  370. margin-left: 18px;
  371. }
  372. .btn {
  373. background: #fc7200;
  374. border-color: #fc7200;
  375. color: #fff !important;
  376. margin-left: 10px;
  377. }
  378. .search_inp {
  379. width: 380px;
  380. height: 44px;
  381. display: flex;
  382. align-items: center;
  383. position: relative;
  384. .inp {
  385. width: 100%;
  386. // height: 44px;
  387. border: none;
  388. }
  389. .btn {
  390. font-size: 22px;
  391. position: absolute;
  392. right: 15px;
  393. }
  394. }
  395. }
  396. }
  397. }
  398. .order_list {
  399. width: 100%;
  400. height: calc(100vh - 180px);
  401. margin-top: 10px;
  402. .list {
  403. position: relative;
  404. height: calc(100vh - 210px);
  405. overflow: hidden;
  406. }
  407. .empty-data {
  408. display: flex;
  409. flex-direction: column;
  410. align-items: center;
  411. justify-content: center;
  412. background-color: #fff;
  413. height: 100%;
  414. img {
  415. width: 349px;
  416. height: 222px;
  417. }
  418. .no-data {
  419. color: #9EA7B7;
  420. }
  421. }
  422. }
  423. }
  424. </style>