<template>
  <div>
    <div class="d-flex flex-between">
      <div>
      </div>
      <el-form label-width="100px" :inline="true">
        <el-form-item prop="jdd_id">
          <el-select class="mr10" v-model="jdd_id" @change="getListData" placeholder="请选择">
            <el-option v-for="item in rwList" :key="item.jdd_id" :label="item.jdd_name" :value="item.jdd_id"></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" v-loading="loading" 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="jdd_name" width="auto"></el-table-column>
      <el-table-column label="督导类型" width="" prop="jdd_ddlx"></el-table-column>
      <el-table-column label="督导对象" width="" prop="jdd_dddx"></el-table-column>
      <el-table-column label="附件数" prop="jdd_fjs" width="100">
      </el-table-column>
      <el-table-column label="责任人" prop="jdd_zrr" width="100">
      </el-table-column>
      <el-table-column label="责任部门" prop="jdd_uo_name" width="100">
      </el-table-column>
      <el-table-column label="任务开始时间" prop="jdd_start_date" width="">
      </el-table-column>
      <el-table-column label="任务结束时间" prop="jdd_end_date" width="">
      </el-table-column>
      <el-table-column label="任务内容" show-overflow-tooltip prop="jdd_content" width="auto">
        <!-- <template slot-scope="scope">
          <div v-html="scope.row.jdd_content"></div>
        </template> -->
      </el-table-column>
      <el-table-column label="操作" width="150">
        <template slot-scope="scope">
          <el-button type="text" @click="toDetail(scope.row.jdd_id,scope.row.jdd_ddlx_option_k)">详情 </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 { ddzs_list, ddrw_list } from "./api";
export default {
  name: "index",
  data() {
    return {
      keyword: "",
      rwList: [],
      tableData: [],
      limit: 10,
      total: 12,
      cur_page: 1,
      loading: false,
      jdd_id: ""
    };
  },
  methods: {
    getrwList() {
      let data = {
        page: 1,
        limit: 999,
      };

      ddrw_list(data).then((res) => {
        this.rwList = res.data.page_data;
        let obj = {
          jdd_id: "",
          jdd_name: "全部",
        };
        this.rwList.unshift(obj);
      });
    },
    getListData() {
      this.loading = true;
      let data = {
        page: this.cur_page,
        limit: this.limit,
        keyword: this.keyword,
        jdd_id: this.jdd_id,
        ptype: "5",
        jdd_ddzs_status: "1"
      };

      ddzs_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);
      });
    },
    //  1 是教育局没指标 2 教育局有指标  3 学校没指标 4学校有指标
    toDetail(id, jdd_ddlx_option_k) {
      if (jdd_ddlx_option_k == "1") {
        this.$router.push({ name: "dddx_jyjwzb_detail", params: { id: id } });
      }
      if (jdd_ddlx_option_k == "2") {
        this.$router.push({ name: "dddx_jyj_detail", params: { id: id } });
      }
      if (jdd_ddlx_option_k == "3") {
        this.$router.push({ name: "dddx_xxwzb_detail", params: { id: id } });
      }
      if (jdd_ddlx_option_k == "4") {
        this.$router.push({ name: "dddx_xxyzb_detail", params: { id: id } });
      }

    },
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getListData();
    },

  },
  mounted() {
    this.getListData();
    this.getrwList();
  },
};
</script>

<style scoped>
</style>