接口调整

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> {
data: T[];
items: T[];
/**
*
*/

View File

@ -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<PageDto<DraftItem>> {
): Promise<PageDto<DraftIscsDataDto>> {
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

View File

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

View File

@ -40,6 +40,13 @@
label="发布"
@click="prePublish(props.row)"
/>
<q-btn
color="info"
style="width: 80px"
:disable="operateDisabled"
:label="props.row.isShared ? '取消共享' : '共享'"
@click="sharedDraftData(props.row)"
/>
<q-btn
color="red"
:disable="operateDisabled"
@ -136,7 +143,9 @@ import {
DraftDataType,
DraftItem,
draftPageQuery,
DraftIscsDataDto,
IscsStyle,
sharedDraft,
} from '../api/DraftApi';
import { ApiError } from 'src/boot/axios';
import { useRouter } from 'vue-router';
@ -154,7 +163,6 @@ const tableHeight = computed(() => {
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 } });
}
</script>