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