<template>
  <div class="view" v-loading="load">
    <module-view :propConfig="config" ref="view"  @pagination="getList" @onRefresh="getList"/>
  </div>
  
</template>

<script lang="ts">
import { Component, Prop, Vue, Watch } from "vue-property-decorator";
import {dswWaybill} from '@/api/omsOrder'
@Component
export default class WMSPrintLog extends Vue {
  config:any={
    attr:{
      calculateH:true
    },
    tool:{
      tools:{
        // search:true,
        refresh:true
      }
    },
    table:{
      attr:{
        size:'mini',
        seq:true,
        align:'center',
        triggerRowCheck:'row'
      },
      columns:[{
        title:'创建时间',
        field:'createTime',
        width:150
      },{
        title:'方法',
        field:'method',
        width:100
      },{
        title:'响应结果',
        field:'responseInfo',
        ellipsis:true,
        copy:true,
        width:270
      },{
        title:'wms单据编码',
        field:'outerCode',
        width:110,
      },{
        title:'wms单据编码',
        field:'waybillCode',
        width:110
      },{
        title:'物流单号',
        field:'waybillCode',
        width:110
      },{
        title:'商家物流编码',
        field:'cpCode',
        // ellipsis:true,
        width:110
      },{
        title:'发货人信息',
        field:'send',
        ellipsis:true,
        copy:true,
        width:200
      },{
        title:'订单包裹信息',
        field:'packages',
        ellipsis:true,
        copy:true,
        width:300
      },{
        title:'菜鸟必传',
        field:'templateUrl',
        width:130
      },{
        title:'面单平台',
        field:'platformType',
        width:130
      },{
        title:'面单打印数据',
        field:'props',
        ellipsis:true,
        copy:true,
        width:300
      }]
    }
  }
  time:any;
  timeNum = 0;
  data:Array<any>=[]
  load = false;


  getList(){
    if(!this.$refs.view){
      if(this.timeNum > 5){
        return
      }
      this.timeNum ++;
      setTimeout(()=>{
        this.getList()
      },500) 
      return
    }
    let query:any = (this.$refs.view as any).getQuery();
    this.load = true;
    dswWaybill(query).then((res:any) =>{
      this.load = false;
      (this.$refs.view as any).setTableValue(res.data.records);
      let page={
        pageNo: res.data.current, //当前页
        pageSize: res.data.size, //每页条数
        total: res.data.total //总条数
      };
      (this.$refs.view as any).setPage(page)
    }).catch(()=>{
      this.load = false;
    });
    
  }

  mounted(){
    this.$nextTick(()=>{
      this.getList()
    })
  }
}
</script>

<style lang="scss" scoped>
.view{
  width: 100%;
  height: 100%;
  overflow-y: hidden;
}
</style>