Browse Source

update

master
cyril.tsui 1 year ago
parent
commit
79350d054e
2 changed files with 27 additions and 15 deletions
  1. +27
    -12
      src/pages/PublicNotice/ListPanel/SearchPublicNoticeForm.js
  2. +0
    -3
      src/pages/PublicNotice/Search_GLD/SearchForm.js

+ 27
- 12
src/pages/PublicNotice/ListPanel/SearchPublicNoticeForm.js View File

@@ -16,14 +16,15 @@ import * as DateUtils from "utils/DateUtils";
const SearchPublicNoticeForm = ({ applySearch, searchCriteria }) => { const SearchPublicNoticeForm = ({ applySearch, searchCriteria }) => {


const [type, setType] = React.useState([]); 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 [minDate, setMinDate] = React.useState(searchCriteria.dateFrom);
const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo); const [maxDate, setMaxDate] = React.useState(searchCriteria.dateTo);
const [selectedLabelsString, setSelectedLabelsString] = React.useState('');


const { reset, register, handleSubmit } = useForm() const { reset, register, handleSubmit } = useForm()
const onSubmit = (data) => { const onSubmit = (data) => {
data.status = selectedLabelsString
let typeArray = []; let typeArray = [];


for (let i = 0; i < type.length; i++) { for (let i = 0; i < type.length; i++) {
@@ -35,14 +36,14 @@ const SearchPublicNoticeForm = ({ applySearch, 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:"",
status: (data.status === "" || data.status.includes('all')) ? "" : data.status,
}; };
applySearch(temp); applySearch(temp);
}; };


function resetForm() { function resetForm() {
setType([]); setType([]);
setStatus({ key: 0, label: '全部', type: 'all' });
setStatus({ key: 0, label: 'All', labelCht: "全部", type: 'all' });
reset(); 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 }}> <Grid item xs={9} s={6} md={5} lg={3} sx={{ ml: 3, mr: 3, mb: 3 }}>
<Autocomplete <Autocomplete
multiple
{...register("status")} {...register("status")}
disablePortal
id="status" id="status"
filterOptions={(options)=>options}
// filterOptions={(options)=>options}
options={ options={
localStorage.getItem('userData').creditor? localStorage.getItem('userData').creditor?
ComboData.publicNoticeStatic_Creditor: ComboData.publicNoticeStatic_Creditor:
ComboData.publicNoticeStatic ComboData.publicNoticeStatic
} }
values={status} values={status}
inputValue={status?.labelCht}
// inputValue={status?.labelCht}
getOptionLabel={(option)=>option.labelCht} getOptionLabel={(option)=>option.labelCht}
onChange={(event, newValue) => { 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) => ( renderInput={(params) => (
<TextField {...params} <TextField {...params}
label="狀態" label="狀態"
/> />
)} )}
InputLabelProps={{
shrink: true
}}
// InputLabelProps={{
// 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}}>*/}


+ 0
- 3
src/pages/PublicNotice/Search_GLD/SearchForm.js View File

@@ -31,9 +31,7 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria,issu


const { reset, register, handleSubmit } = useForm() const { reset, register, handleSubmit } = useForm()
const onSubmit = (data) => { const onSubmit = (data) => {
console.log(selectedLabelsString)
data.status = selectedLabelsString data.status = selectedLabelsString
console.log(data.status)
let typeArray = []; let typeArray = [];


for (let i = 0; i < type.length; i++) { for (let i = 0; i < type.length; i++) {
@@ -194,7 +192,6 @@ const SearchPublicNoticeForm = ({ applySearch, orgComboData, searchCriteria,issu
id="status" id="status"
options={ComboData.publicNoticeStatic_GLD} options={ComboData.publicNoticeStatic_GLD}
value={selectedStatus} value={selectedStatus}
onChange={(event, newValue) => { onChange={(event, newValue) => {
const findAllIndex = newValue.findIndex((ele) => { const findAllIndex = newValue.findIndex((ele) => {
return ele.type === "all" return ele.type === "all"


Loading…
Cancel
Save