<template>
  <!-- 报工详情 -->
  <div>
    <div class="" v-if="taskType != 5">
      <div v-for="(objData, index) in list" :key="index" class="card_box">
        <div class="rx-bc">
          <div class="item_box rx-bc">
            <div class="round">{{ index + 1 }}</div>
            <div class="time">取样时间:{{ objData.executorTime }} </div>
          </div>

          <div class="item_box rx-bc">
            <div class="time"
              >工序名称：
              {{
                objData.currentTaskDiagram &&
                objData.currentTaskDiagram.taskTypeName
              }}</div
            >
          </div>
        </div>
        <div>
          <workOrderBom
            :item="objData"
            v-if="objData"
            :isDetails="true"
          ></workOrderBom>
          <!-- 详情报工信息 -->
          <jobBom
            :item="objData"
            v-if="objData.notFormedList"
            :palletList="objData.palletList"
            :notFormed="objData.notFormedList"
            :isDetails="true"
          ></jobBom>

          <deviceBom
            v-if="objData.equipmentList && objData.equipmentList.length != 0"
            :list="objData.equipmentList"
          >
          </deviceBom>

          <modelBom
            v-if="objData.modelList && objData.modelList.length != 0"
            :list="objData.modelList"
          >
          </modelBom>
          <!--
          <qualityStat
            :normalQuality="objData.normalQuality"
            v-if="objData && taskType == 3"
          ></qualityStat> -->

          <!-- <sampleBom
            :item="objData.quality"
            v-if="objData.quality && taskType == 2"
            :workReportInfo="objData.workReportInfo"
            :isDetails="true"
          ></sampleBom> -->

          <palletBom
            v-if="objData.palletList && objData.palletList.length != 0"
            :palletList="objData.palletList"
            :isDetails="true"
          >
          </palletBom>

          <revolvingDiskBom
            v-if="
              objData.revolvingDiskList && objData.revolvingDiskList.length > 0
            "
            pattern="job"
            :revolvingDiskList="objData.revolvingDiskList"
          ></revolvingDiskBom>

          <semiProductJobBom
            v-if="
              objData.semiProductList &&
              objData.semiProductList.length != 0 &&
              taskType != 6 &&
              objData.singleReport == 1
            "
            :list="objData.semiProductList"
            :item="objData"
            :isDetails="true"
            :singleReport="objData.singleReport"
          >
          </semiProductJobBom>

          <semiProductJobBomPL
            v-if="
              objData.semiProductList &&
              objData.semiProductList.length != 0 &&
              taskType != 6 &&
              objData.singleReport == 0
            "
            :list="objData.semiProductList"
            :item="objData"
            :isDetails="true"
            :singleReport="objData.singleReport"
          >
          </semiProductJobBomPL>

          <oneJobQualityBom
            v-if="
              objData.semiProductList &&
              objData.semiProductList.length != 0 &&
              taskType == 6 &&
              clientEnvironmentId == 3 &&
              objData.singleReport == 1
            "
            :list="objData.semiProductList"
            :item="objData"
            :isDetails="true"
          ></oneJobQualityBom>

          <oneJobQualityBomPL
            v-if="
              taskType == 6 &&
              clientEnvironmentId == 3 &&
              objData.singleReport == 0
            "
            :list="objData.semiProductList"
            :item="objData"
            :isDetails="true"
          ></oneJobQualityBomPL>

          <byProductBom
            v-if="
              objData.productRecycleList &&
              objData.productRecycleList.length != 0
            "
            :list="objData.productRecycleList"
            :isDetails="true"
          >
          </byProductBom>

          <turnoverBom
            v-if="objData.turnover && objData.turnover.length != 0"
            :list="objData.turnover"
            :wordItem="objData"
            pattern="job"
            :isDetails="true"
          >
          </turnoverBom>

          <aridRegion
            v-if="objData.aridRegionList && objData.aridRegionList.length != 0"
            :list="objData.aridRegionList"
            :remainingTime="0"
            :isType="true"
          ></aridRegion>

          <packingTgBom
            v-if="
              objData.packInfo &&
              objData.packInfo.pickOutInList &&
              objData.packInfo.pickOutInList != 0 &&
              taskType == 4 &&
              clientEnvironmentId == 3
            "
            :list="objData.packInfo.pickOutInList"
            :isWarehousing="true"
            :isDetails="true"
            :item="objData"
          >
          </packingTgBom>

          <!-- <packingBom
            v-if="objData.packInfo && clientEnvironmentId == 2"
            :packInfo="objData.packInfo"
          >
          </packingBom> -->
        </div>
      </div>
    </div>

    <div v-if="taskType == 5">
      <div class="card_box" v-for="(objData, index) in list" :key="index">
        <div class="rx-bc title_card">
          <div>{{ index + 1 }}</div>
          <div>报工时间: {{ objData.createTime }}</div>
        </div>

        <workOrderBom2
          :item="objData"
          v-if="objData"
          :isDetails="true"
        ></workOrderBom2>
        <div v-if="objData.detailList && objData.detailList.length">
          <detailsBom :list="objData.detailList" :isDetails="true"></detailsBom>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import { listWorkReport, listApplystorage } from '@/api/produce/workOrder';
  import workOrderBom from '../feeding/components/workOrderBom.vue';
  import deviceBom from '../feeding/components/deviceBom.vue';
  import modelBom from '../feeding/components/modelBom.vue';
  import jobBom from '../jobBooking/components/jobBom.vue';

  import semiProductJobBom from '../jobBooking/components/semiProductJobBom.vue';
  import semiProductJobBomPL from '../jobBooking/components/semiProductJobBomPL.vue';
  import oneJobQualityBom from '../jobBooking/components/oneJobQualityBom.vue';
  import oneJobQualityBomPL from '../jobBooking/components/oneJobQualityBomPL.vue';

  import byProductBom from '../jobBooking/components/byProductBom';
  import turnoverBom from '../jobBooking/components/turnoverBom.vue';
  import aridRegion from '../feeding/components/aridRegion.vue';
  import paramBom from '../feeding/components/paramBom.vue';

  //   import qualityStat from '../sample/components/qualityStat.vue';
  //   import sampleBom from '../sample/components/sampleBom.vue';
  import palletBom from '../feeding/components/palletBom.vue';

  import revolvingDiskBom from '../feeding/components/revolvingDiskBom.vue';
  import packingTgBom from '../jobBooking/components/packingTgBom.vue';

  //   import packingBom from '../jobBooking/components/packingBomDetails.vue';

  import detailsBom from '../warehousing/components/detailsBom.vue';
  import workOrderBom2 from '../warehousing/components/workOrderBom.vue';

  export default {
    components: {
      workOrderBom,
      workOrderBom,
      deviceBom,
      modelBom,
      jobBom,

      semiProductJobBom,
      semiProductJobBomPL,
      oneJobQualityBom,
      oneJobQualityBomPL,

      byProductBom,
      turnoverBom,
      aridRegion,
      paramBom,

      //   qualityStat,
      //   sampleBom,
      palletBom,
      revolvingDiskBom,
      packingTgBom,
      //   packingBom,

      detailsBom,
      workOrderBom2
    },
    props: {
      routeObj: {
        type: Object,
        default() {
          return {};
        }
      },
      newId: {
        type: String,
        default: ''
      },
      curTaskObj: {
        type: Object,
        default() {
          return () => {};
        }
      }
    },

    watch: {
      curTaskObj: {
        handler(obj) {
          if (obj) {
            console.log(obj, '55555555555');
            this.taskType = obj.type;
            this.getList();
          }
        },
        deep: true,
        immediate: true
      },
      newId: {
        handler(newval) {
          this.newIdTo = newval;
        },
        deep: true,
        immediate: true
      }
    },

    computed: {
      clientEnvironmentId() {
        return this.$store.state.user.info.clientEnvironmentId;
      }
    },

    data() {
      return {
        taskType: null,
        list: [],
        newIdTo: ''
      };
    },

    created() {},

    methods: {
      getList() {
        console.log('出发啊');

        let param = {
          workOrderId: this.routeObj.id,
          taskId: this.newId
        };

        console.log(this.taskType, 99999999);

        let URL = this.taskType == 5 ? listApplystorage : listWorkReport;

        URL(param).then((res) => {
          console.log(res, 'res');

          this.list = JSON.parse(JSON.stringify(res));
        });
      }
    }
  };
</script>

<style scoped lang="scss">
  .rx-bc {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .item_box {
    margin-top: 5px;
    margin-bottom: 6px;
    padding: 0 10px;

    .round {
      width: 20px;
      height: 20px;
      line-height: 20px;
      border-radius: 50%;
      background: #157a2c;
      color: #fff;
      text-align: center;
      font-size: 12px;
    }

    .time {
      color: #157a2c;
      font-family: PingFang HK;
      font-size: 14px;
      font-style: normal;
      font-weight: 500;
      margin-left: 8px;
    }
  }

  .title_card {
    height: 35px;
    width: 100%;
    background: #157a2c;
    font-size: 16px;
    color: #fff;
    line-height: 35px;
    padding: 0 20px;
    box-sizing: border-box;
  }
</style>
