system-copyright-react/src/route/proj/ProjNew.tsx

311 lines
14 KiB
TypeScript
Raw Normal View History

2024-03-14 18:33:58 +08:00
import './proj-new.css';
2024-05-12 07:45:51 +08:00
import { useNavigate, useParams, useSearchParams } from "react-router-dom";
2024-05-29 14:43:48 +08:00
import { Button, Flex, Form, Input, message, Modal, Spin, Checkbox } from "antd";
2024-05-12 07:45:51 +08:00
import { useContext, useEffect, useState } from "react";
import { get, post } from "../../util/AjaxUtils.ts";
2024-06-17 16:35:28 +08:00
import {
2024-06-14 15:50:34 +08:00
// IProjCharge,
2024-06-17 16:35:28 +08:00
ProjAdditionalType, ProjChargeType
} from "../../interfaces/proj/IProj.ts";
2024-05-12 07:45:51 +08:00
import { GlobalDispatchContext, reloadUser } from "../../context/GlobalContext.ts";
2024-06-17 16:35:28 +08:00
import BelongPeople from '../../components/BelongPeople/BelongPeople.tsx'
2024-05-23 14:57:22 +08:00
// const { TextArea } = Input;
2024-03-20 18:30:39 +08:00
type ProjInfo = {
projName: string;
projIntroduction: string;
2024-06-17 16:35:28 +08:00
belongPeople: string
2024-03-14 18:33:58 +08:00
};
export default function ProjNew() {
2024-04-02 18:45:46 +08:00
const globalDispatchContext = useContext(GlobalDispatchContext);
2024-03-14 18:33:58 +08:00
const nav = useNavigate();
2024-03-20 18:30:39 +08:00
const pathParams = useParams();
const [queryParams] = useSearchParams();
2024-03-14 18:33:58 +08:00
2024-03-20 18:30:39 +08:00
const [messageApi, contextHolder] = message.useMessage();
const [loading, setLoading] = useState<boolean>(false);
2024-05-21 11:21:34 +08:00
const height = window.innerHeight - 180;
2024-03-20 18:30:39 +08:00
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
const [isEditModalOpen, setIsEditModalOpen] = useState(false);
const [chargePrice, setChargePrice] = useState(0);
const [projInfo, setProjInfo] = useState<ProjInfo>({
projName: '',
projIntroduction: '',
2024-06-17 16:35:28 +08:00
belongPeople: ''
2024-03-20 18:30:39 +08:00
});
2024-06-17 16:35:28 +08:00
const [form] = Form.useForm<ProjInfo>();
// 所属者弹窗
const [belongModal, setBelongModal] = useState(false)
// const [belongPeopleName ,setBelongPeopleName] = useState('')
// // 暂存一个信息过度
// const [newBelongPeopleName,setNewBelongPeopleName] = useState('')
const [belongPeopleInfo, setBelongPeopleInfo] = useState({
authorName: '',
authorType: '',
authorIdCardType: '',
authorIdCard: '',
authorCrcAccount:'',
authorId:'',
authorProvinceCity:''
})
const setValue = (value:string) => {
form.setFieldsValue({
belongPeople:value
})
}
2024-03-21 22:22:35 +08:00
const [createProjId, setCreateProjId] = useState('');
2024-05-23 16:20:14 +08:00
const oldlistProjChargeAdditional: string[] = [];
2024-05-29 14:43:48 +08:00
const [listProjChargeAdditional, setlistProjChargeAdditional] = useState<string[]>([])
2024-03-20 18:30:39 +08:00
useEffect(() => {
get({
messageApi: messageApi,
url: '/api/proj/charge/get',
2024-05-12 07:45:51 +08:00
onSuccess({ data }) {
2024-06-14 15:50:34 +08:00
console.log(data);
2024-06-17 16:35:28 +08:00
2024-06-14 15:50:34 +08:00
const charge = data as any;
2024-05-08 17:54:01 +08:00
// console.log('创建页price',charge.proj.materialAgent);
2024-05-12 07:45:51 +08:00
2024-03-20 18:30:39 +08:00
let price = 0;
switch (pathParams.projChargeType) {
case ProjChargeType.ALL:
2024-06-14 15:50:34 +08:00
// price = charge.proj.all;
price = charge.projTypes[0].price;
2024-03-20 18:30:39 +08:00
break;
2024-06-14 15:50:34 +08:00
// case ProjChargeType.MATERIAL_AGENT:
// price = charge.proj.materialAgent;
// break;
// case ProjChargeType.MATERIAL_AGENT_URGENT:
// price = charge.proj.materialAgentUrgent;
// break;
2024-03-20 18:30:39 +08:00
case ProjChargeType.MATERIAL:
2024-06-14 15:50:34 +08:00
price = charge.projTypes[1].price;
2024-03-20 18:30:39 +08:00
break;
case ProjChargeType.FREE:
2024-06-14 15:50:34 +08:00
price = charge.projTypes[2].price;
2024-03-20 18:30:39 +08:00
break;
default:
messageApi.error({
type: 'error',
content: '价格类型错误',
})
}
2024-05-12 07:45:51 +08:00
const pkg = queryParams.get('pkg') == 'true' ? true : false
const videoDemo = queryParams.get('videoDemo') == 'true' ? true : false
2024-05-08 17:54:01 +08:00
if (pkg) {
2024-03-20 18:30:39 +08:00
price += charge.additional.pkg;
2024-05-23 16:20:14 +08:00
oldlistProjChargeAdditional.push(ProjAdditionalType.PKG);
console.log(listProjChargeAdditional);
2024-05-29 14:43:48 +08:00
2024-03-20 18:30:39 +08:00
}
2024-05-08 17:54:01 +08:00
if (videoDemo) {
2024-03-20 18:30:39 +08:00
price += charge.additional.videoDemo;
2024-05-23 16:20:14 +08:00
oldlistProjChargeAdditional.push(ProjAdditionalType.VIDEO_DEMO);
console.log(listProjChargeAdditional);
2024-03-20 18:30:39 +08:00
}
setChargePrice(price);
2024-05-23 16:20:14 +08:00
setlistProjChargeAdditional(oldlistProjChargeAdditional)
2024-05-12 07:45:51 +08:00
// console.log('传递信息pkg:',pkg,'videoDemo:',videoDemo);
// console.log('显示价格',price);
2024-03-20 18:30:39 +08:00
}
})
}, []);
2024-03-14 23:34:40 +08:00
2024-03-14 18:33:58 +08:00
return (
<>
2024-03-20 18:30:39 +08:00
{contextHolder}
2024-05-12 07:45:51 +08:00
{/* <Breadcrumb
2024-03-14 18:33:58 +08:00
items={[
{title: <Link to={'/'}></Link>},
{title: <Link to={'/proj-create'}></Link>},
2024-03-14 23:34:40 +08:00
{title: '新建项目'},
2024-03-14 18:33:58 +08:00
]}
2024-05-12 07:45:51 +08:00
/> */}
2024-05-29 14:43:48 +08:00
<div className='projNew' style={{ height: `${height}px`, overflow: 'auto' }}>
2024-03-14 23:34:40 +08:00
<div className="proj-new">
2024-05-12 07:45:51 +08:00
{/* <div className="proj-title">请完善项目的基本信息</div> */}
2024-03-14 23:34:40 +08:00
<div className="proj-form">
<Form
name="basic"
2024-06-17 16:35:28 +08:00
form={form}
2024-03-14 23:34:40 +08:00
layout={'vertical'}
2024-05-12 07:45:51 +08:00
labelCol={{ span: 24 }}
wrapperCol={{ span: 24 }}
2024-05-23 14:57:22 +08:00
style={{ width: '100%' }}
2024-03-20 18:30:39 +08:00
onFinish={(formData) => {
setIsCreateModalOpen(true);
setProjInfo({
projName: formData.projName,
2024-06-17 16:35:28 +08:00
projIntroduction: formData.projIntroduction,
belongPeople: formData.belongPeople
2024-03-20 18:30:39 +08:00
})
}}
2024-03-14 23:34:40 +08:00
autoComplete="off"
2024-03-14 18:33:58 +08:00
>
2024-05-12 07:45:51 +08:00
<div className='formItemOne'>
2024-05-29 14:43:48 +08:00
<div className='formItem-title oneTitle'>*</div>
2024-05-12 07:45:51 +08:00
<Form.Item<ProjInfo>
name="projName"
2024-05-29 14:43:48 +08:00
rules={[{ required: true, message: '请输入系统全称' }]}
2024-05-12 07:45:51 +08:00
>
2024-06-17 16:35:28 +08:00
<Input style={{ background: '#eeeeee', width: '800px', height: '50px', fontSize: '16px' }} placeholder="请输入系统全称" />
</Form.Item>
</div>
<div className='formItemOne' style={{ marginTop: 20, position: 'relative' }}>
<div className='formItem-title '>
*
</div>
<Form.Item<ProjInfo>
name="belongPeople"
rules={[{ required: true, message: '请选择/创建知识产权所属者' }]}
>
<Input style={{ background: '#eeeeee', width: '800px', height: '50px', fontSize: '16px', color: '#3B3B3B' }} placeholder="请选择/创建知识产权所属者" disabled />
2024-05-29 14:43:48 +08:00
</Form.Item>
2024-06-17 16:35:28 +08:00
<div style={{ position: 'absolute', right: 23, fontSize: 16, color: " #1F79FF", cursor: 'pointer' }} onClick={() => {
setBelongModal(true)
}}></div>
2024-05-29 14:43:48 +08:00
</div>
<div className='software-protocol'>
<Form.Item
name="agreement"
valuePropName="checked"
rules={[
{
validator: (_, value) =>
value ? Promise.resolve() : Promise.reject(new Error('请阅读并勾选《软件委托开发协议》')),
},
]}
>
<Checkbox>
2024-06-17 16:35:28 +08:00
<a onClick={() => {
2024-05-31 09:19:30 +08:00
window.open('https://www.aimzhu.com/Seda.html')
}}></a>
2024-05-29 14:43:48 +08:00
</Checkbox>
2024-05-12 07:45:51 +08:00
</Form.Item>
</div>
2024-05-23 14:57:22 +08:00
{/* <div className='formItemTwo'>
2024-05-12 07:45:51 +08:00
<div className='formItem-title '></div>
<Form.Item<ProjInfo>
name="projIntroduction"
>
<TextArea rows={10} style={{ background: '#eeeeee', resize: 'none',width:"328px",height:'220px',fontSize:'16px' }} placeholder="请对系统作出简单的描述,以使可准确生成资料..." />
</Form.Item>
2024-05-23 14:57:22 +08:00
</div> */}
2024-05-29 14:43:48 +08:00
<div style={{ marginTop: '' }}>
2024-05-12 07:45:51 +08:00
<Form.Item>
<Flex align="center" justify="center" gap="large">
2024-05-29 14:43:48 +08:00
<Button
// style={{
// backgroundColor: '#F5F5F5', width: '216px',
// height: '50px', color: '#AFAFAF', fontSize: '16px'
// }}
size='large'
type="default" htmlType="button" onClick={() => {
nav(-1);
}}
2024-05-21 11:21:34 +08:00
>
2024-05-12 07:45:51 +08:00
</Button>
<Button type="primary" htmlType="submit"
2024-05-29 14:43:48 +08:00
size='large'
// style={{
// backgroundColor: 'var(--color-primary)', width: '216px',
// height: '50px', fontSize: '16px', marginLeft: '53px'
// }}
>
2024-05-12 07:45:51 +08:00
</Button>
2024-03-14 18:33:58 +08:00
2024-05-12 07:45:51 +08:00
</Flex>
</Form.Item>
</div>
2024-03-14 23:34:40 +08:00
</Form>
</div>
2024-03-14 18:33:58 +08:00
</div>
</div>
2024-03-20 18:30:39 +08:00
<Modal title="提示"
2024-05-12 07:45:51 +08:00
okText="确定"
cancelText="取消"
open={isCreateModalOpen}
onOk={() => {
2024-05-23 16:20:14 +08:00
// console.log('最终',listProjChargeAdditional);
2024-06-17 16:35:28 +08:00
console.log(belongPeopleInfo.authorId);
2024-05-12 07:45:51 +08:00
setIsCreateModalOpen(false);
post<any>({
messageApi,
url: '/api/proj/create',
body: {
projName: projInfo.projName,
projChargeType: pathParams.projChargeType,
2024-06-17 16:35:28 +08:00
listProjChargeAdditional: listProjChargeAdditional,
authorCrcAccount:belongPeopleInfo.authorCrcAccount,
authorId:belongPeopleInfo.authorId,
authorIdCard:belongPeopleInfo.authorIdCard,
authorIdCardType:belongPeopleInfo.authorIdCardType,
authorName:belongPeopleInfo.authorName,
authorProvinceCity:belongPeopleInfo.authorProvinceCity,
authorType:belongPeopleInfo.authorType
2024-05-12 07:45:51 +08:00
},
onBefore() {
setLoading(true);
},
onSuccess({ data }) {
setIsEditModalOpen(true);
setCreateProjId(data.data);
reloadUser(messageApi, globalDispatchContext).then(() => {
messageApi.success('扣款成功');
});
},
onFinally() {
setLoading(false);
}
})
}}
onCancel={() => {
setIsCreateModalOpen(false);
}}>
2024-03-20 18:30:39 +08:00
<div> {chargePrice / 100} </div>
</Modal>
<Modal title="提示"
2024-05-12 07:45:51 +08:00
okText="确定"
cancelText="取消"
open={isEditModalOpen}
onOk={() => {
if (pathParams.projChargeType == ProjChargeType.ALL) {
nav(`/proj-eall/${createProjId}`);
} else if (pathParams.projChargeType == ProjChargeType.FREE) {
nav(`/proj-efree/${createProjId}`);
} else {
nav(`/proj-edit/${createProjId}`);
}
}}
onCancel={() => {
setIsEditModalOpen(false);
}}>
2024-03-20 18:30:39 +08:00
<div></div>
2024-03-14 23:34:40 +08:00
</Modal>
2024-06-17 16:35:28 +08:00
<Modal title="选择所属者"
destroyOnClose
open={belongModal}
width={1200}
footer={null}
onCancel={() => {
setBelongModal(false)
}}>
<BelongPeople setBelongPeopleInfo={setBelongPeopleInfo} belongPeopleInfo={belongPeopleInfo} setValue={setValue} ></BelongPeople>
</Modal>
2024-05-12 07:45:51 +08:00
<Spin tip="正在提交..." spinning={loading} fullscreen />
2024-03-14 18:33:58 +08:00
</>
)
}