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) => (
<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,16 +781,14 @@ 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">
<Button
variant="ghost"
size="sm"
onClick={() => handleEditEquipment(item)}
>
</Button>
</div>
<TableCell className="text-center">
<Button
variant="ghost"
size="sm"
onClick={() => handleEditEquipment(item)}
>
</Button>
</TableCell>
</TableRow>
)

View File

@@ -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>