From a49845f424ae5b1e43e391837a55c43ce07ea62d Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期三, 01 四月 2026 15:02:47 +0800
Subject: [PATCH] #前端
---
rsf-design/src/views/system/role/rolePage.helpers.js | 74 +++++++++++++++++++++++--------------
1 files changed, 46 insertions(+), 28 deletions(-)
diff --git a/rsf-design/src/views/system/role/rolePage.helpers.js b/rsf-design/src/views/system/role/rolePage.helpers.js
index 0b2696f..aa4c451 100644
--- a/rsf-design/src/views/system/role/rolePage.helpers.js
+++ b/rsf-design/src/views/system/role/rolePage.helpers.js
@@ -1,3 +1,13 @@
+const ROLE_STATUS_META = {
+ 1: { type: 'success', text: '姝e父', bool: true },
+ 0: { type: 'danger', text: '绂佺敤', bool: false }
+}
+
+const ROLE_STATUS_OPTIONS = [
+ { label: '姝e父', value: 1 },
+ { label: '绂佺敤', value: 0 }
+]
+
export function createRoleSearchState() {
return {
name: '',
@@ -6,6 +16,14 @@
status: void 0,
condition: ''
}
+}
+
+function hasValue(value) {
+ return value !== '' && value !== void 0 && value !== null
+}
+
+function normalizeText(value) {
+ return String(value ?? '').trim()
}
export function createRoleFormState() {
@@ -18,20 +36,20 @@
}
}
+export function getRoleStatusOptions() {
+ return ROLE_STATUS_OPTIONS.map((option) => ({ ...option }))
+}
+
export function buildRoleSearchParams(params = {}) {
const searchParams = {
- name: params.name,
- code: params.code,
- memo: params.memo,
+ name: normalizeText(params.name),
+ code: normalizeText(params.code),
+ memo: normalizeText(params.memo),
status: params.status,
- condition: params.condition
+ condition: normalizeText(params.condition)
}
- return Object.fromEntries(
- Object.entries(searchParams).filter(
- ([, value]) => value !== '' && value !== void 0 && value !== null
- )
- )
+ return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => hasValue(value)))
}
export function buildRolePageQueryParams(params = {}) {
@@ -137,22 +155,12 @@
export function buildRoleDialogModel(record = {}) {
return {
...createRoleFormState(),
- id: normalizeRoleId(record.id),
- name: record.name || '',
- code: record.code || '',
- memo: record.memo || '',
- status: record.status !== void 0 && record.status !== null ? record.status : 1
+ ...buildRoleFormData(record)
}
}
export function buildRoleSavePayload(form = {}) {
- return {
- id: normalizeRoleId(form.id),
- name: form.name || '',
- code: form.code || '',
- memo: form.memo || '',
- status: form.status !== void 0 && form.status !== null ? form.status : 1
- }
+ return buildRoleFormData(form)
}
export function normalizeRoleListRow(record = {}) {
@@ -162,17 +170,17 @@
statusBool: record.statusBool !== void 0 ? Boolean(record.statusBool) : statusMeta.bool,
statusText: statusMeta.text,
statusType: statusMeta.type,
- createTimeText: record.createTime$ || record.createTime || '',
- updateTimeText: record.updateTime$ || record.updateTime || ''
+ createTimeText: normalizeText(record.createTime$ || record.createTime),
+ updateTimeText: normalizeText(record.updateTime$ || record.updateTime)
}
}
export function getRoleStatusMeta(status) {
- if (status === true || status === 1) {
- return { type: 'success', text: '姝e父', bool: true }
+ if (status === true || status === 1 || status === '1') {
+ return ROLE_STATUS_META[1]
}
- if (status === false || status === 0) {
- return { type: 'danger', text: '绂佺敤', bool: false }
+ if (status === false || status === 0 || status === '0') {
+ return ROLE_STATUS_META[0]
}
return { type: 'info', text: '鏈煡', bool: false }
}
@@ -314,7 +322,7 @@
}
function normalizeRoleId(value) {
- if (value === '' || value === null || value === void 0) {
+ if (!hasValue(value)) {
return void 0
}
const numeric = Number(value)
@@ -323,3 +331,13 @@
}
return numeric
}
+
+function buildRoleFormData(source = {}) {
+ return {
+ id: normalizeRoleId(source.id),
+ name: normalizeText(source.name),
+ code: normalizeText(source.code),
+ memo: normalizeText(source.memo),
+ status: hasValue(source.status) ? source.status : 1
+ }
+}
--
Gitblit v1.9.1