ysy 1 an în urmă
părinte
comite
5f59b31ee3

+ 165 - 183
src/views/produce/components/jobBooking/components/jobBom.vue

@@ -9,10 +9,7 @@
     <div class="material">
       <div class="content_table">
         <div class="item rx-sc">
-          <div
-            class="rx ww33"
-            v-if="Object.prototype.hasOwnProperty.call(item, 'product')"
-          >
+          <div class="rx ww33" v-if="Object.prototype.hasOwnProperty.call(item, 'product')">
             <div class="lable rx-cc">投料数量</div>
             <div class="content">
               {{ item.product[0] && item.product[0].feedQuantity }}
@@ -26,9 +23,7 @@
 
           <div class="rx ww33">
             <div class="lable rx-cc">重量</div>
-            <div class="content"
-              >{{ item.formingWeight }}{{ item.weightUnit }}</div
-            >
+            <div class="content">{{ item.formingWeight }}{{ item.weightUnit }}</div>
           </div>
         </div>
 
@@ -36,12 +31,7 @@
           <div class="rx ww40">
             <div class="lable lable100 rx-cc">合格品数量</div>
             <div class="content content_num rx-sc">
-              <el-input
-                size="mini"
-                v-model="item.workReportInfo.formedNum"
-                placeholder="请输入合格品数量"
-                @input="blurNum"
-              >
+              <el-input size="mini" v-model="item.workReportInfo.formedNum" placeholder="请输入合格品数量" @input="blurNum">
                 <template slot="append">{{ item.unit }}</template>
               </el-input>
             </div>
@@ -50,31 +40,18 @@
           <div class="rx ww40">
             <div class="lable rx-cc">重量</div>
             <div class="content content_num rx-sc">
-              <el-input
-                size="mini"
-                v-model="item.workReportInfo.formedWeight"
-                placeholder="请输入合格品重量"
-              >
+              <el-input size="mini" v-model="item.workReportInfo.formedWeight" placeholder="请输入合格品重量">
                 <template slot="append">{{ item.weightUnit }}</template>
               </el-input>
             </div>
           </div>
         </div>
 
-        <div
-          class="item rx-sc"
-          v-for="(not, notIndex) in notFormedList"
-          :key="notIndex"
-        >
+        <div class="item rx-sc" v-for="(not, notIndex) in notFormedList" :key="notIndex">
           <div class="rx ww40">
             <div class="lable lable100 rx-cc">不合格数量</div>
             <div class="content content_num rx-sc">
-              <el-input
-                size="mini"
-                v-model="not.notFormedNum"
-                placeholder="请输入不合格数量"
-                @input="changeNum"
-              >
+              <el-input size="mini" v-model="not.notFormedNum" placeholder="请输入不合格数量" @input="changeNum">
                 <template slot="append">{{ item.unit }}</template>
               </el-input>
             </div>
@@ -83,66 +60,31 @@
           <div class="rx ww40">
             <div class="lable rx-cc">重量</div>
             <div class="content content_num rx-sc">
-              <el-input
-                size="mini"
-                v-model="not.notFormedWeight"
-                placeholder="请输入不合格品重量"
-              >
+              <el-input size="mini" v-model="not.notFormedWeight" placeholder="请输入不合格品重量">
                 <template slot="append">{{ item.weightUnit }}</template>
               </el-input>
             </div>
           </div>
 
           <div class="rw ww20 rx-cc">
-            <div
-              class="penalize"
-              v-if="!isDetails"
-              :style="{ background: not.warehouseId ? '#FFA07A' : '' }"
-              @click="penalize"
-            >
-              处置</div
-            >
-            <div
-              class="penalize"
-              v-if="isDetails"
-              :style="{ background: not.warehouseId ? '#FFA07A' : '' }"
-              @click="
-                handleView(isDetails ? not.warehouseName : item.warehouseName)
-              "
-            >
-              查看</div
-            >
+            <div class="penalize" v-if="!isDetails" :style="{ background: not.warehouseId ? '#FFA07A' : '' }"
+              @click="penalize">
+              处置</div>
+            <div class="penalize" v-if="isDetails" :style="{ background: not.warehouseId ? '#FFA07A' : '' }" @click="
+              handleView(isDetails ? not.warehouseName : item.warehouseName)
+              ">
+              查看</div>
           </div>
         </div>
       </div>
     </div>
 
-    <el-dialog
-      title="仓库处置"
-      :visible.sync="visible"
-      :before-close="handleClose"
-      :close-on-click-modal="false"
-      :close-on-press-escape="false"
-      append-to-body
-      width="500px"
-    >
-      <el-form
-        size="mini"
-        :model="form"
-        label-width="96px"
-      
-      >
-        <el-form-item
-          label="仓库"
-          prop="warehouseList"
-        >
+    <el-dialog title="仓库处置" :visible.sync="visible" :before-close="handleClose" :close-on-click-modal="false"
+      :close-on-press-escape="false" append-to-body width="500px">
+      <el-form size="mini" :model="form" label-width="96px">
+        <el-form-item label="仓库" prop="warehouseList">
           <el-select v-model="form.warehouseId" placeholder="请选择仓库">
-            <el-option
-              v-for="item in warehouseList"
-              :label="item.name"
-              :value="item.id"
-              :key="item.id"
-            >
+            <el-option v-for="item in warehouseList" :label="item.name" :value="item.id" :key="item.id">
             </el-option>
           </el-select>
         </el-form-item>
@@ -156,140 +98,180 @@
   </div>
 </template>
 <script>
-  export default {
-    props: {
-      item: {
-        type: Object,
-        default: () => {}
-      },
-      notFormed: {
-        type: Array,
-        default: () => []
-      },
-      isDetails: {
-        type: Boolean,
-        default: false
-      },
-      warehouseList: {
-        type: Array,
-        default: () => []
-      }
+export default {
+  props: {
+    item: {
+      type: Object,
+      default: () => { }
     },
+    notFormed: {
+      type: Array,
+      default: () => []
+    },
+    isDetails: {
+      type: Boolean,
+      default: false
+    },
+    warehouseList: {
+      type: Array,
+      default: () => []
+    }
+  },
 
-    watch: {
-      notFormed: {
-        immediate: true,
-        deep: true,
-        handler(newVal) {
-          this.notFormedList = newVal;
-        }
+  watch: {
+    notFormed: {
+      immediate: true,
+      deep: true,
+      handler(newVal) {
+        this.notFormedList = newVal;
       }
+    }
+  },
+
+  data() {
+    return {
+      notFormedList: [],
+
+      form: {
+        warehouseId: null
+      },
+
+      visible: false
+    };
+  },
+
+  created() {
+    if (this.isDetails) {
+      this.notFormedList = this.notFormedList.map((m) => {
+        return {
+          notFormedNum: Number(m.quantity),
+          notFormedWeight: m.weight,
+          ...m
+        };
+      });
+    }
+  },
+
+  methods: {
+    penalize() {
+      this.visible = true;
     },
 
-    data() {
-      return {
-        notFormedList: [],
+    handleClose() {
+      this.visible = false;
+    },
 
-        form: {
-          warehouseId: null
-        },
+    warehouseSave() {
+      this.$set(this.item.notFormedList[0], 'warehouseId', this.form.warehouseId || null)
 
-        visible: false
-      };
+      this.handleClose()
+      this.$forceUpdate()
     },
 
-    created() {
-      if (this.isDetails) {
-        this.notFormedList = this.notFormedList.map((m) => {
-          return {
-            notFormedNum: Number(m.quantity),
-            notFormedWeight: m.weight,
-            ...m
-          };
-        });
-      }
+    handleView(name) {
+      this.$message.info(name || '未设置');
     },
 
-    methods: {
-      penalize() {
-        this.visible = true;
-      },
+    getDelete(index) {
+      this.list.splice(index, 1);
+    },
 
-      handleClose() {
-        this.visible = false;
-      },
+    blurNum() {
+      let total =
+        Number(this.item.workReportInfo.formedNum) +
+        Number(this.notFormedList[0].notFormedNum);
+      this.$emit('modeNum', total);
 
-      warehouseSave() {
-        this.$set(this.item.notFormedList[0], 'warehouseId', this.form.warehouseId || null)
+      if (
+        this.item.product[0] &&
+        this.item.product[0].feedQuantity > 0 &&
+        Number(this.item.workReportInfo.formedNum)
+      ) {
+        this.$set(
+          this.notFormedList[0],
+          'notFormedNum',
+          this.item.product[0].feedQuantity -
+          Number(this.item.workReportInfo.formedNum)
+        );
+        this.notForme();
+      }
 
-        this.handleClose()
-        this.$forceUpdate()
-      },
+      let weight =
+        Number(this.item.workReportInfo.formedNum) *
+        Number(this.item.singleWeight) *
+        Number(this.item.weightMultiple);
 
-      handleView(name) {
-        this.$message.info(name || '未设置');
-      },
+      if (['G', 'g', '克'].includes(this.item.singleWeightUnit)) {
+        weight = parseFloat((weight / 1000).toFixed(2));
+      } else {
+        weight = parseFloat(weight.toFixed(2));
+      }
 
-      getDelete(index) {
-        this.list.splice(index, 1);
-      },
+      this.$set(this.item.workReportInfo, 'formedWeight', weight);
 
-      blurNum() {
-        let total =
-          Number(this.item.workReportInfo.formedNum) +
-          Number(this.notFormedList[0].notFormedNum);
-        this.$emit('modeNum', total);
+      this.$forceUpdate();
+    },
 
-        if (
-          this.item.product[0] &&
-          this.item.product[0].feedQuantity > 0 &&
-          Number(this.item.workReportInfo.formedNum)
-        ) {
-          this.$set(
-            this.notFormedList[0],
-            'notFormedNum',
-            this.item.product[0].feedQuantity -
-              Number(this.item.workReportInfo.formedNum)
-          );
-          this.notForme();
-        }
 
-        let weight =
-          Number(this.item.workReportInfo.formedNum) *
-          Number(this.item.singleWeight) *
-          Number(this.item.weightMultiple);
+    notForme() {
 
-        if (['G', 'g', '克'].includes(this.item.singleWeightUnit)) {
-          weight = parseFloat((weight / 1000).toFixed(2));
+      let weight = Number(this.notFormedList[0].notFormedNum) * Number(this.item.singleWeight) * Number(this
+        .item.weightMultiple)
+      if (this.item.singleWeightUnit == 'G' || this.item.singleWeightUnit == 'g' || this.item.singleWeightUnit ==
+        '克') {
+        weight = parseFloat((weight / 1000).toFixed(2))
+      } else {
+        weight = parseFloat(weight.toFixed(2))
+      }
+      this.$set(this.notFormedList[0], 'notFormedWeight', weight)
+
+
+      if (  this.item.product[0] && this.item.product[0].feedQuantity > 0 && Number(this.notFormedList[0].notFormedNum)) {
+        this.$set(this.item.workReportInfo, 'formedNum', this.item.product[0].feedQuantity - Number(this
+          .notFormedList[0]
+          .notFormedNum))
+
+
+        let weight = Number(this.item.workReportInfo.formedNum) * Number(this.item.singleWeight) * Number(this
+          .item.weightMultiple)
+        if (this.item.singleWeightUnit == 'G' || this.item.singleWeightUnit == 'g' || this.item
+          .singleWeightUnit == '克') {
+          weight = parseFloat((weight / 1000).toFixed(2))
         } else {
-          weight = parseFloat(weight.toFixed(2));
+          weight = parseFloat(weight.toFixed(2))
         }
+        this.$set(this.item.workReportInfo, 'formedWeight', weight)
+
+      }
 
-        this.$set(this.item.workReportInfo, 'formedWeight', weight);
 
-        this.$forceUpdate();
-      },
 
-      changeNum() {
-        this.notForme();
-        // this.blurNum()
-      }
+      this.$forceUpdate()
+
+    },
+
+
+
+    changeNum() {
+      this.notForme();
+      // this.blurNum()
     }
-  };
+  }
+};
 </script>
 
 <style lang="scss" scoped>
-  .lable {
-    width: 200px;
-  }
+.lable {
+  width: 200px;
+}
 
-  .penalize {
-    width: 80px;
-    line-height: 30px;
-    background: #157a2c;
-    font-size: 12px;
-    text-align: center;
-    color: #fff;
-    cursor: pointer;
-  }
+.penalize {
+  width: 80px;
+  line-height: 30px;
+  background: #157a2c;
+  font-size: 12px;
+  text-align: center;
+  color: #fff;
+  cursor: pointer;
+}
 </style>

+ 52 - 60
src/views/produce/components/jobBooking/index.vue

@@ -10,7 +10,6 @@
       <el-button type="primary" size="mini" @click="save(1, 'all')"
         >缓存</el-button
       >
-
     </div>
 
     <div class="job_box">
@@ -30,7 +29,10 @@
               @click="openPicking(item.workOrderId, item)"
               >添加物料</el-button
             >
-            <el-button type="text" size="mini" @click="removeCacheFn(item.workOrderId)"
+            <el-button
+              type="text"
+              size="mini"
+              @click="removeCacheFn(item.workOrderId)"
               >清空缓存</el-button
             >
             <el-button type="text" size="mini" @click="save(1, index)"
@@ -148,7 +150,12 @@
 <script>
   import { listByIdsReport } from '@/api/produce/job';
   import { getWarehouseList } from '@/api/produce/index';
-  import { jobSave , saveCache ,getCache, removeCache} from '@/api/produce/workOrder'
+  import {
+    jobSave,
+    saveCache,
+    getCache,
+    removeCache
+  } from '@/api/produce/workOrder';
   import pickingList from '../picking/pickingList.vue';
 
   import workOrderBom from '../feeding/components/workOrderBom.vue';
@@ -167,8 +174,6 @@
   import packingBom from './components/packingBom.vue';
   import packingTgBom from './components/packingTgBom';
 
-
-
   export default {
     components: {
       pickingList,
@@ -211,7 +216,7 @@
 
         warehouseList: [],
 
-        loading: null,
+        loading: null
       };
     },
 
@@ -346,7 +351,7 @@
 
       allSelection(id, selectList) {
         this.List.forEach((m) => {
-          if (m.id == id) {
+          if (m.workOrderId == id) {
             let turnover = [];
             let equipmentList = []; // 生产设备
 
@@ -368,7 +373,7 @@
       },
 
       async save(type) {
-         this.loading = this.$loading({
+        this.loading = this.$loading({
           lock: true,
           text: '加载中',
           background: 'rgba(0, 0, 0, 0.7)'
@@ -427,7 +432,6 @@
           });
 
           if (succ) {
-      
             const isRecycle = await this.checkRecycle();
             if (!isRecycle) {
               return false;
@@ -445,7 +449,7 @@
 
         if (this.taskObj.type == 1) {
           const isCache = await this.checkCache(type);
-  
+
           if (!isCache) {
             return false;
           }
@@ -454,17 +458,15 @@
         jobSave(this.List)
           .then((res) => {
             this.loading.close();
-            this.$message.success('报工成功')
-            this.getList(this.idsList);;
-       
+            this.$message.success('报工成功');
+            this.getList(this.idsList);
+          }).catch(() => {
+            this.loading.close();
           })
           .finally(() => {
             setTimeout(function () {
               this.loading.close();
             }, 3000);
-
-  
-
           });
       },
 
@@ -485,57 +487,47 @@
         });
       },
 
-
       checkCache(type) {
-
-				return new Promise((resolve) => {
-					if (type == 1) {
-
-						saveCache(this.List).then(rr => {
-				   this.$message.success('缓存成功')
-           this.loading.close();
-						})
-						resolve(false)
-					} else if (type == 2) {
-						resolve(true)
-					}
-
-				})
-			},
-
+        return new Promise((resolve) => {
+          if (type == 1) {
+            saveCache(this.List).then((rr) => {
+              this.$message.success('缓存成功');
+              this.loading.close();
+            });
+            resolve(false);
+          } else if (type == 2) {
+            resolve(true);
+          }
+        });
+      },
 
       getCacheFn() {
-				let parma = {
-					workOrderId:  this.idsList,
+        let parma = {
+          workOrderIds: this.idsList,
           taskId: this.taskObj.id,
-					type: 1
-				}
-
-				getCache(parma).then(res => {
-				  
-  console.log(res)
-	
-
+          type: 1
+        };
 
-				})
-			},
+        getCache(parma).then((res) => {
+          console.log(res);
+        });
+      },
 
       removeCacheFn(type) {
-    
-      this.$confirm('是否清空缓存', '缓存')
-        .then(() => {
-          let parma = {
-            workOrderIds: type == 'all' ? this.idsList : [type],
-            taskId: this.taskObj.id,
-            type: 1
-          };
-          removeCache(parma).then((res) => {
-            this.$message.success('已经清空缓存')
-            this.getList(this.idsList);
-          });
-        })
-        .catch(() => { });
-    },
+        this.$confirm('是否清空缓存', '缓存')
+          .then(() => {
+            let parma = {
+              workOrderIds: type == 'all' ? this.idsList : [type],
+              taskId: this.taskObj.id,
+              type: 1
+            };
+            removeCache(parma).then((res) => {
+              this.$message.success('已经清空缓存');
+              this.getList(this.idsList);
+            });
+          })
+          .catch(() => {});
+      },
 
       getWarehouseListFn() {
         getWarehouseList().then((res) => {