Browse Source

fix(质检报告): 修复报告审批状态判断并完善报告详情显示

liujt 6 months ago
parent
commit
c3e933499b

+ 44 - 9
src/views/inspectionReport/template/inspection_report1.vue

@@ -8,7 +8,7 @@
         :before-close="cancel"
         :before-close="cancel"
         :maxable="true"
         :maxable="true"
     >   
     >   
-        <!-- <div class="switch">
+        <div v-if="isView && processInstanceId" class="switch">
             <div class="switch_left">
             <div class="switch_left">
                 <ul>
                 <ul>
                 <li
                 <li
@@ -21,7 +21,7 @@
                 </li>
                 </li>
                 </ul>
                 </ul>
             </div>
             </div>
-        </div> -->
+        </div>
         <div v-show="activeComp === 'main'" id="printSection" style="padding: 20px; background-color: white;">
         <div v-show="activeComp === 'main'" id="printSection" style="padding: 20px; background-color: white;">
             <h1 style="text-align: center; font-size: 24px; margin-bottom: 20px; font-weight: bold;">质检报告</h1>
             <h1 style="text-align: center; font-size: 24px; margin-bottom: 20px; font-weight: bold;">质检报告</h1>
             
             
@@ -221,8 +221,8 @@
             </div>
             </div>
         </div>
         </div>
         <bpmDetail
         <bpmDetail
-            v-if="activeComp === 'bpm' && form.processInstance.id"
-            :id="form.processInstance.id"
+            v-if="activeComp === 'bpm' && processInstanceId"
+            :id="processInstanceId"
         ></bpmDetail>
         ></bpmDetail>
         <template v-slot:footer>
         <template v-slot:footer>
             <el-button v-if="isView" type="primary" @click="print" v-loading="loading">打印</el-button>
             <el-button v-if="isView" type="primary" @click="print" v-loading="loading">打印</el-button>
@@ -235,6 +235,7 @@
 <script>
 <script>
 import { queryInspectionReportData, queryInspectionReportList, generateReport } from '@/api/inspectionReport';
 import { queryInspectionReportData, queryInspectionReportList, generateReport } from '@/api/inspectionReport';
 import bpmDetail from '@/views/bpm/processInstance/detail.vue';
 import bpmDetail from '@/views/bpm/processInstance/detail.vue';
+import { getDetailById } from '@/api/inspectionWork/index';
 export default {
 export default {
     name: 'QualityReport',
     name: 'QualityReport',
     props: {
     props: {
@@ -274,6 +275,8 @@ export default {
                 { key: 'bpm', name: '流程详情' }
                 { key: 'bpm', name: '流程详情' }
             ],
             ],
             activeComp: 'main',
             activeComp: 'main',
+            processInstanceId: '',
+            reportApprovalTaskVos: [],
         }
         }
     },
     },
     watch: {
     watch: {
@@ -281,6 +284,7 @@ export default {
             handler: function (val) {
             handler: function (val) {
                 console.log('visible~~~', val);
                 console.log('visible~~~', val);
                 if (val) {
                 if (val) {
+                    // this.getProcessInstance();
                     this.open(this.row, this.item);
                     this.open(this.row, this.item);
                 }
                 }
             },
             },
@@ -293,18 +297,35 @@ export default {
     },
     },
     methods: {
     methods: {
         /* 打开质检报告 */
         /* 打开质检报告 */
-        open(row, item) {
+        async open(row, item) {
             this.currentRow = row;
             this.currentRow = row;
             this.templateItem = item || row;
             this.templateItem = item || row;
             console.log('currentRow~~~', this.currentRow, this.templateItem);
             console.log('currentRow~~~', this.currentRow, this.templateItem);
+
+            try {
+                const res =await getDetailById(this.row.id)
+                this.processInstanceId = res.data.reportProcessInstanceId;
+                this.reportApprovalTaskVos = res.data.reportApprovalTaskVos
+
+            } catch (error) {
+                console.log('error~~~~', error);
+            }
+
             // this.visible = true;
             // this.visible = true;
             if(this.currentRow.reportTemplateJson?.basicInfoData) {
             if(this.currentRow.reportTemplateJson?.basicInfoData) {
                 this.basicInfoData = this.currentRow.reportTemplateJson.basicInfoData || {};
                 this.basicInfoData = this.currentRow.reportTemplateJson.basicInfoData || {};
                 this.inspectionItems = this.currentRow.reportTemplateJson.inspectionItems || [];
                 this.inspectionItems = this.currentRow.reportTemplateJson.inspectionItems || [];
 
 
+                const reviewTime = this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.length - 2]?.endTime?.split(' ')[0] || '';
+                const approvedDate = this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.length - 3]?.endTime?.split(' ')[0] || '';
+                const reviewer = this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.length - 2]?.approvalUserName || '';
+                const checker = this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.length - 3]?.approvalUserName || '';
+
                 this.$set(this.basicInfoData, 'inspectionTime', this.basicInfoData.inspectionTime?.split(' ')[0] || '');
                 this.$set(this.basicInfoData, 'inspectionTime', this.basicInfoData.inspectionTime?.split(' ')[0] || '');
-                this.$set(this.basicInfoData, 'reviewTime', this.basicInfoData.reviewTime?.split(' ')[0] || '');
-                this.$set(this.basicInfoData, 'approvedDate', this.basicInfoData.approvedDate?.split(' ')[0] || '');
+                this.$set(this.basicInfoData, 'reviewTime', this.basicInfoData.reviewTime?.split(' ')[0] || reviewTime || '');
+                this.$set(this.basicInfoData, 'approvedDate', this.basicInfoData.approvedDate?.split(' ')[0] || approvedDate || '');
+                this.$set(this.basicInfoData, 'reviewer', this.basicInfoData.reviewer || reviewer || '');
+                this.$set(this.basicInfoData, 'checker', this.basicInfoData.checker || checker || '');
             } else {
             } else {
                 this.getBasicInfo();
                 this.getBasicInfo();
                 this.getInspectionItems();
                 this.getInspectionItems();
@@ -313,9 +334,17 @@ export default {
         getBasicInfo() {
         getBasicInfo() {
             queryInspectionReportData(this.currentRow.id).then(res => {
             queryInspectionReportData(this.currentRow.id).then(res => {
                 this.basicInfoData = res;
                 this.basicInfoData = res;
+                
+                const reviewTime = this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.length - 2]?.endTime?.split(' ')[0] || '';
+                const approvedDate = this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.length - 3]?.endTime?.split(' ')[0] || '';
+                const reviewer = this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.length - 2]?.approvalUserName || '';
+                const checker = this.reportApprovalTaskVos?.[this.reportApprovalTaskVos.length - 3]?.approvalUserName || '';
+
                 this.$set(this.basicInfoData, 'inspectionTime', this.basicInfoData.inspectionTime?.split(' ')[0] || '');
                 this.$set(this.basicInfoData, 'inspectionTime', this.basicInfoData.inspectionTime?.split(' ')[0] || '');
-                this.$set(this.basicInfoData, 'reviewTime', this.basicInfoData.reviewTime?.split(' ')[0] || '');
-                this.$set(this.basicInfoData, 'approvedDate', this.basicInfoData.approvedDate?.split(' ')[0] || '');
+                this.$set(this.basicInfoData, 'reviewTime', this.basicInfoData.reviewTime?.split(' ')[0] || reviewTime || '');
+                this.$set(this.basicInfoData, 'approvedDate', this.basicInfoData.approvedDate?.split(' ')[0] || approvedDate || '');
+                this.$set(this.basicInfoData, 'reviewer', this.basicInfoData.reviewer || reviewer || '');
+                this.$set(this.basicInfoData, 'checker', this.basicInfoData.checker || checker || '');
             });
             });
         },
         },
         getInspectionItems() {
         getInspectionItems() {
@@ -323,6 +352,12 @@ export default {
                 this.inspectionItems = res;
                 this.inspectionItems = res;
             });
             });
         },
         },
+        getProcessInstance() {
+            getDetailById(this.row.id).then(res => {
+                console.log('res~~~~', res);
+                this.processInstanceId = res.data.reportProcessInstanceId;
+            });
+        },
         cancel() {
         cancel() {
             // this.visible = false;
             // this.visible = false;
             this.$emit('update:visible', false);
             this.$emit('update:visible', false);

+ 1 - 1
src/views/inspectionWork/index.vue

@@ -136,7 +136,7 @@
             v-if="
             v-if="
                 row.status == 1 &&
                 row.status == 1 &&
                 isReportApproval == 1 &&
                 isReportApproval == 1 &&
-                (row.reportApprovalStatus || !isEmptyObject(row.reportTemplateJson)) &&
+                (row.reportApprovalStatus && !isEmptyObject(row.reportTemplateJson)) &&
                 $hasPermission('qms:quality_work_order:generateReport')
                 $hasPermission('qms:quality_work_order:generateReport')
               "
               "
             type="primary"
             type="primary"