@@ -27,6 +27,7 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _p | |||||
const [isSuccessPopUp, setIsSuccessPopUp] = React.useState(false); | const [isSuccessPopUp, setIsSuccessPopUp] = React.useState(false); | ||||
const [resultCount, setResultCount] = React.useState(0); | const [resultCount, setResultCount] = React.useState(0); | ||||
const [dnIdList, setDnIdList] = React.useState([]); | |||||
const [issueSelected, setIssueSelected] = React.useState({}); | const [issueSelected, setIssueSelected] = React.useState({}); | ||||
const [paymentCount, setPaymentCount] = React.useState(0); | const [paymentCount, setPaymentCount] = React.useState(0); | ||||
@@ -86,6 +87,7 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _p | |||||
url: UrlUtils.DEMAND_NOTE_CREATE + "/" + issueSelected.id, | url: UrlUtils.DEMAND_NOTE_CREATE + "/" + issueSelected.id, | ||||
onSuccess: function (responseData) { | onSuccess: function (responseData) { | ||||
setResultCount(responseData.count); | setResultCount(responseData.count); | ||||
setDnIdList(responseData.idList); | |||||
setIsSuccessPopUp(true); | setIsSuccessPopUp(true); | ||||
} | } | ||||
}); | }); | ||||
@@ -95,9 +97,10 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _p | |||||
const fileDownload = () => { | const fileDownload = () => { | ||||
HttpUtils.fileDownload({ | HttpUtils.fileDownload({ | ||||
method:'post', | |||||
url: UrlUtils.DEMAND_NOTE_EXPORT, | url: UrlUtils.DEMAND_NOTE_EXPORT, | ||||
params: { | params: { | ||||
"issueId": issueSelected.id | |||||
"dnIdList": dnIdList | |||||
}, | }, | ||||
onSuccess: function () { | onSuccess: function () { | ||||
notifyDownloadSuccess(); | notifyDownloadSuccess(); | ||||
@@ -219,7 +222,7 @@ const SearchPublicNoticeForm = ({ applySearch, issueComboData, _paymentCount, _p | |||||
<Grid item md={12}> | <Grid item md={12}> | ||||
<Button | <Button | ||||
size="large" | size="large" | ||||
onClick={fileDownload} | |||||
onClick={()=>fileDownload()} | |||||
sx={{ | sx={{ | ||||
textTransform: 'capitalize', | textTransform: 'capitalize', | ||||
alignItems: 'end' | alignItems: 'end' | ||||
@@ -11,15 +11,19 @@ import * as DateUtils from "utils/DateUtils"; | |||||
import * as StatusUtils from "utils/statusUtils/DnStatus"; | import * as StatusUtils from "utils/statusUtils/DnStatus"; | ||||
import { useNavigate } from "react-router-dom"; | import { useNavigate } from "react-router-dom"; | ||||
import { FiDataGrid } from "components/FiDataGrid"; | import { FiDataGrid } from "components/FiDataGrid"; | ||||
import { notifyDownloadSuccess } from 'utils/CommonFunction'; | |||||
import * as UrlUtils from "utils/ApiPathConst"; | import * as UrlUtils from "utils/ApiPathConst"; | ||||
import * as HttpUtils from "utils/HttpUtils"; | import * as HttpUtils from "utils/HttpUtils"; | ||||
// ==============================|| EVENT TABLE ||============================== // | // ==============================|| EVENT TABLE ||============================== // | ||||
export default function SearchDemandNote({ recordList, reloadFun, exportXmlFun }) { | |||||
export default function SearchDemandNote({ recordList, reloadFun }) { | |||||
const [isConfirmPopUp, setConfirmPopUp] = React.useState(false); | const [isConfirmPopUp, setConfirmPopUp] = React.useState(false); | ||||
const [isSendPopUp, setSendPopUp] = React.useState(false); | const [isSendPopUp, setSendPopUp] = React.useState(false); | ||||
const [isErrorPopUp, setIsErrorPopUp] = React.useState(false); | |||||
const [selectonWarning, setSelectonWarning] = React.useState(false); | |||||
const [wait, setWait] = React.useState(false); | |||||
const [rows, setRows] = React.useState(recordList); | const [rows, setRows] = React.useState(recordList); | ||||
const [selectedRowItems, setSelectedRowItems] = React.useState([]); | const [selectedRowItems, setSelectedRowItems] = React.useState([]); | ||||
@@ -33,6 +37,32 @@ export default function SearchDemandNote({ recordList, reloadFun, exportXmlFun } | |||||
navigate('/paymentPage/demandNote/details/' + params.id); | navigate('/paymentPage/demandNote/details/' + params.id); | ||||
}; | }; | ||||
const exportXml = () => { | |||||
let idList = []; | |||||
const datas = rows?.filter((row) => | |||||
selectedRowItems.includes(row.id) | |||||
); | |||||
if(datas?.length<1){ | |||||
setSelectonWarning(true); | |||||
return; | |||||
}else if (datas?.length >= 100) { | |||||
setIsErrorPopUp(true); | |||||
return; | |||||
} | |||||
for (var i = 0; i < datas?.length; i++) { | |||||
idList.push(datas[i].id); | |||||
} | |||||
HttpUtils.fileDownload({ | |||||
method:'post', | |||||
url: UrlUtils.DEMAND_NOTE_EXPORT, | |||||
params: { | |||||
dnIdList:idList | |||||
}, | |||||
onSuccess: function () { | |||||
notifyDownloadSuccess(); | |||||
} | |||||
}); | |||||
} | |||||
const onDownloadClick = (params) => () => { | const onDownloadClick = (params) => () => { | ||||
HttpUtils.fileDownload({ | HttpUtils.fileDownload({ | ||||
@@ -48,6 +78,10 @@ export default function SearchDemandNote({ recordList, reloadFun, exportXmlFun } | |||||
const datas = rows?.filter((row) => | const datas = rows?.filter((row) => | ||||
selectedRowItems.includes(row.id) | selectedRowItems.includes(row.id) | ||||
); | ); | ||||
if(datas?.length<1){ | |||||
setSelectonWarning(true); | |||||
return; | |||||
} | |||||
for (var i = 0; i < datas?.length; i++) { | for (var i = 0; i < datas?.length; i++) { | ||||
idList.push(datas[i].id); | idList.push(datas[i].id); | ||||
} | } | ||||
@@ -64,6 +98,7 @@ export default function SearchDemandNote({ recordList, reloadFun, exportXmlFun } | |||||
} | } | ||||
const doUploadFile = (event) => { | const doUploadFile = (event) => { | ||||
setWait(true); | |||||
let dnMap = {}; | let dnMap = {}; | ||||
const datas = rows?.filter((row) => | const datas = rows?.filter((row) => | ||||
selectedRowItems.includes(row.id) | selectedRowItems.includes(row.id) | ||||
@@ -80,6 +115,7 @@ export default function SearchDemandNote({ recordList, reloadFun, exportXmlFun } | |||||
}, | }, | ||||
files:[file], | files:[file], | ||||
onSuccess() { | onSuccess() { | ||||
setWait(false); | |||||
if (reloadFun) reloadFun(); | if (reloadFun) reloadFun(); | ||||
}, | }, | ||||
}); | }); | ||||
@@ -92,6 +128,10 @@ export default function SearchDemandNote({ recordList, reloadFun, exportXmlFun } | |||||
const datas = rows?.filter((row) => | const datas = rows?.filter((row) => | ||||
selectedRowItems.includes(row.id) | selectedRowItems.includes(row.id) | ||||
); | ); | ||||
if(datas?.length<1){ | |||||
setSelectonWarning(true); | |||||
return; | |||||
} | |||||
for (var i = 0; i < datas?.length; i++) { | for (var i = 0; i < datas?.length; i++) { | ||||
idList.push(datas[i].id); | idList.push(datas[i].id); | ||||
} | } | ||||
@@ -198,6 +238,14 @@ export default function SearchDemandNote({ recordList, reloadFun, exportXmlFun } | |||||
accept=".pdf" | accept=".pdf" | ||||
style={{ display: 'none' }} | style={{ display: 'none' }} | ||||
onChange={(event) => { | onChange={(event) => { | ||||
const datas = rows?.filter((row) => | |||||
selectedRowItems.includes(row.id) | |||||
); | |||||
if(datas.length==0){ | |||||
setSelectonWarning(true); | |||||
document.getElementById("uploadFileBtn").value = ""; | |||||
return; | |||||
} | |||||
doUploadFile(event) | doUploadFile(event) | ||||
}} | }} | ||||
/> | /> | ||||
@@ -228,7 +276,7 @@ export default function SearchDemandNote({ recordList, reloadFun, exportXmlFun } | |||||
<Button | <Button | ||||
size="large" | size="large" | ||||
variant="contained" | variant="contained" | ||||
onClick={exportXmlFun} | |||||
onClick={()=>exportXml()} | |||||
sx={{ | sx={{ | ||||
textTransform: 'capitalize', | textTransform: 'capitalize', | ||||
alignItems: 'end' | alignItems: 'end' | ||||
@@ -268,6 +316,28 @@ export default function SearchDemandNote({ recordList, reloadFun, exportXmlFun } | |||||
onRowDoubleClick={handleRowDoubleClick} | onRowDoubleClick={handleRowDoubleClick} | ||||
/> | /> | ||||
</Box> | </Box> | ||||
<div> | |||||
<Dialog open={isErrorPopUp} onClose={() => setIsErrorPopUp(false)} > | |||||
<DialogTitle><Typography variant="h3">Action Fail</Typography></DialogTitle> | |||||
<DialogContent style={{ display: 'flex', }}> | |||||
<Typography variant="h4" style={{ padding: '16px' }}>Number of DN record must less than 100.<br/>Please edit search form.</Typography> | |||||
</DialogContent> | |||||
<DialogActions> | |||||
<Button onClick={() => setIsErrorPopUp(false)}><Typography variant="h5">OK</Typography></Button> | |||||
</DialogActions> | |||||
</Dialog> | |||||
</div> | |||||
<div> | |||||
<Dialog open={selectonWarning} onClose={() => setSelectonWarning(false)} > | |||||
<DialogTitle><Typography variant="h3">Warning</Typography></DialogTitle> | |||||
<DialogContent style={{ display: 'flex', }}> | |||||
<Typography variant="h4" style={{ padding: '16px' }}>Please Select DN.</Typography> | |||||
</DialogContent> | |||||
<DialogActions> | |||||
<Button onClick={() => setSelectonWarning(false)}><Typography variant="h5">OK</Typography></Button> | |||||
</DialogActions> | |||||
</Dialog> | |||||
</div> | |||||
<div> | <div> | ||||
<Dialog open={isConfirmPopUp} onClose={() => setConfirmPopUp(false)} > | <Dialog open={isConfirmPopUp} onClose={() => setConfirmPopUp(false)} > | ||||
<DialogTitle><Typography variant="h3">Confirm</Typography></DialogTitle> | <DialogTitle><Typography variant="h3">Confirm</Typography></DialogTitle> | ||||
@@ -292,6 +362,13 @@ export default function SearchDemandNote({ recordList, reloadFun, exportXmlFun } | |||||
</DialogActions> | </DialogActions> | ||||
</Dialog> | </Dialog> | ||||
</div> | </div> | ||||
<div> | |||||
<Dialog open={wait} onClose={() => setWait(false)} > | |||||
<DialogContent style={{ display: 'flex', }}> | |||||
<Typography variant="h4" style={{ padding: '16px' }}>Calculating, please wait ...</Typography> | |||||
</DialogContent> | |||||
</Dialog> | |||||
</div> | |||||
</div> | </div> | ||||
); | ); | ||||
} | } |
@@ -3,8 +3,6 @@ import { | |||||
Grid, | Grid, | ||||
Typography, | Typography, | ||||
Stack, | Stack, | ||||
Button, | |||||
Dialog, DialogTitle, DialogContent, DialogActions, | |||||
} from '@mui/material'; | } from '@mui/material'; | ||||
import MainCard from "components/MainCard"; | 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 SearchForm = Loadable(React.lazy(() => import('./SearchForm'))); | ||||
const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); | const EventTable = Loadable(React.lazy(() => import('./DataGrid'))); | ||||
import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' | import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' | ||||
import { notifyDownloadSuccess } from 'utils/CommonFunction'; | |||||
const BackgroundHead = { | const BackgroundHead = { | ||||
backgroundImage: `url(${titleBackgroundImg})`, | backgroundImage: `url(${titleBackgroundImg})`, | ||||
@@ -34,8 +32,6 @@ const BackgroundHead = { | |||||
const UserSearchPage_Individual = () => { | const UserSearchPage_Individual = () => { | ||||
const [isErrorPopUp, setIsErrorPopUp] = React.useState(false); | |||||
const [record, setRecord] = React.useState([]); | const [record, setRecord] = React.useState([]); | ||||
const [orgCombo, setOrgCombo] = React.useState([]); | const [orgCombo, setOrgCombo] = React.useState([]); | ||||
const [issueCombo, setIssueCombo] = 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() { | function getOrgCombo() { | ||||
HttpUtils.get({ | HttpUtils.get({ | ||||
url: UrlUtils.GET_ORG_COMBO, | url: UrlUtils.GET_ORG_COMBO, | ||||
@@ -140,21 +122,10 @@ const UserSearchPage_Individual = () => { | |||||
<EventTable | <EventTable | ||||
recordList={record} | recordList={record} | ||||
reloadFun={getUserList} | reloadFun={getUserList} | ||||
exportXmlFun={exportXml} | |||||
/> | /> | ||||
</MainCard> | </MainCard> | ||||
</Grid> | </Grid> | ||||
<div> | |||||
<Dialog open={isErrorPopUp} onClose={() => setIsErrorPopUp(false)} > | |||||
<DialogTitle><Typography variant="h3">Action Fail</Typography></DialogTitle> | |||||
<DialogContent style={{ display: 'flex', }}> | |||||
<Typography variant="h4" style={{ padding: '16px' }}>Number of DN record must less than 100.<br/>Please edit search form.</Typography> | |||||
</DialogContent> | |||||
<DialogActions> | |||||
<Button onClick={() => setIsErrorPopUp(false)}><Typography variant="h5">OK</Typography></Button> | |||||
</DialogActions> | |||||
</Dialog> | |||||
</div> | |||||
</Grid> | </Grid> | ||||
); | ); | ||||
} | } | ||||
@@ -34,7 +34,7 @@ import FpsIcon from "assets/images/icons/fps.svg"; | |||||
const MultiPaymentWindow = (props) => { | const MultiPaymentWindow = (props) => { | ||||
const windowTitle = "請選擇付款方式"; | const windowTitle = "請選擇付款方式"; | ||||
const [content, setContent] = useState(); | |||||
// const [content, setContent] = useState(); | |||||
const [loadtTransactionData, setLoadtTransactionData] = useState({}); | const [loadtTransactionData, setLoadtTransactionData] = useState({}); | ||||
const [loadAvailableMethodData, setLoadAvailableMethodData] = useState([]); | const [loadAvailableMethodData, setLoadAvailableMethodData] = useState([]); | ||||
const [paymentMethod, setPaymentMethod] = useState(""); | const [paymentMethod, setPaymentMethod] = useState(""); | ||||
@@ -106,110 +106,10 @@ const MultiPaymentWindow = (props) => { | |||||
props.setConfirmPayment(true); | props.setConfirmPayment(true); | ||||
}; | }; | ||||
// const getMethodImgClass = (method) => () =>{ | |||||
// setPaymentMethodClass() | |||||
// return paymentMethod == method || paymentMethod == "" ? "" : "grayscale"; | |||||
// } | |||||
useEffect(() => { | useEffect(() => { | ||||
if(props.selectedPaymentMethod === ""){ | if(props.selectedPaymentMethod === ""){ | ||||
setPaymentMethod("") | setPaymentMethod("") | ||||
} | } | ||||
if (availableMethodData.length>0){ | |||||
setContent( | |||||
<Grid container spacing={2} direction="column" justifyContent="space-between" alignItems="flex-start"> | |||||
{/* <Grid item xs={12} md={12}> | |||||
<Grid container > | |||||
<Grid item> | |||||
<FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}> | |||||
交易參考編號: | |||||
</FormLabel> | |||||
</Grid> | |||||
<Grid item> | |||||
<FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}> | |||||
{props.transactionData.transactionid} | |||||
</FormLabel> | |||||
</Grid> | |||||
</Grid> | |||||
</Grid> | |||||
<Grid item xs={12} md={12}> | |||||
<Grid container > | |||||
<Grid item> | |||||
<FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}> | |||||
付款金額: | |||||
</FormLabel> | |||||
</Grid> | |||||
<Grid item> | |||||
<FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}> | |||||
{"HK$ "+FormatUtils.currencyFormat(props.totalAmount)} | |||||
</FormLabel> | |||||
</Grid> | |||||
</Grid> | |||||
</Grid> */} | |||||
<Grid item xs={12} md={12}> | |||||
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="center"> | |||||
<Grid item> | |||||
<Typography variant="h5" sx={{ textAlign: "left" }}> | |||||
請選擇付款方法: | |||||
</Typography> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("FPS")} disabled={props.fpsStatus.active === "N"}> | |||||
<img className={fpsClass} src={FpsIcon} width="80" height="80" alt="FPS"></img> | |||||
</Button> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("Visa")} disabled={props.creditCardStatus.active === "N"}> | |||||
<img className={visaClass} src={VisaIcon} width="80" height="80" alt="Visa"></img> | |||||
</Button> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("Mastercard")} disabled={props.creditCardStatus.active === "N"}> | |||||
<img className={mastercardClass} src={MasterIcon} width="80" height="80" alt="Mastercard"></img> | |||||
</Button> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("UnionPay")} disabled={props.unionPayStatus.active === "N"}> | |||||
<img className={unionPayClass} src={UnionPayIcon} width="80" height="80" alt="UnionPay"></img> | |||||
</Button> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("JCB")} disabled={props.unionPayStatus.active === "N"}> | |||||
<img className={jCBClass} src={JcbIcon} width="80" height="80" alt="JCB"></img> | |||||
</Button> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("PPS")} disabled={props.ppsStatus.active === "N"}> | |||||
<img className={pPSClass} src={PpsIcon} width="80" height="80" alt="PPS"></img> | |||||
</Button> | |||||
</Grid> | |||||
</Grid> | |||||
</Grid> | |||||
{paymentMethod !=""? | |||||
<Grid item xs={12} md={12}> | |||||
<Grid container direction="row" justifyContent="flex-start" alignItems="center"> | |||||
<Grid item> | |||||
<FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}> | |||||
已選擇付款方法: | |||||
</FormLabel> | |||||
</Grid> | |||||
<Grid item> | |||||
<FormLabel sx={{ fontSize: "16px", color: "#000000", textAlign: "center" }}> | |||||
{paymentMethod} | |||||
</FormLabel> | |||||
</Grid> | |||||
</Grid> | |||||
</Grid> | |||||
: null} | |||||
</Grid> | |||||
) | |||||
}else{ | |||||
<Grid container direction="row" justifyContent="center" alignItems="center"> | |||||
<FormLabel sx={{ fontSize: "20px", color: "#000000", textAlign: "center" }}> | |||||
付款功能現在不可用。 | |||||
</FormLabel> | |||||
</Grid> | |||||
} | |||||
}, [availableMethodData]); | }, [availableMethodData]); | ||||
const formik = useFormik({ | const formik = useFormik({ | ||||
@@ -256,19 +156,80 @@ const MultiPaymentWindow = (props) => { | |||||
</Typography> */} | </Typography> */} | ||||
{!props.onReady ? | {!props.onReady ? | ||||
<LoadingComponent /> | <LoadingComponent /> | ||||
:content | |||||
:availableMethodData.length>0? | |||||
<Grid container spacing={2} direction="column" justifyContent="space-between" alignItems="flex-start"> | |||||
<Grid item xs={12} md={12}> | |||||
<Grid container spacing={1} direction="row" justifyContent="flex-start" alignItems="center"> | |||||
<Grid item> | |||||
<Typography variant="h5" sx={{ textAlign: "left" }}> | |||||
請選擇付款方法: | |||||
</Typography> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("FPS")} disabled={props.fpsStatus.active === "N"}> | |||||
<img className={fpsClass} src={FpsIcon} width="80" height="80" alt="FPS"></img> | |||||
</Button> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("Visa")} disabled={props.creditCardStatus.active === "N"}> | |||||
<img className={visaClass} src={VisaIcon} width="80" height="80" alt="Visa"></img> | |||||
</Button> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("Mastercard")} disabled={props.creditCardStatus.active === "N"}> | |||||
<img className={mastercardClass} src={MasterIcon} width="80" height="80" alt="Mastercard"></img> | |||||
</Button> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("UnionPay")} disabled={props.unionPayStatus.active === "N"}> | |||||
<img className={unionPayClass} src={UnionPayIcon} width="80" height="80" alt="UnionPay"></img> | |||||
</Button> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("JCB")} disabled={props.unionPayStatus.active === "N"}> | |||||
<img className={jCBClass} src={JcbIcon} width="80" height="80" alt="JCB"></img> | |||||
</Button> | |||||
</Grid> | |||||
<Grid item> | |||||
<Button variant="contained" color="white" onClick={selectedPaymentMethodHandle("PPS")} disabled={props.ppsStatus.active === "N"}> | |||||
<img className={pPSClass} src={PpsIcon} width="80" height="80" alt="PPS"></img> | |||||
</Button> | |||||
</Grid> | |||||
</Grid> | |||||
</Grid> | |||||
{paymentMethod !=""? | |||||
<Grid item xs={12} md={12}> | |||||
<Grid container direction="row" justifyContent="flex-start" alignItems="center"> | |||||
<Grid item> | |||||
<FormLabel sx={{ fontSize: "20px", color: "#000000", textAlign: "center" }}> | |||||
已選擇付款方法: | |||||
</FormLabel> | |||||
</Grid> | |||||
<Grid item> | |||||
<FormLabel sx={{ fontSize: "20px", color: "#000000", textAlign: "center" }}> | |||||
{paymentMethod} | |||||
</FormLabel> | |||||
</Grid> | |||||
</Grid> | |||||
</Grid> | |||||
: null} | |||||
</Grid>: | |||||
<Grid container direction="row" justifyContent="center" alignItems="center"> | |||||
<FormLabel sx={{ fontSize: "20px", color: "#000000", textAlign: "center"}}> | |||||
付款功能現在不可用。 | |||||
</FormLabel> | |||||
</Grid> | |||||
} | } | ||||
</Grid> | </Grid> | ||||
<Grid item xs={12} md={12}> | <Grid item xs={12} md={12}> | ||||
<Grid container > | <Grid container > | ||||
<Grid item> | <Grid item> | ||||
<Typography variant="h5" sx={{ textAlign: "left" }}> | |||||
付款總額(HK$): | |||||
<Typography sx={{fontSize: "20px", color: "#000000", textAlign: "left" }}> | |||||
付款總額(HK$): | |||||
</Typography> | </Typography> | ||||
</Grid> | </Grid> | ||||
<Grid item> | <Grid item> | ||||
<Typography variant="h5" sx={{ textAlign: "left" }}> | |||||
<Typography sx={{fontSize: "20px", color: "#000000", textAlign: "left" }}> | |||||
{" HK$ " + FormatUtils.currencyFormat(props.totalAmount)} | {" HK$ " + FormatUtils.currencyFormat(props.totalAmount)} | ||||
</Typography> | </Typography> | ||||
</Grid> | </Grid> | ||||
@@ -47,7 +47,7 @@ const Index = () => { | |||||
const navigate = useNavigate() | const navigate = useNavigate() | ||||
const location = useLocation(); | 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 preferpaymentmethods = ['visa', 'mastercard', 'pps', 'creditcard', 'fps']; | ||||
const [totalAmount, setTotalAmount] = useState(0); | const [totalAmount, setTotalAmount] = useState(0); | ||||
const [appIds, setAppIds] = useState([]); | const [appIds, setAppIds] = useState([]); | ||||
@@ -169,8 +169,12 @@ const Index = () => { | |||||
let availableMethods = responseData.availablepaymentmethods; | let availableMethods = responseData.availablepaymentmethods; | ||||
setAvailableMethods(availableMethods); | setAvailableMethods(availableMethods); | ||||
}, | |||||
onError: () =>{ | |||||
setOnReady(true) | |||||
} | } | ||||
}); | }); | ||||
// const responseData = { | // const responseData = { | ||||
// "availablepaymentmethods": [ | // "availablepaymentmethods": [ | ||||
// { | // { | ||||
@@ -298,25 +302,6 @@ const Index = () => { | |||||
// }; | // }; | ||||
// let availableMethods = responseData.availablepaymentmethods; | // let availableMethods = responseData.availablepaymentmethods; | ||||
// setAvailableMethods(availableMethods); | // 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(() => { | useEffect(() => { | ||||
@@ -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){ | if(!url){ | ||||
url = FILE_DOWN_GET+"/"+fileId+"/"+skey+"/"+filename | 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}) =>{ | export const fileUpload = ({refType, refId, files, refCode, onSuccess, onFail, onError}) =>{ | ||||
postWithFiles({ | postWithFiles({ | ||||