Browse Source

fix: 修复检测报工样品数量计算与显示问题

yusheng 2 months ago
parent
commit
a7e99097f2

+ 2 - 2
src/views/inspectionProjectRequest/components/inspectionProjectRequestList.vue

@@ -233,7 +233,7 @@
     verificationQualityInspector,
     removeItem
   } from '@/api/inspectionProjectRequest';
-  import { craftFiles } from '@/api/inspectionWork';
+
   import dictMixins from '@/mixins/dictMixins';
   import { reviewStatus } from '@/enum/dict';
   import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
@@ -600,7 +600,7 @@
         if (row.recordingMethod == 1) {
           this.$refs.inspectionProjectReportRef.open(
             {
-              workData: { ...res, measureUnit: res.sampleMeasureUnit },
+              workData: { ...res, measureUnit: res.sampleMeasureUnit,workSampleCount:res.sampleTotal },
               list: res.templateList
             },
             type,

+ 5 - 1
src/views/inspectionProjectTask/components/inspectionProjectTaskList.vue

@@ -411,7 +411,11 @@
         if (row.recordingMethod == 1) {
           this.$refs.inspectionProjectReportRef.open(
             {
-              workData: { ...res.data, measureUnit: row.measureUnit },
+              workData: {
+                ...res.data,
+                measureUnit: row.measureUnit,
+                workSampleCount: res.sampleTotal
+              },
               list: res.data.templateList
             },
             type,

+ 21 - 5
src/views/inspectionWork/components/baseInfo.vue

@@ -223,7 +223,10 @@
           <el-form-item
             label="合格数:"
             prop="qualifiedNumber"
-            v-if="showArrange == '1'"
+            v-if="
+              showArrange == '1' ||
+              (showArrange == '2' && this.form.qualityMode != '2')
+            "
           >
             <el-input
               :min="0"
@@ -238,7 +241,10 @@
           <el-form-item
             label="不合格数:"
             prop="noQualifiedNumber"
-            v-if="showArrange == '1'"
+            v-if="
+              showArrange == '1' ||
+              (showArrange == '2' && this.form.qualityMode != '2')
+            "
           >
             <el-input
               :min="0"
@@ -289,7 +295,10 @@
               v-model="form.qualityResults"
               placeholder="请选择"
               style="width: 100%"
-              :disabled="showArrange == '0'"
+              :disabled="
+                showArrange == '0' ||
+                (showArrange == '2' && this.form.qualityMode == '2')
+              "
               @change="selectResult"
             >
               <el-option label="合格" :value="1" />
@@ -317,7 +326,14 @@
             />
           </el-form-item>
         </el-col>
-        <el-col :span="showArrange == '1' ? 24 : 12">
+        <el-col
+          :span="
+            showArrange == '1' ||
+            (showArrange == '2' && this.form.qualityMode != '2')
+              ? 24
+              : 12
+          "
+        >
           <el-form-item label="备注:" prop="remark">
             <el-input
               type="textarea"
@@ -737,7 +753,7 @@
       //选择部门(搜索)
       searchDeptNodeClick(info, row) {
         this.form.executeUserId = '';
-        this.$set(this.form, 'executeUserName',' item.name');
+        this.$set(this.form, 'executeUserName', ' item.name');
         this.$set(this.form, 'executeUserIdList', '');
         if (info) {
           const params = { groupId: info };

+ 23 - 32
src/views/inspectionWork/components/inspectionProjectReport.vue

@@ -10,7 +10,6 @@
     width="80%"
     resizable
     :maxable="true"
-
   >
     <ele-pro-table
       :needPage="false"
@@ -18,7 +17,7 @@
       :datasource="[form]"
     >
       <template v-slot:toolbar>
-        剩余样品总数:{{ form.remainingSampleCount }}{{ form.measureUnit }}
+        样品总数:{{ form.workSampleCount }}{{ form.measureUnit }}
       </template>
       <template v-slot:craftFiles="{ row }">
         <el-link type="primary" :underline="false" @click="craftFiles(row)"
@@ -84,11 +83,12 @@
           "
         >
           <span>
-            当前检测剩余样品数:{{ getSampleQuantityCount
+            当前检测剩余样品数:{{ form.sampleQuantity
             }}{{ form.measureUnit }}</span
           >
           <el-button
             type="primary"
+            v-if="type != 'detail'"
             @click="handleOneKeyQualified"
             style="margin-right: 10px"
           >
@@ -647,6 +647,8 @@
             minWidth: 180,
             prop: 'sampleQuantity',
             slot: 'sampleQuantity',
+            headerSlot: 'isRequired',
+
             align: 'center',
             label: '样品数',
             showOverflowTooltip: true
@@ -745,14 +747,7 @@
         ];
       },
       getSampleQuantityCount() {
-        return (
-          (this.form.sampleQuantity * 100 -
-            (this.form.lossNumber * 100 || 0) -
-            (this.form.lossNumberUnqualified * 100 || 0) -
-            (this.form.retainedSampleQuantity * 100 || 0) -
-            (this.form.retainedSampleUnqualified * 100 || 0)) /
-          100
-        );
+        return this.form.sampleQuantity;
       }
     },
 
@@ -789,21 +784,16 @@
             ...row,
             batchNo: this.form.batchNo,
             qualityWorkOrderId: this.form.qualityWorkOrderId,
-            getSampleQuantityCount:
-              this.getSampleQuantityCount +
-              Number(row.lossNumber) +
-              Number(row.lossNumberUnqualified) +
-              Number(row.retainedSampleQuantity) +
-              Number(row.retainedSampleUnqualified)
+            getSampleQuantityCount: this.form.sampleQuantity
           },
           type
         );
       },
       experimentReportDone(data) {
-        console.log(data)
+        console.log(data);
         let index = this.tableData.findIndex((item) => item.id == data.id);
         this.$set(this.tableData, index, data);
-        console.log(this.tableData)
+        console.log(this.tableData);
 
         // this.initData();
       },
@@ -819,8 +809,9 @@
           this.title = '检测项受托单';
         }
         if (type == 'report') {
-          let data = {  ...row,...workData };
-          data.sampleQuantity = row.sampleQuantity || data.remainingSampleCount;
+          let data = { ...row, ...workData };
+          console.log(data, workData);
+          data.sampleQuantity = row.sampleQuantity || data.workSampleCount;
           data.sampleNoQualifiedNumber = row.sampleNoQualifiedNumber || 0;
           data.sampleQualifiedNumber =
             row.sampleQualifiedNumber ||
@@ -839,11 +830,11 @@
               item.executionMethod || 1
             );
           });
-          if (row.sampleQuantity) {
-            this.form.remainingSampleCount =
-              Number(row.sampleQuantity) +
-              Number(this.form.remainingSampleCount);
-          }
+          // if (row.sampleQuantity) {
+          //   this.form.remainingSampleCount =
+          //     Number(row.sampleQuantity) +
+          //     Number(this.form.remainingSampleCount);
+          // }
         } else {
           this.$set(this, 'form', JSON.parse(JSON.stringify(workData)));
           this.$set(
@@ -860,10 +851,10 @@
           );
 
           this.tableData = JSON.parse(JSON.stringify(list));
-          if (this.form.qualityWorkOrderId) {
-            this.form.remainingSampleCount =
-              this.form.sampleQuantity + this.form.remainingSampleCount;
-          }
+          // if (this.form.qualityWorkOrderId) {
+          //   this.form.remainingSampleCount =
+          //     this.form.sampleQuantity + this.form.remainingSampleCount;
+          // }
         }
 
         this.visible = true;
@@ -877,8 +868,8 @@
         if (this.form.sampleQuantity < 0) {
           this.form.sampleQuantity = 0;
         }
-        if (this.form.sampleQuantity > this.form.remainingSampleCount) {
-          this.form.sampleQuantity = this.form.remainingSampleCount;
+        if (this.form.sampleQuantity > this.form.workSampleCount) {
+          this.form.sampleQuantity = this.form.workSampleCount;
         }
         if (
           this.form.sampleQuantity <

+ 2 - 1
src/views/inspectionWork/components/inspectionWorkList.vue

@@ -160,7 +160,8 @@
           style="display: inline-block; margin-left: 5px"
           v-if="
             row.status == 1 &&
-            $hasPermission('qms:quality_work_order:qualityReport')
+            $hasPermission('qms:quality_work_order:qualityReport') &&
+            clientEnvironmentId != 7
           "
           text="检测报告"
           :businessId="row.id"

+ 75 - 10
src/views/inspectionWork/details.vue

@@ -174,7 +174,13 @@
         <el-tab-pane label="样品信息" name="2">
           <el-form label-width="130px">
             <el-row>
-              <el-col :span="6" v-if="showArrange == '1'">
+              <el-col
+                :span="6"
+                v-if="
+                  showArrange == '1' ||
+                  (showArrange == '2' && form.qualityModeName != '抽检')
+                "
+              >
                 <el-form-item label="样品合格数:">
                   <el-input disabled v-model="form.sampleQualifiedNumber"
                     ><template slot="append">{{
@@ -183,7 +189,13 @@
                   >
                 </el-form-item>
               </el-col>
-              <el-col :span="6" v-if="showArrange == '1'">
+              <el-col
+                :span="6"
+                v-if="
+                  showArrange == '1' ||
+                  (showArrange == '2' && form.qualityModeName != '抽检')
+                "
+              >
                 <el-form-item label="样品不合格数:">
                   <el-input disabled v-model="form.sampleNoQualifiedNumber"
                     ><template slot="append">{{
@@ -360,6 +372,14 @@
                 :datasource="taskMonadList"
                 :needPage="false"
               >
+                <template v-slot:code="{ row }">
+                  <el-link
+                    type="primary"
+                    :underline="false"
+                    @click="report(row, 'inspectionProjectTask')"
+                    >{{ row.code }}</el-link
+                  >
+                </template>
               </ele-pro-table>
             </el-tab-pane>
             <el-tab-pane label="检测请托单" name="5">
@@ -369,6 +389,14 @@
                 :datasource="requestEntrustList"
                 :needPage="false"
               >
+                <template v-slot:code="{ row }">
+                  <el-link
+                    type="primary"
+                    :underline="false"
+                    @click="report(row, 'inspectionProjectRequest')"
+                    >{{ row.code }}</el-link
+                  >
+                </template>
               </ele-pro-table>
             </el-tab-pane>
           </el-tabs>
@@ -404,6 +432,12 @@
     </el-card>
     <sampleListDialog ref="detailRef"></sampleListDialog>
     <experimentReport ref="experimentReport"></experimentReport>
+    <sampleReport ref="sampleReportRef" @reload="reload"></sampleReport>
+    <!-- 编辑弹窗 -->
+    <inspectionProjectReport
+      ref="inspectionProjectReportRef"
+      @reload="reload"
+    />
   </div>
 </template>
 
@@ -417,10 +451,18 @@
   import { recordingMethodList } from '@/utils/util.js';
   import sampleListDialog from './components/sampleListDialog.vue';
   import experimentReport from './components/experimentReport.vue';
-
+  import inspectionProjectReport from '@/views/inspectionWork/components/inspectionProjectReport.vue';
+  import sampleReport from '@/views/inspectionWork/components/sampleReport.vue';
+  import { getById as getByIdProjectTask } from '@/api/inspectionProjectTask';
+  import { getById as getByIdProjectRequest } from '@/api/inspectionProjectRequest';
   export default {
     mixins: [detailMixins],
-    components: { sampleListDialog, experimentReport },
+    components: {
+      sampleListDialog,
+      experimentReport,
+      inspectionProjectReport,
+      sampleReport
+    },
     data() {
       return {
         activeName: '1',
@@ -431,8 +473,8 @@
         sourceData3: [],
         sourceData4: [],
         sourceData5: [],
-        taskMonadList:[],
-        requestEntrustList:[],
+        taskMonadList: [],
+        requestEntrustList: [],
         disposeTypeList: [],
         form: {},
         showArrange: '0',
@@ -483,7 +525,30 @@
           }
         });
       },
-
+      /* 报工 */
+      async report(row, type) {
+        let api =
+          type == 'inspectionProjectTask'
+            ? getByIdProjectTask
+            : getByIdProjectRequest;
+        const res = await api(row.id);
+        if (row.recordingMethod == 1) {
+          this.$refs.inspectionProjectReportRef.open(
+            {
+              workData: {
+                ...res.data,
+                measureUnit: row.measureUnit,
+                workSampleCount: res.sampleTotal
+              },
+              list: res.data.templateList
+            },
+            'detail',
+            type
+          );
+        } else {
+          this.$refs.sampleReportRef.open(res.data, 'detail', type);
+        }
+      },
       async getUserList(params) {
         if (!params.groupId) return;
         try {
@@ -594,9 +659,9 @@
         this.$set(this.form, 'remark', res.remark);
         this.sourceData3 = res.templateList || [];
         this.sourceData1 = res.qualityInventoryList || [];
-        this.taskMonadList=res.taskMonadList||[]
-        this.requestEntrustList=res.requestEntrustList||[]
-        
+        this.taskMonadList = res.taskMonadList || [];
+        this.requestEntrustList = res.requestEntrustList || [];
+
         let name = this.$route.query.name;
         // const result = name == '计划' ? res.qualityWorkOrderDetailVO : res;
         let result = {};

+ 39 - 14
src/views/inspectionWork/edit.vue

@@ -81,7 +81,13 @@
           </el-col>
           <el-col :span="6">
             <el-form-item label="样品合格率:" prop="sampleQualificationRate">
-              <el-input v-model="form.sampleQualificationRate" disabled />
+              <el-input
+                v-model="form.sampleQualificationRate"
+                disabled
+                type="number"
+              >
+                <template slot="append">%</template>
+              </el-input>
             </el-form-item>
           </el-col>
           <el-col :span="6">
@@ -89,7 +95,13 @@
               label="样品不合格率:"
               prop="sampleNoQualificationRate"
             >
-              <el-input v-model="form.sampleNoQualificationRate" disabled />
+              <el-input
+                v-model="form.sampleNoQualificationRate"
+                disabled
+                type="number"
+              >
+                <template slot="append">%</template>
+              </el-input>
             </el-form-item>
           </el-col>
         </el-row>
@@ -598,7 +610,13 @@
         this.$nextTick(() => {
           let qualityResults = this.form.qualityResults;
           let showArrange = this.$refs.baseInfoRefs.showArrange;
-          if (showArrange == '1') return;
+          if (
+            showArrange == '1' ||
+            (showArrange == '2' && this.form.qualityMode != '2')
+          ) {
+            return;
+          }
+
           if (qualityResults == null || qualityResults == undefined) {
             for (let i = 0; i < list.length; i++) {
               let el = list[i];
@@ -703,7 +721,10 @@
         // }
         // this.$nextTick(() => {
         let showArrange = this.$refs.baseInfoRefs?.showArrange;
-        if (showArrange != '1') {
+        if (
+          showArrange != '1' ||
+          (showArrange == '2' && this.form.qualityMode == '2')
+        ) {
           if (sampleQuantity == sampleQualifiedNumber) {
             this.$set(this.form, 'qualificationRate', '100%');
             this.$set(this.form, 'noQualificationRate', '0');
@@ -759,7 +780,10 @@
         }
         this.$set(this.form, 'qualifiedNumber', qualifiedNumber);
         this.$set(this.form, 'noQualifiedNumber', noQualifiedNumber);
-        if (showArrange != '1') {
+        if (
+          showArrange != '1' ||
+          (showArrange == '2' && this.form.qualityMode == '2')
+        ) {
           return;
         }
 
@@ -976,9 +1000,9 @@
       //检测项报工
       inspectionProjectReport({ index, list }) {
         this.$nextTick(() => {
-          if (this.form.taskMonadInfo) {
-            delete this.form.taskMonadInfo.remainingSampleCount;
-          }
+          // if (this.form.taskMonadInfo) {
+          //   delete this.form.taskMonadInfo.remainingSampleCount;
+          // }
           this.$refs.inspectionProjectReportRef.open(
             {
               workData: {
@@ -999,7 +1023,8 @@
                 accessory: this.form.accessory,
                 qualityNames: this.form.qualityNames,
                 qualityTimeEnd: this.form.qualityTimeEnd,
-                remainingSampleCount: this.form.remainingSampleCount,
+                workSampleCount: this.form.sampleQuantity,
+                // remainingSampleCount: this.form.remainingSampleCount,
                 measureUnit: this.sampleList[0]?.measureUnit
               },
               row: this.form.taskMonadInfo || {},
@@ -1016,8 +1041,8 @@
           ...this.schemeList.filter((item) => item.correlationId)
         ];
         data.type = 2;
-        this.form.remainingSampleCount =
-          data.remainingSampleCount - data.sampleQuantity;
+        // this.form.remainingSampleCount =
+        //   data.remainingSampleCount - data.sampleQuantity;
         this.form.taskMonadInfo = data;
         this.form.hours = data.hours;
         console.log(this.schemeList, 'this.schemeList');
@@ -1549,9 +1574,9 @@
           this.getProSamList(this.packingList);
         }
         if (this.form.recordingMethod != 1) {
-           this.$nextTick(()=>{
-             this.countQualityResults();
-           })
+          this.$nextTick(() => {
+            this.countQualityResults();
+          });
         }
       },
       async queryQualityTempleContent() {

+ 46 - 7
src/views/inspectionWork/mixins/detailMixins.js

@@ -154,12 +154,11 @@ export default {
           prop: 'groupName',
           label: '接收人部门'
         },
-        
+
         {
           prop: 'qualityType',
           label: '类型'
-        },
-        
+        }
       ],
       disposeTypeMap: {
         1: '返工',
@@ -563,6 +562,7 @@ export default {
         },
         {
           prop: 'code',
+          slot:'code',
           label: '请托单号',
           showOverflowTooltip: true,
           align: 'center',
@@ -704,6 +704,7 @@ export default {
         },
         {
           prop: 'code',
+          slot:'code',
           label: '检测任务单号',
           showOverflowTooltip: true,
           align: 'center',
@@ -1229,7 +1230,7 @@ export default {
     isSampleQuantity(item, index) {
       // this.resetData(item, index, ['qualifiedQuantity', 'noQualifiedQuantity']);
       if (Number(item.sampleQuantity) > this.getSampleQuantityCount) {
-        this.$message.error('样品数量不能大于当前检测剩余样品数');
+        this.$message.error('样品数量不能大于当前检测样品数');
         this.$set(
           this.tableData[index],
           'sampleQuantity',
@@ -1277,12 +1278,16 @@ export default {
       };
 
       if (Number(item[key]) > Number(item[keyObj.key])) {
+        this.$message.close();
+
         this.$message.error(
           title + keyObj.title + '不能大于样品' + keyObj.title
         );
         this.$set(this.tableData[index], key, 0);
       }
       if (keyObj.numTotal > item[keyObj.key]) {
+        this.$message.close();
+
         this.$message.error(
           title +
             keyObj.title +
@@ -1296,11 +1301,16 @@ export default {
         this.$set(this.tableData[index], key, 0);
       }
       if (item[key] - (this.curretNum || 0) > this.getSampleQuantityCount) {
-        this.$message.error(
-          title + keyObj.title + '不能大于当前检测剩余样品数'
-        );
+        this.$message.close();
+        this.$message.error(title + keyObj.title + '不能大于当前检测样品数');
+        this.$set(this.tableData[index], key, 0);
+      }
+      if (Number(this.getTableDataTotal()) > this.getSampleQuantityCount) {
+        this.$message.close();
+        this.$message.error('留样数与损耗数之和不能大于当前检测样品数');
         this.$set(this.tableData[index], key, 0);
       }
+      // console.log(,'getTableDataTotal')
       this.curretNum = this.tableData[index][key];
       this.initData();
     },
@@ -1323,6 +1333,35 @@ export default {
           this.form[key] = this.form[key] / 100;
         });
       });
+    },
+
+    // 计算 tableData 中 keyArr 字段的总和
+    getTableDataTotal() {
+      const total = {
+        lossNumber: 0,
+        lossNumberUnqualified: 0,
+        retainedSampleQuantity: 0,
+        retainedSampleUnqualified: 0,
+        totalSum: 0
+      };
+
+      this.tableData.forEach((item) => {
+        this.keyArr.forEach((key) => {
+          total[key] = total[key] * 100;
+          total[key] += Number(item[key] * 100) || 0;
+          total[key] = total[key] / 100;
+        });
+      });
+
+      // 计算四个字段的总和
+      total.totalSum = (
+        total.lossNumber +
+        total.lossNumberUnqualified +
+        total.retainedSampleQuantity +
+        total.retainedSampleUnqualified
+      ).toFixed(2);
+
+      return total.totalSum;
     }
   }
 };

+ 1 - 1
vue.config.js

@@ -38,7 +38,7 @@ module.exports = {
         // target: 'http://192.168.1.30:18086',
         // target: 'http://192.168.1.251:18186',
         // target: 'http://124.71.68.31:50001',
-        target: 'http://192.168.1.3:18086',
+        target: 'http://192.168.1.251:18086',
         // target: 'http://192.168.1.3:18086', // 付丽
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {