// material-ui import * as React from 'react'; import { Stack, Typography, Button, Dialog, DialogTitle, DialogContent, DialogActions } from '@mui/material'; import { FiDataGrid } from "components/FiDataGrid"; import * as DateUtils from "utils/DateUtils" import * as FormatUtils from "utils/FormatUtils" import * as StatusUtils from "utils/statusUtils/PublicNoteStatusUtils"; import { useNavigate } from "react-router-dom"; // ==============================|| EVENT TABLE ||============================== // export default function SubmittedTab({ rows }) { const [selectedRowItems, setSelectedRowItems] = React.useState([]); const [isPopUp, setIsPopUp] = React.useState(false); //const [amount, setAmount] = React.useState(0); const navigate = useNavigate() const handleDetailClick = (params) => () => { navigate('/publicNotice/' + params.id); }; const columns = [ { id: 'appNo', field: 'appNo', headerName: '申請編號', flex: 1, }, { id: 'created', field: 'created', headerName: '提交日期', flex: 1, valueGetter: (params) => { return DateUtils.datetimeStr(params.value); } }, // { // id: 'contactPerson', // field: 'contactPerson', // headerName: '聯絡人', // flex: 2, // renderCell: (params) => { // let phone = JSON.parse(params.row.contactTelNo); // let faxNo = JSON.parse(params.row.contactFaxNo); // let contact = ""; // if (phone) { // contact = "電話: " + phone?.countryCode + " " + phone?.phoneNumber // } // if (faxNo && faxNo?.faxNumber) { // if (contact != "") // contact = contact + ", " // contact = contact + "傳真:" + faxNo?.countryCode + " " + faxNo?.faxNumber // } // return (<> // {params?.value}
// {contact} // ); // } // }, { id: 'remarks', field: 'remarks', headerName: '我的備註', flex: 3, }, { id: 'fee', field: 'fee', headerName: '價錢', flex: 1, renderCell: (params) => { return FormatUtils.currencyFormat(params.row.fee) }, }, { id: 'status', field: 'status', headerName: '狀態', flex: 1, renderCell: (params) => { return [StatusUtils.getStatus(params)] }, }, { field: 'actions', type: 'actions', headerName: '', width: 120, cellClassName: 'actions', renderCell: (params) => { return ; }, } ]; const getWindowContent = () => { var content = []; let totalAmount = 0; const datas = rows?.filter((row) => selectedRowItems.includes(row.id) ); for (var i = 0; i < datas?.length; i++) { content.push(<> 申請編號: {datas[i].appNo}({DateUtils.datetimeStr(datas[i].created)}) 備註: {datas[i].remarks}

); totalAmount += datas[i].fee; } content.push( 總計金額: HK$ {FormatUtils.currencyFormat(totalAmount)}

); //setAmount(totalAmount); return content; } function handleRowDoubleClick(params) { navigate('/publicNotice/' + params.id); } function doPayment() { setIsPopUp(false); let totalAmount = 0; let appIdList = []; const datas = rows?.filter((row) => selectedRowItems.includes(row.id) ); for (var i = 0; i < datas?.length; i++) { totalAmount += datas[i].fee; appIdList.push(datas[i].id); } navigate('/paymentPage', { state: { amount: totalAmount, appIdList: appIdList } }); } return ( <>
{ setSelectedRowItems(newSelection); }} onRowDoubleClick={handleRowDoubleClick} getRowHeight={() => 'auto'} />
setIsPopUp(false)} > 確認付款 {getWindowContent()}
); }