fix(role): 修复 roleSort 默认值与后端验证不一致

前端 initialValue 从 0 改为 1,min 从 0 改为 1,添加前端验证规则;
后端 RoleUpdateRequest.roleSort 补充 @Min(value=1) 验证注解。
统一前后端约束,避免默认值提交时触发验证错误。
This commit is contained in:
张翔
2026-05-06 14:15:55 +08:00
parent 5b26a355a0
commit 6115ed0214
2 changed files with 8 additions and 15 deletions
@@ -41,7 +41,7 @@ export default function RoleManagement() {
try {
const res = await roleApi.getAllPermissions()
setPermissions(Array.isArray(res) ? res : [])
} catch {}
} catch { /* ignored */ }
}
function handleAdd() {
@@ -86,7 +86,7 @@ export default function RoleManagement() {
}
setModalOpen(false)
loadRoles()
} catch {}
} catch { /* ignored */ }
}
const permissionTreeData = buildPermissionTree(permissions)
@@ -154,7 +154,7 @@ export default function RoleManagement() {
open={modalOpen}
onOk={handleSubmit}
onCancel={() => setModalOpen(false)}
destroyOnClose
destroyOnHidden
width={600}
>
<Form form={form} layout="vertical">
@@ -164,8 +164,8 @@ export default function RoleManagement() {
<Form.Item name="roleKey" label="角色标识" rules={[{ required: true, message: '请输入角色标识' }]}>
<Input />
</Form.Item>
<Form.Item name="roleSort" label="排序" initialValue={0}>
<InputNumber min={0} style={{ width: '100%' }} />
<Form.Item name="roleSort" label="排序" initialValue={1} rules={[{ type: 'number' as const, min: 1, message: '排序必须大于0' }]}>
<InputNumber min={1} style={{ width: '100%' }} />
</Form.Item>
<Form.Item name="status" label="状态" initialValue={RoleStatus.ACTIVE}>
<Select options={Object.entries(roleStatusMap).map(([value, info]) => ({ label: info.label, value }))} />