From f49bfd6c085cbf28a25d9404f8dc5b74368b716a Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期五, 29 五月 2026 15:54:02 +0800
Subject: [PATCH] 新疆马铃薯 1.代码更新

---
 src/views/equipmentManagement/upkeep/index.vue | 1182 +++++++++++++++++++++++++++++++---------------------------
 1 files changed, 638 insertions(+), 544 deletions(-)

diff --git a/src/views/equipmentManagement/upkeep/index.vue b/src/views/equipmentManagement/upkeep/index.vue
index 245a162..419e9aa 100644
--- a/src/views/equipmentManagement/upkeep/index.vue
+++ b/src/views/equipmentManagement/upkeep/index.vue
@@ -1,652 +1,746 @@
 <template>
   <div class="app-container">
-    <el-tabs v-model="activeTab"
-             @tab-change="handleTabChange">
-      <!-- 淇濆吇浠诲姟tab -->
-      <el-tab-pane label="淇濆吇浠诲姟"
-                   name="scheduled">
+    <el-tabs v-model="activeTab" @tab-change="handleTabChange">
+      <!-- 瀹氭椂浠诲姟绠$悊tab -->
+      <el-tab-pane label="瀹氭椂浠诲姟绠$悊" name="scheduled">
         <div class="search_form">
-          <el-form :model="scheduledFilters"
-                   :inline="true">
+          <el-form :model="scheduledFilters" :inline="true">
             <el-form-item label="浠诲姟鍚嶇О">
-              <el-input v-model="scheduledFilters.taskName"
-                        style="width: 240px"
-                        placeholder="璇疯緭鍏ヤ换鍔″悕绉�"
-                        clearable
-                        :prefix-icon="Search"
-                        @change="getScheduledTableData" />
+              <el-input
+                  v-model="scheduledFilters.taskName"
+                  style="width: 240px"
+                  placeholder="璇疯緭鍏ヤ换鍔″悕绉�"
+                  clearable
+                  :prefix-icon="Search"
+                  @change="getScheduledTableData"
+              />
             </el-form-item>
-            <el-form-item label="浠诲姟鐘舵��">
-              <el-select v-model="scheduledFilters.status"
-                         placeholder="璇烽�夋嫨浠诲姟鐘舵��"
-                         clearable
-                         style="width: 200px">
-                <el-option label="鍚敤"
-                           value="1" />
-                <el-option label="鍋滅敤"
-                           value="0" />
+            <el-form-item label="鏄惁鍚敤">
+              <el-select v-model="scheduledFilters.isEnabled" placeholder="璇烽�夋嫨鏄惁鍚敤" clearable style="width: 200px">
+                <el-option label="鍚敤" :value="1" />
+                <el-option label="绂佺敤" :value="0" />
               </el-select>
             </el-form-item>
             <el-form-item>
-              <el-button type="primary"
-                         @click="getScheduledTableData">鎼滅储</el-button>
+              <el-button type="primary" @click="getScheduledTableData">鎼滅储</el-button>
               <el-button @click="resetScheduledFilters">閲嶇疆</el-button>
             </el-form-item>
           </el-form>
         </div>
         <div class="table_list">
           <div class="actions">
-            <el-text class="mx-1"
-                     size="large">淇濆吇浠诲姟</el-text>
+            <el-text class="mx-1" size="large">瀹氭椂浠诲姟绠$悊</el-text>
             <div>
-              <el-button type="primary"
-                         icon="Plus"
-                         @click="addScheduledTask">
+              <el-button type="primary" icon="Plus" @click="addScheduledTask">
                 鏂板浠诲姟
               </el-button>
-              <el-button type="danger"
-                         icon="Delete"
-                         :disabled="scheduledMultipleList.length <= 0"
-                         @click="delScheduledTaskByIds(scheduledMultipleList.map((item) => item.id))">
+              <el-button
+                type="danger"
+                icon="Delete"
+                :disabled="scheduledMultipleList.length <= 0"
+                @click="delScheduledTaskByIds(scheduledMultipleList.map((item) => item.id))"
+              >
                 鎵归噺鍒犻櫎
               </el-button>
             </div>
           </div>
-          <PIMTable rowKey="id"
-                    isSelection
-                    :column="scheduledColumns"
-                    :tableData="scheduledDataList"
-                    :page="{
+          <PIMTable
+            rowKey="id"
+            isSelection
+            :column="scheduledColumns"
+            :tableData="scheduledDataList"
+            :page="{
               current: scheduledPagination.currentPage,
               size: scheduledPagination.pageSize,
               total: scheduledPagination.total,
             }"
-                    @selection-change="handleScheduledSelectionChange"
-                    @pagination="changeScheduledPage">
-            <template #statusRef="{ row }">
-              <el-tag v-if="row.status === 1"
-                      type="success">鍚敤</el-tag>
-              <el-tag v-if="row.status === 0"
-                      type="danger">鍋滅敤</el-tag>
+            @selection-change="handleScheduledSelectionChange"
+            @pagination="changeScheduledPage"
+          >
+            <template #isEnabledRef="{ row }">
+              <el-switch
+                v-model="row.isEnabled"
+                :active-value="1"
+                :inactive-value="0"
+                :loading="row.enableSwitchLoading"
+                :before-change="() => handleScheduledEnableBeforeChange(row)"
+              />
             </template>
             <template #operation="{ row }">
-              <el-button type="primary"
-                         link
-                         @click="editScheduledTask(row)">
+              <el-button
+                type="primary"
+                link
+                @click="editScheduledTask(row)"
+              >
                 缂栬緫
               </el-button>
-              <el-button type="danger"
-                         link
-                         @click="delScheduledTaskByIds(row.id)">
+              <el-button
+                type="danger"
+                link
+                @click="delScheduledTaskByIds(row.id)"
+              >
                 鍒犻櫎
               </el-button>
             </template>
           </PIMTable>
         </div>
       </el-tab-pane>
-      <!-- 淇濆吇璁板綍tab锛堝師璁惧淇濆吇椤甸潰锛� -->
-      <el-tab-pane label="淇濆吇璁板綍"
-                   name="record">
+
+      <!-- 浠诲姟璁板綍tab锛堝師璁惧淇濆吇椤甸潰锛� -->
+      <el-tab-pane label="浠诲姟璁板綍" name="record">
         <div class="search_form">
-          <el-form :model="filters"
-                   :inline="true">
+          <el-form :model="filters" :inline="true">
             <el-form-item label="璁惧鍚嶇О">
-              <el-input v-model="filters.deviceName"
-                        style="width: 240px"
-                        placeholder="璇疯緭鍏ヨ澶囧悕绉�"
-                        clearable
-                        :prefix-icon="Search"
-                        @change="getTableData" />
+              <el-input
+                  v-model="filters.deviceName"
+                  style="width: 240px"
+                  placeholder="璇疯緭鍏ヨ澶囧悕绉�"
+                  clearable
+                  :prefix-icon="Search"
+                  @change="getTableData"
+              />
             </el-form-item>
             <el-form-item label="璁″垝淇濆吇鏃ユ湡">
-              <el-date-picker v-model="filters.maintenancePlanTime"
-                              type="date"
-                              placeholder="璇烽�夋嫨璁″垝淇濆吇鏃ユ湡"
-                              size="default"
-                              @change="(date) => handleDateChange(date,2)" />
+              <el-date-picker
+                  v-model="filters.maintenancePlanTime"
+                  type="date"
+                  placeholder="璇烽�夋嫨璁″垝淇濆吇鏃ユ湡"
+                  size="default"
+                  @change="(date) => handleDateChange(date,2)"
+              />
             </el-form-item>
             <el-form-item label="瀹為檯淇濆吇鏃ユ湡">
-              <el-date-picker v-model="filters.maintenanceActuallyTime"
-                              type="date"
-                              placeholder="璇烽�夋嫨瀹為檯淇濆吇鏃ユ湡"
-                              size="default"
-                              @change="(date) => handleDateChange(date,1)" />
+              <el-date-picker
+                  v-model="filters.maintenanceActuallyTime"
+                  type="date"
+                  placeholder="璇烽�夋嫨瀹為檯淇濆吇鏃ユ湡"
+                  size="default"
+                  @change="(date) => handleDateChange(date,1)"
+              />
             </el-form-item>
             <el-form-item label="瀹為檯淇濆吇浜�">
-              <el-input v-model="filters.maintenanceActuallyName"
-                        style="width: 240px"
-                        placeholder="璇疯緭鍏ュ疄闄呬繚鍏讳汉"
-                        clearable
-                        :prefix-icon="Search"
-                        @change="getTableData" />
+              <el-input
+                  v-model="filters.maintenanceActuallyName"
+                  style="width: 240px"
+                  placeholder="璇疯緭鍏ュ疄闄呬繚鍏讳汉"
+                  clearable
+                  :prefix-icon="Search"
+                  @change="getTableData"
+              />
             </el-form-item>
             <el-form-item>
-              <el-button type="primary"
-                         @click="getTableData">鎼滅储</el-button>
+              <el-button type="primary" @click="getTableData">鎼滅储</el-button>
               <el-button @click="resetFilters">閲嶇疆</el-button>
             </el-form-item>
           </el-form>
         </div>
         <div class="table_list">
           <div class="actions">
-            <el-text class="mx-1"
-                     size="large">淇濆吇璁板綍</el-text>
+            <el-text class="mx-1" size="large">浠诲姟璁板綍</el-text>
             <div>
-              <el-button type="success"
-                         icon="Van"
-                         @click="addPlan">
+              <el-button type="success" icon="Van" @click="addPlan">
                 鏂板璁″垝
               </el-button>
               <el-button @click="handleOut">
                 瀵煎嚭
               </el-button>
-              <el-button type="danger"
-                         icon="Delete"
-                         :disabled="multipleList.length <= 0 || hasFinishedStatus"
-                         @click="delRepairByIds(multipleList.map((item) => item.id))">
+              <el-button
+                type="danger"
+                icon="Delete"
+                :disabled="multipleList.length <= 0 || hasFinishedStatus"
+                @click="delRepairByIds(multipleList.map((item) => item.id))"
+              >
                 鎵归噺鍒犻櫎
               </el-button>
             </div>
           </div>
-          <PIMTable rowKey="id"
-                    isSelection
-                    :column="columns"
-                    :tableData="dataList"
-                    :page="{
+         <PIMTable
+        rowKey="id"
+        isSelection
+        :column="columns"
+        :tableData="dataList"
+        :page="{
           current: pagination.currentPage,
           size: pagination.pageSize,
           total: pagination.total,
         }"
-                    @selection-change="handleSelectionChange"
-                    @pagination="changePage">
-            <template #maintenanceResultRef="{ row }">
-              <div>{{ row.maintenanceResult || '-' }}</div>
-            </template>
-            <template #statusRef="{ row }">
-              <el-tag v-if="row.status === 2"
-                      type="danger">澶辫触</el-tag>
-              <el-tag v-if="row.status === 1"
-                      type="success">瀹岀粨</el-tag>
-              <el-tag v-if="row.status === 0"
-                      type="warning">寰呬繚鍏�</el-tag>
-            </template>
-            <template #operation="{ row }">
-              <!-- 杩欎釜鍔熻兘璺熸柊澧炰繚鍏诲姛鑳戒竴妯′竴鏍凤紝鏈夊暐鎰忎箟锛� -->
-              <!-- <el-button
+        @selection-change="handleSelectionChange"
+        @pagination="changePage"
+      >
+        <template #maintenanceResultRef="{ row }">
+          <div>{{ row.maintenanceResult || '-' }}</div>
+        </template>
+        <template #statusRef="{ row }">
+          <el-tag v-if="row.status === 2" type="danger">澶辫触</el-tag>
+          <el-tag v-if="row.status === 1" type="success">瀹岀粨</el-tag>
+          <el-tag v-if="row.status === 0" type="warning">寰呬繚鍏�</el-tag>
+        </template>
+        <template #operation="{ row }">
+          <!-- 杩欎釜鍔熻兘璺熸柊澧炰繚鍏诲姛鑳戒竴妯′竴鏍凤紝鏈夊暐鎰忎箟锛� -->
+          <!-- <el-button
               type="primary"
               text
               @click="addMaintain(row)"
           >
             鏂板淇濆吇
           </el-button> -->
-              <el-button type="primary"
-                         link
-                         :disabled="row.status === 1"
-                         @click="editPlan(row.id)">
-                缂栬緫
-              </el-button>
-              <el-button type="success"
-                         link
-                         :disabled="row.status === 1"
-                         @click="addMaintain(row)">
-                淇濆吇
-              </el-button>
-              <el-button type="danger"
-                         link
-                         :disabled="row.status === 1"
-                         @click="delRepairByIds(row.id)">
-                鍒犻櫎
-              </el-button>
-              <el-button type="primary"
-                         link
-                         @click="openFileDialog(row)">
-                闄勪欢
-              </el-button>
-            </template>
-          </PIMTable>
+          <el-button
+            type="primary"
+            link
+            :disabled="row.status === 1"
+            @click="editPlan(row.id)"
+          >
+            缂栬緫
+          </el-button>
+          <el-button
+            type="success"
+            link
+            :disabled="row.status === 1"
+            @click="addMaintain(row)"
+          >
+            淇濆吇
+          </el-button>
+          <el-button
+            type="danger"
+            link
+            :disabled="row.status === 1"
+            @click="delRepairByIds(row.id)"
+          >
+            鍒犻櫎
+          </el-button>
+          <el-button
+            type="primary"
+            link
+            @click="openFileDialog(row)"
+          >
+            闄勪欢
+          </el-button>
+        </template>
+      </PIMTable>
         </div>
       </el-tab-pane>
     </el-tabs>
-    <PlanModal ref="planModalRef"
-               @ok="getTableData" />
-    <MaintenanceModal ref="maintainModalRef"
-                      @ok="getTableData" />
-    <FormDia ref="formDiaRef"
-             @closeDia="getScheduledTableData" />
-    <FileList v-if="fileDialogVisible"
-              v-model:visible="fileDialogVisible"
-              :record-type="'device_maintenance'"
-              :record-id="currentMaintenanceTaskId" />
+    <PlanModal ref="planModalRef" @ok="getTableData" />
+        <MaintenanceModal ref="maintainModalRef" @ok="getTableData" />
+        <FormDia ref="formDiaRef" @closeDia="getScheduledTableData" />
+    <FileListDialog 
+      ref="fileListDialogRef"
+      v-model="fileDialogVisible"
+      :show-upload-button="true"
+      :show-delete-button="true"
+      :delete-method="handleAttachmentDelete"
+      :name-column-label="'闄勪欢鍚嶇О'"
+      :rulesRegulationsManagementId="currentMaintenanceTaskId"
+      @upload="handleAttachmentUpload" />
   </div>
 </template>
 
 <script setup>
-  import {
-    ref,
-    onMounted,
-    reactive,
-    getCurrentInstance,
-    nextTick,
-    computed,
-    defineAsyncComponent,
-  } from "vue";
-  import { Search } from "@element-plus/icons-vue";
-  import { ElMessage, ElMessageBox } from "element-plus";
-  import PlanModal from "./Form/PlanModal.vue";
-  import MaintenanceModal from "./Form/MaintenanceModal.vue";
-  import FormDia from "./Form/formDia.vue";
-  import {
-    getUpkeepPage,
-    delUpkeep,
-    deviceMaintenanceTaskList,
-    deviceMaintenanceTaskDel,
-  } from "@/api/equipmentManagement/upkeep";
-  import dayjs from "dayjs";
+import { ref, onMounted, reactive, getCurrentInstance, nextTick, computed } from 'vue'
+import { Search } from '@element-plus/icons-vue'
+import { ElMessage, ElMessageBox } from 'element-plus'
+import PlanModal from './Form/PlanModal.vue'
+import MaintenanceModal from './Form/MaintenanceModal.vue'
+import FormDia from './Form/formDia.vue'
+import FileListDialog from '@/components/Dialog/FileListDialog.vue'
+import {
+  getUpkeepPage,
+  delUpkeep,
+  deviceMaintenanceTaskList,
+  deviceMaintenanceTaskDel,
+  deviceMaintenanceTaskChangeEnable,
+} from '@/api/equipmentManagement/upkeep'
+import {
+  listMaintenanceTaskFiles,
+  addMaintenanceTaskFile,
+  delMaintenanceTaskFile,
+} from '@/api/equipmentManagement/maintenanceTaskFile'
+import dayjs from 'dayjs'
 
-  const { proxy } = getCurrentInstance();
-  const FileList = defineAsyncComponent(() =>
-    import("@/components/Dialog/FileList.vue")
-  );
+const { proxy } = getCurrentInstance()
 
-  // Tab鐩稿叧
-  const activeTab = ref("scheduled");
+// Tab鐩稿叧
+const activeTab = ref('scheduled')
 
-  // 璁″垝寮圭獥鎺у埗鍣�
-  const planModalRef = ref();
-  // 淇濆吇寮圭獥鎺у埗鍣�
-  const maintainModalRef = ref();
-  // 瀹氭椂浠诲姟寮圭獥鎺у埗鍣�
-  const formDiaRef = ref();
-  // 闄勪欢寮圭獥
-  const fileListDialogRef = ref(null);
-  const fileDialogVisible = ref(false);
-  const currentMaintenanceTaskId = ref(null);
+// 璁″垝寮圭獥鎺у埗鍣�
+const planModalRef = ref()
+// 淇濆吇寮圭獥鎺у埗鍣�
+const maintainModalRef = ref()
+// 瀹氭椂浠诲姟寮圭獥鎺у埗鍣�
+const formDiaRef = ref()
+// 闄勪欢寮圭獥
+const fileListDialogRef = ref(null)
+const fileDialogVisible = ref(false)
+const currentMaintenanceTaskId = ref(null)
 
-  // 淇濆吇璁板綍tab锛堝師璁惧淇濆吇椤甸潰锛夌浉鍏冲彉閲�
-  const filters = reactive({
-    deviceName: "",
-    maintenancePlanTime: "",
-    maintenanceActuallyTime: "",
-    maintenanceActuallyName: "",
-  });
+// 浠诲姟璁板綍tab锛堝師璁惧淇濆吇椤甸潰锛夌浉鍏冲彉閲�
+const filters = reactive({
+  deviceName: '',
+  maintenancePlanTime: '',
+  maintenanceActuallyTime: '',
+  maintenanceActuallyName: '',
+})
 
-  const dataList = ref([]);
-  const pagination = ref({
-    currentPage: 1,
-    pageSize: 10,
-    total: 0,
-  });
-  const multipleList = ref([]);
+const dataList = ref([])
+const pagination = ref({
+  currentPage: 1,
+  pageSize: 10,
+  total: 0,
+})
+const multipleList = ref([])
 
-  // 淇濆吇浠诲姟tab鐩稿叧鍙橀噺
-  const scheduledFilters = reactive({
-    taskName: "",
-    status: "",
-  });
+// 瀹氭椂浠诲姟绠$悊tab鐩稿叧鍙橀噺
+const scheduledFilters = reactive({
+  taskName: '',
+  isEnabled: undefined,
+})
 
-  const scheduledDataList = ref([]);
-  const scheduledPagination = reactive({
-    currentPage: 1,
-    pageSize: 10,
-    total: 0,
-  });
-  const scheduledMultipleList = ref([]);
+const scheduledDataList = ref([])
+const scheduledPagination = reactive({
+  currentPage: 1,
+  pageSize: 10,
+  total: 0,
+})
+const scheduledMultipleList = ref([])
 
-  // 淇濆吇浠诲姟琛ㄦ牸鍒楅厤缃�
-  const scheduledColumns = ref([
-    { prop: "taskName", label: "璁惧鍚嶇О" },
-    {
-      label: "瑙勬牸鍨嬪彿",
-      prop: "deviceModel",
-    },
-    {
-      label: "淇濆吇椤圭洰",
-      prop: "machineryCategory",
-      minWidth: 120,
-      formatData: cell => cell || "--",
-    },
-    {
-      prop: "frequencyType",
-      label: "棰戞",
-      minWidth: 150,
-      // PIMTable 浣跨敤鐨勬槸 formatData锛岃�屼笉鏄� Element-Plus 鐨� formatter
-      formatData: cell =>
-        ({
-          DAILY: "姣忔棩",
-          WEEKLY: "姣忓懆",
-          MONTHLY: "姣忔湀",
-          QUARTERLY: "瀛e害",
-        }[cell] || ""),
-    },
-    {
-      prop: "frequencyDetail",
-      label: "寮�濮嬫棩鏈熶笌鏃堕棿",
-      minWidth: 150,
-      // 鍚屾牱鏀圭敤 formatData锛孭IMTable 鍐呴儴浼氭妸鍗曞厓鏍煎�间紶杩涙潵
-      formatData: cell => {
-        if (typeof cell !== "string") return "";
-        let val = cell;
-        const replacements = {
-          MON: "鍛ㄤ竴",
-          TUE: "鍛ㄤ簩",
-          WED: "鍛ㄤ笁",
-          THU: "鍛ㄥ洓",
-          FRI: "鍛ㄤ簲",
-          SAT: "鍛ㄥ叚",
-          SUN: "鍛ㄦ棩",
-        };
-        // 浣跨敤姝e垯涓�娆℃�ф浛鎹㈡墍鏈夊尮閰嶉」
-        return val.replace(
-          /MON|TUE|WED|THU|FRI|SAT|SUN/g,
-          match => replacements[match]
-        );
-      },
-    },
-    { prop: "maintenancePerson", label: "淇濆吇浜�", minWidth: 100 },
-    { prop: "registrant", label: "鐧昏浜�", minWidth: 100 },
-    {
-      prop: "registrationDate",
-      label: "鐧昏鏃ユ湡",
-      minWidth: 100,
-      formatData: cell =>
-        cell ? dayjs(cell).format("YYYY-MM-DD HH:mm:ss") : "-",
-    },
-    {
-      fixed: "right",
-      label: "鎿嶄綔",
-      dataType: "slot",
-      slot: "operation",
-      align: "center",
-      width: "200px",
-    },
-  ]);
+// 瀹氭椂浠诲姟绠$悊琛ㄦ牸鍒楅厤缃�
+const scheduledColumns = ref([
+	{
+		label: "鎵�鍦ㄥ尯鍩�",
+		prop: "areaName",
+	},
+	{ prop: "taskName", label: "璁惧鍚嶇О"},
+	{
+		label: "瑙勬牸鍨嬪彿",
+		prop: "deviceModel",
+	},
+	{
+		prop: "frequencyType",
+		label: "棰戞",
+		minWidth: 150,
+		// PIMTable 浣跨敤鐨勬槸 formatData锛岃�屼笉鏄� Element-Plus 鐨� formatter
+		formatData: (cell) => ({
+			DAILY: "姣忔棩",
+			WEEKLY: "姣忓懆",
+			MONTHLY: "姣忔湀",
+			QUARTERLY: "瀛e害",
+			YEARLY: "姣忓勾",
+		}[cell] || "")
+	},
+	{
+		prop: "frequencyDetail",
+		label: "寮�濮嬫棩鏈熶笌鏃堕棿",
+		minWidth: 150,
+		// 鍚屾牱鏀圭敤 formatData锛孭IMTable 鍐呴儴浼氭妸鍗曞厓鏍煎�间紶杩涙潵
+		formatData: (cell) => {
+			if (typeof cell !== 'string') return '';
+			let val = cell;
+			const replacements = {
+				MON: '鍛ㄤ竴',
+				TUE: '鍛ㄤ簩',
+				WED: '鍛ㄤ笁',
+				THU: '鍛ㄥ洓',
+				FRI: '鍛ㄤ簲',
+				SAT: '鍛ㄥ叚',
+				SUN: '鍛ㄦ棩'
+			};
+			// 浣跨敤姝e垯涓�娆℃�ф浛鎹㈡墍鏈夊尮閰嶉」
+			return val.replace(/MON|TUE|WED|THU|FRI|SAT|SUN/g, match => replacements[match]);
+		}
+	},
+	{ prop: "registrant", label: "鐧昏浜�", minWidth: 100 },
+	{ prop: "registrationDate", label: "鐧昏鏃ユ湡", minWidth: 100 },
+	{
+		label: "鏄惁鍚敤",
+		prop: "isEnabled",
+		dataType: "slot",
+		slot: "isEnabledRef",
+		align: "center",
+		width: "120px",
+	},
+	{
+		fixed: "right",
+		label: "鎿嶄綔",
+		dataType: "slot",
+		slot: "operation",
+		align: "center",
+		width: "200px",
+	},
+])
 
-  // 淇濆吇璁板綍琛ㄦ牸鍒楅厤缃紙鍘熻澶囦繚鍏昏〃鏍煎垪锛�
-  const columns = ref([
-    {
-      label: "璁惧鍚嶇О",
-      align: "center",
-      prop: "deviceName",
-    },
-    {
-      label: "瑙勬牸鍨嬪彿",
-      align: "center",
-      prop: "deviceModel",
-    },
-    {
-      label: "璁″垝淇濆吇鏃ユ湡",
-      align: "center",
-      prop: "maintenancePlanTime",
-      formatData: cell => {
-        return cell == null ? "-" : dayjs(cell).format("YYYY-MM-DD");
-      },
-    },
-    {
-      label: "褰曞叆浜�",
-      align: "center",
-      prop: "createUserName",
-    },
-    {
-      label: "淇濆吇椤圭洰",
-      align: "center",
-      prop: "machineryCategory",
-      formatData: cell => cell || "--",
-    },
-    // {
-    //   label: "褰曞叆鏃ユ湡",
-    //   align: "center",
-    //   prop: "createTime",
-    //   formatData: (cell) => dayjs(cell).format("YYYY-MM-DD HH:mm:ss"),
-    //   width: 200,
-    // },
-    {
-      label: "瀹為檯淇濆吇浜�",
-      align: "center",
-      prop: "maintenanceActuallyName",
-    },
-    {
-      label: "瀹為檯淇濆吇鏃ユ湡",
-      align: "center",
-      prop: "maintenanceActuallyTime",
-      formatData: cell =>
-        cell ? dayjs(cell).format("YYYY-MM-DD HH:mm:ss") : "-",
-    },
-    {
-      label: "淇濆吇缁撴灉",
-      align: "center",
-      prop: "maintenanceResult",
-      dataType: "slot",
-      slot: "maintenanceResultRef",
-    },
-    {
-      label: "鐘舵��",
-      align: "center",
-      prop: "status",
-      dataType: "slot",
-      slot: "statusRef",
-    },
-    {
-      fixed: "right",
-      label: "鎿嶄綔",
-      dataType: "slot",
-      slot: "operation",
-      align: "center",
-      width: "350px",
-    },
-  ]);
+// 浠诲姟璁板綍琛ㄦ牸鍒楅厤缃紙鍘熻澶囦繚鍏昏〃鏍煎垪锛�
+const columns = ref([
+	{
+		label: "鎵�鍦ㄥ尯鍩�",
+		prop: "areaName",
+	},
+	{
+		label: "璁惧鍚嶇О",
+		align: "center",
+		prop: "deviceName",
+	},
+	{
+		label: "瑙勬牸鍨嬪彿",
+		align: "center",
+		prop: "deviceModel",
+	},
+	{
+		label: "璁″垝淇濆吇鏃ユ湡",
+		align: "center",
+		prop: "maintenancePlanTime",
+		formatData: (cell) => dayjs(cell).format("YYYY-MM-DD"),
+	},
+	{
+		label: "褰曞叆浜�",
+		align: "center",
+		prop: "createUserName",
+	},
+	// {
+	//   label: "褰曞叆鏃ユ湡",
+	//   align: "center",
+	//   prop: "createTime",
+	//   formatData: (cell) => dayjs(cell).format("YYYY-MM-DD HH:mm:ss"),
+	//   width: 200,
+	// },
+	{
+		label: "瀹為檯淇濆吇浜�",
+		align: "center",
+		prop: "maintenanceActuallyName",
+	},
+	{
+		label: "瀹為檯淇濆吇鏃ユ湡",
+		align: "center",
+		prop: "maintenanceActuallyTime",
+		formatData: (cell) =>
+			cell ? dayjs(cell).format("YYYY-MM-DD HH:mm:ss") : "-",
+	},
+	{
+		label: "淇濆吇缁撴灉",
+		align: "center",
+		prop: "maintenanceResult",
+		dataType: "slot",
+		slot: "maintenanceResultRef",
+	},
+	{
+		label: "鐘舵��",
+		align: "center",
+		prop: "status",
+		dataType: "slot",
+		slot: "statusRef",
+	},
+	{
+		fixed: "right",
+		label: "鎿嶄綔",
+		dataType: "slot",
+		slot: "operation",
+		align: "center",
+		width: "350px",
+	},
+])
 
-  // Tab鍒囨崲澶勭悊
-  const handleTabChange = tabName => {
-    if (tabName === "record") {
-      getTableData();
-    } else if (tabName === "scheduled") {
-      getScheduledTableData();
+// Tab鍒囨崲澶勭悊
+const handleTabChange = (tabName) => {
+  if (tabName === 'record') {
+    getTableData()
+  } else if (tabName === 'scheduled') {
+    getScheduledTableData()
+  }
+}
+
+// 瀹氭椂浠诲姟绠$悊鐩稿叧鏂规硶
+const getScheduledTableData = async () => {
+  try {
+    const params = {
+      current: scheduledPagination.currentPage,
+      size: scheduledPagination.pageSize,
+      taskName: scheduledFilters.taskName || undefined,
+      isEnabled: scheduledFilters.isEnabled,
     }
-  };
-
-  // 淇濆吇浠诲姟鐩稿叧鏂规硶
-  const getScheduledTableData = async () => {
-    try {
-      const params = {
-        current: scheduledPagination.currentPage,
-        size: scheduledPagination.pageSize,
-        taskName: scheduledFilters.taskName || undefined,
-        status: scheduledFilters.status || undefined,
-      };
-      const { code, data } = await deviceMaintenanceTaskList(params);
-      if (code === 200) {
-        scheduledDataList.value = data?.records || [];
-        scheduledPagination.total = data?.total || 0;
-      }
-    } catch (error) {
-      ElMessage.error("鑾峰彇瀹氭椂浠诲姟鍒楄〃澶辫触");
+    const { code, data } = await deviceMaintenanceTaskList(params)
+    if (code === 200) {
+      const records = data?.records || []
+      scheduledDataList.value = records.map((item) => ({
+        ...item,
+        isEnabled: Number(item.isEnabled ?? item.status ?? 1),
+        enableSwitchLoading: false,
+      }))
+      scheduledPagination.total = data?.total || 0
     }
-  };
+  } catch (error) {
+    ElMessage.error('鑾峰彇瀹氭椂浠诲姟鍒楄〃澶辫触')
+  }
+}
 
-  const resetScheduledFilters = () => {
-    scheduledFilters.taskName = "";
-    scheduledFilters.status = "";
-    getScheduledTableData();
-  };
+const resetScheduledFilters = () => {
+  scheduledFilters.taskName = ''
+  scheduledFilters.isEnabled = undefined
+  getScheduledTableData()
+}
 
-  const handleScheduledSelectionChange = selection => {
-    scheduledMultipleList.value = selection;
-  };
+const handleScheduledSelectionChange = (selection) => {
+  scheduledMultipleList.value = selection
+}
 
-  const changeScheduledPage = page => {
-    scheduledPagination.currentPage = page.page;
-    scheduledPagination.pageSize = page.limit;
-    getScheduledTableData();
-  };
+const changeScheduledPage = (page) => {
+  scheduledPagination.currentPage = page.page
+  scheduledPagination.pageSize = page.limit
+  getScheduledTableData()
+}
 
-  const addScheduledTask = () => {
-    nextTick(() => {
-      formDiaRef.value?.openDialog("add");
-    });
-  };
+const addScheduledTask = () => {
+  nextTick(() => {
+		formDiaRef.value?.openDialog('add');
+	});
+}
 
-  const editScheduledTask = row => {
-    if (row) {
-      nextTick(() => {
-        formDiaRef.value?.openDialog("edit", row);
-      });
-    }
-  };
+const editScheduledTask = (row) => {
+  if (row) {
+		nextTick(() => {
+			formDiaRef.value?.openDialog('edit', row);
+		});
+  }
+}
 
-  const delScheduledTaskByIds = async ids => {
-    try {
-      await ElMessageBox.confirm("纭畾鍒犻櫎閫変腑鐨勫畾鏃朵换鍔″悧锛�", "鎻愮ず", {
-        type: "warning",
-      });
-      const payload = Array.isArray(ids) ? ids : [ids];
-      await deviceMaintenanceTaskDel(payload);
-      ElMessage.success("鍒犻櫎瀹氭椂浠诲姟鎴愬姛");
-      getScheduledTableData();
-    } catch (error) {
-      // 鐢ㄦ埛鍙栨秷鍒犻櫎
-    }
-  };
-
-  const handleScheduledOut = () => {
-    ElMessage.info("瀵煎嚭瀹氭椂浠诲姟鍔熻兘寰呭疄鐜�");
-  };
-
-  // 淇濆吇璁板綍鐩稿叧鏂规硶锛堝師璁惧淇濆吇椤甸潰鏂规硶锛�
-  const getTableData = async () => {
-    try {
-      const params = {
-        current: pagination.value.currentPage,
-        size: pagination.value.pageSize,
-        deviceName: filters.deviceName || undefined,
-        maintenancePlanTime: filters.maintenancePlanTime
-          ? dayjs(filters.maintenancePlanTime).format("YYYY-MM-DD")
-          : undefined,
-        maintenanceActuallyTime: filters.maintenanceActuallyTime
-          ? dayjs(filters.maintenanceActuallyTime).format("YYYY-MM-DD")
-          : undefined,
-        maintenanceActuallyName: filters.maintenanceActuallyName || undefined,
-      };
-
-      const { code, data } = await getUpkeepPage(params);
-      if (code === 200) {
-        dataList.value = data.records;
-        pagination.value.total = data.total;
-      }
-    } catch (error) {
-      console.log(error);
-    }
-  };
-
-  const resetFilters = () => {
-    filters.deviceName = "";
-    filters.maintenancePlanTime = "";
-    filters.maintenanceActuallyTime = "";
-    filters.maintenanceActuallyName = "";
-    getTableData();
-  };
-
-  const handleSelectionChange = selection => {
-    multipleList.value = selection;
-  };
-
-  // 妫�鏌ラ�変腑鐨勮褰曚腑鏄惁鏈夊畬缁撶姸鎬佺殑
-  const hasFinishedStatus = computed(() => {
-    return multipleList.value.some(item => item.status === 1);
-  });
-
-  const changePage = page => {
-    pagination.value.currentPage = page.page;
-    pagination.value.pageSize = page.limit;
-    getTableData();
-  };
-
-  const addMaintain = row => {
-    maintainModalRef.value.open(row.id, row);
-  };
-
-  const addPlan = () => {
-    planModalRef.value.openModal();
-  };
-
-  const editPlan = id => {
-    planModalRef.value.openEdit(id);
-  };
-
-  const delRepairByIds = async ids => {
-    // 妫�鏌ユ槸鍚︽湁瀹岀粨鐘舵�佺殑璁板綍
-    const hasFinished = multipleList.value.some(item => item.status === 1);
-    if (hasFinished) {
-      ElMessage.warning("涓嶈兘鍒犻櫎鐘舵�佷负瀹岀粨鐨勮褰�");
-      return;
-    }
-
-    try {
-      await ElMessageBox.confirm("纭鍒犻櫎淇濆吇鏁版嵁, 姝ゆ搷浣滀笉鍙��?", "璀﹀憡", {
-        confirmButtonText: "纭畾",
-        cancelButtonText: "鍙栨秷",
-        type: "warning",
-      });
-
-      const { code } = await delUpkeep(ids);
-      if (code === 200) {
-        ElMessage.success("鍒犻櫎鎴愬姛");
-        getTableData();
-      }
-    } catch (error) {
-      // 鐢ㄦ埛鍙栨秷鍒犻櫎
-    }
-  };
-
-  const handleOut = () => {
-    ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
-      confirmButtonText: "纭",
-      cancelButtonText: "鍙栨秷",
-      type: "warning",
+const delScheduledTaskByIds = async (ids) => {
+  try {
+    await ElMessageBox.confirm('纭畾鍒犻櫎閫変腑鐨勫畾鏃朵换鍔″悧锛�', '鎻愮ず', {
+      type: 'warning',
     })
-      .then(() => {
-        proxy.download("/device/maintenance/export", {}, "璁惧淇濆吇.xlsx");
-      })
-      .catch(() => {
-        ElMessage.info("宸插彇娑�");
-      });
-  };
+    const payload = Array.isArray(ids) ? ids : [ids]
+    await deviceMaintenanceTaskDel(payload)
+    ElMessage.success('鍒犻櫎瀹氭椂浠诲姟鎴愬姛')
+    getScheduledTableData()
+  } catch (error) {
+    // 鐢ㄦ埛鍙栨秷鍒犻櫎
+  }
+}
 
-  const handleDateChange = (date, type) => {
-    if (type === 1) {
-      filters.maintenanceActuallyTime = date
-        ? dayjs(date).format("YYYY-MM-DD")
-        : "";
-    } else {
-      filters.maintenancePlanTime = date ? dayjs(date).format("YYYY-MM-DD") : "";
+const handleScheduledEnableBeforeChange = async (row) => {
+  if (row.enableSwitchLoading) {
+    return false
+  }
+  const nextValue = Number(row.isEnabled) === 1 ? 0 : 1
+  row.enableSwitchLoading = true
+  try {
+    const res = await deviceMaintenanceTaskChangeEnable({
+      id: row.id,
+      isEnabled: nextValue,
+    })
+    if (res?.code !== 200) {
+      throw new Error(res?.msg || '鏇存柊澶辫触')
     }
-    getTableData();
-  };
+    ElMessage.success('鍚敤鐘舵�佸凡鏇存柊')
+    return true
+  } catch (error) {
+    ElMessage.error(error?.message || '鍚敤鐘舵�佹洿鏂板け璐�')
+    return false
+  } finally {
+    row.enableSwitchLoading = false
+  }
+}
 
-  // 鎵撳紑闄勪欢寮圭獥
-  const openFileDialog = async row => {
-    currentMaintenanceTaskId.value = row.id;
-    fileDialogVisible.value = true;
-  };
+const handleScheduledOut = () => {
+  ElMessage.info('瀵煎嚭瀹氭椂浠诲姟鍔熻兘寰呭疄鐜�')
+}
 
-  onMounted(() => {
-    // 鏍规嵁榛樿婵�娲荤殑 Tab 璋冪敤瀵瑰簲鐨勬煡璇㈡帴鍙�
-    if (activeTab.value === "scheduled") {
-      getScheduledTableData();
-    } else {
-      getTableData();
+// 浠诲姟璁板綍鐩稿叧鏂规硶锛堝師璁惧淇濆吇椤甸潰鏂规硶锛�
+const getTableData = async () => {
+  try {
+    const params = {
+      current: pagination.value.currentPage,
+      size: pagination.value.pageSize,
+      deviceName: filters.deviceName || undefined,
+      maintenancePlanTime: filters.maintenancePlanTime ? dayjs(filters.maintenancePlanTime).format('YYYY-MM-DD') : undefined,
+      maintenanceActuallyTime: filters.maintenanceActuallyTime ? dayjs(filters.maintenanceActuallyTime).format('YYYY-MM-DD') : undefined,
+      maintenanceActuallyName: filters.maintenanceActuallyName || undefined,
     }
-  });
+
+    const { code, data } = await getUpkeepPage(params)
+    if (code === 200) {
+      dataList.value = data.records
+      pagination.value.total = data.total
+    }
+  } catch (error) {
+    console.log(error);
+    
+  }
+}
+
+const resetFilters = () => {
+  filters.deviceName = ''
+  filters.maintenancePlanTime = ''
+  filters.maintenanceActuallyTime = ''
+  filters.maintenanceActuallyName = ''
+  getTableData()
+}
+
+const handleSelectionChange = (selection) => {
+  multipleList.value = selection
+}
+
+// 妫�鏌ラ�変腑鐨勮褰曚腑鏄惁鏈夊畬缁撶姸鎬佺殑
+const hasFinishedStatus = computed(() => {
+  return multipleList.value.some(item => item.status === 1)
+})
+
+const changePage = (page) => {
+  pagination.value.currentPage = page.page
+  pagination.value.pageSize = page.limit
+  getTableData()
+}
+
+const addMaintain = (row) => {
+  maintainModalRef.value.open(row.id, row)
+}
+
+const addPlan = () => {
+  planModalRef.value.openModal()
+}
+
+const editPlan = (id) => {
+  planModalRef.value.openEdit(id)
+}
+
+const delRepairByIds = async (ids) => {
+  // 妫�鏌ユ槸鍚︽湁瀹岀粨鐘舵�佺殑璁板綍
+  const hasFinished = multipleList.value.some(item => item.status === 1)
+  if (hasFinished) {
+    ElMessage.warning('涓嶈兘鍒犻櫎鐘舵�佷负瀹岀粨鐨勮褰�')
+    return
+  }
+  
+  try {
+    await ElMessageBox.confirm('纭鍒犻櫎淇濆吇鏁版嵁, 姝ゆ搷浣滀笉鍙��?', '璀﹀憡', {
+      confirmButtonText: '纭畾',
+      cancelButtonText: '鍙栨秷',
+      type: 'warning',
+    })
+    
+    const { code } = await delUpkeep(ids)
+    if (code === 200) {
+      ElMessage.success('鍒犻櫎鎴愬姛')
+      getTableData()
+    }
+  } catch (error) {
+    // 鐢ㄦ埛鍙栨秷鍒犻櫎
+  }
+}
+
+const handleOut = () => {
+  ElMessageBox.confirm('閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�', '瀵煎嚭', {
+    confirmButtonText: '纭',
+    cancelButtonText: '鍙栨秷',
+    type: 'warning',
+  })
+    .then(() => {
+      proxy.download('/device/maintenance/export', {}, '璁惧淇濆吇.xlsx')
+    })
+    .catch(() => {
+      ElMessage.info('宸插彇娑�')
+    })
+}
+
+const handleDateChange = (date, type) => {
+  if (type === 1) {
+    filters.maintenanceActuallyTime = date ? dayjs(date).format('YYYY-MM-DD') : ''
+  } else {
+    filters.maintenancePlanTime = date ? dayjs(date).format('YYYY-MM-DD') : ''
+  }
+  getTableData()
+}
+
+// 闄勪欢鐩稿叧鏂规硶
+// 鏌ヨ闄勪欢鍒楄〃
+const fetchMaintenanceTaskFiles = async (deviceMaintenanceId) => {
+  try {
+    const params = {
+      current: 1,
+      size: 100,
+      deviceMaintenanceId,
+      rulesRegulationsManagementId:deviceMaintenanceId
+    }
+    const res = await listMaintenanceTaskFiles(params)
+    const records = res?.data?.records || []
+    const mapped = records.map(item => ({
+      id: item.id,
+      name: item.fileName || item.name,
+      url: item.fileUrl || item.url,
+      raw: item,
+    }))
+    fileListDialogRef.value?.setList(mapped)
+  } catch (error) {
+    ElMessage.error('鑾峰彇闄勪欢鍒楄〃澶辫触')
+  }
+}
+
+// 鎵撳紑闄勪欢寮圭獥
+const openFileDialog = async (row) => {
+  currentMaintenanceTaskId.value = row.id
+  fileDialogVisible.value = true
+  await fetchMaintenanceTaskFiles(row.id)
+}
+
+// 鍒锋柊闄勪欢鍒楄〃
+const refreshFileList = async () => {
+  if (!currentMaintenanceTaskId.value) return
+  await fetchMaintenanceTaskFiles(currentMaintenanceTaskId.value)
+}
+
+// 涓婁紶闄勪欢
+const handleAttachmentUpload = async (filePayload) => {
+  if (!currentMaintenanceTaskId.value) return
+  try {
+    const payload = {
+      name: filePayload?.fileName || filePayload?.name,
+      url: filePayload?.fileUrl || filePayload?.url,
+      deviceMaintenanceId: currentMaintenanceTaskId.value,
+    }
+    await addMaintenanceTaskFile(payload)
+    ElMessage.success('鏂囦欢涓婁紶鎴愬姛')
+    await refreshFileList()
+  } catch (error) {
+    ElMessage.error('鏂囦欢涓婁紶澶辫触')
+  }
+}
+
+// 鍒犻櫎闄勪欢
+const handleAttachmentDelete = async (row) => {
+  if (!row?.id) return false
+  try {
+    await ElMessageBox.confirm('纭鍒犻櫎璇ラ檮浠讹紵', '鎻愮ず', { type: 'warning' })
+  } catch {
+    return false
+  }
+  try {
+    await delMaintenanceTaskFile(row.id)
+    ElMessage.success('鍒犻櫎鎴愬姛')
+    await refreshFileList()
+    return true
+  } catch (error) {
+    ElMessage.error('鍒犻櫎澶辫触')
+    return false
+  }
+}
+
+onMounted(() => {
+  // 鏍规嵁榛樿婵�娲荤殑 Tab 璋冪敤瀵瑰簲鐨勬煡璇㈡帴鍙�
+  if (activeTab.value === 'scheduled') {
+    getScheduledTableData()
+  } else {
+    getTableData()
+  }
+})
 </script>
 
 <style lang="scss" scoped>
-  .table_list {
-    margin-top: unset;
-  }
-  .actions {
-    display: flex;
-    justify-content: space-between;
-    margin-bottom: 10px;
-  }
+.table_list {
+  margin-top: unset;
+}
+.actions {
+  display: flex;
+  justify-content: space-between;
+  margin-bottom: 10px;
+}
 </style>
 
 

--
Gitblit v1.9.3