|
@@ -1,6 +1,6 @@
|
|
|
import { useState } from 'react'
|
|
import { useState } from 'react'
|
|
|
import { useQuery, useMutation } from '@tanstack/react-query'
|
|
import { useQuery, useMutation } from '@tanstack/react-query'
|
|
|
-import { Plus, Search, Edit, Trash2 } from 'lucide-react'
|
|
|
|
|
|
|
+import { Plus, Search, Edit, Trash2, X } from 'lucide-react'
|
|
|
import { format } from 'date-fns'
|
|
import { format } from 'date-fns'
|
|
|
import { useForm } from 'react-hook-form'
|
|
import { useForm } from 'react-hook-form'
|
|
|
import { zodResolver } from '@hookform/resolvers/zod'
|
|
import { zodResolver } from '@hookform/resolvers/zod'
|
|
@@ -8,6 +8,7 @@ import { toast } from 'sonner'
|
|
|
|
|
|
|
|
import { Button } from '@d8d/shared-ui-components/components/ui/button'
|
|
import { Button } from '@d8d/shared-ui-components/components/ui/button'
|
|
|
import { Input } from '@d8d/shared-ui-components/components/ui/input'
|
|
import { Input } from '@d8d/shared-ui-components/components/ui/input'
|
|
|
|
|
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@d8d/shared-ui-components/components/ui/select'
|
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@d8d/shared-ui-components/components/ui/card'
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@d8d/shared-ui-components/components/ui/card'
|
|
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@d8d/shared-ui-components/components/ui/table'
|
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@d8d/shared-ui-components/components/ui/table'
|
|
|
import { Badge } from '@d8d/shared-ui-components/components/ui/badge'
|
|
import { Badge } from '@d8d/shared-ui-components/components/ui/badge'
|
|
@@ -27,7 +28,7 @@ const updateFormSchema = UpdateBankNameDto
|
|
|
|
|
|
|
|
export const BankNameManagement = () => {
|
|
export const BankNameManagement = () => {
|
|
|
// 状态管理
|
|
// 状态管理
|
|
|
- const [searchParams, setSearchParams] = useState<BankNameQueryParams>({ page: 1, limit: 10, search: '' })
|
|
|
|
|
|
|
+ const [searchParams, setSearchParams] = useState<BankNameQueryParams>({ page: 1, limit: 10, search: '', status: 'all' })
|
|
|
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
const [isModalOpen, setIsModalOpen] = useState(false)
|
|
|
const [editingType, setEditingType] = useState<BankName | null>(null)
|
|
const [editingType, setEditingType] = useState<BankName | null>(null)
|
|
|
const [isCreateForm, setIsCreateForm] = useState(true)
|
|
const [isCreateForm, setIsCreateForm] = useState(true)
|
|
@@ -60,13 +61,20 @@ export const BankNameManagement = () => {
|
|
|
queryKey: ['advertisement-types', searchParams],
|
|
queryKey: ['advertisement-types', searchParams],
|
|
|
queryFn: async () => {
|
|
queryFn: async () => {
|
|
|
const client = bankNameClientManager.get()
|
|
const client = bankNameClientManager.get()
|
|
|
- const res = await client.index.$get({
|
|
|
|
|
- query: {
|
|
|
|
|
- page: searchParams.page,
|
|
|
|
|
- pageSize: searchParams.limit,
|
|
|
|
|
- keyword: searchParams.search
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 构建查询参数
|
|
|
|
|
+ const query: Record<string, unknown> = {
|
|
|
|
|
+ page: searchParams.page,
|
|
|
|
|
+ pageSize: searchParams.limit,
|
|
|
|
|
+ keyword: searchParams.search
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 添加状态筛选(当status不是'all'时)
|
|
|
|
|
+ if (searchParams.status && searchParams.status !== 'all') {
|
|
|
|
|
+ query.filters = JSON.stringify({ status: parseInt(searchParams.status) })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const res = await client.index.$get({ query })
|
|
|
if (res.status !== 200) throw new Error('获取银行名称列表失败')
|
|
if (res.status !== 200) throw new Error('获取银行名称列表失败')
|
|
|
return await res.json()
|
|
return await res.json()
|
|
|
}
|
|
}
|
|
@@ -260,8 +268,8 @@ export const BankNameManagement = () => {
|
|
|
<CardDescription>管理所有银行名称配置</CardDescription>
|
|
<CardDescription>管理所有银行名称配置</CardDescription>
|
|
|
</CardHeader>
|
|
</CardHeader>
|
|
|
<CardContent>
|
|
<CardContent>
|
|
|
- <div className="mb-4">
|
|
|
|
|
- <form onSubmit={(e) => { e.preventDefault(); handleSearch() }} className="flex gap-2">
|
|
|
|
|
|
|
+ <div className="mb-4 space-y-4">
|
|
|
|
|
+ <form onSubmit={(e) => { e.preventDefault(); handleSearch() }} className="flex gap-2 items-end">
|
|
|
<div className="relative flex-1 max-w-sm">
|
|
<div className="relative flex-1 max-w-sm">
|
|
|
<Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" />
|
|
<Search className="absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" />
|
|
|
<Input
|
|
<Input
|
|
@@ -272,10 +280,41 @@ export const BankNameManagement = () => {
|
|
|
data-testid="search-input"
|
|
data-testid="search-input"
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ <div className="flex flex-col gap-1">
|
|
|
|
|
+ <label className="text-xs text-muted-foreground">状态筛选</label>
|
|
|
|
|
+ <Select
|
|
|
|
|
+ value={searchParams.status || 'all'}
|
|
|
|
|
+ onValueChange={(value) => setSearchParams(prev => ({ ...prev, status: value as 'all' | '0' | '1', page: 1 }))}
|
|
|
|
|
+ data-testid="status-filter-select"
|
|
|
|
|
+ >
|
|
|
|
|
+ <SelectTrigger className="w-[140px]" data-testid="status-filter-trigger">
|
|
|
|
|
+ <SelectValue placeholder="选择状态" />
|
|
|
|
|
+ </SelectTrigger>
|
|
|
|
|
+ <SelectContent>
|
|
|
|
|
+ <SelectItem value="all" data-testid="status-all-option">全部状态</SelectItem>
|
|
|
|
|
+ <SelectItem value="1" data-testid="status-enabled-option">启用</SelectItem>
|
|
|
|
|
+ <SelectItem value="0" data-testid="status-disabled-option">禁用</SelectItem>
|
|
|
|
|
+ </SelectContent>
|
|
|
|
|
+ </Select>
|
|
|
|
|
+ </div>
|
|
|
<Button type="submit" variant="outline" data-testid="search-button">
|
|
<Button type="submit" variant="outline" data-testid="search-button">
|
|
|
搜索
|
|
搜索
|
|
|
</Button>
|
|
</Button>
|
|
|
</form>
|
|
</form>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 筛选条件标签 */}
|
|
|
|
|
+ {searchParams.status && searchParams.status !== 'all' && (
|
|
|
|
|
+ <div className="flex flex-wrap gap-2">
|
|
|
|
|
+ <Badge variant="secondary" className="flex items-center gap-1" data-testid="status-filter-badge">
|
|
|
|
|
+ 状态: {searchParams.status === '1' ? '启用' : '禁用'}
|
|
|
|
|
+ <X
|
|
|
|
|
+ className="h-3 w-3 cursor-pointer pointer-events-auto"
|
|
|
|
|
+ onClick={() => setSearchParams(prev => ({ ...prev, status: 'all', page: 1 }))}
|
|
|
|
|
+ data-testid="clear-status-filter"
|
|
|
|
|
+ />
|
|
|
|
|
+ </Badge>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div className="rounded-md border">
|
|
<div className="rounded-md border">
|