diff --git a/.workbuddy/expert-history.json b/.workbuddy/expert-history.json index 4685c69..3c69eb4 100644 --- a/.workbuddy/expert-history.json +++ b/.workbuddy/expert-history.json @@ -35,5 +35,5 @@ } ] }, - "lastUpdated": 1776331561536 + "lastUpdated": 1776332994640 } \ No newline at end of file diff --git a/config/env.ts b/config/env.ts index 7d83fe0..6df3879 100644 --- a/config/env.ts +++ b/config/env.ts @@ -2,22 +2,22 @@ export const ENV_CONFIG = { // 开发环境 development: { - // API_BASE_URL: 'https://mp-api.websoft.top/api', - API_BASE_URL: 'http://127.0.0.1:9200/api', + API_BASE_URL: 'https://mp-api.websoft.top/api', + // API_BASE_URL: 'http://127.0.0.1:9200/api', APP_NAME: '开发环境', DEBUG: 'true', }, // 生产环境 production: { - // API_BASE_URL: 'https://mp-api.websoft.top/api', - API_BASE_URL: 'http://127.0.0.1:9200/api', + API_BASE_URL: 'https://mp-api.websoft.top/api', + // API_BASE_URL: 'http://127.0.0.1:9200/api', APP_NAME: '南南佐顿门窗', DEBUG: 'false', }, // 测试环境 test: { - // API_BASE_URL: 'https://mp-api.websoft.top/api', - API_BASE_URL: 'http://127.0.0.1:9200/api', + API_BASE_URL: 'https://mp-api.websoft.top/api', + // API_BASE_URL: 'http://127.0.0.1:9200/api', APP_NAME: '测试环境', DEBUG: 'true', } diff --git a/src/api/shop/shopDealerApply/model/index.ts b/src/api/shop/shopDealerApply/model/index.ts index 0fef919..ddc6b5c 100644 --- a/src/api/shop/shopDealerApply/model/index.ts +++ b/src/api/shop/shopDealerApply/model/index.ts @@ -66,4 +66,5 @@ export interface ShopDealerApplyParam extends PageParam { userId?: number; keywords?: string; applyStatus?: number; // 申请状态筛选 (10待审核 20审核通过 30驳回) + receptionistId?: number; // 接待人员用户ID(用于查询分配给自己的客户) } diff --git a/src/dealer/customer/add.tsx b/src/dealer/customer/add.tsx index 294bb1a..03afaa5 100644 --- a/src/dealer/customer/add.tsx +++ b/src/dealer/customer/add.tsx @@ -1138,6 +1138,9 @@ const AddShopDealerApply = () => { + + + {isEditMode && ( <> diff --git a/src/dealer/customer/index.tsx b/src/dealer/customer/index.tsx index 6c574cf..7e245ea 100644 --- a/src/dealer/customer/index.tsx +++ b/src/dealer/customer/index.tsx @@ -1,4 +1,4 @@ -import {useState, useEffect, useCallback, useRef} from 'react' +import {useState, useEffect, useCallback} from 'react' import {View, Text} from '@tarojs/components' import Taro, {useDidShow} from '@tarojs/taro' import {Loading, InfiniteLoading, Empty, Space, Tabs, TabPane, Tag, Button, SearchBar} from '@nutui/nutui-react-taro' @@ -33,24 +33,10 @@ const CustomerIndex = () => { const [page, setPage] = useState(1) const [hasMore, setHasMore] = useState(true) - // 非分销商不允许查看客户列表 - const {user, hasRole, loading: userLoading} = useUser() - // 管理员允许查看全部;普通分销商仅查看自己 - const isAdminUser = user?.isAdmin === true - const canView = hasRole('dealer') || isAdminUser + // 权限检查:只要登录就能查看客户列表 + const {user, loading: userLoading} = useUser() const roleCheckFinished = !userLoading - const noPermissionShownRef = useRef(false) - - useEffect(() => { - if (!roleCheckFinished || canView) return - if (noPermissionShownRef.current) return - noPermissionShownRef.current = true - Taro.showToast({ - title: '没有查看权限', - icon: 'none', - duration: 1500 - }) - }, [roleCheckFinished, canView]) + const isLoggedIn = roleCheckFinished && user !== null // Tab配置 const tabList = getStatusOptions(); @@ -201,14 +187,13 @@ const CustomerIndex = () => { const currentUserId = Number(Taro.getStorageSync('UserId')) || user?.userId || 0; // 构建API参数,根据状态筛选 + // 查看自己提交的(userId)或分配给自己的(receptionistId)的客户 const params: any = { type: 4, - page: currentPage + page: currentPage, + userId: currentUserId, + receptionistId: currentUserId }; - // 非管理员:只看自己添加的客户 - if (!isAdminUser && currentUserId > 0) { - params.userId = currentUserId; - } const applyStatus = mapCustomerStatusToApplyStatus(statusFilter || activeTab); if (applyStatus !== undefined) { params.applyStatus = applyStatus; @@ -251,7 +236,7 @@ const CustomerIndex = () => { } finally { setLoading(false); } - }, [activeTab, page, isAdminUser, user?.userId]); + }, [activeTab, page, user?.userId]); const reloadMore = async () => { if (loading || !hasMore) return; // 防止重复加载 @@ -300,11 +285,11 @@ const CustomerIndex = () => { const fetchStatusCounts = useCallback(async () => { try { const currentUserId = Number(Taro.getStorageSync('UserId')) || user?.userId || 0; - const baseParams: any = {type: 4}; - // 非管理员:只统计自己添加的客户 - if (!isAdminUser && currentUserId > 0) { - baseParams.userId = currentUserId; - } + const baseParams: any = { + type: 4, + userId: currentUserId, + receptionistId: currentUserId + }; // 并行获取各状态的数量 const [allRes, pendingRes, signedRes, cancelledRes] = await Promise.all([ @@ -323,7 +308,7 @@ const CustomerIndex = () => { } catch (error) { console.error('获取状态统计失败:', error); } - }, [isAdminUser, user?.userId]); + }, [user?.userId]); const getStatusCounts = () => statusCounts; @@ -364,22 +349,22 @@ const CustomerIndex = () => { // 初始化统计数据 useEffect(() => { - if (!roleCheckFinished || !canView) return; + if (!isLoggedIn) return; fetchStatusCounts().then(); - }, [roleCheckFinished, canView]); + }, [isLoggedIn]); // 当activeTab变化时重新获取数据 useEffect(() => { - if (!roleCheckFinished || !canView) return; + if (!isLoggedIn) return; setList([]); // 清空列表 setPage(1); // 重置页码 setHasMore(true); // 重置加载状态 fetchCustomerData(activeTab, true); - }, [activeTab, roleCheckFinished, canView]); + }, [activeTab, isLoggedIn]); // 监听页面显示,当从其他页面返回时刷新数据 useDidShow(() => { - if (!roleCheckFinished || !canView) return; + if (!isLoggedIn) return; // 刷新当前tab的数据和统计信息 setList([]); setPage(1); @@ -593,10 +578,11 @@ const CustomerIndex = () => { ); } - if (!canView) { + // 未登录时显示提示 + if (!isLoggedIn) { return ( - +