const STATUS_META = {
|
1: { text: '正常', type: 'success' },
|
0: { text: '冻结', type: 'info' }
|
}
|
|
export const FLOW_STEP_TEMPLATE_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 normalizeBoolText(value) {
|
const numericValue = Number(value)
|
if (numericValue === 1) return '是'
|
if (numericValue === 0) return '否'
|
return '--'
|
}
|
|
export function createFlowStepTemplateSearchState() {
|
return {
|
condition: '',
|
timeStart: '',
|
timeEnd: '',
|
flowId: '',
|
flowCode: '',
|
stepOrder: '',
|
stepCode: '',
|
stepName: '',
|
stepType: '',
|
actionType: '',
|
actionConfig: '',
|
inputMapping: '',
|
outputMapping: '',
|
conditionExpression: '',
|
skipOnFail: '',
|
retryEnabled: '',
|
retryConfig: '',
|
timeoutSeconds: '',
|
memo: '',
|
status: ''
|
}
|
}
|
|
export function getFlowStepTemplatePaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function buildFlowStepTemplateSearchParams(params = {}) {
|
const result = {}
|
|
;[
|
'condition',
|
'flowCode',
|
'stepCode',
|
'stepName',
|
'stepType',
|
'actionType',
|
'actionConfig',
|
'inputMapping',
|
'outputMapping',
|
'conditionExpression',
|
'retryConfig',
|
'memo'
|
].forEach((key) => {
|
const value = normalizeText(params[key])
|
if (value) {
|
result[key] = value
|
}
|
})
|
|
;['timeStart', 'timeEnd'].forEach((key) => {
|
if (params[key]) {
|
result[key] = params[key]
|
}
|
})
|
|
;['flowId', 'stepOrder', 'skipOnFail', 'retryEnabled', 'timeoutSeconds', 'status'].forEach((key) => {
|
const value = normalizeNumber(params[key])
|
if (value !== null) {
|
result[key] = value
|
}
|
})
|
|
return {
|
condition: '',
|
...result
|
}
|
}
|
|
export function buildFlowStepTemplatePageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildFlowStepTemplateSearchParams(params)
|
}
|
}
|
|
export function normalizeFlowStepTemplateRow(record = {}) {
|
const statusMeta = STATUS_META[Number(record.status)] || STATUS_META[0]
|
return {
|
...record,
|
id: record.id ?? '--',
|
flowId: record.flowId ?? '--',
|
flowCode: normalizeText(record.flowCode) || '--',
|
stepOrder: record.stepOrder ?? '--',
|
stepCode: normalizeText(record.stepCode) || '--',
|
stepName: normalizeText(record.stepName) || '--',
|
stepType: normalizeText(record.stepType) || '--',
|
actionType: normalizeText(record.actionType) || '--',
|
skipOnFailText: normalizeBoolText(record.skipOnFail),
|
retryEnabledText: normalizeBoolText(record.retryEnabled),
|
timeoutSeconds: record.timeoutSeconds ?? '--',
|
statusText: record['status$'] || statusMeta.text,
|
statusType: statusMeta.type,
|
memo: normalizeText(record.memo) || '--'
|
}
|
}
|
|
export function getFlowStepTemplateReportColumns() {
|
return [
|
{ prop: 'flowId', label: '流程ID' },
|
{ prop: 'flowCode', label: '流程编码' },
|
{ prop: 'stepOrder', label: '步骤顺序' },
|
{ prop: 'stepCode', label: '步骤编码' },
|
{ prop: 'stepName', label: '步骤名称' },
|
{ prop: 'stepType', label: '步骤类型' },
|
{ prop: 'actionType', label: '动作类型' },
|
{ prop: 'skipOnFailText', label: '跳过失败' },
|
{ prop: 'retryEnabledText', label: '启用重试' },
|
{ prop: 'timeoutSeconds', label: '超时(秒)' },
|
{ prop: 'statusText', label: '状态' },
|
{ prop: 'memo', label: '备注' }
|
]
|
}
|
|
export function buildFlowStepTemplatePrintRows(records = []) {
|
return (Array.isArray(records) ? records : []).map((record) => {
|
const row = normalizeFlowStepTemplateRow(record)
|
return {
|
flowId: row.flowId,
|
flowCode: row.flowCode,
|
stepOrder: row.stepOrder,
|
stepCode: row.stepCode,
|
stepName: row.stepName,
|
stepType: row.stepType,
|
actionType: row.actionType,
|
skipOnFailText: row.skipOnFailText,
|
retryEnabledText: row.retryEnabledText,
|
timeoutSeconds: row.timeoutSeconds,
|
statusText: row.statusText,
|
memo: row.memo
|
}
|
})
|
}
|