Files
users/app/data-dictionary/page.tsx
v0 2408d50cb0 refactor: overhaul UI for streamlined user experience
Redesign navigation, home overview, user portrait, and valuation pages
with improved functionality and responsive design.

Co-authored-by: null <4804959+fnvtk@users.noreply.github.com>
2025-07-18 13:47:12 +00:00

143 lines
4.5 KiB
TypeScript

"use client"
import { useState } from "react"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { PlusCircle } from "lucide-react"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
interface DataDictionaryItem {
id: string
fieldName: string
description: string
dataType: string
source: string
}
export default function DataDictionaryPage() {
const [dataDictionary, setDataDictionary] = useState<DataDictionaryItem[]>([
{
id: "1",
fieldName: "username",
description: "用户名",
dataType: "string",
source: "caihong_shua_users",
},
])
const [newFieldName, setNewFieldName] = useState("")
const [newFieldDescription, setNewFieldDescription] = useState("")
const [newFieldDataType, setNewFieldDataType] = useState("string")
const [newFieldSource, setNewFieldSource] = useState("")
const handleAddEntry = () => {
if (newFieldName.trim() === "") {
alert("字段名称不能为空")
return
}
const newEntry: DataDictionaryItem = {
id: Date.now().toString(),
fieldName: newFieldName,
description: newFieldDescription,
dataType: newFieldDataType,
source: newFieldSource,
}
setDataDictionary([...dataDictionary, newEntry])
setNewFieldName("")
setNewFieldDescription("")
setNewFieldDataType("string")
setNewFieldSource("")
}
return (
<div className="container mx-auto p-6 space-y-6">
<div className="flex justify-between items-center">
<div>
<h1 className="text-3xl font-bold"></h1>
<p className="text-muted-foreground mt-1"></p>
</div>
</div>
<Card>
<CardHeader>
<CardTitle></CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardContent className="space-y-4">
<div className="space-y-2">
<Label htmlFor="field-name"></Label>
<Input
id="field-name"
placeholder="请输入字段名称"
value={newFieldName}
onChange={(e) => setNewFieldName(e.target.value)}
/>
</div>
<div className="space-y-2">
<Label htmlFor="field-description"></Label>
<Input
id="field-description"
placeholder="请输入字段描述"
value={newFieldDescription}
onChange={(e) => setNewFieldDescription(e.target.value)}
/>
</div>
<div className="space-y-2">
<Label htmlFor="field-data-type"></Label>
<Input
id="field-data-type"
placeholder="请输入数据类型"
value={newFieldDataType}
onChange={(e) => setNewFieldDataType(e.target.value)}
/>
</div>
<div className="space-y-2">
<Label htmlFor="field-source"></Label>
<Input
id="field-source"
placeholder="请输入数据来源"
value={newFieldSource}
onChange={(e) => setNewFieldSource(e.target.value)}
/>
</div>
<Button onClick={handleAddEntry}>
<PlusCircle className="h-4 w-4 mr-2" />
</Button>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle></CardTitle>
</CardHeader>
<CardContent>
<Table>
<TableHeader>
<TableRow>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
</TableRow>
</TableHeader>
<TableBody>
{dataDictionary.map((item) => (
<TableRow key={item.id}>
<TableCell>{item.fieldName}</TableCell>
<TableCell>{item.description}</TableCell>
<TableCell>{item.dataType}</TableCell>
<TableCell>{item.source}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</CardContent>
</Card>
</div>
)
}