Преглед на файлове

feat(jobBom): 更新损耗状态判断逻辑,支持减损状态

xieyong преди 2 дни
родител
ревизия
a2f8eb38fe

+ 164 - 3
src/views/produce/components/jobBooking/components/batchSemiProductJobBom.vue

@@ -379,6 +379,14 @@
           >损耗</el-link
         >
 
+        <el-link
+          type="text"
+          style="color: #67c23a"
+          @click="openReduceLoss(row, $index)"
+          v-if="!row.extInfo.isLoss && item.currentTaskDiagram.isFirstTask != 1"
+          >减损</el-link
+        >
+
         <el-link
           type="success"
           @click="getOk($index)"
@@ -398,9 +406,25 @@
               $index
             )
           "
-          v-if="row.extInfo.isLoss"
+          v-if="row.extInfo.isLoss == 1"
           >撤回</el-link
         >
+        <el-link
+          type="text"
+          @click="
+            returnReduceLoss(
+              [
+                {
+                  returnId: row.id,
+                  returnQt: row.feedQuantity
+                }
+              ],
+              $index
+            )
+          "
+          v-else-if="row.extInfo.isLoss == 3"
+          >减损撤回</el-link
+        >
         <el-link type="warning" @click="getCancle($index)" v-else>取消</el-link>
         <el-link type="danger" @click="getDelete($index)" v-if="!isChoose"
           >删除</el-link
@@ -716,6 +740,39 @@
       </span>
     </el-dialog>
 
+    <el-dialog
+      title="减损数"
+      :visible.sync="reduceLossVisible"
+      v-if="reduceLossVisible"
+      width="30%"
+      :before-close="handleClose"
+      append-to-body
+    >
+      <el-form
+        ref="form"
+        :model="reduceLossForm"
+        label-width="120px"
+        label-position="right"
+      >
+        <el-form-item label="批次号">
+          <el-input v-model="reduceLossForm.batchNo" style="width: 220px"></el-input>
+        </el-form-item>
+        <el-form-item label="减损数">
+          <el-input
+            v-model="reduceLossForm.quantity"
+            style="width: 220px"
+            @input="reduceLossInput"
+          >
+            <template slot="append"> {{ reduceLossForm.unit }}</template>
+          </el-input>
+        </el-form-item>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="reduceLossVisible = false">取 消</el-button>
+        <el-button type="primary" @click="getReduceLossParam">确 定</el-button>
+      </span>
+    </el-dialog>
+
     <juRenPackOne ref="juRenPackOneRef" />
     <juRenPack ref="juRenPackRef" />
     <!-- <te-rui-print-one ref="teRuiPrintOneRef" />
@@ -783,7 +840,7 @@
   import { queryProductLicense } from '@/api/produce';
   import tabMixins from '@/mixins/tableColumnsMixin';
   import { parameterGetByCode } from '@/api/system/dictionary-data';
-  import { splitBatch } from '@/api/produce/feeding';
+  import { splitBatch, reduceLossBatch, returnReduceLossBatch } from '@/api/produce/feeding';
   import { juRenPrint, isJuRen } from '@/api/produce';
   import juRenPackOne from '../../juRenPackOne.vue';
   import juRenPack from '../../juRenPack.vue';
@@ -1212,6 +1269,7 @@
             align: 'center',
             showOverflowTooltip: true,
             formatter: (row) => {
+              if (row.extInfo.isLoss == 3) return '已损耗';
               return row.extInfo.isLoss && row.extInfo.isLoss == 1
                 ? '是'
                 : '否';
@@ -1400,6 +1458,15 @@
         lossVisible: false,
         lossData: {},
         lossIndex: '',
+        reduceLossForm: {
+          batchNo: '',
+          quantity: '',
+          unit: '',
+          isLoss: 3
+        },
+        reduceLossVisible: false,
+        reduceLossData: {},
+        reduceLossIndex: '',
         teRuiData: {},
         barcodeVisible: false,
         barcodeForm: {
@@ -1538,7 +1605,7 @@
       sunTj() {
         if (this.item.workReportInfo && this.item.singleReport == 1) {
           const formedNumList = this.newList.filter(
-            (v) => v.extInfo.isQualified == 1
+            (v) => v.extInfo.isQualified == 1 && v.extInfo.isLoss != 3
           );
 
           const notFormedNumList = this.newList.filter(
@@ -1683,6 +1750,7 @@
         this.dialogEngrave = false;
         this.batchVisible = false;
         this.lossVisible = false;
+        this.reduceLossVisible = false;
         this.barcodeVisible = false;
       },
 
@@ -1753,6 +1821,11 @@
           this.$emit('reloadData');
         });
       },
+      returnReduceLoss(returnBatchDetailPOList, index) {
+        returnReduceLossBatch({returnBatchDetailPOList}).then((res) => {
+          this.$emit('reloadData');
+        });
+      },
       batchInput(val) {
         let newVal = val.replace(/[^\d.]/g, '');
 
@@ -1968,6 +2041,94 @@
         this.$set(this.item, 'product', _arr);
       },
 
+      openReduceLoss(item, index) {
+        this.reduceLossForm.quantity = '';
+        this.reduceLossForm.unit = '';
+        this.reduceLossForm.batchNo = '';
+        this.reduceLossData = item;
+        this.reduceLossIndex = index;
+        this.reduceLossForm.batchNo = item.batchNo;
+        this.reduceLossForm.unit = item.unit;
+        this.reduceLossVisible = true;
+      },
+
+      reduceLossInput(val) {
+        let newVal = val.replace(/[^\d.]/g, '');
+
+        if (newVal.startsWith('.')) {
+          newVal = '';
+        }
+
+        const firstDotIndex = newVal.indexOf('.');
+        if (firstDotIndex !== -1) {
+          newVal =
+            newVal.slice(0, firstDotIndex + 1) +
+            newVal.slice(firstDotIndex + 1).replace(/\./g, '');
+        }
+
+        const match = newVal.match(/^(\d+)(\.\d{0,4})?/);
+        this.reduceLossForm.quantity = match ? match[0] : '';
+      },
+
+      async getReduceLossParam() {
+        if (this.reduceLossForm.quantity) {
+          if (Number(this.reduceLossData.feedQuantity) == 0) {
+            this.$message.warning('减损数不能为0');
+            return;
+          }
+
+          if (
+            Number(this.reduceLossData.feedQuantity) <
+            Number(this.reduceLossForm.quantity)
+          ) {
+            this.$message.warning('减损数不能大于数量');
+            return;
+          }
+
+          let dataList = [];
+          await reduceLossBatch({
+            batchNo: this.reduceLossForm.batchNo,
+            isLoss: 3,
+            isQualified: 0,
+            notReason: '',
+            notType: 0,
+            product: this.reduceLossData,
+            splitQt: Number(this.reduceLossForm.quantity)
+          }).then((res) => {
+            res.forEach((item) => {
+              dataList.push(this.deepCopy(item));
+            });
+
+            if (dataList.length != 0) {
+              this.refreshReduceLossData(dataList);
+            }
+          });
+        }
+        this.reduceLossVisible = false;
+      },
+
+      refreshReduceLossData(list) {
+        const number = this.sub(
+          Number(this.list[this.reduceLossIndex].feedQuantity),
+          Number(this.reduceLossForm.quantity)
+        );
+        this.list[this.reduceLossIndex].extInfo.sourceQuantity = number;
+        this.list[this.reduceLossIndex].feedQuantity = number;
+        this.list[this.reduceLossIndex].extInfo.newWeight =
+          (Number(this.list[this.reduceLossIndex].extInfo.newWeight) * 100000) /
+            100000 -
+          (Number(list[0].extInfo.newWeight) * 100000) / 100000;
+
+        list.forEach((item) => {
+          item.childBatch = 1;
+        });
+
+        const newList = this.list.filter((item) => item.feedQuantity != 0);
+        let _arr = [...newList, ...list];
+
+        this.$set(this.item, 'product', _arr);
+      },
+
       // changeHeatNumber() {
       //   if (this.deviceList.length > 0) {
       //     const device = this.deviceList[0];

+ 2 - 1
src/views/produce/components/jobBooking/components/jobBom.vue

@@ -265,7 +265,8 @@
               ? product.filter((it) => it.confirm == 1)
               : product;
 
-            const isLoss = (item) => item.extInfo.isLoss == 1;
+            const isLoss = (item) =>
+              item.extInfo.isLoss == 1 || item.extInfo.isLoss == 3;
 
             const isFormed = (item) => {
               const { isQualified, notType } = item.extInfo;