const STATUS_META = {
|
1: { text: '启用', type: 'success', bool: true },
|
0: { text: '禁用', type: 'danger', bool: false }
|
}
|
|
const CURRENT_META = {
|
1: { text: '当前版本', type: 'success', bool: true },
|
0: { text: '历史版本', type: 'info', bool: false }
|
}
|
|
export const TASK_PATH_TEMPLATE_REPORT_TITLE = '任务路径模板报表'
|
export const TASK_PATH_TEMPLATE_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 numberValue = Number(value)
|
return Number.isNaN(numberValue) ? fallback : numberValue
|
}
|
|
export function createTaskPathTemplateSearchState() {
|
return {
|
condition: '',
|
templateCode: '',
|
templateName: '',
|
sourceType: '',
|
targetType: '',
|
conditionExpression: '',
|
conditionDesc: '',
|
version: '',
|
isCurrent: '',
|
effectiveTime: '',
|
expireTime: '',
|
priority: '',
|
timeoutMinutes: '',
|
stepSize: '',
|
maxRetryTimes: '',
|
retryIntervalSeconds: '',
|
status: '',
|
remark: '',
|
timeStart: '',
|
timeEnd: ''
|
}
|
}
|
|
export function createTaskPathTemplateFormState() {
|
return {
|
id: void 0,
|
templateCode: '',
|
templateName: '',
|
sourceType: '',
|
targetType: '',
|
conditionExpression: '',
|
conditionDesc: '',
|
version: 1,
|
isCurrent: 1,
|
effectiveTime: '',
|
expireTime: '',
|
priority: 1,
|
timeoutMinutes: '',
|
stepSize: '',
|
maxRetryTimes: 3,
|
retryIntervalSeconds: 60,
|
status: 1,
|
remark: ''
|
}
|
}
|
|
export function getTaskPathTemplateStatusOptions() {
|
return [
|
{ label: '启用', value: 1 },
|
{ label: '禁用', value: 0 }
|
]
|
}
|
|
export function getTaskPathTemplateCurrentOptions() {
|
return [
|
{ label: '当前版本', value: 1 },
|
{ label: '历史版本', value: 0 }
|
]
|
}
|
|
export function getTaskPathTemplatePaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function getTaskPathTemplateStatusMeta(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 getTaskPathTemplateCurrentMeta(isCurrent) {
|
if (isCurrent === true || Number(isCurrent) === 1) {
|
return CURRENT_META[1]
|
}
|
if (isCurrent === false || Number(isCurrent) === 0) {
|
return CURRENT_META[0]
|
}
|
return { text: '未知', type: 'info', bool: false }
|
}
|
|
export function buildTaskPathTemplateSearchParams(params = {}) {
|
const searchParams = {
|
condition: normalizeText(params.condition),
|
templateCode: normalizeText(params.templateCode),
|
templateName: normalizeText(params.templateName),
|
sourceType: normalizeText(params.sourceType),
|
targetType: normalizeText(params.targetType),
|
conditionExpression: normalizeText(params.conditionExpression),
|
conditionDesc: normalizeText(params.conditionDesc),
|
version: normalizeNumber(params.version),
|
isCurrent: normalizeNumber(params.isCurrent),
|
effectiveTime: normalizeText(params.effectiveTime),
|
expireTime: normalizeText(params.expireTime),
|
priority: normalizeNumber(params.priority),
|
timeoutMinutes: normalizeNumber(params.timeoutMinutes),
|
stepSize: normalizeNumber(params.stepSize),
|
maxRetryTimes: normalizeNumber(params.maxRetryTimes),
|
retryIntervalSeconds: normalizeNumber(params.retryIntervalSeconds),
|
status: normalizeNumber(params.status),
|
remark: normalizeText(params.remark),
|
timeStart: normalizeText(params.timeStart),
|
timeEnd: normalizeText(params.timeEnd)
|
}
|
|
return Object.fromEntries(
|
Object.entries(searchParams).filter(([, value]) => value !== '' && value !== void 0 && value !== null)
|
)
|
}
|
|
export function buildTaskPathTemplatePageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildTaskPathTemplateSearchParams(params)
|
}
|
}
|
|
export function buildTaskPathTemplateSavePayload(formData = {}) {
|
return {
|
...(formData.id !== void 0 && formData.id !== null && formData.id !== ''
|
? { id: Number(formData.id) }
|
: {}),
|
templateCode: normalizeText(formData.templateCode),
|
templateName: normalizeText(formData.templateName),
|
sourceType: normalizeText(formData.sourceType),
|
targetType: normalizeText(formData.targetType),
|
conditionExpression: normalizeText(formData.conditionExpression),
|
conditionDesc: normalizeText(formData.conditionDesc),
|
version: normalizeNumber(formData.version, 1),
|
isCurrent: normalizeNumber(formData.isCurrent, 1),
|
effectiveTime: normalizeText(formData.effectiveTime),
|
expireTime: normalizeText(formData.expireTime),
|
priority: normalizeNumber(formData.priority, 1),
|
...(formData.timeoutMinutes !== void 0 &&
|
formData.timeoutMinutes !== null &&
|
formData.timeoutMinutes !== ''
|
? { timeoutMinutes: Number(formData.timeoutMinutes) }
|
: {}),
|
...(formData.stepSize !== void 0 && formData.stepSize !== null && formData.stepSize !== ''
|
? { stepSize: Number(formData.stepSize) }
|
: {}),
|
maxRetryTimes: normalizeNumber(formData.maxRetryTimes, 3),
|
retryIntervalSeconds: normalizeNumber(formData.retryIntervalSeconds, 60),
|
status: normalizeNumber(formData.status, 1),
|
remark: normalizeText(formData.remark)
|
}
|
}
|
|
export function buildTaskPathTemplateDialogModel(record = {}) {
|
return {
|
...createTaskPathTemplateFormState(),
|
...(record.id !== void 0 && record.id !== null && record.id !== ''
|
? { id: Number(record.id) }
|
: {}),
|
templateCode: normalizeText(record.templateCode || ''),
|
templateName: normalizeText(record.templateName || ''),
|
sourceType: normalizeText(record.sourceType || ''),
|
targetType: normalizeText(record.targetType || ''),
|
conditionExpression: normalizeText(record.conditionExpression || ''),
|
conditionDesc: normalizeText(record.conditionDesc || ''),
|
version: normalizeNumber(record.version, 1),
|
isCurrent: normalizeNumber(record.isCurrent, 1),
|
effectiveTime: normalizeText(record.effectiveTime$ || record.effectiveTime || ''),
|
expireTime: normalizeText(record.expireTime$ || record.expireTime || ''),
|
priority: normalizeNumber(record.priority, 1),
|
timeoutMinutes: normalizeNumber(record.timeoutMinutes, ''),
|
stepSize: normalizeNumber(record.stepSize, ''),
|
maxRetryTimes: normalizeNumber(record.maxRetryTimes, 3),
|
retryIntervalSeconds: normalizeNumber(record.retryIntervalSeconds, 60),
|
status: normalizeNumber(record.status, 1),
|
remark: normalizeText(record.remark || '')
|
}
|
}
|
|
export function normalizeTaskPathTemplateDetailRecord(record = {}) {
|
const statusMeta = getTaskPathTemplateStatusMeta(record.statusBool ?? record.status)
|
const currentMeta = getTaskPathTemplateCurrentMeta(record.isCurrent)
|
return {
|
...record,
|
templateCode: normalizeText(record.templateCode || ''),
|
templateName: normalizeText(record.templateName || ''),
|
sourceType: normalizeText(record.sourceType || ''),
|
targetType: normalizeText(record.targetType || ''),
|
conditionExpression: normalizeText(record.conditionExpression || ''),
|
conditionDesc: normalizeText(record.conditionDesc || ''),
|
remark: normalizeText(record.remark || ''),
|
statusText: statusMeta.text,
|
statusType: statusMeta.type,
|
statusBool: record.statusBool !== void 0 ? Boolean(record.statusBool) : statusMeta.bool,
|
isCurrentText: currentMeta.text,
|
isCurrentType: currentMeta.type,
|
isCurrentBool: record.isCurrent !== void 0 ? Boolean(record.isCurrent) : currentMeta.bool,
|
createByText: normalizeText(record.createBy$ || record.createByText || ''),
|
updateByText: normalizeText(record.updateBy$ || record.updateByText || ''),
|
createTimeText: normalizeText(record.createTime$ || record.createTime || ''),
|
updateTimeText: normalizeText(record.updateTime$ || record.updateTime || ''),
|
effectiveTimeText: normalizeText(record.effectiveTime$ || record.effectiveTime || ''),
|
expireTimeText: normalizeText(record.expireTime$ || record.expireTime || '')
|
}
|
}
|
|
export function normalizeTaskPathTemplateListRow(record = {}) {
|
return normalizeTaskPathTemplateDetailRecord(record)
|
}
|
|
export function buildTaskPathTemplatePrintRows(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((record) => normalizeTaskPathTemplateListRow(record))
|
}
|
|
export function buildTaskPathTemplateReportMeta({
|
previewMeta = {},
|
count = 0,
|
orientation = TASK_PATH_TEMPLATE_REPORT_STYLE.orientation
|
} = {}) {
|
return {
|
reportTitle: TASK_PATH_TEMPLATE_REPORT_TITLE,
|
reportDate: previewMeta.reportDate,
|
printedAt: previewMeta.printedAt,
|
operator: previewMeta.operator,
|
count,
|
reportStyle: {
|
...TASK_PATH_TEMPLATE_REPORT_STYLE,
|
orientation
|
}
|
}
|
}
|
|
export function buildTaskPathTemplateFlowSnapshot(record = {}) {
|
const sourceType = normalizeText(record.sourceType || '')
|
const targetType = normalizeText(record.targetType || '')
|
const stepSize = normalizeText(record.stepSize || '')
|
const templateCode = normalizeText(record.templateCode || '')
|
return [
|
{ key: 'source', title: '起点类型', value: sourceType || '--' },
|
{ key: 'step', title: '步序长度', value: stepSize || '--' },
|
{ key: 'target', title: '终点类型', value: targetType || '--' },
|
{ key: 'code', title: '模板编码', value: templateCode || '--' }
|
]
|
}
|