api
This commit is contained in:
@@ -109,6 +109,18 @@ interface Worker {
|
||||
// 优先级数据类型接口 - API返回键值对格式
|
||||
type PriorityData = Record<string, string>
|
||||
|
||||
// 工单状态枚举
|
||||
enum WorkOrderStatus {
|
||||
PENDING_ACCEPT = 1,
|
||||
ACCEPTED = 2,
|
||||
IN_PROGRESS = 3,
|
||||
REPAIRING = 4,
|
||||
CHECKING_INFO = 5,
|
||||
WAITING_SIGNATURE = 6,
|
||||
COMPLETED = 7
|
||||
}
|
||||
|
||||
|
||||
// 工单数据类型接口
|
||||
interface WorkOrder {
|
||||
createBy: string | null
|
||||
@@ -190,20 +202,26 @@ export default function WorkOrdersPage() {
|
||||
fetchWorkOrders()
|
||||
}, [])
|
||||
|
||||
const getStatusBadge = (status: string) => {
|
||||
switch (status) {
|
||||
case "pending":
|
||||
return <Badge className="bg-gray-100 text-gray-800">待分配</Badge>
|
||||
case "assigned":
|
||||
return <Badge className="bg-blue-100 text-blue-800">已分配</Badge>
|
||||
case "in-progress":
|
||||
return <Badge className="bg-black text-white">进行中</Badge>
|
||||
case "completed":
|
||||
return <Badge className="bg-green-100 text-green-800">已完成</Badge>
|
||||
case "cancelled":
|
||||
return <Badge variant="destructive">已取消</Badge>
|
||||
const getStatusBadge = (status: string | number) => {
|
||||
const statusValue = typeof status === 'string' ? parseInt(status) : status
|
||||
|
||||
switch (statusValue) {
|
||||
case WorkOrderStatus.PENDING_ACCEPT:
|
||||
return <Badge className="bg-gray-100 text-gray-800">待接单</Badge>
|
||||
case WorkOrderStatus.ACCEPTED:
|
||||
return <Badge className="bg-blue-100 text-blue-800">已接单</Badge>
|
||||
case WorkOrderStatus.IN_PROGRESS:
|
||||
return <Badge className="bg-yellow-100 text-yellow-800">订单进行中</Badge>
|
||||
case WorkOrderStatus.REPAIRING:
|
||||
return <Badge className="bg-orange-100 text-orange-800">订单维修中</Badge>
|
||||
case WorkOrderStatus.CHECKING_INFO:
|
||||
return <Badge className="bg-purple-100 text-purple-800">核对检测信息</Badge>
|
||||
case WorkOrderStatus.WAITING_SIGNATURE:
|
||||
return <Badge className="bg-indigo-100 text-indigo-800">待商户签字</Badge>
|
||||
case WorkOrderStatus.COMPLETED:
|
||||
return <Badge className="bg-green-100 text-green-800">订单已完成</Badge>
|
||||
default:
|
||||
return <Badge variant="outline">未知</Badge>
|
||||
return <Badge variant="outline">未知状态</Badge>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +276,9 @@ export default function WorkOrdersPage() {
|
||||
item.equipmentName.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
item.merchantName.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
item.workerName.toLowerCase().includes(searchTerm.toLowerCase())
|
||||
const itemStatus = item.workersId ? "assigned" : "pending"
|
||||
|
||||
// 使用工单的实际状态进行过滤
|
||||
const itemStatus = item.status || "1" // 默认为待接单状态
|
||||
const matchesStatus = statusFilter === "all" || itemStatus === statusFilter
|
||||
const matchesPriority = priorityFilter === "all" || item.priority === priorityFilter
|
||||
const matchesWorker = workerFilter === "all" || item.workerName === workerFilter
|
||||
@@ -378,11 +398,13 @@ export default function WorkOrdersPage() {
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">全部状态</SelectItem>
|
||||
<SelectItem value="pending">待分配</SelectItem>
|
||||
<SelectItem value="assigned">已分配</SelectItem>
|
||||
<SelectItem value="in-progress">进行中</SelectItem>
|
||||
<SelectItem value="completed">已完成</SelectItem>
|
||||
<SelectItem value="cancelled">已取消</SelectItem>
|
||||
<SelectItem value="1">待接单</SelectItem>
|
||||
<SelectItem value="2">已接单</SelectItem>
|
||||
<SelectItem value="3">订单进行中</SelectItem>
|
||||
<SelectItem value="4">订单维修中</SelectItem>
|
||||
<SelectItem value="5">核对检测信息</SelectItem>
|
||||
<SelectItem value="6">待商户签字</SelectItem>
|
||||
<SelectItem value="7">订单已完成</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
@@ -473,7 +495,7 @@ export default function WorkOrdersPage() {
|
||||
{getPriorityBadge(item.priority)}
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>{getStatusBadge(item.workersId ? "assigned" : "pending")}</TableCell>
|
||||
<TableCell>{getStatusBadge(item.status || "1")}</TableCell>
|
||||
<TableCell>
|
||||
<div className="space-y-1">
|
||||
<div className="font-medium">{item.workerName}</div>
|
||||
|
Reference in New Issue
Block a user