api调整

This commit is contained in:
joylink_zhaoerwei 2024-09-19 09:37:56 +08:00
parent f9ee903d60
commit 2d73321e06
2 changed files with 54 additions and 18 deletions

View File

@ -38,8 +38,8 @@ export async function draftPageQuery(
params: PagingQueryParams params: PagingQueryParams
): Promise<PageDto<DraftItem>> { ): Promise<PageDto<DraftItem>> {
const query = ` const query = `
query userDraftDataPaging($paging: PageQueryDto, $query: UserDraftDataFilterDto) { query userDraftIscsDataPaging($paging: PageQueryDto, $query: UserDraftIscsDataFilterDto) {
userDraftDataPaging(paging: $paging, query: $query) { userDraftIscsDataPaging(paging: $paging, query: $query) {
total total
data { data {
id name dataType createdAt updatedAt isShared id name dataType createdAt updatedAt isShared
@ -51,7 +51,7 @@ export async function draftPageQuery(
query, query,
variables: params, variables: params,
}); });
return response.data.data.userDraftDataPaging; return response.data.data.userDraftIscsDataPaging;
} }
/** /**
@ -59,25 +59,28 @@ export async function draftPageQuery(
* @param params * @param params
* @returns * @returns
*/ */
export function createDraft(name: string) { export enum IscsStyle {
UNKNOWN,
DA_SHI_ZHI_NENG = 'DA_SHI_ZHI_NENG',
}
interface CreateDraftIscsDto {
input: {
name: string;
options: { style: IscsStyle };
userId: number;
};
}
export function createDraft(params: CreateDraftIscsDto) {
const mutation = ` const mutation = `
mutation createDraftData($input: CreateDraftDataDto) { mutation createDraftIscsData($input: CreateDraftIscsDto) {
createDraftData(input: $input) { createDraftIscsData(input: $input) {
name name
} }
} }
`; `;
const variables = {
input: {
name,
dataType: DraftDataType.ISCS,
data: [],
userId: 1,
},
};
return api.post(``, { return api.post(``, {
query: mutation, query: mutation,
variables, variables: params,
}); });
} }

View File

@ -64,10 +64,18 @@
<q-input <q-input
outlined outlined
label="名称 * " label="名称 * "
v-model="draftName" v-model="createForm.draftName"
lazy-rules lazy-rules
:rules="[(val) => val.length > 0 || '请输入名称!']" :rules="[(val) => val.length > 0 || '请输入名称!']"
/> />
<q-select
v-model="createForm.style"
:options="iscsStyleOption"
emit-value
map-options
label="ISCS类型"
lazy-rules
/>
<q-card-actions align="right"> <q-card-actions align="right">
<q-btn color="primary" label="创建" type="submit" /> <q-btn color="primary" label="创建" type="submit" />
<q-btn label="取消" v-close-popup /> <q-btn label="取消" v-close-popup />
@ -128,6 +136,7 @@ import {
DraftDataType, DraftDataType,
DraftItem, DraftItem,
draftPageQuery, draftPageQuery,
IscsStyle,
} from '../api/DraftApi'; } from '../api/DraftApi';
import { ApiError } from 'src/boot/axios'; import { ApiError } from 'src/boot/axios';
@ -168,6 +177,14 @@ const columnDefs: QTableColumn[] = [
field: (row) => new Date(row.updatedAt).toLocaleString(), field: (row) => new Date(row.updatedAt).toLocaleString(),
align: 'center', align: 'center',
}, },
{
name: 'isShared',
label: '是否共享',
field: (row) => {
return row.isShared ? '是' : '否';
},
align: 'center',
},
{ name: 'operations', label: '操作', field: 'operations', align: 'center' }, { name: 'operations', label: '操作', field: 'operations', align: 'center' },
]; ];
@ -216,14 +233,30 @@ async function onRequest(props: any) {
} }
const createFormShow = ref(false); const createFormShow = ref(false);
const draftName = ref(''); const createForm = reactive({
draftName: '',
style: IscsStyle.DA_SHI_ZHI_NENG,
});
const iscsStyleOption = [
{
label: '达实智能',
value: IscsStyle.DA_SHI_ZHI_NENG,
},
];
const myForm = ref<QForm | null>(null); const myForm = ref<QForm | null>(null);
function onCreate() { function onCreate() {
myForm.value?.validate().then(async (res) => { myForm.value?.validate().then(async (res) => {
if (res) { if (res) {
operateDisabled.value = true; operateDisabled.value = true;
try { try {
await createDraft(draftName.value); const variables = {
input: {
name: createForm.draftName,
options: { style: createForm.style },
userId: 1,
},
};
await createDraft(variables);
createFormShow.value = false; createFormShow.value = false;
tableRef.value.requestServerInteraction(); // tableRef.value.requestServerInteraction(); //
} catch (err) { } catch (err) {