<template>
  <!-- #ifdef H5 -->
  <zj-page-layout
    :isScroll="true"
    :hasFooter="false"
    :refresherTriggered="refresherTriggered"
    @refresherrefresh="refresherrefresh"
  >
    <view class="list-container">
      <view class="item" v-for="(item, index) in dataList" :key="index">
        <view class="row">
          <view class="label">采集时间</view>
          <view class="value">{{ item.giveTime }}</view>
        </view>
        <view class="row">
          <view class="label">采集状态</view>
          <view class="value">{{ item.status | statusFilter }}</view>
        </view>
        <view class="row">
          <view class="label">主工程师</view>
          <view class="value">{{ item.workerName }}</view>
        </view>
        <view class="row" v-if="item.pgOrderWorkers.filter(o => !o.isMaster).length">
          <view class="label">辅工程师</view>
          <view class="value">{{
            item.pgOrderWorkers
              .filter(o => !o.isMaster)
              .map(o => o.workerName)
              .join(',')
          }}</view>
        </view>
        <view class="row">
          <view class="label">采集图片</view>
          <view class="images">
            <view class="it" v-for="(it, idx) in item.pgOrderProductDetails" :key="idx">
              <image :src="it.fileUrl" mode="aspectFill"></image>
              <view class="text">{{ it.fileName }}</view>
            </view>
          </view>
        </view>
      </view>
    </view>

    <Loading :type="2" :loadStatus="loadStatus" :dataList="dataList" />
  </zj-page-layout>
  <!-- #endif -->

  <!-- #ifndef H5 -->
  <web-view
    :src="webViewHref(`/packageWorkorder/pages/overDetail`, pam, crossPagePam)"
    @message="crossPage.$listener"
  ></web-view>
  <!-- #endif -->
</template>

<script>
 // #ifdef H5
export default {
   filters: {
     statusFilter(val) {
       const MAP = {
         WAIT: '待采集',
         WAIT_SAVE: '待完善',
         OK: '已采集',
       }
       return MAP[val]
     }
   },

	data() {
		return {
			loadStatus: 1,
			refresherTriggered: false,
			dataList: [],
		}
	},

	async onLoad({id}) {
		this.id = id;
		this.getList();
	},

	methods: {
		refresherrefresh(e) {
			this.refresherTriggered = true;
			this.getList();
		},

		getList() {
			this.$api.post('/changeOrder/productDetailList', {
         workerOrderId: this.id,
			}).then(res => {
				this.dataList = res.data;
			}).finally(res => {
				this.loadStatus = 0;
				this.refresherTriggered = false;
			})
		},
	}
}

 // #endif
 // #ifndef H5
 export default {
   data() {
     return {
       pam: {},
     }
   },
   onLoad(pam) {
     this.pam = pam;
   }
 }
 // #endif
</script>

<style lang="scss" scoped>
.list-container {
  .item {
    margin-top: 30rpx;
    background: #ffffff;
    padding: 30rpx;
  }
  .row {
    display: flex;
    margin-top: 20rpx;
    &:first-child {
      margin-top: 0;
    }
    .label {
      font-size: 28rpx;
      color: $sec-font;
      margin-right: 20rpx;
      flex-shrink: 0;
    }
    .value {
      font-size: 28rpx;
    }
    .images {
      display: flex;
      flex-wrap: wrap;
      .it {
        margin-bottom: 20rpx;
        margin-right: 20rpx;
        display: flex;
        flex-direction: column;
        align-items: center;
        image {
          width: 120rpx;
          height: 120rpx;
          display: block;
        }
        .text {
          font-size: 24rpx;
          color: $sec-font;
          margin-top: 8rpx;
        }
      }
    }
  }
}
</style>
