From 09d48e3e7a79771f87e700fb0ec6e17f939be8ad Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Fri, 20 Sep 2024 10:28:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/ApiCommon.ts | 2 +- src/api/DraftApi.ts | 41 ++++++++++++++++++++++++++----- src/drawApp/iscsApp.ts | 4 +++ src/pages/IscsDraftManage.vue | 46 ++++++++++++++++++++++++++++++----- 4 files changed, 80 insertions(+), 13 deletions(-) diff --git a/src/api/ApiCommon.ts b/src/api/ApiCommon.ts index a68a66a..965cbb4 100644 --- a/src/api/ApiCommon.ts +++ b/src/api/ApiCommon.ts @@ -26,7 +26,7 @@ export class OrderItemDto { } export interface PageDto { - data: T[]; + items: T[]; /** * 记录总数 */ diff --git a/src/api/DraftApi.ts b/src/api/DraftApi.ts index d53a0e2..3eb81b7 100644 --- a/src/api/DraftApi.ts +++ b/src/api/DraftApi.ts @@ -15,7 +15,7 @@ export interface DraftItem { id: number; name: string; dataType: DraftDataType; - options: { style: IscsStyle }; + options: string; data: string; userId: number; isShared: boolean; @@ -35,15 +35,24 @@ interface PagingQueryParams { isShared?: boolean; }; } +export interface DraftIscsDataDto { + draftData: DraftItem; + options: IscsDataOptions; +} + +export interface IscsDataOptions { + style: IscsStyle; +} export async function draftPageQuery( params: PagingQueryParams -): Promise> { +): Promise> { const query = ` query userDraftIscsDataPaging($paging: PageQueryDto, $query: UserDraftIscsDataFilterDto) { userDraftIscsDataPaging(paging: $paging, query: $query) { total - data { - id name dataType createdAt updatedAt isShared options {style} + items { + draftData {id name dataType createdAt updatedAt isShared } + options {style} } } } @@ -67,7 +76,7 @@ export enum IscsStyle { interface CreateDraftIscsDto { input: { name: string; - options: { style: IscsStyle }; + options: IscsDataOptions; userId: number; }; } @@ -75,7 +84,7 @@ export function createDraft(params: CreateDraftIscsDto) { const mutation = ` mutation createDraftIscsData($input: CreateDraftIscsDto) { createDraftIscsData(input: $input) { - name + draftData {name} } } `; @@ -104,6 +113,26 @@ export function deleteDraft(id: number) { }); } +/** + * 共享草稿 + * @param id 草稿id + */ +export function sharedDraft(id: number, isShared: boolean) { + const mutation = ` + mutation updateDraftDataShared($id: Int,$isShared: Boolean) { + updateDraftDataShared(id: $id,isShared: $isShared){id} + } +`; + const variables = { + id, + isShared, + }; + return api.post('', { + query: mutation, + variables, + }); +} + /** * 获取草稿数据 * @param params diff --git a/src/drawApp/iscsApp.ts b/src/drawApp/iscsApp.ts index 6b8d289..b7550ad 100644 --- a/src/drawApp/iscsApp.ts +++ b/src/drawApp/iscsApp.ts @@ -75,6 +75,10 @@ export async function loadDrawDatas(): Promise { storage.cctvButtons.forEach((cctvButton) => { datas.push(new CCTVButtonData(cctvButton)); }); + return { + canvasProperty: storage.canvas, + datas: datas, + }; } else { return Promise.resolve({ datas: [], diff --git a/src/pages/IscsDraftManage.vue b/src/pages/IscsDraftManage.vue index a02c3f7..ce1b75e 100644 --- a/src/pages/IscsDraftManage.vue +++ b/src/pages/IscsDraftManage.vue @@ -40,6 +40,13 @@ label="发布" @click="prePublish(props.row)" /> + { return props.sizeHeight - 32; }); - onMounted(() => { tableRef.value.requestServerInteraction(); }); @@ -206,6 +214,7 @@ const pagination = ref({ }); // eslint-disable-next-line +let allRequestData: DraftIscsDataDto[] = []; async function onRequest(props: any) { const { page, rowsPerPage } = props.pagination; const filter = props.filter; @@ -219,10 +228,16 @@ async function onRequest(props: any) { query: { userId: 1, dataType: DraftDataType.ISCS, name: filter.name }, }; try { - let response = await draftPageQuery(variables); - const pageData = response; - pagination.value.rowsNumber = pageData.total; - rows.splice(0, rows.length, ...(pageData.data as [])); + const response = await draftPageQuery(variables); + pagination.value.rowsNumber = response.total; + pagination.value.page = page; + pagination.value.rowsPerPage = rowsPerPage; + rows.splice( + 0, + rows.length, + ...(response.items.map((item) => item.draftData) as []) + ); + allRequestData = response.items; } catch (err) { const error = err as ApiError; $q.notify({ @@ -260,6 +275,8 @@ function onCreate() { }; await createDraft(variables); createFormShow.value = false; + createForm.draftName = ''; + createForm.style = IscsStyle.DA_SHI_ZHI_NENG; tableRef.value.requestServerInteraction(); // 刷新列表 } catch (err) { const error = err as ApiError; @@ -313,8 +330,25 @@ async function deleteData(row: DraftItem) { }); } +async function sharedDraftData(row: DraftItem) { + operateDisabled.value = true; + try { + await sharedDraft(row.id, !row.isShared); + operateDisabled.value = false; + tableRef.value.requestServerInteraction(); // 刷新列表 + } catch (err) { + const error = err as ApiError; + $q.notify({ + type: 'negative', + message: error.title, + }); + } +} + function goToPath(row: DraftItem) { let path = `/iscsPainting/${row.id}`; - router.push({ path: path, query: { iscsStyle: row.options.style } }); + const iscsStyle = allRequestData.find((item) => item.draftData.id == row.id) + .options.style; + router.push({ path: path, query: { iscsStyle } }); }