fix(项目管理): 环境管理-Host保存表单检验问题

--bug=1037322 --user=宋昌昌 【项目管理】环境管理-环境-HOST-添加多个host,其中域名为空保存时未提示域名必填 https://www.tapd.cn/55049933/s/1494309
This commit is contained in:
song-cc-rock 2024-04-11 14:22:12 +08:00 committed by 刘瑞斌
parent adc7599c66
commit 1901dc466e
2 changed files with 29 additions and 10 deletions

View File

@ -48,7 +48,7 @@
<EnvParamsTab v-if="activeKey === 'envParams'" /> <EnvParamsTab v-if="activeKey === 'envParams'" />
<HttpTab v-else-if="activeKey === 'http'" /> <HttpTab v-else-if="activeKey === 'http'" />
<DataBaseTab v-else-if="activeKey === 'database'" /> <DataBaseTab v-else-if="activeKey === 'database'" />
<HostTab v-else-if="activeKey === 'host'" /> <HostTab v-else-if="activeKey === 'host'" ref="hostTabRef" />
<!-- <PreTab v-else-if="activeKey === 'pre'" /> <!-- <PreTab v-else-if="activeKey === 'pre'" />
<PostTab v-else-if="activeKey === 'post'" /> --> <PostTab v-else-if="activeKey === 'post'" /> -->
<div v-else-if="activeKey === 'pre' || activeKey === 'post'" class="h-full"> <div v-else-if="activeKey === 'pre' || activeKey === 'post'" class="h-full">
@ -77,6 +77,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue';
import { Message } from '@arco-design/web-vue'; import { Message } from '@arco-design/web-vue';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
@ -114,6 +115,7 @@
const loading = ref(false); const loading = ref(false);
const tabSettingVisible = ref(false); const tabSettingVisible = ref(false);
const appStore = useAppStore(); const appStore = useAppStore();
const hostTabRef = ref();
const store = useProjectEnvStore(); const store = useProjectEnvStore();
const envPluginList = ref<EnvPluginListItem[]>([]); const envPluginList = ref<EnvPluginListItem[]>([]);
@ -216,17 +218,27 @@
}; };
} }
const saveCallBack = async () => {
//
loading.value = true;
store.currentEnvDetailInfo.mock = true;
await updateOrAddEnv({ fileList: [], request: getParameters() });
setState(true);
Message.success(store.currentEnvDetailInfo.id ? t('common.updateSuccess') : t('common.saveSuccess'));
emit('ok', store.currentEnvDetailInfo.id);
};
const handleSave = async () => { const handleSave = async () => {
await envForm.value?.validate(async (valid) => { await envForm.value?.validate(async (valid) => {
if (!valid) { if (!valid) {
try { try {
loading.value = true; // Host-Tab(Host)
store.currentEnvDetailInfo.mock = true; if (activeKey.value === 'host') {
await updateOrAddEnv({ fileList: [], request: getParameters() }); hostTabRef.value?.validateForm(saveCallBack);
setState(true); } else {
await saveCallBack();
Message.success(store.currentEnvDetailInfo.id ? t('common.updateSuccess') : t('common.saveSuccess')); }
emit('ok', store.currentEnvDetailInfo.id);
} catch (error) { } catch (error) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(error); console.log(error);
@ -236,6 +248,7 @@
} }
}); });
}; };
watchEffect(() => { watchEffect(() => {
if (store.currentId) { if (store.currentId) {
store.initEnvDetail(); store.initEnvDetail();

View File

@ -48,13 +48,11 @@
import { onClickOutside } from '@vueuse/core'; import { onClickOutside } from '@vueuse/core';
import { debounce } from 'lodash-es'; import { debounce } from 'lodash-es';
import MsCodeEditor from '@/components/pure/ms-code-editor/index.vue';
import MsBatchForm from '@/components/business/ms-batch-form/index.vue'; import MsBatchForm from '@/components/business/ms-batch-form/index.vue';
import { FormItemModel } from '@/components/business/ms-batch-form/types'; import { FormItemModel } from '@/components/business/ms-batch-form/types';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useProjectEnvStore from '@/store/modules/setting/useProjectEnvStore'; import useProjectEnvStore from '@/store/modules/setting/useProjectEnvStore';
import { getGenerateId } from '@/utils';
import { EnvConfigItem } from '@/models/projectManagement/environmental'; import { EnvConfigItem } from '@/models/projectManagement/environmental';
@ -104,6 +102,10 @@
// //
const editorContent = ref(''); const editorContent = ref('');
function validateForm(cb?: () => void) {
return batchFormRef.value?.formValidate(cb);
}
/** /**
* 解析代码编辑器内容 * 解析代码编辑器内容
*/ */
@ -130,6 +132,10 @@
}); });
} }
defineExpose({
validateForm,
});
watch( watch(
() => editorContent.value, () => editorContent.value,
(val) => { (val) => {