refactor(项目管理): 环境管理环境参数修改

This commit is contained in:
rubyliu 2024-02-28 21:33:30 +08:00 committed by 刘瑞斌
parent 4d832ce503
commit 5e266613e6
7 changed files with 26 additions and 23 deletions

View File

@ -1,5 +1,3 @@
import { key } from 'localforage';
export interface EnvListItem { export interface EnvListItem {
name: string; name: string;
id: string; id: string;
@ -36,11 +34,12 @@ export interface EnvConfig {
commmonVariables?: EnvConfigItem[]; commmonVariables?: EnvConfigItem[];
httpConfig?: EnvConfigItem[]; httpConfig?: EnvConfigItem[];
dataSource?: DataSourceItem[]; dataSource?: DataSourceItem[];
hostConfig?: EnvConfigItem[]; hostConfig?: EnvConfigItem;
authConfig?: EnvConfigItem; authConfig?: EnvConfigItem;
preScript?: EnvConfigItem[]; preProcessorConfig?: EnvConfigItem;
postScript?: EnvConfigItem[]; postProcessorConfig?: EnvConfigItem;
assertions?: EnvConfigItem[]; assertionConfig?: EnvConfigItem;
pluginConfigMap?: EnvConfigItem;
} }
export interface EnvDetailItem { export interface EnvDetailItem {
id?: string; id?: string;

View File

@ -11,9 +11,9 @@
const params = computed({ const params = computed({
set: (value: any) => { set: (value: any) => {
store.currentEnvDetailInfo.config.assertions = value; store.currentEnvDetailInfo.config.assertionConfig = value;
}, },
get: () => store.currentEnvDetailInfo.config.assertions || [], get: () => store.currentEnvDetailInfo.config.assertionConfig || [],
}); });
</script> </script>

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<div class="flex flex-row items-center gap-[8px]"> <div class="flex flex-row items-center gap-[8px]">
<a-switch type="line" size="small" /> <a-switch v-model:model-value="currentList.enable" type="line" size="small" />
<div class="text-[var(--color-text-1)]">{{ t('project.environmental.host.config') }}</div> <div class="text-[var(--color-text-1)]">{{ t('project.environmental.host.config') }}</div>
</div> </div>
<div class="mt-[8px]"> <div class="mt-[8px]">
@ -10,7 +10,7 @@
:models="batchFormModels" :models="batchFormModels"
:form-mode="ruleFormMode" :form-mode="ruleFormMode"
add-text="project.menu.rule.addRule" add-text="project.menu.rule.addRule"
:default-vals="currentList" :default-vals="currentList.hosts"
show-enable show-enable
:is-show-drag="false" :is-show-drag="false"
></MsBatchForm> ></MsBatchForm>
@ -35,14 +35,15 @@
const store = useProjectEnvStore(); const store = useProjectEnvStore();
const currentList = computed({ const currentList = computed({
get: () => (store.currentEnvDetailInfo.config.hostConfig || []) as FakeTableListItem[], get: () => store.currentEnvDetailInfo.config.hostConfig || {},
set: (value: EnvConfigItem[] | undefined) => { set: (value: EnvConfigItem) => {
store.currentEnvDetailInfo.config.hostConfig = value; console.log(value);
store.currentEnvDetailInfo.config.hostConfig = value || {};
}, },
}); });
const batchFormRef = ref(); const batchFormRef = ref();
onClickOutside(batchFormRef, () => { onClickOutside(batchFormRef, () => {
currentList.value = batchFormRef.value?.getFormResult(); currentList.value.hosts = batchFormRef.value?.getFormResult();
}); });
type UserModalMode = 'create' | 'edit'; type UserModalMode = 'create' | 'edit';
const batchFormModels: Ref<FormItemModel[]> = ref([ const batchFormModels: Ref<FormItemModel[]> = ref([

View File

@ -43,7 +43,6 @@
</template> </template>
<script lang="ts" async setup> <script lang="ts" async setup>
import { defineModel } from 'vue';
import { TableData } from '@arco-design/web-vue'; import { TableData } from '@arco-design/web-vue';
import MsButton from '@/components/pure/ms-button/index.vue'; import MsButton from '@/components/pure/ms-button/index.vue';
@ -69,9 +68,12 @@
const tableStore = useTableStore(); const tableStore = useTableStore();
const addVisible = ref(false); const addVisible = ref(false);
const currentId = ref(''); const currentId = ref('');
const innerParam = defineModel<TableData[]>('modelValue', {
type: Array, const innerParam = computed({
default: () => [], set: (value: TableData[]) => {
store.currentEnvDetailInfo.config.httpConfig = value;
},
get: () => store.currentEnvDetailInfo.config.httpConfig || [],
}); });
const columns: MsTableColumn = [ const columns: MsTableColumn = [
@ -124,6 +126,7 @@
showSetting: true, showSetting: true,
showPagination: false, showPagination: false,
showMode: false, showMode: false,
debug: true,
}); });
const form = reactive({ const form = reactive({

View File

@ -12,9 +12,9 @@
// TODO: // TODO:
const params = computed<any>({ const params = computed<any>({
set: (value: any) => { set: (value: any) => {
store.currentEnvDetailInfo.config.postScript = value; store.currentEnvDetailInfo.config.postProcessorConfig = value;
}, },
get: () => store.currentEnvDetailInfo.config.postScript || [], get: () => store.currentEnvDetailInfo.config.postProcessorConfig || {},
}); });
</script> </script>

View File

@ -12,9 +12,9 @@
// TODO: // TODO:
const params = computed<any>({ const params = computed<any>({
set: (value: any) => { set: (value: any) => {
store.currentEnvDetailInfo.config.preScript = value; store.currentEnvDetailInfo.config.preProcessorConfig = value;
}, },
get: () => store.currentEnvDetailInfo.config.preScript || [], get: () => store.currentEnvDetailInfo.config.preProcessorConfig || {},
}); });
</script> </script>

View File

@ -230,7 +230,7 @@
const envList = ref<EnvListItem[]>([]); // const envList = ref<EnvListItem[]>([]); //
const evnGroupList = ref<EnvListItem[]>([]); // const evnGroupList = ref<EnvListItem[]>([]); //
const showType = ref<EnvAuthScopeEnum>(EnvAuthScopeEnum.PROJECT_GROUP); // const showType = ref<EnvAuthScopeEnum>(EnvAuthScopeEnum.PROJECT); //
const activeKey = computed(() => store.currentId); // id const activeKey = computed(() => store.currentId); // id