<template>
  <view class="page-product-receipt">
    <view class="header" :style="{ backgroundColor: `rgba(250, 53, 52, ${scrollTop / 100})` }">
      <view class="left">
        <u-icon class="icon" name="arrow-left" @click="uni.navigateBack({})" />
      </view>
      <view class="title">历史记录</view>
      <view class="right"></view>
    </view>
    <u-form class="form" ref="form" label-width="180rpx">
      <!-- 订单 -->
      <!-- <u-form-item label="检验节点"> -->
      <u-input @blur="onblur()" @focus="onfocus" @click="onclick" :border="true" v-model="selectvalue" placeholder="请选择检验节点" style="overflow: hidden" />
      <!-- </u-form-item> -->
    </u-form>
    <view class="scroll">
      <view v-for="item in list" :key="item.id" @dblclick="onFormDoubleClick(item)">
        <u-form style="margin-top: 10rpx" class="form2">
          <view class="list">
            <view class="righttitle">
              <view class="boder-icon-top zhuangtai" data-state="0">待收货</view>
            </view>
            <view class="row-list">
              <view class="list-item"> 来料批次号: </view>
              <view> 4500331750 </view>
            </view>
            <view class="row-list">
              <view class="list-item"> 订单号: </view>
              <view> 40000006954 </view>
            </view>
            <view class="row-list">
              <view class="row-list-item">
                <view class="list-item"> 物料号: </view>
                <view> tp100 </view>
              </view>
              <view class="row-list-item">
                <view class="list-item"> 物料名称: </view>
                <view> 12335 </view>
              </view>
            </view>
            <view class="row-list">
              <view class="row-list-item">
                <view class="list-item"> 收货数量: </view>
                <view> 100/0 </view>
              </view>
            </view>
            <view a:if="true" class="righttitle">
              <view @click.stop="onPass(item)" class="boder-icon-rigth"> 查看 </view>
            </view>
          </view>
        </u-form>
      </view>
    </view>
    <view>
      <u-popup v-model="show" mode="center" width="98%">
        <view class="selectlist">
          <view class="item" v-for="(item, index) in detailList" :key="index">
            <div class="item1">检查项: {{ item.itemName }}</div>
            <div class="item1">检查结果: {{ item.itemMethod }}</div>
            <div v-for="(item1, index1) in item.standardList" :key="index1">
              <div class="item1 item2" v-if="item1.standardType == 'qualitative'">
                <div>检查标准: {{ item1.standardName }}</div>
                <div class="select">
                  <u-radio-group v-model="item1.detailReach" @change="radioGroupChange(item1, item1.detailReach, index, index1)">
                    <u-radio @change="radioChange" v-for="(n, indexn) in listselect" :key="indexn" :name="n.type" :disabled="item1.detailReach == n.type ? false : true">
                      {{ n.name }}
                    </u-radio>
                  </u-radio-group>
                </div>
              </div>
              <div class="item1 item2" v-if="item1.standardType == 'quantify'">
                <div>检查标准: {{ item1.standardName }}</div>
                <div class="input-box" id="input-box1">
                  实际值:
                  <input class="input" :disabled="item1.actualValue == null ? true : true" v-model="item1.actualValue" @focus="focus()" @blur="blur(item1, item1.actualValue, index, index1)" @change="changeinput(item1)" @input="input(item1)" type="text" name="" id="" />
                  单位:mm
                </div>
              </div>
            </div>
          </view>
          <div style="text-align: center; margin-top: 10px">
            <u-button style="width: 100%; height: 35px; margin: auto" @click="onOk" size="mini" type="primary">确认</u-button>
          </div>
        </view>
      </u-popup>
      <view v-if="show" class="mask"></view>
    </view>
    <u-select v-model="showselect" mode="mutil-column-auto" :list="selectlist" @confirm="confirmselect"></u-select>
    <u-modal v-model="isshow" class="modal" :show-cancel-button="true" :show-title="false" @cancel="cancel" @confirm="confirm">
      <div class="tagsbox">
        <u-tag v-for="(item, index) in tagslist" class="tags" :key="item.id" :text="item.tagsname" type="info" closeable @close="tagClick(index)" />
      </div>
      <div class="upload-name">
        <div>
          <u-input :border="true" v-model="tagsvalue" style="overflow: hidden" />
        </div>
        <div>
          <u-button style="width: 100px; height: 35px; margin-left: 5px" @click="ontagsadd" size="mini" type="primary">确认</u-button>
        </div>
      </div>
    </u-modal>
  </view>
</template>
<script lang="ts">
import { Component } from 'vue-property-decorator';
import { BasePage } from '@/components/base/page';
import jPicker from '@/components/J-Picker/jPicker.vue';
import model from './model';
//import { any } from 'lodash/fp';
//import { session } from '@/store/modules/session';
@Component({
  components: {
    jPicker,
  },
})
export default class PurchaseWHSRM extends BasePage {
  model = model;
  list: any = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }];
  show = false;
  showselect = false;
  isshow = false;
  form3: any = {
    barCodewl: '',
  };
  listselect: any = [
    {
      type: 1,
      name: '合格',
      radiovalue: null,
    },
    {
      type: 0,
      name: '不合格',
      radiovalue: null,
    },
  ];
  // remove: any = {};
  // async onReady() {
  //   await this.model.queryLocation();
  //   this.remove = this.model.WlList[0];
  // }
  // selectItem(e: any) {
  //   this.remove = e.pickerName;
  // }
  orderNo: any = '';
  selectvalue: any = '';
  border = true;
  height = 100;
  autoHeight = true;
  imgList: any = [];
  imgUrlList: any = [];
  isqualified = [
    {
      label: '合格',
      value: '1',
    },
    {
      label: '不合格',
      value: '0',
    },
  ];
  selectlist: any = [
    {
      value: 1,
      label: '中国',
      children: [
        {
          value: 2,
          label: '广东',
          children: [
            {
              value: 3,
              label: '深圳',
            },
            {
              value: 4,
              label: '广州',
            },
          ],
        },
        {
          value: 5,
          label: '广西',
          children: [
            {
              value: 6,
              label: '南宁',
            },
            {
              value: 7,
              label: '桂林',
            },
          ],
        },
      ],
    },
    {
      value: 8,
      label: '美国',
      children: [
        {
          value: 9,
          label: '纽约',
          children: [
            {
              value: 10,
              label: '皇后街区',
            },
          ],
        },
      ],
    },
  ];
  productCodeList: any = {};
  detailList: any = [
    {
      createBy: 'job',
      createTime: '2023-12-01 09:25:38',
      updateBy: null,
      updateTime: null,
      remark: null,
      poolName: null,
      deptId: null,
      id: '0d28bb4dc1b14186a0ad7610c4ea98a4',
      code: null,
      orderCode: 'O20231201001',
      parentCode: null,
      itemCode: '20231128002',
      itemName: '纸盒料架',
      itemMethod: '目视、触摸',
      itemType: 'spotInspection',
      itemTypeName: '点检',
      factoryCode: '1000',
      attr1: null,
      attr2: null,
      attr3: null,
      delFlag: '0',
      standardList: [
        {
          createBy: 'job',
          createTime: '2023-12-01 09:25:38',
          updateBy: null,
          updateTime: '2023-12-01 09:30:55',
          remark: null,
          poolName: null,
          deptId: null,
          id: 'c0c4cc8a651f49ae9a63b4397c8745f4',
          code: null,
          parentCode: '0d28bb4dc1b14186a0ad7610c4ea98a4',
          orderCode: 'O20231201001',
          standardType: 'qualitative',
          standardName: '检查料架有没有松动，目视有没有异物堵塞线体',
          detailUpLimit: null,
          detailDownLimit: null,
          detailUnit: null,
          detailReach: '1',
          actualValue: null,
          detailError: null,
          factoryCode: '1000',
          attr1: null,
          attr2: null,
          attr3: null,
          delFlag: '0',
          picturePath: null,
          picturePaths: null,
          standardTypeName: null,
          errorFlag: '0',
          faultType: null,
          repairReach: null,
          repairValue: null,
          repairPicture: null,
          itemName: null,
          checkPictrueList: [],
        },
      ],
      itemTools: null,
    },
    {
      createBy: 'job',
      createTime: '2023-12-01 09:25:38',
      updateBy: null,
      updateTime: null,
      remark: null,
      poolName: null,
      deptId: null,
      id: '34220cb558004bd09e08fdf14fada352',
      code: null,
      orderCode: 'O20231201001',
      parentCode: null,
      itemCode: '20231128003',
      itemName: '入盒机构',
      itemMethod: '目视、触摸',
      itemType: 'spotInspection',
      itemTypeName: '点检',
      factoryCode: '1000',
      attr1: null,
      attr2: null,
      attr3: null,
      delFlag: '0',
      standardList: [
        {
          createBy: 'job',
          createTime: '2023-12-01 09:25:38',
          updateBy: null,
          updateTime: '2023-12-01 09:30:55',
          remark: null,
          poolName: null,
          deptId: null,
          id: '0b2277d4760c4063b3981a52675ca96b',
          code: null,
          parentCode: '34220cb558004bd09e08fdf14fada352',
          orderCode: 'O20231201001',
          standardType: 'qualitative',
          standardName: '打开入盒机前用气枪清理表面灰尘、废料',
          detailUpLimit: null,
          detailDownLimit: null,
          detailUnit: null,
          detailReach: '1',
          actualValue: null,
          detailError: null,
          factoryCode: '1000',
          attr1: null,
          attr2: null,
          attr3: null,
          delFlag: '0',
          picturePath: null,
          picturePaths: null,
          standardTypeName: null,
          errorFlag: '0',
          faultType: null,
          repairReach: null,
          repairValue: null,
          repairPicture: null,
          itemName: null,
          checkPictrueList: [],
        },
        {
          createBy: 'job',
          createTime: '2023-12-01 09:25:38',
          updateBy: null,
          updateTime: '2023-12-01 09:30:55',
          remark: null,
          poolName: null,
          deptId: null,
          id: '6152eff58de14a86af1cb52a010c8bf7',
          code: null,
          parentCode: '34220cb558004bd09e08fdf14fada352',
          orderCode: 'O20231201001',
          standardType: 'qualitative',
          standardName: '检查入盒机构传动部、螺丝有没有松动',
          detailUpLimit: null,
          detailDownLimit: null,
          detailUnit: null,
          detailReach: '1',
          actualValue: null,
          detailError: null,
          factoryCode: '1000',
          attr1: null,
          attr2: null,
          attr3: null,
          delFlag: '0',
          picturePath: null,
          picturePaths: null,
          standardTypeName: null,
          errorFlag: '0',
          faultType: null,
          repairReach: null,
          repairValue: null,
          repairPicture: null,
          itemName: null,
          checkPictrueList: [],
        },
      ],
      itemTools: null,
    },
    {
      createBy: 'job',
      createTime: '2023-12-04 14:32:04',
      updateBy: null,
      updateTime: null,
      remark: null,
      poolName: null,
      deptId: null,
      id: '32e34709fd2846e79b46fce9c1dad477',
      code: null,
      orderCode: 'O20231204005',
      parentCode: null,
      itemCode: '20231117006',
      itemName: '皮带、轴承、齿轮',
      itemMethod: '试机',
      itemType: 'spotInspection',
      itemTypeName: '点检',
      factoryCode: '1000',
      attr1: null,
      attr2: null,
      attr3: null,
      delFlag: '0',
      standardList: [
        {
          createBy: 'job',
          createTime: '2023-12-04 14:32:04',
          updateBy: null,
          updateTime: '2023-12-04 14:34:01',
          remark: null,
          poolName: null,
          deptId: null,
          id: '8a107dae72d1469590cba36066f46621',
          code: null,
          parentCode: '32e34709fd2846e79b46fce9c1dad477',
          orderCode: 'O20231204005',
          standardType: 'quantify',
          standardName: '机油量',
          detailUpLimit: 30.0,
          detailDownLimit: 10.0,
          detailUnit: 'ml',
          detailReach: '0',
          actualValue: 0.0,
          detailError: null,
          factoryCode: '1000',
          attr1: null,
          attr2: null,
          attr3: null,
          delFlag: '0',
          picturePath: null,
          picturePaths: null,
          standardTypeName: null,
          errorFlag: null,
          faultType: null,
          repairReach: null,
          repairValue: null,
          repairPicture: null,
          itemName: null,
          checkPictrueList: [],
        },
        {
          createBy: 'job',
          createTime: '2023-12-04 14:32:04',
          updateBy: null,
          updateTime: '2023-12-04 14:34:01',
          remark: null,
          poolName: null,
          deptId: null,
          id: '99ed048515a0456c9126bd83da298e5d',
          code: null,
          parentCode: '32e34709fd2846e79b46fce9c1dad477',
          orderCode: 'O20231204005',
          standardType: 'qualitative',
          standardName: '运行流畅无异响',
          detailUpLimit: null,
          detailDownLimit: null,
          detailUnit: null,
          detailReach: '0',
          actualValue: null,
          detailError: null,
          factoryCode: '1000',
          attr1: null,
          attr2: null,
          attr3: null,
          delFlag: '0',
          picturePath: null,
          picturePaths: null,
          standardTypeName: null,
          errorFlag: null,
          faultType: null,
          repairReach: null,
          repairValue: null,
          repairPicture: null,
          itemName: null,
          checkPictrueList: ['http://localhost:9300/downLoadFile?id=656d72d339e7164f038e8baa&fileName=cc764c41967d4cc199193090f4a1b443_th.jpg', 'http://localhost:9300/downLoadFile?id=656d72d639e7164f038e8bac&fileName=dda84cfe50dc462ba731490000c6d6bc.png'],
        },
      ],
      itemTools: null,
    },
  ];
  equipmentindex: any = [];
  tagsvalue: any = '';
  tagslist: any = [];
  //收货按钮
  tagClick(index) {
    this.tagslist.splice(index, 1);
  }
  ontagsadd() {
    let arr1 = {};
    if (this.tagsvalue == '' || this.tagsvalue == undefined) {
      // this.customToast('请扫码设备编码');
      (this.$refs.uToast as any).show({
        title: '请输入内容',
        type: 'default',
      });
      return;
    }
    arr1 = {
      tagsname: this.tagsvalue,
    };
    this.tagslist.push(arr1);
  }
  onPass(item) {
    console.log('1234567', item);
    this.show = true;
  }
  radioGroupChange(item, value, index, index1) {
    console.log(item, value, index, index1);
  }
  radioChange(e) {
    console.log(e, '11111');
  }
  blur(item, value, index, index1) {
    console.log(item, value, index, index1);
    this.equipmentindex = [];
    this.equipmentindex.push(index);
    this.equipmentindex.push(index1);
    this.isshow = true;
  }
  focus() {
    this.isshow = true;
  }
  changeinput(e) {
    console.log(e);
  }
  input(e) {
    console.log(e);
  }
  nopoup() {
    this.show = false;
    this.form3.barCodewl = '';
  }
  onblur() {
    console.log('333');
    this.showselect = true;
  }
  onfocus() {
    console.log('222');
    this.showselect = false;
  }
  onclick() {
    console.log('111');
    this.showselect = true;
  }
  //点击收货按钮，录入批次（或系统自动生成）、数量、托盘码进行收货。
  onOk() {
    console.log('1234567');
    //await this.model.OnSubmit(this.form3.barCodewl);
  }
  confirmselect(e) {
    console.log(e);
  }
  confirm() {
    console.log(this.detailList[this.equipmentindex[0]].standardList[this.equipmentindex[1]]);
  }
  cancel() {
    this.isshow = false;
  }
  async onFormDoubleClick(item) {
    console.log('双击', item);
    //await this.model.OnSubmit(item.id);
    this.uni.navigateTo({
      url: this.page.wms.PurchaseWHSRMDetail,
    });
  }
  //查询货单关联采购单信息
  async query() {
    // if (this.orderNo == '' || this.orderNo.length == 0) {
    //   this.customToast('请输入nficl');
    //   return;
    // }
    // await this.model.queryOrderNo(this.orderNo);
    // this.list = model.orderNoItemList;
  }
  //提单按钮
  tidan() {
    console.log('11111');
  }
  histroyItem: any = {};
  barcode: any = '';
  //完成送货单
  scanwl() {
    const self: PurchaseWHSRM = this as PurchaseWHSRM;
    const showToast = (message: string) => {
      uni.showToast({
        title: message,
        icon: 'none',
      });
    };
    uni.scanCode({
      onlyFromCamera: true,
      success: function (res) {
        //showToast(res.result);
        console.log('条码类型：' + res.scanType);
        console.log('条码内容：' + res.result);
        self.form3.barCodewl = res.result;
        //that.getByPoint();
      },
      fail: function () {
        showToast('扫码不成功');
      },
    });
  }
}
</script>
<style lang="scss" scoped>
.page-product-receipt {
  background: #f2f2f2 linear-gradient(0deg, #f2f2f2 0%, #f8262c 51%, #d9001b 100%) no-repeat;
  background-size: 100% 600rpx;
  padding: 118rpx 30rpx 162rpx;
  min-height: 100%;

  .header {
    position: fixed;
    top: 0rpx;
    left: 0;
    right: 0;
    z-index: 99;
    display: flex;
    height: 120rpx;
    line-height: 88rpx;
    color: #fff;
    font-size: 34rpx;
    font-weight: 500;
    text-align: center;
    padding: 45rpx 0rpx 0rpx;

    .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;

      .Transfer {
        width: 280rpx;
        height: 64rpx;
        background: rgb(242, 242, 242);
        border-radius: 110rpx;
      }
    }

    .single {
      width: 100%;
      height: 100rpx;
      display: flex;

      .single-left {
        width: 80%;
        height: 100%;
        display: flex;

        view {
          width: 142rpx;
          height: 100%;
          line-height: 100rpx;
        }
      }

      .single-right {
        button {
          margin-top: 15rpx;
          width: 140rpx;
          height: 70rpx;
          background-color: #fa3534;
        }
      }
    }

    .row {
      display: flex;
      flex-direction: row;
      justify-content: space-around;
      flex: 1;
    }
  }

  .scroll {
    // margin-top: 120rpx;
    // padding-left: 30rpx;
    // padding-right: 16rpx;
    // margin-bottom: 20rpx;
    // overflow: scroll;
    // padding-top: 20rpx;
    .form2 {
      background-color: #fff;
      padding: 0rpx 25rpx 25rpx;
      border-radius: 10rpx;
      box-shadow: 0 0 20rpx 0 rgba(128, 128, 128, 0.2);
      color: #8d8989;

      .row-list {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        .row-list-item {
          display: flex;
          flex-direction: row;
          justify-content: space-between;
          width: 40%;
        }
        .list-item {
          display: flex;
          flex-direction: row;
          flex: 1;
        }
      }

      .righttitle {
        display: flex;
        justify-content: flex-end;

        .boder-icon-rigth {
          border: 1rpx solid #fa3534;
          width: 130rpx;
          text-align: center;
          background: #fa3534;
          color: #ffffff;
          margin-top: 10px;
        }

        .zhuangtai {
          background: #a7a0a04a;
          width: 224rpx;
          margin-right: -27rpx;
          border: 2rpx solid #a7a0a04a;
          border-radius: 12rpx;
          text-align: center;
          margin-bottom: 10rpx;
        }

        .zhuangtai[data-state='1'] {
          color: green;
        }

        .zhuangtai[data-state='0'] {
          color: blue;
        }
      }
    }
  }

  .bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99;
    background: #ffffff;
    box-shadow: 0 1rpx 20rpx 0 rgba(128, 128, 128, 0.2);
    padding: 20rpx;
  }

  .button-bar {
  }

  .photoList {
    display: flex;
    padding-top: 12rpx;

    .chooseBtn {
      width: 202rpx;
      height: 202rpx;
      background: #fafafa;
      border-radius: 12rpx;
      border: 2rpx dashed #e2e2e2;
      display: flex;
      justify-content: center;
      align-items: center;

      .inner {
        text-align: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
      }

      .desc {
        font-size: 28rpx;
        font-weight: 400;
        color: #24252a;
        line-height: 40rpx;
      }

      .img {
        width: 50rpx;
        height: 50rpx;
        margin-bottom: 6rpx;
      }
    }

    .photoBox {
      width: 202rpx;
      height: 202rpx;
      background: #fafafa;
      border-radius: 12rpx;
      position: relative;

      .closeBtn {
        position: absolute;
        top: -12rpx;
        right: -12rpx;
        z-index: 2;
        width: 36rpx;
        height: 36rpx;

        .img {
          width: 36rpx;
          height: 36rpx;
        }
      }

      .img {
        width: 202rpx;
        height: 202rpx;
        border-radius: 12rpx;
      }
    }

    .itemBox {
      flex: 0 0 202rpx;
      margin-right: 20rpx;

      &:last-child {
        margin-right: 0;
      }
    }

    // /deep/ .remarksBox textarea {
    //   font-size: 24rpx;
    // }
  }
  .form3 {
    padding: 20rpx;
    //border-radius: 10rpx;
    //box-shadow: 0 0 20rpx 0 rgba(128, 128, 128, 0.2);
    .poupitem {
      display: flex;
      flex-direction: row;
      justify-content: space-around;
      margin: 20rpx;
      .pouptitle {
        width: 25%;
      }
      .poupcontent {
        border: 1px solid rgba(128, 128, 128, 0.2);
      }
    }
  }
  .poupbutton {
    display: flex;
    justify-content: space-around;
  }
  .mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* 半透明的黑色背景 */
    z-index: 9999; /* 确保遮罩层在最上层 */
  }
  .selectlist {
    margin-top: 15px;
    border-radius: 5px;
    // border: rgba(121, 121, 121, 1) solid 1px;
    // background-color: #ffffff;
    padding: 7px 8px 7px 12px;
    box-sizing: border-box;
    .item-name {
      .quest {
        // width: 367px;
        // border-radius: 5px;
        // border: rgba(121, 121, 121, 1) solid 1px;
        // background-color: #ffffff;
        padding: 7px 8px 7px 12px;
        box-sizing: border-box;
        text-align: center;
        font-size: 18px;
      }
      .details {
        display: flex;
        font-size: 16px;
        // justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
      }
    }
    .single-left {
      display: flex;
      // align-items: center;
      // justify-content: space-around;
      text-align: center;
      margin-top: 12px;
      margin-bottom: 20px;
      border: 1px solid #eee;
    }
    .item {
      margin-top: 15px;
      width: 344px;
      border-radius: 5px;
      border: rgba(121, 121, 121, 1) solid 1px;
      // background-color: #ffffff;
      padding: 7px 8px 7px 8px;
      box-sizing: border-box;
      .item1 {
        margin-bottom: 3px;
        white-space: 1px;
        font-size: 15px;
        font-weight: 600;
      }
      .item2 {
        display: flex;
        align-content: center;
        justify-content: space-between;
        .select {
          font-size: 15px;
          font-weight: 400;
          display: flex;
          // margin-left: 19px;
        }
        .input-box {
          font-size: 13px;
          font-weight: 400;
          display: flex;
          align-content: center;
          margin-top: 2px;
          .input {
            font-size: 12px;
            width: 65px;
            padding: 1px 8px;
            height: 20px;
            box-sizing: border-box;
            border: 1px solid #b6b6b6;
            margin-left: 6px;
            display: inline-block;
            margin-right: 6px;
            border-radius: 4px;
            position: relative;
          }
        }
      }
    }
  }
  .modal {
    .upload-name {
      padding: 10px 20px;
      display: flex;
      justify-content: space-between;
      .name {
        font-size: 17px;
        font-weight: 600;
      }
    }
    .tagsbox {
      padding: 10px 20px;
      .tags {
        margin-right: 5px;
      }
    }
  }
}
</style>
