You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

165 lines
5.3 KiB

  1. // material-ui
  2. import * as React from 'react';
  3. import {
  4. DataGrid,
  5. } from "@mui/x-data-grid";
  6. import {
  7. Stack,
  8. Typography,
  9. Button,
  10. Dialog, DialogTitle, DialogContent, DialogActions
  11. } from '@mui/material';
  12. import * as DateUtils from "utils/DateUtils"
  13. import * as StatusUtils from "./PublicNoteStatusUtils";
  14. import {useNavigate} from "react-router-dom";
  15. // ==============================|| EVENT TABLE ||============================== //
  16. export default function SubmittedTab({ rows }) {
  17. const [selectedRowItems, setSelectedRowItems] = React.useState([]);
  18. const [isPopUp, setIsPopUp] = React.useState(false);
  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) {
  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: 'status',
  70. field: 'status',
  71. headerName: '狀態',
  72. flex: 1,
  73. renderCell: (params) => {
  74. return [StatusUtils.getStatus(params)]
  75. },
  76. },
  77. {
  78. field: 'actions',
  79. type: 'actions',
  80. headerName: '',
  81. width: 100,
  82. cellClassName: 'actions',
  83. renderCell: (params) => {
  84. return <Button onClick={handleDetailClick(params)}>查看詳細</Button>;
  85. },
  86. }
  87. ];
  88. const getWindowContent = () => {
  89. var content = [];
  90. const datas = rows?.filter((row) =>
  91. selectedRowItems.includes(row.id)
  92. );
  93. for (var i = 0; i < datas?.length; i++) {
  94. content.push(<>
  95. <Stack direction="row" justifyContent="space-between"><Typography variant="h5">申請編號: {datas[i].appNo}</Typography>({DateUtils.datetimeStr(datas[i].created)})</Stack>
  96. 備註: {datas[i].remarks}
  97. <br /><br />
  98. </>);
  99. }
  100. return content;
  101. }
  102. return (
  103. <>
  104. <div style={{ height: 400, width: '100%', padding: 4 }}>
  105. <DataGrid
  106. checkboxSelection
  107. disableRowSelectionOnClick
  108. rows={rows}
  109. columns={columns}
  110. editMode="row"
  111. rowSelectionModel={selectedRowItems}
  112. initialState={{
  113. pagination: {
  114. paginationModel: { page: 0, pageSize: 5 },
  115. },
  116. }}
  117. pageSizeOptions={[5, 10]}
  118. autoHeight={true}
  119. onRowSelectionModelChange={(newSelection) => {
  120. setSelectedRowItems(newSelection);
  121. }}
  122. sx={{
  123. margin: "4 2 4 2",
  124. boxShadow: 1,
  125. border: 1,
  126. borderColor: '#DDD',
  127. '& .super-app-theme--header': {
  128. backgroundColor: '#EEE',
  129. },
  130. }}
  131. />
  132. <Button variant="contained" onClick={() => { setIsPopUp(true) }}>付款</Button>
  133. </div>
  134. <div>
  135. <Dialog open={isPopUp} onClose={() => setIsPopUp(false)} >
  136. <DialogTitle></DialogTitle>
  137. <Typography variant="h2" style={{ padding: '16px' }}>確認付款</Typography>
  138. <DialogContent style={{ display: 'flex', }}>
  139. <Stack direction="column" justifyContent="space-between">
  140. {getWindowContent()}
  141. </Stack>
  142. </DialogContent>
  143. <DialogActions>
  144. <Button onClick={() => setIsPopUp(false)}>Close</Button>
  145. <Button onClick={() => setIsPopUp(false)}>確認</Button>
  146. </DialogActions>
  147. </Dialog>
  148. </div>
  149. </>
  150. );
  151. }