Mr.Zhang
2023-09-07 def7a94103b1c68110dcfc2a7ceba3021a22a24f
minipro_standard/pages/InOperation/InOperation.vue
@@ -63,10 +63,9 @@
            </div>
         </div>
         <!--        入库单(单个仓库)        -->
         <template
            v-if="route.query.type == 9 && info.woScanMaterialBeanList && info.woScanMaterialBeanList.length > 0">
         <template v-if="type == 9 && woScanMaterialBeanList && woScanMaterialBeanList.length > 0">
            <div class="page_yxwl_list">
               <div class="page_yxwl_list_item" v-for="(item, index) in info.woScanMaterialBeanList" :key="index">
               <div class="page_yxwl_list_item" v-for="(item, index) in woScanMaterialBeanList" :key="index">
                  <div class="page_yxwl_list_item_top">
                     <!--                            <div class="page_yxwl_list_item_top_left" v-if="item.batch">{{item.materialName}} | {{item.materialCode}}|{{item.batch}}</div>-->
                     <div class="page_yxwl_list_item_top_left">{{item.materialName}} | {{item.materialCode}}
@@ -107,7 +106,7 @@
            </div>
         </template>
         <!--        转库单(多个仓库)        -->
         <template v-else-if="route.query.type == 7 && seleMateriaList.length > 0">
         <template v-else-if="type == 7 && seleMateriaList.length > 0">
            <!-- <template v-for="(item, index) in info.wtransferWarehouseList" :key="index"> -->
            <div class="page_yxwl_list">
               <div class="page_yxwl_list_item" v-for="(item1, idx) in seleMateriaList" :key="idx">
@@ -158,16 +157,14 @@
            <span>确认入库</span>
         </div>
      </div>
      <SelectMultipleMaterial ref="selectMultipleMaterial" />
      <SelectLoaction ref="selectLoaction" @selected="selectLocation"/>
      <MaterialIn ref="materialIn" @selected="selectLocation"/>
      <SelectLoaction ref="selectLoaction" @selected="selectLocation" />
      <MaterialIn ref="materialIn" @selected="selectMaterial" />
   </view>
</template>
<script>
   import InOutInfo from '@/components/InOutInfo.vue'
   import SelectMultipleMaterial from '@/components/SelectMultipleMaterial.vue'
   import SelectLoaction from '@/components/SelectLoaction.vue'
   import SelectLoaction from '@/components/SelectLoaction.vue'
   import MaterialIn from '@/components/materialIn.vue'
   import {
      QRCodeType
@@ -196,24 +193,25 @@
   } from '@/util/api/agencyAPI'
   export default {
      components: {
         InOutInfo,
         SelectLoaction,
         MaterialIn,
         SelectMultipleMaterial
         InOutInfo,
         SelectLoaction,
         MaterialIn
      },
      data() {
         return {
            type: '',
            id: '',
            id: '',
            wareHouseId: '',
            isZKD: false,
            show: false,
            info: {},
            ids: [],
            location: '',
            ids: [],
            location: '',
            locationName: '',
            wtransferWarehouseList: [],
            MateriaList: []
            MateriaList: [],
            woScanMaterialBeanList: [],
            seleMateriaList: [] // 已选物料
         };
      },
      onLoad(option) {
@@ -246,8 +244,8 @@
            let data = {
               id: this.id
            }
            console.log(this.type, QRCodeType.CKD);
            if (this.type == QRCodeType.CKD) {
            // console.log(this.type, QRCodeType.CKD);
            if (this.type == QRCodeType.RKD) {
               infoAction = wOutBoundForInOut
               data.wOutboundType = '1'
            } else if (this.type == QRCodeType.ZKD) {
@@ -256,13 +254,14 @@
            }
            infoAction(data).then(res => {
               if (this.isZKD) {
                  this.info = res.data.wtransfer
                  this.info = res.data.wtransfer
                  this.wareHouseId = res.data.wtransfer.inWarehouseId
                  this.wtransferWarehouseList = res.data.wtransferWarehouseList
                  this.MateriaList = res.data.wtransferWarehouseList[0].wtransferDetailList
               } else {
                  this.info = res.data.woutbound
                  this.woutboundDetailsWait = res.data.woutboundDetailsWait
                  this.woScanMaterialBeanList = res.data.woScanMaterialBeanList
               }
            }).catch(err => {
               uni.$u.toast(err)
@@ -277,19 +276,167 @@
                  wareHouseId: this.wareHouseId
               })
               .then(res => {
                  if (res.data.length === 1) {
                     this.location = res.data[0].id
                     this.locationName = res.data[0].unionName
                     this.$refs.materialIn.open({list: this.MateriaList})
                  } else {
                     this.$refs.selectLoaction.open({wareHouseId: this.wareHouseId})
                  if (res.data.length === 1) {
                     this.location = res.data[0].id
                     this.locationName = res.data[0].unionName
                     this.$refs.materialIn.open({
                        list: this.MateriaList
                     })
                  } else {
                     this.$refs.selectLoaction.open({
                        wareHouseId: this.wareHouseId
                     })
                  }
               })
         },
         selectLocation(item) {
            this.location = item.id
            this.locationName = item.unionName
            this.$refs.materialIn.open({list: this.MateriaList})
         },
         selectLocation(item) {
            this.location = item.id
            this.locationName = item.unionName
            this.$refs.materialIn.open({
               list: this.MateriaList
            })
         },
         selectMaterial(val) {
            let material = JSON.parse(JSON.stringify(val))
            let tempMaterial = this.seleMateriaList.find(item => item.locationId == this.location)
            if (tempMaterial) {
               if (tempMaterial.qualityType == material.qualityType && tempMaterial.procedureId == material
                  .procedureId &&
                  tempMaterial.batch == material.batch && tempMaterial.materialId == material.materialId) {
                  uni.$u.toast('相同货位,同一个物料只能有一个')
                  return
               }
            }
            let materialNum = 0
            let num = 0
            this.seleMateriaList.forEach(item => {
               if (item.id === material.id) {
                  materialNum += Number(item.outActnum)
               }
            })
            this.MateriaList.forEach(item => {
               if (item.id === material.id) {
                  num = item.outActnum - materialNum
               }
            })
            material.outActnum = num
            this.seleMateriaList.push({
               ...material,
               locationId: this.location,
               locationName: this.locationName
            })
         },
         submit() {
            if (this.type == QRCodeType.ZKD) {
               if (!this.seleMateriaList.length) {
                  uni.$u.toast('转入物料不能为空')
                  return
               }
               let result = this.seleMateriaList.reduce((a, b) => {
                  if (a[b.id]) {
                     a[b.id].push(b);
                  } else {
                     a[b.id] = [b];
                  }
                  return a;
               }, {});
               for (let i = 0; i < this.MateriaList.length; i++) {
                  for (let a in result) {
                     if (this.MateriaList[i].id == a) {
                        let total = 0
                        for (let b = 0; b < result[a].length; b++) {
                           total = Number(total) + Number(result[a][b].outActnum)
                        }
                        if (!total || total <= 0) {
                           uni.$u.toast('入库数量不能小于0')
                           return
                           // Toast.fail({
                           //    message: '入库数量不能小于0',
                           //    forbidClick: true,
                           //    duration: 2000
                           // })
                        }
                        if (total > this.MateriaList[i].outActnum) {
                           uni.$u.toast('入库数量不能大于待入库数量')
                           return
                           // Toast.fail({
                           //    message: '入库数量不能大于待入库数量',
                           //    forbidClick: true,
                           //    duration: 2000
                           // })
                        }
                     }
                  }
               }
               let submitTransferInDetailDTOList = []
               this.seleMateriaList.forEach(item => {
                  submitTransferInDetailDTOList.push({
                     inNum: item.outActnum,
                     locationId: item.locationId,
                     wtransferDetailId: item.id
                  })
               })
               transferToInNew({
                  submitTransferInDetailDTOList,
                  wtransferId: this.id
               }).then(res => {
                  if (res.code === 200) {
                     this.$store.dispatch('getUpcomingNum')
                     uni.$u.toast('操作成功')
                     // Toast.success({
                     //    message: '操作成功',
                     //    forbidClick: true,
                     //    duration: 2000
                     // })
                     // setTimeout(() => {
                     //    if (route.query.Type == '4') { // 跳转完工入库详情
                     //       router.push({
                     //          name: 'completionDetails',
                     //          query: {
                     //             id: route.query.id,
                     //             dbid: route.query.dbid,
                     //             type: 7,
                     //             isShow: 2
                     //          }
                     //       })
                     //       return
                     //    }
                     //    router.replace({
                     //       name: 'wTransferDetail',
                     //       query: {
                     //          id: route.query.id
                     //       }
                     //    })
                     // }, 2000)
                  }
               })
            } else if (this.type === QRCodeType.RKD) {
               wOutBoundForUpload({
                  id: this.info.id,
                  wOutboundType: 1
               }).then(res => {
                  if (res.code === 200) {
                     this.$store.dispatch('getUpcomingNum')
                     uni.$u.toast('操作成功')
                     // Toast.success({
                     //    message: '操作成功',
                     //    forbidClick: true,
                     //    duration: 2000
                     // })
                     // setTimeout(() => {
                     //    // router.go(-1)
                     //    router.replace({
                     //       name: 'wInboundDetail',
                     //       query: {
                     //          id: this.id
                     //       }
                     //    })
                     // }, 2000)
                  }
               })
            }
         }
      }
   }
@@ -606,6 +753,7 @@
                     }
                     .nr {
                        display: flex;
                        font-size: 26rpx;
                        font-weight: 400;
                        color: #222222;