feat(缺陷管理): 缺陷管理自定义字段增加文本入参
This commit is contained in:
parent
d34d149eb3
commit
7b13836e80
|
@ -50,6 +50,8 @@ export interface BugEditCustomField {
|
|||
options?: any[];
|
||||
defaultValue: string;
|
||||
platformSystemField: boolean;
|
||||
sourceType?: string;
|
||||
field?: string;
|
||||
}
|
||||
export interface BugEditFormObject {
|
||||
[key: string]: any;
|
||||
|
@ -59,6 +61,7 @@ export interface BugEditCustomFieldItem {
|
|||
name: string;
|
||||
type: string | undefined;
|
||||
value: string;
|
||||
text?: string[] | null; // 消息通知文本提示
|
||||
}
|
||||
export type BugBatchUpdateFiledType = 'single_select' | 'multiple_select' | 'tags' | 'input' | 'user_selector' | 'date';
|
||||
export interface BugBatchUpdateFiledForm {
|
||||
|
|
|
@ -63,9 +63,9 @@
|
|||
import { useAppStore } from '@/store';
|
||||
import { hasAnyPermission } from '@/utils/permission';
|
||||
|
||||
import { BugEditCustomField, BugEditFormObject } from '@/models/bug-management';
|
||||
import { BugEditCustomField, BugEditFormObject, type CustomFieldItem } from '@/models/bug-management';
|
||||
|
||||
import { makeCustomFieldsParams } from '../utils';
|
||||
import { getCurrentText, makeCustomFieldsParams } from '../utils';
|
||||
|
||||
const appStore = useAppStore();
|
||||
|
||||
|
@ -77,6 +77,7 @@
|
|||
formRule: FormItem[];
|
||||
isPlatformDefaultTemplate: boolean;
|
||||
platformSystemFields: BugEditCustomField[]; // 平台系统字段
|
||||
currentCustomFields: CustomFieldItem[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
@ -118,7 +119,7 @@
|
|||
};
|
||||
|
||||
async function makeParams() {
|
||||
const customFields = await makeCustomFieldsParams(innerFormItem.value);
|
||||
const customFields = await makeCustomFieldsParams(innerFormItem.value, props.currentCustomFields);
|
||||
if (props.isPlatformDefaultTemplate) {
|
||||
// 平台系统默认字段插入自定义集合
|
||||
props.platformSystemFields.forEach((item) => {
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
v-model:tags="tags"
|
||||
:form-rule="formRules"
|
||||
:detail="detailInfo"
|
||||
:current-custom-fields="currentCustomFields"
|
||||
:current-platform="props.currentPlatform"
|
||||
:is-platform-default-template="isPlatformDefaultTemplate"
|
||||
:loading="rightLoading"
|
||||
|
|
|
@ -276,7 +276,7 @@
|
|||
import { AssociatedList, AttachFileInfo } from '@/models/caseManagement/featureCase';
|
||||
import { TableQueryParams } from '@/models/common';
|
||||
|
||||
import { convertToFileByBug } from '@/views/bug-management/utils';
|
||||
import { convertToFileByBug, getCurrentText } from '@/views/bug-management/utils';
|
||||
|
||||
defineOptions({
|
||||
name: 'BugDetailTab',
|
||||
|
@ -499,7 +499,7 @@
|
|||
id: field.fieldId,
|
||||
name: field.fieldName,
|
||||
type: field.type,
|
||||
value: field.fieldId === 'status' ? props.detailInfo.status : filterField.value,
|
||||
value: field.fieldId === 'status' ? props.detailInfo.status : filterField?.value,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -508,8 +508,13 @@
|
|||
async function handleSave() {
|
||||
try {
|
||||
confirmLoading.value = true;
|
||||
const customFields: BugEditCustomFieldItem[] = getDetailCustomFields();
|
||||
console.log(customFields);
|
||||
let customFields: BugEditCustomFieldItem[] = getDetailCustomFields();
|
||||
customFields = customFields.map((e: any) => {
|
||||
return {
|
||||
...e,
|
||||
text: getCurrentText(e, props.currentCustomFields, 'id'),
|
||||
};
|
||||
});
|
||||
if (props.isPlatformDefaultTemplate) {
|
||||
// 平台系统默认字段插入自定义集合
|
||||
props.platformSystemFields.forEach((item) => {
|
||||
|
|
|
@ -260,7 +260,7 @@
|
|||
import { CaseLinkEnum } from '@/enums/caseEnum';
|
||||
|
||||
import { convertToFile } from '../case-management/caseManagementFeature/components/utils';
|
||||
import { convertToFileByBug, getDefaultMemberValue } from './utils';
|
||||
import { convertToFileByBug, getCurrentText, getDefaultMemberValue } from './utils';
|
||||
import { getCaseTemplateContent } from '@/views/case-management/components/addDefectDrawer/utils';
|
||||
|
||||
const props = defineProps<{
|
||||
|
@ -413,7 +413,6 @@
|
|||
// 处理表单格式
|
||||
const getFormRules = (arr: BugEditCustomField[]) => {
|
||||
formRules.value = [];
|
||||
console.log(arr);
|
||||
if (Array.isArray(arr) && arr.length) {
|
||||
formRules.value = arr.map((item: any) => {
|
||||
const initOptions = item.options || JSON.parse(item.platformOptionJson || '[]');
|
||||
|
@ -581,6 +580,7 @@
|
|||
name: item.title as string,
|
||||
type: item.sourceType as string,
|
||||
value: Array.isArray(item.value) ? JSON.stringify(item.value) : (item.value as string),
|
||||
text: getCurrentText(item, currentCustomFields.value),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import { MsFileItem } from '@/components/pure/ms-upload/types';
|
|||
import useUserStore from '@/store/modules/user';
|
||||
import { findParents, Option } from '@/utils/recursion';
|
||||
|
||||
import { BugEditCustomFieldItem } from '@/models/bug-management';
|
||||
import { BugEditCustomFieldItem, type CustomFieldItem } from '@/models/bug-management';
|
||||
import { AssociatedList } from '@/models/caseManagement/featureCase';
|
||||
import type { DetailCustomField, FieldOptions } from '@/models/setting/template';
|
||||
|
||||
|
@ -77,7 +77,23 @@ export function convertToFileByDetail(fileInfo: AssociatedList): MsFileItem {
|
|||
};
|
||||
}
|
||||
|
||||
export function makeCustomFieldsParams(formItem: FormRuleItem[]) {
|
||||
// 选项所选文本入参
|
||||
export function getCurrentText(item: FormRuleItem, currentCustomFields: CustomFieldItem[], idKey = 'field') {
|
||||
const textType = ['SELECT', 'MULTIPLE_SELECT', 'RADIO', 'CHECKBOX', 'MEMBER', 'MULTIPLE_MEMBER'];
|
||||
|
||||
if ((item.sourceType && textType.includes(item.sourceType)) || (item.type && textType.includes(item.type))) {
|
||||
const currentItemOptions = currentCustomFields.find((e: any) => e.fieldId === item[idKey])?.options || [];
|
||||
const filteredOptions = Array.isArray(item.value)
|
||||
? currentItemOptions.filter((e: any) => (item.value as string[]).includes(e.value))
|
||||
: currentItemOptions.filter((e: any) => e.value === item.value);
|
||||
const optionText = filteredOptions.map((option) => option.text);
|
||||
|
||||
return optionText;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function makeCustomFieldsParams(formItem: FormRuleItem[], currentCustomFields: CustomFieldItem[]) {
|
||||
const customFields: BugEditCustomFieldItem[] = [];
|
||||
if (formItem && formItem.length) {
|
||||
formItem.forEach((item: FormRuleItem) => {
|
||||
|
@ -90,6 +106,7 @@ export function makeCustomFieldsParams(formItem: FormRuleItem[]) {
|
|||
name: item.title as string,
|
||||
type: item.sourceType as string,
|
||||
value: Array.isArray(itemVal) ? JSON.stringify(itemVal) : (itemVal as string),
|
||||
text: getCurrentText(item, currentCustomFields),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue