<template>
 <div class="app-container">
        <div style="display:flex">
          <treeselect 
          v-model="listQuery.teststate" 
          :multiple="false" 
          :options="taskOptions" 
          placeholder="任务状态" 
          :disable-branch-nodes="true" 
          @input="handleFilter" 
          style="width: 280px" clearable/>
         
           </div>
           
  <div>
    <el-table
      v-loading="listLoading"
      :data="tableData"
      style="width: 100%;"
      border
      fit
      stripe
      highlight-current-row
      height="380"
    >
    
      <el-table-column type="index" width="50" />
      <el-table-column label="状态">
        <template slot-scope="scope" >{{ scope.row.teststate }}</template>
      </el-table-column>
      <el-table-column label="检测任务号">
        <template slot-scope="scope" >{{ scope.row.detnumber }}</template>
      </el-table-column>
       <el-table-column label="检测单元">
        <template slot-scope="scope" >{{ scope.row.certunit_.name }}</template>
      </el-table-column>
        <el-table-column label="样品描述">
        <template slot-scope="scope" >{{ scope.row.sampledec }}</template>
      </el-table-column>
       <el-table-column label="收费方式">
        <template slot-scope="scope" >{{ scope.row.charge }}</template>
      </el-table-column>
      <el-table-column label="被委托检测机构">
        <template slot-scope="scope" >{{ scope.row.testorg_.name}}</template>
      </el-table-column>
        <el-table-column label="检验项目">
        <template slot-scope="scope" >{{ scope.row.testitem}}</template>
      </el-table-column>
      <el-table-column label="创建时间">
        <template slot-scope="scope">
          <span>{{ scope.row.create_time }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作"  width="250">
        <template slot-scope="scope">
         
          <el-button
           v-if="scope.row.teststate=='待实验室检验'"
            type="primary"
            size="small"
            :disabled="!checkPermission(['certapps_update'])"
           @click="handleCreate(scope)"
          >任务反馈</el-button>
            <el-button
           v-if="scope.row.teststate=='到样检测中'"
            type="primary"
            size="small"
            :disabled="!checkPermission(['certapps_update'])"
           @click="handleCreate2(scope)"
          >任务反馈</el-button>
           <el-button
            type="primary"
            size="small"
            :disabled="!checkPermission(['certapps_update'])"
            @click="handlestate(scope.row.id)"
          >查看任务</el-button>
        </template>
      </el-table-column>
    </el-table>

   
    
  </div>
    </div>
</template>
<script>
import { getTestOrgList} from "@/api/laboratory"
import { getDictList } from "@/api/dict";
import { getCertunitList } from "@/api/certunit";
import { getCertappunitList, testtaskCertappunit,teststateCertappunit ,getTasklist} from "@/api/certappunit";
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 },
  props:['certapp'],
  data() {
    return {
      tableData: [],
      listLoading: true,
     taskOptions:[
        {
          label: "待检任务",
          value: "待检任务",
        },
        {
          label: "在检任务",
          value: "在检任务",
        },
         {
          label: "已检任务",
          value: "已检任务",
        }],
      listQuery: {
        page: 1,
        page_size: 20
      },
       
       
      
    };
  },
  watch:{
    
  },
  created() {
    this.getList();
    this.getList() 
   
  },
  methods: {
    checkPermission,
    getList() {
      this.listLoading = true;
      
      getTasklist().then((response) => {
       
        if (response.data) {
           this.tableData = response.data;
          
        }
        this.listLoading = false;
      });
    },
     handleCreate(scope) {
      this.$router.push({path:"/testorg/feedback/create",query:{taskid:scope.row.id}})
    },
     handleCreate2(scope) {
      this.$router.push({path:"/testorg/feedbacks/create",query:{taskid:scope.row.id}})
    },
   
  },
};
</script>
