695593266@qq.com 2 месяцев назад
Родитель
Сommit
8b078f2b5a
3 измененных файлов с 223 добавлено и 117 удалено
  1. 9 0
      src/api/produce/index.js
  2. 70 6
      src/views/produce/components/warehousing/index.vue
  3. 144 111
      src/views/produce/index.vue

+ 9 - 0
src/api/produce/index.js

@@ -228,3 +228,12 @@ export async function getProcessMonitoring(data) {
   }
   }
   return Promise.reject(new Error(res.data.message));
   return Promise.reject(new Error(res.data.message));
 }
 }
+
+//根据物品id查询仓库信息
+export async function getWarehouseInfoById(id) {
+  const res = await request.get(`/main/category/getDefaultWarehouseId/${id}`);
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 70 - 6
src/views/produce/components/warehousing/index.vue

@@ -382,6 +382,7 @@
   import jobDdBom from './components/newJobDdBom.vue';
   import jobDdBom from './components/newJobDdBom.vue';
   import { parameterGetByCode } from '@/api/system/dictionary-data';
   import { parameterGetByCode } from '@/api/system/dictionary-data';
   import { getTeam } from '@/api/produce/job.js';
   import { getTeam } from '@/api/produce/job.js';
+  import { getWarehouseInfoById } from '@/api/produce/index.js';
 
 
   export default {
   export default {
     components: {
     components: {
@@ -495,8 +496,74 @@
     },
     },
 
 
     methods: {
     methods: {
+      getCategoryIdFromWarehouseItem(item) {
+        if (!item) {
+          return null;
+        }
+
+        return (
+          item.categoryId ||
+          (item.product &&
+          item.product.length &&
+          item.product[0] &&
+          item.product[0].categoryId
+            ? item.product[0].categoryId
+            : null) ||
+          (item.semiProductList &&
+          item.semiProductList.length &&
+          item.semiProductList[0] &&
+          item.semiProductList[0].categoryId
+            ? item.semiProductList[0].categoryId
+            : null)
+        );
+      },
+
+      async setDefaultWarehouseId(list = []) {
+        const currentItem = list.find((item) => {
+          return this.getCategoryIdFromWarehouseItem(item);
+        });
+        const categoryId = this.getCategoryIdFromWarehouseItem(currentItem);
+
+        if (!categoryId) {
+          this.warehouseId = null;
+          return;
+        }
+
+        try {
+          const res = await getWarehouseInfoById(categoryId);
+          const warehouseInfo =
+            res && Object.prototype.hasOwnProperty.call(res, 'data')
+              ? res.data
+              : res;
+
+          if (Array.isArray(warehouseInfo)) {
+            const firstWarehouse = warehouseInfo[0] || {};
+            this.warehouseId =
+              firstWarehouse.id ||
+              firstWarehouse.warehouseId ||
+              firstWarehouse.defaultWarehouseId ||
+              null;
+            return;
+          }
+
+          if (warehouseInfo && typeof warehouseInfo === 'object') {
+            this.warehouseId =
+              warehouseInfo.id ||
+              warehouseInfo.warehouseId ||
+              warehouseInfo.defaultWarehouseId ||
+              null;
+            return;
+          }
+
+          this.warehouseId = warehouseInfo || null;
+        } catch (e) {
+          this.warehouseId = null;
+        }
+      },
+
       getList(ids) {
       getList(ids) {
         this.idsList = ids || [];
         this.idsList = ids || [];
+        this.warehouseId = null;
         let param = {
         let param = {
           ids: ids,
           ids: ids,
           taskId: this.taskObj.id,
           taskId: this.taskObj.id,
@@ -507,7 +574,7 @@
         console.log(param, 'idsidsidsids');
         console.log(param, 'idsidsidsids');
 
 
         listByIdsReport(param)
         listByIdsReport(param)
-          .then((res) => {
+          .then(async (res) => {
             if (res[0].workOrderType == 1) {
             if (res[0].workOrderType == 1) {
               this.inWarehouseType = 1;
               this.inWarehouseType = 1;
             } else if (res[0].workOrderType == 2) {
             } else if (res[0].workOrderType == 2) {
@@ -580,6 +647,7 @@
                 ...obj
                 ...obj
               };
               };
             });
             });
+            await this.setDefaultWarehouseId(res);
             if (
             if (
               this.isReportTime &&
               this.isReportTime &&
               this.idsList.length == 1 &&
               this.idsList.length == 1 &&
@@ -831,11 +899,7 @@
           }
           }
         }
         }
 
 
-        if (
-          maxFeedMs != null &&
-          startDate &&
-          startDate.getTime() < maxFeedMs
-        ) {
+        if (maxFeedMs != null && startDate && startDate.getTime() < maxFeedMs) {
           adjustedStart = this.formatDateTimeString(new Date(maxFeedMs));
           adjustedStart = this.formatDateTimeString(new Date(maxFeedMs));
           this.$message?.warning?.(
           this.$message?.warning?.(
             '批量开始时间不能小于最后投料时间,已调整为最晚投料时间'
             '批量开始时间不能小于最后投料时间,已调整为最晚投料时间'

+ 144 - 111
src/views/produce/index.vue

@@ -162,111 +162,111 @@
                 :work-order-info="previewWorkOrderInfo"
                 :work-order-info="previewWorkOrderInfo"
               />
               />
               <template v-else>
               <template v-else>
-              <!-- 领料 -->
-              <div v-if="operationType == 'pick' && activeName == '0'">
-                <pickDetails
-                  ref="pickListRef"
-                  :workTaskId="workTaskId"
-                  :taskId="taskObj.id"
-                  @pickAdd="pickAdd"
-                ></pickDetails>
-              </div>
-
-              <div v-if="operationType == 'feed' && activeName == '0'">
-                <!-- 投料 -->
-                <feeding
-                  :workListIds="workListIds"
-                  :feedNeedEquipment="feedNeedEquipment"
-                  @reload="reloadFeeding"
-                ></feeding>
-              </div>
-
-              <div v-if="operationType == 'job'">
-                <!-- // 报工列表 入库 -->
-
-                <warehousing
-                  v-if="taskObj.id == -1 && activeName == '0'"
-                  :workListIds="workListIds"
-                  ref="wareRef"
-                  :workPlanType="workPlanType"
-                ></warehousing>
-
-                <jobBooking
-                  v-else-if="isFinalCheckProduction && activeName == '0'"
-                  :workListIds="workListIds"
-                  ref="jobRef"
-                  :reportNeedFeed="reportNeedFeed"
-                  :workPlanType="workPlanType"
-                ></jobBooking>
-
-                <task-report
-                  ref="taskReportRef"
-                  v-if="activeName == '1' && isFinalCheckProduction"
-                  style="background: #fff"
-                  @success="successTask"
-                />
-              </div>
-
-              <div v-if="operationType == 'workOrder'">
-                <workOrderHandover
-                  :workListIds="workListIds"
-                  :workData="workData"
-                  ref="workOrderHandoverRef"
-                  @cancel="closeWorkOrderHandover"
-                ></workOrderHandover>
-              </div>
-
-              <!-- 工步 -->
-              <div v-if="operationType == 'workStep'"> </div>
-              <!-- 质检工序 -->
-
-              <div v-if="operationType == 'inspection'">
-                <inspection
-                  :workListIds="workListIds"
-                  ref="inspectionRef"
-                ></inspection>
-              </div>
-
-              <!-- 委外 -->
-              <div
-                v-if="operationType == 'Outsourcing' && isType == '3'"
-                class="right_main_box"
-              >
-                <outsourcingDetails
-                  ref="outsourcingListRef"
-                  @outsourcingAdd="outsourcingAdd"
-                  v-if="!isStep && !isOutsource && !isPleaseEntrust"
-                  :chooseType="chooseType"
-                ></outsourcingDetails>
-                <outsourcing
-                  :outsourceFormVal="outsourceForm"
-                  :taskObj="taskObj"
-                  :workListIds="workListIds[0]"
-                  :workData="workData"
-                  @changePlugIn="changePlugIn"
-                  @changeCancel="changeCancel"
-                  :chooseType="chooseType"
-                  v-if="isStep"
-                ></outsourcing>
-
-                <!--   -->
-                <outsourceList
-                  :workData="workData"
-                  :taskObj="taskObj"
-                  :outsourceFormVal="outsourceForm"
-                  :chooseType="chooseType"
-                  @closeForm="closeForm"
-                  @outScucc="outScucc"
-                  v-if="isOutsource"
-                ></outsourceList>
-
-                <pleaseEntrust
-                  :outsourceFormVal="outObj"
-                  @closeForm="closeForm"
-                  @outScucc="outScucc"
-                  v-if="isPleaseEntrust"
-                ></pleaseEntrust>
-              </div>
+                <!-- 领料 -->
+                <div v-if="operationType == 'pick' && activeName == '0'">
+                  <pickDetails
+                    ref="pickListRef"
+                    :workTaskId="workTaskId"
+                    :taskId="taskObj.id"
+                    @pickAdd="pickAdd"
+                  ></pickDetails>
+                </div>
+
+                <div v-if="operationType == 'feed' && activeName == '0'">
+                  <!-- 投料 -->
+                  <feeding
+                    :workListIds="workListIds"
+                    :feedNeedEquipment="feedNeedEquipment"
+                    @reload="reloadFeeding"
+                  ></feeding>
+                </div>
+
+                <div v-if="operationType == 'job'">
+                  <!-- // 报工列表 入库 -->
+
+                  <warehousing
+                    v-if="taskObj.id == -1 && activeName == '0'"
+                    :workListIds="workListIds"
+                    ref="wareRef"
+                    :workPlanType="workPlanType"
+                  ></warehousing>
+
+                  <jobBooking
+                    v-else-if="isFinalCheckProduction && activeName == '0'"
+                    :workListIds="workListIds"
+                    ref="jobRef"
+                    :reportNeedFeed="reportNeedFeed"
+                    :workPlanType="workPlanType"
+                  ></jobBooking>
+
+                  <task-report
+                    ref="taskReportRef"
+                    v-if="activeName == '1' && isFinalCheckProduction"
+                    style="background: #fff"
+                    @success="successTask"
+                  />
+                </div>
+
+                <div v-if="operationType == 'workOrder'">
+                  <workOrderHandover
+                    :workListIds="workListIds"
+                    :workData="workData"
+                    ref="workOrderHandoverRef"
+                    @cancel="closeWorkOrderHandover"
+                  ></workOrderHandover>
+                </div>
+
+                <!-- 工步 -->
+                <div v-if="operationType == 'workStep'"> </div>
+                <!-- 质检工序 -->
+
+                <div v-if="operationType == 'inspection'">
+                  <inspection
+                    :workListIds="workListIds"
+                    ref="inspectionRef"
+                  ></inspection>
+                </div>
+
+                <!-- 委外 -->
+                <div
+                  v-if="operationType == 'Outsourcing' && isType == '3'"
+                  class="right_main_box"
+                >
+                  <outsourcingDetails
+                    ref="outsourcingListRef"
+                    @outsourcingAdd="outsourcingAdd"
+                    v-if="!isStep && !isOutsource && !isPleaseEntrust"
+                    :chooseType="chooseType"
+                  ></outsourcingDetails>
+                  <outsourcing
+                    :outsourceFormVal="outsourceForm"
+                    :taskObj="taskObj"
+                    :workListIds="workListIds[0]"
+                    :workData="workData"
+                    @changePlugIn="changePlugIn"
+                    @changeCancel="changeCancel"
+                    :chooseType="chooseType"
+                    v-if="isStep"
+                  ></outsourcing>
+
+                  <!--   -->
+                  <outsourceList
+                    :workData="workData"
+                    :taskObj="taskObj"
+                    :outsourceFormVal="outsourceForm"
+                    :chooseType="chooseType"
+                    @closeForm="closeForm"
+                    @outScucc="outScucc"
+                    v-if="isOutsource"
+                  ></outsourceList>
+
+                  <pleaseEntrust
+                    :outsourceFormVal="outObj"
+                    @closeForm="closeForm"
+                    @outScucc="outScucc"
+                    v-if="isPleaseEntrust"
+                  ></pleaseEntrust>
+                </div>
               </template>
               </template>
             </div>
             </div>
           </template>
           </template>
@@ -508,9 +508,7 @@
           if (!list || !list.length) return {};
           if (!list || !list.length) return {};
           const primaryId = this.workListIds[0];
           const primaryId = this.workListIds[0];
           const row =
           const row =
-            primaryId != null
-              ? list.find((r) => r.id == primaryId)
-              : null;
+            primaryId != null ? list.find((r) => r.id == primaryId) : null;
           const resolved = row || list[0];
           const resolved = row || list[0];
           return resolved ? { ...resolved } : {};
           return resolved ? { ...resolved } : {};
         }
         }
@@ -970,8 +968,7 @@
 
 
       taskSelect(data) {
       taskSelect(data) {
         this.workOrderDetailPreviewSuppressed = false;
         this.workOrderDetailPreviewSuppressed = false;
-        this.taskData =
-          data.list && data.list.length > 0 ? data.list[0] : null;
+        this.taskData = data.list && data.list.length > 0 ? data.list[0] : null;
       },
       },
 
 
       buildWorkOrderInfoFromTaskRow(row) {
       buildWorkOrderInfoFromTaskRow(row) {
@@ -1043,6 +1040,36 @@
         }
         }
       },
       },
 
 
+      /** 投料前首件两检校验(与报工逻辑一致) */
+      async validateFeedFirstArticle() {
+        if (this.activeName === '1') {
+          const row = this.taskData;
+          if (!row) {
+            this.$message.warning('请选择一条任务单进行投料');
+            return false;
+          }
+          if (
+            this.taskObj.id != '-1' &&
+            row.hasFirstArticleDualInspection == '1' &&
+            row.totalFirstArticleDualInspectionStatus != '2'
+          ) {
+            this.$message.warning('请先完成首件两检再投料');
+            return false;
+          }
+          return true;
+        }
+
+        if (!this.checkWorkOrder({ min: 1 })) return false;
+        if (this.taskObj.id != '-1') {
+          const result = await this.checkQualityResult();
+          if (!result?.firstArticleDualInspectionResult) {
+            this.$message.warning('请完成首件两检再投料!');
+            return false;
+          }
+        }
+        return true;
+      },
+
       async footBtn(t) {
       async footBtn(t) {
         this.workPlanType = '';
         this.workPlanType = '';
 
 
@@ -1062,11 +1089,16 @@
           }
           }
 
 
           this.operationType = t;
           this.operationType = t;
-        } else {
+        } else if (t !== 'feed') {
           this.operationType = t;
           this.operationType = t;
         }
         }
         if (!this.checkTaskSelected()) return;
         if (!this.checkTaskSelected()) return;
 
 
+        if (t === 'feed') {
+          if (!(await this.validateFeedFirstArticle())) return;
+          this.operationType = 'feed';
+        }
+
         this.workOrderDetailPreviewSuppressed = true;
         this.workOrderDetailPreviewSuppressed = true;
 
 
         const handler = this.actionMap[t];
         const handler = this.actionMap[t];
@@ -1229,6 +1261,7 @@
         this.isFinalCheckProduction = false;
         this.isFinalCheckProduction = false;
         if (this.taskObj.id != '-1') {
         if (this.taskObj.id != '-1') {
           const result = await this.checkQualityResult();
           const result = await this.checkQualityResult();
+          console.log(result, 'result');
           if (!result?.firstArticleDualInspectionResult) {
           if (!result?.firstArticleDualInspectionResult) {
             return this.$message.warning('请完成首件两检再报工!');
             return this.$message.warning('请完成首件两检再报工!');
           }
           }