system-copyright-react/src/route/TrademarkMall/TrademarkExpertEdit.tsx

203 lines
6.6 KiB
TypeScript
Raw Normal View History

2025-06-25 13:58:43 +08:00
import { useEffect, useState, useContext } from 'react'
2025-05-27 10:47:05 +08:00
import './trademark-edit.css'
2025-06-25 13:58:43 +08:00
import { useLocation, useNavigate } from 'react-router-dom';
import { expertRegister } from '../../request/api'
import { GlobalDispatchContext, reloadUser } from "../../context/GlobalContext";
// import { useNavigate } from 'react-router-dom';
2025-06-04 09:25:40 +08:00
import {
Form,
Input, Button,
2025-06-25 13:58:43 +08:00
Modal,
message,
Spin
2025-06-04 09:25:40 +08:00
} from 'antd';
2025-06-25 13:58:43 +08:00
import useMessage from "antd/es/message/useMessage";
2025-06-04 09:25:40 +08:00
const { TextArea } = Input;
2025-05-27 10:47:05 +08:00
export default function TrademarkExpertEdit() {
2025-06-25 13:58:43 +08:00
const nav = useNavigate()
const globalDispatchContext = useContext(GlobalDispatchContext);
const [messageApi, contextHolder] = useMessage();
2025-06-04 09:25:40 +08:00
const { state } = useLocation()
2025-05-27 10:47:05 +08:00
const height = window.innerHeight - 180;
2025-06-04 09:25:40 +08:00
const [form] = Form.useForm<any>();
2025-06-25 13:58:43 +08:00
const [upLodaing, setUpLodaing] = useState(false)
2025-06-04 09:25:40 +08:00
const [modal, setModal] = useState(false)
2025-06-25 13:58:43 +08:00
const [trademarkName, setTrademarkName] = useState('') //名称
const [trademarkContent, setTrademarkContent] = useState('') //描述
2025-06-04 09:25:40 +08:00
const onFinish = (values: any) => {
console.log(values);
2025-06-25 13:58:43 +08:00
setTrademarkName(values.trademarkName)
setTrademarkContent(values.trademarkContent ? values.trademarkContent : '')
2025-06-04 09:25:40 +08:00
setModal(true)
}
useEffect(() => {
console.log('state', state);
}, [])
2025-05-27 10:47:05 +08:00
return (
2025-06-25 13:58:43 +08:00
<Spin tip="正在提交,请稍后..." size="small" spinning={upLodaing}>
{contextHolder}
<div className='trademarkExpertBox' style={{ height: `${height}px`, overflow: 'auto' }}>
<div style={{
display: state.id == '2' ? 'unset' : 'none'
}}>
<div className='trademarkTop'>
<div className='trademarkTopL'>
!
</div>
<div>
</div>
2025-06-04 09:25:40 +08:00
</div>
</div>
2025-06-25 13:58:43 +08:00
<div style={{
display: state.id == '3' ? 'unset' : 'none'
}}>
<div className='trademarkTop'>
<div className='trademarkTopL'>
!
</div>
<div>
<div></div>
<div style={{
marginTop: '5px'
}}>;</div>
<div style={{
marginTop: '5px'
}}></div>
</div>
2025-06-04 09:25:40 +08:00
</div>
</div>
2025-06-25 13:58:43 +08:00
<div className='trademarkForm '>
<Form
name="Form"
form={form}
onFinish={onFinish}
initialValues={{ softWare: '' }}
style={{ maxWidth: 600, marginTop: 20 }}
>
<div className='trademarkForm-item'>
<div className='trademarkForm-title'>
<span style={{
color: 'red'
}}>*</span>
</div>
<div className='trademarkInput'>
<Form.Item
name="trademarkName"
rules={[{ required: true, message: '请输入商标名称!' }]}
2025-06-04 09:25:40 +08:00
>
2025-06-25 13:58:43 +08:00
<Input style={{
width: 500,
height: 46,
background: '#FFF',
color: 'black'
}}
placeholder="商标名称"
>
</Input>
2025-06-04 09:25:40 +08:00
2025-06-25 13:58:43 +08:00
</Form.Item>
2025-06-04 09:25:40 +08:00
2025-06-25 13:58:43 +08:00
</div>
2025-06-04 09:25:40 +08:00
</div>
2025-06-25 13:58:43 +08:00
<div className='trademarkForm-item'>
<div className='trademarkForm-title'>
</div>
<div className='trademarkInput'>
<Form.Item
name="trademarkContent"
// rules={[{ required: true, message: '请输入商标名称!' }]}
>
<TextArea style={{
width: 500,
height: 200,
background: '#FFF',
color: 'black',
resize: 'none'
}}
placeholder="需求描述"
>
</TextArea>
</Form.Item>
</div>
2025-06-04 09:25:40 +08:00
</div>
2025-06-25 13:58:43 +08:00
<div style={{
textWrap: 'nowrap',
}}>1</div>
<div style={{
textWrap: 'nowrap',
}}></div>
<Form.Item>
<div className='trademark-btn'>
<Button type="primary" htmlType="submit" style={{
width: 273,
height: 52
2025-06-04 09:25:40 +08:00
}}
>
2025-06-25 13:58:43 +08:00
</Button>
</div>
</Form.Item>
</Form>
2025-06-04 09:25:40 +08:00
2025-06-25 13:58:43 +08:00
</div>
<Modal title="提示"
centered
destroyOnClose={true}
open={modal}
onCancel={() => { setModal(false) }}
okText='确定'
cancelText='取消'
onOk={async () => {
setModal(false)
2025-06-04 09:25:40 +08:00
2025-06-25 13:58:43 +08:00
try {
setUpLodaing(true)
await expertRegister({
trademarkName,
trademarkContent,
trademarkMode: state.id,
trademarkModeName: state.title
})
reloadUser(messageApi, globalDispatchContext).then(() => {
setModal(false)
message.success('付款成功');
nav(-1)
2025-06-04 09:25:40 +08:00
2025-06-25 13:58:43 +08:00
});
setUpLodaing(false)
} catch (error: any) {
setUpLodaing(false)
2025-06-04 09:25:40 +08:00
2025-06-25 13:58:43 +08:00
// setAddLoading(false)
if (error.response) {
const data = error.response.data;
message.error(data.msg ? data.msg : `${data.path}(${data.status})`)
} else {
console.error(error)
}
} finally {
// setAddLoading(false)
setUpLodaing(false)
}
// setModal(false)
}}
>
{state.price}
</Modal>
2025-06-04 09:25:40 +08:00
</div>
2025-06-25 13:58:43 +08:00
</Spin>
2025-05-27 10:47:05 +08:00
)
}