Bläddra i källkod

物料添加、嘉实记录表功能修改

lucw 7 månader sedan
förälder
incheckning
ef47052660

+ 107 - 72
src/views/batchRecord/components/editModal.vue

@@ -499,8 +499,38 @@
           style="margin-top: 20px"
         ></header-title>
 
+        <template
+          v-if="
+            form.itemType == 2 &&
+            form.recordRulesClassify == 10 &&
+            form.workOrderId &&
+            form.produceTaskId &&
+            form.ruleId &&
+            form.produceRoutingId
+          "
+        >
+          <el-tabs v-model="statisticsType" type="card">
+            <el-tab-pane
+              v-for="i in statisticsTypeList"
+              :label="i.label"
+              :name="i.value"
+              :key="i.value"
+            >
+            </el-tab-pane>
+          </el-tabs>
+          <statistics
+            ref="statisticsRef"
+            :details.sync="form.details"
+            :statisticsType="statisticsType"
+            :produceTaskId="form.produceTaskId"
+            :workOrderId="form.workOrderId"
+            :routingId="form.produceRoutingId"
+            :ruleId="form.ruleId"
+          ></statistics>
+        </template>
+
         <ele-pro-table
-          v-if="form.itemType == 2"
+          v-if="form.itemType == 2 && form.recordRulesClassify != 10"
           v-loading="loading"
           ref="table"
           row-key="id"
@@ -610,65 +640,33 @@
     </template>
 
     <template v-else v-slot:footer>
-      <template
-        v-if="
-          ($hasPermission('mes:producetaskrulerecord:tempsu') ||
-            $hasPermission('mes:producetaskrulerecord:tempsus')) &&
-          form.executeMethod == '1'
-        "
+      <el-button
+        type="primary"
+        @click="save"
+        :loading="butLoading"
+        :disabled="form.executeStatus == 2"
+        >保存</el-button
       >
-        <el-button
-          v-if="$hasPermission('mes:producetaskrulerecord:tempsu')"
-          type="primary"
-          @click="save"
-          :loading="butLoading"
-          :disabled="form.executeStatus != 0"
-          >保存</el-button
-        >
 
-        <el-button
-          v-if="$hasPermission('mes:producetaskrulerecord:tempsus')"
-          type="primary"
-          @click="submit"
-          :loading="butLoading"
-          >执行</el-button
-        >
-      </template>
-      <template
+      <el-button
+        type="primary"
+        @click="submit('submit')"
+        :loading="butLoading"
+        :disabled="form.executeStatus == 2"
+        >报工</el-button
+      >
+
+      <el-button
         v-if="
-          ($hasPermission('mes:producetaskrecordrulesrecord:saveorupdate') ||
-            $hasPermission('mes:producetaskrecordrulesrecord:sus')) &&
-          form.executeMethod == '2'
+          $hasPermission('mes:producetaskrecordrulesrecord:res') &&
+          form.executeStatus == 2
         "
+        type="primary"
+        @click="submit('submit-reset')"
+        :loading="butLoading"
+        >重新报工</el-button
       >
-        <el-button
-          v-if="$hasPermission('mes:producetaskrecordrulesrecord:saveorupdate')"
-          type="primary"
-          @click="save"
-          :loading="butLoading"
-          >保存</el-button
-        >
-        <el-button
-          v-if="$hasPermission('mes:producetaskrecordrulesrecord:sus')"
-          type="primary"
-          @click="submit"
-          :loading="butLoading"
-          >执行</el-button
-        >
-      </template>
-
-      <template v-if="form.executeMethod == '3'">
-        <el-button
-          type="primary"
-          @click="save"
-          :loading="butLoading"
-          :disabled="form.executeStatus != 0"
-          >保存</el-button
-        >
-        <el-button type="primary" @click="submit" :loading="butLoading"
-          >执行</el-button
-        >
-      </template>
+
       <el-button @click="handleClose" :loading="butLoading">取 消</el-button>
     </template>
 
@@ -743,13 +741,15 @@
     getById as producetaskrulerecordGetById,
     queryListByWorkOrderId,
     saveOrUpdate,
-    saveOrUpdateAndSubmit
+    saveOrUpdateAndSubmit,
+    resetSubmit
   } from '@/api/producetaskrecordrulesrecord/index.js';
   import bpmDetail from '@/views/bpm/processInstance/detail.vue';
   import bpmTask from '@/components/bpmTask/bpmTask.vue';
   import { getFactoryarea } from '@/api/aps/index';
   import { getTeam } from '@/api/produce/job.js';
   import material from '@/views/produce/components/prenatalExamination/material.vue';
+  import statistics from '@/views/produce/components/prenatalExamination/statistics.vue';
 
   export default {
     name: 'editModal',
@@ -767,7 +767,8 @@
       toolModal,
       bpmDetail,
       bpmTask,
-      material
+      material,
+      statistics
     },
     props: {
       // 1-产前准备,2-过程监测,3-产后检查
@@ -1024,6 +1025,13 @@
           { label: '原材料', value: 1 },
           { label: '在制品', value: 2 },
           { label: 'BOM标准产出', value: 3 }
+        ],
+        // 1-成品统计,2-物料统计,3-工序统计"
+        statisticsType: '1',
+        statisticsTypeList: [
+          { label: '成品统计', value: '1' },
+          { label: '物料统计', value: '2' },
+          { label: '工序统计', value: '3' }
         ]
       };
     },
@@ -1161,6 +1169,7 @@
         console.log('data 详情', data);
         this.$util.assignObject(this.form, data);
         this.form.details = this.form.details.map((i) => {
+          i.checkUsersIds = i.checkUsers.map((j) => j.userId);
           return {
             ...i,
             toolNames: i.tools.map((i) => i.toolName).join(',')
@@ -1212,6 +1221,7 @@
       handleClose() {
         this.form = JSON.parse(JSON.stringify(this.formBaseData));
         this.produceTaskList = [];
+        this.statisticsType = '1';
         this.details = null;
         this.$nextTick(() => {
           this.$refs.formRef.clearValidate();
@@ -1304,6 +1314,7 @@
           this.form.specification = workOrder.specification;
           this.form.formingNum = workOrder.formingNum;
           this.form.brandNo = workOrder.brandNo;
+          this.form.produceRoutingId = workOrder.produceRoutingId;
           this.getProductTaskList(workOrder.id);
         } else {
           this.workOrderInfo = null;
@@ -1316,6 +1327,7 @@
           this.form.specification = null;
           this.form.formingNum = null;
           this.form.brandNo = '';
+          this.form.produceRoutingId = '';
 
           this.produceTaskList = [];
         }
@@ -1361,7 +1373,7 @@
         this.getListByWorkOrderId();
       },
       // 执行
-      submit() {
+      submit(type = '') {
         this.$refs.formRef.validate(async (valid) => {
           if (!valid) {
             return '';
@@ -1379,12 +1391,7 @@
               }
             );
           } else if (this.form.executeMethod == 2) {
-            // 验证产出物数量;
-            const valid = this.$refs.materialRef.validateOutputQuantities();
-            if (!valid) {
-              return;
-            }
-            this.releaseRulesSaveOrSubmit('submit');
+            this.releaseRulesSaveOrSubmit(type);
           } else {
             // 任务确认
             this.saveRuleRecord();
@@ -1441,7 +1448,11 @@
         }
 
         // 报工需要验证 缓存不验证 排除 recordRulesClassify ==4 物料添加 的情况
-        if (type == 'submit' && this.form.recordRulesClassify != '4') {
+        if (
+          type.includes('submit') &&
+          this.form.recordRulesClassify != '4' &&
+          this.form.recordRulesClassify != '10'
+        ) {
           // 验证检查项目
           const detailRequired = this.form.details.some((i) => {
             return (
@@ -1458,6 +1469,22 @@
           }
         }
 
+        if (this.$refs.materialRef) {
+          // 验证产出物数量;
+          const valid = this.$refs.materialRef.validateOutputQuantities();
+          if (!valid) {
+            return;
+          }
+        }
+
+        if (this.$refs.statisticsRef && type != 'cache') {
+          // 验证统计项目
+          const valid = this.$refs.statisticsRef.validateStatisticsFilled();
+          if (!valid) {
+            return;
+          }
+        }
+
         const body = JSON.parse(JSON.stringify(this.form));
 
         // 工时小时转毫秒
@@ -1470,6 +1497,9 @@
           if (type == 'submit') {
             await saveOrUpdateAndSubmit(body);
             this.$message.success('报工成功!');
+          } else if (type == 'submit-reset') {
+            await resetSubmit(body);
+            this.$message.success('重新报工成功!');
           } else {
             const id = await saveOrUpdate(body);
             this.form.id = id;
@@ -1565,7 +1595,12 @@
         row.toolNames = '';
       },
       async getListByWorkOrderId(type = '') {
-        if (!this.form.produceTaskId || this.reportWorkType != 2) return;
+        if (
+          !this.form.produceTaskId ||
+          this.reportWorkType != 2 ||
+          this.form.itemType != 2
+        )
+          return;
         // 查询物料信息
         const materialObject = await queryListByWorkOrderId({
           workOrderId: this.form.workOrderId,
@@ -1576,10 +1611,10 @@
 
         console.log('materialObject 物料信息', materialObject);
         if (type == '') {
-          this.addForm.outputDetails = materialObject.outputDetails;
-          this.addForm.pickDetails = materialObject.pickDetails.map((i) => {
+          this.form.outputDetails = materialObject.outputDetails;
+          this.form.pickDetails = materialObject.pickDetails.map((i) => {
             // 物料清单中如果存在则 selected 设置为 true
-            const any = this.addForm.outputDetails.find(
+            const any = this.form.outputDetails.find(
               (j) => j.categoryId === i.categoryId
             );
             if (any) {
@@ -1593,10 +1628,10 @@
         }
 
         if (type == 'output') {
-          this.addForm.outputDetails = materialObject.outputDetails;
-          this.addForm.pickDetails = this.addForm.pickDetails.map((i) => {
+          this.form.outputDetails = materialObject.outputDetails;
+          this.form.pickDetails = this.form.pickDetails.map((i) => {
             // 物料清单中如果存在则 selected 设置为 true
-            const any = this.addForm.outputDetails.find(
+            const any = this.form.outputDetails.find(
               (j) => j.categoryId === i.categoryId
             );
             if (any) {

+ 17 - 0
src/views/batchRecord/components/list.vue

@@ -75,10 +75,27 @@
             type="primary"
             :underline="false"
             @click="openEdit('edit', row)"
+            v-if="
+              row.executeStatus == 0 ||
+              (row.executeStatus == 1 && row.itemType == 2) ||
+              (row.executeStatus == 1 && row.itemType == 3)
+            "
           >
             报工
           </el-link>
 
+          <el-link
+            v-if="
+              row.executeStatus == 2 &&
+              $hasPermission('mes:producetaskrecordrulesrecord:res')
+            "
+            type="primary"
+            :underline="false"
+            @click="openEdit('edit', row)"
+          >
+            重新报工
+          </el-link>
+
           <el-link
             v-if="row.approvalStatus === 0"
             type="primary"

+ 5 - 1
src/views/produce/components/prenatalExamination/index.vue

@@ -111,7 +111,11 @@
           isTempRecord: 0
         };
         const data = await getLastRuleRecords(body);
-        this.ruleRecordsList = data;
+        this.ruleRecordsList = data.map(i => {
+          // 工序名称
+          i.produceTaskName = this.produceTaskInfo.name
+          return i;
+        });
         console.log('报工流程 事项', this.ruleRecordsList);
         this.loading = false;
       },

+ 105 - 79
src/views/produce/components/prenatalExamination/material.vue

@@ -10,7 +10,7 @@
       cache-key="prenatal-examination-material-list-table-2511031522"
       autoAmendPage
       :needPage="false"
-      @refresh="$emit('refresh', 'material')"
+      @refresh="$emit('refresh')"
     >
       <template v-slot:toolbar>
         <el-button type="primary" @click="openMaterialModal"
@@ -36,7 +36,7 @@
       cache-key="prenatal-examination-output-list-table-2511031523"
       autoAmendPage
       :needPage="false"
-      @refresh="$emit('refresh', 'output')"
+      @refresh="localOutputDetailsRefresh"
     >
       <template v-slot:reportQuantity="{ row }">
         <el-input-number
@@ -431,9 +431,7 @@
               return (row.sumNoQualifiedQuantity || 0) + (row.unit || '');
             }
           }
-        ],
-        // bomInfo
-        materialQuotaInfo: null
+        ]
       };
     },
     mounted() {},
@@ -486,31 +484,32 @@
             this.produceTaskId
           );
           console.log('this.materialQuotaInfo', data);
-          if (!data.standardOutput) {
-            return this.$message.warning('未配置标准产出物料');
-          }
           this.materialQuotaInfo = data;
-          // 赋值产出
-          this.localOutputDetails = [
-            {
-              ...data.standardOutput,
-              id: null,
-              reportQuantity: 0,
-              qualifiedQuantity: 0,
-              noQualifiedQuantity: 0,
-              msg: '',
-              sumReportQuantity: 0,
-              sumQualifiedQuantity: 0,
-              sumNoQualifiedQuantity: 0,
-              ruleId: this.ruleId,
-              outputType: this.outputType,
-              produceTaskId: this.produceTaskId,
-              produceTaskInstanceId: this.produceTaskInstanceId,
-              produceTaskName: this.produceTaskName,
-              workOrderId: this.workOrderId
-            }
-          ];
-          this.$emit('update:outputDetails', this.localOutputDetails);
+          //
+          if (data && data.standardOutput) {
+            // 赋值产出
+            this.localOutputDetails = [
+              {
+                ...data.standardOutput,
+                id: null,
+                reportQuantity: 0,
+                qualifiedQuantity: 0,
+                noQualifiedQuantity: 0,
+                msg: '',
+                sumReportQuantity: 0,
+                sumQualifiedQuantity: 0,
+                sumNoQualifiedQuantity: 0,
+                ruleId: this.ruleId,
+                outputType: this.outputType,
+                produceTaskId: this.produceTaskId,
+                produceTaskInstanceId: this.produceTaskInstanceId,
+                produceTaskName: this.produceTaskName,
+                workOrderId: this.workOrderId
+              }
+            ];
+            this.$emit('update:outputDetails', this.localOutputDetails);
+          }
+
           console.log('this.localOutputDetails', this.localOutputDetails);
         }
       },
@@ -523,7 +522,7 @@
       },
       selectedChange(row) {
         console.log('row', row);
-        if(this.outputType != 1) return;
+        if (this.outputType != 1) return;
 
         if (row.selected) {
           // 判断是否存在
@@ -568,25 +567,28 @@
       // getCategoryAndLevelByCategoryId 获取产品
       async getCategoryAndLevelByCategoryId() {
         const data = await getCategoryAndLevelByCategoryId(this.categoryId);
-        this.localOutputDetails = [
-          {
-            ...data,
-            id: null,
-            reportQuantity: 0,
-            qualifiedQuantity: 0,
-            noQualifiedQuantity: 0,
-            msg: '',
-            sumReportQuantity: 0,
-            sumQualifiedQuantity: 0,
-            sumNoQualifiedQuantity: 0,
-            ruleId: this.ruleId,
-            outputType: this.outputType,
-            produceTaskId: this.produceTaskId,
-            produceTaskInstanceId: this.produceTaskInstanceId,
-            produceTaskName: this.produceTaskName,
-            workOrderId: this.workOrderId
-          }
-        ];
+        if (data) {
+          this.localOutputDetails = [
+            {
+              ...data,
+              id: null,
+              reportQuantity: 0,
+              qualifiedQuantity: 0,
+              noQualifiedQuantity: 0,
+              msg: '',
+              sumReportQuantity: 0,
+              sumQualifiedQuantity: 0,
+              sumNoQualifiedQuantity: 0,
+              ruleId: this.ruleId,
+              outputType: this.outputType,
+              produceTaskId: this.produceTaskId,
+              produceTaskInstanceId: this.produceTaskInstanceId,
+              produceTaskName: this.produceTaskName,
+              workOrderId: this.workOrderId
+            }
+          ];
+        }
+
         this.$emit('update:outputDetails', this.localOutputDetails);
 
         const bomInfo = await getMaterialQuotaInfo(
@@ -603,15 +605,19 @@
           // 物料本身 不能超过已报工数量减领料数量
           return row.quantity - row.sumReportQuantity;
         }
+        if (row.outputType == 2) {
+          // 在物料中查询对应的物料
+          const pickitem = this.preOutputDetails.find(
+            (pick) => pick.categoryId == row.categoryId
+          );
+          if (pickitem) {
+            return  pickitem.qualifiedQuantity;
+          }
+        }
         return Infinity;
       },
       // 判断生成产出清单的物料数量是合格
       async validateOutputQuantities() {
-        if (this.localPickDetails.length == 0) {
-          this.$message.warning(`物料清单不能为空`);
-          return false;
-        }
-
         if (this.localOutputDetails.length == 0) {
           this.$message.warning(`产出清单不能为空`);
           return false;
@@ -626,18 +632,20 @@
           }
 
           // 判断当次合格数量 和 不合格数量 之和需要等于 报工数量
-          if (
-            item.reportQuantity !==
-            item.qualifiedQuantity + item.noQualifiedQuantity
-          ) {
+          if (!item.qualifiedQuantity) {
             this.$message.warning(
-              `物料【${item.categoryName}】的当次合格数量和不合格数量之和必须等于报工数量`
+              `请填写产出清单【${item.categoryName}】的当次合格数量`
             );
             return false;
           }
         }
 
         if (this.outputType == 1) {
+          if (this.localPickDetails.length == 0) {
+            this.$message.warning(`物料清单不能为空`);
+            return false;
+          }
+
           for (const item of this.localOutputDetails) {
             const pickitem = this.localPickDetails.find(
               (pick) =>
@@ -661,7 +669,7 @@
           }
         }
 
-        if (this.outputType == 2 || this.outputType == 3) {
+        if (this.outputType == 2) {
           let val = true;
 
           if (!this.materialQuotaInfo) {
@@ -671,6 +679,15 @@
             );
           }
 
+          // 没有配置产出清单 、没有原材料 不检查
+          if (
+            !this.materialQuotaInfo ||
+            !this.materialQuotaInfo.standardOutput ||
+            this.localPickDetails.length == 0
+          ) {
+            return true;
+          }
+
           this.materialQuotaInfo.materialQuota.forEach((i) => {
             // 避免重复提示
             if (!val) {
@@ -726,25 +743,25 @@
               }
             }
             // 上一道工序产出物存在
-            if (preOutputItem) {
-              if (needQuantity > preOutputItem.quantity) {
-                this.$message.warning(
-                  `物料【${preOutputItem.categoryName}】领料数量不足,需${needQuantity}${preOutputItem.unit},当前仅有${preOutputItem.quantity}${preOutputItem.unit}`
-                );
-                val = false;
-                return false;
-              }
-              // 判断累计报工数量是否足够
-              let preOutputItemSumReportQuantity =
-                preOutputItem.sumReportQuantity + preOutputItem.reportQuantity;
-              if (needQuantity > preOutputItemSumReportQuantity) {
-                this.$message.warning(
-                  `物料【${preOutputItem.categoryName}】累计报工数量不足,需${needQuantity}${preOutputItem.unit},当前仅有${preOutputItemSumReportQuantity}${preOutputItem.unit}`
-                );
-                val = false;
-                return false;
-              }
-            }
+            // if (preOutputItem) {
+            //   if (needQuantity > preOutputItem.quantity) {
+            //     this.$message.warning(
+            //       `物料【${preOutputItem.categoryName}】领料数量不足,需${needQuantity}${preOutputItem.unit},当前仅有${preOutputItem.quantity}${preOutputItem.unit}`
+            //     );
+            //     val = false;
+            //     return false;
+            //   }
+            //   // 判断累计报工数量是否足够
+            //   let preOutputItemSumReportQuantity =
+            //     preOutputItem.sumReportQuantity + preOutputItem.reportQuantity;
+            //   if (needQuantity > preOutputItemSumReportQuantity) {
+            //     this.$message.warning(
+            //       `物料【${preOutputItem.categoryName}】累计报工数量不足,需${needQuantity}${preOutputItem.unit},当前仅有${preOutputItemSumReportQuantity}${preOutputItem.unit}`
+            //     );
+            //     val = false;
+            //     return false;
+            //   }
+            // }
           });
 
           return val;
@@ -756,6 +773,15 @@
       qualifiedQuantityChange(row) {
         row.noQualifiedQuantity = row.reportQuantity - row.qualifiedQuantity;
         this.$emit('update:outputDetails', this.localOutputDetails);
+      },
+      localOutputDetailsRefresh() {
+        if (this.outputType == 1) {
+          $emit('refresh', 'output');
+        } else if (this.outputType == 2) {
+          this.getCategoryAndLevelByCategoryId();
+        } else {
+          this.getMaterialQuotaInfo();
+        }
       }
     }
   };

+ 27 - 5
src/views/produce/components/prenatalExamination/releaseRulesDialog.vue

@@ -208,6 +208,7 @@
               placeholder="请选择产出物类型"
               filterable
               style="width: 100%"
+              :disabled="preOutputDetails.some((i) => i.outputType == 2)"
             >
               <el-option
                 v-for="item in outputTypeList"
@@ -755,8 +756,7 @@
           this.addForm.produceRoutingName = workOrderInfo.produceRoutingName;
           this.addForm.produceTaskConfigId = productionInfo.produceTaskConfigId;
           this.addForm.produceTaskId = productionInfo.produceTaskId;
-          this.addForm.produceTaskName =
-            productionInfo.produceTaskName || workOrderInfo.taskName;
+          this.addForm.produceTaskName = productionInfo.produceTaskName;
           this.addForm.productCode = workOrderInfo.productCode;
           this.addForm.productModel = workOrderInfo.model;
           this.addForm.productName = workOrderInfo.productName;
@@ -769,6 +769,7 @@
             productionInfo.recordRulesExecuteMethodId;
           this.addForm.recordRulesExecuteMethodName =
             productionInfo.recordRulesExecuteMethodName;
+          this.addForm.ruleId = productionInfo.ruleId;
 
           // 临时添加存在规则详情
 
@@ -787,7 +788,10 @@
 
         console.log('this.productionInfo', this.productionInfo);
         console.log('this.addForm', this.addForm);
-        this.getRuleInfo();
+        this.$nextTick(() => {
+          this.getListByWorkOrderId();
+          this.getRuleInfo();
+        });
       },
       // 获取详情
       async getCacheInfo() {
@@ -841,7 +845,12 @@
       },
       // 物料信息查询
       async getListByWorkOrderId(type = '') {
-        console.log('type 物料信息', type);
+        console.log(
+          'type 物料信息',
+          type,
+          this.productionInfo.produceTaskId,
+          this.addForm.reportWorkType
+        );
         if (
           !this.productionInfo.produceTaskId ||
           this.addForm.reportWorkType != 2
@@ -871,7 +880,20 @@
             }
             return i;
           });
-          this.preOutputDetails = materialObject.preOutputDetails;
+          this.preOutputDetails = materialObject.preOutputDetails.map((i) => {
+            i.quantity = i.qualifiedQuantity;
+            return i;
+          });
+
+          //  this.preOutputDetails 是否存在outputType=2的数据
+          const hasInProcess = this.preOutputDetails.some(
+            (i) => i.outputType == 2
+          );
+          if (hasInProcess) {
+            // 产出物为在制品
+            this.addForm.outputType = 2;
+            // 不可选择
+          }
         }
 
         if (type == 'output') {

+ 12 - 5
src/views/produce/components/prenatalExamination/statistics.vue

@@ -202,13 +202,15 @@
         if (
           this.localDetails.length > 0 &&
           this.localDetails[0].statisticsValue &&
-          this.localDetails[0].statisticsType == 1
+          this.localDetails[0].statisticsType == 1 &&
+          this.localDetails[0].statisticsValue[0]
         ) {
           return this.localDetails[0].statisticsValue[0].map((item, index) => {
             return {
               label: item.title,
               slot: `column_${index}`,
-              align: 'center'
+              align: 'center',
+              minWidth: 200
             };
           });
         } else {
@@ -226,7 +228,8 @@
             return {
               label: item.title,
               slot: `column_${index}`,
-              align: 'center'
+              align: 'center',
+              minWidth: 200
             };
           });
         } else {
@@ -244,7 +247,8 @@
             return {
               label: item.title,
               slot: `column_${index}`,
-              align: 'center'
+              align: 'center',
+              minWidth: 200
             };
           });
         } else {
@@ -271,7 +275,10 @@
           return;
         }
         // 已构建过统计数据
-        if (detials[0].statisticsValue) {
+        if (
+          detials[0].statisticsValue &&
+          detials[0].statisticsValue.length > 0
+        ) {
           return (this.localDetails = JSON.parse(JSON.stringify(detials)));
         }
         // 构建统计数据