<template>
<div class="container">
  <my-nav @listener-helper="helperHandle"></my-nav>
  <div class="content">
<!--    <InputNumber :max="10" :min="1" v-model="value1"></InputNumber>-->
    <my-modal-material ref="materialModal" @getselectedList="getselectedList"></my-modal-material>
  </div>
</div>
</template>

<script>
import MyNav from '@/components/my-nav'
import MyModalMaterial from '@/components/my-modal-form/my-modal-material'
import { ApplyTakeAdd } from '@/api/integrated'

export default {
  name: "store-in",
  data() {
    return {
      data: [],
      show: false,
      material: {},
      otherData: []
    }
  },
  components: {
    MyNav,
    MyModalMaterial
  },
  methods: {
    /* 辅助扫描通知 */
    helperHandle (data) {
      this.otherData = data
    },

    getselectedList (data,newData) {
      const materialList = []
      for (let i = 0; i < data.length; i++) {
        const element = data[i];
        materialList.push({
          materialCode: element.code,
          takeQty: element.quantity
        })
      }
      for (let i = 0; i < newData.length; i++) {
        const element = newData[i];
        if(element.quantity != undefined && element.quantity != ''){
          materialList.push({
            materialCode: element.materialCode,
            takeQty: element.quantity
          })
        }
      }
      ApplyTakeAdd({
        materialList: materialList
      }).then(res => {
        if (res.code === 0) {
          this.$Message.success(res.msg || '领料成功！')
          this.handle(data,newData)
        }
      })
    },
    handle(data,newData) {
      this.$router.replace({
        name: 'store-out',
        query: {
          data: JSON.stringify(data),
          otherData: JSON.stringify(this.otherData),
          newData:JSON.stringify(newData)
        }
      })
    }
  },
  mounted() {
  },
  destroyed() {
  }
}
</script>

<style lang="scss" scoped>
  .container {
    width: 100vw;
    height: 100vh;
    overflow: auto;
    //background: rgba(2, 125, 180, 1);
    background-image: linear-gradient(270deg,
        #2c3034 0%,
        #50575e 49%,
        #2c3034 100%);
    .content {
      padding: 10px 40px;
      margin: 10px;
      height: calc(100% - 142px);
      display: flex;
      align-items: center;
      justify-content: center;
      //background: rgba(1, 84, 120, 1);
      border-radius: 10px;
      .reading {
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 36px;
        font-weight: bold;
        color: #00FFFF;
      }
      .title {
        padding: 10px 0;
        text-align: center;
        font-size: 36px;
        font-weight: bold;
        color: #2dc57c;
      }
      .list-wrap {
        width: 100%;
        height: calc(100% - 74px);
        //background: rgba(2, 125, 180, 0.486274509803922);
        background: #2c3034;
        border-radius: 10px;
        border: solid 1px #3879e7;
        overflow: auto;
        .item {
          padding: 20px 40px;
          //background: rgba(215, 215, 215, 1);
          //border-radius: 10px;
          cursor: pointer;
          color: #ffffff;
          border-bottom: solid 1px #2655ad;;
          .row {
            margin-bottom: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-radius: 10px;
            &:last-child {
              margin-bottom: 0;
            }
            .col {
              flex: 1;
              font-size: 18px;
              text-align: left;
            }
          }
        }
      }
    }
  }
</style>
