Compare commits
2 Commits
20f77ff886
...
c58060fbd7
| Author | SHA1 | Date | |
|---|---|---|---|
| c58060fbd7 | |||
| 2d4d73d0d1 |
@@ -359,25 +359,6 @@ const AddShopDealerApply = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证必填字段
|
||||
if (!values.mobile || values.mobile.trim() === '') {
|
||||
Taro.showToast({
|
||||
title: '请填写联系方式',
|
||||
icon: 'error'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证手机号格式
|
||||
const phoneRegex = /^1[3-9]\d{9}$/;
|
||||
if (!phoneRegex.test(values.mobile)) {
|
||||
Taro.showToast({
|
||||
title: '请填写正确的手机号',
|
||||
icon: 'error'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 规范化报备人:留空=自己报备(当前登录用户)
|
||||
const rawUserId = normalizeText(values.userId);
|
||||
const submitUserId = rawUserId
|
||||
@@ -644,8 +625,8 @@ const AddShopDealerApply = () => {
|
||||
<Form.Item name="realName" label="姓名" initialValue={FormData?.realName} required>
|
||||
<Input placeholder="张三" disabled={isEditMode}/>
|
||||
</Form.Item>
|
||||
<Form.Item name="mobile" label="手机号" initialValue={FormData?.mobile} required>
|
||||
<Input placeholder="手机号" disabled={isEditMode} maxLength={11}/>
|
||||
<Form.Item name="mobile" label="手机号/微信号" initialValue={FormData?.mobile}>
|
||||
<Input placeholder="手机号/微信号" disabled={isEditMode}/>
|
||||
</Form.Item>
|
||||
<Form.Item name="comments" label="备注" initialValue={FormData?.comments}>
|
||||
<Input placeholder="请输入备注信息" />
|
||||
|
||||
@@ -37,10 +37,29 @@ const CustomerIndex = () => {
|
||||
const {user, loading: userLoading} = useUser()
|
||||
const roleCheckFinished = !userLoading
|
||||
const isLoggedIn = roleCheckFinished && user !== null
|
||||
const isSuperAdmin = user?.isSuperAdmin === true
|
||||
|
||||
// Tab配置
|
||||
const tabList = getStatusOptions();
|
||||
|
||||
const buildCustomerQueryParams = useCallback((currentPage?: number) => {
|
||||
const currentUserId = Number(Taro.getStorageSync('UserId')) || user?.userId || 0;
|
||||
const params: any = {
|
||||
type: 4
|
||||
};
|
||||
|
||||
if (currentPage !== undefined) {
|
||||
params.page = currentPage;
|
||||
}
|
||||
|
||||
if (!isSuperAdmin) {
|
||||
params.userId = currentUserId;
|
||||
params.receptionistId = currentUserId;
|
||||
}
|
||||
|
||||
return params;
|
||||
}, [isSuperAdmin, user?.userId]);
|
||||
|
||||
// 复制手机号
|
||||
const copyPhone = (phone: string) => {
|
||||
Taro.setClipboardData({
|
||||
@@ -183,17 +202,11 @@ const CustomerIndex = () => {
|
||||
const fetchCustomerData = useCallback(async (statusFilter?: CustomerStatus, resetPage = false, targetPage?: number) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const currentPage = resetPage ? 1 : (targetPage || page);
|
||||
const currentUserId = Number(Taro.getStorageSync('UserId')) || user?.userId || 0;
|
||||
const currentPage = resetPage ? 1 : (targetPage || 1);
|
||||
|
||||
// 构建API参数,根据状态筛选
|
||||
// 查看自己提交的(userId)或分配给自己的(receptionistId)的客户
|
||||
const params: any = {
|
||||
type: 4,
|
||||
page: currentPage,
|
||||
userId: currentUserId,
|
||||
receptionistId: currentUserId
|
||||
};
|
||||
// 非超管查看自己提交的(userId)或分配给自己的(receptionistId)的客户;超管查询全部
|
||||
const params = buildCustomerQueryParams(currentPage);
|
||||
const applyStatus = mapCustomerStatusToApplyStatus(statusFilter || activeTab);
|
||||
if (applyStatus !== undefined) {
|
||||
params.applyStatus = applyStatus;
|
||||
@@ -236,7 +249,7 @@ const CustomerIndex = () => {
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [activeTab, page, user?.userId]);
|
||||
}, [activeTab, buildCustomerQueryParams]);
|
||||
|
||||
const reloadMore = async () => {
|
||||
if (loading || !hasMore) return; // 防止重复加载
|
||||
@@ -284,12 +297,7 @@ const CustomerIndex = () => {
|
||||
// 获取所有状态的统计数量
|
||||
const fetchStatusCounts = useCallback(async () => {
|
||||
try {
|
||||
const currentUserId = Number(Taro.getStorageSync('UserId')) || user?.userId || 0;
|
||||
const baseParams: any = {
|
||||
type: 4,
|
||||
userId: currentUserId,
|
||||
receptionistId: currentUserId
|
||||
};
|
||||
const baseParams = buildCustomerQueryParams();
|
||||
|
||||
// 并行获取各状态的数量
|
||||
const [allRes, pendingRes, signedRes, cancelledRes] = await Promise.all([
|
||||
@@ -308,7 +316,7 @@ const CustomerIndex = () => {
|
||||
} catch (error) {
|
||||
console.error('获取状态统计失败:', error);
|
||||
}
|
||||
}, [user?.userId]);
|
||||
}, [buildCustomerQueryParams]);
|
||||
|
||||
const getStatusCounts = () => statusCounts;
|
||||
|
||||
@@ -351,7 +359,7 @@ const CustomerIndex = () => {
|
||||
useEffect(() => {
|
||||
if (!isLoggedIn) return;
|
||||
fetchStatusCounts().then();
|
||||
}, [isLoggedIn]);
|
||||
}, [fetchStatusCounts, isLoggedIn]);
|
||||
|
||||
// 当activeTab变化时重新获取数据
|
||||
useEffect(() => {
|
||||
@@ -360,7 +368,7 @@ const CustomerIndex = () => {
|
||||
setPage(1); // 重置页码
|
||||
setHasMore(true); // 重置加载状态
|
||||
fetchCustomerData(activeTab, true);
|
||||
}, [activeTab, isLoggedIn]);
|
||||
}, [activeTab, fetchCustomerData, isLoggedIn]);
|
||||
|
||||
// 监听页面显示,当从其他页面返回时刷新数据
|
||||
useDidShow(() => {
|
||||
|
||||
Reference in New Issue
Block a user