Browse Source

入库登记-调拨入库功能调整

lxf 2 years ago
parent
commit
71707cb8d1

+ 9 - 0
src/api/shengde/warehouse/outAndInWarehouse.js

@@ -117,3 +117,12 @@ export function detailListCount(data) {
     data: data,
   })
 }
+
+// 出入库登记-校验是否能选择bom规格
+export function getComeOrder(data) {
+  return request({
+    url: '/saas-wms/saas/wms/tprowmsstockregistrationdetail/getComeOrder',
+    method: 'post',
+    data: data,
+  })
+}

+ 30 - 4
src/views/shengde/warehouse/putInStorage/material.vue

@@ -14,6 +14,7 @@
             <span>{{ `${scope.row.productLong} * ${scope.row.productWide} * ${scope.row.productHigh}` }}</span>
           </template>
         </el-table-column>
+        <el-table-column label="可调拨数量" prop="transferQuantity" width="120" v-if="form.type == '5'" />
         <el-table-column label="入库数量" width="180">
           <template slot-scope="scope">
             <el-form-item :prop="'details.' + scope.$index + '.quantity'" :rules="formRules.quantity" :inline-message="true">
@@ -38,6 +39,7 @@
 <script>
 import { mapGetters } from 'vuex'
 import SelectBOM from '@/components/shengde/SelectBOM/index'
+import { getComeOrder } from '@/api/shengde/warehouse/outAndInWarehouse'
 
 export default {
   props: {
@@ -68,6 +70,14 @@ export default {
       return flag
     },
     selectBOM() {
+      if (this.form.type == '5') {
+        if (!this.form.subsidiaryId) {
+          return this.msgInfo('请先选择事业部')
+        }
+        if (!this.form.oldWarehouseId) {
+          return this.msgInfo('请先选择原仓库')
+        }
+      }
       this.openSelect = true
     },
     handleSelect(data, index) {
@@ -76,7 +86,23 @@ export default {
         if (row && row.id) {
           let tableData = this.form.details.filter((item) => item.businessId === row.id)
           if (tableData && tableData.length > 0) {
-            this.msgInfo('该物料已添加')
+            return this.msgInfo('该物料已添加')
+          }
+          if (this.form.type == '5') {
+            getComeOrder({ warehouseId: this.form.oldWarehouseId, businessId: row.id, subsidiaryId: this.form.subsidiaryId }).then((res) => {
+              this.form.details.push({
+                businessId: row.id,
+                quantity: undefined,
+                genre: 2,
+                productLong: row.productLong,
+                productWide: row.productWide,
+                productHigh: row.productHigh,
+                nameChinese: row.nameChinese,
+                specCode: row.specCode,
+                transferQuantity: Number(res.data.data),
+              })
+              return this.msgSuccess('添加成功')
+            })
           } else {
             this.form.details.push({
               businessId: row.id,
@@ -88,13 +114,13 @@ export default {
               nameChinese: row.nameChinese,
               specCode: row.specCode,
             })
-            this.msgSuccess('添加成功')
+            return this.msgSuccess('添加成功')
           }
         } else {
-          this.msgInfo('添加失败')
+          return this.msgInfo('添加失败')
         }
       } else {
-        this.msgInfo('添加失败')
+        return this.msgInfo('添加失败')
       }
     },
     clickRemove(index) {

+ 30 - 20
src/views/shengde/warehouse/putInStorage/register.vue

@@ -57,6 +57,7 @@ export default {
         details: [],
         warehouseStatus: '',
         purchaseContractId: '',
+        oldWarehouseId: '',
       },
     }
   },
@@ -76,30 +77,39 @@ export default {
         flagMaterial = this.$refs.material.validateForm()
       }
       if (flagStorage && flagProduct && flagMaterial) {
-        if (this.form.details && this.form.details.length > 0) {
-          this.loadingText = '提交数据中,请稍后'
-          this.loadingStatus = true
-          API.registrationSave(this.form).then(
-            () => {
-              Utils.$emit('refreshPutList', true)
-              this.msgSuccess('提交完成')
-              this.$store.dispatch('delView', this.$route)
-              this.$router.replace({
-                path: '/shengde/warehouse/putInStorage/index',
-              })
-            },
-            (err) => {
-              console.log('registrationSave: ' + err)
-              this.loadingStatus = false
-            }
-          )
-        } else {
+        if (this.form.type == '5' && this.form.warehouseId === this.form.oldWarehouseId) {
+          return this.msgInfo('调拨仓库不能相同')
+        }
+        if (!(this.form.details && this.form.details.length > 0)) {
           if (status === 1) {
-            this.msgInfo('请选择产品信息')
+            return this.msgInfo('请选择产品信息')
           } else {
-            this.msgInfo('请选择BOM信息')
+            return this.msgInfo('请选择BOM信息')
+          }
+        }
+        if (this.form.type == '5') {
+          for (let i = 0; i < this.form.details.length; i++) {
+            if (this.form.details[i].transferQuantity < this.form.details[i].quantity) {
+              return this.msgInfo('入库数量不可大于可调拨数量')
+            }
           }
         }
+        this.loadingText = '提交数据中,请稍后'
+        this.loadingStatus = true
+        API.registrationSave(this.form).then(
+          () => {
+            Utils.$emit('refreshPutList', true)
+            this.msgSuccess('提交完成')
+            this.$store.dispatch('delView', this.$route)
+            this.$router.replace({
+              path: '/shengde/warehouse/putInStorage/index',
+            })
+          },
+          (err) => {
+            console.log('registrationSave: ' + err)
+            this.loadingStatus = false
+          }
+        )
       } else {
         setTimeout(() => {
           const errorDiv = document.getElementsByClassName('is-error')

+ 17 - 2
src/views/shengde/warehouse/putInStorage/storage.vue

@@ -14,7 +14,7 @@
           </el-form-item>
           <el-form-item label="事业部:" prop="subsidiaryId">
             <!-- <el-select v-model="form.subsidiaryId" placeholder="请选择事业部" size="small" style="width: 100%" @change="changeSubsidiary"> -->
-            <el-select v-model="form.subsidiaryId" placeholder="请选择事业部" size="small" style="width: 100%">
+            <el-select v-model="form.subsidiaryId" placeholder="请选择事业部" size="small" style="width: 100%" @change="changeSubsidiary">
               <el-option v-for="item in companyList" :key="item.id" :label="item.name" :value="item.id" />
             </el-select>
           </el-form-item>
@@ -25,10 +25,15 @@
             </el-select>
           </el-form-item>
           <el-form-item label="入库类型:" prop="type">
-            <el-select v-model="form.type" placeholder="请选择入库类型" size="small" style="width: 100%">
+            <el-select v-model="form.type" placeholder="请选择入库类型" size="small" style="width: 100%" @change="changeType()">
               <el-option v-for="item in stockType" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
             </el-select>
           </el-form-item>
+          <el-form-item label="原仓库:" prop="oldWarehouseId" v-if="form.type == '5'">
+            <el-select v-model="form.oldWarehouseId" placeholder="请选择原仓库" size="small" style="width: 100%" @change="changePurchase">
+              <el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id" />
+            </el-select>
+          </el-form-item>
           <el-form-item label="申请人:" prop="proposer">
             <el-input v-model="form.proposer" size="small" placeholder="请输入申请人" />
           </el-form-item>
@@ -61,6 +66,7 @@ export default {
       formRules: {
         subsidiaryId: [{ required: true, message: '请选择事业部', trigger: 'change' }],
         warehouseId: [{ required: true, message: '请选择仓库', trigger: 'change' }],
+        oldWarehouseId: [{ required: true, message: '请选择原仓库', trigger: 'change' }],
         type: [{ required: true, message: '请选择入库类型', trigger: 'change' }],
         proposer: [{ required: true, message: '请输入申请人', trigger: 'blur' }],
       },
@@ -125,6 +131,15 @@ export default {
     changePurchase() {
       this.form.details = []
     },
+    changeType() {
+      this.form.oldWarehouseId = ''
+      this.form.details = []
+    },
+    changeSubsidiary() {
+      if (this.form.type == '5') {
+        this.form.details = []
+      }
+    },
   },
 }
 </script>