董国庆
2026-05-19 d46a5711da81d65b75a001e235ae06490149f22b
fix(operationWorkbench): 优化场站导出功能并修复地图编辑器异常触发问题

列表页移除手动CSV导出逻辑,改用后端导出API,修复导出提示文案错误并新增异常捕获;地图编辑器新增抑制标记,避免程序关闭编辑器时触发不必要的几何同步操作。
2个文件已修改
81 ■■■■■ 已修改文件
src/views/businessOperations/operationWorkbench/list.vue 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/businessOperations/operationWorkbench/map.vue 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/businessOperations/operationWorkbench/list.vue
@@ -9,7 +9,7 @@
import { useBoolean, usePermission } from '@/hooks'
import { copyFence, fetchEnabledOpenCityList, getFenceList } from '@/service/api/operations'
import { deletePoint, enableDisablePoint, exportPointExcel, fetchFenceAndStationAreaList, fetchPointPageList } from '@/service/api/point'
import { deleteStation, fetchStationListByElectronicId, fetchStationPageList, updateStationStatus } from '@/service/api/station'
import { deleteStation, exportStationExcel, fetchStationListByElectronicId, fetchStationPageList, updateStationStatus } from '@/service/api/station'
import { useWorkbenchStore } from '@/store'
import { downloadFile } from '@/utils'
@@ -1271,60 +1271,24 @@
  checkedRowKeys.value = rowKeys
}
function getSelectedStationRows() {
  const selectedKeySet = new Set(checkedRowKeys.value)
  return listData.value.filter(row => selectedKeySet.has(row.id))
}
function escapeCsvCell(value: unknown) {
  const text = String(value ?? '').replace(/"/g, '""')
  return `"${text}"`
}
function buildStationCsvContent(rows: any[]) {
  const headers = [
    '场站ID',
    '场站名称',
    '点位数量',
    '限停时长',
    '状态',
    '更新人',
    '更新时间',
    '创建人',
    '创建时间',
  ]
  const records = rows.map((row) => {
    const parkingTimeLimit = row.parkingTimeLimit ? `${row.parkingTimeLimit}分钟` : '-'
    return [
      row.stationNumber || '-',
      row.stationName || '-',
      `${row.pointCount || 0}站点`,
      parkingTimeLimit,
      getStationStatusText(row),
      row.updateBy || '-',
      row.updateTime ? dayjs(row.updateTime).format('YYYY/MM/DD HH:mm') : '-',
      row.createBy || '-',
      row.createTime ? dayjs(row.createTime).format('YYYY/MM/DD HH:mm') : '-',
    ].map(escapeCsvCell).join(',')
  })
  return [`\uFEFF${headers.map(escapeCsvCell).join(',')}`, ...records].join('\n')
}
function handleStationBatchExport() {
async function handleStationBatchExport() {
  if (checkedRowKeys.value.length === 0) {
    message.warning('请先选择需要导出的点位')
    message.warning('请先选择需要导出的场站')
    return
  }
  const selectedRows = getSelectedStationRows()
  const csvContent = buildStationCsvContent(selectedRows)
  const csvBlob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })
  const fileName = `RT运营管理后台-场站列表_${dayjs().format('YYYY-MM-DD')}.csv`
  downloadFile(csvBlob, fileName)
  message.success('导出成功')
  try {
    const res = await exportStationExcel({ ids: checkedRowKeys.value })
    if (res instanceof Blob) {
      downloadFile(res, '场站列表.xlsx')
      message.success('导出成功')
    }
    else {
      message.error('导出失败')
    }
  }
  catch {
    message.error('导出失败')
  }
}
function handleStationDisable(row: any) {
src/views/businessOperations/operationWorkbench/map.vue
@@ -464,6 +464,7 @@
const stationPolyEditor = shallowRef<any>(null);
const stationDraftPolygon = shallowRef<any>(null);
const stationDraftPoints = ref<LngLatTuple[]>([]);
const suppressStationEditorEnd = ref(false);
let stationEditorRollbacking = false;
const restrictedAreaForm = ref<RestrictedAreaFormState>(
  createEmptyRestrictedAreaForm()
@@ -1591,6 +1592,7 @@
function cleanupStationEditorState(removePolygon = true) {
  stationMouseTool.value?.close?.();
  stationMouseTool.value = null;
  if (stationPolyEditor.value) suppressStationEditorEnd.value = true;
  stationPolyEditor.value?.close?.();
  stationPolyEditor.value = null;
  if (removePolygon && stationDraftPolygon.value && map.value)
@@ -1653,6 +1655,7 @@
  if (!map.value || stationDraftPoints.value.length < 3 || stationEditorRollbacking)
    return;
  stationEditorRollbacking = true;
  if (stationPolyEditor.value) suppressStationEditorEnd.value = true;
  stationPolyEditor.value?.close?.();
  stationPolyEditor.value = null;
  if (stationDraftPolygon.value && map.value)
@@ -1668,6 +1671,7 @@
function enableStationDraftEdit() {
  if (!map.value || !stationDraftPolygon.value || stationEditorRollbacking) return;
  if (stationPolyEditor.value) suppressStationEditorEnd.value = true;
  stationPolyEditor.value?.close?.();
  setStationDraftPolygonStyle(true);
  stationPolyEditor.value = new (window as any).AMap.PolyEditor(
@@ -1703,8 +1707,15 @@
    }
    syncStationDraftGeometryState(points);
  };
  const handleStationGeometryEditEnd = () => {
    if (suppressStationEditorEnd.value) {
      suppressStationEditorEnd.value = false;
      return;
    }
    syncStationGeometry();
  };
  stationPolyEditor.value.on("adjust", syncStationGeometry);
  stationPolyEditor.value.on("end", syncStationGeometry);
  stationPolyEditor.value.on("end", handleStationGeometryEditEnd);
  stationPolyEditor.value.on("addnode", syncStationGeometry);
  stationPolyEditor.value.on("removenode", syncStationGeometry);
  stationPolyEditor.value.open();