<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>
    <view style="margin: 20px">
      <wyb-table ref="table" :headers="headers" :contents="tableData" enable-check="single" width="auto" first-col-bg-color="#ffffff" checker-color="#000000" @onCheck="changeContent" show-left-and-right-border />
    </view>
    <view class="bottom-bar">
      <u-row class="button-bar">
        <!-- 确定 -->
        <u-col :span="6">
          <u-button @click="gozhijian" type="primary">质检</u-button>
        </u-col>
        <!-- 返回 -->
        <u-col :span="6">
          <u-button type="error" @click="goxiangxi">详细查看</u-button>
        </u-col>
      </u-row>
    </view>
  </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 { session } from '@/store/modules/session';
//import wybTable from '@/components/wyb-table/wyb-table.vue';
@Component({
  components: {
    jPicker,
  },
})
export default class ProductionQtyInsplist extends BasePage {
  model = model;
  rowdata: any = {};
  headers = [
    {
      label: '序号',
      key: 'index',
      width: 100,
    },
    {
      label: 'rfid',
      key: 'rfid',
      width: 320,
    },
    {
      label: '订单',
      key: 'orderCode',
    },
    {
      label: '机台',
      key: 'machineName',
    },
    {
      label: '产品',
      key: 'productName',
      width: 220,
    },
    {
      label: '工单',
      key: 'workorderCode',
      width: 220,
    },
    // {
    //   label: '是否合格',
    //   key: 'licensePlateNumber',
    // },
    {
      label: '不良描述',
      key: 'badMeg',
    },
    // {
    //   label: '照片',
    //   key: 'checkPeople',
    // },
  ];
  tableData: any = [];
  // remove: any = {};
  // async onReady() {
  //   await this.model.queryLocation();
  //   this.remove = this.model.WlList[0];
  // }
  // selectItem(e: any) {
  //   this.remove = e.pickerName;
  // }
  onShow() {
    this.query();
  }
  changeContent(e) {
    //console.log('eee', e.data);
    this.rowdata = e.data[0]?.lineData;
    // uni.$emit('changeContent',e);
  }
  gozhijian() {
    this.uni.navigateTo({
      url: this.page.mes.ProductionQtyInsp,
    });
  }
  goxiangxi() {
    //debugger
    //console.log('xssss',this.rowdata);
    if (JSON.stringify(this.rowdata) === '{}' || this.rowdata === undefined) {
      this.customToast('请选择一行进行查看');
    } else {
      this.model.rowdata = this.rowdata;
      this.uni.navigateTo({
        url: this.page.mes.ProductionQtyInspDetail,
      });
    }
  }
  async query() {
    //this.tableData = [];
    await this.model.queryhandChecklist();
    //console.log('1234567', this.model.Checklist);
    this.tableData = this.model.Checklist;
    this.tableData.map((item, index) => {
      item.index = index + 1;
    });
    //console.log('this.tableData', model.Checklist);
    //this.productCodeList = this.model.productCodeList[0];
    //this.histroyItem = this.model.orderNoItemList[0];
  }
  histroyItem: any = {};
  barcode: any = '';
  // async onSubmit() {
  //   if (this.orderNo == '' || this.orderNo.length == 0) {
  //     this.customToast('请输入nficl');
  //     return;
  //   }
  //   if (this.histroyItem == {} || !this.histroyItem.productCode) {
  //     this.customToast(this.$t('message.AppendMateriel5') as string);
  //     return;
  //   }
  //   if (this.barcode == '' || this.barcode.length == 0) {
  //     this.customToast(this.$t('message.barcode') as string);
  //     return;
  //   }
  //   let params = {
  //     loginName: session.loginName,
  //     orderNo: this.orderNo,
  //     orderItem: this.histroyItem.orderItem,
  //     productCode: this.histroyItem.productCode,
  //     productDescZh: this.histroyItem.productDescZh,
  //     orderType: this.histroyItem.orderType,
  //     barcode: this.barcode,
  //     // locCode: this.remove.value,
  //   };
  //   await this.model.OnSubmit(params);
  //   if (this.model.SubmitCode == '1') {
  //     this.customToast(this.$t('message.Warehouse_Tip9') as string);
  //     this.barcode = '';
  //     this.histroyItem = {};
  //     this.productCodeList = {};
  //     this.model.empty();
  //     await this.query();
  //   }
  // }
}
</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;
        }
      }
    }
  }

  .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;
    // }
  }
}
// .wyb-table-scroll-view {
//   width: auto !important;
// }
</style>
