feat(register): 添加注册后重定向功能
从URL参数获取redirect值并在注册成功后跳转
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
// 供应商注册
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useIntl, history } from 'umi';
|
||||
import React, { useState, useEffect, useRef } from 'react';
|
||||
import { useIntl, history, useLocation } from 'umi';
|
||||
import { Form, Button, message, Radio, Checkbox, Modal, Spin } from 'antd';
|
||||
import { HomeOutlined } from '@ant-design/icons';
|
||||
import DomesticForm from './supplier/DomesticForm';
|
||||
@ -25,12 +25,17 @@ const SupplierRegister: React.FC<supplierWithInputProps> = (props) => {
|
||||
const [modalVisible, setModalVisible] = useState(false);
|
||||
const [surveyQuestions, setSurveyQuestions] = useState<API.SurveyQuestionResponse>([]);
|
||||
const [fetchingQuestions, setFetchingQuestions] = useState(false);
|
||||
|
||||
const location = useLocation();
|
||||
const redirectRef = useRef<string>('');
|
||||
// 获取问卷列表
|
||||
useEffect(() => {
|
||||
const searchParams = new URLSearchParams(location.search);
|
||||
const redirect = searchParams.get('redirect'); // 获取 redirect 参数
|
||||
if (redirect) {
|
||||
redirectRef.current = redirect;
|
||||
}
|
||||
//供应商带录入
|
||||
if (supplierWithInput) {
|
||||
|
||||
}
|
||||
const fetchQuestions = async () => {
|
||||
setFetchingQuestions(true);
|
||||
@ -85,17 +90,19 @@ const SupplierRegister: React.FC<supplierWithInputProps> = (props) => {
|
||||
values.coscoSupplierBase = values.coscoSupplierBase || {};
|
||||
values.coscoSupplierBase.supplierType = supplierType;
|
||||
|
||||
if(supplierType === 'pe') {
|
||||
if (supplierType === 'pe') {
|
||||
values.coscoSupplierBase.personName = values.coscoSupplierBase.name;
|
||||
values.coscoSupplierBase.personPhone = values.coscoSupplierBase.contactPhone;
|
||||
values.coscoSupplierSurveyAttachments = [{
|
||||
attachmentsType: "accessory",
|
||||
fileName: values.attachments.file.response.fileName,
|
||||
fileType: values.attachments.file.response.fileType,
|
||||
fileSize: values.attachments.file.response.fileSize,
|
||||
filePath: values.attachments.file.response.filePath,
|
||||
fileUrl: values.attachments.file.response.filePath,
|
||||
}]
|
||||
values.coscoSupplierSurveyAttachments = [
|
||||
{
|
||||
attachmentsType: 'accessory',
|
||||
fileName: values.attachments.file.response.fileName,
|
||||
fileType: values.attachments.file.response.fileType,
|
||||
fileSize: values.attachments.file.response.fileSize,
|
||||
filePath: values.attachments.file.response.filePath,
|
||||
fileUrl: values.attachments.file.response.filePath,
|
||||
},
|
||||
];
|
||||
}
|
||||
console.log('供应商注册信息:', values);
|
||||
// 直接调用API supplierWithInput === true 供应商注册代录 否则 注册 accessory
|
||||
@ -103,6 +110,10 @@ const SupplierRegister: React.FC<supplierWithInputProps> = (props) => {
|
||||
const response = await (supplierWithInput ? addAgent(values) : coscoSupplierBaseAdd(values));
|
||||
|
||||
if (response.success) {
|
||||
if (redirectRef.current) {
|
||||
window.location.href = redirectRef.current;
|
||||
return;
|
||||
}
|
||||
if (!supplierWithInput) {
|
||||
message.success('注册成功,请登录');
|
||||
history.push('/login');
|
||||
@ -143,7 +154,6 @@ const SupplierRegister: React.FC<supplierWithInputProps> = (props) => {
|
||||
</>
|
||||
)}
|
||||
|
||||
|
||||
<Spin spinning={fetchingQuestions}>
|
||||
<Form
|
||||
form={form}
|
||||
@ -158,16 +168,17 @@ const SupplierRegister: React.FC<supplierWithInputProps> = (props) => {
|
||||
wrapperCol={{ span: 17 }}
|
||||
>
|
||||
<Form.Item label="境内/境外" labelCol={{ span: 2 }} wrapperCol={{ span: 19 }}>
|
||||
<Radio.Group onChange={handleSupplierTypeChange} buttonStyle="solid" value={supplierType}>
|
||||
<Radio.Group
|
||||
onChange={handleSupplierTypeChange}
|
||||
buttonStyle="solid"
|
||||
value={supplierType}
|
||||
>
|
||||
<Radio.Button value="dvs">境内企业/机构</Radio.Button>
|
||||
<Radio.Button value="ovs">境外企业</Radio.Button>
|
||||
{supplierWithInput && (
|
||||
<Radio.Button value="pe">个人</Radio.Button>
|
||||
)}
|
||||
{supplierWithInput && <Radio.Button value="pe">个人</Radio.Button>}
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
|
||||
|
||||
{supplierType === 'dvs' ? (
|
||||
<DomesticForm
|
||||
form={form}
|
||||
@ -205,25 +216,23 @@ const SupplierRegister: React.FC<supplierWithInputProps> = (props) => {
|
||||
]}
|
||||
>
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<Checkbox>
|
||||
我已阅读并同意
|
||||
<Button
|
||||
type="link"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setModalVisible(true);
|
||||
}}
|
||||
>
|
||||
《注册信息承诺书》
|
||||
</Button>
|
||||
</Checkbox>
|
||||
<Checkbox>
|
||||
我已阅读并同意
|
||||
<Button
|
||||
type="link"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setModalVisible(true);
|
||||
}}
|
||||
>
|
||||
《注册信息承诺书》
|
||||
</Button>
|
||||
</Checkbox>
|
||||
</div>
|
||||
</Form.Item>
|
||||
)}
|
||||
|
||||
|
||||
|
||||
<Form.Item wrapperCol={{ span: 24 }}>
|
||||
<div style={{ textAlign: 'center' }}>
|
||||
<Button type="primary" htmlType="submit" loading={loading}>
|
||||
@ -251,7 +260,7 @@ const SupplierRegister: React.FC<supplierWithInputProps> = (props) => {
|
||||
okText="我知道了"
|
||||
cancelButtonProps={{ style: { display: 'none' } }}
|
||||
destroyOnClose
|
||||
// maskClosable={false}
|
||||
// maskClosable={false}
|
||||
>
|
||||
<div style={{ maxHeight: '60vh', overflow: 'auto' }}>
|
||||
<p>尊敬的用户:</p>
|
||||
|
Reference in New Issue
Block a user