<template>
  <div>
    <div class="d-flex flex-right">
      <el-form label-width="100px" :inline="true">
        <el-form-item prop="state_value">
          <el-select class="mr10" v-model="type_value" placeholder="请选择类别">
            <el-option
              v-for="item in type_list"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <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>
    </div>
    <el-table :data="tableData" tooltip-effect="dark" 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="bt"
        width="auto"
      ></el-table-column>
      <el-table-column label="创建人" width="200" prop="cjr"></el-table-column>
      <el-table-column label="日期" width="150" prop="rq"></el-table-column>
      <el-table-column label="是否参与" prop="sfcy" width="150">
      </el-table-column>
      <el-table-column label="状态" prop="ztmc" width="150"> </el-table-column>
      <!-- <el-table-column label="操作" width="150">
        <template slot-scope="scope">
          <el-button type="text" @click="">参与投票 </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>
export default {
  name: "index",
  data() {
    return {
      keyword: "",
      type_value: "",
      type_list: [
        {
          label: "全部",
          value: "0",
        },
        {
          label: "未参与",
          value: "1",
        },
        {
          label: "已参与",
          value: "2",
        },
      ],
      tableData: [
        {
          id: "1",
          bt: "关于学校调研报告",
          cjr: "周静",
          rq: "2021/07/22",
          sfcy: "未参与",
          ztmc: "进行中",
        },
        {
          id: "2",
          bt: "关于学校调研报告",
          cjr: "周静",
          rq: "2021/07/22",
          sfcy: "未参与",
          ztmc: "进行中",
        },
        {
          id: "3",
          bt: "关于学校调研报告",
          cjr: "周静",
          rq: "2021/07/22",
          sfcy: "未参与",
          ztmc: "进行中",
        },
        {
          id: "4",
          bt: "关于学校调研报告",
          cjr: "周静",
          rq: "2021/07/22",
          sfcy: "未参与",
          ztmc: "进行中",
        },
        {
          id: "5",
          bt: "关于学校调研报告",
          cjr: "周静",
          rq: "2021/07/22",
          sfcy: "未参与",
          ztmc: "进行中",
        },
        {
          id: "6",
          bt: "关于学校调研报告",
          cjr: "周静",
          rq: "2021/07/22",
          sfcy: "未参与",
          ztmc: "进行中",
        },
        {
          id: "7",
          bt: "关于学校调研报告",
          cjr: "周静",
          rq: "2021/07/22",
          sfcy: "未参与",
          ztmc: "进行中",
        },
        {
          id: "8",
          bt: "关于学校调研报告",
          cjr: "周静",
          rq: "2021/07/22",
          sfcy: "未参与",
          ztmc: "进行中",
        },
        {
          id: "9",
          bt: "关于学校调研报告",
          cjr: "周静",
          rq: "2021/07/22",
          sfcy: "已参与",
          ztmc: "进行中",
        },
        {
          id: "10",
          bt: "关于学校调研报告",
          cjr: "周静",
          rq: "2021/07/22",
          sfcy: "未参与",
          ztmc: "进行中",
        },
      ],
      limit: 10,
      total: 12,
      cur_page: 1,
      loading: false,
    };
  },
  methods: {
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getListData();
    },
    getListData() {
      this.loading = true;
      let data = {
        page: this.cur_page,
        limit: this.limit,
        keyword: this.keyword,
      };

      wfqd_list(data).then((res) => {
        this.loading = false;
        this.tableData = res.data.page_data;
        this.cur_page = Number(res.data.page_now);
        this.total = Number(res.data.total_rows);
      });
    },
  },
};
</script>

<style scoped>
</style>