<template>
  <div>
    <div class="d-flex flex-right">
      <el-form label-width="100px" :inline="true">
        <el-form-item prop="state_value">
          <el-select
            class="mr15"
            v-model="state_value"
            placeholder="请选择状态"
            @change="getListData"
          >
            <el-option
              v-for="item in state_list"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-form-item prop="time">
            <el-date-picker
              style="width: 100%"
              @change="getListData"
              v-model="time"
              value-format="yyyy-MM-dd"
              type="date"
              placeholder="请选择日期"
            >
            </el-date-picker>
          </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-item>
      </el-form>
    </div>
    <el-table :data="tableData" tooltip-effect="dark" style="width: 100%">
      <el-table-column label="序号" align="center" type="index" width="50">
      </el-table-column>
      <el-table-column label="标题" show-overflow-tooltip width="auto">
        <template slot-scope="scope">
          <a
            href="javascript:;"
            @click="toDetail(scope.row.wwj_id)"
            class="text-normal"
            >{{ scope.row.wwj_title }}</a
          >
        </template>
      </el-table-column>
      <el-table-column
        label="发起人"
        width="150"
        prop="wwj_fqr"
      ></el-table-column>
      <el-table-column
        label="截止日期"
        width="150"
        prop="www_jzsj"
      ></el-table-column>
      <el-table-column label="状态" width="100">
        <template slot-scope="scope">
          <span v-if="scope.row.wwj_zt_option_k == 1">正常</span>
          <span v-if="scope.row.wwj_zt_option_k == 2" class="text-orange"
            >即将超期</span
          >
          <span v-if="scope.row.wwj_zt_option_k == 3" class="text-red"
            >已结束</span
          >
        </template>
      </el-table-column>
      <el-table-column label="进度" width="200">
        <template slot-scope="scope">
          <el-progress
            :percentage="Number(scope.row.wwj_jd)"
            color="#4351FF"
          ></el-progress>
        </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 { wtjd_list } from "./api";
export default {
  name: "index",
  data() {
    return {
      state_value: "",
      keyword: "",
      state_list: [
        {
          label: "全部",
          value: "0",
        },
        {
          label: "正常",
          value: "1",
        },
        {
          label: "即将超期",
          value: "2",
        },
        {
          label: "结束",
          value: "3",
        },
      ],
      time: "",
      tableData: [],
      limit: 10,
      total: 0,
      cur_page: 1,
    };
  },
  methods: {
    getListData() {
      let data = {
        page: this.cur_page,
        limit: this.limit,
        keyword: this.keyword,
        www_jzsj: this.time,
        wwj_zt: this.state_value,
      };
      wtjd_list(data).then((res) => {
        this.tableData = res.data.page_data;
        this.cur_page = Number(res.data.page_now);
        this.total = Number(res.data.total_rows);
      });
    },
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getListData();
    },
    toDetail(id) {
      this.$router.push({ name: "wjsj_wtjd_wjxq", params: { id: id } });
    },
  },
  mounted() {
    this.getListData();
  },
};
</script>

<style lang="scss" scoped>
.el-button--text {
  color: #4351ff;
}
</style>