Browse Source

update app search

master
Anna Ho 1 year ago
parent
commit
04e7f551d5
4 changed files with 94 additions and 14 deletions
  1. +1
    -0
      src/pages/PublicNotice/ApplyForm/index.js
  2. +76
    -13
      src/pages/PublicNoticeSearch_GLD/SearchForm.js
  3. +15
    -1
      src/pages/PublicNoticeSearch_GLD/index.js
  4. +2
    -0
      src/utils/ApiPathConst.js

+ 1
- 0
src/pages/PublicNotice/ApplyForm/index.js View File

@@ -58,6 +58,7 @@ const ApplyForm = () => {
} }


function zeroPad(num, places) { function zeroPad(num, places) {
num=num?num:0;
var zero = places - num.toString().length + 1; var zero = places - num.toString().length + 1;
return Array(+(zero > 0 && zero)).join("0") + num; return Array(+(zero > 0 && zero)).join("0") + num;
} }


+ 76
- 13
src/pages/PublicNoticeSearch_GLD/SearchForm.js View File

@@ -13,12 +13,15 @@ import * as DateUtils from "utils/DateUtils";
// ==============================|| DASHBOARD - DEFAULT ||============================== // // ==============================|| DASHBOARD - DEFAULT ||============================== //




const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) => {
const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria,issueComboData
}) => {


const [type, setType] = React.useState([]); 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 [orgSelected, setOrgSelected] = React.useState({});
const [orgCombo, setOrgCombo] = 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 [minDate, setMinDate] = React.useState(searchCriteria.dateFrom);
const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo);
@@ -38,8 +41,10 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) =
dateFrom: data.dateFrom, dateFrom: data.dateFrom,
dateTo: data.dateTo, dateTo: data.dateTo,
contact: data.contact, 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); applySearch(temp);
}; };
@@ -50,13 +55,34 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) =
} }
}, [orgComboData]); }, [orgComboData]);


React.useEffect(() => {
if (issueComboData && issueComboData.length > 0) {
setIssueCombo(issueComboData);
}
}, [issueComboData]);

function resetForm() { function resetForm() {
setType([]); setType([]);
setStatus({ key: 0, label: 'All', type: 'all' });
setStatus({ key: 0, label: 'All', type: 'all' });
setOrgSelected({}); setOrgSelected({});
setIssueSelected({});
reset(); 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 ( return (
<MainCard xs={12} md={12} lg={12} <MainCard xs={12} md={12} lg={12}
border={false} border={false}
@@ -93,8 +119,8 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) =
type="date" type="date"
label="Submit Date(From)" label="Submit Date(From)"
defaultValue={searchCriteria.dateFrom} defaultValue={searchCriteria.dateFrom}
InputProps={{inputProps: { max: maxDate} }}
onChange={(newValue)=>{
InputProps={{ inputProps: { max: maxDate } }}
onChange={(newValue) => {
setMinDate(DateUtils.dateStr(newValue)); setMinDate(DateUtils.dateStr(newValue));
}} }}
InputLabelProps={{ InputLabelProps={{
@@ -110,8 +136,8 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) =
shrink: true shrink: true
}} }}
{...register("dateTo")} {...register("dateTo")}
InputProps={{inputProps: { min: minDate} }}
onChange={(newValue)=>{
InputProps={{ inputProps: { min: minDate } }}
onChange={(newValue) => {
setMaxDate(DateUtils.dateStr(newValue)); setMaxDate(DateUtils.dateStr(newValue));
}} }}
id="dateTo" id="dateTo"
@@ -132,7 +158,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) =
shrink: true shrink: true
}} }}
/> />
</Grid> </Grid>


<Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}> <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
@@ -140,7 +166,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) =
{...register("status")} {...register("status")}
disablePortal disablePortal
id="status" id="status"
filterOptions={(options)=>options}
filterOptions={(options) => options}
options={ComboData.publicNoticeStaticEng} options={ComboData.publicNoticeStaticEng}
value={status} value={status}
inputValue={status?.label} inputValue={status?.label}
@@ -169,7 +195,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) =
id="orgId" id="orgId"
options={orgCombo} options={orgCombo}
value={orgSelected} value={orgSelected}
inputValue={(orgSelected?.label)?orgSelected?.label: ""}
inputValue={(orgSelected?.label) ? orgSelected?.label : ""}
onChange={(event, newValue) => { onChange={(event, newValue) => {
if (newValue !== null) { if (newValue !== null) {
setOrgSelected(newValue); setOrgSelected(newValue);
@@ -183,12 +209,49 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria }) =
}} }}
/> />
)} )}
/> />
</Grid> </Grid>
: <></> : <></>
} }


<Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
<Autocomplete
{...register("issueId")}
disablePortal
id="issueId"
options={issueCombo}
value={issueSelected}
inputValue={(issueSelected?.id) ? getIssueLabel(issueSelected) : ""}
getOptionLabel={(option)=>getIssueLabel(option)}
onChange={(event, newValue) => {
if (newValue !== null) {
setIssueSelected(newValue);
}
}}
renderInput={(params) => (
<TextField {...params}
label="Gazette Issue"
InputLabelProps={{
shrink: true
}}
/>
)}
/>
</Grid>

<Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
<TextField
fullWidth
{...register("groupNo")}
id='groupNo'
label="Gazette Code."
defaultValue={searchCriteria.groupNo}
InputLabelProps={{
shrink: true
}}
/>
</Grid>



</Grid> </Grid>




+ 15
- 1
src/pages/PublicNoticeSearch_GLD/index.js View File

@@ -32,6 +32,7 @@ const UserSearchPage_Individual = () => {


const [record,setRecord] = React.useState([]); const [record,setRecord] = React.useState([]);
const [orgCombo,setOrgCombo] = React.useState([]); const [orgCombo,setOrgCombo] = React.useState([]);
const [issueCombo,setIssueCombo] = React.useState([]);
const [searchCriteria, setSearchCriteria] = React.useState({ const [searchCriteria, setSearchCriteria] = React.useState({
dateTo: DateUtils.dateStr(new Date()), dateTo: DateUtils.dateStr(new Date()),
dateFrom: DateUtils.dateStr(new Date().setDate(new Date().getDate()-14)), dateFrom: DateUtils.dateStr(new Date().setDate(new Date().getDate()-14)),
@@ -41,11 +42,12 @@ const UserSearchPage_Individual = () => {
React.useEffect(() => { React.useEffect(() => {
getUserList(); getUserList();
getOrgCombo(); getOrgCombo();
getIssueCombo();
}, []); }, []);


React.useEffect(() => { React.useEffect(() => {
setOnReady(true); setOnReady(true);
}, [orgCombo]);
}, [record]);


React.useEffect(() => { React.useEffect(() => {
getUserList(); 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) { function applySearch(input) {
setSearchCriteria(input); setSearchCriteria(input);
} }
@@ -92,6 +105,7 @@ const UserSearchPage_Individual = () => {
<SearchForm <SearchForm
applySearch={applySearch} applySearch={applySearch}
orgComboData={orgCombo} orgComboData={orgCombo}
issueComboData={issueCombo}
searchCriteria={searchCriteria} searchCriteria={searchCriteria}
/> />
</Grid> </Grid>


+ 2
- 0
src/utils/ApiPathConst.js View File

@@ -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 SET_PUBLIC_NOTICE_STATUS_WITHDRAW = apiPath+'/application/application-detail-status-withdrawn';
export const UPDATE_PUBLIC_NOTICE_APPLY_DETAIL = apiPath+'/application/save'; export const UPDATE_PUBLIC_NOTICE_APPLY_DETAIL = apiPath+'/application/save';


export const GET_ISSUE_COMBO = apiPath+'/gazette-issue/combo';

//User Group //User Group
export const POST_AND_UPDATE_USER_GROUP = apiPath+'/group/save'; export const POST_AND_UPDATE_USER_GROUP = apiPath+'/group/save';

Loading…
Cancel
Save