fix: 修改模板字段参数问题和缺陷默认值问题

This commit is contained in:
xinxin.wu 2024-02-29 17:03:14 +08:00 committed by 刘瑞斌
parent b891d57a6d
commit a0ae2b4857
9 changed files with 58 additions and 38 deletions

View File

@ -12,6 +12,7 @@ export const INPUT = {
props: {
'placeholder': t('formCreate.PleaseEnter'),
'max-length': 255,
'allow-clear': true,
},
};
export const SELECT = {
@ -21,10 +22,11 @@ export const SELECT = {
value: '',
options: [],
props: {
multiple: false,
placeholder: t('formCreate.PleaseSelect'),
options: [],
modelValue: '',
'multiple': false,
'placeholder': t('formCreate.PleaseSelect'),
'options': [],
'modelValue': '',
'allow-clear': true,
},
};
@ -35,10 +37,11 @@ export const MULTIPLE_SELECT = {
value: [],
options: [],
props: {
multiple: true,
placeholder: t('formCreate.PleaseSelect'),
options: [],
modelValue: [],
'multiple': true,
'placeholder': t('formCreate.PleaseSelect'),
'options': [],
'modelValue': [],
'allow-clear': true,
},
};
@ -65,9 +68,10 @@ export const MEMBER = {
value: '',
options: [],
props: {
multiple: false,
placeholder: t('formCreate.PleaseSelect'),
modelValue: '',
'multiple': false,
'placeholder': t('formCreate.PleaseSelect'),
'modelValue': '',
'allow-clear': true,
},
};
@ -78,10 +82,11 @@ export const MULTIPLE_MEMBER = {
value: [],
options: [],
props: {
multiple: true,
placeholder: t('formCreate.PleaseSelect'),
options: [],
modelValue: [],
'multiple': true,
'placeholder': t('formCreate.PleaseSelect'),
'options': [],
'modelValue': [],
'allow-clear': true,
},
};
@ -114,7 +119,7 @@ export const FLOAT = {
type: 'InputNumber',
field: 'fieldName',
title: '',
value: 0,
value: 0.0,
props: {
precision: 2,
placeholder: t('formCreate.PleaseEnter'),
@ -138,7 +143,8 @@ export const MULTIPLE_INPUT = {
title: '',
value: [],
props: {
placeholder: t('formCreate.PleaseEnter'),
'placeholder': t('formCreate.PleaseEnter'),
'allow-clear': true,
},
};
@ -170,8 +176,9 @@ export const PASSWORD = {
title: '',
value: '',
props: {
modelValue: '',
instructionsIcon: '',
'modelValue': '',
'instructionsIcon': '',
'allow-clear': true,
},
};

View File

@ -4,7 +4,7 @@ import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal';
const isSave = ref(false);
let isRouteIntercepted = false;
const isRouteIntercepted = ref<boolean>(false);
// 离开页面确认提示
export default function useLeaveUnSaveTip() {
@ -15,7 +15,7 @@ export default function useLeaveUnSaveTip() {
isSave.value = flag;
};
onBeforeRouteLeave((to, from, next) => {
if (to.path === from.path || isRouteIntercepted) {
if (to.path === from.path) {
next();
return;
}
@ -31,7 +31,7 @@ export default function useLeaveUnSaveTip() {
status: 'normal',
},
onBeforeOk: async () => {
isRouteIntercepted = true;
isSave.value = true;
next();
},
hideCancel: false,

View File

@ -25,7 +25,7 @@ export type SeneType = 'FUNCTIONAL' | 'BUG' | 'API' | 'UI' | 'TEST_PLAN' | Locat
export interface FieldOptions {
fieldId?: string;
value: string | string[] | number | number[];
value: any;
text: string;
internal?: boolean; // 是否是内置模板
}
@ -67,7 +67,7 @@ export interface AddOrUpdateField {
type: FormItemType;
remark: string; // 备注
scopeId: string; // 组织或项目ID
options?: FieldOption[];
options?: FieldOptions[];
enableOptionKey: boolean;
[key: string]: any;
}

View File

@ -336,16 +336,16 @@
const getFormRules = (arr: BugEditCustomField[]) => {
formRules.value = [];
if (Array.isArray(arr) && arr.length) {
formRules.value = arr.map((item) => {
formRules.value = arr.map((item: any) => {
return {
type: item.type,
name: item.fieldId,
label: item.fieldName,
value: item.value,
value: item.defaultValue,
options: item.platformOptionJson ? JSON.parse(item.platformOptionJson) : item.options,
required: item.required as boolean,
props: {
modelValue: item.value,
modelValue: item.defaultValue,
options: item.platformOptionJson ? JSON.parse(item.platformOptionJson) : item.options,
},
};

View File

@ -73,8 +73,7 @@
>{{ t('system.orgTemplate.copy') }}</MsButton
>
<a-divider
v-if="!record.internal"
v-permission="['PROJECT_TEMPLATE:READ+ADD']"
v-if="!record.internal && hasAnyPermission(['PROJECT_TEMPLATE:READ+ADD'])"
class="h-[16px]"
direction="vertical"
/>

View File

@ -306,11 +306,17 @@
const result = selectData.value.map((item) => {
if (item.formRules?.length) {
const { value } = item.formRules[0];
let setValue;
if (typeof value === 'number') {
setValue = value;
} else {
setValue = value || '';
}
return {
fieldId: item.id,
required: item.required,
apiFieldId: item.apiFieldId || '',
defaultValue: value || '',
defaultValue: setValue,
};
}
return [];

View File

@ -136,7 +136,7 @@
import { useAppStore } from '@/store';
import { getGenerateId } from '@/utils';
import type { AddOrUpdateField, fieldIconAndNameModal } from '@/models/setting/template';
import type { AddOrUpdateField, fieldIconAndNameModal, FieldOptions } from '@/models/setting/template';
import { fieldIconAndName, getFieldRequestApi, getFieldType } from './fieldSetting';
@ -314,10 +314,15 @@
fieldDefaultValues.value = [...list];
if (showOptionsSelect.value) {
fieldForm.value.options = (batchFormRef.value?.getFormResult() || []).map((item: any) => {
return {
...item,
value: fieldForm.value.enableOptionKey ? item.value : getGenerateId(),
const currentItem: FieldOptions = {
text: item.text,
value: item.value ? item.value : getGenerateId(),
};
if (item.fieldId) {
currentItem.fieldId = item.fieldId;
}
return currentItem;
});
}
await cb();

View File

@ -74,9 +74,12 @@
:ok-text="t('system.orgTemplate.confirm')"
@confirm="handleOk(record)"
>
<MsButton v-permission="props.updatePermission" :disabled="record.internal" class="!mr-0">{{
t('system.orgTemplate.edit')
}}</MsButton></MsPopConfirm
<MsButton
v-if="!record.internal && hasAnyPermission(props.updatePermission)"
:disabled="record.internal"
class="!mr-0"
>{{ t('system.orgTemplate.edit') }}</MsButton
></MsPopConfirm
>
<a-divider v-if="!record.internal" class="h-[12px]" direction="vertical" />

View File

@ -54,7 +54,7 @@
>{{ t('system.orgTemplate.copy') }}</MsButton
>
<a-divider
v-if="!record.internal"
v-if="hasAnyPermission(['ORGANIZATION_TEMPLATE:READ+ADD']) && !record.internal"
v-permission="['ORGANIZATION_TEMPLATE:READ+ADD']"
class="h-[12px]"
direction="vertical"