fix(项目管理): 缺陷模板多选字段默认值保存后有误

--bug=1046409 --user=宋昌昌 【项目管理】编辑缺陷模版-多值输入类型字段-编辑后保存无效 https://www.tapd.cn/55049933/s/1578713
This commit is contained in:
song-cc-rock 2024-09-14 14:25:23 +08:00 committed by Craftsman
parent 3baf12d0e0
commit 3497df836f
3 changed files with 26 additions and 24 deletions

View File

@ -184,7 +184,6 @@
</template>
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { Message } from '@arco-design/web-vue';
import MsButton from '@/components/pure/ms-button/index.vue';
@ -387,7 +386,7 @@
formRules.value = [];
if (Array.isArray(arr) && arr.length) {
formRules.value = arr.map((item: any) => {
const initOptions = item.options || JSON.parse(item.platformOptionJson || '{}');
const initOptions = item.options || JSON.parse(item.platformOptionJson || '[]');
const initValue = getInitValue(item, initOptions);
return {
type: item.type,

View File

@ -601,7 +601,7 @@
return customFields.map((item: any) => {
const currentFormRules = FieldTypeFormRules[item.type];
let selectOptions: any = [];
const multipleType = ['MULTIPLE_SELECT', 'CHECKBOX', 'MULTIPLE_MEMBER', 'MULTIPLE_INPUT'];
const multipleType = ['MULTIPLE_SELECT', 'CHECKBOX', 'MULTIPLE_MEMBER'];
if (item.options && item.options.length) {
selectOptions = item.options.map((optionItem: any) => {
return {

View File

@ -306,14 +306,15 @@ export const getTotalFieldOptionList = (totalData: DefinedFieldItem[]) => {
*/
export const getCustomDetailFields = (totalData: DefinedFieldItem[], customFields: CustomField[]) => {
const customFieldsIds = customFields.map((index: any) => index.fieldId);
return totalData.filter((item) => {
const currentCustomFieldIndex = customFieldsIds.findIndex((it: any) => it === item.id);
return totalData
.filter((item) => {
const index = customFieldsIds.findIndex((it: any) => it === item.id);
if (customFieldsIds.indexOf(item.id) > -1) {
const currentForm = item.formRules?.map((it: any) => {
it.props.modelValue = customFields[currentCustomFieldIndex].defaultValue;
it.props.modelValue = customFields[index].defaultValue;
return {
...it,
value: customFields[currentCustomFieldIndex].defaultValue,
value: customFields[index].defaultValue,
effect: {
required: item.required,
},
@ -321,12 +322,14 @@ export const getCustomDetailFields = (totalData: DefinedFieldItem[], customField
});
const formItem = item;
formItem.formRules = cloneDeep(currentForm);
formItem.apiFieldId = customFields[currentCustomFieldIndex].apiFieldId;
formItem.required = customFields[currentCustomFieldIndex].required;
formItem.apiFieldId = customFields[index].apiFieldId;
formItem.required = customFields[index].required;
formItem.index = index;
return true;
}
return false;
});
})
.sort((f1, f2) => f1.index - f2.index);
};
export default {};