const PREPARATION_STATUS_META = {
|
8: { text: '取消', type: 'danger' },
|
10: { text: '初始化', type: 'info' },
|
11: { text: '待处理', type: 'warning' },
|
13: { text: '生成工作档', type: 'primary' },
|
14: { text: '作业中', type: 'warning' },
|
15: { text: '已完成', type: 'success' }
|
}
|
|
const PREPARATION_RLE_STATUS_META = {
|
0: { text: '正常', type: 'success' },
|
1: { text: '已释放', type: 'warning' }
|
}
|
|
export const PREPARATION_REPORT_TITLE = '备料单报表'
|
export const PREPARATION_REPORT_STYLE = {
|
titleAlign: 'center',
|
titleLevel: 'strong',
|
orientation: 'landscape',
|
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 normalizeStatusMeta(exceStatus, exceStatusText) {
|
if (exceStatusText) {
|
return PREPARATION_STATUS_META[Number(exceStatus)] || {
|
text: exceStatusText,
|
type: 'info'
|
}
|
}
|
|
return PREPARATION_STATUS_META[Number(exceStatus)] || {
|
text: normalizeText(exceStatus) || '--',
|
type: 'info'
|
}
|
}
|
|
function normalizeRleStatusMeta(rleStatus, rleStatusText) {
|
if (rleStatusText) {
|
return PREPARATION_RLE_STATUS_META[Number(rleStatus)] || {
|
text: rleStatusText,
|
type: 'info'
|
}
|
}
|
|
return PREPARATION_RLE_STATUS_META[Number(rleStatus)] || {
|
text: normalizeText(rleStatus) || '--',
|
type: 'info'
|
}
|
}
|
|
export function createPreparationSearchState() {
|
return {
|
condition: '',
|
code: '',
|
poCode: '',
|
wkType: '',
|
exceStatus: '',
|
rleStatus: '',
|
logisNo: '',
|
customerName: '',
|
saleOrgName: '',
|
memo: ''
|
}
|
}
|
|
export function buildPreparationSearchParams(params = {}) {
|
const result = {}
|
|
;[
|
'condition',
|
'code',
|
'poCode',
|
'wkType',
|
'logisNo',
|
'customerName',
|
'saleOrgName',
|
'memo'
|
].forEach((key) => {
|
const value = normalizeText(params[key])
|
if (value) {
|
result[key] = value
|
}
|
})
|
|
if (params.exceStatus !== '' && params.exceStatus !== undefined && params.exceStatus !== null) {
|
result.exceStatus = normalizeNumber(params.exceStatus)
|
}
|
|
if (params.rleStatus !== '' && params.rleStatus !== undefined && params.rleStatus !== null) {
|
result.rleStatus = normalizeNumber(params.rleStatus)
|
}
|
|
return result
|
}
|
|
export function buildPreparationPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildPreparationSearchParams(params)
|
}
|
}
|
|
export function buildPreparationDetailQueryParams(params = {}) {
|
return {
|
orderId: Number(params.orderId) || 0,
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20
|
}
|
}
|
|
export function normalizePreparationRow(record = {}) {
|
const statusMeta = normalizeStatusMeta(
|
record.exceStatus,
|
record['exceStatus$'] || record.exceStatusText
|
)
|
const rleStatusMeta = normalizeRleStatusMeta(
|
record.rleStatus,
|
record['rleStatus$'] || record.rleStatusText
|
)
|
|
return {
|
...record,
|
id: record.id ?? null,
|
code: normalizeText(record.code) || '--',
|
poCode: normalizeText(record.poCode) || '--',
|
typeLabel: normalizeText(record['type$'] || record.type) || '--',
|
wkTypeLabel: normalizeText(record['wkType$'] || record.wkType) || '--',
|
exceStatusText: statusMeta.text,
|
exceStatusTagType: statusMeta.type,
|
rleStatusText: rleStatusMeta.text,
|
rleStatusTagType: rleStatusMeta.type,
|
anfme: record.anfme ?? '--',
|
workQty: record.workQty ?? '--',
|
qty: record.qty ?? '--',
|
logisNo: normalizeText(record.logisNo) || '--',
|
saleOrgName: normalizeText(record.saleOrgName) || '--',
|
saleUserName: normalizeText(record.saleUserName) || '--',
|
businessTimeText:
|
normalizeText(record['businessTime$'] || record.businessTimeText || record.businessTime) ||
|
'--',
|
customerId: normalizeText(record.customerId) || '--',
|
customerName: normalizeText(record.customerName) || '--',
|
stockOrgName: normalizeText(record.stockOrgName) || '--',
|
createByText: normalizeText(record['createBy$'] || record.createByText) || '--',
|
createTimeText:
|
normalizeText(record['createTime$'] || record.createTimeText || record.createTime) || '--',
|
updateByText: normalizeText(record['updateBy$'] || record.updateByText) || '--',
|
updateTimeText:
|
normalizeText(record['updateTime$'] || record.updateTimeText || record.updateTime) || '--',
|
memo: normalizeText(record.memo) || '--',
|
canComplete: Number(record.exceStatus) !== 15,
|
canCancel: Number(record.exceStatus) === 10,
|
canDelete: Number(record.exceStatus) !== 15
|
}
|
}
|
|
export function normalizePreparationItemRow(record = {}) {
|
return {
|
...record,
|
id: record.id ?? null,
|
matnrCode: normalizeText(record.matnrCode) || '--',
|
maktx: normalizeText(record.maktx) || '--',
|
splrBatch: normalizeText(record.splrBatch) || '--',
|
splrName: normalizeText(record.splrName) || '--',
|
anfme: record.anfme ?? '--',
|
qty: record.qty ?? '--',
|
memo: normalizeText(record.memo) || '--'
|
}
|
}
|
|
export function getPreparationActionList(row = {}) {
|
const normalizedRow = normalizePreparationRow(row)
|
return [
|
{ key: 'view', label: '查看详情', icon: 'ri:eye-line' },
|
{ key: 'print', label: '打印', icon: 'ri:printer-line' },
|
{
|
key: 'complete',
|
label: '完成',
|
icon: 'ri:check-line',
|
color: 'var(--el-color-success)',
|
disabled: !normalizedRow.canComplete
|
},
|
{
|
key: 'cancel',
|
label: '取消',
|
icon: 'ri:close-circle-line',
|
color: 'var(--el-color-danger)',
|
disabled: !normalizedRow.canCancel
|
},
|
{
|
key: 'delete',
|
label: '删除',
|
icon: 'ri:delete-bin-6-line',
|
color: 'var(--el-color-danger)',
|
disabled: !normalizedRow.canDelete
|
}
|
]
|
}
|
|
export function createPreparationDetailItemColumns() {
|
return [
|
{ type: 'globalIndex', label: '序号', width: 72, align: 'center' },
|
{ prop: 'matnrCode', label: '物料编码', minWidth: 160, showOverflowTooltip: true },
|
{ prop: 'maktx', label: '物料名称', minWidth: 180, showOverflowTooltip: true },
|
{ prop: 'splrBatch', label: '供应商批次', minWidth: 140, showOverflowTooltip: true },
|
{ prop: 'splrName', label: '供应商', minWidth: 160, showOverflowTooltip: true },
|
{ prop: 'anfme', label: '应出数量', width: 100, align: 'right' },
|
{ prop: 'qty', label: '已出数量', width: 100, align: 'right' },
|
{ prop: 'memo', label: '备注', minWidth: 160, showOverflowTooltip: true }
|
]
|
}
|
|
export function buildPreparationPrintRows(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((record) => normalizePreparationRow(record))
|
}
|
|
export function buildPreparationReportMeta({
|
previewMeta = {},
|
count = 0,
|
orientation = PREPARATION_REPORT_STYLE.orientation
|
} = {}) {
|
return {
|
reportTitle: PREPARATION_REPORT_TITLE,
|
reportDate: previewMeta.reportDate,
|
printedAt: previewMeta.printedAt,
|
operator: previewMeta.operator,
|
count,
|
reportStyle: {
|
...PREPARATION_REPORT_STYLE,
|
orientation
|
}
|
}
|
}
|