const SERIAL_RULE_RESET_OPTIONS = [
|
{ label: '年重置', value: 'year' },
|
{ label: '月重置', value: 'month' },
|
{ label: '日重置', value: 'day' }
|
]
|
|
export function createSerialRuleSearchState() {
|
return {
|
condition: '',
|
code: '',
|
name: '',
|
reset: '',
|
status: ''
|
}
|
}
|
|
export function createSerialRuleFormState() {
|
return {
|
id: null,
|
code: '',
|
name: '',
|
delimit: '',
|
reset: '',
|
resetDep: '',
|
currValue: 0,
|
lastCode: '',
|
status: 1,
|
memo: ''
|
}
|
}
|
|
export function getSerialRulePaginationKey() {
|
return {
|
current: 'current',
|
size: 'pageSize'
|
}
|
}
|
|
export function getSerialRuleResetOptions() {
|
return SERIAL_RULE_RESET_OPTIONS
|
}
|
|
export function getSerialRuleResetLabel(value) {
|
return SERIAL_RULE_RESET_OPTIONS.find((item) => item.value === value)?.label || value || '-'
|
}
|
|
export function getSerialRuleStatusMeta(status) {
|
return Number(status) === 1
|
? { text: '正常', type: 'success', bool: true }
|
: { text: '冻结', type: 'danger', bool: false }
|
}
|
|
export function buildSerialRuleSearchParams(params = {}) {
|
return {
|
condition: String(params.condition || '').trim(),
|
code: String(params.code || '').trim(),
|
name: String(params.name || '').trim(),
|
...(params.reset ? { reset: String(params.reset) } : {}),
|
...(params.status !== '' && params.status !== null && params.status !== undefined
|
? { status: Number(params.status) }
|
: {})
|
}
|
}
|
|
export function buildSerialRulePageQueryParams(params = {}) {
|
return {
|
current: params.current || 1,
|
pageSize: params.pageSize || params.size || 20,
|
...buildSerialRuleSearchParams(params)
|
}
|
}
|
|
export function buildSerialRuleDialogModel(record = {}) {
|
return {
|
...createSerialRuleFormState(),
|
...(record.id ? { id: Number(record.id) } : {}),
|
code: record.code || '',
|
name: record.name || '',
|
delimit: record.delimit || '',
|
reset: record.reset || '',
|
resetDep: record.resetDep || '',
|
currValue: record.currValue !== undefined && record.currValue !== null ? Number(record.currValue) : 0,
|
lastCode: record.lastCode || '',
|
status: record.status !== undefined && record.status !== null ? Number(record.status) : 1,
|
memo: record.memo || ''
|
}
|
}
|
|
export function buildSerialRuleSavePayload(formData = {}) {
|
return {
|
...(formData.id ? { id: Number(formData.id) } : {}),
|
code: String(formData.code || '').trim(),
|
name: String(formData.name || '').trim(),
|
delimit: String(formData.delimit || '').trim(),
|
reset: String(formData.reset || '').trim(),
|
resetDep: String(formData.resetDep || '').trim(),
|
currValue: Number(formData.currValue || 0),
|
lastCode: String(formData.lastCode || '').trim(),
|
status: Number(formData.status ?? 1),
|
memo: String(formData.memo || '').trim()
|
}
|
}
|
|
export function normalizeSerialRuleListRow(record = {}) {
|
const statusMeta = getSerialRuleStatusMeta(record.status)
|
return {
|
...record,
|
code: record.code || '',
|
name: record.name || '',
|
delimit: record.delimit || '-',
|
resetText: record['reset$'] || getSerialRuleResetLabel(record.reset),
|
resetDep: record.resetDep || '-',
|
currValue: record.currValue ?? 0,
|
lastCode: record.lastCode || '-',
|
memo: record.memo || '',
|
statusText: record['status$'] || statusMeta.text,
|
statusType: statusMeta.type,
|
statusBool: record.statusBool ?? statusMeta.bool,
|
updateByLabel: record['updateBy$'] || '',
|
createByLabel: record['createBy$'] || '',
|
updateTimeText: record['updateTime$'] || record.updateTime || '',
|
createTimeText: record['createTime$'] || record.createTime || ''
|
}
|
}
|