添加浙大网新厂商
This commit is contained in:
parent
5d1dfb4d0c
commit
e33a988e47
@ -1 +1 @@
|
||||
Subproject commit fe2d65a91d08c62c55608aa28f799bfaaf18808e
|
||||
Subproject commit 3dddb31503eddd794b391a2e17c4f0e11467c2f6
|
@ -1,9 +1,11 @@
|
||||
export enum CategoryType {
|
||||
JK = 'JK',
|
||||
TH = 'TH',
|
||||
ZDWX = 'ZDWX',
|
||||
}
|
||||
|
||||
export const categoryTypeOptions = [
|
||||
{ label: '交控(11)', value: CategoryType.JK },
|
||||
{ label: '通号(12)', value: CategoryType.TH },
|
||||
{ label: '浙大网新', value: CategoryType.ZDWX },
|
||||
];
|
||||
|
@ -9,6 +9,10 @@ const thSignalConsts = {
|
||||
lampNum: 2,
|
||||
};
|
||||
|
||||
const zdwxSignalConsts = {
|
||||
lampNum: 1,
|
||||
};
|
||||
|
||||
function getJkTypeConsts(type: string) {
|
||||
if (type === Signal.Type) {
|
||||
return jkSignalConsts;
|
||||
@ -25,11 +29,21 @@ function getThTypeConsts(type: string) {
|
||||
}
|
||||
}
|
||||
|
||||
function getZdwxTypeConsts(type: string) {
|
||||
if (type === Signal.Type) {
|
||||
return zdwxSignalConsts;
|
||||
} else {
|
||||
throw new Error('未找到该设备类型的常量');
|
||||
}
|
||||
}
|
||||
|
||||
export function getCategoryConsts(category: CategoryType) {
|
||||
if (category === CategoryType.TH) {
|
||||
return getThTypeConsts;
|
||||
} else if (category === CategoryType.JK) {
|
||||
return getJkTypeConsts;
|
||||
} else if (category === CategoryType.ZDWX) {
|
||||
return getZdwxTypeConsts;
|
||||
} else {
|
||||
throw new Error('未找到该厂商的常量函数');
|
||||
}
|
||||
|
210
src/drawApp/zdwxApp.ts
Normal file
210
src/drawApp/zdwxApp.ts
Normal file
@ -0,0 +1,210 @@
|
||||
import { fromUint8Array, toUint8Array } from 'js-base64';
|
||||
import {
|
||||
CombinationKey,
|
||||
IDrawApp,
|
||||
IGraphicStorage,
|
||||
KeyListener,
|
||||
newDrawApp,
|
||||
} from 'src/jl-graphic';
|
||||
import { graphicData } from 'src/protos/stationLayoutGraphics';
|
||||
import { getDraft } from 'src/api/DraftApi';
|
||||
import { useDrawStore } from 'src/stores/draw-store';
|
||||
import { useLineStore } from 'src/stores/line-store';
|
||||
import { TrackSectionDraw } from 'src/graphics/trackSection/TrackSectionDrawAssistant';
|
||||
import {
|
||||
TrackSection,
|
||||
TrackSectionTemplate,
|
||||
} from 'src/graphics/trackSection/TrackSection';
|
||||
import { TrackSectionData } from './graphics/TrackSectionInteraction';
|
||||
import { TrackLogicSectionDraw } from 'src/graphics/trackLogicSection/TrackLogicSectionDrawAssistant';
|
||||
import {
|
||||
TrackLogicSection,
|
||||
TrackLogicSectionTemplate,
|
||||
} from 'src/graphics/trackLogicSection/TrackLogicSection';
|
||||
import { TrackLogicSectionData } from './graphics/TrackLogicSectionInteraction';
|
||||
import {
|
||||
drawCommonLayerList,
|
||||
initCommonDrawApp,
|
||||
saveCommonDrawDatas,
|
||||
loadCommonDrawDatas,
|
||||
saveDrawToServer,
|
||||
} from './commonApp';
|
||||
import { SignalDraw } from 'src/graphics/signal/SignalDrawAssistant';
|
||||
import { SignalTemplate, Signal } from 'src/graphics/signal/Signal';
|
||||
import { SignalData, SignalState } from './graphics/SignalInteraction';
|
||||
import { getCategoryConsts } from './gategoryConsts';
|
||||
import { CategoryType } from 'src/components/CategoryType';
|
||||
|
||||
let zdwxDrawApp: IDrawApp | null = null;
|
||||
|
||||
export function getZdwxDrawApp(): IDrawApp | null {
|
||||
return zdwxDrawApp;
|
||||
}
|
||||
|
||||
export function destroyZdwxDrawApp(): void {
|
||||
if (zdwxDrawApp) {
|
||||
zdwxDrawApp.destroy();
|
||||
zdwxDrawApp = null;
|
||||
}
|
||||
}
|
||||
|
||||
export const drawZdwxLayerList = [
|
||||
// 图层列表 默认显示的图层defaultShow: true
|
||||
...drawCommonLayerList,
|
||||
{ label: '轨道区段', value: TrackSection.Type, defaultShow: false },
|
||||
{ label: '轨道逻辑区段', value: TrackLogicSection.Type, defaultShow: false },
|
||||
];
|
||||
|
||||
function initZdwxShowLayer(app: IDrawApp) {
|
||||
const showTypeList: string[] = [];
|
||||
drawCommonLayerList.forEach((item) => {
|
||||
if (item.defaultShow) {
|
||||
showTypeList.push(item.value);
|
||||
}
|
||||
});
|
||||
const alllGraphic = app.queryStore.getAllGraphics();
|
||||
alllGraphic.forEach((g) => {
|
||||
if (showTypeList.includes(g.type)) {
|
||||
g.visible = true;
|
||||
} else {
|
||||
g.visible = false;
|
||||
}
|
||||
});
|
||||
const lineStore = useLineStore();
|
||||
lineStore.setShowLayer(showTypeList);
|
||||
}
|
||||
|
||||
export function initZdwxDrawApp(): IDrawApp {
|
||||
zdwxDrawApp = newDrawApp({
|
||||
dataLoader: loadZdwxDrawDatas,
|
||||
});
|
||||
const app = zdwxDrawApp;
|
||||
const getZdwxTypeConsts = getCategoryConsts(CategoryType.ZDWX);
|
||||
initCommonDrawApp(app);
|
||||
new SignalDraw(
|
||||
app,
|
||||
new SignalTemplate(
|
||||
new SignalData(),
|
||||
new SignalState(),
|
||||
getZdwxTypeConsts(Signal.Type)
|
||||
)
|
||||
);
|
||||
new TrackSectionDraw(app, new TrackSectionTemplate(new TrackSectionData()));
|
||||
new TrackLogicSectionDraw(
|
||||
app,
|
||||
new TrackLogicSectionTemplate(new TrackLogicSectionData())
|
||||
);
|
||||
app.addKeyboardListener(
|
||||
new KeyListener({
|
||||
value: 'KeyS',
|
||||
global: true,
|
||||
combinations: [CombinationKey.Ctrl],
|
||||
onPress: () => {
|
||||
saveDrawToServer(saveZdwxDrawDatas(app));
|
||||
},
|
||||
})
|
||||
);
|
||||
app.on('postdataloaded', () => {
|
||||
initZdwxShowLayer(app);
|
||||
});
|
||||
return zdwxDrawApp;
|
||||
}
|
||||
|
||||
export async function loadZdwxDrawDatas(): Promise<IGraphicStorage> {
|
||||
const drawStore = useDrawStore();
|
||||
const id = drawStore.draftId;
|
||||
if (!id) {
|
||||
throw new Error('获取数据异常:为获取到草稿地图ID');
|
||||
}
|
||||
const { proto: base64 } = await getDraft(id);
|
||||
if (base64) {
|
||||
const storage = graphicData.RtssGraphicStorage.deserialize(
|
||||
toUint8Array(base64)
|
||||
);
|
||||
const datas = loadCommonDrawDatas(storage);
|
||||
storage.trackSections.forEach((section) => {
|
||||
datas.push(new TrackSectionData(section));
|
||||
});
|
||||
storage.trackLogicSections.forEach((logicSection) => {
|
||||
datas.push(new TrackLogicSectionData(logicSection));
|
||||
});
|
||||
refDevicesList = storage.stationRelateDeviceList;
|
||||
return Promise.resolve({
|
||||
canvasProperty: storage.canvas,
|
||||
datas: datas,
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve({
|
||||
datas: [],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function saveZdwxDrawDatas(app: IDrawApp) {
|
||||
const storage = saveCommonDrawDatas(app, refDevicesList);
|
||||
console.log(storage, '保存数据');
|
||||
const graphics = app.queryStore.getAllGraphics();
|
||||
graphics.forEach((g) => {
|
||||
if (TrackSection.Type === g.type) {
|
||||
const trackSectionData = (g as TrackSection).saveData();
|
||||
storage.trackSections.push((trackSectionData as TrackSectionData).data);
|
||||
} else if (TrackLogicSection.Type === g.type) {
|
||||
const trackLogicSectionData = (g as TrackLogicSection).saveData();
|
||||
storage.trackLogicSections.push(
|
||||
(trackLogicSectionData as TrackLogicSectionData).data
|
||||
);
|
||||
}
|
||||
});
|
||||
const base64 = fromUint8Array(storage.serialize());
|
||||
return base64;
|
||||
}
|
||||
|
||||
//关联设备列表的增删改查
|
||||
export interface RelateDevicelistItem {
|
||||
deviceType: graphicData.RelatedRef.DeviceType | undefined;
|
||||
code: string;
|
||||
combinationtypes: {
|
||||
code: string;
|
||||
refDevices: string[];
|
||||
refDevicesCode?: string[];
|
||||
expanded?: boolean;
|
||||
}[];
|
||||
}
|
||||
|
||||
let refDevicesList: graphicData.StationRelateDevice[] = [];
|
||||
export function loadStationRelateDeviceList() {
|
||||
return refDevicesList;
|
||||
}
|
||||
|
||||
export function creatStationRelateDevice(row: graphicData.StationRelateDevice) {
|
||||
refDevicesList.push(row);
|
||||
zdwxDrawApp?.emit('postdataloaded');
|
||||
}
|
||||
|
||||
export function editStationRelateDevice(
|
||||
editRow: RelateDevicelistItem,
|
||||
newData: graphicData.StationRelateDevice
|
||||
) {
|
||||
for (let i = 0; i < refDevicesList.length; i++) {
|
||||
if (
|
||||
refDevicesList[i].deviceType == editRow.deviceType &&
|
||||
refDevicesList[i].code == editRow.code
|
||||
) {
|
||||
refDevicesList[i] = newData;
|
||||
break;
|
||||
}
|
||||
}
|
||||
zdwxDrawApp?.emit('postdataloaded');
|
||||
}
|
||||
|
||||
export function deleteStationRelateDevice(row: RelateDevicelistItem) {
|
||||
for (let i = 0; i < refDevicesList.length; i++) {
|
||||
if (
|
||||
refDevicesList[i].deviceType == row.deviceType &&
|
||||
refDevicesList[i].code == row.code
|
||||
) {
|
||||
refDevicesList.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -273,6 +273,7 @@ import { DialogChainObject, useQuasar } from 'quasar';
|
||||
import LayerControlDialog from 'src/components/draw-app/dialogs/LayerControlDialog.vue';
|
||||
import { drawThLayerList } from 'src/drawApp/thApp';
|
||||
import { drawJkLayerList } from 'src/drawApp/jkApp';
|
||||
import { drawZdwxLayerList, saveZdwxDrawDatas } from 'src/drawApp/zdwxApp';
|
||||
import { useLineStore } from 'src/stores/line-store';
|
||||
import { Curvature } from 'src/graphics/curvature/Curvature';
|
||||
import { CurvatureDraw } from 'src/graphics/curvature/CurvatureAssistant';
|
||||
@ -502,6 +503,9 @@ function saveAllDrawDatas() {
|
||||
case CategoryType.JK:
|
||||
base64 = saveJkDrawDatas(drawApp);
|
||||
break;
|
||||
case CategoryType.ZDWX:
|
||||
base64 = saveJkDrawDatas(drawApp);
|
||||
break;
|
||||
}
|
||||
saveDrawToServer(base64);
|
||||
}
|
||||
@ -516,6 +520,9 @@ function handleCheckData() {
|
||||
case CategoryType.JK:
|
||||
base64 = saveJkDrawDatas(drawApp);
|
||||
break;
|
||||
case CategoryType.ZDWX:
|
||||
base64 = saveZdwxDrawDatas(drawApp);
|
||||
break;
|
||||
}
|
||||
checkDataToServer(base64);
|
||||
}
|
||||
@ -687,6 +694,9 @@ async function saveAs(name: string) {
|
||||
case CategoryType.JK:
|
||||
base64 = saveJkDrawDatas(drawApp);
|
||||
break;
|
||||
case CategoryType.ZDWX:
|
||||
base64 = saveZdwxDrawDatas(drawApp);
|
||||
break;
|
||||
}
|
||||
const record = await saveAsDraft(+route.params.id as number, {
|
||||
name,
|
||||
@ -733,6 +743,9 @@ watch(
|
||||
case CategoryType.JK:
|
||||
drawLayerList = drawJkLayerList;
|
||||
break;
|
||||
case CategoryType.ZDWX:
|
||||
drawLayerList = drawZdwxLayerList;
|
||||
break;
|
||||
}
|
||||
dialogInstance.value = $q
|
||||
.dialog({
|
||||
|
@ -169,6 +169,8 @@ onMounted(async () => {
|
||||
lineStore.setCategoryType(CategoryType.JK);
|
||||
} else if (CategoryType.TH === category) {
|
||||
lineStore.setCategoryType(CategoryType.TH);
|
||||
} else if (CategoryType.ZDWX === category) {
|
||||
lineStore.setCategoryType(CategoryType.ZDWX);
|
||||
}
|
||||
if (find) {
|
||||
sceneInfo.value = find;
|
||||
|
@ -11,6 +11,11 @@ import {
|
||||
getJkDrawApp,
|
||||
initJkDrawApp,
|
||||
} from 'src/drawApp/jkApp';
|
||||
import {
|
||||
destroyZdwxDrawApp,
|
||||
getZdwxDrawApp,
|
||||
initZdwxDrawApp,
|
||||
} from 'src/drawApp/zdwxApp';
|
||||
import {
|
||||
DrawAssistant,
|
||||
GraphicData,
|
||||
@ -76,6 +81,9 @@ export const useDrawStore = defineStore('draw', {
|
||||
case CategoryType.JK:
|
||||
app = getJkDrawApp();
|
||||
break;
|
||||
case CategoryType.ZDWX:
|
||||
app = getZdwxDrawApp();
|
||||
break;
|
||||
}
|
||||
return app;
|
||||
},
|
||||
@ -114,6 +122,9 @@ export const useDrawStore = defineStore('draw', {
|
||||
case CategoryType.JK:
|
||||
app = initJkDrawApp();
|
||||
break;
|
||||
case CategoryType.ZDWX:
|
||||
app = initZdwxDrawApp();
|
||||
break;
|
||||
}
|
||||
if (app == null) {
|
||||
throw new Error('未初始化app');
|
||||
@ -144,6 +155,9 @@ export const useDrawStore = defineStore('draw', {
|
||||
case CategoryType.JK:
|
||||
destroyJkDrawApp();
|
||||
break;
|
||||
case CategoryType.ZDWX:
|
||||
destroyZdwxDrawApp();
|
||||
break;
|
||||
}
|
||||
},
|
||||
setDraftId(id: number | null) {
|
||||
|
Loading…
Reference in New Issue
Block a user