Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

189 строки
6.2 KiB

  1. // material-ui
  2. import * as React from 'react';
  3. import {
  4. Stack,
  5. Typography,
  6. Button,
  7. Dialog, DialogTitle, DialogContent, DialogActions
  8. } from '@mui/material';
  9. import { FiDataGrid } from "components/FiDataGrid";
  10. import * as DateUtils from "utils/DateUtils"
  11. import * as FormatUtils from "utils/FormatUtils"
  12. import * as StatusUtils from "utils/statusUtils/PublicNoteStatusUtils";
  13. import { useNavigate } from "react-router-dom";
  14. // ==============================|| EVENT TABLE ||============================== //
  15. export default function SubmittedTab({ rows }) {
  16. const [selectedRowItems, setSelectedRowItems] = React.useState([]);
  17. const [isPopUp, setIsPopUp] = React.useState(false);
  18. //const [amount, setAmount] = React.useState(0);
  19. const navigate = useNavigate()
  20. const handleDetailClick = (params) => () => {
  21. navigate('/publicNotice/' + params.id);
  22. };
  23. const columns = [
  24. {
  25. id: 'appNo',
  26. field: 'appNo',
  27. headerName: '申請編號',
  28. flex: 1,
  29. },
  30. {
  31. id: 'created',
  32. field: 'created',
  33. headerName: '提交日期',
  34. flex: 1,
  35. valueGetter: (params) => {
  36. return DateUtils.datetimeStr(params.value);
  37. }
  38. },
  39. // {
  40. // id: 'contactPerson',
  41. // field: 'contactPerson',
  42. // headerName: '聯絡人',
  43. // flex: 2,
  44. // renderCell: (params) => {
  45. // let phone = JSON.parse(params.row.contactTelNo);
  46. // let faxNo = JSON.parse(params.row.contactFaxNo);
  47. // let contact = "";
  48. // if (phone) {
  49. // contact = "電話: " + phone?.countryCode + " " + phone?.phoneNumber
  50. // }
  51. // if (faxNo && faxNo?.faxNumber) {
  52. // if (contact != "")
  53. // contact = contact + ", "
  54. // contact = contact + "傳真:" + faxNo?.countryCode + " " + faxNo?.faxNumber
  55. // }
  56. // return (<>
  57. // {params?.value}<br />
  58. // {contact}
  59. // </>);
  60. // }
  61. // },
  62. {
  63. id: 'remarks',
  64. field: 'remarks',
  65. headerName: '我的備註',
  66. flex: 3,
  67. },
  68. {
  69. id: 'fee',
  70. field: 'fee',
  71. headerName: '價錢',
  72. flex: 1,
  73. renderCell: (params) => {
  74. return FormatUtils.currencyFormat(params.row.fee)
  75. },
  76. },
  77. {
  78. id: 'status',
  79. field: 'status',
  80. headerName: '狀態',
  81. flex: 1,
  82. renderCell: (params) => {
  83. return [StatusUtils.getStatus(params)]
  84. },
  85. },
  86. {
  87. field: 'actions',
  88. type: 'actions',
  89. headerName: '',
  90. width: 120,
  91. cellClassName: 'actions',
  92. renderCell: (params) => {
  93. return <Button onClick={handleDetailClick(params)}>查看詳細</Button>;
  94. },
  95. }
  96. ];
  97. const getWindowContent = () => {
  98. var content = [];
  99. let totalAmount = 0;
  100. const datas = rows?.filter((row) =>
  101. selectedRowItems.includes(row.id)
  102. );
  103. for (var i = 0; i < datas?.length; i++) {
  104. content.push(<>
  105. <Stack direction="row" justifyContent="space-between"><Typography variant="h5">申請編號: {datas[i].appNo}</Typography>({DateUtils.datetimeStr(datas[i].created)})</Stack>
  106. 備註: {datas[i].remarks}
  107. <br /><br />
  108. </>);
  109. totalAmount += datas[i].fee;
  110. }
  111. content.push(<Typography variant="h5">
  112. 總計金額: HK$ {FormatUtils.currencyFormat(totalAmount)} <br /><br />
  113. </Typography>);
  114. //setAmount(totalAmount);
  115. return content;
  116. }
  117. function handleRowDoubleClick(params) {
  118. navigate('/publicNotice/' + params.id);
  119. }
  120. function doPayment() {
  121. setIsPopUp(false);
  122. let totalAmount = 0;
  123. let appIdList = [];
  124. const datas = rows?.filter((row) =>
  125. selectedRowItems.includes(row.id)
  126. );
  127. for (var i = 0; i < datas?.length; i++) {
  128. totalAmount += datas[i].fee;
  129. appIdList.push(datas[i].id);
  130. }
  131. navigate('/paymentPage', { state: { amount: totalAmount, appIdList: appIdList } });
  132. }
  133. return (
  134. <>
  135. <div style={{ height: 400, width: '100%', padding: 4 }}>
  136. <FiDataGrid
  137. checkboxSelection
  138. disableRowSelectionOnClick
  139. rows={rows}
  140. columns={columns}
  141. initialState={{
  142. pagination: {
  143. paginationModel: { page: 0, pageSize: 5 },
  144. },
  145. }}
  146. onRowSelectionModelChange={(newSelection) => {
  147. setSelectedRowItems(newSelection);
  148. }}
  149. onRowDoubleClick={handleRowDoubleClick}
  150. getRowHeight={() => 'auto'}
  151. />
  152. <br/>
  153. <Button variant="contained" onClick={() => { setIsPopUp(true) }}><Typography variant="h5">付款</Typography></Button>
  154. </div>
  155. <div>
  156. <Dialog open={isPopUp} onClose={() => setIsPopUp(false)} >
  157. <DialogTitle></DialogTitle>
  158. <Typography variant="h2" style={{ padding: '16px' }}>確認付款</Typography>
  159. <DialogContent style={{ display: 'flex', }}>
  160. <Stack direction="column" justifyContent="space-between">
  161. {getWindowContent()}
  162. </Stack>
  163. </DialogContent>
  164. <DialogActions>
  165. <Button onClick={() => setIsPopUp(false)}><Typography variant="h5">Close</Typography></Button>
  166. <Button onClick={() => doPayment()}><Typography variant="h5">確認</Typography></Button>
  167. </DialogActions>
  168. </Dialog>
  169. </div>
  170. </>
  171. );
  172. }