<template>
  <!-- 调拨 -->
  <view class="main-wrap" :class="{ info: isInfo }">
    <uni-search-bar
      class="uni-search-bar"
      @confirm="search"
      v-model="searchValue"
      @input="search"
      cancelButton="none"
      placeholder="调拨单号"
    >
    </uni-search-bar>

    <scroll-view scroll-y="true" class="scroll-Y" @scrolltolower="lower">
      <view class="order-list">
        <view class="item" v-for="(item, index) in listData" :key="index">
          <view class="title">
            <view class="s1">
              {{ getDictValue('物品类型', baseInfo.assetType) }}编码
              {{ item.onlyCode }}
            </view>
            <view class="s2">
              <!-- {{ dict.bizScene[item.dialType] }} -->
            </view>
          </view>
          <view class="main">
            <view class="row">
              <view class="row-item">
                <text class="t1">调拨单号</text>
                <text class="t2">{{ item.dialNumber }}</text>
              </view>
              <view class="row-item">
                <text class="t1">包装编码</text>
                <text class="t2">{{ item.num }}</text>
              </view>
            </view>
            <view class="row">
              <view class="row-item" v-if="!baseInfo.isUnpack">
                <text class="t1">最小包装单元</text>
                <text class="t2">{{
                  `${item.measurementUnit || ''}${item.unit}/${
                    item.minPackUnit
                  }`
                }}</text>
              </view>
              <view class="row-item" v-if="dimension == 1">
                <text class="t1">批次号</text>
                <text class="t2">{{ item.batchNo }}</text>
              </view>
            </view>
            <view class="row">
              <view class="row-item w100">
                <text class="t1">调出货位</text>
                <text class="t2"
                  >{{ item.warehouseName }}-{{ item.outWarehouseAreaName }}-{{
                    item.outWarehouseAreaGoodsCode
                  }}-{{ item.outGoodsAllocationCode }}</text
                >
              </view>
            </view>
            <view class="row">
              <view class="row-item w100">
                <text class="t1">调入货位</text>
                <text class="t2"
                  >{{ item.inWarehouseName }}-{{ item.inWarehouseAreaName }}-{{
                    item.inWarehouseAreaGoodsCode
                  }}-{{ item.inGoodsAllocationCode }}</text
                >
              </view>
            </view>
            <view class="row">
              <view class="row-item">
                <text class="t1">审核时间</text>
                <text class="t2">{{ item.auditorTime }}</text>
              </view>
            </view>
            <!-- <view class="ckmx" @click="goDetails(item)"> 查看明细 </view> -->
          </view>
        </view>
      </view>

      <u-loadmore :status="status" style="margin: 20rpx 0" />
    </scroll-view>
  </view>
</template>

<script>
import { post } from '@/utils/api.js'
let [page, size, isEnd] = [1, 10, true]
import dictMixins from '@/mixins/dictMixins'
export default {
  props: ['batchNum', 'inventoryCode', 'isInfo', 'baseInfo', 'dimension'],
  mixins: [dictMixins],
  data () {
    return {
      listData: [],
      status: 'loading',
      searchValue: ''
      // dict: {
      //   bizScene: {
      //     1: '库内调拨',
      //     2: '库外调拨'
      //   }
      // }
    }
  },
  created () {
    this.getData()
  },
  methods: {
    // 触底
    lower () {
      console.log('触底')
      if (isEnd) {
        return
      }
      this.getMoreLists()
    },
    getData () {
      let par = {
        page,
        size,
        batchNum: this.batchNum,
        inventoryCode: this.inventoryCode
      }
      if (this.searchValue !== '') {
        par.key = this.searchValue
      }
      par = this.URLSearchParams(par)
      //   post(this.apiUrl + '/InventoryBook/select/getTransferList?' + par).then(
      post(this.apiUrl + '/InventoryBook/select/getTransferDetail?' + par).then(
        res => {
          if (res.success) {
            this.listData = [...this.listData, ...res.data.records]
            let pages = res.data.pages

            if (page < pages) {
              isEnd = false
            } else {
              isEnd = true
              this.status = 'nomore'
            }
          }
        }
      )
    },
    getMoreLists () {
      page++
      this.getData()
    },
    search () {
      this.page = 1
      this.listData = []
      this.status = 'loading'
      this.getData()
    },
    goDetails (item) {
      let par = {
        bizNum: item.dialNumber,
        batchNum: this.batchNum,
        type: '调拨'
      }
      par = this.URLSearchParams(par)
      uni.navigateTo({
        url: '/pages/warehouse/inventory/order/order?' + par
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.main-wrap {
  height: calc(100% - 170rpx);
  &.info {
    height: calc(100% - 236rpx);
  }
}

.scroll-Y {
  //height: calc(100% - 112rpx);
  height: 100vh;
  background-color: #fafafa;
}

.order-list {
  .item {
    background-color: #fff;
    margin-bottom: 30rpx;
    margin-bottom: 30rpx;

    .title {
      display: flex;
      padding: 20rpx;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid #dedede;

      .s1 {
        color: #333333;
        font-size: 28rpx;
        font-weight: bold;
      }

      .s2 {
        font-size: 28rpx;
        font-weight: bold;
        color: #333333;
      }
    }

    .main {
      padding: 0 30rpx;

      .row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 20rpx 0;
        border-bottom: 1px dashed #dedede;
        .row-item {
          .t1 {
            font-weight: bold;
            font-size: 28rpx;
            color: #333333;
            margin-right: 20rpx;
          }

          .t2 {
            font-size: 28rpx;
            color: #333333;
          }
        }
      }

      .ckmx {
        color: #70b603;
        font-size: 28rpx;
        font-weight: bold;
        padding: 20rpx;
        display: flex;
        justify-content: flex-end;
      }
    }
  }
}
</style>
