<template>
  <div class="app-container">
   
    <el-card>
        <el-descriptions title="任务详情" :column="5" border  style="margin-bottom: 20px">
  <el-descriptions-item label="任务编号">{{productionplans.number}}</el-descriptions-item>
  <el-descriptions-item label="产品名称" v-if="productionplans.product_">{{productionplans.product_.name}}</el-descriptions-item>
  <el-descriptions-item label="规格型号" v-if="productionplans.product_">{{productionplans.product_.specification}}</el-descriptions-item>
  <el-descriptions-item label="生产状态">{{state_[productionplans.state]}}</el-descriptions-item>
   <el-descriptions-item label="不合格品数量">不合格数没有</el-descriptions-item>
</el-descriptions>
        <el-table
                :data="wproduct"
                border
                fit
                stripe
                style="width: 100%"
               height="500"
              >
               
                <el-table-column type="index" width="50" />
              

                <el-table-column label="玻璃编号" >
                  <template slot-scope="scope" >{{ scope.row.number }}</template>
                </el-table-column>
                
                  <el-table-column label="所在子工序">
                  <template slot-scope="scope"  >{{
                    scope.row.step_.name
                  }}</template>
                </el-table-column>
                  <el-table-column label="状态" >
                  <template slot-scope="scope">{{
                    actstate_[scope.row.act_state]
                  }}</template>
                </el-table-column>
               <el-table-column
          align="center"
          label="过程记录"
          width="220px"
        >
          <template slot-scope="scope">
          
            <el-link
              v-if="checkPermission(['material_delete'])"
              type="primary"
              @click="handleoption(scope)"
              >查看</el-link
            >
          </template>
        </el-table-column>
              
               
              </el-table>

    </el-card>
  
  </div>
</template>
<script>
import {  getwproductList} from "@/api/wpm";
import checkPermission from "@/utils/permission";
import { getProductionplan,getsubproductionplanList } from "@/api/pm";

import { genTree } from "@/utils";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination

export default {
  components: { Pagination },
  data() {
    return {
      productionplans:{
       number:""
     },
      wproduct: "",
       state_:{
        10:'制定中',
        20:'已下达',
        30:'已接受',
        40:'生产中',
        50:'已完成',
         60:'军检完成'},
       actstate_: {
        6: "待复检",
        10: "操作进行中",
        20: "待检验",
        30: "已合格",
        40: "库存中",
        50: "不合格",
        60: "待成品检验",
        8: "操作准备中",
        26: "待夹层检验",
        70: "报废",
      },
    };
  },
  computed: {},
  watch: {},
  created() {
    
    this.id = this.$route.params.id;
    this.productionplan = this.$route.params.productionplanid;
    this.getList();
    this.getpList();
    console.log(this.productionplan);

  },
  methods: {
    checkPermission,
     getpList() {
      getProductionplan(this.productionplan).then((response) => {
        if (response.data) {
          this.productionplans = response.data;
        
        }
        
      });
    },
    //半成品列表
    getList() {
      getwproductList({production_plan:this.productionplan,step__process:this.id,page:0}).then((response) => {
        if (response.data) {
          this.wproduct= response.data;
        } 

        
      });
    },
     
     //查看该玻璃检验记录表
    handleoption(scope){
       console.log(this.productionplan);
        this.$router.push({name: "taskrecordfrom", params: { id:scope.row.id,productionplanid:this.productionplan,number:scope.row.number,process:scope.row.step_.name} })
    
    },
  },
};
</script>
