feat: 實作使用者啟停用功能與安全性強化
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 1m1s

- 新增使用者「啟用/停用」狀態切換功能 (含後端 API、權限控管、活動紀錄)
- 強化安全性:隱藏超級管理員角色的可見度與操作權限
- 更新開發規範:加入多租戶資料同步規範於 framework.md
- 前端優化:使用 Switch 元件進行狀態快速切換,調整表格欄位順序
This commit is contained in:
2026-02-03 11:51:46 +08:00
parent 0185843c62
commit d671c08338
21 changed files with 350 additions and 161 deletions

View File

@@ -6,6 +6,8 @@ import { Input } from '@/Components/ui/input';
import { Label } from '@/Components/ui/label';
import { RadioGroup, RadioGroupItem } from '@/Components/ui/radio-group';
import { FormEvent } from 'react';
import { Switch } from '@/Components/ui/switch';
import { Can } from '@/Components/Permission/Can';
interface Role {
id: number;
@@ -18,6 +20,7 @@ interface UserData {
name: string;
email: string;
username: string | null;
is_active: boolean;
}
interface Props {
@@ -34,6 +37,7 @@ export default function UserEdit({ user, roles, currentRoles }: Props) {
password: '',
password_confirmation: '',
roles: currentRoles,
is_active: user.is_active,
});
const handleSubmit = (e: FormEvent) => {
@@ -133,6 +137,28 @@ export default function UserEdit({ user, roles, currentRoles }: Props) {
/>
{errors.email && <p className="text-sm text-red-500">{errors.email}</p>}
</div>
{/* Status */}
<Can permission="users.activate">
<div className="space-y-2">
<Label htmlFor="is_active" className="flex items-center gap-2">
<Check className="h-4 w-4" />
</Label>
<div className="flex items-center gap-2">
<Switch
id="is_active"
checked={data.is_active}
onCheckedChange={(checked: boolean) => setData('is_active', checked)}
/>
<span className="text-sm text-gray-500">
{data.is_active ? '啟用' : '停用'}
</span>
</div>
<p className="text-xs text-gray-400">
使
</p>
</div>
</Can>
</div>
{/* Roles */}