| | |
| | | style="width: 220px" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item v-show="activeRadio === 'taskManage'" label="是否启用"> |
| | | <el-select |
| | | v-model="queryParams.isEnabled" |
| | | placeholder="请选择" |
| | | clearable |
| | | style="width: 140px" |
| | | > |
| | | <el-option label="启用" :value="1" /> |
| | | <el-option label="禁用" :value="0" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item v-show="activeRadio === 'task'" label="执行日期"> |
| | | <el-date-picker |
| | | v-model="queryDate" |
| | |
| | | <span v-else class="no-data">--</span> |
| | | </div> |
| | | </template> |
| | | <template #isEnabledSwitch="{ row }"> |
| | | <el-switch |
| | | v-model="row.isEnabled" |
| | | :active-value="1" |
| | | :inactive-value="0" |
| | | :loading="row.enableSwitchLoading" |
| | | :before-change="() => handleTimingTaskEnableBeforeChange(row)" |
| | | /> |
| | | </template> |
| | | </PIMTable> |
| | | </el-card> |
| | | <form-dia ref="formDia" @closeDia="handleQuery" /> |
| | |
| | | |
| | | <script setup> |
| | | import { Delete, Plus } from "@element-plus/icons-vue"; |
| | | import { ElMessageBox } from "element-plus"; |
| | | import { ElMessage, ElMessageBox } from "element-plus"; |
| | | import { getCurrentInstance, nextTick, onMounted, reactive, ref } from "vue"; |
| | | import dayjs from "dayjs"; |
| | | import PIMTable from "@/components/PIMTable/PIMTable.vue"; |
| | | import FormDia from "@/views/equipmentManagement/inspectionManagement/components/formDia.vue"; |
| | | import ViewFiles from "@/views/equipmentManagement/inspectionManagement/components/viewFiles.vue"; |
| | | import { |
| | | changeTimingTaskEnable, |
| | | delTimingTask, |
| | | inspectionTaskList, |
| | | timingTaskList, |
| | |
| | | const queryParams = reactive({ |
| | | taskName: "", |
| | | areaId: undefined, |
| | | isEnabled: undefined, |
| | | createTimeStart: undefined, |
| | | createTimeEnd: undefined, |
| | | }); |
| | |
| | | { prop: "registrant", label: "登记人", minWidth: 100 }, |
| | | { prop: "createTime", label: "登记日期", width: 130 }, |
| | | ]); |
| | | |
| | | const isEnabledColumn = { |
| | | prop: "isEnabled", |
| | | label: "是否启用", |
| | | minWidth: 110, |
| | | dataType: "slot", |
| | | slot: "isEnabledSwitch", |
| | | }; |
| | | |
| | | // 巡检状态列(仅定时任务记录显示) |
| | | const inspectionStatusColumn = { |
| | |
| | | const radioChange = (value) => { |
| | | if (value === "taskManage") { |
| | | const operationColumn = getOperationColumn(["edit"]); |
| | | tableColumns.value = [...columns.value, ...(operationColumn ? [operationColumn] : [])]; |
| | | tableColumns.value = [...columns.value, isEnabledColumn, ...(operationColumn ? [operationColumn] : [])]; |
| | | } else { |
| | | const operationColumn = getOperationColumn(["viewFile"]); |
| | | // 定时任务记录添加巡检状态列 |
| | | tableColumns.value = [...columns.value, inspectionStatusColumn, inspectionResultColumn, ...(operationColumn ? [operationColumn] : [])]; |
| | | // 切换到定时任务记录时,默认查询当天 |
| | | queryDate.value = dayjs().format("YYYY-MM-DD"); |
| | | queryParams.isEnabled = undefined; |
| | | } |
| | | pageNum.value = 1; |
| | | pageSize.value = 10; |
| | |
| | | const rawData = res?.data?.records || []; |
| | | tableData.value = rawData.map((item) => { |
| | | const processedItem = { ...item }; |
| | | if (activeRadio.value === "taskManage") { |
| | | processedItem.isEnabled = Number( |
| | | processedItem.isEnabled ?? processedItem.status ?? 1 |
| | | ); |
| | | processedItem.enableSwitchLoading = false; |
| | | } |
| | | if (processedItem.inspector) { |
| | | if (typeof processedItem.inspector === "string") { |
| | | processedItem.inspector = processedItem.inspector |
| | |
| | | const resetQuery = () => { |
| | | queryParams.taskName = ""; |
| | | queryParams.areaId = undefined; |
| | | queryParams.isEnabled = undefined; |
| | | queryParams.createTimeStart = undefined; |
| | | queryParams.createTimeEnd = undefined; |
| | | // 定时任务记录时重置为当天 |
| | |
| | | selectedRows.value = selection; |
| | | }; |
| | | |
| | | const handleTimingTaskEnableBeforeChange = async (row) => { |
| | | if (row.enableSwitchLoading) { |
| | | return false; |
| | | } |
| | | const nextValue = Number(row.isEnabled) === 1 ? 0 : 1; |
| | | row.enableSwitchLoading = true; |
| | | try { |
| | | const res = await changeTimingTaskEnable({ |
| | | id: row.id, |
| | | isEnabled: nextValue, |
| | | }); |
| | | if (res?.code !== 200) { |
| | | throw new Error(res?.msg || "更新失败"); |
| | | } |
| | | ElMessage.success("启用状态已更新"); |
| | | return true; |
| | | } catch (error) { |
| | | proxy.$modal.msgError(error?.message || "启用状态更新失败"); |
| | | return false; |
| | | } finally { |
| | | row.enableSwitchLoading = false; |
| | | } |
| | | }; |
| | | |
| | | const handleOut = () => { |
| | | ElMessageBox.confirm("选中的内容将被导出,是否确认导出?", "导出", { |
| | | confirmButtonText: "确认", |