import './proj-new.css'; import { useNavigate, useParams, useSearchParams } from "react-router-dom"; import { Button, Flex, Form, Input, message, Modal, Spin, Checkbox, DatePicker,Select } from "antd"; import { useContext, useEffect, useState } from "react"; import { get, post } from "../../util/AjaxUtils.ts"; // import {GlobalContext} from "../../context/GlobalContext.ts"; import { // IProjCharge, ProjAdditionalType, ProjChargeType } from "../../interfaces/proj/IProj.ts"; import locale from 'antd/es/date-picker/locale/zh_CN'; import { GlobalDispatchContext, reloadUser } from "../../context/GlobalContext.ts"; import BelongPeople from '../../components/BelongPeople/BelongPeople.tsx' import ContactPeople from '../../components/ContactPeople/ContactPeople.tsx' import dayjs from 'dayjs'; import SelectCouponModal from '../../components/CouponModal/SelectCouponModal.tsx' // const { TextArea } = Input; type ProjInfo = { projName: string; projIntroduction: string; belongPeople: string; contacts: string; projDevCompleteDate: string; coupon?: string; projVersion: string; backendCodeLang: string; }; export default function ProjNew() { // 是否显示优惠券 const [couponShow, setcouponShow] = useState(true) // const globalContext = useContext(GlobalContext); const dateFormat = 'YYYY年MM月DD日'; const globalDispatchContext = useContext(GlobalDispatchContext); const nav = useNavigate(); const pathParams = useParams(); const [queryParams] = useSearchParams(); const [messageApi, contextHolder] = message.useMessage(); const [loading, setLoading] = useState(false); const height = window.innerHeight - 180; // 提示结尾是否带关键字弹窗 // const [hasKeywords, setHasKeywords] = useState(false); // 创建项目弹窗 const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); const [isEditModalOpen, setIsEditModalOpen] = useState(false); const [chargePrice, setChargePrice] = useState(0); const [projInfo, setProjInfo] = useState({ projName: '', projIntroduction: '', belongPeople: '', contacts: '', projDevCompleteDate: '', projVersion: '', backendCodeLang: '', }); const [form] = Form.useForm(); // 所属者弹窗 const [belongModal, setBelongModal] = useState(false) // 联系人弹窗 const [concatModal, setConcatModal] = useState(false) // const [belongPeopleName ,setBelongPeopleName] = useState('') const [belongPeopleInfo, setBelongPeopleInfo] = useState({ authorName: '', authorType: '', authorIdCardType: '', authorIdCard: '', authorCrcAccount: '', authorId: '', authorProvinceCity: '' }) const [concatPeopleInfo, setConcatPeopleInfo] = useState({ applyConcatId: '', applyContactCsaNo: '', applyContactEmail: '', applyContactName: '', applyContactPhone: '', applyContactCompany: '' }) // 优惠券弹窗 const [couponModal, setCouponModal] = useState(false) const setValue = (value: string) => { form.setFieldsValue({ belongPeople: value }) } const setConcatValue = (value: string) => { form.setFieldsValue({ contacts: value }) } const [createProjId, setCreateProjId] = useState(''); const oldlistProjChargeAdditional: string[] = []; const [listProjChargeAdditional, setlistProjChargeAdditional] = useState([]) // 是否可用优惠券 const [hasCoupon, setHasCoupon] = useState(false) // 给优惠券栏赋值 const setCouponTitle = (value: string) => { form.setFieldsValue({ coupon: value }); } // 优惠券id const [couponId, setCouponId] = useState('') // 优惠券减的钱数 const [couponNum, setCouponNum] = useState(0) // 查看是否有可用获取优惠券信息 const getCouponData = () => { get({ messageApi, url: `/api/coupon/user/listpage/self`, // url: `/api/proj/refund/apply/listpage?applyStatus=${state.type}`, config: { params: { page: 1, rows: 10, isEffective: 1, isUsed: 0, } }, onBefore() { }, onSuccess(data: any) { if (data.data.rows.length > 0) { setHasCoupon(true) } }, onFinally() { }, }) } //判断是否以“软件”、“系统”、“平台”或“APP”结尾 function isEndsWithKeywords(str: string) { const keywords = ["软件", "系统", "平台", "APP"]; return keywords.some(keyword => str.endsWith(keyword)); } // 提示信息是否显示 const [showTip, setShowTip] = useState(false) useEffect(() => { get({ messageApi: messageApi, url: '/api/proj/charge/get', onSuccess({ data }) { // console.log(data); const charge = data as any; // console.log('创建页price',charge.proj.materialAgent); let price = 0; switch (pathParams.projChargeType) { case ProjChargeType.ALL: // price = charge.proj.all; price = charge.projTypes[0].price; break; // case ProjChargeType.MATERIAL_AGENT: // price = charge.proj.materialAgent; // break; // case ProjChargeType.MATERIAL_AGENT_URGENT: // price = charge.proj.materialAgentUrgent; // break; case ProjChargeType.MATERIAL: price = charge.projTypes[1].price; break; case ProjChargeType.FREE: price = charge.projTypes[2].price; break; default: messageApi.error({ type: 'error', content: '价格类型错误', }) } const pkg = queryParams.get('pkg') == 'true' ? true : false const videoDemo = queryParams.get('videoDemo') == 'true' ? true : false const urgent = queryParams.get('urgent') == 'true' ? true : false if (pkg) { price += charge.additional.pkg; oldlistProjChargeAdditional.push(ProjAdditionalType.PKG); // console.log(listProjChargeAdditional); } if (videoDemo) { price += charge.additional.videoDemo; oldlistProjChargeAdditional.push(ProjAdditionalType.VIDEO_DEMO); // console.log(listProjChargeAdditional); } if (urgent) { price += charge.additional.urgent; oldlistProjChargeAdditional.push(ProjAdditionalType.URGENT); // console.log(listProjChargeAdditional); } setChargePrice(price); setlistProjChargeAdditional(oldlistProjChargeAdditional) // console.log('传递信息pkg:',pkg,'videoDemo:',videoDemo); } }) // console.log('类型', pathParams.projChargeType); if (pathParams.projChargeType == 'FREE') { setcouponShow(false) } getCouponData() }, []); return ( <> {contextHolder} {/* 首页}, {title: 创建项目}, {title: '新建项目'}, ]} /> */}
{/*
请完善项目的基本信息
*/}
{ setIsCreateModalOpen(true); setProjInfo({ projName: formData.projName, projIntroduction: formData.projIntroduction, belongPeople: formData.belongPeople, contacts: formData.contacts, projDevCompleteDate: formData.projDevCompleteDate, projVersion: formData.projVersion?formData.projVersion:'v1.0', backendCodeLang: formData.backendCodeLang, }) }} autoComplete="off" >
系统全称*
name="projName" rules={[ { required: true, message: '请输入系统全称' }, ]} > { // 打印值 // console.log(e.target.value); if (e.target.value) { if (isEndsWithKeywords(e.target.value)) { setShowTip(false) } else { setShowTip(true) } } else { setShowTip(false) } }} style={{ background: '#eeeeee', width: '800px', height: '50px', fontSize: '16px' }} placeholder="请输入系统全称 (注:系统全称建议以“软件”、“系统”、“平台”或“APP”结尾)" />
系统全称建议以“软件”、“系统”、“平台”或“APP”结尾
系统版本*
name="projVersion" >
系统语言*
name="backendCodeLang" rules={[ { required: true, message: '请选择系统语言' }, ]} >
知识产权所属者*
name="belongPeople" rules={[{ required: true, message: '请选择/创建知识产权所属者' }]} >
{ setBelongModal(true) }}>选择
知识产权联系人*
name="contacts" rules={[{ required: true, message: '请选择/创建知识产权联系人' }]} >
{ setConcatModal(true) }}>选择
开发完成时间
// label="开发完成时间" name="projDevCompleteDate" // rules={[{ required: true, message: '请输入开发完成时间' }]} > current && current > dayjs().endOf('day')} />
优惠券
name="coupon" // rules={[{ required: true, message: '请选择优惠券' }]} >
{ if (hasCoupon) { setCouponModal(true) // #1F79FF } else { messageApi.error('无可用优惠券') } }}>选择
value ? Promise.resolve() : Promise.reject(new Error('请阅读并勾选《软件委托开发协议》')), }, ]} > 我同意平台 { window.open('https://www.aimzhu.com/Seda.html') }}>《软件委托开发协议》
{/*
简单描述
name="projIntroduction" >