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

新增损耗功能和工单列表查看终止

695593266@qq.com 9 месяцев назад
Родитель
Сommit
727642872f

+ 175 - 15
src/views/produce/components/jobBooking/components/batchSemiProductJobBom.vue

@@ -330,10 +330,24 @@
           v-if="
             row.feedQuantity > 1 &&
             item.currentTaskDiagram.isFirstTask != 1 &&
-            row.isAllPackageData != 1
+            row.isAllPackageData != 1 &&
+            !row.extInfo.isLoss
           "
           >拆批</el-link
         >
+
+        <el-link
+          type="text"
+          style="color: orange"
+          @click="openLoss(row, $index)"
+          v-if="
+            ![2, 3, 6].includes(Number(item.currentTaskDiagram.type)) &&
+            !row.extInfo.isLoss &&
+            item.currentTaskDiagram.isFirstTask != 1
+          "
+          >损耗</el-link
+        >
+
         <el-link
           type="success"
           @click="getOk($index)"
@@ -615,6 +629,34 @@
         <el-button type="primary" @click="getQualityParam">确 定</el-button>
       </span>
     </el-dialog>
+
+    <el-dialog
+      title="损耗数"
+      :visible.sync="lossVisible"
+      v-if="lossVisible"
+      width="30%"
+      :before-close="handleClose"
+      append-to-body
+    >
+      <el-form
+        ref="form"
+        :model="lossForm"
+        label-width="120px"
+        label-position="right"
+      >
+        <el-form-item label="批次号">
+          <el-input v-model="lossForm.batchNo" style="width: 220px"></el-input>
+        </el-form-item>
+        <el-form-item label="损耗数">
+          <el-input v-model="lossForm.quantity" style="width: 220px"></el-input>
+          {{ lossForm.unit }}
+        </el-form-item>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="lossVisible = false">取 消</el-button>
+        <el-button type="primary" @click="getLossParam">确 定</el-button>
+      </span>
+    </el-dialog>
   </div>
 </template>
 
@@ -1000,6 +1042,18 @@
             align: 'center',
             showOverflowTooltip: true
           },
+          {
+            minWidth: 100,
+            prop: 'extInfo.isLoss',
+            label: '是否损耗',
+            align: 'center',
+            showOverflowTooltip: true,
+            formatter: (row) => {
+              return row.extInfo.isLoss && row.extInfo.isLoss == 1
+                ? '是'
+                : '否';
+            }
+          },
           {
             columnKey: 'action',
             label: '操作',
@@ -1130,24 +1184,63 @@
           isQualified: 1,
           notType: '',
           notReason: '',
-          unit: ''
+          unit: '',
+          isLoss: 0
         },
         itemData: {},
         itemIndex: '',
         printData: {},
-        printStyle: ''
+        printStyle: '',
+        lossForm: {
+          batchNo: '',
+          quantity: '',
+          unit: '',
+          isLoss: 1
+        },
+        lossVisible: false,
+        lossData: {},
+        lossIndex: ''
       };
     },
 
     methods: {
       sunTj() {
         if (this.item.workReportInfo && this.item.singleReport == 1) {
-          this.item.workReportInfo.formedNum = this.newList.filter(
+          const formedNumList = this.newList.filter(
             (v) => v.extInfo.isQualified == 1
-          ).length;
-          this.item.workReportInfo.notFormedNum = this.newList.filter(
+          );
+
+          const notFormedNumList = this.newList.filter(
             (v) => v.extInfo.isQualified !== 1
-          ).length;
+          );
+
+          if (formedNumList.length != 0) {
+            this.item.workReportInfo.formedNum = formedNumList.reduce(
+              (acc, pro) => {
+                return pro.feedQuantity ? acc + Number(pro.feedQuantity) : acc;
+              },
+              0
+            );
+          } else {
+            this.item.workReportInfo.formedNum = 0;
+          }
+
+          if (notFormedNumList.length != 0) {
+            this.item.workReportInfo.notFormedNum = notFormedNumList.reduce(
+              (acc, pro) => {
+                return pro.feedQuantity ? acc + Number(pro.feedQuantity) : acc;
+              },
+              0
+            );
+          } else {
+            this.item.workReportInfo.notFormedNum = 0;
+          }
+          // this.item.workReportInfo.formedNum = this.newList.filter(
+          //   (v) => v.extInfo.isQualified == 1
+          // ).length;
+          // this.item.workReportInfo.notFormedNum = this.newList.filter(
+          //   (v) => v.extInfo.isQualified !== 1
+          // ).length;
         }
       },
       sumweight(arr) {
@@ -1248,6 +1341,7 @@
         this.dialogVisible = false;
         this.dialogEngrave = false;
         this.batchVisible = false;
+        this.lossVisible = false;
       },
 
       batchEngrave() {
@@ -1298,7 +1392,6 @@
       },
 
       openBatch(item, index) {
-        console.log(item, '需要拆批的数据');
         this.batchForm.quantity = '';
         this.batchForm.unit = '';
         this.batchForm.batchNo = '';
@@ -1320,7 +1413,7 @@
           }
 
           if (this.itemData.feedQuantity <= this.batchForm.quantity) {
-            this.$message.warning('拆批数不能大于数量');
+            this.$message.warning('拆批数不能大于或者等于数量');
             return;
           }
 
@@ -1336,13 +1429,16 @@
             batchNo: this.batchForm.batchNo,
             isQualified: this.batchForm.isQualified,
             notType: this.batchForm.notType,
-            notReason: this.batchForm.notReason
+            notReason: this.batchForm.notReason,
+            isLoss: 0
           }).then((res) => {
             res.forEach((item) => {
               dataList.push(this.deepCopy(item));
             });
 
-            this.refreshData(dataList);
+            if (dataList.length != 0) {
+              this.refreshData(dataList);
+            }
           });
         }
         this.batchVisible = false;
@@ -1364,10 +1460,6 @@
         });
         let _arr = [...this.list, ...list];
 
-        console.log(this.list, '拆批的数据');
-
-        // this.list = _arr;
-
         this.$set(this.item, 'product', _arr);
       },
 
@@ -1387,6 +1479,74 @@
         }, result);
       },
 
+      openLoss(item, index) {
+        this.lossForm.quantity = '';
+        this.lossForm.unit = '';
+        this.lossForm.batchNo = '';
+        this.lossData = item;
+        this.lossIndex = index;
+        this.lossForm.batchNo = item.batchNo;
+        this.lossForm.unit = item.unit;
+        this.lossVisible = true;
+      },
+
+      async getLossParam() {
+        if (this.lossForm.quantity && this.lossForm.batchNo) {
+          if (
+            Number(this.lossData.feedQuantity) < Number(this.lossForm.quantity)
+          ) {
+            this.$message.warning('损耗数不能大于数量');
+            return;
+          }
+
+          let dataList = [];
+          await splitBatch({
+            product: this.lossData,
+            splitQt: Number(this.lossForm.quantity),
+            batchNo: this.lossForm.batchNo,
+            isLoss: 1
+          }).then((res) => {
+            res.forEach((item) => {
+              dataList.push(this.deepCopy(item));
+            });
+
+            if (dataList.length != 0) {
+              this.refreshLossData(dataList);
+            }
+          });
+        }
+        this.lossVisible = false;
+      },
+
+      refreshLossData(list) {
+        const number =
+          Number(this.list[this.lossIndex].feedQuantity) -
+          Number(this.lossForm.quantity);
+        this.list[this.lossIndex].extInfo.sourceQuantity = number;
+        this.list[this.lossIndex].feedQuantity = number;
+        this.list[this.lossIndex].extInfo.newWeight =
+          (Number(this.list[this.lossIndex].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);
+        console.log(newList, 'newList新数据');
+
+        // this.$set(
+        //   this.item,
+        //   'product',
+        //   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];

+ 42 - 7
src/views/produce/components/jobBooking/components/jobBom.vue

@@ -260,16 +260,29 @@
 
             newVal.product.forEach((item) => {
               if (
-                !item.extInfo.isQualified ||
-                item.extInfo.isQualified == 1 ||
-                item.extInfo.isQualified == 3
+                (!item.extInfo.isQualified ||
+                  item.extInfo.isQualified == 1 ||
+                  item.extInfo.isQualified == 3) &&
+                !item.extInfo.isLoss
               ) {
-                formedNum = formedNum + Number(item.feedQuantity);
+                // formedNum = formedNum + Number(item.feedQuantity);
+                formedNum = this.add(formedNum, Number(item.feedQuantity));
               } else {
-                if (item.extInfo.notType == 5 || item.extInfo.notType == 8) {
-                  formedNum = formedNum + Number(item.feedQuantity);
+                if (
+                  (item.extInfo.notType == 5 || item.extInfo.notType == 8) &&
+                  !item.extInfo.isLoss
+                ) {
+                  // formedNum = formedNum + Number(item.feedQuantity);
+
+                  formedNum = this.add(formedNum, Number(item.feedQuantity));
                 } else {
-                  notFormedNum = notFormedNum + Number(item.feedQuantity);
+                  // notFormedNum = notFormedNum + Number(item.feedQuantity);
+                  if (!item.extInfo.isLoss) {
+                    notFormedNum = this.add(
+                      notFormedNum,
+                      Number(item.feedQuantity)
+                    );
+                  }
                 }
               }
             });
@@ -355,6 +368,28 @@
         this.visible = false;
       },
 
+      toInteger(num) {
+        const len = this.getDecimalLength(num);
+        return {
+          int: Math.round(num * Math.pow(10, len)),
+          factor: Math.pow(10, len)
+        };
+      },
+
+      add(a, b) {
+        const { int: aInt, factor: aFactor } = this.toInteger(a);
+        const { int: bInt, factor: bFactor } = this.toInteger(b);
+        const maxFactor = Math.max(aFactor, bFactor);
+        return (
+          (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
+          maxFactor
+        );
+      },
+
+      getDecimalLength(num) {
+        return (num.toString().split('.')[1] || '').length;
+      },
+
       warehouseSave() {
         this.$set(
           this.item.notFormedList[0],

+ 31 - 3
src/views/produce/components/jobBooking/components/jobDdBom.vue

@@ -193,12 +193,18 @@
                 item.extInfo.isQualified == 1 ||
                 item.extInfo.isQualified == 3
               ) {
-                formedNum = formedNum + Number(item.feedQuantity);
+                // formedNum = formedNum + Number(item.feedQuantity);
+                formedNum = this.add(formedNum, Number(item.feedQuantity));
               } else {
                 if (item.extInfo.notType == 5 || item.extInfo.notType == 8) {
-                  formedNum = formedNum + Number(item.feedQuantity);
+                  // formedNum = formedNum + Number(item.feedQuantity);
+                  formedNum = this.add(formedNum, Number(item.feedQuantity));
                 } else {
-                  notFormedNum = notFormedNum + Number(item.feedQuantity);
+                  // notFormedNum = notFormedNum + Number(item.feedQuantity);
+                  notFormedNum = this.add(
+                    notFormedNum,
+                    Number(item.feedQuantity)
+                  );
                 }
                 // notFormedNum = notFormedNum + Number(item.feedQuantity);
               }
@@ -297,6 +303,28 @@
         }
       },
 
+      toInteger(num) {
+        const len = this.getDecimalLength(num);
+        return {
+          int: Math.round(num * Math.pow(10, len)),
+          factor: Math.pow(10, len)
+        };
+      },
+
+      add(a, b) {
+        const { int: aInt, factor: aFactor } = this.toInteger(a);
+        const { int: bInt, factor: bFactor } = this.toInteger(b);
+        const maxFactor = Math.max(aFactor, bFactor);
+        return (
+          (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
+          maxFactor
+        );
+      },
+
+      getDecimalLength(num) {
+        return (num.toString().split('.')[1] || '').length;
+      },
+
       tableDataFn(tableData) {
         console.log(tableData);
         let adultCount = 0;

+ 34 - 5
src/views/produce/components/jobBooking/components/newSemiProductJobBom.vue

@@ -918,14 +918,43 @@
 
     methods: {
       sunTj() {
-        console.log(this.newList, 'workReportInfo.formedNum');
+        console.log(this.newList, 'workReportInfo.formedNum2222');
         if (this.item.workReportInfo && this.item.singleReport == 1) {
-          this.item.workReportInfo.formedNum = this.newList.filter(
+          const formedNumList = this.newList.filter(
             (v) => v.extInfo.isQualified == 1
-          ).length;
-          this.item.workReportInfo.notFormedNum = this.newList.filter(
+          );
+
+          const notFormedNumList = this.newList.filter(
             (v) => v.extInfo.isQualified !== 1
-          ).length;
+          );
+
+          if (formedNumList.length != 0) {
+            this.item.workReportInfo.formedNum = formedNumList.reduce(
+              (acc, pro) => {
+                return pro.feedQuantity ? acc + Number(pro.feedQuantity) : acc;
+              },
+              0
+            );
+          } else {
+            this.item.workReportInfo.formedNum = 0;
+          }
+
+          if (notFormedNumList.length != 0) {
+            this.item.workReportInfo.notFormedNum = notFormedNumList.reduce(
+              (acc, pro) => {
+                return pro.feedQuantity ? acc + Number(pro.feedQuantity) : acc;
+              },
+              0
+            );
+          } else {
+            this.item.workReportInfo.notFormedNum = 0;
+          }
+          // this.item.workReportInfo.formedNum = this.newList.filter(
+          //   (v) => v.extInfo.isQualified == 1
+          // ).length;
+          // this.item.workReportInfo.notFormedNum = this.newList.filter(
+          //   (v) => v.extInfo.isQualified !== 1
+          // ).length;
         }
       },
       sumweight(arr) {

+ 37 - 5
src/views/produce/components/jobBooking/components/semiProductJobBom.vue

@@ -966,15 +966,47 @@
 
     methods: {
       sunTj() {
-        console.log(this.newList, 'workReportInfo.formedNum');
+        console.log(this.newList, 'workReportInfo.formedNum111');
         if (this.item.workReportInfo && this.item.singleReport == 1) {
-          this.item.workReportInfo.formedNum = this.newList.filter(
+          const formedNumList = this.newList.filter(
             (v) => v.extInfo.isQualified == 1
-          ).length;
-          this.item.workReportInfo.notFormedNum = this.newList.filter(
+          );
+
+          const notFormedNumList = this.newList.filter(
             (v) => v.extInfo.isQualified !== 1
-          ).length;
+          );
+
+          if (formedNumList.length != 0) {
+            this.item.workReportInfo.formedNum = formedNumList.reduce(
+              (acc, pro) => {
+                return pro.feedQuantity ? acc + Number(pro.feedQuantity) : acc;
+              },
+              0
+            );
+          } else {
+            this.item.workReportInfo.formedNum = 0;
+          }
+
+          if (notFormedNumList.length != 0) {
+            this.item.workReportInfo.notFormedNum = notFormedNumList.reduce(
+              (acc, pro) => {
+                return pro.feedQuantity ? acc + Number(pro.feedQuantity) : acc;
+              },
+              0
+            );
+          } else {
+            this.item.workReportInfo.notFormedNum = 0;
+          }
+          // this.item.workReportInfo.formedNum = this.newList.filter(
+          //   (v) => v.extInfo.isQualified == 1
+          // ).length;
+          // this.item.workReportInfo.notFormedNum = this.newList.filter(
+          //   (v) => v.extInfo.isQualified !== 1
+          // ).length;
         }
+
+        // console.log(this.item.workReportInfo.formedNum);
+        // console.log(this.item.workReportInfo.notFormedNum);
       },
       sumweight(arr) {
         console.log(arr, 6666667777);

+ 12 - 2
src/views/produce/components/outsourcing/index.vue

@@ -472,9 +472,19 @@
       this.getContactList();
       this.getFactoryList();
       // if (this.activeName == '1') {
-      //   this.attributeData.name = this.outsourceFormVal.name + '委托';
+      //   // this.attributeData.name = this.outsourceFormVal.name + '委托';
+      //   this.$set(
+      //     this.outsourceFormVal,
+      //     'name',
+      //     this.outsourceFormVal.name + '委托'
+      //   );
       // } else if (this.activeName == '2') {
-      //   this.attributeData.name = this.outsourceFormVal.name + '请托';
+      //   // this.attributeData.name = this.outsourceFormVal.name + '请托';
+      //   this.$set(
+      //     this.outsourceFormVal,
+      //     'name',
+      //     this.outsourceFormVal.name + '请托'
+      //   );
       // }
     },
 

+ 2 - 0
src/views/produceOrder/index.vue

@@ -16,6 +16,7 @@
         <el-tab-pane label="待生产" name="4"></el-tab-pane>
         <el-tab-pane label="已完成" name="6"></el-tab-pane>
         <el-tab-pane label="已延期" name="7"></el-tab-pane>
+        <el-tab-pane label="已终止" name="10"></el-tab-pane>
       </el-tabs>
       <!-- 数据表格 -->
       <!--   :cache-key="cacheKeyUrl" -->
@@ -831,6 +832,7 @@
         let res = await getPage({
           ...where,
           ...order,
+          queryTermination: this.tabValue == '10' ? 1 : 0,
           pageNum: page,
           size: limit,
           ...this.sort

+ 2 - 2
vue.config.js

@@ -33,9 +33,9 @@ module.exports = {
       '/api': {
         // target: 'http://124.71.68.31:50001',
         // target: 'http://192.168.1.116:18086',
-        target: 'http://192.168.1.251:18086',
+        // target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.103:18086',192.168.1.116
-        // target: 'http://192.168.1.125:18086',
+        target: 'http://192.168.1.125:18086',
         // target: 'http://192.168.1.116:18086',
         // target: 'http://192.168.1.144:18086',
         // target: 'http://192.168.1.30:18086',