Bläddra i källkod

feat: 新增记录方法编辑功能

yusheng 2 månader sedan
förälder
incheckning
4c4f166064

+ 8 - 0
src/api/inspectionWork/index.js

@@ -29,6 +29,14 @@ export async function update(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+// 编辑记录方法
+export async function updateRecordingMethod(data) {
+  const res = await request.post(`/qms/quality_work_order/updateRecordingMethod`, data);
+  if (res.data.code == 0) {
+    return res.data.message;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 
 export async function getById(id) {
   const res = await request.get(`/qms/quality_work_order/getById/${id}`);

+ 49 - 6
src/views/inspectionProjectTask/components/inspectionProjectTaskSend.vue

@@ -28,6 +28,26 @@
       class="el-form-box"
       label-width="120px"
     >
+      <el-row>
+        <el-col :span="8">
+          <el-form-item label="记录方法:" prop="recordingMethod">
+            <el-select
+              style="width: 100%"
+              v-model="recordingMethod"
+              placeholder="请选择"
+              :disabled="isDisabled"
+              @change="recordingMethodChange"
+            >
+              <el-option
+                v-for="item in recordingMethodList"
+                :label="item.label"
+                :value="item.value"
+                :key="item.value"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+      </el-row>
       <el-row>
         <el-col :span="8">
           <el-form-item
@@ -133,7 +153,7 @@
     qualityInspectionItemDispatching,
     qualityInspectionItemRequest
   } from '@/api/inspectionProjectTask';
-  import { getById } from '@/api/inspectionWork';
+  import { getById, updateRecordingMethod } from '@/api/inspectionWork';
   import {
     getById as getQualityInspectionItemById,
     updateRequestentrust
@@ -141,6 +161,8 @@
   import { inspectionProjectStatus } from '@/enum/dict.js';
   import deptSelect from '@/components/CommomSelect/dept-select.vue';
   import { getUserPage } from '@/api/system/organization';
+  import { recordingMethodList } from '@/utils/util.js';
+
   const defaultForm = {
     id: null,
     executeDeptId: '',
@@ -161,12 +183,14 @@
     data() {
       return {
         type: 1,
+        recordingMethodList,
         pgaeName: '',
         form: { ...defaultForm },
         executorList: [],
         selection: [],
         list: [],
-
+        templateLis: [],
+        qualitySampleList: [],
         rules: {
           executeDeptId: [
             { required: true, message: '请选择部门', trigger: 'blur' }
@@ -195,6 +219,16 @@
       };
     },
     computed: {
+      isDisabled() {
+        if (
+          this.isUpdate == 1 ||
+          this.list.filter((item) => item.status != 0).length
+        ) {
+          return true;
+        }
+
+        return false;
+      },
       tableColumns() {
         return this.recordingMethod == 1
           ? [
@@ -482,15 +516,20 @@
         }
         //获取工单质检方案
         await getById(this.form.qualityWorkOrderId).then((res) => {
-          this.list =
-            row.recordingMethod == 1
-              ? res.data.templateList
-              : res.data.qualitySampleList;
+          this.templateList = res.data.templateList;
+          this.qualitySampleList = res.data.qualitySampleList;
+          this.recordingMethodChange();
           this.$nextTick(() => {
             this.$refs.table.setSelectedRowKeys(this.templateIdS);
           });
         });
       },
+      recordingMethodChange() {
+        this.list =
+          this.recordingMethod == 1
+            ? this.templateList
+            : this.qualitySampleList;
+      },
       searchDeptNodeClick(info, row) {
         let depKey = this.type == 1 ? 'executeDeptId' : 'receiveDeptId';
         let depNameKey = this.type == 1 ? 'executeDeptName' : 'receiveDeptName';
@@ -573,6 +612,10 @@
           })
             .then((msg) => {
               this.loading = false;
+              updateRecordingMethod({
+                id: this.form.qualityWorkOrderId,
+                recordingMethod: this.recordingMethod
+              });
               this.$emit('reload');
               this.cancel();
             })

+ 81 - 45
src/views/inspectionWork/components/experimentReport.vue

@@ -415,10 +415,28 @@
   import ProductModal from '@/views/inspectionProject/components/ProductModal.vue';
   import imgList from '@/components/upload/imgList.vue';
   import detailMixins from '../mixins/detailMixins';
-
+  const defForm = {
+    code: '',
+    correlationId: '',
+    consumablesJson: [],
+    toolJson: [],
+    attachmentUrl: [],
+    experimentalTime: '',
+    imgUrl: [],
+    procedureJson: null,
+    qualityStandardName: '',
+    qualityStandardId: '',
+    processRequirementsJson: '',
+    recordJson: null,
+    qualityWorkOrderId: '',
+    results: 1,
+    resultsDescription: '',
+    experimentEquipmentList: []
+  };
   export default {
     components: { experimentationProcess, releaseRules, ProductModal, imgList },
-    props: {},
+
+    props: { pageName: '' },
     mixins: [dictMixins, detailMixins],
 
     data() {
@@ -430,22 +448,7 @@
         type: '',
         getSampleQuantityCount: 0,
         form: {
-          code: '',
-          correlationId: '',
-          consumablesJson: [],
-          toolJson: [],
-          attachmentUrl: [],
-          experimentalTime: '',
-          imgUrl: [],
-          procedureJson: null,
-          qualityStandardName: '',
-          qualityStandardId: '',
-          processRequirementsJson: '',
-          recordJson: null,
-          qualityWorkOrderId: '',
-          results: 1,
-          resultsDescription: '',
-          experimentEquipmentList: []
+          ...defForm
         },
         laboratoryList: [],
         unitColumns: [
@@ -629,34 +632,51 @@
             }
           });
         } else {
-          this.form.correlationId = row.id;
-          this.form.qualityStandardName = row.qualityStandardName;
-          this.form.qualityStandardId = row.qualityStandardId;
-          this.form.qualityWorkOrderId = row.qualityWorkOrderId;
-          this.form.processRequirementsJson = '';
-          if (row.symbol) {
-            this.form.processRequirementsJson += row.symbol;
-          }
-          if (row.textType == 3) {
-            this.form.processRequirementsJson +=
-              row.minValue + '-' + row.maxValue;
+          if (row.experiment && row.experiment.correlationId) {
+            this.form = JSON.parse(JSON.stringify(row.experiment));
+            this.$nextTick(() => {
+              if (this.form.procedureJson.tempJson) {
+                this.$refs.experimentationProcess1.init(
+                  this.form.procedureJson.tempJson
+                );
+              }
+              if (this.form.recordJson.tempJson) {
+                this.$refs.experimentationProcess2.init(
+                  this.form.recordJson.tempJson
+                );
+              }
+            });
           } else {
-            this.form.processRequirementsJson += row.defaultValue;
-          }
-          if (row.unitName) {
-            this.form.processRequirementsJson += row.unitName;
-          }
-
-          this.$nextTick(async () => {
-            if (row.procedureJson.tempJson) {
-              this.$refs.experimentationProcess1.init(
-                row.procedureJson.tempJson
-              );
+            this.form.correlationId = row.id;
+            this.form.qualityStandardName = row.qualityStandardName;
+            this.form.qualityStandardId = row.qualityStandardId;
+            this.form.qualityWorkOrderId = row.qualityWorkOrderId;
+            this.form.processRequirementsJson = '';
+            if (row.symbol) {
+              this.form.processRequirementsJson += row.symbol;
             }
-            if (row.recordJson.tempJson) {
-              this.$refs.experimentationProcess2.init(row.recordJson.tempJson);
+            if (row.textType == 3) {
+              this.form.processRequirementsJson +=
+                row.minValue + '-' + row.maxValue;
+            } else {
+              this.form.processRequirementsJson += row.defaultValue;
             }
-          });
+            if (row.unitName) {
+              this.form.processRequirementsJson += row.unitName;
+            }
+            this.$nextTick(() => {
+              if (row.procedureJson.tempJson) {
+                this.$refs.experimentationProcess1.init(
+                  row.procedureJson.tempJson
+                );
+              }
+              if (row.recordJson.tempJson) {
+                this.$refs.experimentationProcess2.init(
+                  row.recordJson.tempJson
+                );
+              }
+            });
+          }
         }
 
         this.getFactoryarea();
@@ -759,13 +779,22 @@
               tempJson: JSON.stringify(recordJson)
             };
           }
+          let row = JSON.parse(JSON.stringify(this.tableData[0]));
+          if (!this.pageName) {
+            row.experiment = data;
+            this.$emit('done', row);
+            this.handleClose();
+
+            return;
+          }
           let api = data.id ? update : save;
           api(data)
             .then((msg) => {
               this.loading = false;
               this.$message.success(msg);
+              row.experimentId = msg;
               this.handleClose();
-              this.$emit('done', this.tableData[0]);
+              this.$emit('done', row);
             })
             .catch((e) => {
               this.loading = false;
@@ -773,7 +802,14 @@
         });
       },
       handleClose() {
-        this.visible = false;
+        this.form = {
+          ...defForm
+        };
+        this.$nextTick(() => {
+          this.$refs.experimentationProcess1.init('{}');
+          this.$refs.experimentationProcess2.init('{}');
+          this.visible = false;
+        });
       }
     }
   };

+ 5 - 1
src/views/inspectionWork/components/inspectionProjectReport.vue

@@ -269,6 +269,7 @@
     <experimentReport
       ref="experimentReport"
       @done="experimentReportDone"
+      :pageName="pageName"
     ></experimentReport>
     <wokePopup ref="wokePopupRef"></wokePopup>
   </ele-modal>
@@ -799,9 +800,12 @@
         );
       },
       experimentReportDone(data) {
+        console.log(data)
         let index = this.tableData.findIndex((item) => item.id == data.id);
         this.$set(this.tableData, index, data);
-        this.initData();
+        console.log(this.tableData)
+
+        // this.initData();
       },
 
       async open({ workData, row, list }, type, pageName) {

+ 55 - 8
src/views/inspectionWork/edit.vue

@@ -146,14 +146,28 @@
           </el-col>
           <el-col :span="6">
             <el-form-item label="记录方法:" prop="recordingMethod">
-              <el-input
+              <el-select
+                style="width: 100%"
+                v-model="form.recordingMethod"
+                placeholder="请选择"
+                :disabled="isDisabled"
+                @change="recordingMethodChange"
+              >
+                <el-option
+                  v-for="item in recordingMethodList"
+                  :label="item.label"
+                  :value="item.value"
+                  :key="item.value"
+                ></el-option>
+              </el-select>
+              <!-- <el-input
                 disabled
                 :value="
                   recordingMethodList.find(
                     (item) => item.value == form.recordingMethod
                   )?.label
                 "
-              />
+              /> -->
             </el-form-item>
           </el-col>
           <el-col :span="6">
@@ -361,6 +375,17 @@
     },
     mixins: [dictMixins],
     computed: {
+      isDisabled() {
+        if (
+          this.form.taskMonadList?.length ||
+          this.form.requestEntrustList?.length ||
+          this.form.isUpdate == 1
+        ) {
+          return true;
+        }
+
+        return false;
+      },
       sampletypeVal() {
         return (row) => {
           if (row == 1) {
@@ -556,6 +581,15 @@
       }
     },
     methods: {
+      recordingMethodChange() {
+        this.$nextTick(() => {
+          if (this.form.recordingMethod != 1) {
+            this.$refs.tabsRef.$refs.showSampleListTable.doLayout();
+            this.countQualityResults();
+          }
+        });
+      },
+
       //合格与不合格数变化处理逻辑
       quantityCalculation(val) {
         this.$refs.tabsRef.setSampleList(val, this.form.total);
@@ -986,6 +1020,7 @@
           data.remainingSampleCount - data.sampleQuantity;
         this.form.taskMonadInfo = data;
         this.form.hours = data.hours;
+        console.log(this.schemeList, 'this.schemeList');
       },
       // 切换检验方式为全检后生成样品
       changeGetSampleList(list) {
@@ -1514,7 +1549,9 @@
           this.getProSamList(this.packingList);
         }
         if (this.form.recordingMethod != 1) {
-          this.countQualityResults();
+           this.$nextTick(()=>{
+             this.countQualityResults();
+           })
         }
       },
       async queryQualityTempleContent() {
@@ -1551,11 +1588,17 @@
             this.type == 'add' ? save : this.type == 'edit' ? update : '';
 
           this.form.qualityTimeStart = this.qualityTimeStart;
-          this.form.qualityId = this.form.qualityIdList.join(',');
+          this.form.qualityId = this.form.qualityIdList.toString();
 
           delete this.form['qualityTimeEnd'];
 
-          this.form.executeUserId = this.form.executeUserIdList.join(',');
+          this.form.executeUserId = this.form.executeUserIdList.toString();
+          this.form.isUpdate = 1;
+          this.schemeList.forEach((item) => {
+            if (item.executionMethod != 2 || this.form.recordingMethod != 1) {
+              item.experiment = null;
+            }
+          });
           let params = {
             ...this.form,
             sampleList: this.sampleList,
@@ -1740,7 +1783,7 @@
 
           this.form.qualityTimeEnd = this.getNowTime();
           this.form.qualityTimeStart = this.qualityTimeStart;
-          this.form.qualityId = this.form.qualityIdList.join(',');
+          this.form.qualityId = this.form.qualityIdList.toString();
           this.form.executeUserIdList = this.form.executeUserIdList || [];
           if (
             !this.form.executeUserIdList.find(
@@ -1757,10 +1800,14 @@
                   this.$store.state.user.info.name
                 : this.$store.state.user.info.name;
           }
-          this.form.executeUserId = this.form.executeUserIdList.join(',');
+          this.form.executeUserId = this.form.executeUserIdList.toString();
 
           // this.form.qualityIdList = [];
-
+          this.schemeList.forEach((item) => {
+            if (item.executionMethod != 2 || this.form.recordingMethod != 1) {
+              item.experiment = null;
+            }
+          });
           let params = {
             ...this.form,
             sampleList: this.sampleList,