feat(dealer): 调整客户报备保护期为15天并优化表单提示

- 将保护期从7天调整为15天,并使用常量PROTECTION_DAYS统一管理
- 更新已报备提示信息,显示当前状态及本次报备未生效
- 修改确认模态框内容,显示正确的保护期天数
- 优化输入框占位符提示,提供具体的输入示例
- 注释掉页面加载失败时的错误提示,避免影响用户体验
This commit is contained in:
2026-01-22 17:03:38 +08:00
parent 8d67732c7a
commit 9294c7b049

View File

@@ -25,6 +25,7 @@ const AddShopDealerApply = () => {
const [isEditMode, setIsEditMode] = useState<boolean>(false) const [isEditMode, setIsEditMode] = useState<boolean>(false)
const [existingApply, setExistingApply] = useState<ShopDealerApply | null>(null) const [existingApply, setExistingApply] = useState<ShopDealerApply | null>(null)
const [referee, setReferee] = useState<ShopDealerUser>() const [referee, setReferee] = useState<ShopDealerUser>()
const PROTECTION_DAYS = 15;
// 房号信息:用 dealerCode 存储唯一键dealerName 存储展示文案 // 房号信息:用 dealerCode 存储唯一键dealerName 存储展示文案
const buildHouseKey = (community: string, buildingNo: string, unitNo: string | undefined, roomNo: string) => { const buildHouseKey = (community: string, buildingNo: string, unitNo: string | undefined, roomNo: string) => {
@@ -141,11 +142,11 @@ const AddShopDealerApply = () => {
} }
// 提交表单 // 提交表单
// 计算保护期过期时间(7天后) // 计算保护期过期时间(15天后)
const calculateExpirationTime = (): string => { const calculateExpirationTime = (): string => {
const now = new Date(); const now = new Date();
const expirationDate = new Date(now); const expirationDate = new Date(now);
expirationDate.setDate(now.getDate() + 7); // 7天后 expirationDate.setDate(now.getDate() + PROTECTION_DAYS); // 15天后
// 格式化为数据库需要的格式YYYY-MM-DD HH:mm:ss // 格式化为数据库需要的格式YYYY-MM-DD HH:mm:ss
const year = expirationDate.getFullYear(); const year = expirationDate.getFullYear();
@@ -223,23 +224,23 @@ const AddShopDealerApply = () => {
// 已签约/已取消:直接提示已报备 // 已签约/已取消:直接提示已报备
if (existingCustomer.applyStatus && existingCustomer.applyStatus !== 10) { if (existingCustomer.applyStatus && existingCustomer.applyStatus !== 10) {
Taro.showToast({ Taro.showToast({
title: `该房号信息已报备(${getApplyStatusText(existingCustomer.applyStatus)}`, title: `该房号信息已报备(${getApplyStatusText(existingCustomer.applyStatus)},本次报备未生效`,
icon: 'none', icon: 'none',
duration: 2500 duration: 2500
}); });
return false; return false;
} }
// 跟进中:保留 7 天保护期逻辑 // 跟进中:保护期逻辑
if (existingCustomer.applyTime) { if (existingCustomer.applyTime) {
const applyTimeStamp = new Date(existingCustomer.applyTime).getTime(); const applyTimeStamp = new Date(existingCustomer.applyTime).getTime();
const currentTimeStamp = new Date().getTime(); const currentTimeStamp = new Date().getTime();
const sevenDaysInMs = 7 * 24 * 60 * 60 * 1000; const protectionMs = PROTECTION_DAYS * 24 * 60 * 60 * 1000;
if (currentTimeStamp - applyTimeStamp < sevenDaysInMs) { if (currentTimeStamp - applyTimeStamp < protectionMs) {
const remainingDays = Math.ceil((sevenDaysInMs - (currentTimeStamp - applyTimeStamp)) / (24 * 60 * 60 * 1000)); const remainingDays = Math.ceil((protectionMs - (currentTimeStamp - applyTimeStamp)) / (24 * 60 * 60 * 1000));
Taro.showToast({ Taro.showToast({
title: `该房号信息已报备,保护期剩余${remainingDays}`, title: `该房号信息已报备${getApplyStatusText(existingCustomer.applyStatus)},保护期剩余${remainingDays},本次报备未生效`,
icon: 'none', icon: 'none',
duration: 3000 duration: 3000
}); });
@@ -250,7 +251,7 @@ const AddShopDealerApply = () => {
const modalResult = await new Promise<boolean>((resolve) => { const modalResult = await new Promise<boolean>((resolve) => {
Taro.showModal({ Taro.showModal({
title: '提示', title: '提示',
content: '该房号已超过7天保护期,是否重新报备跟进?', content: `该房号已超过${PROTECTION_DAYS}天保护期,是否重新报备跟进?`,
showCancel: true, showCancel: true,
cancelText: '取消', cancelText: '取消',
confirmText: '确定', confirmText: '确定',
@@ -262,7 +263,7 @@ const AddShopDealerApply = () => {
if (!modalResult) return false; if (!modalResult) return false;
} else { } else {
Taro.showToast({ Taro.showToast({
title: '该房号信息已报备', title: `该房号信息已报备${getApplyStatusText(existingCustomer.applyStatus)}),本次报备未生效`,
icon: 'none', icon: 'none',
duration: 2500 duration: 2500
}); });
@@ -291,7 +292,7 @@ const AddShopDealerApply = () => {
refereeId: referee?.refereeId, refereeId: referee?.refereeId,
applyStatus: isEditMode ? 20 : 10, applyStatus: isEditMode ? 20 : 10,
auditTime: undefined, auditTime: undefined,
// 设置保护期过期时间(7天后) // 设置保护期过期时间(15天后)
expirationTime: expirationTime, expirationTime: expirationTime,
// 确保日期数据正确提交(使用数据库格式) // 确保日期数据正确提交(使用数据库格式)
applyTime: values.applyTime || (applyTime ? formatDateForDatabase(applyTime) : ''), applyTime: values.applyTime || (applyTime ? formatDateForDatabase(applyTime) : ''),
@@ -351,10 +352,10 @@ const AddShopDealerApply = () => {
}).catch((error) => { }).catch((error) => {
console.error('页面加载失败:', error); console.error('页面加载失败:', error);
setLoading(false); setLoading(false);
Taro.showToast({ // Taro.showToast({
title: '页面加载失败', // title: '页面加载失败',
icon: 'error' // icon: 'error'
}); // });
}) })
}, []); // 依赖用户ID当用户变化时重新加载 }, []); // 依赖用户ID当用户变化时重新加载
@@ -390,22 +391,22 @@ const AddShopDealerApply = () => {
<View className={'bg-gray-100 h-3'}></View> <View className={'bg-gray-100 h-3'}></View>
<CellGroup style={{padding: '4px 0'}}> <CellGroup style={{padding: '4px 0'}}>
<Form.Item name="address" label="小区" initialValue={FormData?.address} required> <Form.Item name="address" label="小区" initialValue={FormData?.address} required>
<Input placeholder="请选择/填写小区" disabled={isEditMode}/> <Input placeholder="幸福里" disabled={isEditMode}/>
</Form.Item> </Form.Item>
<Form.Item name="buildingNo" label="楼栋号" required> <Form.Item name="buildingNo" label="楼栋号" required>
<Input placeholder="请输入楼栋号" disabled={isEditMode}/> <Input placeholder="3" disabled={isEditMode}/>
</Form.Item> </Form.Item>
<Form.Item name="unitNo" label="单元号"> <Form.Item name="unitNo" label="单元号">
<Input placeholder="选填" disabled={isEditMode}/> <Input placeholder="1" disabled={isEditMode}/>
</Form.Item> </Form.Item>
<Form.Item name="roomNo" label="房号" required> <Form.Item name="roomNo" label="房号" required>
<Input placeholder="请输入房号" disabled={isEditMode}/> <Input placeholder="1201" disabled={isEditMode}/>
</Form.Item> </Form.Item>
<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} required>
<Input placeholder="请输入手机号" disabled={isEditMode} maxLength={11}/> <Input placeholder="手机号" disabled={isEditMode} maxLength={11}/>
</Form.Item> </Form.Item>
{isEditMode && ( {isEditMode && (
<> <>