index.jsx 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import React from 'react';
  2. import Page from '@/components/Page';
  3. import { useNavigate } from 'react-router-dom';
  4. import { queryTable, queryDict } from "@/utils/request";
  5. import { ProTable } from "@ant-design/pro-components";
  6. import { Button, notification } from "antd";
  7. import { getTaCheck } from '@/service/tacheck';
  8. import { getTaCheckAnswer } from '@/service/tacheckanswer';
  9. import useBool from '@/utils/hooks/useBool';
  10. const getCheck = queryDict(getTaCheck, { labelKey: 'title', valueKey: 'checkId' });
  11. const getAnswer = queryTable(getTaCheckAnswer);
  12. const addOnParams = { itemType: 'survey' };
  13. export default (props) => {
  14. const [loading, startLoading, stopLoading] = useBool();
  15. const paramsRef = React.useRef();
  16. const [notificationApi, contextHolder] = notification.useNotification();
  17. const navigate = useNavigate();
  18. const goToDetail = (row) => {
  19. navigate(`/checkAnswer/survey/detail?answerId=${row.answerId}&itemType=survey`)
  20. }
  21. const columns = [
  22. {
  23. title: "模拟测评",
  24. dataIndex: "checkId",
  25. valueType: 'select',
  26. request: getCheck,
  27. hideInTable: true,
  28. formItemProps: {
  29. rules: [
  30. { required: true, message: '请选择模拟测评' }
  31. ]
  32. }
  33. },
  34. {
  35. title: "答题时间",
  36. dataIndex: "createDate",
  37. valueType: 'date',
  38. hideInSearch: true,
  39. },
  40. {
  41. title: "社区",
  42. dataIndex: "communityName",
  43. },
  44. {
  45. title: "小区",
  46. dataIndex: "addr",
  47. },
  48. {
  49. title: "答题人",
  50. dataIndex: "userName",
  51. },
  52. {
  53. title: "受访者性别",
  54. dataIndex: "sex",
  55. hideInSearch: true,
  56. },
  57. {
  58. title: "年龄段",
  59. dataIndex: "age",
  60. hideInSearch: true,
  61. },
  62. {
  63. title: "得分",
  64. dataIndex: "score",
  65. hideInSearch: true,
  66. },
  67. {
  68. title: '操作',
  69. hideInSearch: true,
  70. key: 'options',
  71. render: (_, row) => {
  72. return (
  73. <Button type="link" onClick={() => goToDetail(row)}>详情</Button>
  74. )
  75. }
  76. }
  77. ]
  78. const beforeSearchSubmit = (params) => {
  79. paramsRef.current = params;
  80. return params;
  81. }
  82. const onExport = () => {
  83. // if (!paramsRef.current) {
  84. // notificationApi.warning({ message: '请先进行条件查询' });
  85. // return
  86. // }
  87. // startLoading();
  88. // exportTaCheckAnswer({
  89. // ...paramsRef.current,
  90. // ...addOnParams,
  91. // }).then(() => {
  92. // stopLoading();
  93. // }).catch(() => {
  94. // stopLoading();
  95. // });
  96. }
  97. return (
  98. <Page>
  99. {contextHolder}
  100. <ProTable
  101. rowKey="answerId"
  102. manualRequest
  103. columns={columns}
  104. request={getAnswer}
  105. params={addOnParams}
  106. beforeSearchSubmit={beforeSearchSubmit}
  107. form={{ ignoreRules: false }}
  108. // toolBarRender={() => [
  109. // <Button
  110. // key="1"
  111. // type="primary"
  112. // loading={loading}
  113. // onClick={onExport}
  114. // >
  115. // 导出
  116. // </Button>,
  117. // ]}
  118. />
  119. </Page>
  120. )
  121. }