refactor(dealer): 重构经销商申请页面
- 优化页面逻辑,支持查看和编辑现有申请- 调整表单字段,增加签约价格和签约时间- 修改审核状态显示文案 - 优化取消签约功能 -修复了一些小问题
This commit is contained in:
@@ -2,19 +2,20 @@ import {useEffect, useState, useRef} from "react";
|
|||||||
import {Loading, CellGroup, Cell, Input, Form} from '@nutui/nutui-react-taro'
|
import {Loading, CellGroup, Cell, Input, Form} from '@nutui/nutui-react-taro'
|
||||||
import {Edit} from '@nutui/icons-react-taro'
|
import {Edit} from '@nutui/icons-react-taro'
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
|
import {useRouter} from '@tarojs/taro'
|
||||||
import {View} from '@tarojs/components'
|
import {View} from '@tarojs/components'
|
||||||
import FixedButton from "@/components/FixedButton";
|
import FixedButton from "@/components/FixedButton";
|
||||||
import {useUser} from "@/hooks/useUser";
|
import {useUser} from "@/hooks/useUser";
|
||||||
import {ShopDealerApply} from "@/api/shop/shopDealerApply/model";
|
import {ShopDealerApply} from "@/api/shop/shopDealerApply/model";
|
||||||
import {
|
import {
|
||||||
addShopDealerApply,
|
addShopDealerApply, getShopDealerApply,
|
||||||
pageShopDealerApply,
|
|
||||||
updateShopDealerApply
|
updateShopDealerApply
|
||||||
} from "@/api/shop/shopDealerApply";
|
} from "@/api/shop/shopDealerApply";
|
||||||
import {getShopDealerUser} from "@/api/shop/shopDealerUser";
|
import {getShopDealerUser} from "@/api/shop/shopDealerUser";
|
||||||
|
|
||||||
const AddUserAddress = () => {
|
const AddShopDealerApply = () => {
|
||||||
const {user} = useUser()
|
const {user} = useUser()
|
||||||
|
const {params} = useRouter();
|
||||||
const [loading, setLoading] = useState<boolean>(true)
|
const [loading, setLoading] = useState<boolean>(true)
|
||||||
const [FormData, setFormData] = useState<ShopDealerApply>()
|
const [FormData, setFormData] = useState<ShopDealerApply>()
|
||||||
const formRef = useRef<any>(null)
|
const formRef = useRef<any>(null)
|
||||||
@@ -27,32 +28,26 @@ const AddUserAddress = () => {
|
|||||||
case 10:
|
case 10:
|
||||||
return '待审核'
|
return '待审核'
|
||||||
case 20:
|
case 20:
|
||||||
return '审核通过'
|
return '已签约'
|
||||||
case 30:
|
case 30:
|
||||||
return '驳回'
|
return '已取消'
|
||||||
default:
|
default:
|
||||||
return '未知状态'
|
return '未知状态'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const reload = async () => {
|
const reload = async () => {
|
||||||
// 判断用户是否登录
|
if(!params.id){
|
||||||
if (!user?.userId) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 查询当前用户ID是否已有申请记录
|
// 查询当前用户ID是否已有申请记录
|
||||||
try {
|
try {
|
||||||
const res = await pageShopDealerApply({});
|
const dealerApply = await getShopDealerApply(Number(params.id));
|
||||||
if (res && res.count > 0) {
|
if(dealerApply){
|
||||||
|
setFormData(dealerApply)
|
||||||
setIsEditMode(true);
|
setIsEditMode(true);
|
||||||
setExistingApply(res.list[0]);
|
setExistingApply(dealerApply)
|
||||||
// 如果有记录,填充表单数据
|
Taro.setNavigationBarTitle({title: '签约'})
|
||||||
setFormData(res.list[0]);
|
|
||||||
setLoading(false)
|
|
||||||
} else {
|
|
||||||
setIsEditMode(false);
|
|
||||||
setExistingApply(null);
|
|
||||||
setLoading(false)
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
@@ -121,7 +116,7 @@ const AddUserAddress = () => {
|
|||||||
reload().then(() => {
|
reload().then(() => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
})
|
})
|
||||||
}, [user?.userId]); // 依赖用户ID,当用户变化时重新加载
|
}, []); // 依赖用户ID,当用户变化时重新加载
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <Loading className={'px-2'}>加载中</Loading>
|
return <Loading className={'px-2'}>加载中</Loading>
|
||||||
@@ -140,7 +135,7 @@ const AddUserAddress = () => {
|
|||||||
<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="dealerName" label="公司名称" initialValue={FormData?.dealerName} required>
|
<Form.Item name="dealerName" label="公司名称" initialValue={FormData?.dealerName} required>
|
||||||
<Input placeholder="公司名称" maxLength={10}/>
|
<Input placeholder="公司名称" maxLength={10} disabled={true}/>
|
||||||
</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={true}/>
|
<Input placeholder="请输入联系人" disabled={true}/>
|
||||||
@@ -155,7 +150,7 @@ const AddUserAddress = () => {
|
|||||||
<Input placeholder="请填写户号" disabled={true}/>
|
<Input placeholder="请填写户号" disabled={true}/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="money" label="签约价格" initialValue={FormData?.money} required>
|
<Form.Item name="money" label="签约价格" initialValue={FormData?.money} required>
|
||||||
<Input placeholder="请按合同填写签约价格" disabled={true}/>
|
<Input placeholder="(元/兆瓦时)"/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="applyTime" label="签约时间" initialValue={FormData?.applyTime} required>
|
<Form.Item name="applyTime" label="签约时间" initialValue={FormData?.applyTime} required>
|
||||||
<Input placeholder="请选择签约时间" disabled={true}/>
|
<Input placeholder="请选择签约时间" disabled={true}/>
|
||||||
@@ -183,7 +178,7 @@ const AddUserAddress = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{FormData?.applyStatus === 20 && (
|
{FormData?.applyStatus === 20 && (
|
||||||
<Cell title={'审核时间'} extra={FormData?.auditTime || '无'}/>
|
<Cell title={'签约时间'} extra={FormData?.auditTime || '无'}/>
|
||||||
)}
|
)}
|
||||||
{FormData?.applyStatus === 30 && (
|
{FormData?.applyStatus === 30 && (
|
||||||
<Cell title={'驳回原因'} extra={FormData?.rejectReason || '无'}/>
|
<Cell title={'驳回原因'} extra={FormData?.rejectReason || '无'}/>
|
||||||
@@ -193,10 +188,10 @@ const AddUserAddress = () => {
|
|||||||
|
|
||||||
|
|
||||||
{/* 底部浮动按钮 */}
|
{/* 底部浮动按钮 */}
|
||||||
{(!isEditMode || FormData?.applyStatus === 10 || FormData?.applyStatus === 30) && (
|
{(!isEditMode || FormData?.applyStatus === 10) && (
|
||||||
<FixedButton
|
<FixedButton
|
||||||
icon={<Edit/>}
|
icon={<Edit/>}
|
||||||
text={isEditMode ? '保存修改' : '提交申请'}
|
text={isEditMode ? '保存修改' : '确定签约'}
|
||||||
disabled={FormData?.applyStatus === 10}
|
disabled={FormData?.applyStatus === 10}
|
||||||
onClick={handleFixedButtonClick}
|
onClick={handleFixedButtonClick}
|
||||||
/>
|
/>
|
||||||
@@ -206,4 +201,4 @@ const AddUserAddress = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AddUserAddress;
|
export default AddShopDealerApply;
|
||||||
|
|||||||
@@ -115,15 +115,20 @@ const CustomerIndex = () => {
|
|||||||
updateShopDealerApply({
|
updateShopDealerApply({
|
||||||
...customer,
|
...customer,
|
||||||
applyStatus: 30
|
applyStatus: 30
|
||||||
}).then(r => {
|
}).then(() => {
|
||||||
console.log(r)
|
Taro.showToast({
|
||||||
|
title: '取消成功',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
fetchCustomerData().then();
|
||||||
|
fetchStatusCounts().then();
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchCustomerData();
|
fetchCustomerData().then();
|
||||||
fetchStatusCounts();
|
fetchStatusCounts().then();
|
||||||
}, [fetchCustomerData, fetchStatusCounts]);
|
}, [fetchCustomerData, fetchStatusCounts]);
|
||||||
|
|
||||||
// 当activeTab变化时重新获取数据
|
// 当activeTab变化时重新获取数据
|
||||||
@@ -134,7 +139,7 @@ const CustomerIndex = () => {
|
|||||||
// 渲染客户项
|
// 渲染客户项
|
||||||
const renderCustomerItem = (customer: CustomerUser) => (
|
const renderCustomerItem = (customer: CustomerUser) => (
|
||||||
<View key={customer.userId} className="bg-white rounded-lg p-4 mb-3 shadow-sm">
|
<View key={customer.userId} className="bg-white rounded-lg p-4 mb-3 shadow-sm">
|
||||||
<View className="flex items-center mb-3">
|
<View className="flex items-center mb-3" onClick={() => navTo(`/dealer/customer/add?id=${customer.applyId}`, true)}>
|
||||||
<View className="flex-1">
|
<View className="flex-1">
|
||||||
<View className="flex items-center justify-between mb-1">
|
<View className="flex items-center justify-between mb-1">
|
||||||
<Text className="font-semibold text-gray-800 mr-2">
|
<Text className="font-semibold text-gray-800 mr-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user