<template>
  <div>
    <div class="feed_box">
      <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.createTime }} </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)
            "
            :list="objData.semiProductList"
            :item="objData"
            :isDetails="true"
          >
          </semiProductJobBom>

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

          <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"
          ></packingTgBom>

          <!-- <packingBom
            v-if="objData.packInfo && clientEnvironmentId == 2"
            :packInfo="objData.packInfo"
          >
          </packingBom> -->
        </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/oneJobBom.vue';
  import oneJobQualityBom from '../jobBooking/components/oneJobQualityBom.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';
  export default {
    components: {
      workOrderBom,
      workOrderBom,
      deviceBom,
      modelBom,
      jobBom,

      semiProductJobBom,
      oneJobQualityBom,
      byProductBom,
      turnoverBom,
      aridRegion,
      paramBom,

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

      //   detailsBom,
      //   workOrderBom2
    },
    props: {
      routeObj: {
        type: Object,
        default() {
          return {};
        }
      },

      curTaskObj: {
        type: Object,
        default() {
          return () => {};
        }
      }
    },

    watch: {
      curTaskObj: {
        handler(obj) {
          if (obj) {
            this.taskType = obj.type;
            this.getList(obj.taskId);
          }
        },
        deep: true,
        immediate: true
      }
    },

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

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

    created() {},

    methods: {
      getList(taskId) {
        let param = {
          workOrderId: this.routeObj.id,
          taskId: taskId
        };
        let URL = this.taskType == 5 ? listApplystorage : listWorkReport;
        URL(param).then((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;
    }
  }
</style>
