<template>
  <view class="page-kan-dan-detail">
    <view class="header" :style="{ backgroundColor: `rgba(23, 83, 234, ${scrollTop / 100})` }">
      <view class="left">
        <u-icon class="icon" name="arrow-left" @click="uni.navigateBack()" />
      </view>
      <view class="title">{{ $t('message.Warehouse_TransferDetails') }}</view>
      <view class="right"></view>
    </view>
    <wyb-table class="table" ref="table" width="100%" enable-check="multiple" show-left-and-right-border :headers="headers" :contents="model.orderInInfoList" :show-vert-border="false" />
    <view class="bottom-bar">
      <!-- <view class="extra">
        <u-row>
          <u-col :span="2"> 看单号: </u-col>
          <u-col :span="8">
            <u-input v-model="order3" @confirm="onKdOrderNoConfirm" placeholder="看单号" />
          </u-col>
        </u-row>
        <u-row>
          <u-col :span="2"> 接收人 </u-col>
          <u-col :span="3">
            <u-input v-model="receiverName" @confirm="onReceiverNameConfirm" placeholder="接收人" />
          </u-col>
          <u-col :span="2"> 口令 </u-col>
          <u-col :span="3">
            <u-input v-model="operatorPass" placeholder="口令" />
          </u-col>
        </u-row>
      </view> -->
      <view class="container">
        <u-row>
          <u-col :span="6">
            <u-button type="primary" @click="Confirm">{{ $t('message.dn_Confirm') }}</u-button>
          </u-col>
          <u-col :span="6">
            <u-button type="error" @click="uni.navigateBack({ delta: 1 })">{{ $t('message.po_Return') }}</u-button>
          </u-col>
        </u-row>
      </view>
    </view>
  </view>
</template>

<script lang="ts">
import { Component } from 'vue-property-decorator';
import { BasePage } from '@/components/base/page';
import model from './model';
// import { order, OrderDetail } from '@/pages/raw/warehouse/transfer/model';
// import { auth } from '@/store/modules/auth';
// import { pick, omit, cloneDeep } from 'lodash/fp';
import { headers } from './config';
import { session } from '@/store/modules/session';

@Component
export default class KanDanHandOverDetails extends BasePage {
  order = '';
  headers = headers;

  /**
   * 页面Module
   */
  model = model;
  // details: Array<OrderDetail> = [
  //   // {
  //   //   orderNo: 'SGC2012230010',
  //   //   barcode: '',
  //   //   productCode: 'CBAH90E00',
  //   //   productDescZh: 'HWM70-M1201 马来西亚',
  //   //   createdDate: '2020-12-23 08:09:19',
  //   //   createdBy: 'admin',
  //   // },
  //   // {
  //   //   orderNo: 'SGC2012230009',
  //   //   barcode: 'sss',
  //   //   productCode: 'BH03YME00',
  //   //   productDescZh: 'AQR-S541XA(BL)',
  //   //   createdDate: '2020-12-23 08:09:19',
  //   //   createdBy: 'admin',
  //   // },
  // ];
  // async mounted() {
  // }
  // beforeDestroy() {
  // }

  async Confirm() {
    const orderlist: any = [];
    this.model.orderInInfoList.forEach((item: any) => {
      if (item.checked) {
        orderlist.push(item);
      }
    });
    if (orderlist.length == 0) {
      this.customToast(this.$t('message.Pi_tip18') as string);
      return;
    }
    orderlist.forEach((item: any) => {
      item.type = '1';
      item.keepBy = session.loginName;
      item.orderType = '0';
    });
    await model.onTakeoutConfirm(orderlist);
    setTimeout(() => {
      uni.navigateBack({ delta: 1 });
    }, 2000);
  }
}
</script>

<style lang="scss" scoped>
.page-kan-dan-detail {
  background: #f2f2f2 linear-gradient(0deg, #f2f2f2 0%, #4a78ea 51%, #1753ea 100%) no-repeat;
  background-size: 100% 600rpx;
  padding: 118rpx 30rpx 162rpx;
  min-height: 100%;

  .header {
    position: fixed;
    top: 36rpx;
    left: 0;
    right: 0;
    z-index: 99;
    display: flex;
    height: 88rpx;
    line-height: 88rpx;
    color: #fff;
    font-size: 34rpx;
    font-weight: 500;
    text-align: center;
    .title {
      flex: 3;
    }
    .left,
    .right {
      flex: 1;
    }
    .icon {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 88rpx;
      height: 88rpx;
    }
  }

  .form {
    background-color: #fff;
    padding: 40rpx;
    border-radius: 10rpx;
    box-shadow: 0 0 20rpx 0 rgba(128, 128, 128, 0.2);

    .u-form-item {
      padding: 30rpx 0;
      line-height: 35rpx;
    }
  }

  .bottom-bar {
    z-index: 21;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;

    .container {
      background: #ffffff;
      box-shadow: 0 1rpx 20rpx 0 rgba(128, 128, 128, 0.2);
      padding: 20rpx;
    }

    .extra {
      background-color: #fff;
      margin: 5px;
      border-radius: 5px;
      padding: 0 10px;
    }

    .bottom-info {
      .u-form-item {
        padding: 0;
      }
    }
  }
}
</style>
