index.jsx 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. import React from 'react';
  2. import { Button, Badge } from 'antd';
  3. import { useNavigate } from 'react-router-dom';
  4. import List from '@/components/Page/List';
  5. import { getTaIssue } from '@/service/taissue';
  6. import { getTdLocType } from '@/service/tdloctype';
  7. import { getSysOrg } from '@/service/sysorg';
  8. import { queryDict } from '@/utils/request';
  9. import { processEnum, processStatus } from '@/utils/biz';
  10. import { exportTaIssue } from '@/service/taissue';
  11. import useBool from '@/utils/hooks/useBool';
  12. const queryOrg = queryDict(getSysOrg, { labelKey: 'name', valueKey: 'orgId' });
  13. const queryLocType = queryDict(getTdLocType, { labelKey: 'name', valueKey: 'typeId' });
  14. const today = (new Date()).toJSON().substring(0, 10);
  15. export default (props) => {
  16. const [loading, startLoading, stopLoading] = useBool();
  17. const navigate = useNavigate();
  18. const paramsRef = React.useRef();
  19. const columns = [
  20. {
  21. title: "上报日期",
  22. dataIndex: "createDate",
  23. valueType: 'date',
  24. hideInSearch: true,
  25. },
  26. {
  27. title: "点位",
  28. dataIndex: "locId",
  29. valueType: 'select',
  30. request: queryLocType,
  31. },
  32. {
  33. title: "位置",
  34. dataIndex: "addr",
  35. hideInSearch: true,
  36. },
  37. {
  38. title: "问题详情",
  39. dataIndex: "content",
  40. hideInSearch: true,
  41. ellipsis: true,
  42. },
  43. {
  44. title: "责任单位",
  45. dataIndex: "orgId",
  46. valueType: 'select',
  47. request: queryOrg,
  48. },
  49. {
  50. title: "流程状态",
  51. dataIndex: "bizStatus",
  52. valueType: 'select',
  53. valueEnum: processEnum,
  54. render: (_, row) => {
  55. if (row.processNode != '03' && today >= row.expireDate) {
  56. return <Badge status="error" text="已逾期" />;
  57. } else {
  58. const st = processStatus.filter(x => x.value == row.processNode)[0];
  59. return <Badge status={st?.badge} text={st?.label} />;
  60. }
  61. }
  62. },
  63. {
  64. title: "截止日期",
  65. dataIndex: "expireDate",
  66. hideInSearch: true,
  67. }
  68. ];
  69. const onExport = () => {
  70. startLoading();
  71. exportTaIssue(paramsRef.current).then(() => {
  72. stopLoading();
  73. }).catch(() => {
  74. stopLoading();
  75. });
  76. }
  77. const beforeSearchSubmit = (params) => {
  78. paramsRef.current = params;
  79. return params;
  80. }
  81. return (
  82. <List
  83. rowKey="issueId"
  84. request={getTaIssue}
  85. columns={columns}
  86. beforeSearchSubmit={beforeSearchSubmit}
  87. optionRender={(_, row) => [
  88. <Button key="detail" type="link" onClick={() => navigate(`/issue/detail?id=${row.issueId}`)}>详情</Button>
  89. ]}
  90. toolBarRender={() => [
  91. (
  92. <Button
  93. key="1"
  94. type="primary"
  95. loading={loading}
  96. onClick={onExport}
  97. >
  98. 导出
  99. </Button>
  100. )
  101. ]}
  102. />
  103. )
  104. }