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