接口调整

This commit is contained in:
joylink_zhaoerwei 2024-09-20 10:28:48 +08:00
parent 3387d4536e
commit 09d48e3e7a
4 changed files with 80 additions and 13 deletions

View File

@ -26,7 +26,7 @@ export class OrderItemDto {
} }
export interface PageDto<T = unknown> { export interface PageDto<T = unknown> {
data: T[]; items: T[];
/** /**
* *
*/ */

View File

@ -15,7 +15,7 @@ export interface DraftItem {
id: number; id: number;
name: string; name: string;
dataType: DraftDataType; dataType: DraftDataType;
options: { style: IscsStyle }; options: string;
data: string; data: string;
userId: number; userId: number;
isShared: boolean; isShared: boolean;
@ -35,15 +35,24 @@ interface PagingQueryParams {
isShared?: boolean; isShared?: boolean;
}; };
} }
export interface DraftIscsDataDto {
draftData: DraftItem;
options: IscsDataOptions;
}
export interface IscsDataOptions {
style: IscsStyle;
}
export async function draftPageQuery( export async function draftPageQuery(
params: PagingQueryParams params: PagingQueryParams
): Promise<PageDto<DraftItem>> { ): Promise<PageDto<DraftIscsDataDto>> {
const query = ` const query = `
query userDraftIscsDataPaging($paging: PageQueryDto, $query: UserDraftIscsDataFilterDto) { query userDraftIscsDataPaging($paging: PageQueryDto, $query: UserDraftIscsDataFilterDto) {
userDraftIscsDataPaging(paging: $paging, query: $query) { userDraftIscsDataPaging(paging: $paging, query: $query) {
total total
data { items {
id name dataType createdAt updatedAt isShared options {style} draftData {id name dataType createdAt updatedAt isShared }
options {style}
} }
} }
} }
@ -67,7 +76,7 @@ export enum IscsStyle {
interface CreateDraftIscsDto { interface CreateDraftIscsDto {
input: { input: {
name: string; name: string;
options: { style: IscsStyle }; options: IscsDataOptions;
userId: number; userId: number;
}; };
} }
@ -75,7 +84,7 @@ export function createDraft(params: CreateDraftIscsDto) {
const mutation = ` const mutation = `
mutation createDraftIscsData($input: CreateDraftIscsDto) { mutation createDraftIscsData($input: CreateDraftIscsDto) {
createDraftIscsData(input: $input) { 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 * @param params

View File

@ -75,6 +75,10 @@ export async function loadDrawDatas(): Promise<IGraphicStorage> {
storage.cctvButtons.forEach((cctvButton) => { storage.cctvButtons.forEach((cctvButton) => {
datas.push(new CCTVButtonData(cctvButton)); datas.push(new CCTVButtonData(cctvButton));
}); });
return {
canvasProperty: storage.canvas,
datas: datas,
};
} else { } else {
return Promise.resolve({ return Promise.resolve({
datas: [], datas: [],

View File

@ -40,6 +40,13 @@
label="发布" label="发布"
@click="prePublish(props.row)" @click="prePublish(props.row)"
/> />
<q-btn
color="info"
style="width: 80px"
:disable="operateDisabled"
:label="props.row.isShared ? '取消共享' : '共享'"
@click="sharedDraftData(props.row)"
/>
<q-btn <q-btn
color="red" color="red"
:disable="operateDisabled" :disable="operateDisabled"
@ -136,7 +143,9 @@ import {
DraftDataType, DraftDataType,
DraftItem, DraftItem,
draftPageQuery, draftPageQuery,
DraftIscsDataDto,
IscsStyle, IscsStyle,
sharedDraft,
} from '../api/DraftApi'; } from '../api/DraftApi';
import { ApiError } from 'src/boot/axios'; import { ApiError } from 'src/boot/axios';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
@ -154,7 +163,6 @@ const tableHeight = computed(() => {
return props.sizeHeight - 32; return props.sizeHeight - 32;
}); });
onMounted(() => { onMounted(() => {
tableRef.value.requestServerInteraction(); tableRef.value.requestServerInteraction();
}); });
@ -206,6 +214,7 @@ const pagination = ref({
}); });
// eslint-disable-next-line // eslint-disable-next-line
let allRequestData: DraftIscsDataDto[] = [];
async function onRequest(props: any) { async function onRequest(props: any) {
const { page, rowsPerPage } = props.pagination; const { page, rowsPerPage } = props.pagination;
const filter = props.filter; const filter = props.filter;
@ -219,10 +228,16 @@ async function onRequest(props: any) {
query: { userId: 1, dataType: DraftDataType.ISCS, name: filter.name }, query: { userId: 1, dataType: DraftDataType.ISCS, name: filter.name },
}; };
try { try {
let response = await draftPageQuery(variables); const response = await draftPageQuery(variables);
const pageData = response; pagination.value.rowsNumber = response.total;
pagination.value.rowsNumber = pageData.total; pagination.value.page = page;
rows.splice(0, rows.length, ...(pageData.data as [])); pagination.value.rowsPerPage = rowsPerPage;
rows.splice(
0,
rows.length,
...(response.items.map((item) => item.draftData) as [])
);
allRequestData = response.items;
} catch (err) { } catch (err) {
const error = err as ApiError; const error = err as ApiError;
$q.notify({ $q.notify({
@ -260,6 +275,8 @@ function onCreate() {
}; };
await createDraft(variables); await createDraft(variables);
createFormShow.value = false; createFormShow.value = false;
createForm.draftName = '';
createForm.style = IscsStyle.DA_SHI_ZHI_NENG;
tableRef.value.requestServerInteraction(); // tableRef.value.requestServerInteraction(); //
} catch (err) { } catch (err) {
const error = err as ApiError; 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) { function goToPath(row: DraftItem) {
let path = `/iscsPainting/${row.id}`; 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 } });
} }
</script> </script>