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.
 
 

136 rivejä
4.4 KiB

  1. // material-ui
  2. import * as React from 'react';
  3. import {FiDataGrid} from "components/FiDataGrid";
  4. import {
  5. Button,
  6. Typography, useMediaQuery
  7. } from '@mui/material';
  8. import * as DateUtils from "utils/DateUtils"
  9. import {useNavigate} from "react-router-dom";
  10. import {
  11. isORGLoggedIn,
  12. } from "utils/Utils";
  13. import {useTheme} from "@emotion/react";
  14. import {getStatusIntl} from "utils/statusUtils/PublicNoteStatusUtils";
  15. import {FormattedMessage, useIntl} from "react-intl";
  16. // ==============================|| EVENT TABLE ||============================== //
  17. export default function BaseGrid({rows}) {
  18. const navigate = useNavigate()
  19. const theme = useTheme();
  20. const isMdOrLg = useMediaQuery(theme.breakpoints.up('md'));
  21. const intl = useIntl();
  22. const handleDetailClick = (params) => () => {
  23. navigate('/publicNotice/'+ params.id);
  24. };
  25. // const remarkHeadername = rows.orgId===null?"我的備註":"Care Of / 我的備註"
  26. const columns = [
  27. {
  28. id: 'appNo',
  29. field: 'appNo',
  30. headerName: intl.formatMessage({id: 'applicationId'}),
  31. width: isMdOrLg ? 'auto' : 160,
  32. flex: isMdOrLg ? 1 : undefined,
  33. },
  34. {
  35. id: 'created',
  36. field: 'created',
  37. headerName: intl.formatMessage({id: 'submitDate'}),
  38. width: isMdOrLg ? 'auto' : 300,
  39. flex: isMdOrLg ? 1 : undefined,
  40. valueGetter:(params)=>{
  41. return DateUtils.datetimeStr(params?.value);
  42. }
  43. },
  44. // {
  45. // id: 'contactPerson',
  46. // field: 'contactPerson',
  47. // headerName: '聯絡人',
  48. // flex: 2,
  49. // renderCell: (params) => {
  50. // let phone = JSON.parse(params.row.contactTelNo);
  51. // let faxNo = JSON.parse(params.row.contactFaxNo);
  52. // let contact = "";
  53. // if (phone) {
  54. // contact = "電話: " + phone?.countryCode + " " + phone?.phoneNumber
  55. // }
  56. // if (faxNo && faxNo?.faxNumber) {
  57. // if (contact != "")
  58. // contact = contact + ", "
  59. // contact = contact + "傳真:" + faxNo?.countryCode + " " + faxNo?.faxNumber
  60. // }
  61. // return (<>
  62. // {params?.value}<br />
  63. // {contact}
  64. // </>);
  65. // }
  66. // },
  67. {
  68. id: 'remarks',
  69. field: 'remarks',
  70. headerName: isORGLoggedIn()? intl.formatMessage({id: 'gazetteCount2_1'}) : intl.formatMessage({id: 'myRemarks'}),
  71. width: isMdOrLg ? 'auto' : 400,
  72. flex: isMdOrLg ? 3 : undefined,
  73. renderCell: (params) => (
  74. isORGLoggedIn()?
  75. <div>
  76. <Typography>Care Of: {params.row.careOf}</Typography>
  77. <Typography>
  78. <FormattedMessage id="myRemarks"/>: {params.row.remarks}
  79. </Typography>
  80. </div>:
  81. <div>
  82. <Typography>{params.row.remarks}</Typography>
  83. </div>
  84. )
  85. },
  86. {
  87. id: 'status',
  88. field: 'status',
  89. headerName: intl.formatMessage({id: 'status'}),
  90. width: isMdOrLg ? 'auto' : 160,
  91. flex: isMdOrLg ? 1 : undefined,
  92. renderCell: (params) => {
  93. return [getStatusIntl(params,intl)]
  94. },
  95. },
  96. {
  97. field: 'actions',
  98. headerName: '',
  99. width: 160,
  100. cellClassName: 'actions',
  101. renderCell: (params) => {
  102. return <Button onClick={handleDetailClick(params)}>
  103. <FormattedMessage id="viewDetail"/>
  104. </Button>;
  105. },
  106. }
  107. ];
  108. function handleRowDoubleClick(params) {
  109. navigate('/publicNotice/'+ params.id);
  110. }
  111. return (
  112. <div style={{minHeight: 400, width: '100%', padding: 4}}>
  113. <FiDataGrid
  114. rows={rows}
  115. columns={columns}
  116. initialState={{
  117. pagination: {
  118. paginationModel: {page: 0, pageSize: 10},
  119. },
  120. }}
  121. onRowDoubleClick={handleRowDoubleClick}
  122. getRowHeight={() => 'auto'}
  123. />
  124. </div>
  125. );
  126. }