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> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useRoute } from 'vue-router';
import { Message } from '@arco-design/web-vue'; import { Message } from '@arco-design/web-vue';
import MsButton from '@/components/pure/ms-button/index.vue'; import MsButton from '@/components/pure/ms-button/index.vue';
@ -387,7 +386,7 @@
formRules.value = []; formRules.value = [];
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 || '[]');
const initValue = getInitValue(item, initOptions); const initValue = getInitValue(item, initOptions);
return { return {
type: item.type, type: item.type,

View File

@ -601,7 +601,7 @@
return customFields.map((item: any) => { return customFields.map((item: any) => {
const currentFormRules = FieldTypeFormRules[item.type]; const currentFormRules = FieldTypeFormRules[item.type];
let selectOptions: any = []; 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) { if (item.options && item.options.length) {
selectOptions = item.options.map((optionItem: any) => { selectOptions = item.options.map((optionItem: any) => {
return { return {

View File

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