接口调整
This commit is contained in:
parent
3387d4536e
commit
09d48e3e7a
|
@ -26,7 +26,7 @@ export class OrderItemDto {
|
|||
}
|
||||
|
||||
export interface PageDto<T = unknown> {
|
||||
data: T[];
|
||||
items: T[];
|
||||
/**
|
||||
* 记录总数
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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: [],
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue