校验name
This commit is contained in:
parent
5c2bca34ee
commit
c81a7db6cd
@ -106,6 +106,25 @@ export async function sharedDraftPageQuery(
|
||||
return response.data.data.sharedDraftIscsDataPaging;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查新建的草稿名字是否已有
|
||||
* @param id 草稿id
|
||||
*/
|
||||
export function draftDataExist(variables: {
|
||||
dataType: DraftDataType;
|
||||
name: string;
|
||||
}) {
|
||||
const query = `
|
||||
query draftDataExist($dataType: DataType,$name: String) {
|
||||
draftDataExist(dataType: $dataType,name: $name)
|
||||
}
|
||||
`;
|
||||
return api.post('', {
|
||||
query,
|
||||
variables,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建草稿
|
||||
* @param params
|
||||
|
@ -54,6 +54,25 @@ export function setDefaultPublish(variables: {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查发布的草稿名字是否已有
|
||||
* @param id 草稿id
|
||||
*/
|
||||
export function isReleaseDataNameExists(variables: {
|
||||
dataType: DraftDataType;
|
||||
name: string;
|
||||
}) {
|
||||
const query = `
|
||||
query isReleaseDataNameExists($dataType: DataType,$name: String) {
|
||||
isReleaseDataNameExists(dataType: $dataType,name: $name)
|
||||
}
|
||||
`;
|
||||
return api.post('', {
|
||||
query,
|
||||
variables,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 草稿图发布
|
||||
* @param draftId 草稿id
|
||||
|
@ -144,6 +144,7 @@
|
||||
v-model="createForm.draftName"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入名称!']"
|
||||
@blur="checkDraftName"
|
||||
/>
|
||||
<q-select
|
||||
v-model="createForm.style"
|
||||
@ -189,6 +190,7 @@
|
||||
v-model="publishForm.pubName"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入名称!']"
|
||||
@blur="checkPublishName"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
@ -266,6 +268,7 @@ import {
|
||||
PagingQueryParams,
|
||||
iscsStyleOption,
|
||||
searchTscsStyleOption,
|
||||
draftDataExist,
|
||||
} from '../api/DraftApi';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
@ -275,6 +278,7 @@ import {
|
||||
PublishItem,
|
||||
publishPageQuery,
|
||||
setDefaultPublish,
|
||||
isReleaseDataNameExists,
|
||||
} from 'src/api/PublishApi';
|
||||
import { useAuthStore } from 'src/stores/auth-store';
|
||||
import { PageDto } from 'src/api/ApiCommon';
|
||||
@ -436,8 +440,20 @@ const createForm = reactive({
|
||||
draftName: '',
|
||||
style: IscsStyle.DA_SHI_ZHI_NENG,
|
||||
});
|
||||
|
||||
const myForm = ref<QForm | null>(null);
|
||||
async function checkDraftName() {
|
||||
if (!createForm.draftName) return;
|
||||
const res = await draftDataExist({
|
||||
dataType: DraftDataType.ISCS,
|
||||
name: createForm.draftName,
|
||||
});
|
||||
if (res.data.data.draftDataExist) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: '草稿名字已存在,请换一个名字',
|
||||
});
|
||||
}
|
||||
}
|
||||
function onCreate() {
|
||||
myForm.value?.validate().then(async (res) => {
|
||||
if (res) {
|
||||
@ -495,6 +511,20 @@ function newPublish(row: DraftItem) {
|
||||
publishForm.note = '';
|
||||
}
|
||||
|
||||
async function checkPublishName() {
|
||||
if (!publishForm.draftName) return;
|
||||
const res = await isReleaseDataNameExists({
|
||||
dataType: DraftDataType.ISCS,
|
||||
name: publishForm.draftName,
|
||||
});
|
||||
if (res.data.data.isReleaseDataNameExists) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: '发布名字已存在,请换一个名字',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const publishNameDisable = ref(false);
|
||||
function publishToDefault(row: DraftItem) {
|
||||
if (!row.defaultReleaseDataId) {
|
||||
@ -530,6 +560,7 @@ function publishDraftGraphics() {
|
||||
type: 'positive',
|
||||
message: '发布成功',
|
||||
});
|
||||
tableRef.value.requestServerInteraction();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -546,6 +577,7 @@ function publishDraftGraphics() {
|
||||
} else {
|
||||
publishNameDisable.value = false;
|
||||
publishFormShow.value = false;
|
||||
tableRef.value.requestServerInteraction();
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: '发布成功',
|
||||
|
@ -3,7 +3,7 @@ import { RouteRecordRaw } from 'vue-router';
|
||||
const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '/',
|
||||
redirect: '/home/1e2d0d5d96034f4a0805af6512051ddc',
|
||||
redirect: '/home/b82f4bb0398b01263b6ef12764c6eb20',
|
||||
meta: {
|
||||
hidden: true,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user