<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 { dsCallbackLog, IResponeData, ICallbackLog } from '@/api/omsOrder'
@Component
export default class BackCallLog 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: 'dsMethod',
        width: 100
      }, {
        title: '业务编码',
        field: 'dsTag',
        width: 100
      }, {
        title: '参数签名',
        field: 'dsSign',
        width: 140,
      }, {
        title: '请求时',
        field: 'dsTimestamp',
        width: 150
      }, {
        title: 'URL参数',
        field: 'dsParams',
        ellipsis: true,
        width: 180
      }, {
        title: 'Body参数',
        field: 'dsBody',
        ellipsis: true,
        width: 650
      }, {
        title: '该回调是否已处理',
        field: 'isProcess',
        width: 130
      }, {
        title: '响应信息',
        field: 'respMsg',
        ellipsis: true,
        width: 200
      }]
    }
  }
  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;
    dsCallbackLog(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>