feat: 完成前端业务闭环与后端联调
This commit is contained in:
@@ -6,10 +6,34 @@ import {
|
||||
} from './response-normalizers.js'
|
||||
|
||||
const supportedDictionaryTypes = new Set([
|
||||
'gen_parent_relationship_variant',
|
||||
'gen_education_type',
|
||||
'gen_death_expression',
|
||||
'gen_spouse_relationship_variant',
|
||||
'gen_ceremony_type',
|
||||
'gen_growth_record_type'
|
||||
'gen_person_document_type',
|
||||
'gen_growth_record_type',
|
||||
'gen_merit_type',
|
||||
'gen_feedback_type',
|
||||
'gen_zodiac'
|
||||
])
|
||||
|
||||
const optionStates = new Set(['ACTIVE', 'DISABLED', 'UNKNOWN'])
|
||||
|
||||
export const normalizeBusinessOptionProjection = (value, label, state, subject, errorCode) => {
|
||||
const optionValue = normalizeResponseText(value, `${subject}编码`)
|
||||
const optionLabel = normalizeResponseText(label, `${subject}名称`)
|
||||
const optionState = normalizeResponseText(state, `${subject}状态`)
|
||||
if (optionValue && !optionStates.has(optionState)) {
|
||||
throw createRequestError(`${subject}历史值状态无效`, errorCode)
|
||||
}
|
||||
return {
|
||||
value: optionValue,
|
||||
label: optionLabel || optionValue,
|
||||
state: optionValue ? optionState : ''
|
||||
}
|
||||
}
|
||||
|
||||
export const normalizeBusinessDictionaryType = (dictType) => {
|
||||
if (!supportedDictionaryTypes.has(dictType)) {
|
||||
throw new TypeError('当前页面不支持该业务字典')
|
||||
@@ -27,6 +51,9 @@ export const normalizeBusinessDictionaryOptions = (dictType, value) => {
|
||||
if (!item || typeof item !== 'object' || Array.isArray(item)) {
|
||||
throw createRequestError('业务字典响应包含无效条目', 'BUSINESS_DICTIONARY_RESPONSE_INVALID')
|
||||
}
|
||||
if (item.enabled !== true) {
|
||||
throw createRequestError('业务字典选择接口返回了不可选项', 'BUSINESS_DICTIONARY_RESPONSE_INVALID')
|
||||
}
|
||||
const optionValue = normalizeResponseText(item.value, 'value')
|
||||
const label = normalizeResponseText(item.label, 'label')
|
||||
if (!optionValue || !label || values.has(optionValue)) {
|
||||
@@ -38,7 +65,8 @@ export const normalizeBusinessDictionaryOptions = (dictType, value) => {
|
||||
value: optionValue,
|
||||
label,
|
||||
sort: normalizeOptionalNonnegativeInteger(item.sort, '业务字典排序值', 'BUSINESS_DICTIONARY_RESPONSE_INVALID'),
|
||||
default: item.default === true
|
||||
default: item.default === true,
|
||||
enabled: true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user