zhangwencui
8 小时以前 b7ddb64be82d402dca628e92fa432558fd712289
巡检管理频次字段回显问题
已修改1个文件
164 ■■■■■ 文件已修改
src/views/equipmentManagement/inspectionManagement/index.vue 164 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/equipmentManagement/inspectionManagement/index.vue
@@ -1,22 +1,24 @@
<template>
  <div class="app-container">
    <el-form :inline="true" :model="queryParams" class="search-form">
    <el-form :inline="true"
             :model="queryParams"
             class="search-form">
      <el-form-item label="巡检任务名称">
        <el-input
            v-model="queryParams.taskName"
        <el-input v-model="queryParams.taskName"
            placeholder="请输入巡检任务名称"
            clearable
            style="width: 200px "
        />
                  style="width: 200px " />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleQuery">查询</el-button>
        <el-button type="primary"
                   @click="handleQuery">查询</el-button>
        <el-button @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-card>
      <div style="display: flex;flex-direction: row;justify-content: space-between;margin-bottom: 10px;">
        <el-radio-group v-model="activeRadio" @change="radioChange">
        <el-radio-group v-model="activeRadio"
                        @change="radioChange">
          <el-radio-button v-for="tab in radios"
                           :key="tab.name"
                           :label="tab.label"
@@ -24,8 +26,12 @@
        </el-radio-group>
        <!-- 操作按钮区 -->
        <el-space v-if="activeRadio !== 'task'">
          <el-button type="primary" :icon="Plus" @click="handleAdd(undefined)">新建</el-button>
          <el-button type="danger" :icon="Delete" @click="handleDelete">删除</el-button>
          <el-button type="primary"
                     :icon="Plus"
                     @click="handleAdd(undefined)">新建</el-button>
          <el-button type="danger"
                     :icon="Delete"
                     @click="handleDelete">删除</el-button>
          <el-button @click="handleOut">导出</el-button>
        </el-space>
        <el-space v-else>
@@ -46,30 +52,29 @@
                  total: total,
                  layout: 'total, sizes, prev, pager, next, jumper'
                }"
                :table-style="{ width: '100%', height: 'calc(100vh - 23em)' }"
        >
                  :table-style="{ width: '100%', height: 'calc(100vh - 23em)' }">
          <template #inspector="{ row }">
            <div class="person-tags">
              <!-- 调试信息,上线时删除 -->
              <!-- {{ console.log('inspector data:', row.inspector) }} -->
              <template v-if="row.inspector && row.inspector.length > 0">
                <el-tag
                  v-for="(person, index) in row.inspector"
                <el-tag v-for="(person, index) in row.inspector"
                  :key="index"
                  size="small"
                  type="primary"
                  class="person-tag"
                >
                        class="person-tag">
                  {{ person }}
                </el-tag>
              </template>
              <span v-else class="no-data">--</span>
              <span v-else
                    class="no-data">--</span>
            </div>
          </template>
        </PIMTable>
      </div>
    </el-card>
    <form-dia ref="formDia" @closeDia="handleQuery"></form-dia>
    <form-dia ref="formDia"
              @closeDia="handleQuery"></form-dia>
    <view-files ref="viewFiles"></view-files>
  </div>
</template>
@@ -88,7 +93,7 @@
import {
  delTimingTask,
  inspectionTaskList,
  timingTaskList
    timingTaskList,
} from "@/api/inspectionManagement/index.js";
// 全局变量
@@ -127,12 +132,23 @@
    prop: "frequencyType",
    label: "频次",
    minWidth: 150,
    formatter: (_, __, val) => ({
      DAILY: "每日",
      WEEKLY: "每周",
      MONTHLY: "每月",
      QUARTERLY: "季度"
    }[val] || "")
      // formatter: (_, __, val) => ({
      //   DAILY: "每日",
      //   WEEKLY: "每周",
      //   MONTHLY: "每月",
      //   QUARTERLY: "季度"
      // }[val] || "")
      formatData: params => {
        return params === "DAILY"
          ? "每日"
          : params === "WEEKLY"
          ? "每周"
          : params === "MONTHLY"
          ? "每月"
          : params === "QUARTERLY"
          ? "季度"
          : "";
      },
  },
  {
    prop: "frequencyDetail",
@@ -140,27 +156,30 @@
    minWidth: 150,
    formatter: (row, column, cellValue) => {
      // 先判断是否是字符串
      if (typeof cellValue !== 'string') return '';
        if (typeof cellValue !== "string") return "";
      let val = cellValue;
      const replacements = {
        MON: '周一',
        TUE: '周二',
        WED: '周三',
        THU: '周四',
        FRI: '周五',
        SAT: '周六',
        SUN: '周日'
          MON: "周一",
          TUE: "周二",
          WED: "周三",
          THU: "周四",
          FRI: "周五",
          SAT: "周六",
          SUN: "周日",
      };
      // 使用正则一次性替换所有匹配项
      return val.replace(/MON|TUE|WED|THU|FRI|SAT|SUN/g, match => replacements[match]);
    }
        return val.replace(
          /MON|TUE|WED|THU|FRI|SAT|SUN/g,
          match => replacements[match]
        );
      },
  },
  { prop: "registrant", label: "登记人", minWidth: 100 },
  { prop: "createTime", label: "登记日期", minWidth: 100 },
]);
// 操作列配置
const getOperationColumn = (operations) => {
  const getOperationColumn = operations => {
  if (!operations || operations.length === 0) return null;
  
  const operationConfig = {
@@ -168,43 +187,51 @@
    width: 130,
    fixed: "right",
    dataType: "action",
    operation: operations.map(op => {
      operation: operations
        .map(op => {
      switch (op) {
        case 'edit':
            case "edit":
          return {
            name: "编辑",
            clickFun: handleAdd,
            color: "#409EFF"
                color: "#409EFF",
          };
        case 'viewFile':
            case "viewFile":
          return {
            name: "查看附件",
            clickFun: viewFile,
            color: "#67C23A"
                color: "#67C23A",
          };
        default:
          return null;
      }
    }).filter(Boolean)
        })
        .filter(Boolean),
  };
  
  return operationConfig;
};
onMounted(() => {
  radioChange('taskManage');
    radioChange("taskManage");
});
// 单选变化
const radioChange = (value) => {
  const radioChange = value => {
  if (value === "taskManage") {
    const operationColumn = getOperationColumn(['edit']);
    tableColumns.value = [...columns.value, ...(operationColumn ? [operationColumn] : [])];
    operationsArr.value = ['edit'];
      const operationColumn = getOperationColumn(["edit"]);
      tableColumns.value = [
        ...columns.value,
        ...(operationColumn ? [operationColumn] : []),
      ];
      operationsArr.value = ["edit"];
  } else if (value === "task") {
    const operationColumn = getOperationColumn(['viewFile']);
    tableColumns.value = [...columns.value, ...(operationColumn ? [operationColumn] : [])];
    operationsArr.value = ['viewFile'];
      const operationColumn = getOperationColumn(["viewFile"]);
      tableColumns.value = [
        ...columns.value,
        ...(operationColumn ? [operationColumn] : []),
      ];
      operationsArr.value = ["viewFile"];
  }
  pageNum.value = 1;
  pageSize.value = 10;
@@ -218,7 +245,7 @@
  getList();
};
// 分页处理
const handlePagination = (val) => {
  const handlePagination = val => {
    pageNum.value = val.page;
    pageSize.value = val.limit;
    getList();
@@ -227,7 +254,11 @@
const getList = () => {
  tableLoading.value = true;
  
  const params = { ...queryParams, size: pageSize.value, current: pageNum.value };
    const params = {
      ...queryParams,
      size: pageSize.value,
      current: pageNum.value,
    };
  
  let apiCall;
  if (activeRadio.value === "task") {
@@ -236,7 +267,8 @@
    apiCall = timingTaskList(params);
  }
  
  apiCall.then(res => {
    apiCall
      .then(res => {
    const rawData = res.data.records || [];
    // 处理 inspector 字段,将字符串转换为数组(适用于所有情况)
    tableData.value = rawData.map(item => {
@@ -244,9 +276,12 @@
      
      // 处理 inspector 字段
      if (processedItem.inspector) {
        if (typeof processedItem.inspector === 'string') {
            if (typeof processedItem.inspector === "string") {
          // 字符串按逗号分割
          processedItem.inspector = processedItem.inspector.split(',').map(s => s.trim()).filter(s => s);
              processedItem.inspector = processedItem.inspector
                .split(",")
                .map(s => s.trim())
                .filter(s => s);
        } else if (!Array.isArray(processedItem.inspector)) {
          // 非数组转为数组
          processedItem.inspector = [processedItem.inspector];
@@ -259,7 +294,8 @@
      return processedItem;
    });
    total.value = res.data.total || 0;
  }).finally(() => {
      })
      .finally(() => {
    tableLoading.value = false;
  });
};
@@ -275,15 +311,15 @@
};
// 新增 / 编辑
const handleAdd = (row) => {
  const type = row ? 'edit' : 'add';
  const handleAdd = row => {
    const type = row ? "edit" : "add";
  nextTick(() => {
    formDia.value?.openDialog(type, row);
  });
};
// 查看附件
const viewFile = (row) => {
  const viewFile = row => {
  nextTick(() => {
    viewFiles.value?.openDialog(row);
  });
@@ -298,16 +334,20 @@
  
  const deleteIds = selectedRows.value.map(item => item.id);
  
  proxy.$modal.confirm('是否确认删除所选数据项?').then(() => {
    proxy.$modal
      .confirm("是否确认删除所选数据项?")
      .then(() => {
    return delTimingTask(deleteIds);
  }).then(() => {
      })
      .then(() => {
    proxy.$modal.msgSuccess("删除成功");
    handleQuery();
  }).catch(() => {});
      })
      .catch(() => {});
};
// 多选变更
const handleSelectionChange = (selection) => {
  const handleSelectionChange = selection => {
  selectedRows.value = selection;
};