feat(customer): 优化客户列表访问权限及新增备注字段
- 修改客户添加页面,新增“备注”输入框,支持录入客户备注信息 - 调整环境配置,统一开发、生产、测试环境的API_BASE_URL为正式地址 - 在shopDealerApply模型中新增receptionistId字段,用于查询分配的客户 - 优化客户列表权限逻辑,改为登录即可查看,不再限制角色 - 更新接口调用参数,支持查询当前登录用户提交及分配的客户 - 移除对管理员角色的特殊判断,使权限逻辑更简洁 - UI调整,未登录时显示“请先登录”提示而非“没有查看权限”
This commit is contained in:
@@ -35,5 +35,5 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"lastUpdated": 1776331561536
|
||||
"lastUpdated": 1776332994640
|
||||
}
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
@@ -66,4 +66,5 @@ export interface ShopDealerApplyParam extends PageParam {
|
||||
userId?: number;
|
||||
keywords?: string;
|
||||
applyStatus?: number; // 申请状态筛选 (10待审核 20审核通过 30驳回)
|
||||
receptionistId?: number; // 接待人员用户ID(用于查询分配给自己的客户)
|
||||
}
|
||||
|
||||
@@ -1138,6 +1138,9 @@ const AddShopDealerApply = () => {
|
||||
<Form.Item name="mobile" label="手机号" initialValue={FormData?.mobile} required>
|
||||
<Input placeholder="手机号" disabled={isEditMode} maxLength={11}/>
|
||||
</Form.Item>
|
||||
<Form.Item name="comments" label="备注" initialValue={FormData?.comments}>
|
||||
<Input placeholder="请输入备注信息" />
|
||||
</Form.Item>
|
||||
{isEditMode && (
|
||||
<>
|
||||
<Form.Item name="money" label="签约价格" initialValue={FormData?.money} required>
|
||||
|
||||
@@ -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 (
|
||||
<View className="bg-white flex flex-col items-center justify-center p-4">
|
||||
<Empty description="没有查看权限"/>
|
||||
<Empty description="请先登录"/>
|
||||
<Button
|
||||
size="small"
|
||||
style={{marginTop: '12px'}}
|
||||
|
||||
Reference in New Issue
Block a user