优化
This commit is contained in:
@@ -470,7 +470,7 @@ export default function EquipmentPage() {
|
||||
) : (
|
||||
merchants.map((merchant) => (
|
||||
<SelectItem key={merchant.id} value={merchant.merchantsId || merchant.id}>
|
||||
{merchant.merchantName}
|
||||
{merchant.merchantName} - {merchant.contactPerson}
|
||||
</SelectItem>
|
||||
))
|
||||
)}
|
||||
@@ -598,7 +598,7 @@ export default function EquipmentPage() {
|
||||
<SelectContent className="max-h-[300px]">
|
||||
{merchants.map((merchant) => (
|
||||
<SelectItem key={merchant.id} value={merchant.merchantsId || merchant.id}>
|
||||
{merchant.merchantName}
|
||||
{merchant.merchantName} - {merchant.contactPerson}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
@@ -717,10 +717,10 @@ export default function EquipmentPage() {
|
||||
<TableRow className="bg-gray-50">
|
||||
<TableHead className="font-medium">设备信息</TableHead>
|
||||
<TableHead className="font-medium">商户信息</TableHead>
|
||||
<TableHead className="font-medium">状态</TableHead>
|
||||
<TableHead className="font-medium text-center">状态</TableHead>
|
||||
<TableHead className="font-medium">检测信息</TableHead>
|
||||
<TableHead className="font-medium">负责经销商</TableHead>
|
||||
<TableHead className="font-medium">操作</TableHead>
|
||||
<TableHead className="font-medium text-center">操作</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
@@ -763,8 +763,8 @@ export default function EquipmentPage() {
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex justify-center">{getStatusBadge(item.status)}</div>
|
||||
<TableCell className="text-center">
|
||||
{getStatusBadge(item.status)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="space-y-1">
|
||||
@@ -781,8 +781,7 @@ export default function EquipmentPage() {
|
||||
<div className="text-xs text-gray-500">负责人</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex items-center justify-center space-x-2">
|
||||
<TableCell className="text-center">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
@@ -790,7 +789,6 @@ export default function EquipmentPage() {
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
|
||||
@@ -107,7 +107,7 @@ export default function MallsPage() {
|
||||
name: "",
|
||||
address: "",
|
||||
provinceCode: "",
|
||||
mallUserId: "",
|
||||
mallUserIds: [] as string[],
|
||||
description: "",
|
||||
})
|
||||
|
||||
@@ -285,7 +285,7 @@ export default function MallsPage() {
|
||||
if (newMall.provinceCode) {
|
||||
fetchMallUsers(newMall.provinceCode)
|
||||
// 清空已选择的商场用户
|
||||
setNewMall(prev => ({ ...prev, mallUserId: "" }))
|
||||
setNewMall(prev => ({ ...prev, mallUserIds: [] }))
|
||||
}
|
||||
}, [newMall.provinceCode])
|
||||
|
||||
@@ -297,20 +297,22 @@ export default function MallsPage() {
|
||||
)
|
||||
|
||||
const handleAddMall = async () => {
|
||||
const selectedMallUser = mallUsers.find((user) => user.userId === newMall.mallUserId)
|
||||
const selectedProvince = provinces.find((province) => province.code === newMall.provinceCode)
|
||||
|
||||
if (!selectedMallUser || !selectedProvince) return
|
||||
if (!selectedProvince || newMall.mallUserIds.length === 0) return
|
||||
|
||||
try {
|
||||
setLoading(true)
|
||||
|
||||
// 拼接userId,每个userId后都加逗号,包括最后一个
|
||||
const mallUserIdsString = newMall.mallUserIds.map(id => id + ",").join("")
|
||||
|
||||
const requestBody = {
|
||||
mallName: newMall.name,
|
||||
addr: newMall.address,
|
||||
province: newMall.provinceCode,
|
||||
creator: "管理员", // 可以根据实际登录用户修改
|
||||
mallUser: newMall.mallUserId,
|
||||
mallUser: mallUserIdsString,
|
||||
status: 1
|
||||
}
|
||||
|
||||
@@ -319,7 +321,7 @@ export default function MallsPage() {
|
||||
if (result.code === 200) {
|
||||
// API调用成功,重新获取商场列表
|
||||
await fetchMalls()
|
||||
setNewMall({ name: "", address: "", provinceCode: "", mallUserId: "", description: "" })
|
||||
setNewMall({ name: "", address: "", provinceCode: "", mallUserIds: [], description: "" })
|
||||
setIsAddDialogOpen(false)
|
||||
|
||||
// 可以添加成功提示
|
||||
@@ -429,32 +431,54 @@ export default function MallsPage() {
|
||||
</Select>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="mallUser">选择商场</Label>
|
||||
<Select
|
||||
value={newMall.mallUserId}
|
||||
onValueChange={(value) => setNewMall({ ...newMall, mallUserId: value })}
|
||||
disabled={loading || !newMall.provinceCode}
|
||||
>
|
||||
<SelectTrigger className="w-full">
|
||||
<SelectValue placeholder={
|
||||
!newMall.provinceCode
|
||||
? "请先选择省份"
|
||||
: mallUsers.length === 0
|
||||
? "该省份暂无可选商场"
|
||||
: "请选择商场"
|
||||
} />
|
||||
</SelectTrigger>
|
||||
<SelectContent className="max-h-[300px]">
|
||||
<Label htmlFor="mallUser">选择商场用户(可多选)</Label>
|
||||
{!newMall.provinceCode ? (
|
||||
<div className="text-sm text-gray-500 p-3 border rounded-md bg-gray-50">
|
||||
请先选择省份
|
||||
</div>
|
||||
) : mallUsers.length === 0 ? (
|
||||
<div className="text-sm text-gray-500 p-3 border rounded-md bg-gray-50">
|
||||
该省份暂无可选商场用户
|
||||
</div>
|
||||
) : (
|
||||
<div className="border rounded-md max-h-[200px] overflow-y-auto">
|
||||
{mallUsers.map((mallUser) => (
|
||||
<SelectItem key={mallUser.userId} value={mallUser.userId}>
|
||||
<div className="flex flex-col items-start">
|
||||
<span>{mallUser.userName}</span>
|
||||
<label
|
||||
key={mallUser.userId}
|
||||
className="flex items-center p-3 hover:bg-gray-50 cursor-pointer border-b last:border-b-0"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={newMall.mallUserIds.includes(mallUser.userId)}
|
||||
onChange={(e) => {
|
||||
if (e.target.checked) {
|
||||
setNewMall({
|
||||
...newMall,
|
||||
mallUserIds: [...newMall.mallUserIds, mallUser.userId]
|
||||
})
|
||||
} else {
|
||||
setNewMall({
|
||||
...newMall,
|
||||
mallUserIds: newMall.mallUserIds.filter(id => id !== mallUser.userId)
|
||||
})
|
||||
}
|
||||
}}
|
||||
className="mr-3 h-4 w-4"
|
||||
disabled={loading}
|
||||
/>
|
||||
<div className="flex flex-col">
|
||||
<span className="font-medium">{mallUser.userName}</span>
|
||||
<span className="text-xs text-gray-500">{mallUser.phonenumber}</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
</label>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
)}
|
||||
{newMall.mallUserIds.length > 0 && (
|
||||
<div className="text-sm text-gray-600">
|
||||
已选择 {newMall.mallUserIds.length} 个商场用户
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="description">备注说明</Label>
|
||||
@@ -473,7 +497,7 @@ export default function MallsPage() {
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleAddMall}
|
||||
disabled={!newMall.name || !newMall.address || !newMall.provinceCode || !newMall.mallUserId || loading}
|
||||
disabled={!newMall.name || !newMall.address || !newMall.provinceCode || newMall.mallUserIds.length === 0 || loading}
|
||||
>
|
||||
{loading ? "加载中..." : "确认添加"}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user