123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
- <template>
- <div class="mainContent">
- <el-row class="order_tab">
- <el-col :span="15">
- <div class="tabList">
- <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">
- <div class="point" v-show="item.num">{{ item.num }}</div>
- <span>{{ item.name }}</span>
- <div class="tab_line"></div>
- </div>
- </div>
- </el-col>
- <el-col :span="9" class="search">
- <div class="header_serch">
- <div class="search_inp">
- <el-input size="medium" class="inp" v-model="searchKey" placeholder="请输入手机号/姓名/地址/订单编号" @keydown.enter.native="seachEnterFun" clearable></el-input>
- <el-button size="medium" type="primary" @click.stop="search" slot="append" icon="el-icon-search"></el-button>
- </div>
- <!-- 1.0.0版本暂不开发该功能 -->
- <!-- <div class="Manual">手动发单</div> -->
- </div>
- </el-col>
- </el-row>
- <el-row class="order_list">
- <el-col :span="24" v-loading="isLoading" v-if="orderList.length">
- <order-list class="list" :list="orderList" :tabNum="tabNum"></order-list>
- <div style="text-align: center">
- <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>
- </el-pagination>
- </div>
- </el-col>
- <el-col class="empty-data" v-else>
- <img src="../../static/image/empty-data.png" />
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import bus from "../common/bus.js";
- import sendOrderPopup from "./orderComponents/sendOrderPopup.vue";
- import OrderList from "./orderComponents/orderList.vue";
- import { getOrderList, getOrderMarker, getRefreshOrder } from "../api/order.js";
- export default {
- data() {
- return {
- isLoading: false,
- total: 0,
- orderList: [],
- tabList: [
- {
- name: "新订单",
- num: 0,
- status: 0,
- },
- {
- name: "预约单",
- num: 0,
- status: 10,
- },
- {
- name: "待接单",
- num: 0,
- status: 1,
- },
- {
- name: "取货中",
- num: 0,
- status: 2,
- },
- {
- name: "配送中",
- num: 0,
- status: 3,
- },
- {
- name: "异常单",
- num: 0,
- status: -2,
- },
- {
- name: "已取消",
- num: 0,
- status: -1,
- },
- ],
- tabNum: 0,
- needTrack: false,
- orderDetailStutus: 1,
- params: {
- status: 0,
- searchType: 0,
- pageNum: 1,
- pageSize: 10,
- },
- markerNum: "",
- clickBool: false,
- timer: null,
- timer2: null,
- searchKey: "",
- };
- },
- components: {
- sendOrderPopup,
- OrderList,
- },
- created() {
- this.init();
- this.getOrder();
- this.getMarker();
- this.timer = setInterval(() => {
- this.getMarker();
- this.getRefreshOrder();
- }, 5000);
- // this.timer2 = setInterval(() => {
- // this.getMarker();
- // if (this.tabNum >= 2) {
- // this.getOrder();
- // }
- // }, 60000);
- },
- mounted() {},
- beforeDestroy() {
- clearInterval(this.timer);
- this.timer = null;
- clearInterval(this.timer2);
- this.timer2 = null;
- },
- destroyed() {
- bus.$off("pullData");
- bus.$off("refreshData");
- },
- methods: {
- init() {
- bus.$on("pullData", (index) => {
- this.tabNum = index;
- this.params.status = this.tabList[index].status;
- this.params.pageNum = 1;
- this.orderList = [];
- Promise.all([this.getOrder(), this.getMarker()]);
- });
- bus.$on("refreshData", () => {
- console.log("执行refreshData");
- this.params.pageNum = 1;
- this.orderList = [];
- Promise.all([this.getOrder(), this.getMarker()]);
- });
- },
- seachEnterFun(e) {
- var keyCode = window.event ? e.keyCode : e.which;
- if (keyCode == 13) {
- this.search();
- }
- },
- search() {
- this.$router.push({
- path: "/orderSearch",
- query: {
- searchKey: this.searchKey,
- },
- });
- // this.params.pageNum = 1;
- // this.orderList = [];
- // this.getOrder();
- },
- handleSizeChange(val) {
- this.params.pageNum = 1;
- this.params.pageSize = val;
- this.orderList = [];
- this.getOrder();
- },
- handleCurrentChange(val) {
- this.params.pageNum = val;
- this.orderList = [];
- this.getOrder();
- },
- getMarker() {
- getOrderMarker().then((res) => {
- if (res.code === 200) {
- this.markerNum = res.data;
- this.tabList[0].num = res.data.toBeBillNum;
- this.tabList[1].num = res.data.appointNum;
- this.tabList[2].num = res.data.toBeReceivedNum;
- this.tabList[3].num = res.data.toBePickedNum;
- this.tabList[4].num = res.data.inDeliveryNum;
- this.tabList[5].num = res.data.exceptionNum;
- this.tabList[6].num = res.data.cancelNum;
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- });
- },
- sendOrder() {
- this.$refs.sendOrderPopup.init();
- },
- changeTab(i, status) {
- this.tabNum = i;
- this.params.status = status;
- this.orderList = [];
- this.params.pageNum = 1;
- this.getOrder();
- },
- getOrder() {
- let _this = this;
- var minute = 1000 * 60;
- var hour = minute * 60;
- var day = hour * 24;
- this.isLoading = true;
- getOrderList(this.params).then((res) => {
- this.isLoading = false;
- if (res.code == 200) {
- this.orderList = [];
- this.total = res.data.totalNums || 0;
- this.params.pageNum = res.data.pageNum;
- res.data.data.forEach((element) => {
- element.takeTimeTxt = this.$tool.timeago(
- new Date(element.sendTime).getTime()
- );
- if (element.exceptTime && element.delayTime) {
- element.timeTxt = _this.$tool.eosFormatTime2(
- element.exceptTime,
- element.delayTime
- );
- } else {
- element.timeTxt = "";
- }
- this.orderList.push(element);
- });
- } else {
- this.$message({
- message: res.msg,
- type: "error",
- });
- }
- });
- },
- getRefreshOrder() {
- let orderIds = this.orderList.map((v) => {
- return v.id;
- });
- let params = {
- orderIds: orderIds,
- status: this.tabList[this.tabNum].status,
- };
- getRefreshOrder(params).then((res) => {
- if (res.code === 200) {
- let newList = res.data.newList;
- let deliveryList = res.data.deliveryList;
- if (!newList.length && !deliveryList.length) return;
- // 根据exceptTime判断是新订单还是预约单
- let normalList = newList
- .filter((v) => {
- return !v.exceptTime;
- })
- .map((item) => {
- item.buttonStatus = 0;
- return item;
- });
- let appointList = newList
- .filter((v) => {
- return v.exceptTime;
- })
- .map((item) => {
- item.buttonStatus = 10;
- item.exceptTime = this.$tool.getFormatDate(
- item.exceptTime * 1000
- );
- return item;
- });
- // tabNum 0 是新订单 1是预约单
- if (this.tabNum === 1) {
- this.orderList = this.orderList.concat(appointList);
- } else if (this.tabNum === 0) {
- this.orderList = this.orderList.concat(normalList);
- } else {
- this.orderList = this.orderList.concat(newList);
- }
- console.log("deliveryList", deliveryList);
- deliveryList.forEach((item) => {
- this.orderList = this.orderList.filter((v) => {
- return v.id !== item;
- });
- });
- this.total = this.orderList.length;
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped="scoped">
- /deep/ .el-input__inner {
- padding-right: 30px;
- }
- .mainContent {
- width: 100%;
- height: 100%;
- .order_tab {
- width: 100%;
- height: 74px;
- background: #fff;
- .tabList {
- display: flex;
- justify-content: space-around;
- width: 100%;
- padding-top: 20px;
- padding-left: 36px;
- box-sizing: border-box;
- overflow-x: auto;
- .tab_item {
- font-size: 16px;
- font-weight: 500;
- color: #b1b1b1;
- position: relative;
- text-align: center;
- cursor: pointer;
- .tab_line {
- width: 58px;
- height: 6px;
- background: #fff;
- border-radius: 3px;
- margin-top: 15px;
- }
- .point {
- width: 16px;
- height: 16px;
- border-radius: 50%;
- background: #f74141;
- font-size: 12px;
- font-weight: 400;
- color: #ffffff;
- position: absolute;
- top: -5px;
- right: -10px;
- text-align: center;
- line-height: 16px;
- }
- }
- .tab_item_ac {
- color: #fc7200;
- .tab_line {
- background: #fc7200;
- }
- }
- }
- .search {
- display: flex;
- justify-content: flex-end;
- .header_serch {
- width: 80%;
- height: 74px;
- padding-right: 25px;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- .Manual {
- width: 118px;
- height: 44px;
- background: #fc7200;
- border-radius: 6px;
- font-size: 16px;
- font-weight: 500;
- color: #ffffff;
- text-align: center;
- line-height: 44px;
- margin-left: 18px;
- }
- .search_inp {
- width: 380px;
- height: 44px;
- display: flex;
- align-items: center;
- position: relative;
- .inp {
- width: 100%;
- // height: 44px;
- border: none;
- }
- .btn {
- font-size: 22px;
- position: absolute;
- right: 15px;
- }
- }
- }
- }
- }
- .order_list {
- width: 100%;
- height: calc(100vh - 180px);
- margin-top: 10px;
- .list {
- position: relative;
- height: calc(100vh - 210px);
- overflow: hidden;
- }
- .empty-data {
- display: flex;
- align-items: center;
- justify-content: center;
- background-color: #fff;
- height: 100%;
- img {
- width: 349px;
- height: 222px;
- }
- }
- }
- }
- </style>
|