26 lines
950 B
JavaScript
26 lines
950 B
JavaScript
import { hasRemoteConfig } from '@/utils/runtime-config.js'
|
|
import {
|
|
normalizeBusinessDictionaryOptions,
|
|
normalizeBusinessDictionaryType
|
|
} from './business-dictionary-contract.js'
|
|
import { createRequestError, requestStrict } from './request-client.js'
|
|
|
|
export const businessDictionaryApi = {
|
|
async getBusinessDictionaryOptions(dictType, requestOptions = {}) {
|
|
const normalizedType = normalizeBusinessDictionaryType(dictType)
|
|
if (!hasRemoteConfig()) {
|
|
throw createRequestError(
|
|
'业务字典读取需要真实服务,当前本地预览不会伪造结果',
|
|
'REMOTE_READ_REQUIRED'
|
|
)
|
|
}
|
|
const dictionaryOptions = await requestStrict({
|
|
url: `/genealogy/app/dictionaries/${encodeURIComponent(normalizedType)}`,
|
|
method: 'GET'
|
|
}, {
|
|
requestController: requestOptions.requestController ?? null
|
|
})
|
|
return normalizeBusinessDictionaryOptions(normalizedType, dictionaryOptions)
|
|
}
|
|
}
|