| | |
| | | const CONFIG_TYPE_OPTIONS = [ |
| | | { label: 'boolean', value: 1 }, |
| | | { label: 'number', value: 2 }, |
| | | { label: 'string', value: 3 }, |
| | | { label: 'json', value: 4 }, |
| | | { label: 'date', value: 5 } |
| | | { labelKey: 'pages.system.config.types.boolean', fallback: 'boolean', value: 1 }, |
| | | { labelKey: 'pages.system.config.types.number', fallback: 'number', value: 2 }, |
| | | { labelKey: 'pages.system.config.types.string', fallback: 'string', value: 3 }, |
| | | { labelKey: 'pages.system.config.types.json', fallback: 'json', value: 4 }, |
| | | { labelKey: 'pages.system.config.types.date', fallback: 'date', value: 5 } |
| | | ] |
| | | |
| | | export function createConfigSearchState() { |
| | |
| | | } |
| | | } |
| | | |
| | | export function getConfigTypeOptions() { |
| | | return CONFIG_TYPE_OPTIONS |
| | | export function getConfigTypeOptions(t) { |
| | | return CONFIG_TYPE_OPTIONS.map((item) => ({ |
| | | label: typeof t === 'function' ? t(item.labelKey) : item.fallback, |
| | | value: item.value |
| | | })) |
| | | } |
| | | |
| | | export function getConfigTypeMeta(type) { |
| | | const normalizedType = Number(type) |
| | | return CONFIG_TYPE_OPTIONS.find((item) => item.value === normalizedType) || { label: '-', value: normalizedType || '' } |
| | | return ( |
| | | CONFIG_TYPE_OPTIONS.find((item) => item.value === normalizedType) || { |
| | | labelKey: 'common.placeholder.empty', |
| | | fallback: '--', |
| | | value: normalizedType || '' |
| | | } |
| | | ) |
| | | } |
| | | |
| | | export function getConfigStatusMeta(status) { |
| | | return Number(status) === 1 |
| | | ? { text: '正常', type: 'success', bool: true } |
| | | : { text: '冻结', type: 'danger', bool: false } |
| | | ? { textKey: 'common.status.normal', fallback: 'Normal', type: 'success', bool: true } |
| | | : { textKey: 'common.status.frozen', fallback: 'Frozen', type: 'danger', bool: false } |
| | | } |
| | | |
| | | export function buildConfigSearchParams(params = {}) { |
| | |
| | | } |
| | | |
| | | export function normalizeConfigListRow(record = {}) { |
| | | const typeMeta = getConfigTypeMeta(record.type) |
| | | const statusMeta = getConfigStatusMeta(record.status) |
| | | return { |
| | | ...record, |
| | |
| | | val: record.val || '', |
| | | content: record.content || '', |
| | | memo: record.memo || '', |
| | | typeText: record['type$'] || getConfigTypeMeta(record.type).label, |
| | | statusText: record['status$'] || statusMeta.text, |
| | | typeTextKey: typeMeta.labelKey, |
| | | typeText: typeMeta.fallback, |
| | | statusTextKey: statusMeta.textKey, |
| | | statusText: statusMeta.fallback, |
| | | statusType: statusMeta.type, |
| | | statusBool: record.statusBool ?? statusMeta.bool, |
| | | updateTimeText: record['updateTime$'] || record.updateTime || '', |