<template>
  <div class="page-contain list-contain">
    <top-nav :title="title"
             :showQuery="false"></top-nav>
    <van-list :finished="finished"
              finished-text="没有更多了"
              @load="getLogPage"
              :immediate-check="false"
              class="data-list">
      <div v-for="(item,index) in dataList"
           :key="index"
           class="collapse-box"
           style="margin:10px">
        <div class="top"
             style="padding-top:0px;">
          <div class="row ptb20"
               style="color:#008cee;font-weight:bold">
            <span>{{item.operType}}</span>
          </div>
          <div class="row">
            <span>操作人：{{item.createUser}}</span>
            <span>时间：{{item.createDate}}</span>
          </div>
        </div>
        <div class="info-box"
             style="padding-bottom:0px">
          <div class="info-item">
            <span>详情：</span>
            <span>{{item.msg}}</span>
          </div>
        </div>

      </div>
    </van-list>

  </div>
</template>

<script>

export default {
  name: 'operation-log',
  data () {
    return {
      title: '操作日志',
      finished: false,
      busId: '',

      dataList: [],
      total: 0,
      pageSize: 0,
      currPage: 1
    }
  },
  created () {
    let title = this.$route.params.title
    if (this.$route.params.title) {
      this.title = title
    }
    this.busId = this.$route.params.busId || ''
    this.getLogPage()
  },
  methods: {
    getLogPage () {
      this.pageSize += 10
      let param = {
        currPage: this.currPage,
        pageSize: this.pageSize,
        busSystem: 'cloud-crm-project',
        busId: this.busId
      }

      this.$axios.post({
        domain: 'logUrl',
        url: 'getLogPageList',
        data: param,
        requestType: 'body',
        isShow: false,
        success: function (res) {
          if (res.errorCode === 200) {
            this.dataList = res.data.list || []
            this.total = res.data.totalCount
            if (this.dataList.length >= this.total) {
              this.finished = true
            }
          } else {
            this.$toast({ type: 'fail', message: res.msg })
          }
        }.bind(this),
        error: function (err) {
          this.$toast({ type: 'fail', message: err, duration: 3000 })
        }.bind(this)
      })
    }

  }
}
</script>

<style scoped  lang="scss">
.info-item {
  span:first-child {
    min-width: 80px;
    white-space: nowrap;
    margin-right: 10px;
  }
}

.info-box {
  border: none;
}
.top {
  border-bottom: 1px solid #e9e9e9;
  @extend .info-box;
}
</style>
