diff --git a/src/pages/PublicNotice/ApplyForm/index.js b/src/pages/PublicNotice/ApplyForm/index.js index 9188a16..f04bd44 100644 --- a/src/pages/PublicNotice/ApplyForm/index.js +++ b/src/pages/PublicNotice/ApplyForm/index.js @@ -58,6 +58,7 @@ const ApplyForm = () => { } function zeroPad(num, places) { + num=num?num:0; var zero = places - num.toString().length + 1; return Array(+(zero > 0 && zero)).join("0") + num; } diff --git a/src/pages/PublicNoticeSearch_GLD/SearchForm.js b/src/pages/PublicNoticeSearch_GLD/SearchForm.js index 8caf19a..820bd15 100644 --- a/src/pages/PublicNoticeSearch_GLD/SearchForm.js +++ b/src/pages/PublicNoticeSearch_GLD/SearchForm.js @@ -13,12 +13,15 @@ import * as DateUtils from "utils/DateUtils"; // ==============================|| DASHBOARD - DEFAULT ||============================== // -const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) => { +const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria,issueComboData + }) => { const [type, setType] = React.useState([]); - const [status, setStatus] = React.useState({ key: 0, label: 'All', type: 'all' }); + const [status, setStatus] = React.useState({ key: 0, label: 'All', type: 'all' }); const [orgSelected, setOrgSelected] = React.useState({}); const [orgCombo, setOrgCombo] = React.useState(); + const [issueSelected, setIssueSelected] = React.useState({}); + const [issueCombo, setIssueCombo] = React.useState([]); const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); @@ -38,8 +41,10 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = dateFrom: data.dateFrom, dateTo: data.dateTo, contact: data.contact, - status: (status?.type&&status?.type!= 'all')?status?.type:"", - orgId: (orgSelected?.key&&orgSelected?.key>0)?orgSelected?.key:"", + status: (status?.type && status?.type != 'all') ? status?.type : "", + orgId: (orgSelected?.key && orgSelected?.key > 0) ? orgSelected?.key : "", + issueId: issueSelected?.id, + groupNo: data.groupNo, }; applySearch(temp); }; @@ -50,13 +55,34 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = } }, [orgComboData]); + React.useEffect(() => { + if (issueComboData && issueComboData.length > 0) { + setIssueCombo(issueComboData); + } + }, [issueComboData]); + function resetForm() { setType([]); - setStatus({ key: 0, label: 'All', type: 'all' }); + setStatus({ key: 0, label: 'All', type: 'all' }); setOrgSelected({}); + setIssueSelected({}); reset(); } + function getIssueLabel(data){ + if(data=={}) return ""; + return data.year + +" Vol. "+zeroPad(data.volume,3) + +", No. "+zeroPad(data.issueNo,2) + +", "+DateUtils.dateFormat(data.issueDate, "D MMM YYYY (ddd)"); + } + + function zeroPad(num, places) { + num=num?num:0; + var zero = places - num.toString().length + 1; + return Array(+(zero > 0 && zero)).join("0") + num; + } + return ( { + InputProps={{ inputProps: { max: maxDate } }} + onChange={(newValue) => { setMinDate(DateUtils.dateStr(newValue)); }} InputLabelProps={{ @@ -110,8 +136,8 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = shrink: true }} {...register("dateTo")} - InputProps={{inputProps: { min: minDate} }} - onChange={(newValue)=>{ + InputProps={{ inputProps: { min: minDate } }} + onChange={(newValue) => { setMaxDate(DateUtils.dateStr(newValue)); }} id="dateTo" @@ -132,7 +158,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = shrink: true }} /> - + @@ -140,7 +166,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = {...register("status")} disablePortal id="status" - filterOptions={(options)=>options} + filterOptions={(options) => options} options={ComboData.publicNoticeStaticEng} value={status} inputValue={status?.label} @@ -169,7 +195,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = id="orgId" options={orgCombo} value={orgSelected} - inputValue={(orgSelected?.label)?orgSelected?.label: ""} + inputValue={(orgSelected?.label) ? orgSelected?.label : ""} onChange={(event, newValue) => { if (newValue !== null) { setOrgSelected(newValue); @@ -183,12 +209,49 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) = }} /> )} - /> : <> } + + getIssueLabel(option)} + onChange={(event, newValue) => { + if (newValue !== null) { + setIssueSelected(newValue); + } + }} + renderInput={(params) => ( + + )} + /> + + + + + + diff --git a/src/pages/PublicNoticeSearch_GLD/index.js b/src/pages/PublicNoticeSearch_GLD/index.js index 49f4c61..eace58b 100644 --- a/src/pages/PublicNoticeSearch_GLD/index.js +++ b/src/pages/PublicNoticeSearch_GLD/index.js @@ -32,6 +32,7 @@ const UserSearchPage_Individual = () => { const [record,setRecord] = React.useState([]); const [orgCombo,setOrgCombo] = React.useState([]); + const [issueCombo,setIssueCombo] = React.useState([]); const [searchCriteria, setSearchCriteria] = React.useState({ dateTo: DateUtils.dateStr(new Date()), dateFrom: DateUtils.dateStr(new Date().setDate(new Date().getDate()-14)), @@ -41,11 +42,12 @@ const UserSearchPage_Individual = () => { React.useEffect(() => { getUserList(); getOrgCombo(); + getIssueCombo(); }, []); React.useEffect(() => { setOnReady(true); - }, [orgCombo]); + }, [record]); React.useEffect(() => { getUserList(); @@ -71,6 +73,17 @@ const UserSearchPage_Individual = () => { }); } + function getIssueCombo(){ + HttpUtils.get({ + url: UrlUtils.GET_ISSUE_COMBO, + onSuccess: function(responseData){ + let combo = responseData; + setIssueCombo(combo); + } + }); + } + + function applySearch(input) { setSearchCriteria(input); } @@ -92,6 +105,7 @@ const UserSearchPage_Individual = () => { diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 56e0ed7..01b40d2 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -65,5 +65,7 @@ export const SET_PUBLIC_NOTICE_STATUS_COMPLATED = apiPath+'/application/applicat export const SET_PUBLIC_NOTICE_STATUS_WITHDRAW = apiPath+'/application/application-detail-status-withdrawn'; export const UPDATE_PUBLIC_NOTICE_APPLY_DETAIL = apiPath+'/application/save'; +export const GET_ISSUE_COMBO = apiPath+'/gazette-issue/combo'; + //User Group export const POST_AND_UPDATE_USER_GROUP = apiPath+'/group/save'; \ No newline at end of file