From c3d4c7cc12679e0683e645f5063af2a377cf69e3 Mon Sep 17 00:00:00 2001 From: Yuan Date: Wed, 23 Aug 2023 15:45:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8C=83=E5=9B=B4=E5=88=97=E8=A1=A8=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/TrainApi.ts | 15 +++++++++++++++ src/components/RangeList.vue | 17 ++++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/api/TrainApi.ts b/src/api/TrainApi.ts index 739168e..b8a2956 100644 --- a/src/api/TrainApi.ts +++ b/src/api/TrainApi.ts @@ -44,6 +44,21 @@ export enum DevType { DEVICE_TYPE_GAMA = 'DEVICE_TYPE_GAMA', } +export const deviceTypeMap = { + DEVICE_TYPE_UNKNOW: '未知设备', + DEVICE_TYPE_RTU: '集中站', + DEVICE_TYPE_STATION: '车站', + DEVICE_TYPE_SIGNAL: '信号机', + DEVICE_TYPE_SWITCH: '道岔', + DEVICE_TYPE_TRACK: '轨道', + DEVICE_TYPE_ENTRY: '方向设备', + DEVICE_TYPE_PLATFORM: '站台', + DEVICE_TYPE_SCADA: '供电区段', + DEVICE_TYPE_WATERPROOF_DOOR: '防淹门', + DEVICE_TYPE_WORK_AREA: '工作区', + DEVICE_TYPE_GAMA: '区域自动驾驶', +}; + export function trainMockApi( lineId: number, data: { diff --git a/src/components/RangeList.vue b/src/components/RangeList.vue index 8d33f3d..75a4354 100644 --- a/src/components/RangeList.vue +++ b/src/components/RangeList.vue @@ -9,6 +9,7 @@ import { useRoute } from 'vue-router'; import DraggableDialog from './common/DraggableDialog.vue'; import { QTable, useQuasar } from 'quasar'; import { errorNotify } from 'src/utils/CommonNotify'; +import { deviceTypeMap } from 'src/api/TrainApi'; const $q = useQuasar(); const lineId = useRoute().params.id as string; @@ -16,11 +17,16 @@ const tableRef = ref(); const columns: QTable['columns'] = [ { name: 'id', label: 'ID', field: 'id', align: 'center' }, { name: 'lineId', label: '线路ID', field: 'lineId', align: 'center' }, - { name: 'areaName', label: '名称', field: 'areaName', align: 'center' }, + { + name: 'areaName', + label: '名称', + field: 'areaName', + align: 'center', + }, { name: 'deviceType', label: '设备类型', - field: 'deviceType', + field: (row) => deviceTypeMap[row.deviceType as keyof typeof deviceTypeMap], align: 'center', }, { name: 'operations', label: '操作', field: 'operations', align: 'center' }, @@ -64,13 +70,14 @@ function onEdit(row: IAreaConfigListItem) { props.onEditClick(row); } function deleteData(row: IAreaConfigListItem) { - console.log(row); $q.dialog({ message: `确定删除 "${row.areaName}" 吗?`, cancel: true }).onOk( - () => { + async () => { try { - deleteDeviceArea(row.id); + await deleteDeviceArea(row.id); } catch (err) { errorNotify('删除失败:', err); + } finally { + tableRef.value?.requestServerInteraction(); } } );