const STATUS_META = {
|
1: { text: '正常', type: 'success', bool: true },
|
0: { text: '冻结', type: 'danger', bool: false }
|
}
|
|
export const LOC_AREA_RELA_REPORT_TITLE = '库区关系报表'
|
export const LOC_AREA_RELA_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
|
}
|
|
export function createLocAreaRelaSearchState() {
|
return {
|
condition: '',
|
locAreaId: '',
|
locId: '',
|
status: '',
|
memo: '',
|
timeStart: '',
|
timeEnd: ''
|
}
|
}
|
|
export function createLocAreaRelaFormState() {
|
return {
|
id: void 0,
|
locAreaId: void 0,
|
locId: void 0,
|
status: 1,
|
memo: ''
|
}
|
}
|
|
export function getLocAreaRelaPaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function getLocAreaRelaStatusOptions() {
|
return [
|
{ label: '正常', value: 1 },
|
{ label: '冻结', value: 0 }
|
]
|
}
|
|
export function getLocAreaRelaStatusMeta(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 buildLocAreaRelaSearchParams(params = {}) {
|
const searchParams = {
|
condition: normalizeText(params.condition),
|
locAreaId:
|
params.locAreaId !== undefined && params.locAreaId !== null && params.locAreaId !== ''
|
? normalizeNumber(params.locAreaId)
|
: void 0,
|
locId:
|
params.locId !== undefined && params.locId !== null && params.locId !== ''
|
? normalizeNumber(params.locId)
|
: void 0,
|
status:
|
params.status !== undefined && params.status !== null && params.status !== ''
|
? normalizeNumber(params.status)
|
: void 0,
|
memo: normalizeText(params.memo),
|
timeStart: normalizeText(params.timeStart),
|
timeEnd: normalizeText(params.timeEnd)
|
}
|
|
return Object.fromEntries(
|
Object.entries(searchParams).filter(
|
([, value]) => value !== '' && value !== void 0 && value !== null
|
)
|
)
|
}
|
|
export function buildLocAreaRelaPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildLocAreaRelaSearchParams(params)
|
}
|
}
|
|
export function buildLocAreaRelaSavePayload(formData = {}) {
|
return {
|
...(formData.id !== undefined && formData.id !== null && formData.id !== ''
|
? { id: normalizeNumber(formData.id) }
|
: {}),
|
...(formData.locAreaId !== undefined && formData.locAreaId !== null && formData.locAreaId !== ''
|
? { locAreaId: normalizeNumber(formData.locAreaId) }
|
: {}),
|
...(formData.locId !== undefined && formData.locId !== null && formData.locId !== ''
|
? { locId: normalizeNumber(formData.locId) }
|
: {}),
|
status:
|
formData.status !== undefined && formData.status !== null && formData.status !== ''
|
? normalizeNumber(formData.status)
|
: 1,
|
memo: normalizeText(formData.memo) || ''
|
}
|
}
|
|
export function buildLocAreaRelaDialogModel(record = {}) {
|
return {
|
...createLocAreaRelaFormState(),
|
...(record.id !== undefined && record.id !== null && record.id !== ''
|
? { id: normalizeNumber(record.id) }
|
: {}),
|
locAreaId:
|
record.locAreaId !== undefined && record.locAreaId !== null && record.locAreaId !== ''
|
? normalizeNumber(record.locAreaId)
|
: void 0,
|
locId:
|
record.locId !== undefined && record.locId !== null && record.locId !== ''
|
? normalizeNumber(record.locId)
|
: void 0,
|
status:
|
record.status !== undefined && record.status !== null ? normalizeNumber(record.status, 1) : 1,
|
memo: normalizeText(record.memo || '')
|
}
|
}
|
|
export function normalizeLocAreaRelaDetailRecord(record = {}) {
|
const statusMeta = getLocAreaRelaStatusMeta(record.statusBool ?? record.status)
|
return {
|
...record,
|
locAreaIdText: normalizeText(
|
record.locAreaId$ || record.locAreaIdText || record.locAreaId || ''
|
),
|
locIdText: normalizeText(record.locId$ || record.locIdText || record.locId || ''),
|
memo: normalizeText(record.memo || ''),
|
statusText: statusMeta.text,
|
statusType: statusMeta.type,
|
statusBool: record.statusBool !== void 0 ? Boolean(record.statusBool) : statusMeta.bool,
|
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 normalizeLocAreaRelaListRow(record = {}) {
|
return normalizeLocAreaRelaDetailRecord(record)
|
}
|
|
export function buildLocAreaRelaPrintRows(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((record) => normalizeLocAreaRelaListRow(record))
|
}
|
|
export function buildLocAreaRelaReportMeta({
|
previewMeta = {},
|
count = 0,
|
orientation = LOC_AREA_RELA_REPORT_STYLE.orientation
|
} = {}) {
|
return {
|
reportTitle: LOC_AREA_RELA_REPORT_TITLE,
|
reportDate: previewMeta.reportDate,
|
printedAt: previewMeta.printedAt,
|
operator: previewMeta.operator,
|
count,
|
reportStyle: {
|
...LOC_AREA_RELA_REPORT_STYLE,
|
orientation
|
}
|
}
|
}
|