diff --git a/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js b/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js index 83235ed..cfe2537 100644 --- a/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js +++ b/src/pages/PublicNotice/ApplyForm/PublicNoticeApplyForm.js @@ -4,6 +4,7 @@ import { Typography, Button, RadioGroup, + Dialog, DialogTitle, DialogContent, DialogActions } from '@mui/material'; import { useFormik } from 'formik'; import * as yup from 'yup'; @@ -18,7 +19,8 @@ import {useNavigate} from "react-router-dom"; // ==============================|| DASHBOARD - DEFAULT ||============================== // const PublicNoticeApplyForm = ({loadedData, selections}) => { - //const [formData, setFormData] = React.useState([]); + const [isWarningPopUp, setIsWarningPopUp] = React.useState(false); + const [warningText, setWarningText] = React.useState(""); const [attachment, setAttachment] = React.useState({}); const navigate=useNavigate(); @@ -30,17 +32,28 @@ const PublicNoticeApplyForm = ({loadedData, selections}) => { enableReinitialize:true, initialValues:loadedData, validationSchema:yup.object().shape({ - group: yup.string().max(255), - groupTitle: yup.string().max(255), - groupNo: yup.string().max(255), - contactPerson: yup.string().max(40).nullable(), + contactPerson: yup.string().max(40).required('請輸入聯絡人'), tel_countryCode: yup.string().min(3,'請輸入3位數字').required('請輸入國際區號'), fax_countryCode: yup.string().min(3,'請輸入3位數字'), phoneNumber: yup.string().min(8,'請輸入8位數字').required('請輸入聯絡電話'), - faxNumber: yup.string().min(8,'請輸入8位數字').required('請輸入8位數字'), + faxNumber: yup.string().min(8,'請輸入8位數字'), remarks: yup.string().max(255).nullable(), }), onSubmit:values=>{ + if(!values.issueId){ + setWarningText("請選擇目標期數"); + setIsWarningPopUp(true); + return; + } + if(!attachment){ + setWarningText("請選擇上傳文件"); + setIsWarningPopUp(true); + return; + }else if(attachment.size >= (10*1024*1034)){ + setWarningText("上傳文件大小應<10MB"); + setIsWarningPopUp(true); + return; + } console.log(values); HttpUtils.postWithFiles({ url: UrlUtils.POST_PUBLIC_NOTICE_APPLY, @@ -133,7 +146,7 @@ const PublicNoticeApplyForm = ({loadedData, selections}) => { - 上傳文件: + 上傳文件 ({"檔案大小應<10MB"}): {attachment.name} @@ -143,7 +156,7 @@ const PublicNoticeApplyForm = ({loadedData, selections}) => { id="uploadFileBtn" name="file" type="file" - accept="image/png, image/jpeg" + accept="image/png, image/jpeg.doc,.pdf,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" style={{ display: 'none' }} onChange={(event)=> { readFile(event) @@ -180,6 +193,17 @@ const PublicNoticeApplyForm = ({loadedData, selections}) => { +
+ setIsWarningPopUp(false)} > + Warning + + {warningText} + + + + + +
); };