页面
This commit is contained in:
@@ -44,7 +44,7 @@ export default function LoginPage() {
|
|||||||
// 如果接口失败,使用默认角色列表作为备选
|
// 如果接口失败,使用默认角色列表作为备选
|
||||||
setRoles([
|
setRoles([
|
||||||
{ roleId: "admin", roleName: "总部管理员", roleKey: "admin", remark: "", admin: true },
|
{ roleId: "admin", roleName: "总部管理员", roleKey: "admin", remark: "", admin: true },
|
||||||
{ roleId: "dealer", roleName: "经销商", roleKey: "dealer", remark: "", admin: false },
|
{ roleId: "dealer", roleName: "区域负责人", roleKey: "dealer", remark: "", admin: false },
|
||||||
{ roleId: "mall", roleName: "商场管理员", roleKey: "mall", remark: "", admin: false },
|
{ roleId: "mall", roleName: "商场管理员", roleKey: "mall", remark: "", admin: false },
|
||||||
{ roleId: "merchant", roleName: "商户", roleKey: "merchant", remark: "", admin: false },
|
{ roleId: "merchant", roleName: "商户", roleKey: "merchant", remark: "", admin: false },
|
||||||
{ roleId: "worker", roleName: "维修工人", roleKey: "worker", remark: "", admin: false },
|
{ roleId: "worker", roleName: "维修工人", roleKey: "worker", remark: "", admin: false },
|
||||||
@@ -55,7 +55,7 @@ export default function LoginPage() {
|
|||||||
// 网络错误时使用默认角色列表
|
// 网络错误时使用默认角色列表
|
||||||
setRoles([
|
setRoles([
|
||||||
{ roleId: "admin", roleName: "总部管理员", roleKey: "admin", remark: "", admin: true },
|
{ roleId: "admin", roleName: "总部管理员", roleKey: "admin", remark: "", admin: true },
|
||||||
{ roleId: "dealer", roleName: "经销商", roleKey: "dealer", remark: "", admin: false },
|
{ roleId: "dealer", roleName: "区域负责人", roleKey: "dealer", remark: "", admin: false },
|
||||||
{ roleId: "mall", roleName: "商场管理员", roleKey: "mall", remark: "", admin: false },
|
{ roleId: "mall", roleName: "商场管理员", roleKey: "mall", remark: "", admin: false },
|
||||||
{ roleId: "merchant", roleName: "商户", roleKey: "merchant", remark: "", admin: false },
|
{ roleId: "merchant", roleName: "商户", roleKey: "merchant", remark: "", admin: false },
|
||||||
{ roleId: "worker", roleName: "维修工人", roleKey: "worker", remark: "", admin: false },
|
{ roleId: "worker", roleName: "维修工人", roleKey: "worker", remark: "", admin: false },
|
||||||
|
|||||||
@@ -78,6 +78,13 @@ export default function MerchantsPage() {
|
|||||||
const [userRole, setUserRole] = useState<string>("")
|
const [userRole, setUserRole] = useState<string>("")
|
||||||
const [currentPage, setCurrentPage] = useState(1)
|
const [currentPage, setCurrentPage] = useState(1)
|
||||||
const [pageSize, setPageSize] = useState(10)
|
const [pageSize, setPageSize] = useState(10)
|
||||||
|
const [userEquipmentCount, setUserEquipmentCount] = useState({
|
||||||
|
count: 0,
|
||||||
|
totalCount: 0,
|
||||||
|
countEnd: 0,
|
||||||
|
countExpire: 0
|
||||||
|
})
|
||||||
|
const [loadingUserEquipmentCount, setLoadingUserEquipmentCount] = useState(false)
|
||||||
|
|
||||||
const [newMerchant, setNewMerchant] = useState({
|
const [newMerchant, setNewMerchant] = useState({
|
||||||
name: "",
|
name: "",
|
||||||
@@ -120,6 +127,26 @@ export default function MerchantsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取用户设备统计数量
|
||||||
|
const fetchUserEquipmentCount = async () => {
|
||||||
|
setLoadingUserEquipmentCount(true)
|
||||||
|
try {
|
||||||
|
const response = await apiGet('/back/equipment/user/count')
|
||||||
|
if (response.code === 200) {
|
||||||
|
setUserEquipmentCount({
|
||||||
|
count: response.data?.count || 0,
|
||||||
|
totalCount: response.data?.totalCount || 0,
|
||||||
|
countEnd: response.data?.countEnd || 0,
|
||||||
|
countExpire: response.data?.countExpire || 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取用户设备统计失败:', error)
|
||||||
|
} finally {
|
||||||
|
setLoadingUserEquipmentCount(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 处理省份变化
|
// 处理省份变化
|
||||||
const handleProvinceChange = (province: string) => {
|
const handleProvinceChange = (province: string) => {
|
||||||
setNewMerchant({
|
setNewMerchant({
|
||||||
@@ -263,6 +290,7 @@ export default function MerchantsPage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchUserRole()
|
fetchUserRole()
|
||||||
fetchMerchants()
|
fetchMerchants()
|
||||||
|
fetchUserEquipmentCount()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const [newEquipment, setNewEquipment] = useState({
|
const [newEquipment, setNewEquipment] = useState({
|
||||||
@@ -404,6 +432,18 @@ export default function MerchantsPage() {
|
|||||||
if (merchant.province) {
|
if (merchant.province) {
|
||||||
fetchMalls(merchant.province)
|
fetchMalls(merchant.province)
|
||||||
}
|
}
|
||||||
|
// 加载总商户列表(如果为空,或者商户有总商户ID但列表中没有对应的项)
|
||||||
|
if (!loadingTotalMerchants) {
|
||||||
|
if (totalMerchants.length === 0) {
|
||||||
|
fetchTotalMerchants()
|
||||||
|
} else if (merchant.totalMerchantId) {
|
||||||
|
// 如果商户有总商户ID,但列表中找不到对应的项,重新加载
|
||||||
|
const found = totalMerchants.find(tm => tm.userId === merchant.totalMerchantId)
|
||||||
|
if (!found) {
|
||||||
|
fetchTotalMerchants()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理编辑省份变化
|
// 处理编辑省份变化
|
||||||
@@ -544,10 +584,18 @@ export default function MerchantsPage() {
|
|||||||
<SelectValue placeholder="筛选状态" />
|
<SelectValue placeholder="筛选状态" />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="all">全部状态</SelectItem>
|
<SelectItem value="all">
|
||||||
<SelectItem value="normal">设备正常</SelectItem>
|
全部状态 {loadingUserEquipmentCount ? '' : `(${userEquipmentCount.totalCount})`}
|
||||||
<SelectItem value="expiring">有设备即将到期</SelectItem>
|
</SelectItem>
|
||||||
<SelectItem value="expired">有设备过期</SelectItem>
|
<SelectItem value="normal">
|
||||||
|
设备正常 {loadingUserEquipmentCount ? '' : `(${userEquipmentCount.count})`}
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="expiring">
|
||||||
|
有设备即将到期 {loadingUserEquipmentCount ? '' : `(${userEquipmentCount.countEnd})`}
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="expired">
|
||||||
|
有设备过期 {loadingUserEquipmentCount ? '' : `(${userEquipmentCount.countExpire})`}
|
||||||
|
</SelectItem>
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
@@ -639,11 +687,9 @@ export default function MerchantsPage() {
|
|||||||
<Eye className="h-4 w-4 mr-1" />
|
<Eye className="h-4 w-4 mr-1" />
|
||||||
查看设备({merchant.equipmentCount})
|
查看设备({merchant.equipmentCount})
|
||||||
</Button>
|
</Button>
|
||||||
{userRole !== "merchant" && (
|
<Button variant="outline" size="sm" onClick={() => handleEditMerchant(merchant)}>
|
||||||
<Button variant="outline" size="sm" onClick={() => handleEditMerchant(merchant)}>
|
编辑
|
||||||
编辑
|
</Button>
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@@ -679,11 +725,9 @@ export default function MerchantsPage() {
|
|||||||
<Eye className="h-3 w-3 mr-1" />
|
<Eye className="h-3 w-3 mr-1" />
|
||||||
{merchant.equipmentCount}
|
{merchant.equipmentCount}
|
||||||
</Button>
|
</Button>
|
||||||
{userRole !== "merchant" && (
|
<Button variant="outline" size="sm" onClick={() => handleEditMerchant(merchant)}>
|
||||||
<Button variant="outline" size="sm" onClick={() => handleEditMerchant(merchant)}>
|
<Edit className="h-4 w-4" />
|
||||||
<Edit className="h-4 w-4" />
|
</Button>
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -891,32 +935,36 @@ export default function MerchantsPage() {
|
|||||||
placeholder="请输入联系电话"
|
placeholder="请输入联系电话"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{userRole === "admin" && (
|
<div className="space-y-2">
|
||||||
<div className="space-y-2">
|
<Label htmlFor="totalMerchant">选择总商户(可选)</Label>
|
||||||
<Label htmlFor="totalMerchant">选择总商户(可选)</Label>
|
<Select
|
||||||
<Select
|
value={newMerchant.totalMerchant}
|
||||||
value={newMerchant.totalMerchant}
|
onValueChange={(value) => setNewMerchant({ ...newMerchant, totalMerchant: value })}
|
||||||
onValueChange={(value) => setNewMerchant({ ...newMerchant, totalMerchant: value })}
|
disabled={loadingTotalMerchants}
|
||||||
disabled={loadingTotalMerchants}
|
onOpenChange={(open) => {
|
||||||
onOpenChange={(open) => {
|
if (open && totalMerchants.length === 0 && !loadingTotalMerchants) {
|
||||||
if (open && totalMerchants.length === 0 && !loadingTotalMerchants) {
|
fetchTotalMerchants()
|
||||||
fetchTotalMerchants()
|
}
|
||||||
}
|
}}
|
||||||
}}
|
>
|
||||||
>
|
<SelectTrigger className="w-full">
|
||||||
<SelectTrigger className="w-full">
|
<SelectValue placeholder={loadingTotalMerchants ? "加载中..." : "选择总商户(可选)"} />
|
||||||
<SelectValue placeholder={loadingTotalMerchants ? "加载中..." : "选择总商户(可选)"} />
|
</SelectTrigger>
|
||||||
</SelectTrigger>
|
<SelectContent className="max-h-[300px]">
|
||||||
<SelectContent className="max-h-[300px]">
|
{totalMerchants.length === 0 && !loadingTotalMerchants ? (
|
||||||
{totalMerchants.map((merchant) => (
|
<SelectItem value="no-data" disabled>
|
||||||
|
点击加载总商户数据
|
||||||
|
</SelectItem>
|
||||||
|
) : (
|
||||||
|
totalMerchants.map((merchant) => (
|
||||||
<SelectItem key={merchant.userId} value={merchant.userId}>
|
<SelectItem key={merchant.userId} value={merchant.userId}>
|
||||||
{merchant.nickName}
|
{merchant.nickName}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
))
|
||||||
</SelectContent>
|
)}
|
||||||
</Select>
|
</SelectContent>
|
||||||
</div>
|
</Select>
|
||||||
)}
|
</div>
|
||||||
<div className="col-span-2 space-y-2">
|
<div className="col-span-2 space-y-2">
|
||||||
<Label htmlFor="detailedAddress">详细地址</Label>
|
<Label htmlFor="detailedAddress">详细地址</Label>
|
||||||
<Textarea
|
<Textarea
|
||||||
@@ -1124,32 +1172,54 @@ export default function MerchantsPage() {
|
|||||||
placeholder="请输入联系电话"
|
placeholder="请输入联系电话"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{userRole === "admin" && (
|
<div className="space-y-2">
|
||||||
<div className="space-y-2">
|
<Label htmlFor="edit-totalMerchant">选择总商户(可选)</Label>
|
||||||
<Label htmlFor="edit-totalMerchant">选择总商户(可选)</Label>
|
<Select
|
||||||
<Select
|
value={editMerchant.totalMerchant || undefined}
|
||||||
value={editMerchant.totalMerchant}
|
onValueChange={(value) => {
|
||||||
onValueChange={(value) => setEditMerchant({ ...editMerchant, totalMerchant: value })}
|
if (value === "clear") {
|
||||||
disabled={loadingTotalMerchants}
|
setEditMerchant({ ...editMerchant, totalMerchant: "" })
|
||||||
onOpenChange={(open) => {
|
} else {
|
||||||
if (open && totalMerchants.length === 0 && !loadingTotalMerchants) {
|
setEditMerchant({ ...editMerchant, totalMerchant: value })
|
||||||
fetchTotalMerchants()
|
}
|
||||||
}
|
}}
|
||||||
}}
|
disabled={loadingTotalMerchants}
|
||||||
>
|
onOpenChange={(open) => {
|
||||||
<SelectTrigger className="w-full">
|
if (open && totalMerchants.length === 0 && !loadingTotalMerchants) {
|
||||||
<SelectValue placeholder={loadingTotalMerchants ? "加载中..." : "选择总商户(可选)"} />
|
fetchTotalMerchants()
|
||||||
</SelectTrigger>
|
}
|
||||||
<SelectContent className="max-h-[300px]">
|
}}
|
||||||
{totalMerchants.map((merchant) => (
|
>
|
||||||
<SelectItem key={merchant.userId} value={merchant.userId}>
|
<SelectTrigger className="w-full">
|
||||||
{merchant.nickName}
|
<SelectValue placeholder={loadingTotalMerchants ? "加载中..." : editMerchant.totalMerchant ? "已选择总商户" : "选择总商户(可选)"} />
|
||||||
</SelectItem>
|
</SelectTrigger>
|
||||||
))}
|
<SelectContent className="max-h-[300px]">
|
||||||
</SelectContent>
|
{editMerchant.totalMerchant && !totalMerchants.find(tm => tm.userId === editMerchant.totalMerchant) && (
|
||||||
</Select>
|
<SelectItem value={editMerchant.totalMerchant} disabled>
|
||||||
</div>
|
{editMerchant.totalMerchant} (加载中...)
|
||||||
)}
|
</SelectItem>
|
||||||
|
)}
|
||||||
|
{totalMerchants.length === 0 && !loadingTotalMerchants ? (
|
||||||
|
<SelectItem value="no-data" disabled>
|
||||||
|
{editMerchant.totalMerchant ? "当前值: " + editMerchant.totalMerchant : "点击加载总商户数据"}
|
||||||
|
</SelectItem>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{editMerchant.totalMerchant && (
|
||||||
|
<SelectItem value="clear">
|
||||||
|
清除选择
|
||||||
|
</SelectItem>
|
||||||
|
)}
|
||||||
|
{totalMerchants.map((merchant) => (
|
||||||
|
<SelectItem key={merchant.userId} value={merchant.userId}>
|
||||||
|
{merchant.nickName}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
<div className="col-span-2 space-y-2">
|
<div className="col-span-2 space-y-2">
|
||||||
<Label htmlFor="edit-detailedAddress">详细地址</Label>
|
<Label htmlFor="edit-detailedAddress">详细地址</Label>
|
||||||
<Textarea
|
<Textarea
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ export default function WorkOrderArchivePage() {
|
|||||||
<Eye className="h-4 w-4 mr-1" />
|
<Eye className="h-4 w-4 mr-1" />
|
||||||
查看详情
|
查看详情
|
||||||
</Button>
|
</Button>
|
||||||
{((order.equipmentName?.includes("厨房自动灭火") || order.equipmentName === "厨房自动灭火设备") && (order.workOrderType === "设备安装" || order.workOrderType === "设备检测" || order.workOrderType === "设备改造" || order.workOrderType === "设备维修" || order.workOrderType === "故障维修" || order.workOrderType === "设备拆除" || order.workOrderType === "更换药剂")) && (
|
{(order.workOrderType === "设备安装" || order.workOrderType === "设备检测" || order.workOrderType === "故障检测") && (
|
||||||
<Button variant="outline" size="sm" onClick={() => handleDownloadReport(order.workOrderNumber)}>
|
<Button variant="outline" size="sm" onClick={() => handleDownloadReport(order.workOrderNumber)}>
|
||||||
<FileDown className="h-4 w-4 mr-1" />
|
<FileDown className="h-4 w-4 mr-1" />
|
||||||
下载报告
|
下载报告
|
||||||
@@ -341,7 +341,7 @@ export default function WorkOrderArchivePage() {
|
|||||||
<Eye className="h-3 w-3 mr-1" />
|
<Eye className="h-3 w-3 mr-1" />
|
||||||
查看
|
查看
|
||||||
</Button>
|
</Button>
|
||||||
{((order.equipmentName?.includes("厨房自动灭火") || order.equipmentName === "厨房自动灭火设备") && (order.workOrderType === "设备安装" || order.workOrderType === "设备检测" || order.workOrderType === "设备改造" || order.workOrderType === "设备维修" || order.workOrderType === "故障维修" || order.workOrderType === "设备拆除" || order.workOrderType === "更换药剂")) && (
|
{(order.workOrderType === "设备安装" || order.workOrderType === "设备检测" || order.workOrderType === "故障检测") && (
|
||||||
<Button variant="outline" size="sm" onClick={() => handleDownloadReport(order.workOrderNumber)} className="text-xs">
|
<Button variant="outline" size="sm" onClick={() => handleDownloadReport(order.workOrderNumber)} className="text-xs">
|
||||||
<FileDown className="h-3 w-3 mr-1" />
|
<FileDown className="h-3 w-3 mr-1" />
|
||||||
下载
|
下载
|
||||||
|
|||||||
Reference in New Issue
Block a user