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