|
|
@@ -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 }) => { |
|
|
|
|
|
|
|
<Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}> |
|
|
|
<Autocomplete |
|
|
|
multiple |
|
|
|
{...register("status")} |
|
|
|
disablePortal |
|
|
|
id="status" |
|
|
|
filterOptions={(options)=>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) => ( |
|
|
|
<TextField {...params} |
|
|
|
label="狀態" |
|
|
|
/> |
|
|
|
)} |
|
|
|
InputLabelProps={{ |
|
|
|
shrink: true |
|
|
|
}} |
|
|
|
// InputLabelProps={{ |
|
|
|
// shrink: true |
|
|
|
// }} |
|
|
|
/> |
|
|
|
</Grid> |
|
|
|
{/*<Grid item xs={9} s={6} md={5} lg={3} sx={{ml:3, mr:3, mb:3}}>*/} |
|
|
|