<template>
  <div class="app-container">
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>项目</span>
      </div>
      <el-table
        v-loading="listLoading"
        :data="tableData"
        style="width: 100%;margin-top:10px;"
        border
        fit
        stripe
        highlight-current-row
        height="300"
      >
        <el-table-column
      type="selection"
      width="55">
    </el-table-column>
        <el-table-column label="单号">
          <template slot-scope="scope" v-if="scope.row.number">{{ scope.row.number }}</template>
        </el-table-column>
        <el-table-column label="认证领域/分类">
          <template slot-scope="scope">
            <el-tag>{{scope.row.cert_field_.name}}</el-tag>
            <el-tag
              v-if="scope.row.cccpv_class_"
              type="warning"
              style="margin:2px"
            >{{scope.row.cccpv_class_.name}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="申请信息" width="300px">
          <template slot-scope="scope">
            <div>
              <span style="color:darkblue;font-weight:bold">申请方</span>
              :{{ scope.row.applicant_v.name }}
            </div>
            <div v-if="scope.row.manufacture">
              <span style="color:darkblue;font-weight:bold">制造商</span>
              :{{ scope.row.manufacture_v.name }}
            </div>
            <div v-if="scope.row.factory">
              <span style="color:darkblue;font-weight:bold">生产厂</span>
              :{{ scope.row.factory_v.name }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="当前状态">
          <template slot-scope="scope">{{ scope.row.status}}</template>
        </el-table-column>
        <el-table-column label="创建人">
          <template slot-scope="scope">{{ scope.row.create_by_.name}}</template>
        </el-table-column>
        <el-table-column label="创建日期">
          <template slot-scope="scope">
            <span>{{ scope.row.create_time }}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-card class="box-card" style="margin-top:10px">
      <div slot="header" class="clearfix">
        <span>待处理申请</span>
      </div>
      <div>
        <el-button type="primary">生成项目</el-button>
      </div>
      <el-table
        v-loading="listLoading"
        :data="tableData"
        style="width: 100%;margin-top:10px;"
        border
        fit
        stripe
        highlight-current-row
        height="300"
      >
        <el-table-column
      type="selection"
      width="55">
    </el-table-column>
        <el-table-column label="单号">
          <template slot-scope="scope" v-if="scope.row.number">{{ scope.row.number }}</template>
        </el-table-column>
        <el-table-column label="认证领域/分类">
          <template slot-scope="scope">
            <el-tag>{{scope.row.cert_field_.name}}</el-tag>
            <el-tag
              v-if="scope.row.cccpv_class_"
              type="warning"
              style="margin:2px"
            >{{scope.row.cccpv_class_.name}}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="申请信息" width="300px">
          <template slot-scope="scope">
            <div>
              <span style="color:darkblue;font-weight:bold">申请方</span>
              :{{ scope.row.applicant_v.name }}
            </div>
            <div v-if="scope.row.manufacture">
              <span style="color:darkblue;font-weight:bold">制造商</span>
              :{{ scope.row.manufacture_v.name }}
            </div>
            <div v-if="scope.row.factory">
              <span style="color:darkblue;font-weight:bold">生产厂</span>
              :{{ scope.row.factory_v.name }}
            </div>
          </template>
        </el-table-column>
        <el-table-column label="当前状态">
          <template slot-scope="scope">{{ scope.row.status}}</template>
        </el-table-column>
        <el-table-column label="创建人">
          <template slot-scope="scope">{{ scope.row.create_by_.name}}</template>
        </el-table-column>
        <el-table-column label="创建日期">
          <template slot-scope="scope">
            <span>{{ scope.row.create_time }}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>
<script>
import { getCertappList } from "@/api/certapp";
import Pagination from "@/components/Pagination";
import checkPermission from "@/utils/permission";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { genTree } from "../../utils";
export default {
  components: { Pagination, Treeselect },
  data() {
    return {
      tableData: [],
      listLoading: true,
      listQuery: {
        status: "已受理",
      },
      deptOptions: [],
      field_list: [],
    };
  },
  created() {
    this.getList();
  },
  methods: {
    checkPermission,
    getList() {
      this.listLoading = true;
      getCertappList(this.listQuery).then((response) => {
        if (response.data) {
          this.tableData = response.data;
        }
        this.listLoading = false;
      });
    },
    getdeptOptions() {
      getOrgList().then((res) => {
        this.deptOptions = genTree(res.data);
      });
    },
    resetFilter() {
      this.listQuery = {
        status: "已受理",
      };
      this.getList();
    },
    handleFilter() {
      this.getList();
    },
  },
};
</script>
