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.
 
 

94 regels
2.6 KiB

  1. // material-ui
  2. import * as React from 'react';
  3. import {
  4. DataGrid,
  5. } from "@mui/x-data-grid";
  6. import {
  7. Button
  8. } from '@mui/material';
  9. import * as DateUtils from "utils/DateUtils"
  10. // import * as StatusUtils from "./PublicNoteStatusUtils";
  11. // ==============================|| EVENT TABLE ||============================== //
  12. export default function BaseGrid({rows}) {
  13. const [rowModesModel] = React.useState({});
  14. const columns = [
  15. {
  16. id: 'appNo',
  17. field: 'appNo',
  18. headerName: '申請編號',
  19. flex: 1,
  20. },
  21. {
  22. id: 'created',
  23. field: 'created',
  24. headerName: '提交日期',
  25. flex: 1,
  26. valueGetter:(params)=>{
  27. return DateUtils.datetimeStr(params?.value);
  28. }
  29. },
  30. {
  31. id: 'contactPerson',
  32. field: 'contactPerson',
  33. headerName: '聯絡人',
  34. flex: 2,
  35. renderCell: (params) => {
  36. let phone = JSON.parse(params.row.contactTelNo);
  37. let faxNo = JSON.parse(params.row.contactFaxNo);
  38. let contact = "";
  39. if (phone) {
  40. contact = "電話: " + phone?.countryCode + " " + phone?.phoneNumber
  41. }
  42. if (faxNo) {
  43. if (contact != "")
  44. contact = contact + ", "
  45. contact = contact + "傳真:" + faxNo?.countryCode + " " + faxNo?.faxNumber
  46. }
  47. return (<>
  48. {params?.value}<br />
  49. {contact}
  50. </>);
  51. }
  52. },
  53. {
  54. id: 'remarks',
  55. field: 'remarks',
  56. headerName: '我的備註',
  57. flex: 3,
  58. },
  59. {
  60. field: 'actions',
  61. type: 'actions',
  62. headerName: '',
  63. width: 50,
  64. cellClassName: 'actions',
  65. renderCell: () => {
  66. return <Button onClick={()=>{}}>查看詳細</Button>;
  67. },
  68. }
  69. ];
  70. return (
  71. <div style={{height: 400, width: '100%'}}>
  72. <DataGrid
  73. rows={rows}
  74. columns={columns}
  75. editMode="row"
  76. rowModesModel={rowModesModel}
  77. initialState={{
  78. pagination: {
  79. paginationModel: {page: 0, pageSize: 5},
  80. },
  81. }}
  82. pageSizeOptions={[5, 10]}
  83. autoHeight = {true}
  84. />
  85. </div>
  86. );
  87. }