<template>
  <div>
    <el-form class="fr" label-width="100px" :inline="true">
      <el-form-item prop="keyword">
        <el-input
          placeholder="请输入搜索关键字"
          v-model="keyword"
          clearable
          @clear="getListData"
        >
        </el-input>
      </el-form-item>
      <el-button type="primary" class="ml5" @click="getListData"
        >搜索</el-button
      >
    </el-form>
    <el-table
      :data="tableData"
      tooltip-effect="dark"
      v-loading="loading"
      @selection-change="handleSelectionChange"
      style="width: 100%"
    >
      <el-table-column
        type="selection"
        align="center"
        width="55"
      ></el-table-column>
      <el-table-column label="序号" align="center" type="index" width="50">
      </el-table-column>
      <el-table-column
        label="考核类别"
        show-overflow-tooltip
        prop="jjmkl_name"
      ></el-table-column>
      <el-table-column
        label="创建人"
        show-overflow-tooltip
        prop="jjmkl_cjr"
      ></el-table-column>
      <el-table-column
        label="创建时间"
        show-overflow-tooltip
        prop="jjmkl_cjsj"
      ></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" @click="detailData(scope.row)"
            >详情
          </el-button>
        </template></el-table-column
      >
    </el-table>
    <footer
      class="flex-item-none"
      style="display: flex; justify-content: flex-end; margin-top: 30px"
    >
      <el-pagination
        background
        layout="total,prev, pager, next"
        :page-size="limit"
        :total="total"
        :current-page.sync="cur_page"
        @current-change="handleCurrentChange"
      ></el-pagination>
    </footer>
  </div>
</template>

<script>
import { lbgl_add, lbgl_list } from "./api";
export default {
  name: "index",
  data() {
    return {
      loading: false,
      keyword: "",
      tableData: [],
      rwList: [],
      limit: 10,
      total: 1,
      cur_page: 1,
    };
  },
  methods: {
    getListData() {
      this.loading = true;
      let data = {
        limit: this.limit,
        page: this.cur_page,
        jjmkl_cjr: this.keyword,
        jjmkl_pid:0
      };
      lbgl_list(data).then((res) => {
        if (res.code == "1") {
          this.tableData = res.data.page_data;
          this.cur_page = Number(res.data.page_now);
          this.total = Number(res.data.total_rows);
          this.loading = false;
        }
      });
    },
    detailData(item) {
      this.$router.push({
        name: "jsld_myjsjxkh_lbgl_detail",
        params: {
          id: item.jjmkl_id
        }
      });
    },
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getListData();
    },
    handleSelectionChange(val) {
      this.multipleSelection = [];
      for (let i in val) {
        this.multipleSelection.push(val[i].jddp_id);
      }
    },
  },
  mounted() {
    this.getListData();
  },
};
</script>

<style scoped>
</style>