From fa60bfa07970c192c85a437e7db784eccdae2839 Mon Sep 17 00:00:00 2001
From: 董国庆 <364620639@qq.com>
Date: 星期一, 16 六月 2025 20:04:15 +0800
Subject: [PATCH] 修改bug

---
 laboratory/src/views/dataManagement/approvalPlan/list.vue |  196 ++++++++++++++++++------------------------------
 1 files changed, 74 insertions(+), 122 deletions(-)

diff --git a/laboratory/src/views/dataManagement/approvalPlan/list.vue b/laboratory/src/views/dataManagement/approvalPlan/list.vue
index f215622..3fa5a25 100644
--- a/laboratory/src/views/dataManagement/approvalPlan/list.vue
+++ b/laboratory/src/views/dataManagement/approvalPlan/list.vue
@@ -1,6 +1,6 @@
 <template>
   <div class="list">
-    <TableCustom :queryForm="form" :tableData="tableData" :total="total">
+    <TableCustom :queryForm="form" :tableData="tableData" :total="total" :height="null">
       <template #search>
         <el-form :model="form" labelWidth="auto" inline>
           <el-form-item label="项目课题方案名称:">
@@ -28,7 +28,7 @@
       <template #setting>
         <div class="table-setting">
           <div class="flex a-center">
-            <div class="table-title" :class="{ active: currentType === 'list' }" @click="handleTypeChange('list')">
+            <div class="table-tit" :class="{ active: currentType === 'list' }" @click="handleTypeChange('list')">
               项目课题方案列表
             </div>
             <div v-if="isProcessEngineer" class="table-tit drafts" :class="{ active: currentType === 'draft' }"
@@ -61,18 +61,26 @@
         <el-table-column prop="auditTime" label="审批时间"></el-table-column>
         <el-table-column label="操作" width="250">
           <template slot-scope="scope">
-            <!-- 工艺工程师的按钮 -->
-            <template v-if="isProcessEngineer">
-              <el-button v-if="scope.row.auditStatus === 1" type="text"
-                @click="handleRevokeApprove(scope.row)">撤销审批</el-button>
-              <el-button v-if="scope.row.auditStatus === 3" type="text" @click="handleEdit(scope.row)">编辑</el-button>
-              <el-button v-if="scope.row.auditStatus === 3" type="text" @click="handleDelete(scope.row)">删除</el-button>
-              <el-button v-if="scope.row.auditStatus !== 1" type="text" @click="handleDetail(scope.row)">详情</el-button>
+            <!-- 草稿箱的按钮 -->
+            <template v-if="currentType === 'draft'">
+              <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
+              <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
             </template>
-            <!-- 审批人和超级管理员的按钮 -->
+            <!-- 列表的按钮 -->
             <template v-else>
-              <el-button v-if="scope.row.auditStatus === 1" type="text" @click="handleApprove(scope.row)">审批</el-button>
-              <el-button v-if="scope.row.auditStatus !== 1" type="text" @click="handleDetail(scope.row)">详情</el-button>
+              <!-- 工艺工程师的按钮 -->
+              <template v-if="isProcessEngineer">
+                <el-button v-if="scope.row.auditStatus === 1" type="text"
+                  @click="handleRevokeApprove(scope.row)">撤销审批</el-button>
+                <el-button v-if="scope.row.auditStatus === 3" type="text" @click="handleEdit(scope.row)">编辑</el-button>
+                <el-button v-if="scope.row.auditStatus === 3" type="text" @click="handleDelete(scope.row)">删除</el-button>
+                <el-button v-if="scope.row.auditStatus !== 1" type="text" @click="handleDetail(scope.row)">详情</el-button>
+              </template>
+              <!-- 审批人和超级管理员的按钮 -->
+              <template v-else>
+                <el-button v-if="scope.row.auditStatus === 1" type="text" @click="handleApprove(scope.row)">审批</el-button>
+                <el-button v-if="scope.row.auditStatus !== 1" type="text" @click="handleDetail(scope.row)">详情</el-button>
+              </template>
             </template>
           </template>
         </el-table-column>
@@ -114,64 +122,9 @@
       },
       tableData: [],
       total: 0,
-      // 模拟数据
-      mockListData: [
-        {
-          planCode: "PLAN-2024-001",
-          planName: "2024年度实验室设备升级方案",
-          stage: "规划阶段",
-          creator: "张三",
-          createTime: "2024-03-15",
-          status: "pending",
-          approver: "李四",
-          approveTime: "2024-03-16",
-        },
-        {
-          planCode: "PLAN-2024-002",
-          planName: "实验室安全管理制度更新方案",
-          stage: "实施阶段",
-          creator: "王五",
-          createTime: "2024-03-14",
-          status: "approved",
-          approver: "赵六",
-          approveTime: "2024-03-15",
-        },
-        {
-          planCode: "PLAN-2024-003",
-          planName: "实验室人员培训计划",
-          stage: "准备阶段",
-          creator: "孙七",
-          createTime: "2024-03-13",
-          status: "rejected",
-          approver: "周八",
-          approveTime: "2024-03-14",
-        },
-      ],
-      mockDraftData: [
-        {
-          planCode: "DRAFT-2024-001",
-          planName: "实验室设备采购计划(草稿)",
-          stage: "规划阶段",
-          creator: "张三",
-          createTime: "2024-03-16",
-          status: "draft",
-          approver: "",
-          approveTime: "",
-        },
-        {
-          planCode: "DRAFT-2024-002",
-          planName: "实验室改造方案(草稿)",
-          stage: "准备阶段",
-          creator: "李四",
-          createTime: "2024-03-15",
-          status: "draft",
-          approver: "",
-          approveTime: "",
-        },
-      ],
       approvalDialogVisible: false,
       approvalDialogType: "approve",
-      currentApprovalData: [],
+      currentApprovalData: {}, // 修改为对象类型
       // 确认弹窗相关数据
       changeStatus: false,
       changeStatusTitle: "",
@@ -206,14 +159,16 @@
       this.getTableData();
     },
     handleSearch() {
-      if (this.form.createTime && this.form.createTime.length === 2) {
-        this.form.startTime = this.form.createTime[0];
-        this.form.endTime = this.form.createTime[1];
+      this.updateTimeRange();
+      this.getTableData();
+    },
+    updateTimeRange() {
+      if (this.form.createTime?.length === 2) {
+        [this.form.startTime, this.form.endTime] = this.form.createTime;
       } else {
         this.form.startTime = "";
         this.form.endTime = "";
       }
-      this.getTableData();
     },
     getStatusType(status) {
       const statusMap = {
@@ -256,15 +211,10 @@
       this.approvalDialogVisible = true;
     },
     handleApproveSubmit(data) {
-      // 处理审批通过
-      console.log("审批通过:", data);
       this.approvalDialogVisible = false;
-      this.$message.success("审批通过成功");
       this.getTableData();
     },
     handleRejectSubmit(data) {
-      // 处理审批驳回
-      console.log("审批驳回:", data);
       this.approvalDialogVisible = false;
       this.$message.success("审批驳回成功");
       this.getTableData();
@@ -273,22 +223,20 @@
       this.currentOperationType = "revoke";
       this.currentOperationRow = row;
       this.changeStatusTitle = "确认要撤销这条审批吗?";
-      this.changeStatusTip = "撤销后,审批人将无法收到此条审批信息"; // 这里可以根据实际需求修改提示文案
+      this.changeStatusTip = "撤销后,审批人将无法收到此条审批信息";
       this.changeStatus = true;
     },
     handleEdit(row) {
       this.$router.push({
         path: "/dataManagement/addPlan",
-        query: {
-          id: row.id
-        }
+        query: { id: row.id }
       });
     },
     handleDelete(row) {
       this.currentOperationType = "delete";
       this.currentOperationRow = row;
       this.changeStatusTitle = "确认要删除这条信息吗?";
-      this.changeStatusTip = "删除后信息无法找回"; // 这里可以根据实际需求修改提示文案
+      this.changeStatusTip = "删除后信息无法找回";
       this.changeStatus = true;
     },
     handleDetail(row) {
@@ -299,50 +247,45 @@
     handleTypeChange(type) {
       this.currentType = type;
       this.form.auditStatus = type === "draft" ? -1 : "";
+      this.form.pageNum = 1; // 切换时重置页码
       this.getTableData();
     },
     getTableData() {
-      if (this.form.createTime && this.form.createTime.length === 2) {
-        this.form.startTime = this.form.createTime[0];
-        this.form.endTime = this.form.createTime[1];
-      } else {
-        this.form.startTime = "";
-        this.form.endTime = "";
-      }
-
-      // 创建新的请求参数对象,排除createTime
+      this.updateTimeRange();
       const { createTime, ...requestParams } = this.form;
-      console.log(requestParams, "requestParams");
+      
       getProposalList(requestParams).then((res) => {
-        console.log(res, "请求回来的数据");
         this.tableData = res.data.records;
         this.total = res.data.total;
       });
     },
     handleChangeStatusConfirm() {
-      if (this.currentOperationType === "revoke") {
-        // 处理撤销审批逻辑
-        upAndDown({
-          id: this.currentOperationRow.id,
-          status: 4 // 已撤销状态
-        }).then(() => {
-          this.$message.success("撤销审批成功");
-          this.changeStatus = false;
-          this.getTableData();
-        }).catch(error => {
-          this.$message.error("撤销审批失败");
-        });
-      } else if (this.currentOperationType === "delete") {
-        // 处理删除逻辑
-        deleteById({
-          id: this.currentOperationRow.id
-        }).then(() => {
-          this.$message.success("删除成功");
-          this.changeStatus = false;
-          this.getTableData();
-        }).catch(error => {
-          this.$message.error("删除失败");
-        });
+      const operationMap = {
+        revoke: {
+          api: upAndDown,
+          params: { id: this.currentOperationRow.id, status: -1 },
+          successMsg: "撤销审批成功",
+          errorMsg: "撤销审批失败"
+        },
+        delete: {
+          api: deleteById,
+          params: { id: this.currentOperationRow.id },
+          successMsg: "删除成功",
+          errorMsg: "删除失败"
+        }
+      };
+
+      const operation = operationMap[this.currentOperationType];
+      if (operation) {
+        operation.api(operation.params)
+          .then(() => {
+            this.$message.success(operation.successMsg);
+            this.changeStatus = false;
+            this.getTableData();
+          })
+          .catch(() => {
+            this.$message.error(operation.errorMsg);
+          });
       }
     },
   },
@@ -381,6 +324,13 @@
   color: #049c9a;
   line-height: 27px;
   cursor: pointer;
+  transition: all 0.3s ease;
+
+  &.active {
+    color: #049c9a;
+    background: #ffffff;
+    border: 1px solid #049c9a;
+  }
 }
 
 .table-tit {
@@ -393,18 +343,20 @@
   align-items: center;
   justify-content: center;
   font-family: SourceHanSansCN, SourceHanSansCN;
-  font-weight: bold;
+  
   font-size: 18px;
   color: #606266;
   line-height: 27px;
   margin-left: 16px;
   cursor: pointer;
-}
+  transition: all 0.3s ease;
 
-.active {
-  color: #049c9a;
-  background: #ffffff;
-  border: 1px solid #049c9a;
+  &.active {
+    color: #049c9a;
+    font-weight: bold;
+    background: #ffffff;
+    border: 1px solid #049c9a;
+  }
 }
 
 .el-icon-plus {

--
Gitblit v1.7.1