Просмотр исходного кода

质检工单新增批量关闭

hezhanp 7 месяцев назад
Родитель
Сommit
87d5c2c58c
2 измененных файлов с 65 добавлено и 79 удалено
  1. 9 0
      src/api/inspectionWork/index.js
  2. 56 79
      src/views/inspectionWork/index.vue

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

@@ -142,6 +142,15 @@ export async function closeWork(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+//批量关闭
+export async function closeWorkList(data) {
+  const res = await request.post(`/qms/quality_work_order/batchClose`, data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
 // 关闭
 export async function verificationQualityInspector(id) {
   const res = await request.post(`/qms/quality_work_order/verificationQualityInspector/${id}`);

+ 56 - 79
src/views/inspectionWork/index.vue

@@ -1,7 +1,6 @@
 <template>
   <div class="ele-body">
     <el-card shadow="never">
-      <!-- <search ref="search" @search="search"></search> -->
       <seek-page :seekList="seekList" @search="search" ref="search"></seek-page>
 
       <ele-pro-table
@@ -12,13 +11,21 @@
         :pageSizes="[20, 30, 40, 50, 100]"
         @columns-change="handleColumnChange"
         :cache-key="cacheKeyUrl"
+        row-key="id"
+        @selection-change="selectionChangeHandle"
       >
         <!-- 表头工具栏 -->
-        <!--        <template v-slot:toolbar>-->
-        <!--          <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="openEdit('add')">-->
-        <!--            添加-->
-        <!--          </el-button>-->
-        <!--        </template>-->
+        <template v-slot:toolbar>
+          <el-button 
+            size="small" 
+            type="primary" 
+            class="ele-btn-icon" 
+            @click="batchClose" 
+            :disabled="selection.length === 0"
+          >
+            批量关闭
+          </el-button>
+        </template>
 
         <template v-slot:code="{ row }">
           <el-link
@@ -29,15 +36,7 @@
           >
         </template>
 
-        <!--        <template v-slot:qualityPlanName="{ row }">-->
-        <!--          <div v-if="row.qualityPlanId"> {{ row.qualityPlanName }}</div>-->
-        <!--          <div v-else><el-tag size="mini">自建</el-tag></div>-->
-        <!--        </template>-->
         <template v-slot:sourceCode="{ row }">
-          <!-- <div v-if="row.qualityType == 1">{{ row.qualityPlanCode }}</div>
-          <div v-if="row.qualityType == 2">{{ row.workOrderCode }}</div>
-          <div v-if="row.qualityType == 3">{{ row.qualityPlanCode }}</div>
-          <div v-if="row.qualityType == 6">{{ row.qualityPlanCode }}</div> -->
           <div>{{
             row.qualityPlanCode ? row.qualityPlanCode : row.workOrderCode
           }}</div>
@@ -121,31 +120,8 @@
               <el-link type="warning" :underline="false"> 关闭 </el-link>
             </template>
           </el-popconfirm>
-          <!-- <el-link type="primary" :underline="false">
-            质检报告
-          </el-link>-->
-          <!-- <el-popconfirm class="ele-action" title="确定要删除吗?" @confirm="remove(row)" v-if="row.status == 0">
-            <template v-slot:reference>
-              <el-link type="danger" :underline="false" icon="el-icon-delete">
-                删除
-              </el-link>
-            </template>
-          </el-popconfirm>-->
         </template>
       </ele-pro-table>
-      <!--  -->
-      <!-- <el-dialog title="修改" :visible.sync="certificateVisible" width="25%" :before-close="handleClose">
-        <el-form :inline="true" :model="formData" class="demo-form-inline">
-          <el-form-item label="合格证号">
-            <el-input v-model="formData.certificateNumber" placeholder="请输入"></el-input>
-          </el-form-item>
-        </el-form>
-        <span slot="footer" class="dialog-footer">
-          <el-button @click="handleClose">取 消</el-button>
-          <el-button type="primary" @click="handleSubmit">确 定</el-button>
-        </span>
-      </el-dialog>-->
-      <!--  -->
     </el-card>
     <Certificate
       @search="search"
@@ -181,7 +157,7 @@ import {
   getList,
   removeItem,
   updateCertificateNumber,
-  closeWork,
+  closeWorkList,
   verificationQualityInspector
 } from '@/api/inspectionWork';
 import { queryTodo } from '@/api/bpm/task';
@@ -205,6 +181,14 @@ export default {
     return {
       cacheKeyUrl: 'qsm-c2e9664a-inspectionWork',
       columns: [
+        // 新增多选列
+        {
+          width: 45,
+          type: 'selection',
+          columnKey: 'selection',
+          align: 'center',
+          reserveSelection: true
+        },
         {
           type: 'index',
           columnKey: 'index',
@@ -275,7 +259,6 @@ export default {
           width: 120,
           showOverflowTooltip: true
         },
-
         {
           prop: 'productCode',
           width: 120,
@@ -309,7 +292,6 @@ export default {
           align: 'center',
           showOverflowTooltip: true
         },
-
         {
           prop: 'produceTaskName',
           label: '工序',
@@ -353,7 +335,6 @@ export default {
           align: 'center',
           showOverflowTooltip: true
         },
-
         {
           label: '附件',
           prop: 'accessory',
@@ -395,7 +376,6 @@ export default {
         certificateNumber: ''
       },
       processSubmitDialogFlag: false,
-      // certificateVisible: false,
       rowData: {},
       typeList: [], //类型列表
       qualityMode: [], //取样类型
@@ -412,7 +392,8 @@ export default {
       addOpen: false,
       transferVisible: false,
       transferId: '',
-      isReportApproval: 0
+      isReportApproval: 0,
+      selection: [] // 存储选中的行数据
     };
   },
   created() {
@@ -490,8 +471,38 @@ export default {
     }
   },
   methods: {
+    selectionChangeHandle(val) {
+      this.selection = val;
+    },
+
+    // 批量关闭
+    batchClose() {
+      const validRows = this.selection.filter(row => row.status === 0 && row.qualityType === 2);
+      if (validRows.length === 0) {
+        this.$message.warning('所选工单中没有可关闭的工单');
+        return;
+      }
+
+      this.$confirm(
+        `确定关闭选中的 ${validRows.length} 个工单吗?`,
+        '提示',
+        {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }
+      ).then(async () => {
+        try {
+          await closeWorkList(validRows.map(row => row.id));
+          this.$refs.table.clearSelection();
+          this.search(); 
+        } catch (err) {
+          this.$message.error('批量关闭失败:' + (err.message || '操作异常'));
+        }
+      });
+    },
+
     reportApprovalSubmit(res) {
-      console.log(res, 'res');
       this.processSubmitDialogFlag = true;
       this.$nextTick(async () => {
         let params = {
@@ -504,17 +515,11 @@ export default {
             businessType: '质检报告单'
           }
         };
-        console.log(this.clientEnvironmentId, 'parathis.clientEnvironmentIdms');
         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';
           }
         }
@@ -522,14 +527,10 @@ export default {
       });
     },
     getCode() {
-      // 质检报告审批(0:不需要审批;1:需要审批)
       parameterGetByCode({
         code: 'qms_report_approval'
       }).then((res) => {
-        console.log(res, 'qms_report_approval');
-        console;
         this.isReportApproval = res.value;
-        console.log('isReportApproval', this.isReportApproval);
       });
     },
     async datasource({ page, where, limit }) {
@@ -568,7 +569,6 @@ export default {
               const id = type !== 'add' ? row.id : '';
               const qualityType = type !== 'add' ? row.qualityType : null;
               const qualityTimeStart = row.qualityTimeStart || '';
-              // qualityType是质检类型 来料,生产
               this.$router.push({
                 path: '/inspectionWork/edit',
                 query: {
@@ -588,9 +588,7 @@ export default {
         this.$message.error('请到角色管理配置菜单权限!');
       }
     },
-    // 打开详情
     openDetails(row) {
-      console.log(row, 'row 000');
       let id = row.id;
       this.$router.push({
         path: '/inspectionWork/details',
@@ -615,32 +613,14 @@ export default {
       this.formData.certificateNumber = row.certificateNumber;
       this.rowData = row;
       this.addOpen = true;
-      // this.certificateVisible = true
     },
     closeModel() {
       this.addOpen = false;
     },
     async close(row) {
-      console.log(row);
       await closeWork(row);
       this.done();
     },
-    // handleClose() {
-    //   this.certificateVisible = false;
-    // },
-    // async handleSubmit() {
-    //   this.rowData.certificateNumber = this.formData.certificateNumber;
-    //   this.rowData.qualityTimeStart = new Date(this.rowData.qualityTimeStart);
-    //   this.rowData.qualityTimeEnd = new Date(this.rowData.qualityTimeEnd);
-
-    //   const data = await updateCertificateNumber(this.rowData)
-    //   if (data) {
-    //     this.$message.success('修改成功!');
-    //     this.done();
-    //   }
-    //   this.certificateVisible = false;
-    // },
-
     async getTnspectionPlanType() {
       let res = await getByCode('inspection_plan_type');
       if (res?.code == 0) {
@@ -651,7 +631,6 @@ export default {
         this.typeList = list;
       }
     },
-
     async getQualityMethodCode() {
       let res = await getByCode('quality_method_code');
       if (res?.code == 0) {
@@ -667,12 +646,10 @@ export default {
       this.transferId = id;
     },
     transferConfirm(id) {
-      console.log(id);
-
       this.transferVisible = false;
       this.$message.success('转派成功');
       this.done();
     }
   }
 };
-</script>
+</script>