From 50e95b985a72fcec4a93a2470e9efdfb2620148a Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期四, 02 四月 2026 15:46:09 +0800
Subject: [PATCH] #i18n
---
rsf-design/src/views/basic-info/bas-station-area/basStationAreaPage.helpers.js | 126 ++++++++++++++++++++----------------------
1 files changed, 60 insertions(+), 66 deletions(-)
diff --git a/rsf-design/src/views/basic-info/bas-station-area/basStationAreaPage.helpers.js b/rsf-design/src/views/basic-info/bas-station-area/basStationAreaPage.helpers.js
index d6b337f..b3046db 100644
--- a/rsf-design/src/views/basic-info/bas-station-area/basStationAreaPage.helpers.js
+++ b/rsf-design/src/views/basic-info/bas-station-area/basStationAreaPage.helpers.js
@@ -1,32 +1,21 @@
import { $t } from '@/locales'
-const STATUS_META = {
- 1: { text: $t('common.status.normal'), type: 'success', bool: true },
- 0: { text: $t('common.status.frozen'), type: 'danger', bool: false }
-}
-
-const TYPE_OPTIONS = [
- { label: $t('pages.basicInfo.basStationArea.type.smart'), value: 0 },
- { label: $t('pages.basicInfo.basStationArea.type.normal'), value: 1 }
-]
-
-const BINARY_OPTIONS = [
- { label: $t('common.status.no'), value: 0 },
- { label: $t('common.status.yes'), value: 1 }
-]
-
-const STATUS_OPTIONS = [
- { label: $t('common.status.normal'), value: 1 },
- { label: $t('common.status.frozen'), value: 0 }
-]
-
-export const BAS_STATION_AREA_REPORT_TITLE = $t('pages.basicInfo.basStationArea.reportTitle')
export const BAS_STATION_AREA_REPORT_STYLE = {
titleAlign: 'center',
titleLevel: 'strong',
orientation: 'portrait',
density: 'compact',
showSequence: true
+}
+
+function getStatusMeta(status, t = $t) {
+ if (status === true || Number(status) === 1) {
+ return { text: t('common.status.normal'), type: 'success', bool: true }
+ }
+ if (status === false || Number(status) === 0) {
+ return { text: t('common.status.frozen'), type: 'danger', bool: false }
+ }
+ return { text: t('common.status.unknown'), type: 'info', bool: false }
}
function normalizeText(value) {
@@ -41,14 +30,14 @@
return Number.isNaN(parsed) ? fallback : parsed
}
-function normalizeBooleanText(value) {
- if (value === 1 || value === '1' || value === true || value === $t('common.status.yes')) {
- return $t('common.status.yes')
+function normalizeBooleanText(value, t = $t) {
+ if (value === 1 || value === '1' || value === true || value === t('common.status.yes')) {
+ return t('common.status.yes')
}
- if (value === 0 || value === '0' || value === false || value === $t('common.status.no')) {
- return $t('common.status.no')
+ if (value === 0 || value === '0' || value === false || value === t('common.status.no')) {
+ return t('common.status.no')
}
- return normalizeText(value) || $t('common.placeholder.empty')
+ return normalizeText(value) || t('common.placeholder.empty')
}
function normalizeIdArray(values = []) {
@@ -94,16 +83,6 @@
.filter(Boolean)
return labels.length ? labels.join($t('common.listSeparator')) : $t('common.placeholder.empty')
-}
-
-function getStatusMeta(status) {
- if (status === true || Number(status) === 1) {
- return STATUS_META[1]
- }
- if (status === false || Number(status) === 0) {
- return STATUS_META[0]
- }
- return { text: $t('common.status.unknown'), type: 'info', bool: false }
}
export function createBasStationAreaSearchState() {
@@ -161,16 +140,29 @@
}
}
-export function getBasStationAreaTypeOptions() {
- return TYPE_OPTIONS
+export function getBasStationAreaReportTitle(t = $t) {
+ return t('pages.basicInfo.basStationArea.reportTitle')
}
-export function getBasStationAreaBinaryOptions() {
- return BINARY_OPTIONS
+export function getBasStationAreaTypeOptions(t = $t) {
+ return [
+ { label: t('pages.basicInfo.basStationArea.type.smart'), value: 0 },
+ { label: t('pages.basicInfo.basStationArea.type.normal'), value: 1 }
+ ]
}
-export function getBasStationAreaStatusOptions() {
- return STATUS_OPTIONS
+export function getBasStationAreaBinaryOptions(t = $t) {
+ return [
+ { label: t('common.status.no'), value: 0 },
+ { label: t('common.status.yes'), value: 1 }
+ ]
+}
+
+export function getBasStationAreaStatusOptions(t = $t) {
+ return [
+ { label: t('common.status.normal'), value: 1 },
+ { label: t('common.status.frozen'), value: 0 }
+ ]
}
export function resolveBasStationAreaWarehouseAreaOptions(records = []) {
@@ -417,7 +409,8 @@
}
export function normalizeBasStationAreaDetailRecord(record = {}, resolvers = {}) {
- const statusMeta = getStatusMeta(record.statusBool ?? record.status)
+ const t = resolvers.t || $t
+ const statusMeta = getStatusMeta(record.statusBool ?? record.status, t)
const typeValue = record.type$ ?? record.type
const areaId = record.area ?? record.areaId ?? record.area$
const crossZoneAreaIds = normalizeIdArray(record.crossZoneArea)
@@ -428,54 +421,54 @@
return {
...record,
id: normalizeIdValue(record.id),
- stationAreaName: normalizeText(record.stationAreaName) || $t('common.placeholder.empty'),
- stationAreaId: normalizeText(record.stationAreaId) || $t('common.placeholder.empty'),
+ stationAreaName: normalizeText(record.stationAreaName) || t('common.placeholder.empty'),
+ stationAreaId: normalizeText(record.stationAreaId) || t('common.placeholder.empty'),
type: normalizeIdValue(record.type),
typeText: normalizeText(
record.type$ || record.typeText || resolvers.resolveTypeLabel?.(typeValue) || typeValue
- ) || $t('common.placeholder.empty'),
+ ) || t('common.placeholder.empty'),
inAble: normalizeIdValue(record.inAble),
- inAbleText: normalizeBooleanText(record.inAble),
+ inAbleText: normalizeBooleanText(record.inAble, t),
outAble: normalizeIdValue(record.outAble),
- outAbleText: normalizeBooleanText(record.outAble),
+ outAbleText: normalizeBooleanText(record.outAble, t),
useStatus: normalizeText(record.useStatus),
useStatusText:
normalizeText(record.useStatus$ || record.useStatusText || resolvers.resolveUseStatusLabel?.(record.useStatus) || record.useStatus) ||
- $t('common.placeholder.empty'),
+ t('common.placeholder.empty'),
area: normalizeIdValue(areaId),
- areaText: normalizeText(record.area$ || record.areaText || resolvers.resolveAreaLabel?.(areaId) || '') || $t('common.placeholder.empty'),
+ areaText: normalizeText(record.area$ || record.areaText || resolvers.resolveAreaLabel?.(areaId) || '') || t('common.placeholder.empty'),
isCrossZone: normalizeIdValue(record.isCrossZone),
- isCrossZoneText: normalizeBooleanText(record.isCrossZone),
+ isCrossZoneText: normalizeBooleanText(record.isCrossZone, t),
crossZoneArea: crossZoneAreaIds,
crossZoneAreaText:
resolveOptionText(crossZoneAreaIds, resolvers.resolveCrossZoneAreaLabel, record.crossZoneAreaText || []) ||
- $t('common.placeholder.empty'),
+ t('common.placeholder.empty'),
isWcs: normalizeIdValue(record.isWcs),
- isWcsText: normalizeBooleanText(record.isWcs),
- wcsData: normalizeText(record.wcsData) || $t('common.placeholder.empty'),
+ isWcsText: normalizeBooleanText(record.isWcs, t),
+ wcsData: normalizeText(record.wcsData) || t('common.placeholder.empty'),
containerType: containerTypeIds,
containerTypeText:
resolveOptionText(containerTypeIds, resolvers.resolveContainerTypeLabel, record.containerTypesText || []) ||
- $t('common.placeholder.empty'),
- barcode: normalizeText(record.barcode) || $t('common.placeholder.empty'),
+ t('common.placeholder.empty'),
+ barcode: normalizeText(record.barcode) || t('common.placeholder.empty'),
autoTransfer: normalizeIdValue(record.autoTransfer),
- autoTransferText: normalizeBooleanText(record.autoTransfer),
+ autoTransferText: normalizeBooleanText(record.autoTransfer, t),
stationAlias: stationAliasIds,
stationAliasText:
resolveOptionText(
stationAliasIds,
resolvers.resolveStationAliasLabel,
stationAliasNames.length ? stationAliasNames : record.stationAliasText || []
- ) || $t('common.placeholder.empty'),
+ ) || t('common.placeholder.empty'),
status: normalizeIdValue(record.status),
statusText: statusMeta.text,
statusType: statusMeta.type,
statusBool: record.statusBool !== void 0 ? Boolean(record.statusBool) : statusMeta.bool,
- memo: normalizeText(record.memo) || $t('common.placeholder.empty'),
- createByText: normalizeText(record.createBy$ || record.createByText || '') || $t('common.placeholder.empty'),
- createTimeText: normalizeText(record.createTime$ || record.createTime || '') || $t('common.placeholder.empty'),
- updateByText: normalizeText(record.updateBy$ || record.updateByText || '') || $t('common.placeholder.empty'),
- updateTimeText: normalizeText(record.updateTime$ || record.updateTime || '') || $t('common.placeholder.empty')
+ memo: normalizeText(record.memo) || t('common.placeholder.empty'),
+ createByText: normalizeText(record.createBy$ || record.createByText || '') || t('common.placeholder.empty'),
+ createTimeText: normalizeText(record.createTime$ || record.createTime || '') || t('common.placeholder.empty'),
+ updateByText: normalizeText(record.updateBy$ || record.updateByText || '') || t('common.placeholder.empty'),
+ updateTimeText: normalizeText(record.updateTime$ || record.updateTime || '') || t('common.placeholder.empty')
}
}
@@ -493,10 +486,11 @@
export function buildBasStationAreaReportMeta({
previewMeta = {},
count = 0,
- orientation = BAS_STATION_AREA_REPORT_STYLE.orientation
+ orientation = BAS_STATION_AREA_REPORT_STYLE.orientation,
+ t = $t
} = {}) {
return {
- reportTitle: BAS_STATION_AREA_REPORT_TITLE,
+ reportTitle: getBasStationAreaReportTitle(t),
reportDate: previewMeta.reportDate,
printedAt: previewMeta.printedAt,
operator: previewMeta.operator,
--
Gitblit v1.9.1