<template>
  <div class="app-container">
    <el-form ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="开始日期：">
        <el-date-picker
          v-model="recordDate"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          format="yyyy 年 MM 月 dd 日"
          value-format="yyyy-MM-dd"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="岗检编号：">
        <el-input
          v-model="queryParams.reportNo"
          placeholder="请输入岗位名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table border v-loading="loading" :data="tableData">
      <el-table-column label="序号" align="center" width="80">
        <template slot-scope="scope">
          <span>{{
            scope.$index + 1 + (queryParams.pageNum - 1) * queryParams.pageSize
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="岗检编号" align="center" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.reportNo ? scope.row.reportNo : '--' }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="岗检报告名称"
        align="center"
        show-overflow-tooltip
      >
        <template slot-scope="scope">
          <span>{{ scope.row.reportName ? scope.row.reportName : '--' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="记录时间" align="center" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.startTime ? scope.row.startTime : '--' }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        width="120"
      >
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="
              $router.push(
                `/jobinspectionHistory/jobinspectionHistoryLook?id=${scope.row.id}`
              )
            "
            >查看</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { historyList } from '@/api/allApi/index.js'
export default {
  name: 'PostResponsibilityMeun',

  data() {
    return {
      recordDate: [],
      queryParams: {
        reportNo: '',
        pageNum: 1,
        pageSize: 10
      },
      tableData: [],
      total: 0,
      loading: false,
      showSearch: true
    }
  },

  mounted() {
    this.getList()
  },

  methods: {
    /** 查询岗位列表 */
    getList() {
      this.loading = true
      historyList(this.addDateRange(this.queryParams, this.recordDate)).then(
        (response) => {
          this.tableData = response.rows
          this.total = response.total
          this.loading = false
        }
      )
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        reportNo: '',
        pageNum: 1,
        pageSize: 10
      }
      this.recordDate = []
      this.handleQuery()
    }
  }
}
</script>

<style lang="scss" scoped>
</style>