|
|
@@ -72,6 +72,11 @@ export const OrderManagement: React.FC = () => {
|
|
|
page: 1,
|
|
|
pageSize: 10,
|
|
|
});
|
|
|
+ // 临时搜索条件,用于存储用户输入但尚未提交的搜索条件
|
|
|
+ const [tempSearchParams, setTempSearchParams] = useState<OrderSearchParams>({
|
|
|
+ page: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ });
|
|
|
const [selectedOrder, setSelectedOrder] = useState<OrderDetail | undefined>();
|
|
|
const [isOrderFormOpen, setIsOrderFormOpen] = useState(false);
|
|
|
const [isAssetAssociationOpen, setIsAssetAssociationOpen] = useState(false);
|
|
|
@@ -285,21 +290,30 @@ export const OrderManagement: React.FC = () => {
|
|
|
setIsOrderDetailOpen(true);
|
|
|
};
|
|
|
|
|
|
- // 处理搜索
|
|
|
- const handleSearch = (field: keyof OrderSearchParams, value: string | number | undefined) => {
|
|
|
- setSearchParams(prev => ({
|
|
|
+ // 处理搜索条件输入(只更新临时状态,不触发搜索)
|
|
|
+ const handleSearchInputChange = (field: keyof OrderSearchParams, value: string | number | undefined) => {
|
|
|
+ setTempSearchParams(prev => ({
|
|
|
...prev,
|
|
|
[field]: value,
|
|
|
+ }));
|
|
|
+ };
|
|
|
+
|
|
|
+ // 执行搜索(点击搜索按钮时触发)
|
|
|
+ const handleExecuteSearch = () => {
|
|
|
+ setSearchParams(prev => ({
|
|
|
+ ...tempSearchParams,
|
|
|
page: 1, // 重置到第一页
|
|
|
}));
|
|
|
};
|
|
|
|
|
|
// 重置筛选条件
|
|
|
const handleResetFilters = () => {
|
|
|
- setSearchParams({
|
|
|
+ const resetParams = {
|
|
|
page: 1,
|
|
|
pageSize: 10,
|
|
|
- });
|
|
|
+ };
|
|
|
+ setTempSearchParams(resetParams);
|
|
|
+ setSearchParams(resetParams);
|
|
|
};
|
|
|
|
|
|
// 获取订单状态徽章样式
|
|
|
@@ -365,16 +379,16 @@ export const OrderManagement: React.FC = () => {
|
|
|
<label className="text-sm font-medium">订单名称</label>
|
|
|
<Input
|
|
|
placeholder="搜索订单名称"
|
|
|
- value={searchParams.orderName || ''}
|
|
|
- onChange={(e) => handleSearch('orderName', e.target.value)}
|
|
|
+ value={tempSearchParams.orderName || ''}
|
|
|
+ onChange={(e) => handleSearchInputChange('orderName', e.target.value)}
|
|
|
data-testid="search-order-name-input"
|
|
|
/>
|
|
|
</div>
|
|
|
<div className="space-y-2">
|
|
|
<label className="text-sm font-medium">订单状态</label>
|
|
|
<Select
|
|
|
- value={searchParams.orderStatus?.toString() || 'all'}
|
|
|
- onValueChange={(value) => handleSearch('orderStatus', value !== 'all' ? parseInt(value) : undefined)}
|
|
|
+ value={tempSearchParams.orderStatus?.toString() || 'all'}
|
|
|
+ onValueChange={(value) => handleSearchInputChange('orderStatus', value !== 'all' ? parseInt(value) : undefined)}
|
|
|
>
|
|
|
<SelectTrigger data-testid="filter-order-status-select">
|
|
|
<SelectValue placeholder="全部状态" />
|
|
|
@@ -392,8 +406,8 @@ export const OrderManagement: React.FC = () => {
|
|
|
<div className="space-y-2">
|
|
|
<label className="text-sm font-medium">工作状态</label>
|
|
|
<Select
|
|
|
- value={searchParams.workStatus?.toString() || 'all'}
|
|
|
- onValueChange={(value) => handleSearch('workStatus', value !== 'all' ? parseInt(value) : undefined)}
|
|
|
+ value={tempSearchParams.workStatus?.toString() || 'all'}
|
|
|
+ onValueChange={(value) => handleSearchInputChange('workStatus', value !== 'all' ? parseInt(value) : undefined)}
|
|
|
>
|
|
|
<SelectTrigger data-testid="filter-work-status-select">
|
|
|
<SelectValue placeholder="全部状态" />
|
|
|
@@ -408,11 +422,11 @@ export const OrderManagement: React.FC = () => {
|
|
|
</Select>
|
|
|
</div>
|
|
|
<div className="flex items-end gap-2">
|
|
|
- <Button variant="outline" className="w-full" data-testid="search-button">
|
|
|
+ <Button variant="outline" className="flex-1" onClick={handleExecuteSearch} data-testid="search-button">
|
|
|
<Search className="mr-2 h-4 w-4" />
|
|
|
搜索
|
|
|
</Button>
|
|
|
- <Button variant="outline" className="w-full" onClick={handleResetFilters} data-testid="reset-button">
|
|
|
+ <Button variant="outline" className="flex-1" onClick={handleResetFilters} data-testid="reset-button">
|
|
|
重置
|
|
|
</Button>
|
|
|
</div>
|
|
|
@@ -423,8 +437,8 @@ export const OrderManagement: React.FC = () => {
|
|
|
<div className="space-y-2">
|
|
|
<label className="text-sm font-medium">平台</label>
|
|
|
<PlatformSelector
|
|
|
- value={searchParams.platformId}
|
|
|
- onChange={(value) => handleSearch('platformId', value)}
|
|
|
+ value={tempSearchParams.platformId}
|
|
|
+ onChange={(value) => handleSearchInputChange('platformId', value)}
|
|
|
placeholder="选择平台"
|
|
|
className="w-full"
|
|
|
data-testid="platform-search-select"
|
|
|
@@ -434,8 +448,8 @@ export const OrderManagement: React.FC = () => {
|
|
|
<div className="space-y-2">
|
|
|
<label className="text-sm font-medium">公司</label>
|
|
|
<CompanySelector
|
|
|
- value={searchParams.companyId}
|
|
|
- onChange={(value) => handleSearch('companyId', value)}
|
|
|
+ value={tempSearchParams.companyId}
|
|
|
+ onChange={(value) => handleSearchInputChange('companyId', value)}
|
|
|
placeholder="选择公司"
|
|
|
className="w-full"
|
|
|
data-testid="company-search-select"
|
|
|
@@ -445,8 +459,8 @@ export const OrderManagement: React.FC = () => {
|
|
|
<div className="space-y-2">
|
|
|
<label className="text-sm font-medium">渠道</label>
|
|
|
<ChannelSelector
|
|
|
- value={searchParams.channelId}
|
|
|
- onChange={(value) => handleSearch('channelId', value)}
|
|
|
+ value={tempSearchParams.channelId}
|
|
|
+ onChange={(value) => handleSearchInputChange('channelId', value)}
|
|
|
placeholder="选择渠道"
|
|
|
className="w-full"
|
|
|
data-testid="channel-search-select"
|
|
|
@@ -457,8 +471,8 @@ export const OrderManagement: React.FC = () => {
|
|
|
<label className="text-sm font-medium">开始日期</label>
|
|
|
<Input
|
|
|
type="date"
|
|
|
- value={searchParams.startDate || ''}
|
|
|
- onChange={(e) => handleSearch('startDate', e.target.value || undefined)}
|
|
|
+ value={tempSearchParams.startDate || ''}
|
|
|
+ onChange={(e) => handleSearchInputChange('startDate', e.target.value || undefined)}
|
|
|
data-testid="start-date-input"
|
|
|
/>
|
|
|
</div>
|
|
|
@@ -467,8 +481,8 @@ export const OrderManagement: React.FC = () => {
|
|
|
<label className="text-sm font-medium">结束日期</label>
|
|
|
<Input
|
|
|
type="date"
|
|
|
- value={searchParams.endDate || ''}
|
|
|
- onChange={(e) => handleSearch('endDate', e.target.value || undefined)}
|
|
|
+ value={tempSearchParams.endDate || ''}
|
|
|
+ onChange={(e) => handleSearchInputChange('endDate', e.target.value || undefined)}
|
|
|
data-testid="end-date-input"
|
|
|
/>
|
|
|
</div>
|