From 469222e46fef4555d43b508b2bb4db3cfd10537f Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Fri, 20 Sep 2024 18:08:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=A4=87=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/DraftApi.ts | 56 ++-- src/api/PublishApi.ts | 251 +++++++++++++++ src/layouts/IscsDrawLayout.vue | 23 +- src/pages/IscsDraftManage.vue | 190 +++++++++++- src/pages/IscsPublishManage.vue | 522 ++++++++++++++++++++++++++++++++ src/router/routes.ts | 2 +- src/stores/auth-store.ts | 12 + 7 files changed, 1024 insertions(+), 32 deletions(-) create mode 100644 src/api/PublishApi.ts create mode 100644 src/pages/IscsPublishManage.vue create mode 100644 src/stores/auth-store.ts diff --git a/src/api/DraftApi.ts b/src/api/DraftApi.ts index 3eb81b7..6a12e20 100644 --- a/src/api/DraftApi.ts +++ b/src/api/DraftApi.ts @@ -1,8 +1,6 @@ import { api } from 'src/boot/axios'; import { PageDto } from './ApiCommon'; -const DraftUriBase = ''; - export enum DraftDataType { UNKNOWN, EM = 'EM', @@ -18,9 +16,11 @@ export interface DraftItem { options: string; data: string; userId: number; + defaultReleaseDataId: number; isShared: boolean; createdAt: string; updatedAt: string; + defaultReleaseDataName: string; } interface PagingQueryParams { @@ -51,7 +51,7 @@ export async function draftPageQuery( userDraftIscsDataPaging(paging: $paging, query: $query) { total items { - draftData {id name dataType createdAt updatedAt isShared } + draftData {id name dataType userId defaultReleaseDataId createdAt updatedAt isShared defaultReleaseDataName} options {style} } } @@ -161,7 +161,7 @@ export async function getDraft(id: number): Promise { * @param data * @returns */ -export function saveDraft(data: { id: number; data: string }) { +export function saveDraft(variables: { id: number; data: string }) { const mutation = ` mutation updateDraftDataData($id: Int,$data: String) { updateDraftDataData(id: $id,data: $data){ @@ -169,26 +169,48 @@ export function saveDraft(data: { id: number; data: string }) { } } `; - const variables = { - id: 1, - data: data.data, - }; - console.log(data); return api.post('', { query: mutation, - variables: variables, + variables, }); } /** * 另存草稿数据 - * @param data + * @param variables * @returns */ -export async function saveAsDraft( - id: number, - data: { name: string; proto: string } -): Promise { - const response = await api.post(`${DraftUriBase}/${id}/saveAs`, data); - return response.data; +export async function saveAsDraft(variables: { + id: number; + name: string; + userId: number; +}): Promise { + const mutation = ` + mutation saveAsNewDraftData($id: Int,$name: String,$userId: Int) { + saveAsNewDraftData(id: $id,name: $name,userId: $userId){ + id + } + } +`; + return api.post('', { + query: mutation, + variables, + }); +} + +/** + * 修改草稿数据名称 + * @param id 发布id + * @param name 名称 + */ +export function setDraftRename(variables: { id: number; name: string }) { + const mutation = ` + mutation updateDraftDataName($id: Int,$name: String) { + updateDraftDataName(id: $id,name: $name){id} + } +`; + return api.post('', { + query: mutation, + variables, + }); } diff --git a/src/api/PublishApi.ts b/src/api/PublishApi.ts new file mode 100644 index 0000000..03b7410 --- /dev/null +++ b/src/api/PublishApi.ts @@ -0,0 +1,251 @@ +import { api } from 'src/boot/axios'; +import { PageDto } from './ApiCommon'; +import { DraftDataType, IscsDataOptions } from './DraftApi'; + +const PublishUriBase = '/api/v1/publishedGi'; + +export interface PublishItem { + id: number; + name: string; + dataType: DraftDataType; + options: string; + data: string; + usedVersionId: number; + userId: number; + isPublished: boolean; + createdAt: string; + updatedAt: string; + description: string; +} + +interface PagingQueryParams { + page: { + page: number; + itemsPerPage: number; + }; + query: { + userId: number; + dataType: DraftDataType; + name?: string; + isPublished?: boolean; + }; +} +export interface PublishIscsDataDto { + releaseData: PublishItem; + options: IscsDataOptions; +} + +/** + * 草稿图发布 + * @param draftId 草稿id + * @param note 备注 + */ +export function publishDraft(params: { + draftId: number; + name: string; + description: string; +}) { + const mutation = ` + mutation releaseNewFromDraft($draftId: Int,$name: String,$description: String) { + releaseNewFromDraft(draftId: $draftId,name: $name,description: $description) { + releaseData {id} + } + } +`; + return api.post('', { + query: mutation, + variables: params, + }); +} + +/** + * 草稿图发布到默认 + * @param draftId 草稿id + * @param description 备注 + */ +export function publishDraftToDefault(params: { + draftId: number; + description: string; +}) { + const mutation = ` + mutation releaseToDefaultReleaseData($draftId: Int,$description: String) { + releaseToDefaultReleaseData(draftId: $draftId,description: $description) { + releaseData {id} + } + } +`; + return api.post('', { + query: mutation, + variables: params, + }); +} + +/** + * 分页查询 + * @param params + * @returns + */ +export async function publishPageQuery( + params: PagingQueryParams +): Promise> { + const query = ` + query releaseIscsDataPaging($page: PageQueryDto, $query: UserDraftIscsDataFilterDto) { + releaseIscsDataPaging(page: $page, query: $query) { + total + items { + releaseData {id name dataType usedVersionId userId isPublished createdAt updatedAt description } + options {style} + } + } + } +`; + const response = await api.post('', { + query, + variables: params, + }); + return response.data.data.releaseIscsDataPaging; +} + +/** + * 删除发布图 + * @param id 发布id + */ +export function deletePublish(id: number) { + return api.delete(`${PublishUriBase}/${id}`); +} +/** + * 获取发布地图详细信息 + * @param id 发布地图id + */ +export async function getPublishMapInfoById(id: number): Promise { + const response = await api.get(`${PublishUriBase}/${id}`); + return response.data; +} +/** + * 获取发布地图详细信息 + * @param name 发布地图名称 + */ +export async function getPublishMapInfoByName(params: { + name: string; + detail: boolean; +}): Promise { + const response = await api.get(`${PublishUriBase}/name`, { + params: params, + }); + return response.data; +} + +/** + * 获取已发布的线路地图数据 + */ +export async function getPublishLineNet(): Promise { + const response = await api.get(`${PublishUriBase}/publish/lineNetwork/info`); + return response.data; +} + +/** + * 获取发布地图详细信息 + * @param id 发布地图线路ID + */ +export async function getPublishMapInfoByLineId( + lineId: string +): Promise { + const response = await api.get(`${PublishUriBase}/${lineId}`); + return response.data; +} + +/** + * 另存到草稿 + * @param id 发布id + */ +export function saveToDraft(variables: { versionId: number; userId: number }) { + const mutation = ` + mutation createDraftDataFromReleaseDataVersion($versionId: Int,$userId: Int) { + createDraftDataFromReleaseDataVersion(versionId: $versionId,userId: $userId){name} + } +`; + return api.post('', { + query: mutation, + variables, + }); +} + +export interface PublishHistoryItem { + id: number; + releaseDataId: number; + options: string; + description: string; + data: string; + userId: number; + createdAt: string; +} + +/** + * 获取地图发布历史信息 + * @param id 发布地图ID + */ +export async function getPublishHistoryById(variables: { + dataId: number; + page: { page: number; itemsPerPage: number }; +}): Promise> { + const query = ` + query releaseDataVersionPaging($dataId: Int, $page: PageQueryDto) { + releaseDataVersionPaging(dataId: $dataId, page: $page) { + total + items { + id releaseDataId description userId createdAt + } + } + } +`; + const response = await api.post('', { + query, + variables, + }); + return response.data.data.releaseDataVersionPaging; +} + +/** + * 回退发布版本 + * @param id 发布地图ID + */ +export function fallbackVersion(data: { mapId: number; versionId: number }) { + return api.post(`${PublishUriBase}/fallbackVersion`, data); +} + +/** + * 上下架发布数据 + * @param id 发布id + * @param release 上、下架 + */ +export function setPublishRelease(variables: { + id: number; + isPublished: boolean; +}) { + const mutation = ` + mutation updateReleaseDataPublished($id: Int,$isPublished: Boolean) { + updateReleaseDataPublished(id: $id,isPublished: $isPublished){id} + } +`; + return api.post('', { + query: mutation, + variables, + }); +} + +/** + * 修改发布数据名称 + * @param id 发布id + * @param name 名称 + */ +export function setPublishRename(variables: { id: number; name: string }) { + const mutation = ` + mutation updateReleaseDataName($id: Int,$name: String) { + updateReleaseDataName(id: $id,name: $name){id} + } +`; + return api.post('', { + query: mutation, + variables, + }); +} diff --git a/src/layouts/IscsDrawLayout.vue b/src/layouts/IscsDrawLayout.vue index 75cfd43..2b7857b 100644 --- a/src/layouts/IscsDrawLayout.vue +++ b/src/layouts/IscsDrawLayout.vue @@ -134,7 +134,6 @@ import DrawProperties from 'src/components/draw-app/IscsDrawProperties.vue'; import { onMounted, reactive, ref, watch } from 'vue'; import { useRoute, useRouter } from 'vue-router'; -import { successNotify } from 'src/utils/CommonNotify'; import { useQuasar } from 'quasar'; import { useDrawStore } from 'src/stores/draw-store'; import { CCTVButton } from 'src/graphics/CCTV/cctvButton/CCTVButton'; @@ -142,8 +141,11 @@ import { Arrow } from 'src/graphics/arrow/Arrow'; import { TextContent } from 'src/graphics/textContent/TextContent'; import { Rect } from 'src/graphics/rect/Rect'; import { getIscsStyleConfig } from 'src/configs/iscsStyleConfig'; -import { IscsStyle } from 'src/api/DraftApi'; +import { IscsStyle, saveAsDraft } from 'src/api/DraftApi'; import DraggableDialog from 'src/components/common/DraggableDialog.vue'; +import { ApiError } from 'src/boot/axios'; +import { useAuthStore } from 'src/stores/auth-store'; +import { successNotify } from 'src/utils/CommonNotify'; const $q = useQuasar(); const route = useRoute(); @@ -151,6 +153,7 @@ const router = useRouter(); const searchId = ref(0); const drawStore = useDrawStore(); +const authStore = useAuthStore(); const showDrawTool = ref(true); watch( () => drawStore.drawMode, @@ -290,7 +293,21 @@ const saveAsDialog = ref(false); const saveAsName = ref(''); async function saveAs(name: string) { - successNotify('另存为成功' + name); + try { + await saveAsDraft({ + id: +route.params.id as number, + name, + userId: authStore.userId, + }); + successNotify('另存为草稿成功'); + saveAsDialog.value = false; + } catch (err) { + const error = err as ApiError; + $q.notify({ + type: 'negative', + message: error.title, + }); + } } function onTopMenuClick() { diff --git a/src/pages/IscsDraftManage.vue b/src/pages/IscsDraftManage.vue index ce1b75e..ba6b88a 100644 --- a/src/pages/IscsDraftManage.vue +++ b/src/pages/IscsDraftManage.vue @@ -24,6 +24,38 @@ + + +