fix(项目管理): 修复应用管理保存传参

This commit is contained in:
RubyLiu 2024-02-01 16:38:05 +08:00 committed by Craftsman
parent 6fa3e4ad0f
commit f1e566062a
8 changed files with 102 additions and 21 deletions

View File

@ -167,14 +167,16 @@ export function getDeleteFake(data: FakeTableOperationParams) {
// JIRA插件key校验 // JIRA插件key校验
export function validateJIRAKey(data: object, pluginId: string) { export function validateJIRAKey(data: object, pluginId: string) {
return MSR.post<FakeTableListItem[]>({ url: `${Url.postValidateJiraKeyUrl}${pluginId}`, data }); return MSR.post<MenuTableConfigItem>({ url: `${Url.postValidateJiraKeyUrl}${pluginId}`, data });
} }
// 缺陷管理-获取同步信息 // 缺陷管理-获取同步信息
export function getBugSyncInfo(projectId: string) { export function getBugSyncInfo(projectId: string) {
return MSR.get<FakeTableListItem[]>({ url: `${Url.getBugSyncInfoUrl}${projectId}` }); return MSR.get<MenuTableConfigItem>({ url: `${Url.getBugSyncInfoUrl}${projectId}` });
} }
// 用例管理-获取关联需求信息 // 用例管理-获取关联需求信息
export function getCaseRelatedInfo(projectId: string) { export function getCaseRelatedInfo(projectId: string) {
return MSR.get<FakeTableListItem[]>({ url: `${Url.getCaseRelatedInfoUrl}${projectId}` }); return MSR.get<{ demand_platform_config: string; platform_key: string; case_enable: string }>({
url: `${Url.getCaseRelatedInfoUrl}${projectId}`,
});
} }

View File

@ -1,10 +1,9 @@
<template> <template>
<a-input <a-input
:value="props.modelValue" v-model:model-value="inputValue"
:placeholder="t('project.menu.pleaseInputJiraKey')" :placeholder="t('project.menu.pleaseInputJiraKey')"
v-bind="attrs" v-bind="attrs"
:max-length="255" :max-length="255"
@change="(v: string) => emit('update:modelValue', v)"
@blur="handleBlur" @blur="handleBlur"
/> />
<div class="flex flex-row items-center gap-[10px] text-[12px] leading-[16px]"> <div class="flex flex-row items-center gap-[10px] text-[12px] leading-[16px]">
@ -22,6 +21,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { defineModel } from 'vue';
import { Message } from '@arco-design/web-vue'; import { Message } from '@arco-design/web-vue';
import { validateJIRAKey } from '@/api/modules/project-management/menuManagement'; import { validateJIRAKey } from '@/api/modules/project-management/menuManagement';
@ -29,16 +29,15 @@
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
const attrs = useAttrs(); const attrs = useAttrs();
const { formCreateInject } = attrs;
const props = defineProps<{ const props = defineProps<{
modelValue: string;
instructionsIcon: string; instructionsIcon: string;
value?: string;
}>(); }>();
const previewIcon = ref<string>(''); const previewIcon = ref<string>('');
const emit = defineEmits<{ const inputValue = defineModel<string>();
(event: 'update:modelValue', value: string): void;
}>();
const { t } = useI18n(); const { t } = useI18n();
onMounted(() => { onMounted(() => {
@ -53,13 +52,18 @@
const pluginId = sessionStorage.getItem('platformKey') || ''; const pluginId = sessionStorage.getItem('platformKey') || '';
if (pluginId) { if (pluginId) {
try { try {
await validateJIRAKey({ name: '1231' }, pluginId); await validateJIRAKey({ [(formCreateInject as { [key: string]: string }).field]: inputValue.value }, pluginId);
Message.success('common.validateSuccess'); Message.success('common.validateSuccess');
} catch { } catch (e) {
Message.error('common.validateFaild'); console.log(e);
} }
} }
}; };
watchEffect(() => {
if (props.value) {
inputValue.value = props.value;
}
});
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -19,6 +19,8 @@
import { FormRuleItem } from './types'; import { FormRuleItem } from './types';
import formCreate, { Rule } from '@form-create/arco-design'; import formCreate, { Rule } from '@form-create/arco-design';
defineOptions({ name: 'MsFormCreate' });
const { t } = useI18n(); const { t } = useI18n();
formCreate.component('PassWord', PassWord); formCreate.component('PassWord', PassWord);

View File

@ -83,7 +83,14 @@
<a-tooltip v-if="okDisabled" :content="t('project.menu.defect.enableAfterConfig')"> <a-tooltip v-if="okDisabled" :content="t('project.menu.defect.enableAfterConfig')">
<a-switch size="small" type="line" disabled /> <a-switch size="small" type="line" disabled />
</a-tooltip> </a-tooltip>
<a-switch v-else v-model="form.SYNC_ENABLE" size="small" type="line" /> <a-switch
v-else
v-model="form.SYNC_ENABLE"
checked-value="true"
unchecked-value="false"
size="small"
type="line"
/>
<span class="text-[var(--color-text-1)]"> <span class="text-[var(--color-text-1)]">
{{ t('project.menu.status') }} {{ t('project.menu.status') }}
</span> </span>
@ -111,6 +118,7 @@
import type { FormItem, FormRuleItem } from '@/components/pure/ms-form-create/types'; import type { FormItem, FormRuleItem } from '@/components/pure/ms-form-create/types';
import { import {
getBugSyncInfo,
getPlatformInfo, getPlatformInfo,
getPlatformOptions, getPlatformOptions,
postSaveDefectSync, postSaveDefectSync,
@ -129,6 +137,8 @@
const props = defineProps<{ const props = defineProps<{
visible: boolean; visible: boolean;
}>(); }>();
const formCreateValue = ref<Record<string, any>>({});
const currentVisible = ref<boolean>(props.visible); const currentVisible = ref<boolean>(props.visible);
const platformOption = ref<PoolOption[]>([]); const platformOption = ref<PoolOption[]>([]);
const frequencyOption = ref([ const frequencyOption = ref([
@ -171,6 +181,13 @@
try { try {
if (value) { if (value) {
const res = await getPlatformInfo(value as string, MenuEnum.bugManagement); const res = await getPlatformInfo(value as string, MenuEnum.bugManagement);
if (formCreateValue.value) {
res.formItems.forEach((item) => {
if (formCreateValue.value[item.name]) {
item.value = formCreateValue.value[item.name];
}
});
}
platformRules.value = res.formItems; platformRules.value = res.formItems;
sessionStorage.setItem('platformKey', value as string); sessionStorage.setItem('platformKey', value as string);
} else { } else {
@ -210,12 +227,30 @@
} }
}; };
//
const initDetailInfo = async () => {
try {
await initPlatformOption();
const res = await getBugSyncInfo(currentProjectId.value);
if (res && res.platform_key) {
form.SYNC_ENABLE = res.sync_enable;
form.PLATFORM_KEY = res.platform_key;
formCreateValue.value = JSON.parse(res.bug_platform_config);
// keychange
await handlePlatformChange(res.platform_key);
}
} catch (e) {
// eslint-disable-next-line no-console
console.log(e);
}
};
watch( watch(
() => props.visible, () => props.visible,
(val) => { (val) => {
currentVisible.value = val; currentVisible.value = val;
if (val) { if (val) {
initPlatformOption(); initDetailInfo();
} else { } else {
formRef.value?.resetFields(); formRef.value?.resetFields();
platformRules.value = []; platformRules.value = [];

View File

@ -40,7 +40,14 @@
<a-tooltip v-if="okDisabled" :content="t('project.menu.defect.enableAfterConfig')"> <a-tooltip v-if="okDisabled" :content="t('project.menu.defect.enableAfterConfig')">
<a-switch size="small" type="line" disabled /> <a-switch size="small" type="line" disabled />
</a-tooltip> </a-tooltip>
<a-switch v-else v-model="form.SYNC_ENABLE" size="small" type="line" /> <a-switch
v-else
v-model="form.CASE_ENABLE"
checked-value="true"
unchecked-value="false"
size="small"
type="line"
/>
<span class="text-[var(--color-text-1)]"> <span class="text-[var(--color-text-1)]">
{{ t('project.menu.status') }} {{ t('project.menu.status') }}
</span> </span>
@ -68,6 +75,7 @@
import type { FormItem, FormRuleItem } from '@/components/pure/ms-form-create/types'; import type { FormItem, FormRuleItem } from '@/components/pure/ms-form-create/types';
import { import {
getCaseRelatedInfo,
getPlatformInfo, getPlatformInfo,
getPlatformOptions, getPlatformOptions,
postSaveRelatedCase, postSaveRelatedCase,
@ -98,9 +106,11 @@
const form = reactive({ const form = reactive({
PLATFORM_KEY: '', PLATFORM_KEY: '',
SYNC_ENABLE: 'false', // CASE_ENABLE: 'false', //
}); });
const formCreateValue = ref<Record<string, any>>({});
const okDisabled = computed(() => !form.PLATFORM_KEY); const okDisabled = computed(() => !form.PLATFORM_KEY);
const emit = defineEmits<{ const emit = defineEmits<{
@ -116,6 +126,13 @@
try { try {
if (value) { if (value) {
const res = await getPlatformInfo(value as string, MenuEnum.caseManagement); const res = await getPlatformInfo(value as string, MenuEnum.caseManagement);
if (formCreateValue.value) {
res.formItems.forEach((item) => {
if (formCreateValue.value[item.name]) {
item.value = formCreateValue.value[item.name];
}
});
}
platformRules.value = res.formItems; platformRules.value = res.formItems;
} else { } else {
platformRules.value = []; platformRules.value = [];
@ -156,13 +173,30 @@
console.log(error); console.log(error);
} }
}; };
//
const initDetailInfo = async () => {
try {
await initPlatformOption();
const res = await getCaseRelatedInfo(currentProjectId.value);
if (res && res.platform_key) {
form.CASE_ENABLE = res.case_enable;
form.PLATFORM_KEY = res.platform_key;
formCreateValue.value = JSON.parse(res.demand_platform_config);
// keychange
await handlePlatformChange(res.platform_key);
}
} catch (e) {
// eslint-disable-next-line no-console
console.log(e);
}
};
watch( watch(
() => props.visible, () => props.visible,
(val) => { (val) => {
currentVisible.value = val; currentVisible.value = val;
if (val) { if (val) {
initPlatformOption(); initDetailInfo();
} else { } else {
formRef.value?.resetFields(); formRef.value?.resetFields();
platformRules.value = []; platformRules.value = [];

View File

@ -142,7 +142,7 @@
(e: 'cancel', shouldSearch: boolean): void; (e: 'cancel', shouldSearch: boolean): void;
}>(); }>();
const allModuleIds = ['workstation', 'testPlan', 'bugManagement', 'caseManagement', 'apiTest', 'uiTest', 'loadTest']; const allModuleIds = ['bugManagement', 'caseManagement', 'apiTest'];
const showPoolModuleIds = ['uiTest', 'apiTest', 'loadTest']; const showPoolModuleIds = ['uiTest', 'apiTest', 'loadTest'];

View File

@ -9,7 +9,7 @@
}}</a-button> }}</a-button>
<a-input-search <a-input-search
v-model="keyword" v-model="keyword"
:placeholder="t('system.user.searchUser')" :placeholder="t('system.organization.searchIndexPlaceholder')"
class="w-[240px]" class="w-[240px]"
allow-clear allow-clear
@press-enter="fetchData" @press-enter="fetchData"

View File

@ -60,7 +60,11 @@
</a-checkbox-group> </a-checkbox-group>
</a-form-item> </a-form-item>
<a-form-item v-if="showPool" field="resourcePool" :label="t('system.project.resourcePool')"> <a-form-item v-if="showPool" field="resourcePool" :label="t('system.project.resourcePool')">
<MsSystemPool v-model:modelValue="form.resourcePoolIds" :organization-id="form.organizationId" /> <MsSystemPool
v-model:modelValue="form.resourcePoolIds"
:module-ids="form.moduleIds"
:organization-id="form.organizationId"
/>
</a-form-item> </a-form-item>
<a-form-item field="description" :label="t('system.organization.description')"> <a-form-item field="description" :label="t('system.organization.description')">
<a-textarea <a-textarea
@ -138,7 +142,7 @@
(e: 'cancel', shouldSearch: boolean): void; (e: 'cancel', shouldSearch: boolean): void;
}>(); }>();
const allModuleIds = ['workstation', 'testPlan', 'bugManagement', 'caseManagement', 'apiTest', 'uiTest', 'loadTest']; const allModuleIds = ['bugManagement', 'caseManagement', 'apiTest'];
const showPoolModuleIds = ['uiTest', 'apiTest', 'loadTest']; const showPoolModuleIds = ['uiTest', 'apiTest', 'loadTest'];