| @@ -46,6 +46,11 @@ const SearchPublicNoticeForm = ({ applySearch, generateXML, searchCriteria, onGr | |||||
| setToDateValue(maxDate); | setToDateValue(maxDate); | ||||
| }, [maxDate]); | }, [maxDate]); | ||||
| const toPayMethodArray = (opt) => { | |||||
| if (!opt || opt.type === 'all') return []; | |||||
| return Array.isArray(opt.type) ? opt.type : [opt.type]; | |||||
| }; | |||||
| const onSubmit = () => { | const onSubmit = () => { | ||||
| let sentDateFrom = ""; | let sentDateFrom = ""; | ||||
| let sentDateTo = ""; | let sentDateTo = ""; | ||||
| @@ -63,7 +68,7 @@ const SearchPublicNoticeForm = ({ applySearch, generateXML, searchCriteria, onGr | |||||
| dateFrom: sentDateFrom, | dateFrom: sentDateFrom, | ||||
| dateTo: sentDateTo, | dateTo: sentDateTo, | ||||
| paymentId: selectedIds.join(','), | paymentId: selectedIds.join(','), | ||||
| payMethod : (payMethod?.type && payMethod?.type != 'all') ? payMethod?.type : "", | |||||
| payMethod : toPayMethodArray(payMethod), | |||||
| // status : (status?.type && status?.type != 'all') ? status?.type : "", | // status : (status?.type && status?.type != 'all') ? status?.type : "", | ||||
| }; | }; | ||||
| applySearch(temp); | applySearch(temp); | ||||
| @@ -44,6 +44,26 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, onGridReady }) => | |||||
| } | } | ||||
| }, [searchCriteria]); | }, [searchCriteria]); | ||||
| React.useEffect(() => { | |||||
| const defaultPayMethod = ComboData.payMethod[0]; | |||||
| const value = searchCriteria?.payMethod; // may be [], null, undefined, or array of strings | |||||
| if (!value || value.length === 0) { | |||||
| setPayMethod(defaultPayMethod); | |||||
| return; | |||||
| } | |||||
| // Find the matching entry whose type array matches value contents | |||||
| const found = ComboData.payMethod.find(item => | |||||
| Array.isArray(item.type) && | |||||
| item.type.length === value.length && | |||||
| item.type.every((v, i) => v === value[i]) // strict positional match | |||||
| ); | |||||
| setPayMethod(found ?? defaultPayMethod); | |||||
| }, [searchCriteria?.payMethod]); | |||||
| React.useEffect(() => { | React.useEffect(() => { | ||||
| setFromDateValue(minDate); | setFromDateValue(minDate); | ||||
| }, [minDate]); | }, [minDate]); | ||||
| @@ -52,6 +72,13 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, onGridReady }) => | |||||
| setToDateValue(maxDate); | setToDateValue(maxDate); | ||||
| }, [maxDate]); | }, [maxDate]); | ||||
| // add near the top inside the component (after useState for payMethod) | |||||
| const toPayMethodArray = (opt) => { | |||||
| if (!opt || opt.type === 'all') return []; | |||||
| return Array.isArray(opt.type) ? opt.type : [opt.type]; | |||||
| }; | |||||
| const onSubmit = (data) => { | const onSubmit = (data) => { | ||||
| let sentDateFrom = ""; | let sentDateFrom = ""; | ||||
| let sentDateTo = ""; | let sentDateTo = ""; | ||||
| @@ -67,7 +94,7 @@ const SearchPublicNoticeForm = ({ applySearch, searchCriteria, onGridReady }) => | |||||
| dateFrom: sentDateFrom, | dateFrom: sentDateFrom, | ||||
| dateTo: sentDateTo, | dateTo: sentDateTo, | ||||
| status : (status?.type && status?.type != 'all') ? status?.type : "", | status : (status?.type && status?.type != 'all') ? status?.type : "", | ||||
| payMethod : (payMethod?.type && payMethod?.type != 'all') ? payMethod?.type : "", | |||||
| payMethod : toPayMethodArray(payMethod), | |||||
| start:0, | start:0, | ||||
| limit:10 | limit:10 | ||||
| }; | }; | ||||
| @@ -143,10 +143,11 @@ export const paymentStatus = [ | |||||
| export const payMethod = [ | export const payMethod = [ | ||||
| { key: 0, labelCht: '全部', label: 'All', type: 'all' }, | { key: 0, labelCht: '全部', label: 'All', type: 'all' }, | ||||
| { key: 1, labelCht: '繳費靈', label: 'PPS', type: '01,PPSB,PPS' }, | |||||
| { key: 2, labelCht: '信用卡', label:'Credit Card', type: '02,BCMP,CreditCard' }, | |||||
| { key: 3, labelCht: '銀聯', label:'UnionPay', type: '03,BCMP,CreditCard' }, | |||||
| { key: 4, labelCht: '轉數快', label:'FPS', type: '04,BCFP,FPS' }, | |||||
| { key: 1, labelCht: '繳費靈', label: 'PPS', type: ['01,PPSB,PPS'] }, | |||||
| { key: 2, labelCht: '信用卡', label:'Credit Card', type: ['02,BCMP,CreditCard','03,BCMP,CreditCard'] }, | |||||
| { key: 3, labelCht: '轉數快', label:'FPS', type: ['04,BCFP,FPS'] }, | |||||
| // { key: 3, labelCht: '銀聯', label:'UnionPay', type: '03,BCMP,CreditCard' }, | |||||
| // { key: 4, labelCht: '轉數快', label:'FPS', type: '04,BCFP,FPS' }, | |||||
| ]; | ]; | ||||
| export const paymentMeans= [ | export const paymentMeans= [ | ||||
| @@ -1,13 +1,14 @@ | |||||
| import axios from "axios"; | import axios from "axios"; | ||||
| import { FILE_UP_POST, FILE_DOWN_GET } from "../utils/ApiPathConst"; | import { FILE_UP_POST, FILE_DOWN_GET } from "../utils/ApiPathConst"; | ||||
| import qs from 'qs'; | |||||
| export const get = ({ url, params, onSuccess, onFail, onError }) => { | export const get = ({ url, params, onSuccess, onFail, onError }) => { | ||||
| axios.get(url, { | axios.get(url, { | ||||
| params: params | |||||
| params, | |||||
| paramsSerializer: (p) => qs.stringify(p, { arrayFormat: 'repeat' }) // <-- FIX | |||||
| }).then( | }).then( | ||||
| (response) => { onResponse(response, onSuccess, onFail); } | (response) => { onResponse(response, onSuccess, onFail); } | ||||
| ).catch((error) => { | ).catch((error) => { | ||||
| // console.log(error); | |||||
| return handleError(error, onError); | return handleError(error, onError); | ||||
| }); | }); | ||||
| }; | }; | ||||
| @@ -68,9 +69,9 @@ export const postWithFiles = ({ url, params, files, onSuccess, onFail, onError } | |||||
| }); | }); | ||||
| }; | }; | ||||
| export const fileDownload = ({ url, fileId, skey, filename, params, method, onResponse, onError }) => { | |||||
| export const fileDownload = ({ url, fileId, skey, params, method, onResponse, onError }) => { | |||||
| if (!url) { | if (!url) { | ||||
| url = FILE_DOWN_GET + "/" + fileId + "/" + skey + "/" + filename | |||||
| url = FILE_DOWN_GET + "/" + fileId + "/" + skey | |||||
| } | } | ||||
| if (method == 'post') { | if (method == 'post') { | ||||
| axios.post(url, params, | axios.post(url, params, | ||||