<template>
  <el-dialog
    title="全部待办" 
    :visible.sync="infoVisible"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    @close="infoClose"
    custom-class="serviceIndustry-dialog"
    append-to-body
  >
    <div class="serviceIndustry-box">
      <el-form :inline="true" :model="formInline" size="small" class="serviceIndustry-form" ref="queryFrom">
        <el-col :span="20">
          <el-form-item label="待办任务标题：">
            <el-input v-model.trim="formInline.enterpriseDirectory" placeholder="请输入内容"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item>
            <el-button size="mini" @click="resetQuery('queryFrom')">重置</el-button>
            <el-button size="mini" type="primary" @click="handleQuery('queryFrom')">查询</el-button>
          </el-form-item>
        </el-col>
      </el-form>
      <section>
        <el-table 
          v-loading="loading" 
          class="dataMap-work-table" 
          :data="tableData" 
          border
          :row-class-name="tableRowClassName" 
          :header-cell-style="{background:'#D1D9E6'}"
          height="550px"
        >  <!-- :max-height="tabHeader" -->
          <el-table-column label="序号" type="index" align="center" width="50"/>
          <el-table-column label="待办任务标题" prop="enterpriseDirectory" align="center"/>
          <el-table-column label="审核状态" prop="enterpriseDirectory" align="center">
            <template slot-scope="scope">
              <div class="project-trace-table-type">初审中</div>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="200">
            <template slot-scope="scope">
              <div class="workDialog-btns">
                <div class="project-trace-table-number" @click="enterpriseInfo(scope.row)">审批</div>
                <div class="project-trace-table-number" @click="enterpriseInfo(scope.row)">查看详情</div>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <my-pagination 
          :total="total"
          :page="pagination.pageNum"
          :limit="pagination.pageSize"
          @pagination="getPagination"
          :current-page.sync="pagination.pageNum" 
        ></my-pagination>
      </section>
    </div>
  </el-dialog>
</template>
<script>
import myPagination from "@/views/components/Pagination/index.vue"
import { approvalList } from "@/api/onlineDeclartion/pendingReview"
export default {
  components:{myPagination},
  name: "daibanrenwu",
  data() {
    return {
      infoVisible: false,
      loading: false,
      tableData:[],
      formInline:{
        alertContent:"",
        tyshxydm:"",
        servicesType: null,
      },
      pagination: {
        pageNum:1,
        pageSize:10,
      },
      total:40,
      servicesType:null,
    }
  },
  methods:{
    open(title){
      this.infoVisible = true;
      this.servicesType = title;
      this.formInline.servicesType = title;
      this.pagination = {
        pageNum: 1,
        pageSize: 10
      }
      this.pagination = { ...this.pagination,...this.formInline };
      this.getList();
    },
    infoClose(){
      this.infoVisible = false;
    },
    getList(){
      this.loading = true;
      approvalList(this.pagination).then(res=>{
        this.tableData = res.rows
        console.log(this.tableData);
        this.total = res.rows.length;
        this.loading = false;
      })
    },
    // 获取页码
    getPagination(pages) {
      this.pagination.pageNum = pages.page;
      this.pagination.pageSize = pages.limit;
      this.getList();
    },
    // 重置
    resetQuery(){
      this.pagination = {
        pageNum: 1,
        pageSize: 10
      }
      this.formInline = {
        alertContent:"",
        tyshxydm:"",
        servicesType: this.servicesType,
      },
      this.getList();
    },
    // 查询
    handleQuery(){
      this.pagination = {
        pageNum: 1,
        pageSize: 10
      }
      this.pagination = { ...this.pagination,...this.formInline };
      this.getList();
    },
    // 企业详情
    enterpriseInfo(row){
      if(row.isRead == 1) {
        changeIsRead({id:row.id}).then(res=>{
          this.getList();
        })
      }
    },
    // 修改table背景色
    tableRowClassName({row, rowIndex}){
      if (rowIndex % 2 !== 0) {
        return 'evenNumber-row';
      }
      return '';
    },
  },
}
</script>
<style lang="scss" scoped>
::v-deep .serviceIndustry-dialog {
  margin-top: 10vh !important;
}
</style>