Преглед изворни кода

优化质检报告生成与审批流程,新增报告模板选择功能并支持不同类型质检报告展示

yusheng пре 4 месеци
родитељ
комит
0f591e54e6

+ 28 - 11
src/api/inspectionReport/index.js

@@ -2,7 +2,9 @@ import request from '@/utils/request';
 
 // 列表
 export async function getList(params) {
-  const res = await request.get('/qms/quality_work_order/pageByReport', { params });
+  const res = await request.get('/qms/quality_work_order/pageByReport', {
+    params
+  });
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -10,37 +12,52 @@ export async function getList(params) {
 }
 
 // 质检报告基本信息
-export async function queryInspectionReportData(id) {
-  const res = await request.get(`/qms/quality_work_order/queryInspectionReportData/${id}`);
+export async function queryInspectionReportData({ id, type }) {
+  const res = await request.get(
+    `/qms/quality_work_order/queryInspectionReportData/${id}`,
+    {
+      params: { type }
+    }
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-} 
+}
 
 // 质检报告质检项列表信息
-export async function queryInspectionReportList(id) {
-  const res = await request.get(`/qms/quality_work_order/queryInspectionReportList/${id}`);
+export async function queryInspectionReportList({ id, type }) {
+  const res = await request.get(
+    `/qms/quality_work_order/queryInspectionReportList/${id}`,
+    {
+      params: { type }
+    }
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}  
+}
 
 // 生成/修改质检报告
 export async function generateReport(data) {
-  const res = await request.post(`/qms/quality_work_order/generateReport`, data);
+  const res = await request.post(
+    `/qms/quality_work_order/generateReport`,
+    data
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}  
+}
 
 // 删除质检报告
 export async function deleteReport(id) {
-  const res = await request.delete(`/qms/quality_work_order/deleteReport/${id}`);
+  const res = await request.delete(
+    `/qms/quality_work_order/deleteReport/${id}`
+  );
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}
+}

+ 152 - 6
src/views/inspectionProjectTask/index.vue

@@ -28,8 +28,58 @@
             >{{ row.code }}</el-link
           >
         </template>
+
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
+          <el-dropdown
+            trigger="click"
+            v-if="
+              (!row.reportApprovalStatus || row.reportApprovalStatus == 0) &&
+              isEmptyObject(row.reportTemplateJson) &&
+              $hasPermission('qms:quality_work_order:generateReport')
+            "
+          >
+            <el-link type="primary" :underline="false">生成质检报告</el-link>
+            <el-dropdown-menu slot="dropdown">
+              <el-dropdown-item
+                v-for="item in reportTemplateList"
+                :key="item.id"
+                @click.native="generateReportApproval(row, item)"
+                >{{ item.name
+                }}{{
+                  '(' +
+                  item.versionSymbol +
+                  item.bigVersion +
+                  item.versionMark +
+                  item.smallVersion +
+                  ')'
+                }}</el-dropdown-item
+              >
+            </el-dropdown-menu>
+          </el-dropdown>
+          <el-link
+            v-if="
+              row.reportApprovalStatus &&
+              !isEmptyObject(row.reportTemplateJson) &&
+              $hasPermission('qms:quality_work_order:generateReport')
+            "
+            type="primary"
+            :underline="false"
+            @click="openReport(row)"
+            >查看质检报告</el-link
+          >
+          <!-- 质检报告审批  -->
+          <el-link
+            v-if="
+              !row.reportApprovalStatus &&
+              $hasPermission('qms:quality_work_order:qualityReportApproval')
+            "
+            type="primary"
+            :underline="false"
+            @click="reportApprovalSubmit(row)"
+            >质检报告审批</el-link
+          >
+
           <el-link
             type="primary"
             :underline="false"
@@ -47,9 +97,27 @@
       ref="inspectionProjectReportRef"
       @reload="reload"
     />
-
+    <component
+      :is="targetComponent"
+      ref="targetComponentRef"
+      v-if="targetComponent"
+      :key="targetComponent"
+      :isView="isView"
+      :visible.sync="targetVisible"
+      :row="currentRow"
+      :item="currentItem"
+      @reload="search"
+      :type="type"
+    ></component>
     <sampleReport ref="sampleReportRef" @reload="reload"></sampleReport>
-    <!-- <fileList ref="fileListRef"></fileList> -->
+    <process-submit-dialog
+      api-fun-name="qmsReportApprovalAPI"
+      :processSubmitDialogFlag.sync="processSubmitDialogFlag"
+      :isCloseRefresh="false"
+      v-if="processSubmitDialogFlag"
+      ref="processSubmitDialogRef"
+      @reload="search"
+    ></process-submit-dialog>
   </div>
 </template>
 
@@ -67,19 +135,30 @@
   } from '@/api/inspectionProjectTask';
   import dictMixins from '@/mixins/dictMixins';
   import { recordingMethodList } from '@/utils/util.js';
+  import { getQmsReportTemplatePageList } from '@/api/inspectionWork';
+  import inspection_report1 from '../inspectionReport/template/inspection_report1.vue';
+  import inspection_report2 from '../inspectionReport/template/inspection_report2.vue';
+  import processSubmitDialog from '@/components/processSubmitDialog/processSubmitDialog.vue';
 
   export default {
     components: {
       search,
       inspectionProjectReport,
-      sampleReport
+      sampleReport,
+      inspection_report2,
+      inspection_report1,processSubmitDialog
       // fileList,
       // wokePopup
     },
     mixins: [dictMixins, tabMixins],
     data() {
       return {
+        targetComponent: '',
         cacheKeyUrl: 'qsm-c2e9664a-inspectionProjectTask',
+        reportTemplateList: [],
+        targetVisible: false,
+        processSubmitDialogFlag:false,
+        type: '1',
         // 表格列配置
         columns: [
           {
@@ -268,7 +347,7 @@
           {
             columnKey: 'action',
             label: '操作',
-            width: 220,
+            width: 280,
             align: 'center',
             resizable: false,
             slot: 'action',
@@ -281,6 +360,7 @@
     created() {
       this.requestDict('质检计划类型');
       this.requestDict('取样类型');
+      this.getReportTemplateList();
     },
 
     methods: {
@@ -328,10 +408,76 @@
             'inspectionProjectTask'
           );
         } else {
-          this.$refs.sampleReportRef.open(res.data, type, 'inspectionProjectTask');
+          this.$refs.sampleReportRef.open(
+            res.data,
+            type,
+            'inspectionProjectTask'
+          );
         }
       },
-
+      getReportTemplateList() {
+        getQmsReportTemplatePageList({
+          pageNum: 1,
+          pageSize: 999,
+          isEnabled: 1
+        })
+          .then((res) => {
+            this.reportTemplateList = res.list;
+            console.log('reportTemplateList', this.reportTemplateList);
+          })
+          .catch((err) => {
+            console.error('获取报表模板列表失败:', err);
+            // this.$message.error('获取报表模板列表失败:' + (err.message || '操作异常'));
+          });
+      },
+      generateReportApproval(row, item) {
+        this.targetComponent = item.code;
+        this.isView = false;
+        this.currentRow = row;
+        this.currentItem = item;
+        // this.$refs.targetComponentRef.open(item, row);
+        this.$nextTick(() => {
+          //   this.$refs.targetComponentRef.open(row, isView);
+          this.targetVisible = true;
+          console.log('targetVisible~~~~', this.targetVisible);
+        });
+      },
+      openReport(row) {
+        console.log('openReport', row);
+        this.targetComponent = row.reportTemplateCode;
+        this.isView = true;
+        this.currentRow = row;
+        this.$nextTick(() => {
+          this.targetVisible = true;
+        });
+      },
+      isEmptyObject(obj = {}) {
+        return Object.keys(obj).length === 0;
+      },
+      reportApprovalSubmit(res) {
+        this.processSubmitDialogFlag = true;
+        this.$nextTick(async () => {
+          let params = {
+            businessId: res.id,
+            businessKey: 'qms_report_approval_task_monad',
+            formCreateUserId: res.createUserId,
+            variables: {
+              businessCode: res.code,
+              businessName: res.name,
+              businessType: '质检报告单'
+            }
+          };
+          // if (this.clientEnvironmentId == 5) {
+          //   const data = await getCategoryByCode(res.productCode);
+          //   if (data && data.categoryLevelCodePath?.includes('W3-209')) {
+          //     params.businessKey = 'qms_report_approval1';
+          //   } else {
+          //     params.businessKey = 'qms_report_approval';
+          //   }
+          // }
+          this.$refs.processSubmitDialogRef.init(params);
+        });
+      },
       /* 删除 */
       remove(row) {
         const loading = this.$loading({ lock: true });

+ 23 - 12
src/views/inspectionReport/template/inspection_report1.vue

@@ -144,7 +144,7 @@
                   placeholder="选择日期"
                 />
               </div>
-              <div v-else>{{ basicInfoData.expirationDate ||'/'}}</div>
+              <div v-else>{{ basicInfoData.expirationDate || '/' }}</div>
             </td>
           </tr>
           <tr>
@@ -374,8 +374,11 @@
     queryInspectionReportList,
     generateReport
   } from '@/api/inspectionReport';
+  import { getById } from '@/api/inspectionProjectTask';
   import bpmDetail from '@/views/bpm/processInstance/detail.vue';
   import { getDetailById } from '@/api/inspectionWork/index';
+  import { getCode } from '@/api/login';
+
   export default {
     name: 'QualityReport',
     props: {
@@ -394,7 +397,8 @@
       item: {
         type: Object,
         default: () => {}
-      }
+      },
+      type: ''
     },
     components: {
       bpmDetail
@@ -424,7 +428,6 @@
         handler: function (val) {
           console.log('visible~~~', val);
           if (val) {
-            // this.getProcessInstance();
             this.open(this.row, this.item);
           }
         },
@@ -441,9 +444,10 @@
         this.currentRow = row;
         this.templateItem = item || row;
         console.log('currentRow~~~', this.currentRow, this.templateItem);
+        let api = this.type === '0' ? getDetailById : getById;
 
         try {
-          const res = await getDetailById(this.row.id);
+          const res = await api(this.row.id);
           this.processInstanceId = res.data.reportProcessInstanceId;
           this.reportApprovalTaskVos = res.data.reportApprovalTaskVos;
         } catch (error) {
@@ -503,7 +507,10 @@
         }
       },
       getBasicInfo() {
-        queryInspectionReportData(this.currentRow.id).then((res) => {
+        queryInspectionReportData({
+          id: this.currentRow.id,
+          type: this.type
+        }).then((res) => {
           this.basicInfoData = res;
 
           const reviewTime =
@@ -546,19 +553,22 @@
             'checker',
             this.basicInfoData.checker || checker || ''
           );
+          if (!this.basicInfoData.reportNumber) {
+            getCode('quality_Inspection_report_number').then((res) => {
+              this.$set(this.basicInfoData, 'reportNumber', res);
+            });
+          }
         });
       },
       getInspectionItems() {
-        queryInspectionReportList(this.currentRow.id).then((res) => {
+        queryInspectionReportList({
+          id: this.currentRow.id,
+          type: this.type
+        }).then((res) => {
           this.inspectionItems = res;
         });
       },
-      getProcessInstance() {
-        getDetailById(this.row.id).then((res) => {
-          console.log('res~~~~', res);
-          this.processInstanceId = res.data.reportProcessInstanceId;
-        });
-      },
+
       cancel() {
         // this.visible = false;
         this.$emit('update:visible', false);
@@ -571,6 +581,7 @@
         this.$nextTick(() => {
           const printSection = document.getElementById('printSection');
           const params = {
+            type: this.type,
             id: this.currentRow.id,
             reportTemplateId: this.templateItem.id,
             reportTemplateCode:

+ 23 - 13
src/views/inspectionReport/template/inspection_report2.vue

@@ -176,7 +176,7 @@
                   placeholder="选择日期"
                 />
               </div>
-              <div v-else>{{ basicInfoData.expirationDate ||'/'}}</div>
+              <div v-else>{{ basicInfoData.expirationDate || '/' }}</div>
             </td>
             <td style="width: 150px; border: 1px solid #ccc; padding: 8px"
               >报告日期</td
@@ -396,6 +396,9 @@
   } from '@/api/inspectionReport';
   import bpmDetail from '@/views/bpm/processInstance/detail.vue';
   import { getDetailById } from '@/api/inspectionWork/index';
+  import { getById } from '@/api/inspectionProjectTask';
+  import { getCode } from '@/api/login';
+
   export default {
     name: 'QualityReport',
     props: {
@@ -414,7 +417,8 @@
       item: {
         type: Object,
         default: () => {}
-      }
+      },
+      type: ''
     },
     components: {
       bpmDetail
@@ -444,7 +448,6 @@
         handler: function (val) {
           console.log('visible~~~', val);
           if (val) {
-            // this.getProcessInstance();
             this.open(this.row, this.item);
           }
         },
@@ -461,9 +464,9 @@
         this.currentRow = row;
         this.templateItem = item || row;
         console.log('currentRow~~~', this.currentRow, this.templateItem);
-
+        let api = this.type === '0' ? getDetailById : getById;
         try {
-          const res = await getDetailById(this.row.id);
+          const res = await api(this.row.id);
           this.processInstanceId = res.data.reportProcessInstanceId;
           this.reportApprovalTaskVos = res.data.reportApprovalTaskVos;
         } catch (error) {
@@ -523,7 +526,10 @@
         }
       },
       getBasicInfo() {
-        queryInspectionReportData(this.currentRow.id).then((res) => {
+        queryInspectionReportData({
+          id: this.currentRow.id,
+          type: this.type
+        }).then((res) => {
           this.basicInfoData = res;
           this.basicInfoData.reportCode = res.reportCode || '';
           this.basicInfoData.version =
@@ -571,19 +577,22 @@
             'checker',
             this.basicInfoData.checker || checker || ''
           );
+          if (!this.basicInfoData.reportNumber) {
+            getCode('quality_Inspection_report_number').then((res) => {
+              this.$set(this.basicInfoData, 'reportNumber', res);
+            });
+          }
         });
       },
       getInspectionItems() {
-        queryInspectionReportList(this.currentRow.id).then((res) => {
+        queryInspectionReportList({
+          id: this.currentRow.id,
+          type: this.type
+        }).then((res) => {
           this.inspectionItems = res;
         });
       },
-      getProcessInstance() {
-        getDetailById(this.row.id).then((res) => {
-          console.log('res~~~~', res);
-          this.processInstanceId = res.data.reportProcessInstanceId;
-        });
-      },
+
       cancel() {
         // this.visible = false;
         this.$emit('update:visible', false);
@@ -598,6 +607,7 @@
 
           const params = {
             id: this.currentRow.id,
+            type: this.type,
             reportTemplateId: this.templateItem.id,
             reportTemplateCode:
               this.templateItem.code || this.templateItem.reportTemplateCode,

+ 4 - 0
src/views/inspectionWork/index.vue

@@ -131,6 +131,7 @@
             :underline="false"
             v-if="
               row.status == 0 &&
+              row.isPendingSample != 1 &&
               $hasPermission('qms:quality_work_order:qualityInspectionSend')
             "
             @click="qualityInspectionSend(row, 1)"
@@ -141,6 +142,7 @@
             :underline="false"
             v-if="
               row.status == 0 &&
+              row.isPendingSample != 1 &&
               $hasPermission('qms:quality_work_order:request')
             "
             @click="qualityInspectionSend(row, 2)"
@@ -299,6 +301,7 @@
       :row="currentRow"
       :item="currentItem"
       @reload="search"
+      :type="type"
     ></component>
     <mesWorkOrder ref="mesWorkOrderRef"></mesWorkOrder>
   </div>
@@ -360,6 +363,7 @@
         targetVisible: false,
         currentRow: {},
         currentItem: {},
+        type: '0',
         columns: [
           // 新增多选列
           {

+ 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.251:18086',
+        target: 'http://192.168.1.3:18086',
         // target: 'http://192.168.1.3:18086', // 付丽
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {