From 6db4d38b9761b07a49cb22a0a41cfcdc7bc6dbab Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 19 五月 2026 20:14:14 +0800
Subject: [PATCH] feat: 回退

---
 src/views/equipmentManagement/inspectionManagement/index.vue |  119 +++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 82 insertions(+), 37 deletions(-)

diff --git a/src/views/equipmentManagement/inspectionManagement/index.vue b/src/views/equipmentManagement/inspectionManagement/index.vue
index 35f82d5..1be5ad9 100644
--- a/src/views/equipmentManagement/inspectionManagement/index.vue
+++ b/src/views/equipmentManagement/inspectionManagement/index.vue
@@ -55,8 +55,6 @@
                   :table-style="{ width: '100%', height: 'calc(100vh - 23em)' }">
           <template #inspector="{ row }">
             <div class="person-tags">
-              <!-- 璋冭瘯淇℃伅锛屼笂绾挎椂鍒犻櫎 -->
-              <!-- {{ console.log('inspector data:', row.inspector) }} -->
               <template v-if="row.inspector && row.inspector.length > 0">
                 <el-tag v-for="(person, index) in row.inspector"
                         :key="index"
@@ -69,6 +67,10 @@
               <span v-else
                     class="no-data">--</span>
             </div>
+          </template>
+          <template #statusRef="{ row }">
+            <el-tag v-if="row.isActive === true || row.isActive === 1" type="success">鍚敤</el-tag>
+            <el-tag v-else type="danger">鍋滅敤</el-tag>
           </template>
         </PIMTable>
       </div>
@@ -83,6 +85,7 @@
   import { Delete, Plus } from "@element-plus/icons-vue";
   import { onMounted, ref, reactive, getCurrentInstance, nextTick } from "vue";
   import { ElMessageBox } from "element-plus";
+  import dayjs from "dayjs";
 
   // 缁勪欢寮曞叆
   import PIMTable from "@/components/PIMTable/PIMTable.vue";
@@ -94,6 +97,7 @@
     delTimingTask,
     inspectionTaskList,
     timingTaskList,
+    addOrEditTimingTask,
   } from "@/api/inspectionManagement/index.js";
 
   // 鍏ㄥ眬鍙橀噺
@@ -109,8 +113,8 @@
   // 鍗曢�夋閰嶇疆
   const activeRadio = ref("taskManage");
   const radios = reactive([
-    { name: "taskManage", label: "瀹氭椂浠诲姟绠$悊" },
-    { name: "task", label: "瀹氭椂浠诲姟璁板綍" },
+    { name: "taskManage", label: "宸℃浠诲姟绠$悊" },
+    { name: "task", label: "宸℃浠诲姟璁板綍" },
   ]);
 
   // 琛ㄦ牸鏁版嵁
@@ -132,12 +136,6 @@
       prop: "frequencyType",
       label: "棰戞",
       minWidth: 150,
-      // formatter: (_, __, val) => ({
-      //   DAILY: "姣忔棩",
-      //   WEEKLY: "姣忓懆",
-      //   MONTHLY: "姣忔湀",
-      //   QUARTERLY: "瀛e害"
-      // }[val] || "")
       formatData: params => {
         return params === "DAILY"
           ? "姣忔棩"
@@ -175,38 +173,55 @@
       },
     },
     { prop: "registrant", label: "鐧昏浜�", minWidth: 100 },
-    { prop: "createTime", label: "鐧昏鏃ユ湡", minWidth: 100 },
+    { prop: "createTime", label: "鐧昏鏃ユ湡", minWidth: 120, formatData: (cell) => cell ? dayjs(cell).format("YYYY-MM-DD HH:MM:ss") : "-" },
   ]);
+
+  const statusColumn = {
+    prop: "isActive",
+    label: "浠诲姟鐘舵��",
+    minWidth: 100,
+    align: "center",
+    dataType: "slot",
+    slot: "statusRef",
+  };
 
   // 鎿嶄綔鍒楅厤缃�
   const getOperationColumn = operations => {
     if (!operations || operations.length === 0) return null;
 
+    const operationList = operations
+      .map(op => {
+        switch (op) {
+          case "edit":
+            return {
+              name: "缂栬緫",
+              clickFun: handleAdd,
+              color: "#409EFF",
+            };
+          case "viewFile":
+            return {
+              name: "鏌ョ湅闄勪欢",
+              clickFun: viewFile,
+              color: "#67C23A",
+            };
+          case "toggleActive":
+            return {
+              name: (row) => row.isActive === true || row.isActive === 1 ? "鍋滅敤" : "鍚敤",
+              clickFun: handleToggleActive,
+              color: (row) => row.isActive === true || row.isActive === 1 ? "#F56C6C" : "#67C23A",
+            };
+          default:
+            return null;
+        }
+      })
+      .filter(Boolean);
+
     const operationConfig = {
       label: "鎿嶄綔",
-      width: 130,
+      width: 200,
       fixed: "right",
       dataType: "action",
-      operation: operations
-        .map(op => {
-          switch (op) {
-            case "edit":
-              return {
-                name: "缂栬緫",
-                clickFun: handleAdd,
-                color: "#409EFF",
-              };
-            case "viewFile":
-              return {
-                name: "鏌ョ湅闄勪欢",
-                clickFun: viewFile,
-                color: "#67C23A",
-              };
-            default:
-              return null;
-          }
-        })
-        .filter(Boolean),
+      operation: operationList,
     };
 
     return operationConfig;
@@ -219,12 +234,13 @@
   // 鍗曢�夊彉鍖�
   const radioChange = value => {
     if (value === "taskManage") {
-      const operationColumn = getOperationColumn(["edit"]);
+      const operationColumn = getOperationColumn(["edit", "toggleActive"]);
       tableColumns.value = [
         ...columns.value,
+        statusColumn,
         ...(operationColumn ? [operationColumn] : []),
       ];
-      operationsArr.value = ["edit"];
+      operationsArr.value = ["edit", "toggleActive"];
     } else if (value === "task") {
       const operationColumn = getOperationColumn(["viewFile"]);
       tableColumns.value = [
@@ -346,6 +362,35 @@
       .catch(() => {});
   };
 
+  // 鍚敤/鍋滅敤鍒囨崲
+  const handleToggleActive = async (row) => {
+    const newStatus = row.isActive === true || row.isActive === 1 ? 0 : 1;
+    const actionText = newStatus === 1 ? "鍚敤" : "鍋滅敤";
+
+    try {
+      await proxy.$modal.confirm(`鏄惁纭${actionText}璇ヤ换鍔★紵`)
+    } catch {
+      return
+    }
+
+    try {
+      await addOrEditTimingTask({
+        id: row.id,
+        taskId: row.taskId,
+        taskName: row.taskName,
+        inspectorIds: row.inspectorIds,
+        remarks: row.remarks,
+        frequencyType: row.frequencyType,
+        frequencyDetail: row.frequencyDetail,
+        isActive: newStatus,
+      })
+      proxy.$modal.msgSuccess(`${actionText}鎴愬姛`)
+      handleQuery()
+    } catch (error) {
+      console.error(`${actionText}澶辫触:`, error)
+    }
+  };
+
   // 澶氶�夊彉鏇�
   const handleSelectionChange = selection => {
     selectedRows.value = selection;
@@ -361,11 +406,11 @@
       .then(() => {
         // 鏍规嵁褰撳墠閫変腑鐨勬爣绛鹃〉璋冪敤涓嶅悓鐨勫鍑烘帴鍙�
         if (activeRadio.value === "taskManage") {
-          // 瀹氭椂浠诲姟绠$悊
-          proxy.download("/timingTask/export", {}, "瀹氭椂浠诲姟绠$悊.xlsx");
+          // 淇濆吇浠诲姟绠$悊
+          proxy.download("/timingTask/export", {}, "淇濆吇浠诲姟绠$悊.xlsx");
         } else if (activeRadio.value === "task") {
           // 瀹氭椂浠诲姟璁板綍
-          proxy.download("/inspectionTask/export", {}, "瀹氭椂浠诲姟璁板綍.xlsx");
+          proxy.download("/inspectionTask/export", {}, "淇濆吇浠诲姟璁板綍.xlsx");
         }
       })
       .catch(() => {

--
Gitblit v1.9.3