<template>
  <div class="main">
    <!-- <div class="form-box">
      <el-form
        ref="searchForm"
        :model="searchForm"
        label-position="left"
        label-width="80px"
      >
        <el-row :gutter="36">
          <el-col :span="8">
            <el-form-item label="客户名称" prop="custName">
              <el-input
                v-model="searchForm.custName"
                placeholder="请输入客户名称"
                style="width:200px"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div class="button">
        <el-button type="primary" @click="handleSearch">查询</el-button>
        <el-button @click="handleResetSearch">重置</el-button>
      </div>
    </div> -->

    <div class="table-box">
      <el-table
        ref="tableRef"
        :data="tableData"
        style="widht: 100%"
        ighlight-current-row
      >
        <el-table-column label="网点id" prop="outletId" ellipsis min-width="120" show-overflow-tooltip />
        <el-table-column label="网点名称" prop="outletName" min-width="140" show-overflow-tooltip />
        <el-table-column label="支行id" prop="branchId" min-width="120" show-overflow-tooltip />
        <el-table-column label="支行名称" prop="branchName" min-width="140" show-overflow-tooltip />
        <el-table-column label="柜员号" prop="managerId" min-width="120" show-overflow-tooltip />
        <el-table-column label="柜员姓名" prop="managerName" min-width="120" show-overflow-tooltip />
        <el-table-column label="基期认领客户数" prop="baseClaimCustCnt" min-width="120" show-overflow-tooltip />
        <el-table-column label="基期认领账户数" prop="baseClaimAcctCnt" min-width="120" show-overflow-tooltip />
        <el-table-column label="基期存款余额" prop="baseDepBal" min-width="120" show-overflow-tooltip />
        <el-table-column label="基期存款日均" prop="baseDepAvg" min-width="120" show-overflow-tooltip />
        <el-table-column label="基期代发工资客户数" prop="baseDfgzCnt" min-width="140" show-overflow-tooltip />
        <el-table-column label="基期企业互联产品数" prop="baseQyhlProdCnt" min-width="140" show-overflow-tooltip />
        <el-table-column label="基期代扣代缴产品数" prop="baseDkdjProdCnt" min-width="140" show-overflow-tooltip />
        <el-table-column label="报告期认领客户数" prop="reportClaimCustCnt" min-width="140" show-overflow-tooltip />
        <el-table-column label="报告期认领账户数" prop="reportClaimAcctCnt" min-width="140" show-overflow-tooltip />
        <el-table-column label="报告期存款余额" prop="reportDepBal" min-width="120" show-overflow-tooltip />
        <el-table-column label="报告期存款日均" prop="reportDepAvg" min-width="120" show-overflow-tooltip />
        <el-table-column label="报告期代发工资客户数" prop="reportDfgzCnt" min-width="150" show-overflow-tooltip />
        <el-table-column label="报告期企业互联产品数" prop="reportQyhlProdCnt" min-width="150" show-overflow-tooltip />
        <el-table-column label="报告期代扣代缴产品数" prop="reportDkdjProdCnt" min-width="150" show-overflow-tooltip />
        <el-table-column label="数据日期" prop="dataDate" min-width="120" show-overflow-tooltip />
        <!-- <el-table-column label="操作" prop="edit" width="120" fixed="right">
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              @click="handleViewDetail(scope.row)"
            >查看</el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <el-pagination
        :current-page="currentPage"
        :page-sizes="[10, 20, 30, 50]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handlepageChange"
      />
    </div>

    <search-detail ref="detailRef" />
    <add-record ref="addRef" @update="getData" />
  </div>
</template>

<script>
import { resultList } from '@/api/report.js'
import SearchDetail from './components/searchDetail.vue'
import AddRecord from './components/addRecord.vue'
import { downloadFiles } from '@/utils'
export default {
  components: {
    SearchDetail,
    AddRecord
  },
  data() {
    return {
      searchForm: {},
      tableData: [],
      currentPage: 1,
      pageSize: 10,
      total: 0
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      const params = {
        pageNum: this.currentPage,
        pageSize: this.pageSize,
        ...this.searchForm
      }

      resultList(params).then((res) => {
        if (res.code !== 200) return
        this.tableData = res.rows || []
        this.total = res.total
      })
    },

    handleSizeChange(newSize) {
      this.pageSize = newSize
      this.getData()
    },

    handlepageChange(newPage) {
      this.currentPage = newPage
      this.getData()
    },

    handleSearch() {
      this.currentPage = 1
      this.getData()
    },

    handleResetSearch() {
      this.searchForm = {}
      this.handleSearch()
    },

    handleViewDetail(row) {
      this.$refs.detailRef.openDrawer(row)
    },
    handleEdit() {
      this.$refs.addRef.openDrawer(row)
    }
  }
}
</script>

<style lang="scss" scoped>
.main {
  padding: 30px 16px;
  .form-box {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
  }

  .control-button {
    margin-bottom: 16px;
  }

  .table-box {
    .el-pagination {
      float: right;
      margin-top: 8px;
    }
  }
}
</style>
