const STATUS_META = {
|
1: { text: '正常', type: 'success', bool: true },
|
0: { text: '冻结', type: 'danger', bool: false }
|
}
|
|
const TYPE_OPTIONS = [
|
{ label: '智能站点', value: 0 },
|
{ label: '普通站点', value: 1 }
|
]
|
|
const BINARY_OPTIONS = [
|
{ label: '否', value: 0 },
|
{ label: '是', value: 1 }
|
]
|
|
const STATUS_OPTIONS = [
|
{ label: '正常', value: 1 },
|
{ label: '冻结', value: 0 }
|
]
|
|
export const BAS_STATION_AREA_REPORT_TITLE = '站点区域报表'
|
export const BAS_STATION_AREA_REPORT_STYLE = {
|
titleAlign: 'center',
|
titleLevel: 'strong',
|
orientation: 'portrait',
|
density: 'compact',
|
showSequence: true
|
}
|
|
function normalizeText(value) {
|
return String(value ?? '').trim()
|
}
|
|
function normalizeNumber(value, fallback = void 0) {
|
if (value === '' || value === null || value === undefined) {
|
return fallback
|
}
|
const parsed = Number(value)
|
return Number.isNaN(parsed) ? fallback : parsed
|
}
|
|
function normalizeBooleanText(value) {
|
if (value === 1 || value === '1' || value === true || value === '是') {
|
return '是'
|
}
|
if (value === 0 || value === '0' || value === false || value === '否') {
|
return '否'
|
}
|
return normalizeText(value) || '--'
|
}
|
|
function normalizeIdArray(values = []) {
|
if (Array.isArray(values)) {
|
return values
|
.map((item) => normalizeNumber(item, void 0))
|
.filter((item) => item !== void 0 && item !== null)
|
}
|
|
if (typeof values === 'string' && values.trim()) {
|
return values
|
.split(',')
|
.map((item) => normalizeNumber(item, void 0))
|
.filter((item) => item !== void 0 && item !== null)
|
}
|
|
return []
|
}
|
|
function normalizeStringArray(values = []) {
|
if (Array.isArray(values)) {
|
return values.map((item) => normalizeText(item)).filter(Boolean)
|
}
|
|
if (typeof values === 'string' && values.trim()) {
|
return values
|
.split(',')
|
.map((item) => normalizeText(item))
|
.filter(Boolean)
|
}
|
|
return []
|
}
|
|
function buildJoinedText(values = [], resolver) {
|
const labels = values
|
.map((value) => {
|
if (typeof resolver === 'function') {
|
return normalizeText(resolver(value))
|
}
|
return normalizeText(value)
|
})
|
.filter(Boolean)
|
|
return labels.length ? labels.join('、') : '--'
|
}
|
|
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: '未知', type: 'info', bool: false }
|
}
|
|
export function createBasStationAreaSearchState() {
|
return {
|
condition: '',
|
stationAreaName: '',
|
stationAreaId: '',
|
type: '',
|
inAble: '',
|
outAble: '',
|
useStatus: '',
|
area: '',
|
isCrossZone: '',
|
crossZoneArea: '',
|
isWcs: '',
|
wcsData: '',
|
containerType: '',
|
barcode: '',
|
autoTransfer: '',
|
stationAlias: '',
|
memo: '',
|
status: ''
|
}
|
}
|
|
export function createBasStationAreaFormState() {
|
return {
|
id: void 0,
|
stationAreaName: '',
|
stationAreaId: '',
|
type: void 0,
|
inAble: 0,
|
outAble: 0,
|
useStatus: '',
|
area: void 0,
|
isCrossZone: 0,
|
crossZoneArea: [],
|
isWcs: 0,
|
wcsData: '',
|
containerType: [],
|
barcode: '',
|
autoTransfer: 0,
|
stationAlias: [],
|
status: 1,
|
memo: ''
|
}
|
}
|
|
export function getBasStationAreaPaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function getBasStationAreaTypeOptions() {
|
return TYPE_OPTIONS
|
}
|
|
export function getBasStationAreaBinaryOptions() {
|
return BINARY_OPTIONS
|
}
|
|
export function getBasStationAreaStatusOptions() {
|
return STATUS_OPTIONS
|
}
|
|
export function resolveBasStationAreaWarehouseAreaOptions(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
|
return records
|
.map((item) => {
|
if (!item || typeof item !== 'object') {
|
return null
|
}
|
const value = item.id ?? item.areaId ?? item.value
|
if (value === void 0 || value === null || value === '') {
|
return null
|
}
|
return {
|
value: Number(value),
|
label: normalizeText(item.name || item.areaName || item.code || item.areaCode || `库区 ${value}`)
|
}
|
})
|
.filter(Boolean)
|
}
|
|
export function resolveBasStationAreaStationOptions(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
|
return records
|
.map((item) => {
|
if (!item || typeof item !== 'object') {
|
return null
|
}
|
const value = item.id ?? item.stationId ?? item.value
|
if (value === void 0 || value === null || value === '') {
|
return null
|
}
|
return {
|
value: Number(value),
|
label: normalizeText(item.stationName || item.stationId || item.name || `站点 ${value}`)
|
}
|
})
|
.filter(Boolean)
|
}
|
|
export function resolveBasStationAreaContainerTypeOptions(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
|
return records
|
.map((item) => {
|
if (!item || typeof item !== 'object') {
|
return null
|
}
|
const value = item.value ?? item.id ?? item.dictValue
|
if (value === void 0 || value === null || value === '') {
|
return null
|
}
|
return {
|
value: Number(value),
|
label: normalizeText(item.label || item.name || item.dictLabel || item.value || '')
|
}
|
})
|
.filter(Boolean)
|
}
|
|
export function resolveBasStationAreaUseStatusOptions(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
|
return records
|
.map((item) => {
|
if (!item || typeof item !== 'object') {
|
return null
|
}
|
const value = item.value ?? item.id ?? item.dictValue
|
if (value === void 0 || value === null || value === '') {
|
return null
|
}
|
return {
|
value: normalizeText(item.value ?? value),
|
label: normalizeText(item.label || item.name || item.dictLabel || item.value || '')
|
}
|
})
|
.filter(Boolean)
|
}
|
|
export function buildBasStationAreaSearchParams(params = {}) {
|
const searchParams = {
|
condition: normalizeText(params.condition),
|
stationAreaName: normalizeText(params.stationAreaName),
|
stationAreaId: normalizeText(params.stationAreaId),
|
type:
|
params.type !== undefined && params.type !== null && params.type !== ''
|
? Number(params.type)
|
: void 0,
|
inAble:
|
params.inAble !== undefined && params.inAble !== null && params.inAble !== ''
|
? Number(params.inAble)
|
: void 0,
|
outAble:
|
params.outAble !== undefined && params.outAble !== null && params.outAble !== ''
|
? Number(params.outAble)
|
: void 0,
|
useStatus: normalizeText(params.useStatus),
|
area:
|
params.area !== undefined && params.area !== null && params.area !== ''
|
? Number(params.area)
|
: void 0,
|
isCrossZone:
|
params.isCrossZone !== undefined && params.isCrossZone !== null && params.isCrossZone !== ''
|
? Number(params.isCrossZone)
|
: void 0,
|
crossZoneArea: normalizeText(params.crossZoneArea),
|
isWcs:
|
params.isWcs !== undefined && params.isWcs !== null && params.isWcs !== ''
|
? Number(params.isWcs)
|
: void 0,
|
wcsData: normalizeText(params.wcsData),
|
containerType: normalizeText(params.containerType),
|
barcode: normalizeText(params.barcode),
|
autoTransfer:
|
params.autoTransfer !== undefined && params.autoTransfer !== null && params.autoTransfer !== ''
|
? Number(params.autoTransfer)
|
: void 0,
|
stationAlias: normalizeText(params.stationAlias),
|
memo: normalizeText(params.memo),
|
status:
|
params.status !== undefined && params.status !== null && params.status !== ''
|
? Number(params.status)
|
: void 0
|
}
|
|
return Object.fromEntries(
|
Object.entries(searchParams).filter(([, value]) => value !== '' && value !== void 0 && value !== null)
|
)
|
}
|
|
export function buildBasStationAreaPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildBasStationAreaSearchParams(params)
|
}
|
}
|
|
function normalizeIdValue(value) {
|
if (value === '' || value === null || value === undefined) {
|
return void 0
|
}
|
const numberValue = Number(value)
|
return Number.isNaN(numberValue) ? void 0 : numberValue
|
}
|
|
function resolveOptionText(ids = [], resolver, fallback = []) {
|
const fallbackList = normalizeStringArray(fallback)
|
const resolvedList = normalizeIdArray(ids).map((id, index) => {
|
if (typeof resolver === 'function') {
|
const text = normalizeText(resolver(id))
|
if (text) {
|
return text
|
}
|
}
|
return fallbackList[index] || normalizeText(id)
|
})
|
return buildJoinedText(resolvedList)
|
}
|
|
export function buildBasStationAreaSavePayload(formData = {}) {
|
return {
|
...(formData.id !== void 0 && formData.id !== null && formData.id !== ''
|
? { id: Number(formData.id) }
|
: {}),
|
stationAreaName: normalizeText(formData.stationAreaName) || '',
|
stationAreaId: normalizeText(formData.stationAreaId) || '',
|
...(formData.type !== void 0 && formData.type !== null && formData.type !== ''
|
? { type: Number(formData.type) }
|
: {}),
|
...(formData.inAble !== void 0 && formData.inAble !== null && formData.inAble !== ''
|
? { inAble: Number(formData.inAble) }
|
: {}),
|
...(formData.outAble !== void 0 && formData.outAble !== null && formData.outAble !== ''
|
? { outAble: Number(formData.outAble) }
|
: {}),
|
useStatus: normalizeText(formData.useStatus) || '',
|
...(formData.area !== void 0 && formData.area !== null && formData.area !== ''
|
? { area: Number(formData.area) }
|
: {}),
|
...(formData.isCrossZone !== void 0 && formData.isCrossZone !== null && formData.isCrossZone !== ''
|
? { isCrossZone: Number(formData.isCrossZone) }
|
: {}),
|
...(Array.isArray(formData.crossZoneArea) && formData.crossZoneArea.length
|
? { crossZoneArea: normalizeIdArray(formData.crossZoneArea) }
|
: {}),
|
...(formData.isWcs !== void 0 && formData.isWcs !== null && formData.isWcs !== ''
|
? { isWcs: Number(formData.isWcs) }
|
: {}),
|
wcsData: normalizeText(formData.wcsData) || '',
|
...(Array.isArray(formData.containerType) && formData.containerType.length
|
? { containerType: normalizeIdArray(formData.containerType) }
|
: {}),
|
barcode: normalizeText(formData.barcode) || '',
|
...(formData.autoTransfer !== void 0 && formData.autoTransfer !== null && formData.autoTransfer !== ''
|
? { autoTransfer: Number(formData.autoTransfer) }
|
: {}),
|
...(Array.isArray(formData.stationAlias) && formData.stationAlias.length
|
? { stationAlias: normalizeIdArray(formData.stationAlias).map((item) => String(item)) }
|
: {}),
|
status:
|
formData.status !== void 0 && formData.status !== null && formData.status !== ''
|
? Number(formData.status)
|
: 1,
|
memo: normalizeText(formData.memo) || ''
|
}
|
}
|
|
export function buildBasStationAreaDialogModel(record = {}, resolvers = {}) {
|
return {
|
...createBasStationAreaFormState(),
|
...(record.id !== void 0 && record.id !== null && record.id !== '' ? { id: Number(record.id) } : {}),
|
stationAreaName: normalizeText(record.stationAreaName || ''),
|
stationAreaId: normalizeText(record.stationAreaId || ''),
|
type: normalizeIdValue(record.type),
|
inAble: record.inAble !== void 0 && record.inAble !== null ? Number(record.inAble) : 0,
|
outAble: record.outAble !== void 0 && record.outAble !== null ? Number(record.outAble) : 0,
|
useStatus: normalizeText(record.useStatus || ''),
|
area: normalizeIdValue(record.area),
|
isCrossZone: record.isCrossZone !== void 0 && record.isCrossZone !== null ? Number(record.isCrossZone) : 0,
|
crossZoneArea: normalizeIdArray(record.crossZoneArea),
|
isWcs: record.isWcs !== void 0 && record.isWcs !== null ? Number(record.isWcs) : 0,
|
wcsData: normalizeText(record.wcsData || ''),
|
containerType: normalizeIdArray(record.containerType ?? record.containerTypes),
|
barcode: normalizeText(record.barcode || ''),
|
autoTransfer: record.autoTransfer !== void 0 && record.autoTransfer !== null ? Number(record.autoTransfer) : 0,
|
stationAlias: normalizeIdArray(record.stationAlias),
|
status: record.status !== void 0 && record.status !== null ? Number(record.status) : 1,
|
memo: normalizeText(record.memo || '')
|
}
|
}
|
|
export function normalizeBasStationAreaDetailRecord(record = {}, resolvers = {}) {
|
const statusMeta = getStatusMeta(record.statusBool ?? record.status)
|
const typeValue = record.type$ ?? record.type
|
const areaId = record.area ?? record.areaId ?? record.area$
|
const crossZoneAreaIds = normalizeIdArray(record.crossZoneArea)
|
const containerTypeIds = normalizeIdArray(record.containerType ?? record.containerTypes)
|
const stationAliasIds = normalizeStringArray(record.stationAlias)
|
const stationAliasNames = normalizeStringArray(record.stationAliasStaNo)
|
|
return {
|
...record,
|
id: normalizeIdValue(record.id),
|
stationAreaName: normalizeText(record.stationAreaName) || '--',
|
stationAreaId: normalizeText(record.stationAreaId) || '--',
|
type: normalizeIdValue(record.type),
|
typeText: normalizeText(
|
record.type$ || record.typeText || resolvers.resolveTypeLabel?.(typeValue) || typeValue
|
) || '--',
|
inAble: normalizeIdValue(record.inAble),
|
inAbleText: normalizeBooleanText(record.inAble),
|
outAble: normalizeIdValue(record.outAble),
|
outAbleText: normalizeBooleanText(record.outAble),
|
useStatus: normalizeText(record.useStatus),
|
useStatusText: normalizeText(record.useStatus$ || record.useStatusText || resolvers.resolveUseStatusLabel?.(record.useStatus) || record.useStatus) || '--',
|
area: normalizeIdValue(areaId),
|
areaText: normalizeText(record.area$ || record.areaText || resolvers.resolveAreaLabel?.(areaId) || '') || '--',
|
isCrossZone: normalizeIdValue(record.isCrossZone),
|
isCrossZoneText: normalizeBooleanText(record.isCrossZone),
|
crossZoneArea: crossZoneAreaIds,
|
crossZoneAreaText:
|
resolveOptionText(crossZoneAreaIds, resolvers.resolveCrossZoneAreaLabel, record.crossZoneAreaText || []) || '--',
|
isWcs: normalizeIdValue(record.isWcs),
|
isWcsText: normalizeBooleanText(record.isWcs),
|
wcsData: normalizeText(record.wcsData) || '--',
|
containerType: containerTypeIds,
|
containerTypeText:
|
resolveOptionText(containerTypeIds, resolvers.resolveContainerTypeLabel, record.containerTypesText || []) || '--',
|
barcode: normalizeText(record.barcode) || '--',
|
autoTransfer: normalizeIdValue(record.autoTransfer),
|
autoTransferText: normalizeBooleanText(record.autoTransfer),
|
stationAlias: stationAliasIds,
|
stationAliasText:
|
resolveOptionText(
|
stationAliasIds,
|
resolvers.resolveStationAliasLabel,
|
stationAliasNames.length ? stationAliasNames : record.stationAliasText || []
|
) || '--',
|
status: normalizeIdValue(record.status),
|
statusText: statusMeta.text,
|
statusType: statusMeta.type,
|
statusBool: record.statusBool !== void 0 ? Boolean(record.statusBool) : statusMeta.bool,
|
memo: normalizeText(record.memo) || '--',
|
createByText: normalizeText(record.createBy$ || record.createByText || ''),
|
createTimeText: normalizeText(record.createTime$ || record.createTime || ''),
|
updateByText: normalizeText(record.updateBy$ || record.updateByText || ''),
|
updateTimeText: normalizeText(record.updateTime$ || record.updateTime || '')
|
}
|
}
|
|
export function normalizeBasStationAreaListRow(record = {}, resolvers = {}) {
|
return normalizeBasStationAreaDetailRecord(record, resolvers)
|
}
|