fix(项目管理): 修改环境校验必填

--bug=1037825 --user=王孝刚
【项目管理】环境管理-HTTP-添加HTTP-启用条件为路径-路径为空时不能直接添加,应红框高亮提示路径不能为空
https://www.tapd.cn/55049933/s/1484413
This commit is contained in:
wxg0103 2024-03-29 20:00:29 +08:00 committed by wxg0103
parent 7ac1ee03be
commit 35a59a55b1
1 changed files with 63 additions and 58 deletions

View File

@ -4,6 +4,7 @@
:visible="visible"
unmount-on-close
:mask="false"
destroy-on-close
@confirm="handleAddOrUpdate"
@cancel="emit('close')"
>
@ -175,7 +176,7 @@
<script lang="ts" setup>
import { defineModel } from 'vue';
import { Message } from '@arco-design/web-vue';
import { Message, ValidatedError } from '@arco-design/web-vue';
import MsDrawer from '@/components/pure/ms-drawer/index.vue';
import type { ActionsItem } from '@/components/pure/ms-table-more-action/types';
@ -259,64 +260,68 @@
}
const handleAddOrUpdate = () => {
const index = store.currentEnvDetailInfo.config.httpConfig.findIndex((item) => item.id === form.value.id);
let modules: { moduleId: string; containChildModule: boolean }[] = [];
const { protocol, hostname, condition, path } = form.value;
if (form.value.type === 'MODULE') {
modules = form.value.moduleId.map((item) => {
return {
moduleId: item,
containChildModule: false,
};
});
}
httpRef.value?.validate(async (errors: undefined | Record<string, ValidatedError>) => {
if (!errors) {
const index = store.currentEnvDetailInfo.config.httpConfig.findIndex((item) => item.id === form.value.id);
let modules: { moduleId: string; containChildModule: boolean }[] = [];
const { protocol, hostname, condition, path } = form.value;
if (form.value.type === 'MODULE') {
modules = form.value.moduleId.map((item) => {
return {
moduleId: item,
containChildModule: false,
};
});
}
// typeNONE 1
const noneData = store.currentEnvDetailInfo.config.httpConfig.filter((item) => item.type === 'NONE');
if (noneData.length >= 1 && (props.isCopy || !props.currentId)) {
Message.error(t('project.environmental.http.noneDataExist'));
return;
}
//
if (index > -1 && !props.isCopy) {
const httpItem = {
...form.value,
url: `${protocol}://${hostname}`,
pathMatchRule: {
path,
condition,
},
order: store.currentEnvDetailInfo.config.httpConfig.length + 1,
moduleMatchRule: { modules },
};
store.currentEnvDetailInfo.config.httpConfig.splice(index, 1, httpItem);
//
} else if (index > -1 && props.isCopy) {
const insertItem = {
...form.value,
id: getGenerateId(),
url: `${protocol}://${hostname}`,
order: store.currentEnvDetailInfo.config.httpConfig.length + 1,
moduleMatchRule: { modules },
};
store.currentEnvDetailInfo.config.httpConfig.splice(index + 1, 0, insertItem);
//
} else {
const httpItem = {
...form.value,
url: `${protocol}://${hostname}`,
pathMatchRule: {
path,
condition,
},
id: getGenerateId(),
order: store.currentEnvDetailInfo.config.httpConfig.length + 1,
moduleMatchRule: { modules },
};
store.currentEnvDetailInfo.config.httpConfig.push(httpItem);
}
emit('close');
resetForm();
// typeNONE 1
const noneData = store.currentEnvDetailInfo.config.httpConfig.filter((item) => item.type === 'NONE');
if (noneData.length >= 1 && (props.isCopy || !props.currentId) && form.value.type === 'NONE') {
Message.error(t('project.environmental.http.noneDataExist'));
return;
}
//
if (index > -1 && !props.isCopy) {
const httpItem = {
...form.value,
url: `${protocol}://${hostname}`,
pathMatchRule: {
path,
condition,
},
order: store.currentEnvDetailInfo.config.httpConfig.length + 1,
moduleMatchRule: { modules },
};
store.currentEnvDetailInfo.config.httpConfig.splice(index, 1, httpItem);
//
} else if (index > -1 && props.isCopy) {
const insertItem = {
...form.value,
id: getGenerateId(),
url: `${protocol}://${hostname}`,
order: store.currentEnvDetailInfo.config.httpConfig.length + 1,
moduleMatchRule: { modules },
};
store.currentEnvDetailInfo.config.httpConfig.splice(index + 1, 0, insertItem);
//
} else {
const httpItem = {
...form.value,
url: `${protocol}://${hostname}`,
pathMatchRule: {
path,
condition,
},
id: getGenerateId(),
order: store.currentEnvDetailInfo.config.httpConfig.length + 1,
moduleMatchRule: { modules },
};
store.currentEnvDetailInfo.config.httpConfig.push(httpItem);
}
emit('close');
resetForm();
}
});
};
const envTree = ref<ModuleTreeNode[]>([]);