index.vue 7.19 KB
Newer Older
张锡奇's avatar
张锡奇 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
<style lang="less" >
    #searchOrderList{
        height:100%;
        background:#eef4fe;
        display:flex;
        flex-direction: column;
        /deep/ .weui-cell_access .weui-cell__ft:after{
            height: 10px;
            width: 10px;
            margin-top: -4px;
            right: 0;
        }
        .Table{
            flex-grow: 1;
            height:1px;
            overflow: auto;
            // -webkit-overflow-scrolling: touch;
        }
        .modal>.content,.modal_active>.content{
            .item{
                width: 240px;
                height: 180px;
                background:#eef4fe;
                border-radius:10px;
                display: flex;
                flex-direction: column;
                .content{
                    height:1px;
                    flex-grow: 1;
                    div{
                        height:40px;
                        line-height: 40px;
                        text-align: center;
                        color:#5cadff;
                    }
                }
            }
        }
    }
</style>

<template>
  <div id="searchOrderList">
    <div class="header">
        <searchComponent placeholder="请输入订单号/客户..." :search="search" :status="status" :typeList="typeList"/>
    </div>
    <div class="Table">
        <customerTable :columns="columns" :list="list" :tableStyle="tableStyle"></customerTable>  
    </div>
    <!-- <customerModal :showModal="showModal">
        <div class="item">
            <div class="content">
                <div style="color:#000;font-weight:bold;">选择查看内容</div>
                <div @click="routerToDetail">订单明细</div>
                <div @click="routerToTarck">全流程跟踪</div>
            </div>
            <div class="btns">
                <x-button type="primary" style="background:#6b9bf7;" @click.native="closeModal">取消</x-button>
            </div>
        </div>
    </customerModal> -->
  </div>
</template>

<script>
import Util from '@/libs/util.js'
import searchComponent from '@/components/search'
import customerTable from '@/components/Table'
import customerModal from '@/components/Modal'

import { XButton } from 'vux'

export default {
  name: 'searchOrderList',
  data () {
    return {
        search:{
            dBeginDate:Util.dateFormat(new Date(),'yyyy-MM-01'),
            dEndDate:Util.dateFormat(new Date(),'yyyy-MM-dd'),
            page:1,
            per_page:30,
            sStatus:'全部'
        },
        list:[],
        columns:[
            {
                width:'30%',
                name:'单号',
                align:'center',
                field:'sOrderNoHTML',
                underline:true,
                color:'#2d8cf0',
                fixed:true,
                fixedLeftWidth:'0px'
            },
            {
                width:'40%',
                name:'客户',
                align:'center',
                field:'sCustomerName',
            },
            {
                width:'20%',
                name:'数量',
                align:'center',
                field:'nQty',
            },
            {
                width:'20%',
                name:'销售员',
                align:'center',
                field:'sSalesName'
            },
            {
                width:'20%',
                name:'状态',
                align:'center',
                field:'sStatus'
            }
        ],
        tableStyle:{
            theadBgColor:'rgba(223,238,253,1)',
            complexTrBgColor:'white',
            singleTrBgColor:'#eef4fe',
            theadTdBorder:false,
            tbodyTdBorder:false,
张锡奇's avatar
张锡奇 committed
127 128
            tbodyHeight:'calc(100vh - 120px)',
            tbodyTrBorderBottom:'1px solid #dbe9f8',
张锡奇's avatar
张锡奇 committed
129 130 131 132 133 134 135 136 137 138 139 140 141
            width:'100%'
        },
        host:'https://weixin.huansi.net/apiproxy/huansi/service/proxy/',
        // host:'http://192.168.4.40:5001',
        status:[],
        showModal:false,
        row:{},
        typeList:{
            input:true,
            select:true,
            btns:true,
            time:true
        },
godwithdh's avatar
godwithdh committed
142 143
        
        upbCustomerGUID:'',//客户ID
张锡奇's avatar
张锡奇 committed
144 145 146 147
    }
  },
  async mounted(){
    window.d = this;
godwithdh's avatar
godwithdh committed
148 149

    this.upbCustomerGUID=this.$route.query.upbCustomerGUID||""
张锡奇's avatar
张锡奇 committed
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
    await this.getStatus();
    await this.getHdr();
    this.$store.dispatch('saveUserId',this.$route.params.userId);
  },
  async activated(){
    this.showModal = false;
    this.global.$off('searchData');
    this.global.$off('scrollTable');
    this.global.$off('clickTd');

    //查询条件触发加载
    this.global.$on('searchData',async ()=>{
        this.cleanSearch();
        this.getHdr();
    });
    //滚动加载
    this.global.$on('scrollTable',async ()=>{
        this.getHdr(true);
    })
    //点击表格列触发
    this.global.$on('clickTd',async(res)=>{
        // this.showModal = res.showModal;
张锡奇's avatar
张锡奇 committed
172
        this.row = this.list[res.trIndex];
张锡奇's avatar
张锡奇 committed
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
        this.routerToTarck();
    })
  },
  methods:{
    async getStatus(){
        let res = await this.apiGet(`${this.host}${this.$route.params.userId}/fabricorder/status/`,{},true);
        this.status = res;
        this.status.map(x=>{
            x.sStatus = x.sStatus || '全部';
        })
    },
    async getHdr(flag){
        if(this.search.per_page < 30){
            this.$vux.toast.text('已加载全部数据!', 'middle')
            return false;
        }
        let data = Util.deepClone(this.search);
        if(this.search.sStatus == '全部'){
            let status = [];
            this.status.map(x=>{
                if(x.sStatus != '全部') status.push(x.sStatus);
            })
            data.sStatus = status.join(',');
        }
张锡奇's avatar
张锡奇 committed
197
        data.searchvalue == '' && (delete data.searchvalue);
godwithdh's avatar
godwithdh committed
198
        this.upbCustomerGUID&&(data.upbCustomerGUID=this.upbCustomerGUID)
张锡奇's avatar
张锡奇 committed
199 200 201 202 203
        data.begin_date = data.dBeginDate;
        data.end_date = data.dEndDate;
        delete data.dBeginDate;
        delete data.dEndDate;

godwithdh's avatar
godwithdh committed
204 205
        let res = await this.apiGet(`${this.host}${this.$route.params.userId}/fabricorder/hdr/`,data,'加载中')
        // let res = await this.apiGet(`http://weixin.huansi.net/apiproxy/huansi/hszh_HSFabricTradeTest/fabricorder/hdr/`,data,'加载中')
张锡奇's avatar
张锡奇 committed
206
        
张锡奇's avatar
张锡奇 committed
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
        if(res.table.length > 0){
            res.table.map(x=>{
                x.dReceivedDate = x.dReceivedDate.split(' ')[0]
                x.sOrderNoHTML = `<div><span style="text-decoration:underline;">${x.sOrderNo}</span></div>`
            });
            
            if(flag){
                this.list = this.list.concat(res.table);
            }else{
                this.list = res.table;
            }
            this.search.page++;
            this.search.per_page = res.table.length;
        }
    },
    closeModal(){
        this.showModal = false;
    },
    cleanSearch(){
        this.search.page = 1;
        this.search.per_page = 30;
        this.list = [];
    },
    routerToDetail(){
        this.$store.dispatch('searchOrderSaveHdr',this.row);
        this.$router.push({name:'searchOrderDetail'})
    },
    routerToTarck(){
        this.$store.dispatch('searchOrderSaveHdr',this.row);
        this.$router.push({name:'searchOrderTrack'})
    }
  },
  components:{
      searchComponent,
      XButton,
      customerTable,
      customerModal
  },
}
</script>