zhou zhou
1 天以前 aaf8a50511d77dbc209ca93bbba308c21179a8bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
export const FLOW_STEP_LOG_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
}
 
export function createFlowStepLogSearchState() {
  return {
    condition: '',
    timeStart: '',
    timeEnd: '',
    flowInstanceId: '',
    stepInstanceId: '',
    logType: '',
    logLevel: '',
    logContent: '',
    requestData: '',
    responseData: '',
    memo: '',
    status: ''
  }
}
 
export function getFlowStepLogPaginationKey() {
  return {
    current: 'current',
    size: 'pageSize'
  }
}
 
export function buildFlowStepLogSearchParams(params = {}) {
  const result = {}
 
  ;['condition', 'logType', 'logLevel', 'logContent', 'requestData', 'responseData', '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', 'stepInstanceId', 'status'].forEach((key) => {
    const value = normalizeNumber(params[key])
    if (value !== null) {
      result[key] = value
    }
  })
 
  return {
    condition: '',
    ...result
  }
}
 
export function buildFlowStepLogPageQueryParams(params = {}) {
  return {
    current: params.current || 1,
    pageSize: params.pageSize || params.size || 20,
    ...buildFlowStepLogSearchParams(params)
  }
}
 
export function normalizeFlowStepLogRow(record = {}) {
  return {
    ...record,
    id: record.id ?? '--',
    flowInstanceId: record.flowInstanceId ?? '--',
    stepInstanceId: record.stepInstanceId ?? '--',
    logType: normalizeText(record.logType) || '--',
    logLevel: normalizeText(record.logLevel) || '--',
    logContent: normalizeText(record.logContent) || '--',
    requestData: normalizeText(record.requestData) || '--',
    responseData: normalizeText(record.responseData) || '--',
    createTimeText: normalizeText(record['createTime$'] || record.createTimeText || record.createTime) || '--',
    memo: normalizeText(record.memo) || '--'
  }
}
 
export function getFlowStepLogReportColumns() {
  return [
    { prop: 'flowInstanceId', label: '流程实例ID' },
    { prop: 'stepInstanceId', label: '步骤实例ID' },
    { prop: 'logType', label: '日志类型' },
    { prop: 'logLevel', label: '日志级别' },
    { prop: 'logContent', label: '日志内容' },
    { prop: 'requestData', label: '请求数据' },
    { prop: 'responseData', label: '响应数据' },
    { prop: 'createTimeText', label: '创建时间' },
    { prop: 'memo', label: '备注' }
  ]
}
 
export function buildFlowStepLogPrintRows(records = []) {
  return (Array.isArray(records) ? records : []).map((record) => {
    const row = normalizeFlowStepLogRow(record)
    return {
      flowInstanceId: row.flowInstanceId,
      stepInstanceId: row.stepInstanceId,
      logType: row.logType,
      logLevel: row.logLevel,
      logContent: row.logContent,
      requestData: row.requestData,
      responseData: row.responseData,
      createTimeText: row.createTimeText,
      memo: row.memo
    }
  })
}