fix(项目管理): 环境参数和切换问题
This commit is contained in:
parent
4c653d7eba
commit
abcdecb5e2
|
@ -41,8 +41,14 @@ export interface ProcessorConfig {
|
|||
export interface AssertionConfig {
|
||||
assertions: EnvConfigItem[];
|
||||
}
|
||||
|
||||
export interface CommonParams {
|
||||
requestTimeout: number;
|
||||
responseTimeout: number;
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface EnvConfig {
|
||||
commonParams?: EnvConfigItem;
|
||||
commonParams?: CommonParams;
|
||||
commonVariables: EnvConfigItem[];
|
||||
httpConfig: EnvConfigItem[];
|
||||
dataSources: DataSourceItem[];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { defineStore } from 'pinia';
|
||||
import { number } from 'echarts';
|
||||
import localforage from 'localforage';
|
||||
|
||||
import { getDetailEnv, getGlobalParamDetail } from '@/api/modules/project-management/envManagement';
|
||||
|
@ -45,6 +46,10 @@ const envParamsDefaultConfig: EnvConfig = {
|
|||
},
|
||||
assertionConfig: { assertions: [] },
|
||||
pluginConfigMap: {},
|
||||
commonParams: {
|
||||
requestTimeout: 60000,
|
||||
responseTimeout: 60000,
|
||||
},
|
||||
};
|
||||
|
||||
const useProjectEnvStore = defineStore(
|
||||
|
@ -92,7 +97,6 @@ const useProjectEnvStore = defineStore(
|
|||
const appStore = useAppStore();
|
||||
try {
|
||||
if (id === NEW_ENV_PARAM) {
|
||||
// TODO 数据参数问题
|
||||
currentEnvDetailInfo.value = {
|
||||
projectId: appStore.currentProjectId,
|
||||
name: '',
|
||||
|
@ -107,7 +111,7 @@ const useProjectEnvStore = defineStore(
|
|||
allParamDetailInfo.value = await getGlobalParamDetail(appStore.currentProjectId);
|
||||
} else if (id !== ALL_PARAM && id) {
|
||||
const tmpObj = await getDetailEnv(id);
|
||||
currentEnvDetailInfo.value = tmpObj;
|
||||
currentEnvDetailInfo.value = { ...tmpObj };
|
||||
backupEnvDetailInfo.value = tmpObj;
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
|
||||
<div class="footer" :style="{ width: '100%' }">
|
||||
<a-button @click="handleReset">{{ t('common.cancel') }}</a-button>
|
||||
<a-button :disabled="!canSave" type="primary" @click="handleSave">{{ t('common.save') }}</a-button>
|
||||
<a-button type="primary" :loading="loading" @click="handleSave">{{ t('common.save') }}</a-button>
|
||||
</div>
|
||||
</div>
|
||||
<TabSettingDrawer v-model:visible="tabSettingVisible" @init-data="initTab" />
|
||||
|
@ -93,7 +93,6 @@
|
|||
|
||||
const activeKey = ref('envParams');
|
||||
const envForm = ref();
|
||||
const canSave = ref(false);
|
||||
const { t } = useI18n();
|
||||
const loading = ref(false);
|
||||
const tabSettingVisible = ref(false);
|
||||
|
@ -179,15 +178,14 @@
|
|||
envForm.value?.resetFields();
|
||||
store.initEnvDetail();
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
await envForm.value?.validate(async (valid) => {
|
||||
if (!valid) {
|
||||
try {
|
||||
loading.value = true;
|
||||
store.currentEnvDetailInfo.mock = true;
|
||||
// TODO 需要重新处理收集参数
|
||||
const res = await updateOrAddEnv({ fileList: [], request: store.currentEnvDetailInfo });
|
||||
store.currentEnvDetailInfo = res;
|
||||
await updateOrAddEnv({ fileList: [], request: store.currentEnvDetailInfo });
|
||||
Message.success(t('common.saveSuccess'));
|
||||
emit('ok');
|
||||
} catch (error) {
|
||||
|
@ -212,12 +210,13 @@
|
|||
form.description = currentEnvDetailInfo.description as string;
|
||||
}
|
||||
});
|
||||
watchEffect(() => {
|
||||
if (store.currentEnvDetailInfo) {
|
||||
const { currentEnvDetailInfo, backupEnvDetailInfo } = store;
|
||||
canSave.value = !isEqual(currentEnvDetailInfo, backupEnvDetailInfo);
|
||||
}
|
||||
});
|
||||
|
||||
// watchEffect(() => {
|
||||
// if (store.currentEnvDetailInfo) {
|
||||
// const { currentEnvDetailInfo, backupEnvDetailInfo } = store;
|
||||
// canSave.value = !isEqual(currentEnvDetailInfo, backupEnvDetailInfo);
|
||||
// }
|
||||
// });
|
||||
|
||||
const initTab = async () => {
|
||||
tabSettingVisible.value = false;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
set: (value: any) => {
|
||||
store.currentEnvDetailInfo.config.commonVariables = value;
|
||||
},
|
||||
get: () => store.currentEnvDetailInfo.config.commonVariables || [],
|
||||
get: () => store.currentEnvDetailInfo.config?.commonVariables || [],
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
<div class="flex items-center justify-between">
|
||||
<a-button type="outline" @click="handleAddHttp">{{ t('project.environmental.addHttp') }}</a-button>
|
||||
<div class="flex flex-row gap-[8px]">
|
||||
<a-input-number v-model:model-value="form.linkOutTime" class="w-[180px]">
|
||||
<a-input-number v-model:model-value="form.requestTimeout" class="w-[180px]">
|
||||
<template #prefix>
|
||||
<span class="text-[var(--color-text-3)]">{{ t('project.environmental.http.linkTimeOut') }}</span>
|
||||
</template>
|
||||
</a-input-number>
|
||||
<a-input-number v-model:model-value="form.timeOutTime" class="w-[180px]">
|
||||
<a-input-number v-model:model-value="form.responseTimeout" class="w-[180px]">
|
||||
<template #prefix>
|
||||
<span class="text-[var(--color-text-3)]">{{ t('project.environmental.http.linkTimeOut') }}</span>
|
||||
</template>
|
||||
|
@ -58,6 +58,7 @@
|
|||
import useProjectEnvStore from '@/store/modules/setting/useProjectEnvStore';
|
||||
|
||||
import { BugListItem } from '@/models/bug-management';
|
||||
import type { CommonParams } from '@/models/projectManagement/environmental';
|
||||
import { HttpForm } from '@/models/projectManagement/environmental';
|
||||
import { TableKeyEnum } from '@/enums/tableEnum';
|
||||
|
||||
|
@ -123,12 +124,6 @@
|
|||
debug: true,
|
||||
});
|
||||
|
||||
const form = reactive({
|
||||
linkOutTime: 60000,
|
||||
timeOutTime: 60000,
|
||||
authType: 'Basic Auth',
|
||||
});
|
||||
|
||||
const moreActionList: ActionsItem[] = [
|
||||
{
|
||||
label: t('common.delete'),
|
||||
|
@ -175,9 +170,17 @@
|
|||
const handleNoWarning = () => {
|
||||
store.setHttpNoWarning(false);
|
||||
};
|
||||
|
||||
watch(store.currentEnvDetailInfo.config.httpConfig, () => {
|
||||
propsRes.value.data = store.currentEnvDetailInfo.config.httpConfig;
|
||||
});
|
||||
|
||||
const form = computed({
|
||||
set: (value: any) => {
|
||||
store.currentEnvDetailInfo.config.commonParams = { ...value };
|
||||
},
|
||||
get: () => store.currentEnvDetailInfo.config.commonParams as CommonParams,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
|
|
@ -371,9 +371,12 @@
|
|||
store.setCurrentGroupId(NEW_ENV_GROUP);
|
||||
evnGroupList.value = tmpArr;
|
||||
};
|
||||
const initGroupList = async (keywordStr = '') => {
|
||||
const initGroupList = async (keywordStr = '', initNode = false) => {
|
||||
try {
|
||||
evnGroupList.value = await groupListEnv({ projectId: appStore.currentProjectId, keyword: keywordStr });
|
||||
if (initNode && evnGroupList.value.length) {
|
||||
store.setCurrentGroupId(evnGroupList.value[0].id);
|
||||
}
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error);
|
||||
|
@ -386,11 +389,14 @@
|
|||
store.setCurrentGroupId(id);
|
||||
};
|
||||
|
||||
const initData = async (keywordStr = '') => {
|
||||
const initData = async (keywordStr = '', initNode = false) => {
|
||||
try {
|
||||
envList.value = await listEnv({ projectId: appStore.currentProjectId, keyword: keywordStr });
|
||||
if (initNode && envList.value.length) {
|
||||
store.setCurrentId(envList.value[0].id);
|
||||
}
|
||||
if (showType.value === 'PROJECT_GROUP') {
|
||||
initGroupList(keywordStr);
|
||||
initGroupList(keywordStr, initNode);
|
||||
}
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
|
@ -418,24 +424,20 @@
|
|||
if (envList.value[_newIndex + 1].id) {
|
||||
params.moveMode = 'BEFORE';
|
||||
params.moveId = envList.value[_newIndex + 1].id;
|
||||
return;
|
||||
}
|
||||
if (envList.value[_newIndex - 1].id) {
|
||||
params.moveMode = 'AFTER';
|
||||
params.moveId = envList.value[_newIndex - 1].id;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (type === EnvAuthTypeEnum.ENVIRONMENT_GROUP) {
|
||||
if (evnGroupList.value[_newIndex + 1].id) {
|
||||
params.moveMode = 'AFTER';
|
||||
params.moveId = evnGroupList.value[_newIndex + 1].id;
|
||||
return;
|
||||
}
|
||||
if (evnGroupList.value[_newIndex - 1].id) {
|
||||
params.moveMode = 'BEFORE';
|
||||
params.moveId = evnGroupList.value[_newIndex - 1].id;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -545,7 +547,7 @@
|
|||
}
|
||||
};
|
||||
onMounted(() => {
|
||||
initData();
|
||||
initData(keyword.value, true);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue