mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 08:19:15 +08:00
fix: 增加一些校验规则
This commit is contained in:
parent
35098ce79c
commit
eb56b918a6
@ -28,7 +28,7 @@
|
||||
<el-table-column :label="$t('commons.table.operate')">
|
||||
<template #default="{ row, $index }">
|
||||
<div>
|
||||
<el-button link v-if="row.edit" type="primary" @click="saveGroup(groupForm, row, true)">
|
||||
<el-button link v-if="row.edit" type="primary" @click="saveGroup(groupForm, row)">
|
||||
{{ $t('commons.button.save') }}
|
||||
</el-button>
|
||||
<el-button link v-if="!row.edit" type="primary" @click="editGroup($index)">
|
||||
@ -46,12 +46,7 @@
|
||||
<el-button link v-if="row.edit" type="primary" @click="search()">
|
||||
{{ $t('commons.button.cancel') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
v-if="!row.edit && !row.isDefault"
|
||||
type="primary"
|
||||
@click="saveGroup(groupForm, row, false)"
|
||||
>
|
||||
<el-button link v-if="!row.edit && !row.isDefault" type="primary" @click="setDefault(row)">
|
||||
{{ $t('website.setDefault') }}
|
||||
</el-button>
|
||||
</div>
|
||||
@ -83,7 +78,7 @@ interface DialogProps {
|
||||
type: string;
|
||||
}
|
||||
|
||||
const groupForm = ref();
|
||||
const groupForm = ref<FormInstance>();
|
||||
const acceptParams = (params: DialogProps): void => {
|
||||
type.value = params.type;
|
||||
open.value = true;
|
||||
@ -106,16 +101,13 @@ const search = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const saveGroup = async (formEl: FormInstance, group: Group.GroupInfo, isEdit: boolean) => {
|
||||
const saveGroup = async (formEl: FormInstance, group: Group.GroupInfo) => {
|
||||
if (!formEl) return;
|
||||
await formEl.validate((valid) => {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
group.type = type.value;
|
||||
if (!isEdit) {
|
||||
group.isDefault = true;
|
||||
}
|
||||
if (group.id == 0) {
|
||||
CreateGroup(group).then(() => {
|
||||
MsgSuccess(i18n.global.t('commons.msg.createSuccess'));
|
||||
@ -130,6 +122,14 @@ const saveGroup = async (formEl: FormInstance, group: Group.GroupInfo, isEdit: b
|
||||
});
|
||||
};
|
||||
|
||||
const setDefault = (group: Group.GroupInfo) => {
|
||||
group.isDefault = true;
|
||||
UpdateGroup(group).then(() => {
|
||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
||||
search();
|
||||
});
|
||||
};
|
||||
|
||||
const openCreate = () => {
|
||||
for (const d of data.value) {
|
||||
if (d.name == '') {
|
||||
|
@ -6,7 +6,7 @@
|
||||
<el-form ref="newNameRef" v-loading="loading" :model="renameForm" label-position="top">
|
||||
<el-row type="flex" justify="center">
|
||||
<el-col :span="22">
|
||||
<el-form-item :label="$t('container.newName')" :rules="Rules.requiredInput" prop="newName">
|
||||
<el-form-item :label="$t('container.newName')" :rules="Rules.volumeName" prop="newName">
|
||||
<el-input v-model="renameForm.newName"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
@ -19,7 +19,7 @@
|
||||
<el-option v-for="item in repos" :key="item.id" :value="item.id" :label="item.name" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('container.imageName')" :rules="Rules.requiredInput" prop="targetName">
|
||||
<el-form-item :label="$t('container.imageName')" :rules="Rules.imageName" prop="targetName">
|
||||
<el-input v-model="form.targetName">
|
||||
<template v-if="form.fromRepo" #prepend>{{ loadDetailInfo(form.repoID) }}/</template>
|
||||
</el-input>
|
||||
|
@ -118,10 +118,12 @@ const rules = reactive({
|
||||
const loadGroups = async () => {
|
||||
const res = await GetGroupList({ type: 'host' });
|
||||
groupList.value = res.data;
|
||||
for (const item of groupList.value) {
|
||||
if (item.isDefault) {
|
||||
dialogData.value.rowData.groupID = item.id;
|
||||
break;
|
||||
if (dialogData.value.title === 'create') {
|
||||
for (const item of groupList.value) {
|
||||
if (item.isDefault) {
|
||||
dialogData.value.rowData.groupID = item.id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user