|
|
@@ -0,0 +1,662 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <!-- Tab标签区分手动/自动巡检 -->
|
|
|
+ <el-tabs v-model="activeTab" type="card" class="inspection-tabs" @tab-click="handleTabChange">
|
|
|
+ <el-tab-pane name="manual">
|
|
|
+ <span slot="label">
|
|
|
+ <i class="el-icon-user"></i> 手动巡检
|
|
|
+ </span>
|
|
|
+ </el-tab-pane>
|
|
|
+ <el-tab-pane name="auto">
|
|
|
+ <span slot="label">
|
|
|
+ <i class="el-icon-setting"></i> 自动巡检
|
|
|
+ </span>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+
|
|
|
+ <!-- 搜索区域 -->
|
|
|
+ <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
|
|
|
+ <el-form-item label="归属区域" prop="areaCode">
|
|
|
+ <el-select v-model="queryParams.areaCode" placeholder="请选择区域" clearable style="width: 200px">
|
|
|
+ <el-option v-for="item in areaOptions" :key="item.id" :label="item.label" :value="item.id" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="计划名称" prop="planName">
|
|
|
+ <el-input v-model="queryParams.planName" placeholder="请输入计划名称" clearable style="width: 180px"
|
|
|
+ @keyup.enter.native="handleQuery" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="计划状态" prop="planStatus">
|
|
|
+ <el-select v-model="queryParams.planStatus" placeholder="请选择状态" clearable style="width: 120px">
|
|
|
+ <el-option v-for="item in planStatusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="执行人" prop="executor" v-if="activeTab === 'manual'">
|
|
|
+ <el-input v-model="queryParams.executor" placeholder="请输入执行人" clearable style="width: 120px"
|
|
|
+ @keyup.enter.native="handleQuery" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <!-- 操作按钮 -->
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
|
|
+ v-hasPermi="['ems:inspection:plan:add']">
|
|
|
+ {{ activeTab === 'manual' ? '新增手动巡检' : '新增自动巡检' }}
|
|
|
+ </el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
|
|
|
+ v-hasPermi="['ems:inspection:plan:edit']">修改</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
|
|
|
+ v-hasPermi="['ems:inspection:plan:remove']">删除</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
|
|
|
+ v-hasPermi="['ems:inspection:plan:export']">导出</el-button>
|
|
|
+ </el-col>
|
|
|
+ <!-- 自动巡检:调度器管理按钮 -->
|
|
|
+ <el-col :span="1.5" v-if="activeTab === 'auto'">
|
|
|
+ <el-button type="info" plain icon="el-icon-s-operation" size="mini" @click="showSchedulerStatus"
|
|
|
+ v-hasPermi="['ems:inspection:plan:query']">调度器状态</el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <!-- 手动巡检表格 -->
|
|
|
+ <el-table v-if="activeTab === 'manual'" key="manual-table" v-loading="loading" :data="planList"
|
|
|
+ @selection-change="handleSelectionChange" border>
|
|
|
+ <el-table-column type="selection" width="50" align="center" />
|
|
|
+ <el-table-column label="计划代码" align="left" prop="planCode" width="180" show-overflow-tooltip>
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-link type="primary" @click="handleView(scope.row)">{{ scope.row.planCode }}</el-link>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="计划名称" align="left" prop="planName" min-width="160" show-overflow-tooltip />
|
|
|
+ <el-table-column label="归属区域" align="center" prop="areaName" width="130" />
|
|
|
+ <el-table-column label="目标类型" align="center" width="80">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>
|
|
|
+ <i :class="getTargetTypeIcon(scope.row.targetType)" style="margin-right: 4px"></i>
|
|
|
+ {{ getTargetTypeLabel(scope.row.targetType) }}
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="巡检目标" align="left" prop="targetNames" min-width="200" show-overflow-tooltip>
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tooltip :content="scope.row.targetNames" placement="top" :disabled="!scope.row.targetNames">
|
|
|
+ <span>{{ scope.row.targetNames || '-' }}</span>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="执行人" align="center" prop="executor" width="90" />
|
|
|
+ <el-table-column label="计划状态" align="center" width="90">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tag :type="getManualPlanStatusInfo(scope.row.planStatus).type" size="small" effect="light">
|
|
|
+ {{ getManualPlanStatusInfo(scope.row.planStatus).label }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="计划时间" align="center" prop="planTime" width="150">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ scope.row.planTime || '-' }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="创建时间" align="center" prop="createTime" width="150" />
|
|
|
+ <el-table-column label="操作" align="center" fixed="right" width="250" class-name="small-padding fixed-width">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <!-- 手动巡检:提交报告(待执行状态显示) -->
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-edit-outline"
|
|
|
+ @click="handleSubmitReport(scope.row)"
|
|
|
+ v-if="scope.row.planStatus === 0"
|
|
|
+ v-hasPermi="['ems:inspection:plan:execute']">
|
|
|
+ 提交报告
|
|
|
+ </el-button>
|
|
|
+ <!-- 已完成状态:查看报告 -->
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-document"
|
|
|
+ @click="handleViewReport(scope.row)"
|
|
|
+ v-if="scope.row.planStatus === 2">
|
|
|
+ 查看报告
|
|
|
+ </el-button>
|
|
|
+ <!-- 已完成状态:编辑报告 -->
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-edit-outline"
|
|
|
+ @click="handleEditReport(scope.row)"
|
|
|
+ v-if="scope.row.planStatus === 2"
|
|
|
+ v-hasPermi="['ems:inspection:report:edit']">
|
|
|
+ 编辑报告
|
|
|
+ </el-button>
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-edit"
|
|
|
+ @click="handleUpdate(scope.row)"
|
|
|
+ v-hasPermi="['ems:inspection:plan:edit']">
|
|
|
+ 编辑
|
|
|
+ </el-button>
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-delete" class="delete-btn"
|
|
|
+ @click="handleDelete(scope.row)"
|
|
|
+ v-hasPermi="['ems:inspection:plan:remove']">
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <!-- 自动巡检表格 - 新增调度相关列 -->
|
|
|
+ <el-table v-if="activeTab === 'auto'" key="auto-table" v-loading="loading" :data="planList"
|
|
|
+ @selection-change="handleSelectionChange" border>
|
|
|
+ <el-table-column type="selection" width="50" align="center" />
|
|
|
+ <el-table-column label="计划代码" align="left" prop="planCode" width="160" show-overflow-tooltip>
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-link type="primary" @click="handleView(scope.row)">{{ scope.row.planCode }}</el-link>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="计划名称" align="left" prop="planName" min-width="140" show-overflow-tooltip />
|
|
|
+ <el-table-column label="归属区域" align="center" prop="areaName" width="100" />
|
|
|
+ <el-table-column label="目标类型" align="center" width="70">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>
|
|
|
+ <i :class="getTargetTypeIcon(scope.row.targetType)" style="margin-right: 4px"></i>
|
|
|
+ {{ getTargetTypeLabel(scope.row.targetType) }}
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="Cron表达式" align="center" prop="cronExpression" width="130">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tooltip :content="getCronDescription(scope.row.cronExpression)" placement="top">
|
|
|
+ <span>{{ scope.row.cronExpression || '-' }}</span>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 调度状态列 -->
|
|
|
+ <el-table-column label="调度状态" align="center" width="90">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tag v-if="scope.row.scheduleEnabled === 1" type="success" size="small" effect="light">
|
|
|
+ <i class="el-icon-video-play"></i> 已启用
|
|
|
+ </el-tag>
|
|
|
+ <el-tag v-else type="info" size="small" effect="light">
|
|
|
+ <i class="el-icon-video-pause"></i> 已禁用
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 执行次数 -->
|
|
|
+ <el-table-column label="执行次数" align="center" prop="execCount" width="80">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-badge :value="scope.row.execCount || 0" :max="999" type="primary" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 上次执行时间 -->
|
|
|
+ <el-table-column label="上次执行" align="center" width="150">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span v-if="scope.row.lastExecTime">{{ scope.row.lastExecTime }}</span>
|
|
|
+ <span v-else class="text-muted">暂未执行</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- 下次执行时间 -->
|
|
|
+ <el-table-column label="下次执行" align="center" width="150">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span v-if="scope.row.scheduleEnabled === 1 && scope.row.nextExecTime">
|
|
|
+ {{ scope.row.nextExecTime }}
|
|
|
+ </span>
|
|
|
+ <span v-else class="text-muted">-</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="计划状态" align="center" width="80">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tag :type="getPlanStatusInfo(scope.row.planStatus).type" size="small" effect="light">
|
|
|
+ {{ getPlanStatusInfo(scope.row.planStatus).label }}
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" fixed="right" width="280" class-name="small-padding fixed-width">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <!-- 调度开关 -->
|
|
|
+ <el-button size="mini" type="text"
|
|
|
+ :icon="scope.row.scheduleEnabled === 1 ? 'el-icon-video-pause' : 'el-icon-video-play'"
|
|
|
+ @click="handleToggleSchedule(scope.row)"
|
|
|
+ v-hasPermi="['ems:inspection:plan:edit']">
|
|
|
+ {{ scope.row.scheduleEnabled === 1 ? '禁用调度' : '启用调度' }}
|
|
|
+ </el-button>
|
|
|
+ <!-- 立即执行 -->
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-caret-right"
|
|
|
+ @click="handleTrigger(scope.row)"
|
|
|
+ :disabled="scope.row.planStatus === 1"
|
|
|
+ v-hasPermi="['ems:inspection:plan:execute']">
|
|
|
+ 立即执行
|
|
|
+ </el-button>
|
|
|
+ <el-dropdown @command="(cmd) => handleCommand(cmd, scope.row)" trigger="click">
|
|
|
+ <el-button size="mini" type="text">
|
|
|
+ 更多<i class="el-icon-arrow-down el-icon--right"></i>
|
|
|
+ </el-button>
|
|
|
+ <el-dropdown-menu slot="dropdown">
|
|
|
+ <el-dropdown-item command="edit" icon="el-icon-edit">编辑计划</el-dropdown-item>
|
|
|
+ <el-dropdown-item command="view" icon="el-icon-view">查看详情</el-dropdown-item>
|
|
|
+ <el-dropdown-item command="reports" icon="el-icon-document">查看报告</el-dropdown-item>
|
|
|
+ <el-dropdown-item command="refresh" icon="el-icon-refresh" divided>刷新调度</el-dropdown-item>
|
|
|
+ <el-dropdown-item command="delete" icon="el-icon-delete" style="color: #F56C6C">删除</el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </el-dropdown>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <!-- 分页 -->
|
|
|
+ <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
|
|
|
+ :limit.sync="queryParams.pageSize" @pagination="getList" />
|
|
|
+
|
|
|
+ <!-- 新增/编辑对话框 -->
|
|
|
+ <plan-form ref="planForm" :area-options="areaOptions" :default-plan-type="currentPlanType" @success="getList" />
|
|
|
+
|
|
|
+ <!-- 查看详情对话框 -->
|
|
|
+ <plan-detail ref="planDetail" />
|
|
|
+
|
|
|
+ <!-- 执行结果对话框(自动巡检) -->
|
|
|
+ <report-detail ref="reportDetail" />
|
|
|
+
|
|
|
+ <!-- 手动提交/编辑报告对话框 -->
|
|
|
+ <manual-report-form ref="manualReportForm" @success="getList" />
|
|
|
+
|
|
|
+ <!-- 调度器状态对话框 -->
|
|
|
+ <scheduler-status ref="schedulerStatus" @refresh="getList" />
|
|
|
+
|
|
|
+ <!-- 报告列表对话框 -->
|
|
|
+ <report-list-dialog ref="reportListDialog" />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { listPlan, delPlan, executePlan } from '@/api/inspection/plan'
|
|
|
+import { listReport } from '@/api/inspection/report'
|
|
|
+import {
|
|
|
+ getSchedulerStatus,
|
|
|
+ registerPlan,
|
|
|
+ unregisterPlan,
|
|
|
+ triggerInspection,
|
|
|
+ refreshPlan
|
|
|
+} from '@/api/inspection/scheduler'
|
|
|
+import { areaTreeSelect } from '@/api/basecfg/area'
|
|
|
+import {
|
|
|
+ PLAN_STATUS_OPTIONS,
|
|
|
+ getPlanStatusInfo,
|
|
|
+ getTargetTypeLabel,
|
|
|
+ getTargetTypeIcon
|
|
|
+} from '@/enums/InspectionEnums'
|
|
|
+import PlanForm from './components/PlanForm.vue'
|
|
|
+import PlanDetail from './components/PlanDetail.vue'
|
|
|
+import ReportDetail from '../report/components/ReportDetail.vue'
|
|
|
+import ManualReportForm from '../report/components/Manualreportform.vue'
|
|
|
+import SchedulerStatus from './components/SchedulerStatus.vue'
|
|
|
+import ReportListDialog from '../report/components/ReportListDialog.vue'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'InspectionPlan',
|
|
|
+ components: { PlanForm, PlanDetail, ReportDetail, ManualReportForm, SchedulerStatus, ReportListDialog },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // 当前Tab
|
|
|
+ activeTab: 'manual',
|
|
|
+ // 遮罩层
|
|
|
+ loading: true,
|
|
|
+ // 显示搜索条件
|
|
|
+ showSearch: true,
|
|
|
+ // 选中数组
|
|
|
+ ids: [],
|
|
|
+ // 非单个禁用
|
|
|
+ single: true,
|
|
|
+ // 非多个禁用
|
|
|
+ multiple: true,
|
|
|
+ // 总条数
|
|
|
+ total: 0,
|
|
|
+ // 表格数据
|
|
|
+ planList: [],
|
|
|
+ // 区域选项
|
|
|
+ areaOptions: [],
|
|
|
+ // 查询参数
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ areaCode: null,
|
|
|
+ planName: null,
|
|
|
+ planType: 1, // 默认手动巡检
|
|
|
+ planStatus: null,
|
|
|
+ executor: null
|
|
|
+ },
|
|
|
+ // 手动巡检状态选项
|
|
|
+ manualPlanStatusOptions: [
|
|
|
+ { value: 0, label: '待巡检' },
|
|
|
+ { value: 2, label: '已完成' },
|
|
|
+ { value: 3, label: '已取消' }
|
|
|
+ ],
|
|
|
+ // 自动巡检状态选项
|
|
|
+ autoPlanStatusOptions: PLAN_STATUS_OPTIONS
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ // 当前计划类型
|
|
|
+ currentPlanType() {
|
|
|
+ return this.activeTab === 'manual' ? 1 : 2
|
|
|
+ },
|
|
|
+ // 根据Tab动态切换状态选项
|
|
|
+ planStatusOptions() {
|
|
|
+ return this.activeTab === 'manual' ? this.manualPlanStatusOptions : this.autoPlanStatusOptions
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getAreaTree()
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 引入枚举工具函数
|
|
|
+ getPlanStatusInfo,
|
|
|
+ getTargetTypeLabel,
|
|
|
+ getTargetTypeIcon,
|
|
|
+
|
|
|
+ // 手动巡检状态信息
|
|
|
+ getManualPlanStatusInfo(status) {
|
|
|
+ const map = {
|
|
|
+ 0: { type: 'warning', label: '待巡检' },
|
|
|
+ 1: { type: 'primary', label: '巡检中' },
|
|
|
+ 2: { type: 'success', label: '已完成' },
|
|
|
+ 3: { type: 'info', label: '已取消' }
|
|
|
+ }
|
|
|
+ return map[status] || { type: 'info', label: '未知' }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 获取Cron表达式描述 */
|
|
|
+ getCronDescription(cron) {
|
|
|
+ if (!cron) return '未配置'
|
|
|
+ // 简单解析常见cron表达式
|
|
|
+ const parts = cron.split(' ')
|
|
|
+ if (parts.length < 6) return cron
|
|
|
+
|
|
|
+ const [second, minute, hour, day, month, week] = parts
|
|
|
+
|
|
|
+ // 每天执行
|
|
|
+ if (day === '*' && month === '*' && week === '?') {
|
|
|
+ return `每天 ${hour}:${minute.padStart(2, '0')} 执行`
|
|
|
+ }
|
|
|
+ // 每周执行
|
|
|
+ if (day === '?' && week !== '*') {
|
|
|
+ const weekMap = { '1': '周日', '2': '周一', '3': '周二', '4': '周三', '5': '周四', '6': '周五', '7': '周六' }
|
|
|
+ return `每${weekMap[week] || week} ${hour}:${minute.padStart(2, '0')} 执行`
|
|
|
+ }
|
|
|
+ // 每月执行
|
|
|
+ if (day !== '*' && day !== '?') {
|
|
|
+ return `每月${day}日 ${hour}:${minute.padStart(2, '0')} 执行`
|
|
|
+ }
|
|
|
+
|
|
|
+ return cron
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 查询区域树 */
|
|
|
+ async getAreaTree() {
|
|
|
+ try {
|
|
|
+ const res = await areaTreeSelect('0', 2)
|
|
|
+ this.areaOptions = res.data || []
|
|
|
+ } catch (e) {
|
|
|
+ console.error('获取区域树失败', e)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** Tab切换 */
|
|
|
+ handleTabChange() {
|
|
|
+ this.queryParams.planType = this.currentPlanType
|
|
|
+ this.queryParams.pageNum = 1
|
|
|
+ this.queryParams.planStatus = null
|
|
|
+ this.queryParams.executor = null
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 查询列表 */
|
|
|
+ getList() {
|
|
|
+ this.loading = true
|
|
|
+ this.queryParams.planType = this.currentPlanType
|
|
|
+ listPlan(this.queryParams).then(res => {
|
|
|
+ this.planList = res.rows || []
|
|
|
+ this.total = res.total || 0
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 搜索按钮操作 */
|
|
|
+ handleQuery() {
|
|
|
+ this.queryParams.pageNum = 1
|
|
|
+ this.getList()
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 重置按钮操作 */
|
|
|
+ resetQuery() {
|
|
|
+ this.resetForm('queryForm')
|
|
|
+ this.queryParams.planType = this.currentPlanType
|
|
|
+ this.handleQuery()
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 多选框选中数据 */
|
|
|
+ handleSelectionChange(selection) {
|
|
|
+ this.ids = selection.map(item => item.id)
|
|
|
+ this.single = selection.length !== 1
|
|
|
+ this.multiple = !selection.length
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 新增按钮操作 */
|
|
|
+ handleAdd() {
|
|
|
+ this.$refs.planForm.open(null, this.currentPlanType)
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 查看详情 */
|
|
|
+ handleView(row) {
|
|
|
+ this.$refs.planDetail.open(row.id)
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 修改按钮操作 */
|
|
|
+ handleUpdate(row) {
|
|
|
+ const id = row.id || this.ids[0]
|
|
|
+ this.$refs.planForm.open(id)
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 删除按钮操作 */
|
|
|
+ handleDelete(row) {
|
|
|
+ const ids = row.id ? [row.id] : this.ids
|
|
|
+ const names = row.planName || this.planList.filter(p => ids.includes(p.id)).map(p => p.planName).join('、')
|
|
|
+
|
|
|
+ this.$modal.confirm(`确认删除巡检计划【${names}】吗?`).then(() => {
|
|
|
+ return delPlan(ids)
|
|
|
+ }).then(() => {
|
|
|
+ this.getList()
|
|
|
+ this.$modal.msgSuccess('删除成功')
|
|
|
+ }).catch(() => {})
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 切换调度状态 */
|
|
|
+ handleToggleSchedule(row) {
|
|
|
+ const newStatus = row.scheduleEnabled === 1 ? 0 : 1
|
|
|
+ const action = newStatus === 1 ? '启用' : '禁用'
|
|
|
+
|
|
|
+ // 启用调度前检查cron表达式
|
|
|
+ if (newStatus === 1 && !row.cronExpression) {
|
|
|
+ this.$modal.msgWarning('请先配置Cron表达式')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$modal.confirm(`确认${action}计划【${row.planName}】的定时调度吗?`).then(() => {
|
|
|
+ this.loading = true
|
|
|
+
|
|
|
+ // 根据状态调用注册或注销接口(调度器会自动更新数据库状态)
|
|
|
+ if (newStatus === 1) {
|
|
|
+ return registerPlan(row.planCode)
|
|
|
+ } else {
|
|
|
+ return unregisterPlan(row.planCode)
|
|
|
+ }
|
|
|
+ }).then(() => {
|
|
|
+ this.$modal.msgSuccess(`调度${action}成功`)
|
|
|
+ this.getList()
|
|
|
+ }).catch((err) => {
|
|
|
+ if (err !== 'cancel') {
|
|
|
+ this.$modal.msgError(err.message || `${action}失败`)
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 手动触发执行 */
|
|
|
+ handleTrigger(row) {
|
|
|
+ this.$modal.confirm(`确认立即执行巡检计划【${row.planName}】吗?`).then(() => {
|
|
|
+ this.loading = true
|
|
|
+ return triggerInspection(row.planCode)
|
|
|
+ }).then(res => {
|
|
|
+ this.$modal.msgSuccess('巡检执行完成')
|
|
|
+ this.getList()
|
|
|
+ // 显示巡检结果
|
|
|
+ if (res.data) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$refs.reportDetail.open(res.data)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }).catch((err) => {
|
|
|
+ if (err !== 'cancel') {
|
|
|
+ this.$modal.msgError(err.message || '执行失败')
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 下拉菜单命令处理 */
|
|
|
+ handleCommand(command, row) {
|
|
|
+ switch (command) {
|
|
|
+ case 'edit':
|
|
|
+ this.handleUpdate(row)
|
|
|
+ break
|
|
|
+ case 'view':
|
|
|
+ this.handleView(row)
|
|
|
+ break
|
|
|
+ case 'reports':
|
|
|
+ this.handleViewReports(row)
|
|
|
+ break
|
|
|
+ case 'refresh':
|
|
|
+ this.handleRefreshSchedule(row)
|
|
|
+ break
|
|
|
+ case 'delete':
|
|
|
+ this.handleDelete(row)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 查看报告列表 */
|
|
|
+ handleViewReports(row) {
|
|
|
+ this.$refs.reportListDialog.open(row.planCode, row.planName)
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 刷新调度配置 */
|
|
|
+ handleRefreshSchedule(row) {
|
|
|
+ this.$modal.confirm(`确认刷新计划【${row.planName}】的调度配置吗?`).then(() => {
|
|
|
+ return refreshPlan(row.planCode)
|
|
|
+ }).then(res => {
|
|
|
+ this.$modal.msgSuccess(res.msg || '刷新成功')
|
|
|
+ this.getList()
|
|
|
+ }).catch((err) => {
|
|
|
+ if (err !== 'cancel') {
|
|
|
+ this.$modal.msgError(err.message || '刷新失败')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 显示调度器状态 */
|
|
|
+ showSchedulerStatus() {
|
|
|
+ this.$refs.schedulerStatus.open()
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 自动巡检:立即执行(旧方法保留兼容) */
|
|
|
+ handleExecute(row) {
|
|
|
+ this.handleTrigger(row)
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 手动巡检:提交报告 */
|
|
|
+ handleSubmitReport(row) {
|
|
|
+ this.$refs.manualReportForm.open(row)
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 手动巡检:查看报告 */
|
|
|
+ async handleViewReport(row) {
|
|
|
+ try {
|
|
|
+ this.loading = true
|
|
|
+ // 根据计划代码查询该计划的报告
|
|
|
+ const res = await listReport({ planCode: row.planCode, pageNum: 1, pageSize: 1 })
|
|
|
+ if (res.rows && res.rows.length > 0) {
|
|
|
+ // 找到报告,打开详情弹窗
|
|
|
+ this.$refs.reportDetail.open(res.rows[0].id)
|
|
|
+ } else {
|
|
|
+ this.$modal.msgWarning('该计划暂无巡检报告')
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ this.$modal.msgError('获取报告失败')
|
|
|
+ console.error(e)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 手动巡检:编辑报告 */
|
|
|
+ async handleEditReport(row) {
|
|
|
+ try {
|
|
|
+ this.loading = true
|
|
|
+ // 根据计划代码查询该计划的报告
|
|
|
+ const res = await listReport({ planCode: row.planCode, pageNum: 1, pageSize: 1 })
|
|
|
+ if (res.rows && res.rows.length > 0) {
|
|
|
+ // 找到报告,打开编辑弹窗
|
|
|
+ this.$refs.manualReportForm.openEdit(row, res.rows[0])
|
|
|
+ } else {
|
|
|
+ this.$modal.msgWarning('该计划暂无巡检报告')
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ this.$modal.msgError('获取报告失败')
|
|
|
+ console.error(e)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /** 导出按钮操作 */
|
|
|
+ handleExport() {
|
|
|
+ this.download('/ems/inspection/plan/export', {
|
|
|
+ ...this.queryParams
|
|
|
+ }, `inspection_plan_${this.activeTab}_${new Date().getTime()}.xlsx`)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.inspection-tabs {
|
|
|
+ margin-bottom: 15px;
|
|
|
+}
|
|
|
+
|
|
|
+.inspection-tabs ::v-deep .el-tabs__item {
|
|
|
+ font-size: 14px;
|
|
|
+ padding: 0 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.inspection-tabs ::v-deep .el-tabs__item i {
|
|
|
+ margin-right: 5px;
|
|
|
+}
|
|
|
+
|
|
|
+.inspection-tabs ::v-deep .el-tabs__item.is-active {
|
|
|
+ font-weight: bold;
|
|
|
+}
|
|
|
+
|
|
|
+.delete-btn {
|
|
|
+ color: #F56C6C !important;
|
|
|
+}
|
|
|
+.delete-btn:hover {
|
|
|
+ color: #f78989 !important;
|
|
|
+}
|
|
|
+
|
|
|
+.text-muted {
|
|
|
+ color: #909399;
|
|
|
+ font-size: 12px;
|
|
|
+}
|
|
|
+</style>
|