From 87636871bd78237c4d015c8de1b65060585ffe17 Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Mon, 4 Sep 2023 16:57:42 +0800 Subject: [PATCH] upload combo and file list --- src/components/FileList.js | 2 +- .../OrganizationTable.js | 2 +- src/pages/authentication/AuthWrapperCustom.js | 6 +- src/pages/authentication/BusRegister.js | 17 ++--- src/pages/authentication/Register.js | 8 +- .../auth-forms/BusCustomFormWizard.js | 4 +- .../auth-forms/CustomFormWizard.js | 76 +++++++++++-------- .../auth-forms/UploadFileTable.js | 2 +- src/pages/extra-pages/LoadingComponent.js | 2 +- .../pnspsUserDetailPage/UserAuthTable.js | 2 +- .../pnspsUserDetailPage/UserGroupTable.js | 2 +- .../GroupAuthTable.js | 2 +- .../pnspsUserGroupDetailPage/UserAddCard.js | 1 + .../UserGroupTable.js | 2 +- src/pages/pnspsUserSearchPage/UserTable.js | 2 +- .../UserTable_Individual.js | 2 +- .../UserTable_Organization.js | 2 +- src/utils/ComboData.js | 11 ++- 18 files changed, 80 insertions(+), 65 deletions(-) diff --git a/src/components/FileList.js b/src/components/FileList.js index f1e3e07..f03ce26 100644 --- a/src/components/FileList.js +++ b/src/components/FileList.js @@ -149,7 +149,7 @@ export default function FileList({refType, refId, allowDelete, sx}) { }, }} pageSizeOptions={[5, 10]} - autoHeight + autoHeight = {true} /> ); diff --git a/src/pages/OrganizationSearchPage/OrganizationTable.js b/src/pages/OrganizationSearchPage/OrganizationTable.js index bc120a8..2253f0d 100644 --- a/src/pages/OrganizationSearchPage/OrganizationTable.js +++ b/src/pages/OrganizationSearchPage/OrganizationTable.js @@ -86,7 +86,7 @@ export default function OrganizationTable({recordList}) { }, }} pageSizeOptions={[5, 10]} - autoHeight + autoHeight = {true} /> ); diff --git a/src/pages/authentication/AuthWrapperCustom.js b/src/pages/authentication/AuthWrapperCustom.js index a477405..9f25ce8 100644 --- a/src/pages/authentication/AuthWrapperCustom.js +++ b/src/pages/authentication/AuthWrapperCustom.js @@ -14,7 +14,7 @@ import AuthBackground from 'assets/images/auth/AuthBackground'; // ==============================|| AUTHENTICATION - WRAPPER ||============================== // const AuthWrapperCustom = ({ children }) => ( - + ( justifyContent="center" alignItems="flex-start" sx={{ - minHeight: '80vh' + minHeight: '60vh' }} > {/* @@ -35,7 +35,7 @@ const AuthWrapperCustom = ({ children }) => ( container justifyContent="center" alignItems="flex-start" - sx={{ minHeight: { xs: 'calc(80vh - 134px)', md: 'calc(80vh - 112px)' }}} + sx={{ minHeight: { xs: 'calc(60vh - 134px)', md: 'calc(60vh - 112px)' }}} > {children} diff --git a/src/pages/authentication/BusRegister.js b/src/pages/authentication/BusRegister.js index 128bebd..cfd19b0 100644 --- a/src/pages/authentication/BusRegister.js +++ b/src/pages/authentication/BusRegister.js @@ -74,23 +74,17 @@ steps.findIndex((step, i) => !(i in completed)) : activeStep + 1; setActiveStep(newActiveStep); - console.log(newActiveStep) + scrollToTop(); }; const handleBack = () => { + scrollToTop(); setActiveStep((prevActiveStep) => prevActiveStep - 1); }; - // const handleStep = (step) => () => { - // setActiveStep(step); - // }; - - // const handleComplete = () => { - // const newCompleted = completed; - // newCompleted[activeStep] = true; - // setCompleted(newCompleted); - // handleNext(); - // }; + const scrollToTop = () => { + window.scrollTo(0,0); + }; const handleReset = () => { setActiveStep(0); @@ -173,6 +167,7 @@ ): ( + // diff --git a/src/pages/authentication/Register.js b/src/pages/authentication/Register.js index fd68268..cc385aa 100644 --- a/src/pages/authentication/Register.js +++ b/src/pages/authentication/Register.js @@ -75,7 +75,6 @@ }; const handleNext = () => { - scrollToTop() const newActiveStep = isLastStep() && !allStepsCompleted() ? // It's the last step, but not all steps have been completed, @@ -83,16 +82,16 @@ steps.findIndex((step, i) => !(i in completed)) : activeStep + 1; setActiveStep(newActiveStep); - // console.log(newActiveStep) + scrollToTop(); }; const handleBack = () => { - scrollToTop() + scrollToTop(); setActiveStep((prevActiveStep) => prevActiveStep - 1); }; const scrollToTop = () => { - window.scrollTo({ top: 0, left: 0, behavior: 'smooth' }); + window.scrollTo(0,0); }; const handleReset = () => { @@ -176,6 +175,7 @@ ): ( + // diff --git a/src/pages/authentication/auth-forms/BusCustomFormWizard.js b/src/pages/authentication/auth-forms/BusCustomFormWizard.js index f463a56..ff3997e 100644 --- a/src/pages/authentication/auth-forms/BusCustomFormWizard.js +++ b/src/pages/authentication/auth-forms/BusCustomFormWizard.js @@ -722,7 +722,7 @@ const BusCustomFormWizard = (props) => { - 英文姓名 + 姓名 * { value={formik.values.enName} name="enName" onChange={formik.handleChange} - placeholder="與你的身份證明文件相同" + placeholder="" fullWidth error={Boolean(formik.touched.enName && formik.errors.enName)} onBlur={formik.handleBlur} diff --git a/src/pages/authentication/auth-forms/CustomFormWizard.js b/src/pages/authentication/auth-forms/CustomFormWizard.js index bd43dd8..b148877 100644 --- a/src/pages/authentication/auth-forms/CustomFormWizard.js +++ b/src/pages/authentication/auth-forms/CustomFormWizard.js @@ -76,7 +76,7 @@ const CustomFormWizard = (props) => { const [termsAndConNotAccept, setTermsAndConNotAccept] = useState(false); const [isValid, setisValid] = useState(false); const [isLoading, setLoding] = useState(true); - + const idDocTypeComboList = ComboData.idDocType; const address4ComboList = ComboData.district; const address5ComboList = ComboData.country; @@ -135,22 +135,43 @@ const CustomFormWizard = (props) => { }; const handleFileUpload = (event)=>{ + let list = new DataTransfer(); + let currentFileList = fileListData; const uploadFileList = event.target.files; const saveFileList = []; var currentIndex = 0; - - if (!fileList.length==null){ - currentIndex = fileList.length; + + if (currentFileList.length!=null){ + currentIndex = currentFileList.length; + for (let i = 0; i < currentIndex; i++){ + const file = currentFileList[i] + list.items.add(file); + saveFileList.push(file); + } } - + for (let i = 0; i < uploadFileList.length; i++){ const file = event.target.files[i] - file.id = currentIndex+i+1 - saveFileList.push(file) + let isDuplicate = false; + // Check if the file name already exists in saveFileList + for (let j = 0; j < saveFileList.length; j++) { + if (saveFileList[j].name === file.name) { + isDuplicate = true; + break; + } + } + + if (!isDuplicate) { + file.id = currentIndex+i + saveFileList.push(file) + list.items.add(file); + } + } + let myFileList = list.files; setFileListData(saveFileList) - setFileList(uploadFileList); + setFileList(myFileList); }; useEffect(() => { @@ -311,7 +332,7 @@ const CustomFormWizard = (props) => { submit: null, fax:'', faxCountryCode:'852', - idDocType:selectedIdDocType + idDocType:'' }), validationSchema:yup.object().shape({ username: yup.string().min(6,'用戶名稱最少6位').required('請輸入用戶名稱'), @@ -536,13 +557,18 @@ const CustomFormWizard = (props) => { idDocTypeComboList.label} onBlur={formik.handleBlur} onChange={(event, newValue) => { - setSelectedIdDocType(newValue); - if (newValue!="HKID"){ - formik.setFieldValue("checkDigit","") + // console.log(newValue) + if (newValue!=null){ + setSelectedIdDocType(newValue.type); + if (newValue.type!="HKID"){ + formik.setFieldValue("checkDigit","") + } + } }} sx={{"& .MuiInputBase-root": { height: "41px" },"#idDocType":{padding: "0px 0px 0px 0px"}, "& .MuiAutocomplete-endAdornment": { top: "auto" },}} @@ -1068,8 +1094,8 @@ const CustomFormWizard = (props) => { {/* Preview Form */} - - + +
成為新的個人用戶 @@ -1081,10 +1107,10 @@ const CustomFormWizard = (props) => { */} - - + + - + 用戶登入名稱: @@ -1217,19 +1243,7 @@ const CustomFormWizard = (props) => { :null} - {/* - - 身份證明文件 - 請上傳你的 有效身份證明文件 的數碼檔案,以驗證你的身份。 - 如: 香港身份證; 護照; 中國內地身份證等 - - - 如: 香港身份證; 護照; 中國內地身份證等 - - - */} + diff --git a/src/pages/authentication/auth-forms/UploadFileTable.js b/src/pages/authentication/auth-forms/UploadFileTable.js index d227752..6f209dd 100644 --- a/src/pages/authentication/auth-forms/UploadFileTable.js +++ b/src/pages/authentication/auth-forms/UploadFileTable.js @@ -78,7 +78,7 @@ export default function UploadFileTable({recordList}) { // }, // }} // pageSizeOptions={[5, 10]} - autoHeight + autoHeight = {true} /> ); diff --git a/src/pages/extra-pages/LoadingComponent.js b/src/pages/extra-pages/LoadingComponent.js index a4ceba4..b52e301 100644 --- a/src/pages/extra-pages/LoadingComponent.js +++ b/src/pages/extra-pages/LoadingComponent.js @@ -7,7 +7,7 @@ const LoadingComponent = () => { display="flex" justifyContent="center" alignItems="center" - autoHeight="true" + autoHeight={true} > diff --git a/src/pages/pnspsUserDetailPage/UserAuthTable.js b/src/pages/pnspsUserDetailPage/UserAuthTable.js index bb4592d..5939351 100644 --- a/src/pages/pnspsUserDetailPage/UserAuthTable.js +++ b/src/pages/pnspsUserDetailPage/UserAuthTable.js @@ -73,7 +73,7 @@ export default function UserAuthTable({setSelectedRow, userAuth}) { setSelectedRow(ids); setCurrentSelectedRow(ids); }} - autoHeight + autoHeight = {true} />
); diff --git a/src/pages/pnspsUserDetailPage/UserGroupTable.js b/src/pages/pnspsUserDetailPage/UserGroupTable.js index 12090f0..5793638 100644 --- a/src/pages/pnspsUserDetailPage/UserGroupTable.js +++ b/src/pages/pnspsUserDetailPage/UserGroupTable.js @@ -69,7 +69,7 @@ export default function UserGroupTable({setSelectedRow, userGroup}) { setSelectedRow(ids); setCurrentSelectedRow(ids); }} - autoHeight + autoHeight = {true} /> ); diff --git a/src/pages/pnspsUserGroupDetailPage/GroupAuthTable.js b/src/pages/pnspsUserGroupDetailPage/GroupAuthTable.js index f48e546..b82591b 100644 --- a/src/pages/pnspsUserGroupDetailPage/GroupAuthTable.js +++ b/src/pages/pnspsUserGroupDetailPage/GroupAuthTable.js @@ -73,7 +73,7 @@ export default function GroupAuthTable({setSelectedRow, userAuth}) { setSelectedRow(ids); setCurrentSelectedRow(ids); }} - autoHeight + autoHeight = {true} /> ); diff --git a/src/pages/pnspsUserGroupDetailPage/UserAddCard.js b/src/pages/pnspsUserGroupDetailPage/UserAddCard.js index 8f4806c..ca39bfb 100644 --- a/src/pages/pnspsUserGroupDetailPage/UserAddCard.js +++ b/src/pages/pnspsUserGroupDetailPage/UserAddCard.js @@ -100,6 +100,7 @@ const UserAddCard = ({isCollectData, updateGroupMember,userGroupData}) => { value={selectedUser === null ? null : selectedUser} options={userComboList} onChange={(event, newValue) => { + console.log(newValue) setSelectedUser(newValue); }} renderInput={(params) => } diff --git a/src/pages/pnspsUserGroupSearchPage/UserGroupTable.js b/src/pages/pnspsUserGroupSearchPage/UserGroupTable.js index 6f50a0c..a7786d7 100644 --- a/src/pages/pnspsUserGroupSearchPage/UserGroupTable.js +++ b/src/pages/pnspsUserGroupSearchPage/UserGroupTable.js @@ -68,7 +68,7 @@ export default function UserGroupTable({recordList}) { }, }} pageSizeOptions={[10, 15, 20]} - autoHeight + autoHeight = {true} /> ); diff --git a/src/pages/pnspsUserSearchPage/UserTable.js b/src/pages/pnspsUserSearchPage/UserTable.js index b71f90d..fc5a46b 100644 --- a/src/pages/pnspsUserSearchPage/UserTable.js +++ b/src/pages/pnspsUserSearchPage/UserTable.js @@ -140,7 +140,7 @@ export default function UserTable({recordList}) { }, }} pageSizeOptions={[5, 10]} - autoHeight + autoHeight = {true} /> ); diff --git a/src/pages/pnspsUserSearchPage_Individual/UserTable_Individual.js b/src/pages/pnspsUserSearchPage_Individual/UserTable_Individual.js index 9b3977c..a619925 100644 --- a/src/pages/pnspsUserSearchPage_Individual/UserTable_Individual.js +++ b/src/pages/pnspsUserSearchPage_Individual/UserTable_Individual.js @@ -145,7 +145,7 @@ export default function UserTable_Individual({recordList}) { }, }} pageSizeOptions={[5, 10]} - autoHeight + autoHeight = {true} /> ); diff --git a/src/pages/pnspsUserSearchPage_Organization/UserTable_Organization.js b/src/pages/pnspsUserSearchPage_Organization/UserTable_Organization.js index ee92ff0..7c1d550 100644 --- a/src/pages/pnspsUserSearchPage_Organization/UserTable_Organization.js +++ b/src/pages/pnspsUserSearchPage_Organization/UserTable_Organization.js @@ -145,7 +145,7 @@ export default function UserTable_Organization({recordList}) { }, }} pageSizeOptions={[5, 10]} - autoHeight + autoHeight = {true} /> ); diff --git a/src/utils/ComboData.js b/src/utils/ComboData.js index 00e4525..4d9e9cb 100644 --- a/src/utils/ComboData.js +++ b/src/utils/ComboData.js @@ -1,7 +1,12 @@ - -export const idDocType = ["passport","HKID","CNID","BR","otherCert"]; +export const idDocType = [ + {label:"護照", type:"passport"}, + {label:"香港身份證", type:"HKID"}, + {label:"內地身份證", type:"CNID"}, + {label:"專業執業證書", type:"otherCert"} +]; + export const district = ["北區","長洲區","大埔區","大嶼山區","東區","觀塘區","黃大仙區","九龍城區","葵青區","南區","南丫島區", "坪洲區","荃灣區","沙田區","深水埗區","屯門區","灣仔區","西貢區","油尖旺區","元朗區","中西區"]; export const country = ["中國香港","中國","中國澳門"]; -export const accountFilter = [{display:"Active", value:"active"},{display:"Locked", value:"locked"},{display:"Not verified", value:"notVerified"}]; +export const accountFilter = [{id:1,label:"Active", key:"active"},{id:2,label:"Locked", key:"locked"},{id:3,label:"Not verified", key:"notVerified"}];