<template>
  <div class="app-container">
    <el-card style="margin-top: 2px">
      <el-tabs v-model="activeName" type="card">
        <el-tab-pane label="总览" name="1">
          <el-table
            :data="productionplan.results"
            border
            fit
            stripe
            highlight-current-row
            height="620"
            v-el-height-adaptive-table="{ bottomOffset: 40 }"
          >
            <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.product_.name
              }}</template>
            </el-table-column>
            <el-table-column label="规格型号">
              <template slot-scope="scope">{{
                scope.row.product_.specification
              }}</template>
            </el-table-column>
            <el-table-column label="合格率">
              <el-table-column label="冷加工">
                <template slot-scope="scope" v-if="scope.row.process_json['01']"
                  >{{ scope.row.process_json["01"].rate }}%</template
                >
              </el-table-column>
              <el-table-column label="热弯">
                <template slot-scope="scope" v-if="scope.row.process_json['02']"
                  >{{ scope.row.process_json["02"].rate }}%</template
                >
              </el-table-column>
              <el-table-column label="化学钢化">
                <template slot-scope="scope" v-if="scope.row.process_json['03']"
                  >{{ scope.row.process_json["03"].rate }}%</template
                >
              </el-table-column>
              <el-table-column label="镀膜">
                <template slot-scope="scope" v-if="scope.row.process_json['05']"
                  >{{ scope.row.process_json["05"].rate }}%</template
                >
              </el-table-column>
              <el-table-column label="夹层">
                <template slot-scope="scope" v-if="scope.row.process_json['06']"
                  >{{ scope.row.process_json["06"].rate }}%</template
                >
              </el-table-column>
              <el-table-column label="包边">
                <template slot-scope="scope" v-if="scope.row.process_json['07']"
                  >{{ scope.row.process_json["07"].rate }}%</template
                >
              </el-table-column>
              <el-table-column label="装框">
                <template slot-scope="scope" v-if="scope.row.process_json['08']"
                  >{{ scope.row.process_json["08"].rate }}%</template
                >
              </el-table-column>
            </el-table-column>
            <el-table-column label="创建时间">
              <template slot-scope="scope">{{
                scope.row.create_time
              }}</template>
            </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-link
                  v-if="checkPermission(['material_update'])"
                  type="primary"
                  @click="handledetail(scope)"
                  >详情</el-link
                >
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="productionplan.count > 0"
            :total="productionplan.count"
            :page.sync="listQuery.page"
            :limit.sync="listQuery.page_size"
            @pagination="getList"
          />
        </el-tab-pane>
        <el-tab-pane label="不合格玻璃" name="2">
          <el-table
            :data="wproductticket.results"
            border
            fit
            stripe
            highlight-current-row
            height="620"
            v-el-height-adaptive-table="{ bottomOffset: 40 }"
          >
            <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" v-if="scope.row.order_">{{
                scope.row.order_.number
              }}</template>
            </el-table-column>
            <el-table-column label="产品名称">
              <template slot-scope="scope" v-if="scope.row.product_">{{
                scope.row.product_.name
              }}</template>
            </el-table-column>
            <el-table-column label="规格型号">
              <template slot-scope="scope" v-if="scope.row.product_">{{
                scope.row.product_.specification
              }}</template>
            </el-table-column>
            <el-table-column label="责任工序">
              <template slot-scope="scope" v-if="scope.row.resp_process_">{{
                scope.row.resp_process_.name
              }}</template>
            </el-table-column>
            <el-table-column label="处理结果">
              <template slot-scope="scope">{{
                decision_[scope.row.decision]
              }}</template>
            </el-table-column>
            <el-table-column label="创建时间">
              <template slot-scope="scope">{{
                scope.row.create_time
              }}</template>
            </el-table-column>
            <el-table-column label="操作">
              <template slot-scope="scope">
                <el-link
                  v-if="checkPermission(['material_update'])"
                  type="primary"
                  @click="handledetailbhg(scope)"
                  >查看</el-link
                >
              </template>
            </el-table-column>
          </el-table>
          <pagination
            v-show="wproductticket.count > 0"
            :total="wproductticket.count"
            :page.sync="listQuery2.page"
            :limit.sync="listQuery2.page_size"
            @pagination="getList2"
          />
       
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>
<script>
import { getProductionplanList } from "@/api/pm";
import { getwproductticketList } from "@/api/wpm";
import { ticketread } from "@/api/workflow";

import checkPermission from "@/utils/permission";
import { createTestrecord } from "@/api/inm";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination

export default {
  components: { Pagination },
  data() {
    return {
      process_json_: {
        "01": "冷加工",
        "02": "热弯",
        "03": "化学钢化",
        "05": "镀膜",
        "06": "夹层",
        "07": "包边",
        "08": "装框",
      },
      decision_: {
        10: "返工",
        20: "返修",
        30: "报废",
        40: "让步接受",
        50: "偏离许可",
        60: "降级使用",
        70: "退回供方",
        80: "召回",
      },
      productionplan: {
        count: 0,
      },
      wproductticket: {
        count: 0,
      },
      activeName: "1",
      listQuery: {
        page: 1,
        page_size: 20,
      },
      listQuery2: {
        page: 1,
        page_size: 20,
      },
      limitedRetrial:false,
       customfieldList: [],
    };
  },
  computed: {},
  watch: {},
  created() {
    this.getList(); //总览列表
    this.getList2(); //不合格玻璃审批工单列表
  },
  methods: {
    checkPermission,
    //总览列表
    getList() {
      getProductionplanList(this.listQuery).then((response) => {
        if (response.data) {
          this.productionplan = response.data;
        }
      });
    },
    handledetail(scope) {
      this.$router.push({ name: "taskdetails", params: { id: scope.row.id } });
    },

    //不合格玻璃审批工单列表
    getList2() {
      getwproductticketList(this.listQuery2).then((response) => {
        if (response.data) {
          this.wproductticket = response.data;
        }
      });
    },
    //不合格玻璃审理单查看
    handledetailbhg(scope)
    {
      
        this.$router.push({name:"ticketDetail",params:{ticketId:scope.row.ticket}})
    }
    
  },
};
</script>
