<template>
  <view class="content-box">
    <uni-nav-bar
      fixed="true"
      statusBar="true"
      left-icon="back"
      :title="title"
      background-color="#F7F9FA"
      color="#000"
      @clickLeft="back"
    >
    </uni-nav-bar>

    <view class="list_box">
      <u-list @scrolltolower="scrolltolower" v-if="taskType != 5">
        <view class="card_box" v-for="(objData, index) in list" :key="index">
          <view class="rx-bc title_card">
            <view>{{ index + 1 }}</view>
            <view>报工时间: {{ objData.workReportInfo.executorTime }}</view>
          </view>
          <workOrderBom
            :item="objData"
            v-if="objData"
            :isDetails="true"
            :isReportWork="true"
          ></workOrderBom>

          <paramBom
            v-if="objData.paramDetailList.length != 0"
            :list="objData.paramDetailList"
          ></paramBom>

          <!-- // 报工信息 -->

          <jobBom
            :item="objData"
            v-if="objData.notFormedList"
            :palletList="objData.palletList"
            :notFormed="objData.notFormedList"
            :isDetails="true"
          ></jobBom>

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

          <modelBom
            v-if="objData.modelList.length != 0"
            :list="objData.modelList"
          >
          </modelBom>

          <inspectionBom
            :semiProductList="objData.semiProductList"
            :isDetails="true"
            v-if="
              Object.prototype.hasOwnProperty.call(
                objData,
                'semiProductList'
              ) &&
              objData.semiProductList.length &&
              taskType == 3
            "
          >
          </inspectionBom>

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

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

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

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

          <!-- <!- 报工详情- 扫码报工fff -->
          <semiProductJobBom
            v-if="
              objData.semiProductList &&
              objData.semiProductList.length != 0 &&
              taskType != 6 &&
              objData.singleReport == 1
            "
            :list="objData.semiProductList"
            :item="objData"
            :isDetails="true"
          >
          </semiProductJobBom>

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

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

          <semiProductJobBomPL
            v-if="
              objData.semiProductList &&
              objData.semiProductList.length != 0 &&
              taskType != 6 &&
              taskType != 3 &&
              objData.singleReport == 0 &&
              clientEnvironmentId == 3
            "
            :list="objData.semiProductList"
            :item="objData"
            :isDetails="true"
          >
          </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.length != 0"
            :list="objData.productRecycleList"
            :isDetails="true"
          >
          </byProductBom>

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

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

          <view v-if="objData.packInfo">
            <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>
            <!-- //包装扫码 -->
            <view v-else>
              <view v-if="clientEnvironmentId != 2">
                <!-- <packingBom
                  v-if="taskType == 4 && clientEnvironmentId != 3 && objData"
                  :packInfo="objData.packInfo"
                >
                </packingBom> -->

                <!-- :taskId="taskId"
              :workOrderId="id"
              :objData="objData"
              ref="packRef"
              v-if="taskType == 4 && clientEnvironmentId != 3 && objData"
              :categoryId="categoryId" -->

                <newPackingBomDetails
                  v-if="taskType == 4 && clientEnvironmentId != 3 && objData"
                  :taskId="objData.currentTaskDiagram.taskId"
                  :objData="objData"
                  :categoryId="objData.workOrderId"
                >
                </newPackingBomDetails>
              </view>

              <packingQtBom
                v-else
                :list="objData.packInfo.pickOutInList"
                :isWarehousing="true"
                :isDetails="true"
                :item="objData"
              >
              </packingQtBom>
            </view>
          </view>
        </view>
      </u-list>

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

          <workOrderBom2
            :item="objData"
            v-if="objData"
            :isDetails="true"
          ></workOrderBom2>

          <!-- <detailsBom
            v-if="objData.detailList.length != 0"
            :detailList="objData.detailList"
          ></detailsBom> -->

          <detailsBatchBom
            v-if="objData.detailList.length != 0"
            :detailList="objData.detailList"
          ></detailsBatchBom>
        </view>
      </u-list>

      <view v-if="list.length == 0">
        <view style="margin-top: 20vh">
          <u-empty iconSize="150" textSize="32" text="暂无报工详情"> </u-empty>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { listWorkReport, listApplystorage } from "@/api/pda/workOrder.js";
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 oneJobBom from "../../jobBooking/components/oneJobBom.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 inspectionBom from "../../sample/components/inspectionBom.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 newPackingBomDetails from "../../jobBooking/components/newPackingBomDetails.vue";
import packingQtBom from "../../jobBooking/components/packingQtBom.vue";
import batchProductJobBom from "../../jobBooking/components/batchProductJobBom.vue";

//

import detailsBom from "../../warehousing/components/detailsBom.vue";
import detailsBatchBom from "../../warehousing/components/detailsBatchBom.vue";
import workOrderBom2 from "../../warehousing/components/workOrderBom.vue";

export default {
  components: {
    workOrderBom,
    deviceBom,
    modelBom,
    jobBom,
    oneJobBom,
    semiProductJobBom,
    semiProductJobBomPL,
    oneJobQualityBom,
    oneJobQualityBomPL,
    packingQtBom,
    byProductBom,
    turnoverBom,
    aridRegion,
    paramBom,

    inspectionBom,
    sampleBom,
    palletBom,
    revolvingDiskBom,
    packingTgBom,
    packingBom,

    detailsBom,
    workOrderBom2,
    batchProductJobBom,
    newPackingBomDetails,
    detailsBatchBom,
  },
  data() {
    return {
      workOrderId: null,
      taskId: null,
      list: [],
      taskType: 1,

      clientEnvironmentId:
        uni.getStorageSync("userInfo") &&
        uni.getStorageSync("userInfo").clientEnvironmentId, // *1 主环境-601环境   2 soll-索尔环境    3 tg-碳谷环境
    };
  },
  onLoad(options) {
    this.title = options.taskName ? options.taskName + "-报工详情" : "报工详情";
    this.workOrderId = options.id;
    this.taskId = options.taskId;
    this.taskType = options.taskType;
    this.getList();
  },

  methods: {
    getList() {
      let param = {
        workOrderId: this.workOrderId,
        taskId: this.taskId,
      };
      let URL = this.taskType == 5 ? listApplystorage : listWorkReport;
      URL(param).then((res) => {
        this.list = res;
      });
    },

    scrolltolower() {},
  },
};
</script>

<style lang="scss" scoped>
.content-box {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.list_box {
  flex: 1;
  overflow: hidden;
  padding: 4rpx 0;

  .u-list {
    height: 100% !important;
  }

  .card_box {
    padding: 16rpx;
  }
}

.bottom-wrapper {
  .btn_box {
    width: 750rpx;
    height: 88rpx;
    line-height: 88rpx;
    background: $theme-color;
    text-align: center;
    font-size: 36rpx;
    font-style: normal;
    font-weight: 400;
    color: #fff;
  }
}

.operate_box {
  padding: 10rpx 160rpx;

  /deep/ .u-button {
    width: 160rpx;
  }
}

.title_card {
  height: 70rpx;
  width: 100%;
  background: #157a2c;
  font-size: 30rpx;
  color: #fff;
  line-height: 70rpx;
  padding: 0 22rpx;
  box-sizing: border-box;
}
</style>
