<template>
  <div class="log-table">
    <el-table
      :data="tableData"
      @cell-dblclick="cellDblclick"
      ref="tableRef"
      highlight-current-row
      size="mini" stripe border>
      <!-- <el-table-column type="index" label="序号" width="60" show-overflow-tooltip>
      </el-table-column> -->
      <el-table-column v-for="(item, index) in colunms" :key="index"
            :prop="item.prop"
            :label="item.label"
            :fixed="item.fixed"
            :class-name="item.prop =='msg'?'align-left':'' "
            :show-overflow-tooltip="item.tooltip"
            :min-width="item.width"
            >
      </el-table-column>

    </el-table>
    <!-- 分页-->
    <ls-pagination
      :curr-page.sync="pager.currPage"
      :page-size.sync="pager.pageSize"
      :total="pager.total"
      :page-options="pager.pageOptions"
      @query="doQuery">
    </ls-pagination>
    <dig-log ref="digLog"></dig-log>
  </div>
</template>

<script>
  import digLog from '@/components/dig-log.vue'

  export default {
    name: 'log-table',
    created() {
      this.doQuery();
    },
    components:{
      digLog
    },
    mounted() {
    },
    methods: {
      // 查询数据
      doQuery () {
        let param = {
          currPage: this.pager.curPage,
          pageSize: this.pager.size,
          busSystem: 'cloud-crm-customer',
          currPage: this.pager.currPage,
          pageSize: this.pager.pageSize,
          busSystem: 'cloud-crm-customer',
          busId:this.busId
        };
        this.$ajax.post({
          domain: 'logUrl',
          url: 'getLogPageList',
          data: param,
          requestType: 'body',
          showLoad: false,
          success: function (res) {
            if (res.errorCode === 200) {
                 this.tableData = res.data.list || [];
                 this.pager.total = res.data.totalCount || 0;
            }
          }.bind(this),
          error: function (res) {
            this.$message(res.body.msg || res.msg)
          }.bind(this)
        })
      },
      handleUpdate(row) {
      },
      cellDblclick(row, column, event) {
        if(row.ext1){
          let index =  location.href.lastIndexOf('/');
          let url =  location.href.substring(0, index);
          if(row.busModel == "客户信息变更"){
            url = url + '/changeInfo?id=' + row.ext1;
          } else if(row.busModel == "代理商报备申请"){
            url = url + '/agent-detail?id=' + row.ext1+'&oper=view'+'&title=报备详情';
          } else if(row.busModel == "客户协议"){
            url = url + '/agrmControl?id=' + row.ext1;
          }else if(row.busModel == "客户集团归属"){
            url = url + '/createGroup?action=check&' + 'groupId=' + row.ext1;
          }
          window.open(url);
        };
      },
    },
    data() {
      return {
        //分页参数
        pager: {
          currPage: 1,
          pageSize: 10,
          pageOptions: [10, 20, 30],
          total: 0
        },

        tableData: [],
        //表格列
        colunms: [
          { prop: 'busModel', label: '所属模块',   width: 80, fixed: false,  tooltip: true },
          { prop: 'operType', label: '日志类型',   width: 80, fixed: false,  tooltip: true },
          { prop: 'createUser', label: '操作人',   width: 80, fixed: false,  tooltip: true },
          { prop: 'createDate', label: '操作时间',   width: 100, fixed: false,  tooltip: true },
          { prop: 'msg', label: '详情',   width: 350, fixed: false,  tooltip: true },
        ]
      }
    },
    props:{
      busId: {
        type: String,
        default: '',
        required: true
      },
    }
  }
</script>

<style scoped>
.log-table{
  margin-top: 15px;
}
</style>
