<!-- 异常待办提醒 -->
<template>
  <div class="L-public-main" id="L-size-main">
    <div class="L-main">
      <header id="L-header">
        <el-form :inline="true" :model="formInline" size="small" class="demo-form-inline" ref="queryFrom">
          <el-col :span="24">
            <el-form-item label="待办任务标题：" prop="enterpriseDirectory">
              <el-input v-model.trim="formInline.enterpriseDirectory" placeholder="请输入内容"></el-input>
            </el-form-item>
            <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>
      </header>
      <section>
        <el-table v-loading="loading" :data="tableData" :row-class-name="tableRowClassName" :height="tabHeader" :max-height="tabHeader">
          <el-table-column label="序号" type="index" align="center" width="50"/>
          <el-table-column label="待办任务标题" align="center" prop="enterpriseDirectory" />
          <el-table-column label="申报时间" align="center" prop="createTime">
            <template slot-scope="scope">
              <!-- <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span> -->
              <span>{{ scope.row.createTime }}</span>
            </template>
          </el-table-column>
          <el-table-column label="审核状态" align="center" prop="cylx">
            <template slot-scope="scope">
              <span v-if="scope.row.status == 5" class="approval_status5">评审通过</span>
              <!-- <span v-if="scope.row.status == 4" class="approval_status3">市级评定中</span> -->
              <span v-if="scope.row.status == 3" class="approval_status3">终审中</span>
              <span v-if="scope.row.status == 2" class="approval_status1">复审中</span>
              <span v-if="scope.row.status == 1" class="approval_status1">初审中</span>
              <span v-if="scope.row.status == 0" class="approval_status0">待填报</span>
              <span v-if="scope.row.status == 8" class="approval_status8">初审不通过</span>
              <span v-if="scope.row.status == 7" class="approval_status9">复审不通过</span>
              <!-- <span v-if="scope.row.status == 6" class="approval_status9">专家评审-拒绝</span> -->
              <span v-if="scope.row.status == 6" class="approval_status5">已填报</span>
              <span v-if="scope.row.status == 9" class="approval_status9">终审不通过</span>
              <span v-if="scope.row.status == 10" class="approval_status9">初审驳回</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" prop="userId" align="center" class-name="table-operation" width="120">
            <template slot-scope="scope">
              <span class="look-info" @click="goInfo(scope.row)">查看详情</span>
            </template>
          </el-table-column>
        </el-table>
        <my-pagination 
          id="L-pagination"
          :total="total"
          :page="pagination.current"
          :limit="pagination.size"
          @pagination="getPagination"
          :current-page.sync="pagination.current" 
        ></my-pagination>
      </section>
    </div>
  </div>
</template>
<script>
import myPagination from "@/views/components/Pagination/index.vue"
import { listRecords } from "@/api/onlineDeclartion/records"
export default {
  components:{myPagination},
  data() {
    return {
      userType: this.$store.state.user.userType,
      deptId: this.$store.state.user.deptId,
      total:0,
      pagination: {
        current:1,
        size:10,
        orderChange:0,
      },
      loading:false,
      formInline: {
        enterpriseDirectory: '',
        type: null,
      },
      tableData:[],
      tabHeader: undefined,
    }
  },
  mounted() {
    this.cancalDebounce();
    window.addEventListener('resize', this.cancalDebounce);
    // if(this.$route.params.enterpriseName) {
    //   this.formInline.enterpriseName = this.$route.params.enterpriseName;
    //   this.pagination = { ...this.pagination,...this.formInline };
    // }
    this.getList();
  },
  destroyed() {
    window.removeEventListener('resize', this.cancalDebounce);
  },
  methods:{
    // 列表获取
    getList(){
      this.loading = true;
      listRecords(this.pagination).then(res=>{
        this.loading = false;
        this.total = res.total;
        this.tableData = res.rows;
      })
    },
    // 获取页码
    getPagination(pages) {
      this.pagination.current = pages.page;
      this.pagination.size = pages.limit;
      this.getList();
    },
    // 查询
    handleQuery() {
      this.pagination = {
        current: 1,
        size: 10
      }
      this.pagination = { ...this.pagination,...this.formInline };
      this.getList();
    },
    // 重置
    resetQuery(formName){
      this.$refs[formName].resetFields();
      this.pagination = {
        current: 1,
        size: 10
      }
      this.getList();
    },
    // 修改table背景色
    tableRowClassName({row, rowIndex}){
      if (rowIndex % 2 !== 0) {
        return 'evenNumber-row';
      }
      return '';
    },
    // 查看详情
    goInfo(row){
      // this.$router.push({
      //   name: 'enterpriselibraryInfo',
      //   query: { userId: row.id, creditCode: row.tyshxydm }
      // })
    },
    // 屏幕尺寸变化
    cancalDebounce(){
      const element = document.getElementById('L-size-main'); // 通过元素的 ID 获取元素
      const header = document.getElementById('L-header'); // 通过元素的 ID 获取元素
      const pagination = document.getElementById('L-pagination'); // 通过元素的 ID 获取元素
      const elementHeight = element.offsetHeight;
      const headerHeight = header.offsetHeight;
      const paginationtHeight = pagination.offsetHeight;
      this.tabHeader = elementHeight - headerHeight - paginationtHeight - 140;
    }
  },
}
</script>
<style scoped lang="scss">
.approval_status5 {
  color: #24d3a9;
  position: relative;
  padding-left: 15px;
}
.approval_status5::after {
  position: absolute;
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #24d3a9;
  left: 5px;
  top: 50%;
  transform: translate(-50%, -50%);
}
.approval_status3 {
  color: #134ee6;
  position: relative;
  padding-left: 15px;
}
.approval_status3::after {
  position: absolute;
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #134ee6;
  left: 5px;
  top: 50%;
  transform: translate(-50%, -50%);
}
.approval_status1 {
  color: #1890ff;
  position: relative;
  padding-left: 15px;
}
.approval_status1::after {
  position: absolute;
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #1890ff;
  left: 5px;
  top: 50%;
  transform: translate(-50%, -50%);
}
.approval_status0 {
  color: #14ecd0;
  position: relative;
  padding-left: 15px;
}
.approval_status0::after {
  position: absolute;
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #14ecd0;
  left: 5px;
  top: 50%;
  transform: translate(-50%, -50%);
}
.approval_status8 {
  color: #f39801;
  position: relative;
  padding-left: 15px;
}
.approval_status8::after {
  position: absolute;
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #f39801;
  left: 5px;
  top: 50%;
  transform: translate(-50%, -50%);
}
.approval_status9 {
  color: red;
  position: relative;
  padding-left: 15px;
}
.approval_status9::after {
  position: absolute;
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: red;
  left: 5px;
  top: 50%;
  transform: translate(-50%, -50%);
}
</style>
