const STATUS_META = {
|
1: { text: '正常', type: 'success' },
|
0: { text: '冻结', type: 'info' }
|
}
|
|
export const FLOW_STEP_INSTANCE_REPORT_TITLE = '流程步骤实例报表'
|
|
function normalizeText(value) {
|
return String(value ?? '').trim()
|
}
|
|
function normalizeNumber(value) {
|
if (value === '' || value === null || value === undefined) {
|
return null
|
}
|
const numericValue = Number(value)
|
return Number.isFinite(numericValue) ? numericValue : null
|
}
|
|
function normalizeDateTime(value) {
|
return normalizeText(value) || '--'
|
}
|
|
export function createFlowStepInstanceSearchState() {
|
return {
|
condition: '',
|
timeStart: '',
|
timeEnd: '',
|
flowInstanceId: '',
|
flowInstanceNo: '',
|
stepOrder: '',
|
stepCode: '',
|
stepName: '',
|
stepType: '',
|
stepTemplateId: '',
|
executeResult: '',
|
errorCode: '',
|
errorMessage: '',
|
startTime: '',
|
endTime: '',
|
durationSeconds: '',
|
inputData: '',
|
outputData: '',
|
retryTimes: '',
|
memo: '',
|
status: ''
|
}
|
}
|
|
export function getFlowStepInstancePaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function buildFlowStepInstanceSearchParams(params = {}) {
|
const result = {}
|
|
;[
|
'condition',
|
'flowInstanceNo',
|
'stepCode',
|
'stepName',
|
'stepType',
|
'executeResult',
|
'errorCode',
|
'errorMessage',
|
'startTime',
|
'endTime',
|
'inputData',
|
'outputData',
|
'memo'
|
].forEach((key) => {
|
const value = normalizeText(params[key])
|
if (value) {
|
result[key] = value
|
}
|
})
|
|
;['timeStart', 'timeEnd'].forEach((key) => {
|
if (params[key]) {
|
result[key] = params[key]
|
}
|
})
|
|
;['flowInstanceId', 'stepOrder', 'stepTemplateId', 'durationSeconds', 'retryTimes', 'status'].forEach((key) => {
|
const value = normalizeNumber(params[key])
|
if (value !== null) {
|
result[key] = value
|
}
|
})
|
|
return {
|
condition: '',
|
...result
|
}
|
}
|
|
export function buildFlowStepInstancePageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildFlowStepInstanceSearchParams(params)
|
}
|
}
|
|
export function normalizeFlowStepInstanceRow(record = {}) {
|
const statusMeta = STATUS_META[Number(record.status)] || STATUS_META[0]
|
|
return {
|
...record,
|
id: record.id ?? '--',
|
flowInstanceNo: normalizeText(record.flowInstanceNo) || '--',
|
stepCode: normalizeText(record.stepCode) || '--',
|
stepName: normalizeText(record.stepName) || '--',
|
stepType: normalizeText(record.stepType) || '--',
|
executeResult: normalizeText(record.executeResult) || '--',
|
errorMessage: normalizeText(record.errorMessage) || '--',
|
startTimeText: normalizeDateTime(record['startTime$'] || record.startTimeText || record.startTime),
|
endTimeText: normalizeDateTime(record['endTime$'] || record.endTimeText || record.endTime),
|
durationSeconds: record.durationSeconds ?? '--',
|
statusText: record['status$'] || statusMeta.text,
|
statusType: statusMeta.type,
|
memo: normalizeText(record.memo) || '--'
|
}
|
}
|
|
export function getFlowStepInstanceReportColumns() {
|
return [
|
{ prop: 'flowInstanceNo', label: '流程实例号' },
|
{ prop: 'stepCode', label: '步骤编码' },
|
{ prop: 'stepName', label: '步骤名称' },
|
{ prop: 'stepType', label: '步骤类型' },
|
{ prop: 'executeResult', label: '执行结果' },
|
{ prop: 'errorMessage', label: '错误信息' },
|
{ prop: 'startTimeText', label: '开始时间' },
|
{ prop: 'endTimeText', label: '结束时间' },
|
{ prop: 'durationSeconds', label: '耗时(秒)' },
|
{ prop: 'statusText', label: '状态' },
|
{ prop: 'memo', label: '备注' }
|
]
|
}
|
|
export function buildFlowStepInstancePrintRows(records = []) {
|
return (Array.isArray(records) ? records : []).map((record) => {
|
const row = normalizeFlowStepInstanceRow(record)
|
return {
|
flowInstanceNo: row.flowInstanceNo,
|
stepCode: row.stepCode,
|
stepName: row.stepName,
|
stepType: row.stepType,
|
executeResult: row.executeResult,
|
errorMessage: row.errorMessage,
|
startTimeText: row.startTimeText,
|
endTimeText: row.endTimeText,
|
durationSeconds: row.durationSeconds,
|
statusText: row.statusText,
|
memo: row.memo
|
}
|
})
|
}
|