gongchunyi
8 天以前 990257e90f992cccbfbdd5e3bebd27b0ae5402a8
src/views/safeProduction/emergencyPlanReview/index.vue
@@ -1,6 +1,6 @@
<template>
  <div class="app-container">
    <div class="search_form">
    <div class="search_form mb20">
      <div>
        <span class="search_title">应急预案名称:</span>
        <el-input v-model="searchForm.planName"
@@ -122,12 +122,13 @@
        </el-row>
        <el-form-item label="适用范围:"
                      prop="applyScope">
          <el-checkbox-group v-model="form.applyScope">
            <el-checkbox label="all">全体员工</el-checkbox>
            <el-checkbox label="manager">管理层</el-checkbox>
            <el-checkbox label="hr">人事部门</el-checkbox>
            <el-checkbox label="finance">财务部门</el-checkbox>
            <el-checkbox label="tech">技术部门</el-checkbox>
          <el-checkbox-group v-model="form.applyScope"
                             class="apply-scope-checkbox-group">
            <el-checkbox v-for="dept in applyScopeOptions"
                         :key="dept.deptId"
                         :value="String(dept.deptId)">
              {{ dept.deptName }}
            </el-checkbox>
          </el-checkbox-group>
        </el-form-item>
        <el-form-item label="应急处置步骤:"
@@ -165,9 +166,9 @@
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="dialogVisible = false">取消</el-button>
          <el-button type="primary"
                     @click="submitForm">确定</el-button>
          <el-button @click="dialogVisible = false">取消</el-button>
        </span>
      </template>
    </el-dialog>
@@ -202,11 +203,11 @@
        <div class="detail-section">
          <h4>适用范围</h4>
          <div class="key-points">
            <el-tag v-for="(point, index) in currentKnowledge.applyScope.split(',')"
                    :key="index"
            <el-tag v-for="(scope, index) in getApplyScopeTags(currentKnowledge)"
                    :key="`${scope.value}-${index}`"
                    type="primary"
                    style="margin-right: 8px; margin-bottom: 8px;">
              {{ getApplyScopeLabel(point.trim()) }}
              {{ scope.label }}
            </el-tag>
          </div>
        </div>
@@ -250,6 +251,7 @@
  import { ElMessage, ElMessageBox } from "element-plus";
  import PIMTable from "@/components/PIMTable/PIMTable.vue";
  import { userListNoPage } from "@/api/system/user.js";
  import { listDept } from "@/api/system/dept.js";
  import {
    safeContingencyPlanListPage,
    safeContingencyPlanAdd,
@@ -326,32 +328,49 @@
  // 表单引用
  const formRef = ref();
  const execStepsList = ref([]);
  const applyScopeOptions = ref([]);
  const applyScopeNameMap = computed(() => {
    return applyScopeOptions.value.reduce((map, dept) => {
      map[String(dept.deptId)] = dept.deptName;
      return map;
    }, {});
  });
  // 表格列配置
  const tableColumn = ref([
    {
      label: "应急预案编码",
      prop: "planCode",
      minWidth: 200,
      align: "center",
      showOverflowTooltip: true,
    },
    {
      label: "应急预案名称",
      prop: "planName",
      minWidth: 240,
      align: "center",
      showOverflowTooltip: true,
    },
    {
      label: "发布生效时间",
      prop: "publishTime",
      minWidth: 160,
      align: "center",
      showOverflowTooltip: true,
    },
    {
      label: "核心责任人",
      prop: "coreResponsorUserName",
      minWidth: 140,
      align: "center",
      showOverflowTooltip: true,
    },
    {
      label: "预案类型",
      prop: "planType",
      minWidth: 160,
      align: "center",
      showOverflowTooltip: true,
      formatData: params => {
        return emergencyPlanTypeLabel(params);
@@ -360,6 +379,8 @@
    {
      label: "备注",
      prop: "remark",
      minWidth: 220,
      align: "center",
      showOverflowTooltip: true,
    },
    {
@@ -367,7 +388,7 @@
      label: "操作",
      align: "center",
      fixed: "right",
      width: 200,
      width: 120,
      operation: [
        {
          name: "编辑",
@@ -392,6 +413,7 @@
    userListNoPage().then(res => {
      userList.value = res.data;
    });
    loadApplyScopeOptions();
    getList();
    startAutoRefresh();
  });
@@ -426,6 +448,22 @@
      execStepsList.value = [];
    }
  };
  const loadApplyScopeOptions = () => {
    listDept({ status: "0" }).then(res => {
      applyScopeOptions.value = res.data || [];
    });
  };
  const parseApplyScope = scope => {
    if (Array.isArray(scope)) {
      return scope.map(item => String(item)).filter(Boolean);
    }
    return String(scope || "")
      .split(",")
      .map(item => item.trim())
      .filter(Boolean);
  };
  // 开始自动刷新
  const startAutoRefresh = () => {
    setInterval(() => {
@@ -445,7 +483,7 @@
      .then(res => {
        tableLoading.value = false;
        tableData.value = res.data.records;
        page.total = res.data.total;
        page.value.total = res.data.total;
      })
      .catch(err => {
        tableLoading.value = false;
@@ -471,6 +509,7 @@
      dialogTitle.value = "新增应急预案";
      // 重置表单
      Object.assign(form.value, {
        id: undefined,
        planCode: "", // 预案编号
        applyScope: [], // 适用范围
        planType: "", // 预案类型
@@ -487,7 +526,7 @@
      Object.assign(form.value, {
        id: row.id,
        planCode: row.planCode, // 预案编号
        applyScope: row.applyScope ? row.applyScope.split(",") : [], // 适用范围
        applyScope: parseApplyScope(row.applyScope), // 适用范围
        planType: row.planType, // 预案类型
        planName: row.planName, // 预案名称
        publishTime: row.publishTime, // 发布时间
@@ -507,14 +546,13 @@
    viewDialogVisible.value = true;
  };
  const getApplyScopeLabel = scope => {
    const scopeMap = {
      all: "全体员工",
      manager: "管理层",
      hr: "人事部门",
      finance: "财务部门",
      tech: "技术部门",
    };
    return scopeMap[scope] || scope;
    return applyScopeNameMap.value[String(scope)] || scope;
  };
  const getApplyScopeTags = row => {
    return parseApplyScope(row?.applyScope).map((scope, index) => ({
      value: scope,
      label: getApplyScopeLabel(scope),
    }));
  };
  // 获取类型标签类型
@@ -602,12 +640,14 @@
        }
      }
      // 将应急处置步骤转换为JSON字符串
      form.value.execSteps = JSON.stringify(execStepsList.value);
      const submitData = {
        ...form.value,
        applyScope: form.value.applyScope.join(","),
        execSteps: JSON.stringify(execStepsList.value),
      };
      if (dialogType.value === "add") {
        // 新增应急预案
        form.value.applyScope = form.value.applyScope.join(",");
        safeContingencyPlanAdd({ ...form.value })
        safeContingencyPlanAdd(submitData)
          .then(res => {
            if (res.code == 200) {
              ElMessage.success("添加成功");
@@ -619,8 +659,7 @@
            ElMessage.error(err.msg);
          });
      } else {
        form.value.applyScope = form.value.applyScope.join(",");
        safeContingencyPlanUpdate({ ...form.value })
        safeContingencyPlanUpdate(submitData)
          .then(res => {
            if (res.code == 200) {
              ElMessage.success("更新成功");
@@ -740,6 +779,16 @@
    gap: 8px;
  }
  .apply-scope-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
  }
  .apply-scope-checkbox-group :deep(.el-checkbox) {
    margin-right: 0;
  }
  .usage-stats {
    margin-top: 16px;
  }