diff --git a/src/api/DraftApi.ts b/src/api/DraftApi.ts index 849d4c8..d53a0e2 100644 --- a/src/api/DraftApi.ts +++ b/src/api/DraftApi.ts @@ -15,7 +15,8 @@ export interface DraftItem { id: number; name: string; dataType: DraftDataType; - data: []; + options: { style: IscsStyle }; + data: string; userId: number; isShared: boolean; createdAt: string; @@ -42,12 +43,12 @@ export async function draftPageQuery( userDraftIscsDataPaging(paging: $paging, query: $query) { total data { - id name dataType createdAt updatedAt isShared + id name dataType createdAt updatedAt isShared options {style} } } } `; - const response = await api.post(``, { + const response = await api.post('', { query, variables: params, }); @@ -78,7 +79,7 @@ export function createDraft(params: CreateDraftIscsDto) { } } `; - return api.post(``, { + return api.post('', { query: mutation, variables: params, }); @@ -97,7 +98,7 @@ export function deleteDraft(id: number) { const variables = { id, }; - return api.post(``, { + return api.post('', { query: mutation, variables, }); @@ -109,8 +110,21 @@ export function deleteDraft(id: number) { * @returns */ export async function getDraft(id: number): Promise { - const response = await api.get(`${DraftUriBase}/${id}`); - return response.data; + const query = ` + query draftData($id: Int) { + draftData(id: $id){ + data + } + } +`; + const variables = { + id, + }; + const response = await api.post('', { + query, + variables, + }); + return response.data.data.draftData; } /** @@ -118,13 +132,23 @@ export async function getDraft(id: number): Promise { * @param data * @returns */ -export function saveDraft( - id: number, - data: { - proto: string; +export function saveDraft(data: { id: number; data: string }) { + const mutation = ` + mutation updateDraftDataData($id: Int,$data: String) { + updateDraftDataData(id: $id,data: $data){ + id + } } -) { - return api.put(`${DraftUriBase}/${id}`, data); +`; + const variables = { + id: 1, + data: data.data, + }; + console.log(data); + return api.post('', { + query: mutation, + variables: variables, + }); } /** diff --git a/src/components/common/DraggableDialog.vue b/src/components/common/DraggableDialog.vue new file mode 100644 index 0000000..b4a458a --- /dev/null +++ b/src/components/common/DraggableDialog.vue @@ -0,0 +1,202 @@ + + + diff --git a/src/components/common/ResizableDivHeight.vue b/src/components/common/ResizableDivHeight.vue new file mode 100644 index 0000000..8339c89 --- /dev/null +++ b/src/components/common/ResizableDivHeight.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/src/components/common/ResizableDivWidth.vue b/src/components/common/ResizableDivWidth.vue new file mode 100644 index 0000000..a2ce8ad --- /dev/null +++ b/src/components/common/ResizableDivWidth.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/src/components/common/SelectConfigUtils.vue b/src/components/common/SelectConfigUtils.vue new file mode 100644 index 0000000..1c1ada4 --- /dev/null +++ b/src/components/common/SelectConfigUtils.vue @@ -0,0 +1,186 @@ + + + diff --git a/src/components/draw-app/CCTVDrawProperties.vue b/src/components/draw-app/IscsDrawProperties.vue similarity index 95% rename from src/components/draw-app/CCTVDrawProperties.vue rename to src/components/draw-app/IscsDrawProperties.vue index e4744e5..0ff94f3 100644 --- a/src/components/draw-app/CCTVDrawProperties.vue +++ b/src/components/draw-app/IscsDrawProperties.vue @@ -34,9 +34,9 @@ /> - diff --git a/src/components/draw-app/properties/CCTV/CCTVButtonProperty.vue b/src/components/draw-app/properties/CCTV/CCTVButtonProperty.vue index 60b5654..482b71b 100644 --- a/src/components/draw-app/properties/CCTV/CCTVButtonProperty.vue +++ b/src/components/draw-app/properties/CCTV/CCTVButtonProperty.vue @@ -24,8 +24,8 @@ diff --git a/src/configs/iscsStyleConfig.ts b/src/configs/iscsStyleConfig.ts new file mode 100644 index 0000000..263f913 --- /dev/null +++ b/src/configs/iscsStyleConfig.ts @@ -0,0 +1,76 @@ +import { IscsStyle } from 'src/api/DraftApi'; + +//达实智能(福州一号线) +const DA_SHI_ZHI_NENG = [ + { + menuName: '火灾报警', + submenu: [ + { sunMenuName: '站台报警' }, + { sunMenuName: '站厅报警' }, + { sunMenuName: '系统状态' }, + ], + }, + { + menuName: '机电', + submenu: [ + { sunMenuName: '大系统' }, + { sunMenuName: '小系统' }, + { sunMenuName: '水系统' }, + { sunMenuName: '照明' }, + { sunMenuName: '电、扶梯' }, + { sunMenuName: '给排水' }, + { sunMenuName: '模式' }, + { sunMenuName: '隧道通风' }, + { sunMenuName: '时间表' }, + { sunMenuName: '权限交接' }, + { sunMenuName: '传感器' }, + { sunMenuName: '车站网络' }, + ], + }, + { + menuName: '广播', + submenu: [{ sunMenuName: '子目录' }], + }, + { + menuName: '乘客信息', + submenu: [{ sunMenuName: '子目录' }], + }, + { + menuName: '闭路电视', + submenu: [ + { sunMenuName: '车站控制' }, + { sunMenuName: '车站时序' }, + { sunMenuName: '车站时序编辑' }, + { sunMenuName: '车站设备状态' }, + ], + }, + { + menuName: '屏蔽门', + submenu: [{ sunMenuName: '屏蔽门' }], + }, + { + menuName: '售检票', + submenu: [{ sunMenuName: '子目录' }], + }, + { + menuName: '门禁', + submenu: [{ sunMenuName: '子目录' }], + }, + { + menuName: '防淹门', + submenu: [{ sunMenuName: '子目录' }], + }, + { + menuName: '网络状态', + submenu: [{ sunMenuName: '子目录' }], + }, +]; + +export function getIscsStyleConfig(style: IscsStyle) { + switch (style) { + case IscsStyle.DA_SHI_ZHI_NENG: + return DA_SHI_ZHI_NENG; + default: + return DA_SHI_ZHI_NENG; + } +} diff --git a/src/drawApp/commonApp.ts b/src/drawApp/commonApp.ts index a55396c..78ba9a9 100644 --- a/src/drawApp/commonApp.ts +++ b/src/drawApp/commonApp.ts @@ -20,6 +20,8 @@ import { Rect, RectTemplate } from 'src/graphics/rect/Rect'; import { RectDraw } from 'src/graphics/rect/RectDrawAssistant'; import { RectData } from './graphics/RectInteraction'; import { common } from 'src/protos/common'; +import { errorNotify, successNotify } from 'src/utils/CommonNotify'; +import { saveDraft } from 'src/api/DraftApi'; const UndoOptions: MenuItemOptions = { name: '撤销', @@ -121,7 +123,13 @@ export function saveDrawToServer(base64: string) { if (!id) { return; } - console.log('save' + base64); + saveDraft({ id, data: base64 }) + .then(() => { + successNotify('保存数据成功!'); + }) + .catch((err) => { + errorNotify(err.message, err); + }); } let UniqueIdPrefix = new iscsGraphicData.UniqueIdOfStationLayout(); diff --git a/src/drawApp/graphics/CCTV/CCTVButtonInteraction.ts b/src/drawApp/graphics/CCTV/CCTVButtonInteraction.ts index c4b628f..0647fd8 100644 --- a/src/drawApp/graphics/CCTV/CCTVButtonInteraction.ts +++ b/src/drawApp/graphics/CCTV/CCTVButtonInteraction.ts @@ -1,26 +1,26 @@ import * as pb_1 from 'google-protobuf'; -import { CCTVGraphicData } from 'src/protos/cctv_graphic_data'; import { GraphicDataBase } from '../GraphicDataBase'; import { CCTVButton, ICCTVButtonData, } from 'src/graphics/CCTV/cctvButton/CCTVButton'; +import { iscsGraphicData } from 'src/protos/iscs_graphic_data'; export class CCTVButtonData extends GraphicDataBase implements ICCTVButtonData { - constructor(data?: CCTVGraphicData.CCTVButton) { + constructor(data?: iscsGraphicData.CCTVButton) { let cctvButton; if (data) { cctvButton = data; } else { - cctvButton = new CCTVGraphicData.CCTVButton({ + cctvButton = new iscsGraphicData.CCTVButton({ common: GraphicDataBase.defaultCommonInfo(CCTVButton.Type), }); } super(cctvButton); } - public get data(): CCTVGraphicData.CCTVButton { - return this.getData(); + public get data(): iscsGraphicData.CCTVButton { + return this.getData(); } get code(): string { @@ -29,10 +29,10 @@ export class CCTVButtonData extends GraphicDataBase implements ICCTVButtonData { set code(v: string) { this.data.code = v; } - get buttonType(): CCTVGraphicData.CCTVButton.ButtonType { + get buttonType(): iscsGraphicData.CCTVButton.ButtonType { return this.data.buttonType; } - set buttonType(v: CCTVGraphicData.CCTVButton.ButtonType) { + set buttonType(v: iscsGraphicData.CCTVButton.ButtonType) { this.data.buttonType = v; } clone(): CCTVButtonData { diff --git a/src/drawApp/cctvApp.ts b/src/drawApp/iscsApp.ts similarity index 74% rename from src/drawApp/cctvApp.ts rename to src/drawApp/iscsApp.ts index 5952cde..6b8d289 100644 --- a/src/drawApp/cctvApp.ts +++ b/src/drawApp/iscsApp.ts @@ -6,10 +6,10 @@ import { KeyListener, newDrawApp, } from 'jl-graphic'; -import { CCTVGraphicData } from 'src/protos/cctv_graphic_data'; -import { fromUint8Array } from 'js-base64'; + import { initCommonDrawApp, + loadCommonDrawDatas, saveCommonDrawDatas, saveDrawToServer, } from './commonApp'; @@ -17,21 +17,24 @@ import { CCTVButtonData } from './graphics/CCTV/CCTVButtonInteraction'; import { CCTVButtonDraw } from 'src/graphics/CCTV/cctvButton/CCTVButtonDrawAssistant'; import { CCTVButtonTemplate } from 'src/graphics/CCTV/cctvButton/CCTVButton'; import { useDrawStore } from 'src/stores/draw-store'; +import { iscsGraphicData } from 'src/protos/iscs_graphic_data'; +import { getDraft } from 'src/api/DraftApi'; +import { fromUint8Array, toUint8Array } from 'js-base64'; let drawApp: IDrawApp | null = null; -export function getCCTVDrawApp(): IDrawApp | null { +export function getIscsDrawApp(): IDrawApp | null { return drawApp; } -export function destroyCCTVDrawApp(): void { +export function destroyIscsDrawApp(): void { if (drawApp) { drawApp.destroy(); drawApp = null; } } -export function initCCTVDrawApp(): IDrawApp { +export function initIscsDrawApp(): IDrawApp { const isSupportDeletion = (g: JlGraphic) => { console.log(g); return true; @@ -63,23 +66,28 @@ export async function loadDrawDatas(): Promise { if (!id) { throw new Error('获取数据异常:为获取到草稿地图ID'); } - /* const { proto: base64 } = await getDraft(id); + const { data: base64 } = await getDraft(id); if (base64) { const storage = iscsGraphicData.IscsGraphicStorage.deserialize( toUint8Array(base64) ); - const datas = loadCommonDrawDatas(storage);} */ - return Promise.resolve({ - datas: [], - }); + const datas = loadCommonDrawDatas(storage); + storage.cctvButtons.forEach((cctvButton) => { + datas.push(new CCTVButtonData(cctvButton)); + }); + } else { + return Promise.resolve({ + datas: [], + }); + } } export function saveDrawDatas(app: IDrawApp) { - let storage = new CCTVGraphicData.CCTVGraphicStorage(); + let storage = new iscsGraphicData.IscsGraphicStorage(); storage = saveCommonDrawDatas( app, storage - ) as CCTVGraphicData.CCTVGraphicStorage; + ) as iscsGraphicData.IscsGraphicStorage; const graphics = app.queryStore.getAllGraphics(); /* graphics.forEach((g) => { if (TrackSection.Type === g.type) { diff --git a/src/graphics/CCTV/cctvButton/CCTVButton.ts b/src/graphics/CCTV/cctvButton/CCTVButton.ts index 7ae3f2f..5259237 100644 --- a/src/graphics/CCTV/cctvButton/CCTVButton.ts +++ b/src/graphics/CCTV/cctvButton/CCTVButton.ts @@ -1,8 +1,8 @@ import { GraphicData, JlGraphic, JlGraphicTemplate } from 'jl-graphic'; import CCTV_Button_Assets from './cctv-button-spritesheet.png'; import CCTV_Button_JSON from './cctv-button-data.json'; -import { CCTVGraphicData } from 'src/protos/cctv_graphic_data'; import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js'; +import { iscsGraphicData } from 'src/protos/iscs_graphic_data'; interface CCTVButtonTextures { rectPressBtn: Texture; @@ -14,8 +14,8 @@ interface CCTVButtonTextures { export interface ICCTVButtonData extends GraphicData { get code(): string; set code(v: string); - get buttonType(): CCTVGraphicData.CCTVButton.ButtonType; - set buttonType(v: CCTVGraphicData.CCTVButton.ButtonType); + get buttonType(): iscsGraphicData.CCTVButton.ButtonType; + set buttonType(v: iscsGraphicData.CCTVButton.ButtonType); } export class CCTVButton extends JlGraphic { @@ -40,10 +40,10 @@ export class CCTVButton extends JlGraphic { } doRepaint(): void { - if (this.datas.buttonType == CCTVGraphicData.CCTVButton.ButtonType.rect) { + if (this.datas.buttonType == iscsGraphicData.CCTVButton.ButtonType.rect) { this._cctvButton.texture = this.cctvButtonTextures.rectBtn; } else if ( - this.datas.buttonType == CCTVGraphicData.CCTVButton.ButtonType.monitor + this.datas.buttonType == iscsGraphicData.CCTVButton.ButtonType.monitor ) { this._cctvButton.texture = this.cctvButtonTextures.monitorBtn; } else { diff --git a/src/layouts/IscsDrawLayout.vue b/src/layouts/IscsDrawLayout.vue index 8ef49e6..75cfd43 100644 --- a/src/layouts/IscsDrawLayout.vue +++ b/src/layouts/IscsDrawLayout.vue @@ -18,23 +18,23 @@ - - - + + + + + + diff --git a/src/pages/IscsDraftManage.vue b/src/pages/IscsDraftManage.vue index 2507815..a02c3f7 100644 --- a/src/pages/IscsDraftManage.vue +++ b/src/pages/IscsDraftManage.vue @@ -154,6 +154,7 @@ const tableHeight = computed(() => { return props.sizeHeight - 32; }); + onMounted(() => { tableRef.value.requestServerInteraction(); }); @@ -314,6 +315,6 @@ async function deleteData(row: DraftItem) { function goToPath(row: DraftItem) { let path = `/iscsPainting/${row.id}`; - router.push({ path: path }); + router.push({ path: path, query: { iscsStyle: row.options.style } }); } diff --git a/src/protos/cctv_graphic_data.ts b/src/protos/cctv_graphic_data.ts deleted file mode 100644 index 3165f05..0000000 --- a/src/protos/cctv_graphic_data.ts +++ /dev/null @@ -1,294 +0,0 @@ -/** - * Generated by the protoc-gen-ts. DO NOT EDIT! - * compiler version: 5.27.4 - * source: cctv_graphic_data.proto - * git: https://github.com/thesayyn/protoc-gen-ts */ -import * as dependency_1 from "./iscs_graphic_data"; -import * as pb_1 from "google-protobuf"; -export namespace CCTVGraphicData { - export class CCTVGraphicStorage extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | { - canvas?: dependency_1.iscsGraphicData.Canvas; - cctvButtons?: CCTVButton[]; - arrows?: dependency_1.iscsGraphicData.Arrow[]; - iscsTexts?: dependency_1.iscsGraphicData.IscsText[]; - rects?: dependency_1.iscsGraphicData.Rect[]; - }) { - super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5], this.#one_of_decls); - if (!Array.isArray(data) && typeof data == "object") { - if ("canvas" in data && data.canvas != undefined) { - this.canvas = data.canvas; - } - if ("cctvButtons" in data && data.cctvButtons != undefined) { - this.cctvButtons = data.cctvButtons; - } - if ("arrows" in data && data.arrows != undefined) { - this.arrows = data.arrows; - } - if ("iscsTexts" in data && data.iscsTexts != undefined) { - this.iscsTexts = data.iscsTexts; - } - if ("rects" in data && data.rects != undefined) { - this.rects = data.rects; - } - } - } - get canvas() { - return pb_1.Message.getWrapperField(this, dependency_1.iscsGraphicData.Canvas, 1) as dependency_1.iscsGraphicData.Canvas; - } - set canvas(value: dependency_1.iscsGraphicData.Canvas) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_canvas() { - return pb_1.Message.getField(this, 1) != null; - } - get cctvButtons() { - return pb_1.Message.getRepeatedWrapperField(this, CCTVButton, 2) as CCTVButton[]; - } - set cctvButtons(value: CCTVButton[]) { - pb_1.Message.setRepeatedWrapperField(this, 2, value); - } - get arrows() { - return pb_1.Message.getRepeatedWrapperField(this, dependency_1.iscsGraphicData.Arrow, 3) as dependency_1.iscsGraphicData.Arrow[]; - } - set arrows(value: dependency_1.iscsGraphicData.Arrow[]) { - pb_1.Message.setRepeatedWrapperField(this, 3, value); - } - get iscsTexts() { - return pb_1.Message.getRepeatedWrapperField(this, dependency_1.iscsGraphicData.IscsText, 4) as dependency_1.iscsGraphicData.IscsText[]; - } - set iscsTexts(value: dependency_1.iscsGraphicData.IscsText[]) { - pb_1.Message.setRepeatedWrapperField(this, 4, value); - } - get rects() { - return pb_1.Message.getRepeatedWrapperField(this, dependency_1.iscsGraphicData.Rect, 5) as dependency_1.iscsGraphicData.Rect[]; - } - set rects(value: dependency_1.iscsGraphicData.Rect[]) { - pb_1.Message.setRepeatedWrapperField(this, 5, value); - } - static fromObject(data: { - canvas?: ReturnType; - cctvButtons?: ReturnType[]; - arrows?: ReturnType[]; - iscsTexts?: ReturnType[]; - rects?: ReturnType[]; - }): CCTVGraphicStorage { - const message = new CCTVGraphicStorage({}); - if (data.canvas != null) { - message.canvas = dependency_1.iscsGraphicData.Canvas.fromObject(data.canvas); - } - if (data.cctvButtons != null) { - message.cctvButtons = data.cctvButtons.map(item => CCTVButton.fromObject(item)); - } - if (data.arrows != null) { - message.arrows = data.arrows.map(item => dependency_1.iscsGraphicData.Arrow.fromObject(item)); - } - if (data.iscsTexts != null) { - message.iscsTexts = data.iscsTexts.map(item => dependency_1.iscsGraphicData.IscsText.fromObject(item)); - } - if (data.rects != null) { - message.rects = data.rects.map(item => dependency_1.iscsGraphicData.Rect.fromObject(item)); - } - return message; - } - toObject() { - const data: { - canvas?: ReturnType; - cctvButtons?: ReturnType[]; - arrows?: ReturnType[]; - iscsTexts?: ReturnType[]; - rects?: ReturnType[]; - } = {}; - if (this.canvas != null) { - data.canvas = this.canvas.toObject(); - } - if (this.cctvButtons != null) { - data.cctvButtons = this.cctvButtons.map((item: CCTVButton) => item.toObject()); - } - if (this.arrows != null) { - data.arrows = this.arrows.map((item: dependency_1.iscsGraphicData.Arrow) => item.toObject()); - } - if (this.iscsTexts != null) { - data.iscsTexts = this.iscsTexts.map((item: dependency_1.iscsGraphicData.IscsText) => item.toObject()); - } - if (this.rects != null) { - data.rects = this.rects.map((item: dependency_1.iscsGraphicData.Rect) => item.toObject()); - } - return data; - } - serialize(): Uint8Array; - serialize(w: pb_1.BinaryWriter): void; - serialize(w?: pb_1.BinaryWriter): Uint8Array | void { - const writer = w || new pb_1.BinaryWriter(); - if (this.has_canvas) - writer.writeMessage(1, this.canvas, () => this.canvas.serialize(writer)); - if (this.cctvButtons.length) - writer.writeRepeatedMessage(2, this.cctvButtons, (item: CCTVButton) => item.serialize(writer)); - if (this.arrows.length) - writer.writeRepeatedMessage(3, this.arrows, (item: dependency_1.iscsGraphicData.Arrow) => item.serialize(writer)); - if (this.iscsTexts.length) - writer.writeRepeatedMessage(4, this.iscsTexts, (item: dependency_1.iscsGraphicData.IscsText) => item.serialize(writer)); - if (this.rects.length) - writer.writeRepeatedMessage(5, this.rects, (item: dependency_1.iscsGraphicData.Rect) => item.serialize(writer)); - if (!w) - return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CCTVGraphicStorage { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new CCTVGraphicStorage(); - while (reader.nextField()) { - if (reader.isEndGroup()) - break; - switch (reader.getFieldNumber()) { - case 1: - reader.readMessage(message.canvas, () => message.canvas = dependency_1.iscsGraphicData.Canvas.deserialize(reader)); - break; - case 2: - reader.readMessage(message.cctvButtons, () => pb_1.Message.addToRepeatedWrapperField(message, 2, CCTVButton.deserialize(reader), CCTVButton)); - break; - case 3: - reader.readMessage(message.arrows, () => pb_1.Message.addToRepeatedWrapperField(message, 3, dependency_1.iscsGraphicData.Arrow.deserialize(reader), dependency_1.iscsGraphicData.Arrow)); - break; - case 4: - reader.readMessage(message.iscsTexts, () => pb_1.Message.addToRepeatedWrapperField(message, 4, dependency_1.iscsGraphicData.IscsText.deserialize(reader), dependency_1.iscsGraphicData.IscsText)); - break; - case 5: - reader.readMessage(message.rects, () => pb_1.Message.addToRepeatedWrapperField(message, 5, dependency_1.iscsGraphicData.Rect.deserialize(reader), dependency_1.iscsGraphicData.Rect)); - break; - default: reader.skipField(); - } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): CCTVGraphicStorage { - return CCTVGraphicStorage.deserialize(bytes); - } - } - export class CCTVButton extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | { - common?: dependency_1.iscsGraphicData.CommonInfo; - code?: string; - buttonType?: CCTVButton.ButtonType; - }) { - super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); - if (!Array.isArray(data) && typeof data == "object") { - if ("common" in data && data.common != undefined) { - this.common = data.common; - } - if ("code" in data && data.code != undefined) { - this.code = data.code; - } - if ("buttonType" in data && data.buttonType != undefined) { - this.buttonType = data.buttonType; - } - } - } - get common() { - return pb_1.Message.getWrapperField(this, dependency_1.iscsGraphicData.CommonInfo, 1) as dependency_1.iscsGraphicData.CommonInfo; - } - set common(value: dependency_1.iscsGraphicData.CommonInfo) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_common() { - return pb_1.Message.getField(this, 1) != null; - } - get code() { - return pb_1.Message.getFieldWithDefault(this, 2, "") as string; - } - set code(value: string) { - pb_1.Message.setField(this, 2, value); - } - get buttonType() { - return pb_1.Message.getFieldWithDefault(this, 3, CCTVButton.ButtonType.rect) as CCTVButton.ButtonType; - } - set buttonType(value: CCTVButton.ButtonType) { - pb_1.Message.setField(this, 3, value); - } - static fromObject(data: { - common?: ReturnType; - code?: string; - buttonType?: CCTVButton.ButtonType; - }): CCTVButton { - const message = new CCTVButton({}); - if (data.common != null) { - message.common = dependency_1.iscsGraphicData.CommonInfo.fromObject(data.common); - } - if (data.code != null) { - message.code = data.code; - } - if (data.buttonType != null) { - message.buttonType = data.buttonType; - } - return message; - } - toObject() { - const data: { - common?: ReturnType; - code?: string; - buttonType?: CCTVButton.ButtonType; - } = {}; - if (this.common != null) { - data.common = this.common.toObject(); - } - if (this.code != null) { - data.code = this.code; - } - if (this.buttonType != null) { - data.buttonType = this.buttonType; - } - return data; - } - serialize(): Uint8Array; - serialize(w: pb_1.BinaryWriter): void; - serialize(w?: pb_1.BinaryWriter): Uint8Array | void { - const writer = w || new pb_1.BinaryWriter(); - if (this.has_common) - writer.writeMessage(1, this.common, () => this.common.serialize(writer)); - if (this.code.length) - writer.writeString(2, this.code); - if (this.buttonType != CCTVButton.ButtonType.rect) - writer.writeEnum(3, this.buttonType); - if (!w) - return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): CCTVButton { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new CCTVButton(); - while (reader.nextField()) { - if (reader.isEndGroup()) - break; - switch (reader.getFieldNumber()) { - case 1: - reader.readMessage(message.common, () => message.common = dependency_1.iscsGraphicData.CommonInfo.deserialize(reader)); - break; - case 2: - message.code = reader.readString(); - break; - case 3: - message.buttonType = reader.readEnum(); - break; - default: reader.skipField(); - } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): CCTVButton { - return CCTVButton.deserialize(bytes); - } - } - export namespace CCTVButton { - export enum ButtonType { - rect = 0, - monitor = 1, - semicircle = 2 - } - } -} diff --git a/src/stores/draw-store.ts b/src/stores/draw-store.ts index a45bbf6..be8abcf 100644 --- a/src/stores/draw-store.ts +++ b/src/stores/draw-store.ts @@ -1,14 +1,9 @@ import { defineStore } from 'pinia'; import { - initCCTVDrawApp, - destroyCCTVDrawApp, - getCCTVDrawApp, -} from 'src/drawApp/cctvApp'; -import { - initFASDrawApp, - destroyFASDrawApp, - getFASDrawApp, -} from 'src/drawApp/fasApp'; + initIscsDrawApp, + destroyIscsDrawApp, + getIscsDrawApp, +} from 'src/drawApp/iscsApp'; import { DrawAssistant, GraphicData, @@ -31,16 +26,8 @@ export const useDrawStore = defineStore('draw', { drawGraphicType: (state) => state.drawAssistant?.type, drawGraphicName: (state) => state.drawAssistant?.description, drawGraphicTemplate: (state) => state.drawAssistant?.graphicTemplate, - getApp: (state) => { - let app = null; - switch (state.drawPictureType) { - case PictureType.CCTV: - app = getCCTVDrawApp(); - break; - case PictureType.FireAlarm: - app = getFASDrawApp(); - break; - } + getApp: () => { + const app = getIscsDrawApp(); return app; }, selectedGraphicType: (state) => { @@ -93,15 +80,7 @@ export const useDrawStore = defineStore('draw', { app.unbindFormData(form); }, initDrawApp() { - let app: IDrawApp | null = null; - switch (this.drawPictureType) { - case PictureType.CCTV: - app = initCCTVDrawApp(); - break; - case PictureType.FireAlarm: - app = initFASDrawApp(); - break; - } + const app = initIscsDrawApp(); if (app == null) { throw new Error('未初始化app'); } @@ -124,14 +103,7 @@ export const useDrawStore = defineStore('draw', { // console.log('绘制状态清空,绘制应用销毁'); this.drawAssistant = null; this.selectedGraphics = null; - switch (this.drawPictureType) { - case PictureType.CCTV: - destroyCCTVDrawApp(); - break; - case PictureType.FireAlarm: - destroyFASDrawApp(); - break; - } + destroyIscsDrawApp(); }, setDraftId(id: number | null) { this.draftId = id;