From 79350d054ee04e65ad4dc4fdd73bbc4125f9c25d Mon Sep 17 00:00:00 2001 From: "cyril.tsui" Date: Fri, 27 Oct 2023 18:20:13 +0800 Subject: [PATCH] update --- .../ListPanel/SearchPublicNoticeForm.js | 39 +++++++++++++------ .../PublicNotice/Search_GLD/SearchForm.js | 3 -- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/pages/PublicNotice/ListPanel/SearchPublicNoticeForm.js b/src/pages/PublicNotice/ListPanel/SearchPublicNoticeForm.js index f86b13f..45e1c74 100644 --- a/src/pages/PublicNotice/ListPanel/SearchPublicNoticeForm.js +++ b/src/pages/PublicNotice/ListPanel/SearchPublicNoticeForm.js @@ -16,14 +16,15 @@ import * as DateUtils from "utils/DateUtils"; const SearchPublicNoticeForm = ({ applySearch, searchCriteria }) => { const [type, setType] = React.useState([]); - const [status, setStatus] = React.useState({ key: 0, label: '全部', type: 'all' }); + const [status, setStatus] = React.useState([{ key: 0, label: 'All', labelCht: "全部", type: 'all' }]); const [minDate, setMinDate] = React.useState(searchCriteria.dateFrom); const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); + const [selectedLabelsString, setSelectedLabelsString] = React.useState(''); const { reset, register, handleSubmit } = useForm() const onSubmit = (data) => { - + data.status = selectedLabelsString let typeArray = []; for (let i = 0; i < type.length; i++) { @@ -35,14 +36,14 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria }) => { dateFrom: data.dateFrom, dateTo: data.dateTo, contact: data.contact, - status: (status?.type&&status?.type!= 'all')?status?.type:"", + status: (data.status === "" || data.status.includes('all')) ? "" : data.status, }; applySearch(temp); }; function resetForm() { setType([]); - setStatus({ key: 0, label: '全部', type: 'all' }); + setStatus({ key: 0, label: 'All', labelCht: "全部", type: 'all' }); reset(); } @@ -125,31 +126,45 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria }) => { options} + // filterOptions={(options)=>options} options={ localStorage.getItem('userData').creditor? ComboData.publicNoticeStatic_Creditor: ComboData.publicNoticeStatic } values={status} - inputValue={status?.labelCht} + // inputValue={status?.labelCht} getOptionLabel={(option)=>option.labelCht} onChange={(event, newValue) => { - if (newValue !== null) { - setStatus(newValue); + console.log(newValue) + const findAllIndex = newValue.findIndex((ele) => { + return ele.type === "all" + }) + + if (findAllIndex > -1) { + setStatus([newValue[findAllIndex]]); + setSelectedLabelsString('all') + } else { + const selectedLabels = newValue.map(option => option.type); + const selectedLabelsString = `${selectedLabels.join(',')}`; + setStatus(newValue); + console.log(newValue) + setSelectedLabelsString(selectedLabelsString); } + console.log(selectedLabelsString) + console.log(status) }} renderInput={(params) => ( )} - InputLabelProps={{ - shrink: true - }} + // InputLabelProps={{ + // shrink: true + // }} /> {/**/} diff --git a/src/pages/PublicNotice/Search_GLD/SearchForm.js b/src/pages/PublicNotice/Search_GLD/SearchForm.js index a2b0165..e0af8d2 100644 --- a/src/pages/PublicNotice/Search_GLD/SearchForm.js +++ b/src/pages/PublicNotice/Search_GLD/SearchForm.js @@ -31,9 +31,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria,issu const { reset, register, handleSubmit } = useForm() const onSubmit = (data) => { - console.log(selectedLabelsString) data.status = selectedLabelsString - console.log(data.status) let typeArray = []; for (let i = 0; i < type.length; i++) { @@ -194,7 +192,6 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria,issu id="status" options={ComboData.publicNoticeStatic_GLD} value={selectedStatus} - onChange={(event, newValue) => { const findAllIndex = newValue.findIndex((ele) => { return ele.type === "all"