<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <!--<a-form layout="inline" @keyup.enter.native="searchQuery">-->
        <!--<a-row :gutter="24">-->
          <!--<a-col :md="6" :sm="8">-->
            <!--<a-form-item label="企业名称">-->
              <!--<a-input placeholder="请输入企业名称" v-model="queryParam.companyName"></a-input>-->
            <!--</a-form-item>-->
          <!--</a-col>-->
          <!--<a-col :md="6" :sm="8">-->
            <!--<a-form-item label="平台">-->
              <!--<a-input placeholder="请输入平台" v-model="queryParam.platformName"></a-input>-->
            <!--</a-form-item>-->
          <!--</a-col>-->
          <!--<a-col :md="6" :sm="8" >-->
            <!--<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">-->
              <!--<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>-->
              <!--<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>-->
              <!--&lt;!&ndash;<a @click="handleToggleSearch" style="margin-left: 8px">&ndash;&gt;-->
                <!--&lt;!&ndash;{{ toggleSearchStatus ? '收起' : '展开' }}&ndash;&gt;-->
                <!--&lt;!&ndash;<a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>&ndash;&gt;-->
              <!--&lt;!&ndash;</a>&ndash;&gt;-->
            <!--</span>-->
          <!--</a-col>-->

        <!--</a-row>-->
      <!--</a-form>-->
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="userContract" type="primary" >用户合同</a-button>
      <a-button @click="companyContract" type="primary" >企业合同</a-button>
      <a-button @click="accountStatistics" type="primary" >账户统计</a-button>
    </div>

    <!-- table区域-begin -->
    <div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">


      </a-table>
    </div>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { httpAction,getAction, deleteAction, putActio } from '@/api/manage'
  export default {
    name: "AuthMonitorList",
    mixins:[JeecgListMixin],
    components: {
    },
    data () {
      return {
        type:0,
        description: '合同信息管理页面',
        // 表头
        columns: [
          {
            title:'信息1',
            align:"left",
            dataIndex: 'companyName'
          },
          {
            title:'信息2',
            align:"left",
            dataIndex: 'platformName'
          },
        ],
        columns1: [
          {
            title:'订单id',
            align:"left",
            dataIndex: 'id'
          },
        ],
        columns2: [
          {
            title:'需求id',
            align:"left",
            dataIndex: 'id'
          },
          {
            title:'需求名称',
            align:"left",
            dataIndex: 'name'
          },
        ],
        columns3: [
          {
            title:'企业账户id',
            align:"left",
            dataIndex: 'id'
          },
          {
            title:'错误信息',
            align:"left",
            dataIndex: 'errorMsg'
          }
        ],
        url: {
          list: "",
          list1: "/oauth/autoMonitor/userContract",
          list2: "/oauth/autoMonitor/companyContract",
          list3: "/oauth/autoMonitor/statisticData",
        },
        dictOptions:{
        }
      }
    },
    computed: {
      // importExcelUrl: function(){
      //   return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      // }
    },
    methods: {
      userContract(){
        this.columns=this.columns1;
        this.type=1;
        this.loadData1(1)
      },
      companyContract(){
        this.columns=this.columns2;
        this.type=2;
        this.loadData1(1)
      },
      accountStatistics(){
        this.columns=this.columns3;
        this.type=3;
        this.loadData1(1)
      },
      loadData(arg) {

      },
      loadData1(arg) {
        //加载数据 若传入参数1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        var params = this.getQueryParams();//查询条件
        this.loading = true;
        var url="";
        if( this.type==1){
          url=this.url.list1;
        }else if(this.type==2){
          url=this.url.list2;
        }else if(this.type==3){
          url=this.url.list3;
        }
        getAction(url, params).then((res) => {
          if (res.success) {
            this.dataSource = res.result.records;
            this.ipagination.total = res.result.total;
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
          this.loading = false;
        })
      },

      handleTableChange(pagination, filters, sorter) {
        //分页、排序、筛选变化时触发
        //TODO 筛选
        if (Object.keys(sorter).length > 0) {
          this.isorter.column = sorter.field;
          this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
        }
        this.ipagination = pagination;
        this.loadData1(this.ipagination.current);
      },

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>