Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

142 righe
4.5 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. // ==============================|| EVENT TABLE ||============================== //
  15. export default function SubmittedTab({ rows }) {
  16. const [selectedRowItems, setSelectedRowItems] = React.useState([]);
  17. const [isPopUp, setIsPopUp] = React.useState(false);
  18. const columns = [
  19. {
  20. id: 'appNo',
  21. field: 'appNo',
  22. headerName: '申請編號',
  23. flex: 1,
  24. },
  25. {
  26. id: 'created',
  27. field: 'created',
  28. headerName: '提交日期',
  29. flex: 1,
  30. valueGetter: (params) => {
  31. return DateUtils.datetimeStr(params.value);
  32. }
  33. },
  34. {
  35. id: 'contactPerson',
  36. field: 'contactPerson',
  37. headerName: '聯絡人',
  38. flex: 2,
  39. renderCell: (params) => {
  40. let phone = JSON.parse(params.row.contactTelNo);
  41. let faxNo = JSON.parse(params.row.contactFaxNo);
  42. let contact = "";
  43. if (phone) {
  44. contact = "電話: " + phone?.countryCode + " " + phone?.phoneNumber
  45. }
  46. if (faxNo) {
  47. if (contact != "")
  48. contact = contact + ", "
  49. contact = contact + "傳真:" + faxNo?.countryCode + " " + faxNo?.faxNumber
  50. }
  51. return (<>
  52. {params?.value}<br />
  53. {contact}
  54. </>);
  55. }
  56. },
  57. {
  58. id: 'remarks',
  59. field: 'remarks',
  60. headerName: '我的備註',
  61. flex: 3,
  62. },
  63. {
  64. field: 'actions',
  65. type: 'actions',
  66. headerName: '',
  67. width: 50,
  68. cellClassName: 'actions',
  69. renderCell: () => {
  70. return <Button onClick={() => { }}>查看詳細</Button>;
  71. },
  72. }
  73. ];
  74. const getWindowContent = () => {
  75. var content = [];
  76. const datas = rows?.filter((row) =>
  77. selectedRowItems.includes(row.id)
  78. );
  79. for (var i = 0; i < datas?.length; i++) {
  80. content.push(<>
  81. <Stack direction="row" justifyContent="space-between"><Typography variant="h5">申請編號: {datas[i].appNo}</Typography>({DateUtils.datetimeStr(datas[i].created)})</Stack>
  82. 備註: {datas[i].remarks}
  83. <br /><br />
  84. </>);
  85. }
  86. return content;
  87. }
  88. return (
  89. <>
  90. <div style={{ height: 400, width: '100%' }}>
  91. <DataGrid
  92. checkboxSelection
  93. disableRowSelectionOnClick
  94. rows={rows}
  95. columns={columns}
  96. editMode="row"
  97. rowSelectionModel={selectedRowItems}
  98. initialState={{
  99. pagination: {
  100. paginationModel: { page: 0, pageSize: 5 },
  101. },
  102. }}
  103. pageSizeOptions={[5, 10]}
  104. autoHeight={true}
  105. onRowSelectionModelChange={(newSelection) => {
  106. setSelectedRowItems(newSelection);
  107. }}
  108. />
  109. <Button variant="contained" onClick={() => { setIsPopUp(true) }}>付款</Button>
  110. </div>
  111. <div>
  112. <Dialog open={isPopUp} onClose={() => setIsPopUp(false)} >
  113. <DialogTitle></DialogTitle>
  114. <Typography variant="h2" style={{ padding: '16px' }}>確認付款</Typography>
  115. <DialogContent style={{ display: 'flex', }}>
  116. <Stack direction="column" justifyContent="space-between">
  117. {getWindowContent()}
  118. </Stack>
  119. </DialogContent>
  120. <DialogActions>
  121. <Button onClick={() => setIsPopUp(false)}>Close</Button>
  122. <Button onClick={() => setIsPopUp(false)}>確認</Button>
  123. </DialogActions>
  124. </Dialog>
  125. </div>
  126. </>
  127. );
  128. }