This commit is contained in:
menxipeng
2025-10-25 14:53:05 +08:00
parent ea6996ca6d
commit 6432ce7b04
2 changed files with 67 additions and 45 deletions

View File

@@ -470,7 +470,7 @@ export default function EquipmentPage() {
) : ( ) : (
merchants.map((merchant) => ( merchants.map((merchant) => (
<SelectItem key={merchant.id} value={merchant.merchantsId || merchant.id}> <SelectItem key={merchant.id} value={merchant.merchantsId || merchant.id}>
{merchant.merchantName} {merchant.merchantName} - {merchant.contactPerson}
</SelectItem> </SelectItem>
)) ))
)} )}
@@ -598,7 +598,7 @@ export default function EquipmentPage() {
<SelectContent className="max-h-[300px]"> <SelectContent className="max-h-[300px]">
{merchants.map((merchant) => ( {merchants.map((merchant) => (
<SelectItem key={merchant.id} value={merchant.merchantsId || merchant.id}> <SelectItem key={merchant.id} value={merchant.merchantsId || merchant.id}>
{merchant.merchantName} {merchant.merchantName} - {merchant.contactPerson}
</SelectItem> </SelectItem>
))} ))}
</SelectContent> </SelectContent>
@@ -717,10 +717,10 @@ export default function EquipmentPage() {
<TableRow className="bg-gray-50"> <TableRow className="bg-gray-50">
<TableHead className="font-medium"></TableHead> <TableHead className="font-medium"></TableHead>
<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"></TableHead>
<TableHead className="font-medium"></TableHead> <TableHead className="font-medium text-center"></TableHead>
</TableRow> </TableRow>
</TableHeader> </TableHeader>
<TableBody> <TableBody>
@@ -763,8 +763,8 @@ export default function EquipmentPage() {
</div> </div>
</div> </div>
</TableCell> </TableCell>
<TableCell> <TableCell className="text-center">
<div className="flex justify-center">{getStatusBadge(item.status)}</div> {getStatusBadge(item.status)}
</TableCell> </TableCell>
<TableCell> <TableCell>
<div className="space-y-1"> <div className="space-y-1">
@@ -781,16 +781,14 @@ export default function EquipmentPage() {
<div className="text-xs text-gray-500"></div> <div className="text-xs text-gray-500"></div>
</div> </div>
</TableCell> </TableCell>
<TableCell> <TableCell className="text-center">
<div className="flex items-center justify-center space-x-2"> <Button
<Button variant="ghost"
variant="ghost" size="sm"
size="sm" onClick={() => handleEditEquipment(item)}
onClick={() => handleEditEquipment(item)} >
>
</Button>
</Button>
</div>
</TableCell> </TableCell>
</TableRow> </TableRow>
) )

View File

@@ -107,7 +107,7 @@ export default function MallsPage() {
name: "", name: "",
address: "", address: "",
provinceCode: "", provinceCode: "",
mallUserId: "", mallUserIds: [] as string[],
description: "", description: "",
}) })
@@ -285,7 +285,7 @@ export default function MallsPage() {
if (newMall.provinceCode) { if (newMall.provinceCode) {
fetchMallUsers(newMall.provinceCode) fetchMallUsers(newMall.provinceCode)
// 清空已选择的商场用户 // 清空已选择的商场用户
setNewMall(prev => ({ ...prev, mallUserId: "" })) setNewMall(prev => ({ ...prev, mallUserIds: [] }))
} }
}, [newMall.provinceCode]) }, [newMall.provinceCode])
@@ -297,20 +297,22 @@ export default function MallsPage() {
) )
const handleAddMall = async () => { const handleAddMall = async () => {
const selectedMallUser = mallUsers.find((user) => user.userId === newMall.mallUserId)
const selectedProvince = provinces.find((province) => province.code === newMall.provinceCode) const selectedProvince = provinces.find((province) => province.code === newMall.provinceCode)
if (!selectedMallUser || !selectedProvince) return if (!selectedProvince || newMall.mallUserIds.length === 0) return
try { try {
setLoading(true) setLoading(true)
// 拼接userId每个userId后都加逗号包括最后一个
const mallUserIdsString = newMall.mallUserIds.map(id => id + ",").join("")
const requestBody = { const requestBody = {
mallName: newMall.name, mallName: newMall.name,
addr: newMall.address, addr: newMall.address,
province: newMall.provinceCode, province: newMall.provinceCode,
creator: "管理员", // 可以根据实际登录用户修改 creator: "管理员", // 可以根据实际登录用户修改
mallUser: newMall.mallUserId, mallUser: mallUserIdsString,
status: 1 status: 1
} }
@@ -319,7 +321,7 @@ export default function MallsPage() {
if (result.code === 200) { if (result.code === 200) {
// API调用成功重新获取商场列表 // API调用成功重新获取商场列表
await fetchMalls() await fetchMalls()
setNewMall({ name: "", address: "", provinceCode: "", mallUserId: "", description: "" }) setNewMall({ name: "", address: "", provinceCode: "", mallUserIds: [], description: "" })
setIsAddDialogOpen(false) setIsAddDialogOpen(false)
// 可以添加成功提示 // 可以添加成功提示
@@ -429,32 +431,54 @@ export default function MallsPage() {
</Select> </Select>
</div> </div>
<div className="grid gap-2"> <div className="grid gap-2">
<Label htmlFor="mallUser"></Label> <Label htmlFor="mallUser"></Label>
<Select {!newMall.provinceCode ? (
value={newMall.mallUserId} <div className="text-sm text-gray-500 p-3 border rounded-md bg-gray-50">
onValueChange={(value) => setNewMall({ ...newMall, mallUserId: value })}
disabled={loading || !newMall.provinceCode} </div>
> ) : mallUsers.length === 0 ? (
<SelectTrigger className="w-full"> <div className="text-sm text-gray-500 p-3 border rounded-md bg-gray-50">
<SelectValue placeholder={
!newMall.provinceCode </div>
? "请先选择省份" ) : (
: mallUsers.length === 0 <div className="border rounded-md max-h-[200px] overflow-y-auto">
? "该省份暂无可选商场"
: "请选择商场"
} />
</SelectTrigger>
<SelectContent className="max-h-[300px]">
{mallUsers.map((mallUser) => ( {mallUsers.map((mallUser) => (
<SelectItem key={mallUser.userId} value={mallUser.userId}> <label
<div className="flex flex-col items-start"> key={mallUser.userId}
<span>{mallUser.userName}</span> 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> <span className="text-xs text-gray-500">{mallUser.phonenumber}</span>
</div> </div>
</SelectItem> </label>
))} ))}
</SelectContent> </div>
</Select> )}
{newMall.mallUserIds.length > 0 && (
<div className="text-sm text-gray-600">
{newMall.mallUserIds.length}
</div>
)}
</div> </div>
<div className="grid gap-2"> <div className="grid gap-2">
<Label htmlFor="description"></Label> <Label htmlFor="description"></Label>
@@ -473,7 +497,7 @@ export default function MallsPage() {
</Button> </Button>
<Button <Button
onClick={handleAddMall} 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 ? "加载中..." : "确认添加"} {loading ? "加载中..." : "确认添加"}
</Button> </Button>