<template>
  <div class="app-container">
    <!--搜索区-->
    <div class="float">
      <el-input
        v-model="page.data.name"
        placeholder="请输入姓名"
        clearable
        class="margin-left input"
      />
      <!-- <el-input
        v-model="page.data.passSn"
        placeholder="请输入通行证编号"
        clearable
        class="margin-left input"
      ></el-input>
      <el-select
        filterable
        clearable
        v-model="page.data.qqqqq"
        placeholder="请选择单位"
        class="margin-left input m-b-10"
      >
        <el-option
          v-for="item in unit_list"
          :key="item.code"
          :label="item.desc"
          :value="item.code"
        >
        </el-option>
      </el-select>
      <el-date-picker
        v-model="page.data.startTime"
        type="datetime"
        placeholder="选择起始时间"
        value-format="yyyy-MM-dd HH:mm:ss"
        class="margin-left"
      >
      </el-date-picker>
      <el-date-picker
        v-model="page.data.endTime"
        type="datetime"
        placeholder="选择结束时间"
        value-format="yyyy-MM-dd HH:mm:ss"
        class="margin-left"
      >
      </el-date-picker> -->
      <el-button
        type="primary"
        icon="el-icon-search"
        class="margin-left"
        @click="fetchData"
      >搜索</el-button>
    </div>
    <!--主表格-->
    <el-table
      ref="table_form"
      v-loading="listLoading"
      class="table"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column label="序号" align="center" width="80px">
        <template slot-scope="scope">
          {{ indexMethod(scope.$index) }}
        </template>
      </el-table-column>
      <el-table-column label="引领人姓名" align="center">
        <template slot-scope="scope">
          {{ scope.row.name }}
        </template>
      </el-table-column>
      <el-table-column label="引领人通行证编号" align="center">
        <template slot-scope="scope">
          {{ scope.row.passSn }}
        </template>
      </el-table-column>
      <el-table-column label="有效期开始时间" align="center">
        <template slot-scope="scope">
          {{ scope.row.startTime }}
        </template>
      </el-table-column>
      <el-table-column label="有效期结束时间" align="center">
        <template slot-scope="scope">
          {{ scope.row.endTime }}
        </template>
      </el-table-column>
      <el-table-column label="通行区域" align="center">
        <template slot-scope="scope">
          {{(scope.row.areaList||[]).join('，')}}
        </template>
      </el-table-column>
    </el-table>

    <!--分页栏-->
    <pagination
      :total="total"
      :page.sync="page.pageNum"
      :limit.sync="page.pageSize"
      @pagination="fetchData"
    />
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'
import { leaderList } from '@/api/pass'
export default {
  components: { Pagination },
  filters: {},
  data() {
    return {
      // 主表格&主表格加载状态
      list: [],
      listLoading: true,
      // 分页参数
      page: {
        data: {
          name: null,
          passSn: null,
          startTime: null,
          endTime: null
        },
        pageNum: 1,
        pageSize: 10
      },
      total: 0,
      unit_list: []
    }
  },
  computed: {},
  watch: {},
  created() {
    this.fetchData()
  },
  methods: {
    // 获取列表数据
    fetchData() {
      this.listLoading = true
      leaderList(this.page).then((res) => {
        this.list = res.data.records
        this.total = res.data.total
        this.listLoading = false
      })
    },
    // 返回列表序号
    indexMethod(index) {
      return (this.page.pageNum - 1) * this.page.pageSize + index + 1
    }
  }
}
</script>
<style scoped lang="scss">
</style>
