zhou zhou
11 小时以前 50e95b985a72fcec4a93a2470e9efdfb2620148a
rsf-design/src/views/system/config/configPage.helpers.js
@@ -1,9 +1,9 @@
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() {
@@ -36,19 +36,28 @@
  }
}
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 = {}) {
@@ -100,6 +109,7 @@
}
export function normalizeConfigListRow(record = {}) {
  const typeMeta = getConfigTypeMeta(record.type)
  const statusMeta = getConfigStatusMeta(record.status)
  return {
    ...record,
@@ -109,8 +119,10 @@
    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 || '',