From a2009c8cea679a2551b043f01de85e9424f33b3c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com>
Date: Sat, 18 Apr 2026 10:56:47 +0800
Subject: [PATCH] =?UTF-8?q?feat(customer):=20=E4=BC=98=E5=8C=96=E5=AE=A2?=
=?UTF-8?q?=E6=88=B7=E5=88=97=E8=A1=A8=E8=AE=BF=E9=97=AE=E6=9D=83=E9=99=90?=
=?UTF-8?q?=E5=8F=8A=E6=96=B0=E5=A2=9E=E5=A4=87=E6=B3=A8=E5=AD=97=E6=AE=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修改客户添加页面,新增“备注”输入框,支持录入客户备注信息
- 调整环境配置,统一开发、生产、测试环境的API_BASE_URL为正式地址
- 在shopDealerApply模型中新增receptionistId字段,用于查询分配的客户
- 优化客户列表权限逻辑,改为登录即可查看,不再限制角色
- 更新接口调用参数,支持查询当前登录用户提交及分配的客户
- 移除对管理员角色的特殊判断,使权限逻辑更简洁
- UI调整,未登录时显示“请先登录”提示而非“没有查看权限”
---
.workbuddy/expert-history.json | 2 +-
config/env.ts | 12 ++---
src/api/shop/shopDealerApply/model/index.ts | 1 +
src/dealer/customer/add.tsx | 3 ++
src/dealer/customer/index.tsx | 60 ++++++++-------------
5 files changed, 34 insertions(+), 44 deletions(-)
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 (
-
+