const WAVE_RULE_DICT_TYPE_CODE = 'sys_wave_rule_code'
|
|
export function getWaveRuleDictTypeCode() {
|
return WAVE_RULE_DICT_TYPE_CODE
|
}
|
|
export function createWaveRuleSearchState() {
|
return {
|
condition: '',
|
code: '',
|
type: '',
|
name: '',
|
status: ''
|
}
|
}
|
|
export function createWaveRuleFormState() {
|
return {
|
id: null,
|
code: '',
|
type: '',
|
name: '',
|
status: 1,
|
memo: ''
|
}
|
}
|
|
export function getWaveRulePaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function getWaveRuleStatusMeta(status) {
|
return Number(status) === 1
|
? { text: '正常', type: 'success', bool: true }
|
: { text: '冻结', type: 'danger', bool: false }
|
}
|
|
export function buildWaveRuleSearchParams(params = {}) {
|
return {
|
condition: String(params.condition || '').trim(),
|
code: String(params.code || '').trim(),
|
name: String(params.name || '').trim(),
|
...(params.type !== '' && params.type !== null && params.type !== undefined
|
? { type: Number(params.type) }
|
: {}),
|
...(params.status !== '' && params.status !== null && params.status !== undefined
|
? { status: Number(params.status) }
|
: {})
|
}
|
}
|
|
export function buildWaveRulePageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildWaveRuleSearchParams(params)
|
}
|
}
|
|
export function buildWaveRuleDialogModel(record = {}) {
|
return {
|
...createWaveRuleFormState(),
|
...(record.id ? { id: Number(record.id) } : {}),
|
code: record.code || '',
|
type: record.type !== undefined && record.type !== null && record.type !== ''
|
? Number(record.type)
|
: '',
|
name: record.name || '',
|
status: record.status !== undefined && record.status !== null ? Number(record.status) : 1,
|
memo: record.memo || ''
|
}
|
}
|
|
export function buildWaveRuleSavePayload(formData = {}) {
|
return {
|
...(formData.id ? { id: Number(formData.id) } : {}),
|
...(formData.code ? { code: String(formData.code).trim() } : {}),
|
type: Number(formData.type),
|
name: String(formData.name || '').trim(),
|
status: Number(formData.status ?? 1),
|
memo: String(formData.memo || '').trim()
|
}
|
}
|
|
export function buildWaveRuleTypeOptions(records = []) {
|
if (!Array.isArray(records)) {
|
return []
|
}
|
return records.map((item) => ({
|
label: item.label || item.name || String(item.value ?? ''),
|
value: Number(item.value)
|
}))
|
}
|
|
export function normalizeWaveRuleListRow(record = {}) {
|
const statusMeta = getWaveRuleStatusMeta(record.status)
|
return {
|
...record,
|
code: record.code || '',
|
name: record.name || '',
|
memo: record.memo || '',
|
typeText: record['type$'] || record.typeText || '-',
|
statusText: record['status$'] || statusMeta.text,
|
statusType: statusMeta.type,
|
statusBool: record.statusBool ?? statusMeta.bool,
|
updateByLabel: record['updateBy$'] || record.updateByLabel || '',
|
createByLabel: record['createBy$'] || record.createByLabel || '',
|
updateTimeText: record['updateTime$'] || record.updateTime || '',
|
createTimeText: record['createTime$'] || record.createTime || ''
|
}
|
}
|