zhou zhou
16 小时以前 50e95b985a72fcec4a93a2470e9efdfb2620148a
rsf-design/src/views/basic-info/warehouse-areas/warehouseAreasPage.helpers.js
@@ -1,9 +1,11 @@
const STATUS_META = {
  1: { text: '正常', type: 'success', bool: true },
  0: { text: '冻结', type: 'danger', bool: false }
  1: { textKey: 'common.status.normal', fallback: 'Normal', type: 'success', bool: true },
  0: { textKey: 'common.status.frozen', fallback: 'Frozen', type: 'danger', bool: false }
}
export const WAREHOUSE_AREAS_REPORT_TITLE = '库区报表'
export function getWarehouseAreasReportTitle(t) {
  return t('pages.basicInfo.warehouseAreas.reportTitle')
}
export const WAREHOUSE_AREAS_REPORT_STYLE = {
  titleAlign: 'center',
  titleLevel: 'strong',
@@ -16,14 +18,14 @@
  return String(value ?? '').trim()
}
function normalizeFlagText(value) {
  if (value === 1 || value === '1' || value === true || value === '是') {
    return '是'
function normalizeFlagValue(value) {
  if (value === 1 || value === '1' || value === true || value === '\u662f') {
    return 1
  }
  if (value === 0 || value === '0' || value === false || value === '否') {
    return '否'
  if (value === 0 || value === '0' || value === false || value === '\u5426') {
    return 0
  }
  return normalizeText(value) || '-'
  return null
}
export function createWarehouseAreasSearchState() {
@@ -65,17 +67,17 @@
  }
}
export function getWarehouseAreasStatusOptions() {
export function getWarehouseAreasStatusOptions(t) {
  return [
    { label: '正常', value: 1 },
    { label: '冻结', value: 0 }
    { label: t('common.status.normal'), value: 1 },
    { label: t('common.status.frozen'), value: 0 }
  ]
}
export function getWarehouseAreasFlagOptions() {
export function getWarehouseAreasFlagOptions(t) {
  return [
    { label: '否', value: 0 },
    { label: '是', value: 1 }
    { label: t('common.status.no'), value: 0 },
    { label: t('common.status.yes'), value: 1 }
  ]
}
@@ -190,11 +192,14 @@
  if (status === false || Number(status) === 0) {
    return STATUS_META[0]
  }
  return { text: '未知', type: 'info', bool: false }
  return { textKey: 'common.status.unknown', fallback: 'Unknown', type: 'info', bool: false }
}
export function normalizeWarehouseAreasDetailRecord(record = {}) {
  const statusMeta = getWarehouseAreasStatusMeta(record.statusBool ?? record.status)
  const flagMinusValue = normalizeFlagValue(record.flagMinus$ ?? record.flagMinus)
  const flagLabelManageValue = normalizeFlagValue(record.flagLabelMange$ ?? record.flagLabelMange)
  const flagMixValue = normalizeFlagValue(record.flagMix$ ?? record.flagMix)
  return {
    ...record,
    warehouseName: normalizeText(record.warehouseId$ || record.warehouseName || ''),
@@ -204,10 +209,16 @@
    code: normalizeText(record.code || ''),
    name: normalizeText(record.name || ''),
    memo: normalizeText(record.memo || ''),
    flagMinusText: normalizeFlagText(record.flagMinus$ ?? record.flagMinus),
    flagLabelMangeText: normalizeFlagText(record.flagLabelMange$ ?? record.flagLabelMange),
    flagMixText: normalizeFlagText(record.flagMix$ ?? record.flagMix),
    statusText: statusMeta.text,
    flagMinusText: normalizeText(record.flagMinus$ ?? record.flagMinus) || '-',
    flagMinusTextKey:
      flagMinusValue === null ? '' : flagMinusValue ? 'common.status.yes' : 'common.status.no',
    flagLabelMangeText: normalizeText(record.flagLabelMange$ ?? record.flagLabelMange) || '-',
    flagLabelMangeTextKey:
      flagLabelManageValue === null ? '' : flagLabelManageValue ? 'common.status.yes' : 'common.status.no',
    flagMixText: normalizeText(record.flagMix$ ?? record.flagMix) || '-',
    flagMixTextKey: flagMixValue === null ? '' : flagMixValue ? 'common.status.yes' : 'common.status.no',
    statusText: statusMeta.fallback,
    statusTextKey: statusMeta.textKey,
    statusType: statusMeta.type,
    statusBool: record.statusBool !== void 0 ? Boolean(record.statusBool) : statusMeta.bool,
    createByText: normalizeText(record.createBy$ || record.createByText || ''),
@@ -227,4 +238,3 @@
  }
  return records.map((record) => normalizeWarehouseAreasListRow(record))
}