const CHECK_DIFF_ITEM_REPORT_TITLE = '盘点差异明细报表'
|
|
function filterParams(params = {}, ignoredKeys = []) {
|
return Object.fromEntries(
|
Object.entries(params)
|
.filter(([key, value]) => {
|
if (ignoredKeys.includes(key)) return false
|
if (value === undefined || value === null) return false
|
if (typeof value === 'string' && value.trim() === '') return false
|
return true
|
})
|
.map(([key, value]) => [key, typeof value === 'string' ? value.trim() : value])
|
)
|
}
|
|
export function createCheckDiffItemSearchState() {
|
return {
|
condition: '',
|
checkId: '',
|
orderCode: '',
|
matnrCode: '',
|
barcode: '',
|
reason: '',
|
exceStatus: ''
|
}
|
}
|
|
export function buildCheckDiffItemSearchParams(params = {}) {
|
return filterParams(params, ['current', 'pageSize', 'size'])
|
}
|
|
export function buildCheckDiffItemPageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...filterParams(params, ['current', 'pageSize', 'size'])
|
}
|
}
|
|
function getCheckDiffItemStatusMeta(status) {
|
const normalized = Number(status)
|
if (normalized === 2) {
|
return { text: '已完成', type: 'success' }
|
}
|
if (normalized === 1) {
|
return { text: '处理中', type: 'warning' }
|
}
|
return { text: '待处理', type: 'info' }
|
}
|
|
export function normalizeCheckDiffItemRow(row = {}) {
|
const statusMeta = getCheckDiffItemStatusMeta(row.exceStatus ?? row.exceStatus$)
|
const checkQty = Number(row.checkQty ?? 0)
|
const anfme = Number(row.anfme ?? 0)
|
return {
|
...row,
|
exceStatusLabel: row.exceStatusLabel || row.exceStatus$ || statusMeta.text,
|
exceStatusTagType: row.exceStatusTagType || statusMeta.type,
|
diffQty: row.diffQty ?? Number((checkQty - anfme).toFixed(3)),
|
updateTimeText: row.updateTimeText || row.updateTime$ || row.updateTime || '-',
|
createTimeText: row.createTimeText || row.createTime$ || row.createTime || '-'
|
}
|
}
|
|
export function getCheckDiffItemActionList(record = {}) {
|
return [
|
{ key: 'view', label: '查看详情', icon: 'ri:file-list-3-line' },
|
{
|
key: 'approve',
|
label: '审批通过',
|
icon: 'ri:checkbox-circle-line',
|
auth: 'edit',
|
disabled: Number(record.exceStatus) === 2
|
}
|
]
|
}
|
|
export function buildCheckDiffItemPrintRows(records = []) {
|
return Array.isArray(records) ? records.map((item) => normalizeCheckDiffItemRow(item)) : []
|
}
|
|
export function buildCheckDiffItemReportMeta(rows = []) {
|
return {
|
reportTitle: CHECK_DIFF_ITEM_REPORT_TITLE,
|
reportDate: new Date().toLocaleDateString('zh-CN'),
|
printedAt: new Date().toLocaleString('zh-CN', { hour12: false }),
|
count: rows.length
|
}
|
}
|
|
export { CHECK_DIFF_ITEM_REPORT_TITLE, getCheckDiffItemStatusMeta }
|