Browse Source

申购单,采购合同,入库数据限制

lxf 1 year ago
parent
commit
aa073f2c68

+ 8 - 4
src/views/shengde/group/subscription/management/details/detailedList.vue

@@ -22,6 +22,12 @@
             <span v-else>0</span>
           </template>
         </el-table-column>
+        <el-table-column label="已采购数量" width="100">
+          <template slot-scope="scope">
+            <span v-if="scope.row.purchaseCount">{{ Number(scope.row.purchaseCount) }}</span>
+            <span v-else>0</span>
+          </template>
+        </el-table-column>
         <el-table-column label="库存" width="90">
           <template slot-scope="scope">
             <span style="font-weight: 700" v-if="scope.row.inventoryQuantity">{{ Number(scope.row.inventoryQuantity) }}</span>
@@ -70,9 +76,7 @@
                 </el-table>
               </div>
               <span slot="reference" style="cursor: pointer" @click="clickOnTheWay(scope.row)">
-                <span style="color: #ff0000; font-weight: 700" v-if="scope.row.purchaseQuantity">{{ Number(scope.row.purchaseQuantity) }}</span>
-                <span style="color: #ff0000; font-weight: 700" v-else>0</span>
-                <!-- <span style="color: #ff0000; font-weight: 700">{{ getNum(scope.row) }}</span> -->
+                <span style="color: #ff0000; font-weight: 700">{{ getNum(scope.row) }}</span>
               </span>
             </el-popover>
           </template>
@@ -207,7 +211,7 @@ export default {
   computed: mapGetters(['dictData']),
   methods: {
     headerCellStyle({ columnIndex }) {
-      if ([5, 6, 7, 8, 9].includes(columnIndex)) {
+      if ([6, 7, 8, 9, 10].includes(columnIndex)) {
         return 'background-color: #bee4ed; color: white;'
       } else {
         return ''

+ 7 - 1
src/views/shengde/productionSystem/purchase/contract/product.vue

@@ -1,7 +1,7 @@
 <template>
   <div style="padding: 20px 2vw">
     <el-form ref="ruleForm" :model="form" :rules="formRules" label-width="0">
-      <div>
+      <div v-if="!$route.query.subscriberId">
         <el-button type="primary" size="small" @click="clickSelectProduct" v-db-click>选择物料</el-button>
       </div>
       <br />
@@ -62,6 +62,12 @@
             <span>¥{{ moneyFormat(scope.row.taxPrice, 3) }}</span>
           </template>
         </el-table-column>
+        <el-table-column label="可采购数量" width="100">
+          <template slot-scope="scope">
+            <span v-if="scope.row.availablePurchase">{{ Number(scope.row.availablePurchase) }}</span>
+            <span v-else>0</span>
+          </template>
+        </el-table-column>
         <el-table-column label="采购数量" width="120">
           <template slot-scope="scope">
             <el-form-item :prop="'purchaseContractProductList.' + scope.$index + '.quantity'" :rules="formRules.quantity" :inline-message="true">

+ 33 - 1
src/views/shengde/productionSystem/purchase/contract/start.vue

@@ -211,6 +211,28 @@ export default {
       API.purchaseContractDetail(data).then(
         (res) => {
           this.form = res.data.data
+          if (this.form.subscriberId) {
+            subscriberDetail({ id: this.form.subscriberId }).then((resDetail) => {
+              if (this.form.purchaseContractProductList && this.form.purchaseContractProductList.length > 0) {
+                this.form.purchaseContractProductList = this.form.purchaseContractProductList.map((item) => {
+                  let quantity = 0
+                  if (resDetail.data.data.subscriberBomList && resDetail.data.data.subscriberBomList.length > 0) {
+                    let data = resDetail.data.data.subscriberBomList.filter((itemBom) => itemBom.bomColorId === item.bomColorId)
+                    if (data && data.length > 0) {
+                      quantity = data[0].quantity
+                      if (data[0].purchaseCount) {
+                        quantity = Number(parseFloat(Number(quantity) - Number(data[0].purchaseCount)).toFixed(0))
+                      }
+                    }
+                  }
+                  return {
+                    ...item,
+                    availablePurchase: quantity,
+                  }
+                })
+              }
+            })
+          }
           this.attachments = res.data.data.att
           this.loadingStatus = false
         },
@@ -225,13 +247,18 @@ export default {
         this.form.subscriberId = res.data.data.id
         if (res.data.data.subscriberBomList && res.data.data.subscriberBomList.length > 0) {
           this.form.purchaseContractProductList = res.data.data.subscriberBomList.map((item) => {
+            let quantity = item.quantity
+            if (item.purchaseCount) {
+              quantity = Number(parseFloat(Number(quantity) - Number(item.purchaseCount)).toFixed(0))
+            }
             return {
               bomColorId: item.bomColorId,
               bomColorName: item.bomColorName,
               bomColorCode: item.bomColorCode,
               bomColorImg: '',
               bomColorLogo: '',
-              quantity: item.quantity,
+              availablePurchase: quantity,
+              quantity: quantity,
               price: undefined,
               sumPrice: '',
               remark: '',
@@ -270,6 +297,11 @@ export default {
       let flagPayment = this.$refs.Payment.validateForm()
       if (flagSupplier && flagProduct && flagAddress && flagPayment) {
         if (this.form.purchaseContractProductList && this.form.purchaseContractProductList.length > 0) {
+          for (let i = 0; i < this.form.purchaseContractProductList.length; i++) {
+            if (this.form.purchaseContractProductList[i].quantity > this.form.purchaseContractProductList[i].availablePurchase) {
+              return this.msgInfo('采购数量不能大于可采购数量!')
+            }
+          }
           this.loadingText = '提交数据中,请稍后'
           this.loadingStatus = true
           this.form.att = this.conversion(this.form.att)

+ 6 - 0
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="approveQuantity" width="100" />
         <el-table-column label="入库数量" width="180">
           <template slot-scope="scope">
             <el-form-item :prop="'details.' + scope.$index + '.quantity'" :rules="formRules.quantity" :inline-message="true">
@@ -78,8 +79,13 @@ export default {
           if (tableData && tableData.length > 0) {
             this.msgInfo('该物料已添加')
           } else {
+            let quantity = row.purchaseQuantity
+            if (row.stockQuantity) {
+              quantity = Number(parseFloat(Number(quantity) - Number(row.stockQuantity)).toFixed(0))
+            }
             this.form.details.push({
               businessId: row.id,
+              approveQuantity: quantity,
               quantity: undefined,
               genre: 2,
               productLong: row.productLong,

+ 7 - 0
src/views/shengde/warehouse/putInStorage/register.vue

@@ -77,6 +77,13 @@ export default {
       }
       if (flagStorage && flagProduct && flagMaterial) {
         if (this.form.details && this.form.details.length > 0) {
+          if (this.form.purchaseContractId) {
+            for (let i = 0; i < this.form.details.length; i++) {
+              if (this.form.details[i].quantity > this.form.details[i].approveQuantity) {
+                return this.msgInfo('入库数量不能大于可入库数量')
+              }
+            }
+          }
           this.loadingText = '提交数据中,请稍后'
           this.loadingStatus = true
           API.registrationSave(this.form).then(