<template>
  <u-popup mode="bottom" v-model="show">
    <view class="pop_detail" style="height: 80%">
      <com-item :dataContent="dataContent"></com-item>
      <view class="split_line"></view>
      <scroll-view style="height: 320px" scroll-y>
        <view v-for="(item, index) in dataList" style="width: 100%">
          <view class="item">
            <text class="item_title">{{ item.item_title }} </text>
            <text v-if="item.type == '' || item.type == undefined" class="text_wrap">{{ item.content }}</text>
            <text v-else-if="item.type == 'dateTime'" class="text_wrap">{{ formatDate(item.content) }} </text>
          </view>
        </view>
      </scroll-view>

      <view class="uni-flex u-row-center u-p-t-20 u-p-b-20">
        <view class="close_button" @click="closePopup"> 关闭</view>
        <!-- button 滚动不好使 -->
      </view>
    </view>
  </u-popup>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import comItem from '@/mycomponents/item/item.vue'
import { dateFormat } from '@/common/basic.js'

const dataContent = ref({})
const dataList = ref([])
const show = ref(false)
const openPopup = (val) => {
  dataContent.value = val
  getDataList()
  setTimeout((res) => {
    show.value = true
  }, 500)
}
const closePopup = () => {
  show.value = false
}
const getDataList = () => {
  // console.log(JSON.stringify( dataContent));
  dataList.value.length = 0
  dataList.value.push(
    ...[
      {
        item_title: '包装号',
        content: dataContent.value.number
      },
      {
        item_title: '物料代码',
        content: dataContent.value.itemCode
      },
      {
        item_title: '物品名称',
        content: dataContent.value.itemName
      },
      {
        item_title: '物品描述1',
        content: dataContent.value.itemDesc1
      },
      {
        item_title: '物品描述2',
        content: dataContent.value.itemDesc2
      },
      {
        item_title: '批次',
        content: dataContent.value.batch
      },
      {
        item_title: '替代批次',
        content: dataContent.value.altBatch
      },
      {
        item_title: '生产日期',
        content: dataContent.value.produceDate,
        type: 'dateTime'
      },
      {
        item_title: '有效日期',
        content: dataContent.value.validityDays,
        type: 'dateTime'
      },
      {
        item_title: '失效日期',
        content: dataContent.value.expireDate,
        type: 'dateTime'
      },
      {
        item_title: '计量单位',
        content: dataContent.value.uom,
        type: 'uom'
      },
      {
        item_title: '数量',
        content: dataContent.value.qty
      },
      {
        item_title: '替代计量单位',
        content: dataContent.value.altUom
      },
      {
        item_title: '替代数量',
        content: dataContent.value.altQty
      },
      {
        item_title: '转换率',
        content: dataContent.value.convertRate
      },
      {
        item_title: '标包数量',
        content: dataContent.value.packQty
      },
      {
        item_title: '标包单位',
        content: dataContent.value.packUnit
      },
      {
        item_title: '仓库代码',
        content: dataContent.value.toWarehouseCode
      },
      {
        item_title: '月台代码',
        content: dataContent.value.toDockCode
      },
      {
        item_title: '库位代码',
        content: dataContent.value.toLocationCode
      },
      {
        item_title: '供应商代码',
        content: dataContent.value.supplierCode
      },
      {
        item_title: '供应商物品代码',
        content: dataContent.value.supplierItemCode
      },
      {
        item_title: '采购订单号',
        content: dataContent.value.poNumber
      },
      {
        item_title: '采购订单行',
        content: dataContent.value.poLine
      },
      {
        item_title: '采购计划单号',
        content: dataContent.value.rpNumber
      },
      {
        item_title: '发货单号',
        content: dataContent.value.asnNumber
      },
      {
        item_title: '生产订单号',
        content: dataContent.value.woNumber
      },
      {
        item_title: '生产订单行',
        content: dataContent.value.woLine
      },
      {
        item_title: '生产线代码',
        content: dataContent.value.productionLineCode
      },
      {
        item_title: '班组代码',
        content: dataContent.value.teamCode
      },
      {
        item_title: '班次代码',
        content: dataContent.value.shiftCode
      },
      {
        item_title: '客户代码',
        content: dataContent.value.customerCode
      },
      {
        item_title: '客户月台代码',
        content: dataContent.value.customerDockCode
      },
      {
        item_title: '客户物品代码',
        content: dataContent.value.customerItemCode
      },
      {
        item_title: '销售订单号',
        content: dataContent.value.soNumber
      },
      {
        item_title: '销售订单行',
        content: dataContent.value.soLine
      },
      {
        item_title: '质量等级',
        content: dataContent.value.eqLevel
      },
      {
        item_title: '货主代码',
        content: dataContent.value.ownerCode
      },
      {
        item_title: '重量',
        content: dataContent.value.weight
      },
      {
        item_title: '面积',
        content: dataContent.value.area
      },
      {
        item_title: '体积',
        content: dataContent.value.volume
      }
    ]
  )
}
const formatDate = (val) => {
  return dateFormat(val)
}
defineExpose({
  openPopup,
  closePopup
})
</script>

<style></style>
