feat(dealer): 完善经销商客户添加与订单展示功能

- 添加推荐人信息查询逻辑
- 验证报备人是否存在
This commit is contained in:
2025-10-02 14:15:52 +08:00
parent b0190247d9
commit d469f29468
3 changed files with 62 additions and 24 deletions

View File

@@ -15,6 +15,8 @@ import {
formatDateForDatabase,
extractDateForCalendar, formatDateForDisplay
} from "@/utils/dateUtils";
import {ShopDealerUser} from "@/api/shop/shopDealerUser/model";
import {getShopDealerUser, pageShopDealerUser} from "@/api/shop/shopDealerUser";
const AddShopDealerApply = () => {
const {user} = useUser()
@@ -24,6 +26,7 @@ const AddShopDealerApply = () => {
const formRef = useRef<any>(null)
const [isEditMode, setIsEditMode] = useState<boolean>(false)
const [existingApply, setExistingApply] = useState<ShopDealerApply | null>(null)
const [referee, setReferee] = useState<ShopDealerUser>()
// 日期选择器状态
const [showApplyTimePicker, setShowApplyTimePicker] = useState<boolean>(false)
@@ -78,7 +81,12 @@ const AddShopDealerApply = () => {
}
const reload = async () => {
// 查询推荐人信息
const dealerUser = await getShopDealerUser(Number(Taro.getStorageSync('UserId')))
setReferee(dealerUser)
if (!params.id) {
setLoading(false);
return false;
}
// 查询当前用户ID是否已有申请记录
@@ -100,7 +108,7 @@ const AddShopDealerApply = () => {
Taro.setNavigationBarTitle({title: '签约'})
}
} catch (error) {
setLoading(true)
setLoading(false)
console.error('查询申请记录失败:', error);
setIsEditMode(false);
setExistingApply(null);
@@ -126,6 +134,7 @@ const AddShopDealerApply = () => {
};
const submitSucceed = async (values: any) => {
try {
// 验证必填字段
if (!values.mobile || values.mobile.trim() === '') {
@@ -146,6 +155,18 @@ const AddShopDealerApply = () => {
return;
}
// 验证报备人是否存在
if (values.userId > 0) {
const isExist = await pageShopDealerUser({userId: Number(values.userId)});
if(isExist && isExist.count == 0){
Taro.showToast({
title: '报备人不存在',
icon: 'error'
});
return;
}
}
// 检查客户是否已存在
const res = await pageShopDealerApply({dealerName: values.dealerName, type: 4, applyStatus: 10});
@@ -205,7 +226,7 @@ const AddShopDealerApply = () => {
type: 4,
realName: values.realName || user?.nickname,
mobile: values.mobile,
refereeId: 33534,
refereeId: referee?.refereeId,
applyStatus: isEditMode ? 20 : 10,
auditTime: undefined,
// 设置保护期过期时间7天后
@@ -265,6 +286,13 @@ const AddShopDealerApply = () => {
useEffect(() => {
reload().then(() => {
setLoading(false)
}).catch((error) => {
console.error('页面加载失败:', error);
setLoading(false);
Taro.showToast({
title: '页面加载失败',
icon: 'error'
});
})
}, []); // 依赖用户ID当用户变化时重新加载
@@ -290,7 +318,7 @@ 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>
<Form.Item name="mobile" label="联系方式1" initialValue={FormData?.mobile} required>
<Input placeholder="请输入手机号" disabled={isEditMode} maxLength={11}/>
</Form.Item>
<Form.Item name="address" label="公司地址" initialValue={FormData?.address} required>
@@ -299,9 +327,6 @@ const AddShopDealerApply = () => {
<Form.Item name="dealerCode" label="户号" initialValue={FormData?.dealerCode} required>
<Input placeholder="请填写户号" disabled={isEditMode}/>
</Form.Item>
<Form.Item name="comments" label="跟进情况" initialValue={FormData?.comments}>
<Input placeholder="请填写跟进情况" disabled={isEditMode}/>
</Form.Item>
{isEditMode && (
<>
<Form.Item name="money" label="签约价格" initialValue={FormData?.money} required>
@@ -338,8 +363,12 @@ const AddShopDealerApply = () => {
{/*</Form.Item>*/}
</>
)}
<Form.Item name="userId" label="报备人" initialValue={FormData?.userId} required>
<Form.Item name="userId" label="报备人" initialValue={FormData?.userId}>
<Input
placeholder="自己报备请留空"
disabled={isEditMode}
value={(FormData?.userId)?.toString() || ''}
/>
</Form.Item>
</CellGroup>
</Form>

View File

@@ -1,6 +1,6 @@
import React, {useState, useEffect, useCallback} from 'react'
import {View, Text, ScrollView} from '@tarojs/components'
import {Empty, Tag, PullToRefresh, Loading} from '@nutui/nutui-react-taro'
import {Empty, PullToRefresh, Loading} from '@nutui/nutui-react-taro'
import Taro from '@tarojs/taro'
import {pageShopDealerOrder} from '@/api/shop/shopDealerOrder'
import {useDealerUser} from '@/hooks/useDealerUser'
@@ -97,11 +97,11 @@ const DealerOrders: React.FC = () => {
return '待结算'
}
const getStatusColor = (isSettled?: number, isInvalid?: number) => {
if (isInvalid === 1) return 'danger'
if (isSettled === 1) return 'success'
return 'warning'
}
// const getStatusColor = (isSettled?: number, isInvalid?: number) => {
// if (isInvalid === 1) return 'danger'
// if (isSettled === 1) return 'success'
// return 'warning'
// }
const renderOrderItem = (order: OrderWithDetails) => (
<View key={order.id} className="bg-white rounded-lg p-4 mb-3 shadow-sm">
@@ -109,28 +109,35 @@ const DealerOrders: React.FC = () => {
<Text className="font-semibold text-gray-800">
</Text>
<Tag type={getStatusColor(order.isSettled, order.isInvalid)}>
{getStatusText(order.isSettled, order.isInvalid)}
</Tag>
</View>
<View className="flex justify-between items-center mb-1">
<Text className="text-sm text-gray-400">
¥{order.orderPrice || '0.00'}
</Text>
<Text className="text-lg text-orange-500 font-semibold">
¥{(Number(order.orderPrice) * 10).toFixed(2)}
</Text>
</View>
<View className="flex justify-between items-center mb-1">
<Text className="text-sm text-gray-400">
{order.comments}
</Text>
<Text className="text-sm text-gray-400">
{order.rate}
</Text>
</View>
<View className="flex justify-between items-center">
<Text className="text-sm text-gray-400">
{order.comments}
{order.orderPrice || '0.00'}
</Text>
<Text className="text-sm text-gray-400">
{getStatusText(order.isSettled, order.isInvalid)}
</Text>
</View>
<View className="flex justify-between items-center mb-1">
<Text className="text-sm text-gray-400">
{order.settleTime}
</Text>
</View>
</View>
)