diff --git a/src/api/DraftApi.ts b/src/api/DraftApi.ts index 6a12e20..1563f95 100644 --- a/src/api/DraftApi.ts +++ b/src/api/DraftApi.ts @@ -23,14 +23,14 @@ export interface DraftItem { defaultReleaseDataName: string; } -interface PagingQueryParams { +export interface PagingQueryParams { paging: { page: number; itemsPerPage: number; }; query: { - userId: number; dataType: DraftDataType; + userId?: number; name?: string; isShared?: boolean; }; @@ -64,6 +64,27 @@ export async function draftPageQuery( return response.data.data.userDraftIscsDataPaging; } +export async function sharedDraftPageQuery( + params: PagingQueryParams +): Promise> { + const query = ` + query sharedDraftIscsDataPaging($paging: PageQueryDto, $query: SharedDraftIscsDataFilterDto) { + sharedDraftIscsDataPaging(paging: $paging, query: $query) { + total + items { + draftData {id name dataType userId defaultReleaseDataId createdAt updatedAt isShared defaultReleaseDataName} + options {style} + } + } + } +`; + const response = await api.post('', { + query, + variables: params, + }); + return response.data.data.sharedDraftIscsDataPaging; +} + /** * 创建草稿 * @param params diff --git a/src/api/PublishApi.ts b/src/api/PublishApi.ts index 03b7410..d1acc32 100644 --- a/src/api/PublishApi.ts +++ b/src/api/PublishApi.ts @@ -2,8 +2,6 @@ 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; @@ -24,8 +22,8 @@ interface PagingQueryParams { itemsPerPage: number; }; query: { - userId: number; dataType: DraftDataType; + userId?: number; name?: string; isPublished?: boolean; }; @@ -35,6 +33,25 @@ export interface PublishIscsDataDto { options: IscsDataOptions; } +/** + * 回退发布版本 + * @param id 发布地图ID + */ +export function setDefaultPublish(variables: { + id: number; + releaseDataId: number; +}) { + const mutation = ` + mutation setDefaultReleaseDataId($id: Int,$releaseDataId: Int) { + setDefaultReleaseDataId(id: $id,releaseDataId: $releaseDataId){id} + } +`; + return api.post('', { + query: mutation, + variables, + }); +} + /** * 草稿图发布 * @param draftId 草稿id @@ -106,54 +123,6 @@ export async function publishPageQuery( 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 @@ -209,8 +178,16 @@ export async function getPublishHistoryById(variables: { * 回退发布版本 * @param id 发布地图ID */ -export function fallbackVersion(data: { mapId: number; versionId: number }) { - return api.post(`${PublishUriBase}/fallbackVersion`, data); +export function fallbackVersion(variables: { id: number; versionId: number }) { + const mutation = ` + mutation updateReleaseDataUsedVersion($id: Int,$versionId: Int) { + updateReleaseDataUsedVersion(id: $id,versionId: $versionId){id} + } +`; + return api.post('', { + query: mutation, + variables, + }); } /** diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index e542d8c..be76d5b 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -52,7 +52,11 @@ - + diff --git a/src/pages/IscsDraftManage.vue b/src/pages/IscsDraftManage.vue index ba6b88a..077d631 100644 --- a/src/pages/IscsDraftManage.vue +++ b/src/pages/IscsDraftManage.vue @@ -22,7 +22,12 @@ label="名称" > - + diff --git a/src/pages/IscsPublishManage.vue b/src/pages/IscsPublishManage.vue index 6d4d647..6c28670 100644 --- a/src/pages/IscsPublishManage.vue +++ b/src/pages/IscsPublishManage.vue @@ -61,7 +61,7 @@ @@ -115,7 +109,7 @@
{ - try { - await deletePublish(row.id); - tableRef.value.requestServerInteraction(); // 刷新列表 - } catch (err) { - const error = err as ApiError; - $q.notify({ - type: 'negative', - message: error.title, - }); - } - }) - .onDismiss(() => { - operateDisabled.value = false; +//上下架 +function dataReleaseFn(row: PublishItem) { + if (row.isPublished) { + $q.dialog({ + title: '确认', + message: `确定下架发布数据【${row.name}】吗?`, + cancel: true, + }).onOk(() => { + setPublishRelease({ id: row.id, isPublished: !row.isPublished }).then( + (res) => { + if (res.data?.errors && res.data?.errors.length) { + $q.notify({ + type: 'negative', + message: res.data.errors[0].message, + }); + } else { + tableRef.value.requestServerInteraction(); + } + } + ); }); + } else { + setPublishRelease({ id: row.id, isPublished: !row.isPublished }).then( + (res) => { + if (res.data?.errors && res.data?.errors.length) { + $q.notify({ + type: 'negative', + message: res.data.errors[0].message, + }); + } else { + tableRef.value.requestServerInteraction(); + } + } + ); + } } +//另存草稿 function saveToDraftFn(row: PublishItem) { saveToDraft({ versionId: row.usedVersionId, userId: row.userId, - }) - .then((res) => { + }).then((res) => { + if (res.data?.errors && res.data?.errors.length) { + $q.notify({ + type: 'negative', + message: res.data.errors[0].message, + }); + } else { const draftName = res.data.data.createDraftDataFromReleaseDataVersion.name; $q.notify({ type: 'positive', message: `另存草稿成功且草稿图名字为${draftName}`, }); - }) - .catch((err) => { - const error = err as ApiError; - $q.notify({ - type: 'negative', - message: error.title, - }); - }); + } + }); } +// 项目管理相关 +const emit = defineEmits(['selectsed']); +const selected = ref([]); +watch( + () => selected.value, + (val) => { + if (val != props.selects) { + emit('selectsed', val); + } + } +); const isProject = computed(() => { - // 项目管理 return route.path.includes('dataManage/project'); }); -const selected = ref([]); function getSelectedString() { const nameArr = selected.value.map((item) => { return item.name; @@ -325,16 +339,7 @@ if (isProject.value) { } } -const emit = defineEmits(['selectsed']); -watch( - () => selected.value, - (val) => { - if (val != props.selects) { - emit('selectsed', val); - } - } -); - +//修改发布图名字 const errorCalories = ref(false); const errorMessageCalories = ref(''); function caloriesRangeValidation(val?: string) { @@ -351,22 +356,22 @@ function caloriesRangeValidation(val?: string) { } async function saveRowDataName(row: PublishItem) { - try { - const params = { - id: row.id, - name: row.name, - }; - await setPublishRename(params); - } catch (err) { - const error = err as ApiError; + const params = { + id: row.id, + name: row.name, + }; + const res = await setPublishRename(params); + if (res.data?.errors && res.data?.errors.length) { $q.notify({ type: 'negative', - message: error.title, + message: res.data.errors[0].message, }); + } else { tableRef.value.requestServerInteraction(); } } +//发布历史相关 const historyInfoShow = ref(false); const historyInfo = ref({ id: 0, @@ -393,13 +398,7 @@ const historyColumnDefs: QTableColumn[] = [ { name: 'createdAt', label: '发布时间', - field: 'createdAt', - align: 'center', - }, - { - name: 'releaseDataId', - label: '版本', - field: 'releaseDataId', + field: (row) => new Date(row.createdAt).toLocaleString(), align: 'center', }, { @@ -433,7 +432,6 @@ async function historyOnRequest(props: any) { itemsPerPage: rowsPerPage, }, }; - console.log(page, rowsPerPage); try { const response = await getPublishHistoryById(variables); @@ -452,7 +450,9 @@ async function historyOnRequest(props: any) { } } +const currentUsedVersionId = ref(); function showHistoryFn(row: PublishItem) { + currentUsedVersionId.value = row.usedVersionId; historyInfo.value = row; historyInfoShow.value = true; nextTick(() => { @@ -460,63 +460,30 @@ function showHistoryFn(row: PublishItem) { }); } -function dataReleaseFn(row: PublishItem) { - if (row.isPublished) { - $q.dialog({ - title: '确认', - message: `确定下架发布数据【${row.name}】吗?`, - cancel: true, - }).onOk(() => { - setPublishRelease({ id: row.id, isPublished: !row.isPublished }) - .then(() => { - tableRef.value.requestServerInteraction(); - }) - .catch((err) => { - const error = err as ApiError; - $q.notify({ - type: 'negative', - message: error.title, - }); - }); - }); - } else { - setPublishRelease({ id: row.id, isPublished: !row.isPublished }) - .then(() => { - tableRef.value.requestServerInteraction(); - }) - .catch((err) => { - const error = err as ApiError; - $q.notify({ - type: 'negative', - message: error.title, - }); - }); - } -} - function backVersion(row: PublishHistoryItem) { if (!historyInfo.value.id || !row.id) return; $q.dialog({ title: '确认', - message: `确定把【${historyInfo.value.name}】回退到【${row.releaseDataId}】版本吗?`, + message: `确定把【${historyInfo.value.name}】回退到【${row.description}】版本吗?`, cancel: true, }).onOk(() => { - fallbackVersion({ mapId: historyInfo.value.id, versionId: row.id }) - .then(() => { - $q.notify({ - type: 'positive', - message: '回退版本成功!', - }); - tableRef.value.requestServerInteraction(); - historyInfoShow.value = false; - }) - .catch((err) => { - const error = err as ApiError; - $q.notify({ - type: 'negative', - message: error.title, - }); - }); + fallbackVersion({ id: historyInfo.value.id, versionId: row.id }).then( + (res) => { + if (res.data?.errors && res.data?.errors.length) { + $q.notify({ + type: 'negative', + message: res.data.errors[0].message, + }); + } else { + $q.notify({ + type: 'positive', + message: '回退版本成功!', + }); + tableRef.value.requestServerInteraction(); + historyInfoShow.value = false; + } + } + ); }); } diff --git a/src/router/routes.ts b/src/router/routes.ts index 237944b..9bc861d 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -35,6 +35,15 @@ const routes: RouteRecordRaw[] = [ icon: 'app_registration', }, }, + { + path: 'iscsSharedDraft', + name: 'iscsSharedDraft', + component: () => import('pages/IscsDraftManage.vue'), + meta: { + label: 'iscs分享草稿管理', + icon: 'app_registration', + }, + }, { path: 'iscsPublish', name: 'iscsPublish',