From 9866a439ce32c744af0c1c11fe457bc0778faeaa Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 11 Jan 2024 15:07:50 +0800 Subject: [PATCH 1/2] gen xml with selected ids --- src/pages/DemandNote/Create/SearchForm.js | 7 +- src/pages/DemandNote/Search/DataGrid.js | 81 ++++++++++++++++++++++- src/pages/DemandNote/Search/index.js | 33 +-------- src/utils/HttpUtils.js | 67 ++++++++++++------- 4 files changed, 130 insertions(+), 58 deletions(-) diff --git a/src/pages/DemandNote/Create/SearchForm.js b/src/pages/DemandNote/Create/SearchForm.js index 6b46abd..339e8c9 100644 --- a/src/pages/DemandNote/Create/SearchForm.js +++ b/src/pages/DemandNote/Create/SearchForm.js @@ -27,6 +27,7 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _p const [isSuccessPopUp, setIsSuccessPopUp] = React.useState(false); const [resultCount, setResultCount] = React.useState(0); + const [dnIdList, setDnIdList] = React.useState([]); const [issueSelected, setIssueSelected] = React.useState({}); const [paymentCount, setPaymentCount] = React.useState(0); @@ -86,6 +87,7 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _p url: UrlUtils.DEMAND_NOTE_CREATE + "/" + issueSelected.id, onSuccess: function (responseData) { setResultCount(responseData.count); + setDnIdList(responseData.idList); setIsSuccessPopUp(true); } }); @@ -95,9 +97,10 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _p const fileDownload = () => { HttpUtils.fileDownload({ + method:'post', url: UrlUtils.DEMAND_NOTE_EXPORT, params: { - "issueId": issueSelected.id + "dnIdList": dnIdList }, onSuccess: function () { notifyDownloadSuccess(); @@ -219,7 +222,7 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _p + + + +
+ setSelectonWarning(false)} > + Warning + + Please Select DN. + + + + + +
setConfirmPopUp(false)} > Confirm @@ -292,6 +362,13 @@ export default function SearchDemandNote({ recordList, reloadFun, exportXmlFun }
+
+ setWait(false)} > + + Calculating, please wait ... + + +
); } diff --git a/src/pages/DemandNote/Search/index.js b/src/pages/DemandNote/Search/index.js index cbe9141..c8f15f6 100644 --- a/src/pages/DemandNote/Search/index.js +++ b/src/pages/DemandNote/Search/index.js @@ -3,8 +3,6 @@ import { Grid, Typography, Stack, - Button, - Dialog, DialogTitle, DialogContent, DialogActions, } from '@mui/material'; import MainCard from "components/MainCard"; @@ -18,7 +16,7 @@ const LoadingComponent = Loadable(React.lazy(() => import('pages/extra-pages/Loa const SearchForm = Loadable(React.lazy(() => import('./SearchForm'))); const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' -import { notifyDownloadSuccess } from 'utils/CommonFunction'; + const BackgroundHead = { backgroundImage: `url(${titleBackgroundImg})`, @@ -34,8 +32,6 @@ const BackgroundHead = { const UserSearchPage_Individual = () => { - const [isErrorPopUp, setIsErrorPopUp] = React.useState(false); - const [record, setRecord] = React.useState([]); const [orgCombo, setOrgCombo] = React.useState([]); const [issueCombo, setIssueCombo] = React.useState([]); @@ -69,20 +65,6 @@ const UserSearchPage_Individual = () => { }); } - function exportXml() { - if (record.length >= 100) { - setIsErrorPopUp(true); - return; - } - HttpUtils.fileDownload({ - url: UrlUtils.DEMAND_NOTE_EXPORT, - params: searchCriteria, - onSuccess: function () { - notifyDownloadSuccess(); - } - }); - } - function getOrgCombo() { HttpUtils.get({ url: UrlUtils.GET_ORG_COMBO, @@ -140,21 +122,10 @@ const UserSearchPage_Individual = () => {
-
- setIsErrorPopUp(false)} > - Action Fail - - Number of DN record must less than 100.
Please edit search form.
-
- - - -
-
+ ); } diff --git a/src/utils/HttpUtils.js b/src/utils/HttpUtils.js index 1ab55ba..4c87c38 100644 --- a/src/utils/HttpUtils.js +++ b/src/utils/HttpUtils.js @@ -58,35 +58,56 @@ export const postWithFiles = ({url, params, files, onSuccess, onFail, onError}) }); }; -export const fileDownload = ({url, fileId, skey, filename, onResponse, onError}) =>{ +export const fileDownload = ({url, fileId, skey, filename, params, method, onResponse, onError}) =>{ if(!url){ url = FILE_DOWN_GET+"/"+fileId+"/"+skey+"/"+filename } - axios.get( url, - { - responseType: 'blob', - } - ).then( - (response)=>{ - const fn = response.headers.get("content-disposition")?.split("filename=")[1]?.split('"')[1]?.trim()??filename; - const url = URL.createObjectURL(response.data); - const a = document.createElement('a'); - a.href = url; - a.setAttribute("download", fn); - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - URL.revokeObjectURL(url); - if(onResponse){ - onResponse(); + if(method == 'post'){ + axios.post( url, params, + { + responseType: 'blob', + headers:{ + "Content-Type":"application/json" + } } - } - ).catch(error => { - return handleError(error,onError); - }); -}; + ).then( + (response)=>{ + fileDownloadResponse(response, onResponse) + } + ).catch(error => { + return handleError(error,onError); + }); + }else{ + axios.get( url, + { + responseType: 'blob', + params:params + } + ).then( + (response)=>{ + fileDownloadResponse(response, onResponse) + } + ).catch(error => { + return handleError(error,onError); + }); + } +}; +const fileDownloadResponse=(response, onResponse)=>{ + const fn = response.headers.get("content-disposition")?.split("filename=")[1]?.split('"')[1]?.trim()??filename; + const url = URL.createObjectURL(response.data); + const a = document.createElement('a'); + a.href = url; + a.setAttribute("download", fn); + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + if(onResponse){ + onResponse(); + } +} export const fileUpload = ({refType, refId, files, refCode, onSuccess, onFail, onError}) =>{ postWithFiles({ From 45da4e9645a77b8f0d46e474d2b62388fba53404 Mon Sep 17 00:00:00 2001 From: Alex Cheung Date: Thu, 11 Jan 2024 15:31:45 +0800 Subject: [PATCH 2/2] fix payment window method selected --- src/pages/Payment/MultiPaymentWindow.js | 173 +++++++++--------------- src/pages/Payment/index.js | 25 +--- 2 files changed, 72 insertions(+), 126 deletions(-) diff --git a/src/pages/Payment/MultiPaymentWindow.js b/src/pages/Payment/MultiPaymentWindow.js index 9525b53..77e3131 100644 --- a/src/pages/Payment/MultiPaymentWindow.js +++ b/src/pages/Payment/MultiPaymentWindow.js @@ -34,7 +34,7 @@ import FpsIcon from "assets/images/icons/fps.svg"; const MultiPaymentWindow = (props) => { const windowTitle = "請選擇付款方式"; - const [content, setContent] = useState(); + // const [content, setContent] = useState(); const [loadtTransactionData, setLoadtTransactionData] = useState({}); const [loadAvailableMethodData, setLoadAvailableMethodData] = useState([]); const [paymentMethod, setPaymentMethod] = useState(""); @@ -106,110 +106,10 @@ const MultiPaymentWindow = (props) => { props.setConfirmPayment(true); }; - // const getMethodImgClass = (method) => () =>{ - // setPaymentMethodClass() - // return paymentMethod == method || paymentMethod == "" ? "" : "grayscale"; - // } - useEffect(() => { if(props.selectedPaymentMethod === ""){ setPaymentMethod("") } - if (availableMethodData.length>0){ - setContent( - - {/* - - - - 交易參考編號: - - - - - {props.transactionData.transactionid} - - - - - - - - - 付款金額: - - - - - {"HK$ "+FormatUtils.currencyFormat(props.totalAmount)} - - - - */} - - - - - 請選擇付款方法: - - - - - - - - - - - - - - - - - - - - - - - {paymentMethod !=""? - - - - - 已選擇付款方法: - - - - - {paymentMethod} - - - - - : null} - - ) - }else{ - - - 付款功能現在不可用。 - - - } }, [availableMethodData]); const formik = useFormik({ @@ -256,19 +156,80 @@ const MultiPaymentWindow = (props) => { */} {!props.onReady ? - :content + :availableMethodData.length>0? + + + + + + 請選擇付款方法: + + + + + + + + + + + + + + + + + + + + + + + {paymentMethod !=""? + + + + + 已選擇付款方法:  + + + + + {paymentMethod} + + + + + : null} + : + + + 付款功能現在不可用。 + + } - - - 付款總額(HK$): + + 付款總額(HK$):  - + {" HK$ " + FormatUtils.currencyFormat(props.totalAmount)} diff --git a/src/pages/Payment/index.js b/src/pages/Payment/index.js index c64bf6e..fbf037d 100644 --- a/src/pages/Payment/index.js +++ b/src/pages/Payment/index.js @@ -47,7 +47,7 @@ const Index = () => { const navigate = useNavigate() const location = useLocation(); - // const local = {en:"en_us", zh:"zh_hk", cn:"zh_cn"}; + // const local = {en:"en-us", zh:"zh-hk", cn:"zh-cn"}; const preferpaymentmethods = ['visa', 'mastercard', 'pps', 'creditcard', 'fps']; const [totalAmount, setTotalAmount] = useState(0); const [appIds, setAppIds] = useState([]); @@ -169,8 +169,12 @@ const Index = () => { let availableMethods = responseData.availablepaymentmethods; setAvailableMethods(availableMethods); + }, + onError: () =>{ + setOnReady(true) } }); + // const responseData = { // "availablepaymentmethods": [ // { @@ -298,25 +302,6 @@ const Index = () => { // }; // let availableMethods = responseData.availablepaymentmethods; // setAvailableMethods(availableMethods); - // if (availableMethods.length>0){ - // availableMethods.forEach((method)=>{ - // if(method.subtype === "FPS" ){ - // setFPSStatus(method) - // }else if (method.subtype === "CreditCard"){ - // method.supportedcard.forEach((supportedcard)=>{ - // if (supportedcard === "JCB" || supportedcard === "MasterCard" || supportedcard === "Visa"){ - // setCreditCardStatus(method) - // } else { - // if (supportedcard === "UnionPay"){ - // setUnionPayStatus(method) - // } - // } - // }) - // }else if (method.subtype === "PPS" ){ - // setPPSStatus(method) - // } - // }); - // } } useEffect(() => {