liding
2026-06-30 2129908ed7246f6abb761a788eb681e6a6d872d2
feat(safe): 完善安全巡检系统功能
已修改3个文件
127 ■■■■ 文件已修改
src/api/safeProduction/lineInspection.js 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/safeProduction/lineInspection/index.vue 69 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/safeProduction/safetyFacility/index.vue 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/safeProduction/lineInspection.js
@@ -72,6 +72,23 @@
  });
}
// 修改巡检记录
export function updateInspectionRecord(data) {
  return request({
    url: "/safeLineInspectionRecord",
    method: "put",
    data,
  });
}
// 删除巡检记录
export function deleteInspectionRecord(ids) {
  return request({
    url: "/safeLineInspectionRecord/" + ids.join(","),
    method: "delete",
  });
}
// 批量新增巡检记录
export function batchAddInspectionRecords(data) {
  return request({
src/views/safeProduction/lineInspection/index.vue
@@ -115,7 +115,7 @@
          </el-col>
          <el-col :span="12">
            <el-form-item label="巡检人"
                          prop="inspectorId">
                          prop="inspectorIds">
              <el-select v-model="form.inspectorIds"
                         placeholder="请选择巡检人(可多选)"
                         filterable
@@ -159,6 +159,7 @@
      <div class="mb10">
        <el-button type="primary"
                   size="small"
                   :disabled="currentInspectionStatus === '已完成'"
                   @click="openRecordForm">新增记录</el-button>
      </div>
      <div class="dialog-table-wrapper">
@@ -176,12 +177,18 @@
          </el-table-column>
          <el-table-column prop="checkDesc" label="检查说明" width="200" show-overflow-tooltip />
          <el-table-column prop="checkTime" label="检查时间" width="180" />
          <el-table-column label="操作" width="120" fixed="right">
            <template #default="{ row }">
              <el-button type="primary" link :disabled="currentInspectionStatus === '已完成'" @click="openEditRecordForm(row)">编辑</el-button>
              <el-button type="danger" link :disabled="currentInspectionStatus === '已完成'" @click="handleDeleteRecord(row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!-- 新增记录表单 -->
      <el-dialog v-model="recordFormVisible"
                 title="新增巡检记录"
                 :title="recordForm.id ? '编辑巡检记录' : '新增巡检记录'"
                 width="600px"
                 append-to-body
                 :close-on-click-modal="false">
@@ -249,6 +256,7 @@
      <div class="mb10">
        <el-button type="primary"
                   size="small"
                   :disabled="currentInspectionStatus === '已完成'"
                   @click="openHazardForm('add')">上报隐患</el-button>
      </div>
      <div class="dialog-table-wrapper">
@@ -275,8 +283,8 @@
          <el-table-column prop="rectifyUserName" label="整改责任人" width="120" />
          <el-table-column label="操作" width="150" fixed="right">
            <template #default="{ row }">
              <el-button type="primary" link @click="openHazardForm('edit', row)">编辑</el-button>
              <el-button type="success" link @click="handleRectify(row)" v-if="row.status !== '已整改'">整改</el-button>
              <el-button type="primary" link :disabled="currentInspectionStatus === '已完成'" @click="openHazardForm('edit', row)">编辑</el-button>
              <el-button type="success" link :disabled="currentInspectionStatus === '已完成'" @click="handleRectify(row)" v-if="row.status !== '已整改'">整改</el-button>
            </template>
          </el-table-column>
        </el-table>
@@ -372,6 +380,8 @@
  completeLineInspection,
  getInspectionRecords,
  addInspectionRecord,
  updateInspectionRecord,
  deleteInspectionRecord,
  getHazardsByInspectionId,
  addInspectionHazard,
  updateInspectionHazard
@@ -381,7 +391,8 @@
const rules = {
  inspectionCode: [{ required: true, message: "请输入巡检编号", trigger: "blur" }],
  inspectionName: [{ required: true, message: "请输入巡检名称", trigger: "blur" }],
  lineName: [{ required: true, message: "请输入线路名称", trigger: "blur" }]
  lineName: [{ required: true, message: "请输入线路名称", trigger: "blur" }],
  inspectorIds: [{ required: true, message: "请选择巡检人", trigger: "change" }]
};
const recordRules = {
@@ -428,10 +439,12 @@
  dialogType: "add",
  // 巡检记录
  currentInspectionId: null,
  currentInspectionStatus: "",
  recordDialogVisible: false,
  recordFormVisible: false,
  recordList: [],
  recordForm: {
    id: null,
    inspectionId: null,
    checkPoint: "",
    checkContent: "",
@@ -469,6 +482,7 @@
  dialogTitle,
  dialogType,
  currentInspectionId,
  currentInspectionStatus,
  recordDialogVisible,
  recordFormVisible,
  recordList,
@@ -554,7 +568,7 @@
        clickFun: row => {
          openForm("edit", row);
        },
        show: row => row.status === "待巡检"
        disabled: row => row.status !== "待巡检"
      },
      {
        name: "巡检记录",
@@ -586,7 +600,7 @@
        clickFun: row => {
          handleDelete(row);
        },
        show: row => row.status === "待巡检"
        disabled: row => row.status !== "待巡检"
      }
    ]
  }
@@ -773,6 +787,7 @@
// 打开巡检记录弹窗
const openRecordDialog = row => {
  currentInspectionId.value = row.id;
  currentInspectionStatus.value = row.status;
  fetchRecords(row.id);
  recordDialogVisible.value = true;
};
@@ -788,6 +803,7 @@
// 打开记录表单
const openRecordForm = () => {
  Object.assign(recordForm.value, {
    id: null,
    inspectionId: currentInspectionId.value,
    checkPoint: "",
    checkContent: "",
@@ -798,17 +814,49 @@
  recordFormVisible.value = true;
};
// 打开编辑记录表单
const openEditRecordForm = (row) => {
  Object.assign(recordForm.value, {
    id: row.id,
    inspectionId: row.inspectionId,
    checkPoint: row.checkPoint,
    checkContent: row.checkContent,
    checkResult: row.checkResult,
    checkDesc: row.checkDesc,
    checkTime: row.checkTime
  });
  recordFormVisible.value = true;
};
// 删除巡检记录
const handleDeleteRecord = (row) => {
  ElMessageBox.confirm("确认删除该巡检记录吗?", "删除", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning"
  }).then(async () => {
    const res = await deleteInspectionRecord([row.id]);
    if (res.code === 200) {
      ElMessage.success("删除成功");
      fetchRecords(currentInspectionId.value);
    } else {
      ElMessage.error(res.msg || "删除失败");
    }
  }).catch(() => {});
};
// 提交记录表单
const submitRecordForm = async () => {
  try {
    await recordFormRef.value.validate();
    const res = await addInspectionRecord({ ...recordForm.value });
    const api = recordForm.value.id ? updateInspectionRecord : addInspectionRecord;
    const res = await api({ ...recordForm.value });
    if (res.code === 200) {
      ElMessage.success("添加成功");
      ElMessage.success(recordForm.value.id ? "修改成功" : "添加成功");
      recordFormVisible.value = false;
      fetchRecords(currentInspectionId.value);
    } else {
      ElMessage.error(res.msg || "添加失败");
      ElMessage.error(res.msg || "操作失败");
    }
  } catch (error) {
    console.error("表单验证失败:", error);
@@ -818,6 +866,7 @@
// 打开隐患管理弹窗
const openHazardDialog = row => {
  currentInspectionId.value = row.id;
  currentInspectionStatus.value = row.status;
  fetchHazards(row.id);
  hazardDialogVisible.value = true;
};
src/views/safeProduction/safetyFacility/index.vue
@@ -228,6 +228,11 @@
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="下次检查时间">
              <el-input :value="computedNextCheckTime" disabled placeholder="根据安装时间+有效期自动计算" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态"
                          prop="status">
              <el-select v-model="ledgerForm.status"
@@ -343,6 +348,14 @@
              <el-option label="重大" value="重大" />
            </el-select>
          </el-form-item>
          <el-form-item label="计划整改时间">
            <el-date-picker v-model="rectificationForm.planTime"
                            type="datetime"
                            placeholder="请选择计划整改时间"
                            format="YYYY-MM-DD HH:mm:ss"
                            value-format="YYYY-MM-DD HH:mm:ss"
                            style="width: 100%" />
          </el-form-item>
        </template>
        <el-form-item label="整改说明" v-if="rectificationDialogTitle === '整改'">
          <el-input v-model="rectificationForm.rectifyDesc"
@@ -370,7 +383,7 @@
<script setup>
import { Search } from "@element-plus/icons-vue";
import { onMounted, ref, reactive, toRefs } from "vue";
import { onMounted, ref, reactive, toRefs, computed } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import PIMTable from "@/components/PIMTable/PIMTable.vue";
import {
@@ -435,7 +448,7 @@
  rectificationTableData: [],
  rectificationForm: {
    id: null, inspectionId: null, facilityId: null, problemDesc: "",
    problemLevel: "", rectifyDesc: "", verifyDesc: ""
    problemLevel: "", planTime: "", rectifyDesc: "", verifyDesc: ""
  },
  rectificationDialogVisible: false,
  rectificationDialogTitle: "",
@@ -456,6 +469,15 @@
const ledgerFormRef = ref();
const inspectionFormRef = ref();
const rectificationFormRef = ref();
// 自动计算下次检查时间
const computedNextCheckTime = computed(() => {
  const { installTime, validPeriod } = ledgerForm.value;
  if (!installTime || !validPeriod) return "";
  const date = new Date(installTime);
  date.setDate(date.getDate() + validPeriod);
  return date.toISOString().split("T")[0];
});
// 设施台账表格列配置
const ledgerTableColumn = ref([
@@ -518,7 +540,7 @@
        clickFun: row => openRectificationForm("add", row),
        show: row => row.checkResult === "异常"
      },
      { name: "删除", type: "text", style: { color: "#F56C6C" }, clickFun: row => handleDeleteInspection(row) }
      { name: "删除", type: "text", style: { color: "#F56C6C" }, clickFun: row => handleDeleteInspection(row), disabled: row => row.status !== "待巡检" }
    ]
  }
]);
@@ -562,6 +584,8 @@
// 生命周期
onMounted(() => {
  getLedgerList();
  getInspectionList();
  getRectificationList();
});
// 标签页切换
@@ -618,6 +642,8 @@
const submitLedgerForm = async () => {
  try {
    await ledgerFormRef.value.validate();
    // 自动计算下次检查时间
    ledgerForm.value.nextCheckTime = computedNextCheckTime.value || null;
    const api = ledgerDialogType.value === "add" ? addFacilityLedger : updateFacilityLedger;
    const res = await api({ ...ledgerForm.value });
    if (res.code === 200) {
@@ -640,6 +666,8 @@
    if (res.code === 200) {
      ElMessage.success("删除成功");
      getLedgerList();
    } else {
      ElMessage.error(res.msg || "删除失败");
    }
  }).catch(() => {});
};
@@ -716,6 +744,8 @@
    if (res.code === 200) {
      ElMessage.success("删除成功");
      getInspectionList();
    } else {
      ElMessage.error(res.msg || "删除失败");
    }
  }).catch(() => {});
};
@@ -750,13 +780,14 @@
    rectificationDialogTitle.value = "新增整改";
    Object.assign(rectificationForm.value, {
      id: null, inspectionId: row.id, facilityId: row.facilityId,
      problemDesc: "", problemLevel: "", rectifyDesc: "", verifyDesc: ""
      problemDesc: "", problemLevel: "", planTime: "", rectifyDesc: "", verifyDesc: ""
    });
  } else if (type === "do") {
    rectificationDialogTitle.value = "整改";
    Object.assign(rectificationForm.value, {
      id: row.id, inspectionId: row.inspectionId, facilityId: row.facilityId,
      problemDesc: row.problemDesc, problemLevel: row.problemLevel, rectifyDesc: "", verifyDesc: ""
      problemDesc: row.problemDesc, problemLevel: row.problemLevel, planTime: row.planTime || "",
      rectifyDesc: "", verifyDesc: ""
    });
  } else if (type === "verify") {
    rectificationDialogTitle.value = "验收";