feat: 統一各模組分頁組件佈局並新增系統設定功能相關檔案
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 1m5s

This commit is contained in:
2026-02-25 16:16:49 +08:00
parent 878b90e2ad
commit e3df090afd
59 changed files with 889 additions and 299 deletions

View File

@@ -318,22 +318,25 @@ export default function ActivityLogIndex({ activities, filters, subject_types, u
from={activities.from}
/>
<div className="mt-4 flex flex-col md:flex-row items-center justify-between gap-4">
<div className="flex items-center gap-2 text-sm text-gray-500">
<span></span>
<SearchableSelect
value={perPage}
onValueChange={handlePerPageChange}
options={[
{ label: "10", value: "10" },
{ label: "20", value: "20" },
{ label: "50", value: "50" },
{ label: "100", value: "100" }
]}
className="w-[100px] h-8"
showSearch={false}
/>
<span></span>
<div className="mt-6 flex flex-col sm:flex-row items-center justify-between gap-4">
<div className="flex items-center gap-4">
<div className="flex items-center gap-2 text-sm text-gray-500">
<span></span>
<SearchableSelect
value={perPage}
onValueChange={handlePerPageChange}
options={[
{ label: "10", value: "10" },
{ label: "20", value: "20" },
{ label: "50", value: "50" },
{ label: "100", value: "100" }
]}
className="w-[100px] h-8"
showSearch={false}
/>
<span></span>
</div>
<span className="text-sm text-gray-500"> {activities.total} </span>
</div>
<div className="w-full md:w-auto flex justify-center md:justify-end">
<Pagination links={activities.links} />

View File

@@ -0,0 +1,178 @@
import React from "react";
import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout";
import { Head, useForm } from "@inertiajs/react";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle
} from "@/Components/ui/card";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/Components/ui/tabs";
import { Input } from "@/Components/ui/input";
import { Label } from "@/Components/ui/label";
import { Button } from "@/Components/ui/button";
import {
Coins,
Package,
RefreshCcw,
Monitor,
Save,
Settings
} from "lucide-react";
import { toast } from "sonner";
interface Setting {
key: string;
value: string;
description: string;
}
interface PageProps {
settings: Record<string, Setting[]>;
}
export default function SettingIndex({ settings }: PageProps) {
const { data, setData, post, processing } = useForm({
settings: Object.values(settings).flat().map(s => ({
key: s.key,
value: s.value
}))
});
const handleValueChange = (key: string, value: string) => {
const newSettings = data.settings.map(s =>
s.key === key ? { ...s, value } : s
);
setData('settings', newSettings);
};
const submit = (e: React.FormEvent) => {
e.preventDefault();
post(route('settings.update'), {
onSuccess: () => toast.success("系統設定已更新"),
});
};
const renderSettingRow = (setting: Setting) => {
const currentVal = data.settings.find(s => s.key === setting.key)?.value || '';
return (
<div key={setting.key} className="grid grid-cols-1 md:grid-cols-2 gap-4 items-center py-4 border-b last:border-0 border-gray-100">
<div>
<Label className="text-base font-semibold text-grey-0">{setting.description}</Label>
<p className="text-sm text-gray-500 mt-1">{setting.key}</p>
</div>
<div>
<Input
type="text"
value={currentVal}
onChange={(e) => handleValueChange(setting.key, e.target.value)}
className="max-w-xs"
/>
</div>
</div>
);
};
return (
<AuthenticatedLayout
breadcrumbs={[
{ label: "系統管理", href: "#" },
{ label: "系統設定" }
]}
>
<Head title="系統設定" />
<div className="container mx-auto p-6 max-w-7xl">
<div className="mb-6">
<h1 className="text-2xl font-bold text-grey-0 flex items-center gap-2">
<Settings className="h-6 w-6 text-primary-main" />
</h1>
<p className="text-gray-500 mt-2">
</p>
</div>
<form onSubmit={submit}>
<Tabs defaultValue="finance" className="space-y-6">
<TabsList className="bg-white border p-1 h-auto gap-2">
<TabsTrigger value="finance" className="gap-2 py-2 data-[state=active]:button-filled-primary data-[state=active]:text-white">
<Coins className="h-4 w-4" />
</TabsTrigger>
<TabsTrigger value="inventory" className="gap-2 py-2 data-[state=active]:button-filled-primary data-[state=active]:text-white">
<Package className="h-4 w-4" />
</TabsTrigger>
<TabsTrigger value="turnover" className="gap-2 py-2 data-[state=active]:button-filled-primary data-[state=active]:text-white">
<RefreshCcw className="h-4 w-4" />
</TabsTrigger>
<TabsTrigger value="display" className="gap-2 py-2 data-[state=active]:button-filled-primary data-[state=active]:text-white">
<Monitor className="h-4 w-4" />
</TabsTrigger>
</TabsList>
<TabsContent value="finance">
<Card>
<CardHeader>
<CardTitle></CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent className="space-y-1">
{settings.finance?.map(renderSettingRow)}
</CardContent>
</Card>
</TabsContent>
<TabsContent value="inventory">
<Card>
<CardHeader>
<CardTitle></CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent className="space-y-1">
{settings.inventory?.map(renderSettingRow)}
</CardContent>
</Card>
</TabsContent>
<TabsContent value="turnover">
<Card>
<CardHeader>
<CardTitle></CardTitle>
<CardDescription>調</CardDescription>
</CardHeader>
<CardContent className="space-y-1">
{settings.turnover?.map(renderSettingRow)}
</CardContent>
</Card>
</TabsContent>
<TabsContent value="display">
<Card>
<CardHeader>
<CardTitle></CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent className="space-y-1">
{settings.display?.map(renderSettingRow)}
</CardContent>
</Card>
</TabsContent>
<div className="flex justify-end gap-4 mt-6">
<Button
type="submit"
className="button-filled-primary"
disabled={processing}
>
<Save className="h-4 w-4 mr-2" />
{processing ? "儲存中..." : "儲存設定"}
</Button>
</div>
</Tabs>
</form>
</div>
</AuthenticatedLayout>
);
}

View File

@@ -56,6 +56,7 @@ interface Props {
users: {
data: User[];
from: number;
total: number;
links: PaginationLinks[];
};
filters: {
@@ -394,22 +395,25 @@ export default function UserIndex({ users, roles, filters }: Props) {
</div>
{/* 分頁元件 - 統一樣式 */}
<div className="mt-4 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4">
<div className="flex items-center gap-2 text-sm text-gray-500">
<span></span>
<SearchableSelect
value={perPage}
onValueChange={handlePerPageChange}
options={[
{ label: "10", value: "10" },
{ label: "20", value: "20" },
{ label: "50", value: "50" },
{ label: "100", value: "100" }
]}
className="w-[100px] h-8"
showSearch={false}
/>
<span></span>
<div className="mt-6 flex flex-col sm:flex-row items-center justify-between gap-4">
<div className="flex items-center gap-4">
<div className="flex items-center gap-2 text-sm text-gray-500">
<span></span>
<SearchableSelect
value={perPage}
onValueChange={handlePerPageChange}
options={[
{ label: "10", value: "10" },
{ label: "20", value: "20" },
{ label: "50", value: "50" },
{ label: "100", value: "100" }
]}
className="w-[100px] h-8"
showSearch={false}
/>
<span></span>
</div>
<span className="text-sm text-gray-500"> {users.total} </span>
</div>
<div className="w-full sm:w-auto flex justify-center sm:justify-end">
<Pagination links={users.links} />