Просмотр исходного кода

feat(addInvoice): 添加总数量和可发数量列,更新剩余可发数量逻辑

xieyong 1 неделя назад
Родитель
Сommit
4245b16c55

+ 55 - 3
src/views/entrust/components/addInvoice.vue

@@ -20,8 +20,22 @@
       :row-click-checked-intelligent="false"
       @update:selection="handleSelectionChange"
     >
+      <template v-slot:totalQuantity="{ row }">
+        <span>{{ row.totalQuantity || row.quantity }}{{ row.measuringUnit }}</span>
+      </template>
+
       <template v-slot:quantity="{ row }">
-        <span>{{ row.quantity }}{{ row.measuringUnit }}</span>
+        <span>{{ row.quantity ?? 0 }}{{ row.measuringUnit  }}</span>
+      </template>
+
+      <template v-slot:remainingDeliverableQuantity="{ row }">
+        <el-input
+          placeholder=""
+          v-model="row.remainingDeliverableQuantity"
+          @blur="validateDeliverableQuantity(row)"
+        >
+          <template slot="append">{{ row.measuringUnit }}</template>
+        </el-input>
       </template>
 
       <template v-slot:weight="{ row }">
@@ -92,14 +106,30 @@
             showOverflowTooltip: true
           },
 
+          {
+            prop: 'totalQuantity',
+            slot: 'totalQuantity',
+            label: '总数量',
+            align: 'center',
+            minWidth: 110,
+            showOverflowTooltip: true
+          },
           {
             prop: 'quantity',
             slot: 'quantity',
-            label: '数量',
+            label: '已发数量',
             align: 'center',
             minWidth: 110,
             showOverflowTooltip: true
           },
+          {
+            prop: 'remainingDeliverableQuantity',
+            slot: 'remainingDeliverableQuantity',
+            label: '可发数量',
+            align: 'center',
+            minWidth: 150,
+            showOverflowTooltip: true
+          },
 
           {
             prop: 'workOrderCode',
@@ -168,7 +198,12 @@
         await pleaseEntrustAllGoodsDetail({
           id
         }).then((res) => {
-          this.workinProgress = res.data;
+          this.workinProgress = (res.data || []).map((item) => {
+            const remainingDeliverableQuantity =
+              (Number(item.totalQuantity) || 0) - (Number(item.quantity) || 0);
+              item.remainingDeliverableQuantity = remainingDeliverableQuantity < 0 ? 0 : remainingDeliverableQuantity;
+            return item;
+          });
         });
       },
 
@@ -181,12 +216,29 @@
           return this.$message.warning('请至少选择一条在制品数据');
         }
 
+        this.allSelection = this.allSelection.filter((item) => {
+          return item.remainingDeliverableQuantity > 0;
+        });
         this.$emit('chooseData', this.allSelection);
         this.visible = false;
       },
 
       cancel() {
         this.visible = false;
+      },
+
+      validateDeliverableQuantity(row) {
+        const remainingDeliverableQuantity = row.remainingDeliverableQuantity;
+        const quantity = row.totalQuantity - row.quantity;
+        if (
+          remainingDeliverableQuantity !== null &&
+          remainingDeliverableQuantity !== undefined &&
+          remainingDeliverableQuantity !== '' &&
+          Number(remainingDeliverableQuantity) > Number(quantity)
+        ) {
+          this.$message.warning('可发数量不能大于剩余数量');
+          row.remainingDeliverableQuantity = quantity;
+        }
       }
     }
   };

+ 6 - 6
src/views/entrust/components/goodsDetail.vue

@@ -30,7 +30,7 @@
       height="40vh"
     >
       <template v-slot:quantity="{ row }">
-        <span>{{ row.quantity }}{{ row.measuringUnit }}</span>
+        <span>{{ row.quantity === 0 ? row.totalQuantity : row.quantity }}{{ row.measuringUnit }}</span>
       </template>
 
       <template v-slot:weight="{ row }">
@@ -290,11 +290,11 @@
       },
 
       chooseData(dataList) {
-        this.goodsList = [];
-
-        dataList.forEach((item) => {
-          this.goodsList.push(this.deepCopy(item));
-        });
+        if (dataList.length === 0) return;
+        this.goodsList = dataList.map((item) => {
+          item.quantity = item.remainingDeliverableQuantity;
+          return this.deepCopy(item);
+        }).filter(item => item.quantity > 0);
       },
 
       rejectReason() {},

+ 1 - 1
src/views/produce/components/outsourcing/details.vue

@@ -293,7 +293,7 @@
           :underline="false"
           @click="sendGoods(row, 'detail')"
           v-if="
-            row.approvalStatus == 2 && row.sendStatus != 0 && row.sendStatus
+            row.approvalStatus == 2 && row.sendOutQuantity > 0
           "
         >
           发货详情