Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

169 linhas
5.4 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 && 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: '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. boxShadow: 1,
  124. border: 1,
  125. borderColor: '#DDD',
  126. '& .MuiDataGrid-cell': {
  127. border: 1,
  128. borderColor: "#EEE"
  129. },
  130. '& .MuiDataGrid-footerContainer':{
  131. border: 1,
  132. borderColor: "#EEE"
  133. }
  134. }}
  135. />
  136. <Button variant="contained" onClick={() => { setIsPopUp(true) }}>付款</Button>
  137. </div>
  138. <div>
  139. <Dialog open={isPopUp} onClose={() => setIsPopUp(false)} >
  140. <DialogTitle></DialogTitle>
  141. <Typography variant="h2" style={{ padding: '16px' }}>確認付款</Typography>
  142. <DialogContent style={{ display: 'flex', }}>
  143. <Stack direction="column" justifyContent="space-between">
  144. {getWindowContent()}
  145. </Stack>
  146. </DialogContent>
  147. <DialogActions>
  148. <Button onClick={() => setIsPopUp(false)}>Close</Button>
  149. <Button onClick={() => setIsPopUp(false)}>確認</Button>
  150. </DialogActions>
  151. </Dialog>
  152. </div>
  153. </>
  154. );
  155. }