Yansen 2 jaren geleden
bovenliggende
commit
b438b8a87c

+ 0
- 60
src/pages/answerRecord/fieldEvaluation/index.jsx Bestand weergeven

@@ -1,60 +0,0 @@
1
-import React from 'react';
2
-import Page from '@/components/Page';
3
-import { useNavigate } from 'react-router-dom';
4
-import { queryTable } from "@/utils/request";
5
-import { ProTable } from "@ant-design/pro-components";
6
-import { Button } from "antd";
7
-
8
-export default (props) => {
9
-
10
-  const columns = [
11
-    {
12
-      title: "模拟测评名称",
13
-      dataIndex: "title",
14
-    },
15
-    {
16
-      title: "小区",
17
-    },
18
-    {
19
-      title: "点位名称",
20
-      dataIndex: "startDate",
21
-    },
22
-    {
23
-      title: "题干",
24
-      dataIndex: "endDate",
25
-    },
26
-    {
27
-      title: "答案",
28
-      dataIndex: "status",
29
-    },
30
-    {
31
-      title: "答题时间",
32
-      dataIndex: "status",
33
-    },
34
-    {
35
-      title: "答题人",
36
-      dataIndex: "status",
37
-    },
38
-    {
39
-      title: "详情",
40
-      dataIndex: "status",
41
-    }
42
-  ]
43
-
44
-  return (
45
-    <Page>
46
-      <ProTable
47
-        search={false}
48
-        columns={columns}
49
-        toolBarRender={() => [
50
-          <Button
51
-            key="1"
52
-            type="primary"
53
-          >
54
-            导出
55
-          </Button>,
56
-        ]}
57
-      />
58
-    </Page>
59
-  )
60
-}

+ 0
- 61
src/pages/answerRecord/quesInvestigation/index.jsx Bestand weergeven

@@ -1,61 +0,0 @@
1
-import React from 'react';
2
-import Page from '@/components/Page';
3
-import { useNavigate } from 'react-router-dom';
4
-import { queryTable } from "@/utils/request";
5
-import { ProTable } from "@ant-design/pro-components";
6
-import { Button } from "antd";
7
-
8
-export default (props) => {
9
-
10
-  const columns = [
11
-    {
12
-      title: "模拟测评名称",
13
-      dataIndex: "title",
14
-    },
15
-    {
16
-      title: "小区",
17
-    },
18
-    {
19
-      title: "题干",
20
-      dataIndex: "startDate",
21
-    },
22
-    {
23
-      title: "答案",
24
-      dataIndex: "status",
25
-    },
26
-
27
-    {
28
-      title: "答题人",
29
-      dataIndex: "status",
30
-    },
31
-    {
32
-      title: "答题时间",
33
-      dataIndex: "status",
34
-    },
35
-    {
36
-      title: "受访者性别",
37
-      dataIndex: "status",
38
-    },
39
-    {
40
-      title: "年龄段",
41
-      dataIndex: "status",
42
-    }
43
-  ]
44
-
45
-  return (
46
-    <Page>
47
-      <ProTable
48
-        search={false}
49
-        columns={columns}
50
-        toolBarRender={() => [
51
-          <Button
52
-            key="1"
53
-            type="primary"
54
-          >
55
-            导出
56
-          </Button>,
57
-        ]}
58
-      />
59
-    </Page>
60
-  )
61
-}

+ 106
- 0
src/pages/checkAnswer/loc/index.jsx Bestand weergeven

@@ -0,0 +1,106 @@
1
+import React from 'react';
2
+import { Button, notification } from "antd";
3
+import { ProTable } from "@ant-design/pro-components";
4
+import { useNavigate } from 'react-router-dom';
5
+import { queryTable, queryDict } from "@/utils/request";
6
+import Page from '@/components/Page';
7
+import { getTaCheck } from '@/service/tacheck';
8
+import { getTdLocType } from '@/service/tdloctype';
9
+import { getTaCheckAnswer, exportTaCheckAnswer } from '@/service/tacheckanswer';
10
+import useBool from '@/utils/hooks/useBool';
11
+
12
+const getCheck = queryDict(getTaCheck, { labelKey: 'title', valueKey: 'checkId' });
13
+const getLocType = queryDict(getTdLocType, { labelKey: 'name', valueKey: 'typeId' });
14
+const getAnswer = queryTable(getTaCheckAnswer);
15
+
16
+export default (props) => {
17
+
18
+  const [loading, startLoading, stopLoading] = useBool();
19
+  const paramsRef = React.useRef();
20
+  const [notificationApi, contextHolder] = notification.useNotification();
21
+
22
+  const columns = [
23
+    {
24
+      title: "模拟测评",
25
+      dataIndex: "checkId",
26
+      valueType: 'select',
27
+      request: getCheck,
28
+      hideInTable: true,
29
+      formItemProps: {
30
+        rules: [
31
+          { required: true, message: '请选择模拟测评' }
32
+        ]
33
+      }
34
+    },
35
+    {
36
+      title: "点位名称",
37
+      valueType: 'select',
38
+      request: getLocType,
39
+      dataIndex: "typeId",
40
+    },
41
+    {
42
+      title: "问题",
43
+      dataIndex: "quTitle",
44
+      hideInSearch: true,
45
+    },
46
+    {
47
+      title: "答案",
48
+      dataIndex: "answer",
49
+      hideInSearch: true,
50
+    },
51
+    {
52
+      title: "答题时间",
53
+      dataIndex: "createDate",
54
+      valueType: 'date',
55
+      hideInSearch: true,
56
+    },
57
+    {
58
+      title: "答题人",
59
+      dataIndex: "userName",
60
+      hideInSearch: true,
61
+    },
62
+  ]
63
+
64
+  const beforeSearchSubmit = (params) => {
65
+    paramsRef.current = params;
66
+    return params;
67
+  }
68
+
69
+  const onExport = () => {
70
+    if (!paramsRef.current) {
71
+      notificationApi.warning({ message: '请先进行条件查询' });
72
+      return
73
+    }
74
+
75
+    startLoading();
76
+    exportTaCheckAnswer(paramsRef.current).then(() => {
77
+      stopLoading();
78
+    }).catch(() => {
79
+      stopLoading();
80
+    });
81
+  }
82
+
83
+  return (
84
+    <Page>
85
+      {contextHolder}
86
+      <ProTable
87
+        rowKey="answerItemId"
88
+        manualRequest
89
+        columns={columns}
90
+        request={getAnswer}
91
+        beforeSearchSubmit={beforeSearchSubmit}
92
+        form={{ ignoreRules: false }}
93
+        toolBarRender={() => [
94
+          <Button
95
+            key="1"
96
+            type="primary"
97
+            loading={loading}
98
+            onClick={onExport}
99
+          >
100
+            导出
101
+          </Button>,
102
+        ]}
103
+      />
104
+    </Page>
105
+  )
106
+}

+ 121
- 0
src/pages/checkAnswer/survey/index.jsx Bestand weergeven

@@ -0,0 +1,121 @@
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, exportTaCheckAnswer } from '@/service/tacheckanswer';
9
+import useBool from '@/utils/hooks/useBool';
10
+
11
+const getCheck = queryDict(getTaCheck, { labelKey: 'title', valueKey: 'checkId' });
12
+const getAnswer = queryTable(getTaCheckAnswer);
13
+
14
+const addOnParams = { itemType: 'survey' };
15
+
16
+export default (props) => {
17
+  const [loading, startLoading, stopLoading] = useBool();
18
+  const paramsRef = React.useRef();
19
+  const [notificationApi, contextHolder] = notification.useNotification();
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: "communityName",
37
+    },
38
+    {
39
+      title: "小区",
40
+      dataIndex: "addr",
41
+    },
42
+    {
43
+      title: "问题",
44
+      dataIndex: "quTitle",
45
+      hideInSearch: true,
46
+    },
47
+    {
48
+      title: "答案",
49
+      dataIndex: "answer",
50
+      hideInSearch: true,
51
+    },
52
+    {
53
+      title: "答题时间",
54
+      dataIndex: "createDate",
55
+      valueType: 'date',
56
+      hideInSearch: true,
57
+    },
58
+    {
59
+      title: "答题人",
60
+      dataIndex: "userName",
61
+      hideInSearch: true,
62
+    },
63
+    {
64
+      title: "受访者性别",
65
+      dataIndex: "sex",
66
+      hideInSearch: true,
67
+    },
68
+    {
69
+      title: "年龄段",
70
+      dataIndex: "age",
71
+      hideInSearch: true,
72
+    }
73
+  ]
74
+  
75
+  const beforeSearchSubmit = (params) => {
76
+    paramsRef.current = params;
77
+    return params;
78
+  }
79
+
80
+  const onExport = () => {
81
+    if (!paramsRef.current) {
82
+      notificationApi.warning({ message: '请先进行条件查询' });
83
+      return
84
+    }
85
+
86
+    startLoading();
87
+    exportTaCheckAnswer({
88
+      ...paramsRef.current,
89
+      ...addOnParams,
90
+    }).then(() => {
91
+      stopLoading();
92
+    }).catch(() => {
93
+      stopLoading();
94
+    });
95
+  }
96
+
97
+  return (
98
+    <Page>
99
+      {contextHolder}
100
+      <ProTable
101
+        rowKey="answerItemId"
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
+}

+ 7
- 7
src/routes/routes.jsx Bestand weergeven

@@ -40,8 +40,8 @@ import Notice from "@/pages/notice";
40 40
 
41 41
 import CheckStandList from "@/pages/checkStand/list";
42 42
 import CheckStandEdit from "@/pages/checkStand/edit";
43
-import FieldEvaluation from "@/pages/answerRecord/fieldEvaluation";
44
-import QuesInvestigation from "@/pages/answerRecord/QuesInvestigation";
43
+import CheckLocAnswer from "@/pages/checkAnswer/loc";
44
+import CheckSurveyAnswer from "@/pages/checkAnswer/survey";
45 45
 
46 46
 /**
47 47
  * meta 用来扩展自定义数据数据
@@ -114,7 +114,7 @@ export const authRoutes = [
114 114
         },
115 115
       },
116 116
       {
117
-        path: "answerRecord",
117
+        path: "checkAnswer",
118 118
         element: <Outlet />,
119 119
         meta: {
120 120
           title: "答题记录",
@@ -122,16 +122,16 @@ export const authRoutes = [
122 122
         },
123 123
         children: [
124 124
           {
125
-            path: "answerRecord/fieldEvaluation",
126
-            element: <FieldEvaluation />,
125
+            path: "loc",
126
+            element: <CheckLocAnswer />,
127 127
             meta: {
128 128
               title: "实地测评",
129 129
               icon: <HddOutlined />,
130 130
             },
131 131
           },
132 132
           {
133
-            path: "answerRecord/quesInvestigation",
134
-            element: <QuesInvestigation />,
133
+            path: "survey",
134
+            element: <CheckSurveyAnswer />,
135 135
             meta: {
136 136
               title: "问卷调查",
137 137
               icon: <HddOutlined />,

+ 5
- 0
src/service/tacheckanswer.js Bestand weergeven

@@ -24,3 +24,8 @@ export const putTaCheckAnswer = (id, data) => request(`/api/taCheckAnswer/${id}`
24 24
  * 通过主键删除数据
25 25
  */
26 26
 export const deleteTaCheckAnswer = (id) => request(`/api/taCheckAnswer/${id}`, { method: 'delete' });
27
+
28
+/*
29
+ * 分页查询
30
+ */
31
+export const exportTaCheckAnswer = (params) => request('/api/taCheckAnswer/export', { params, download: true });

+ 20
- 0
src/utils/hooks/useRequest.js Bestand weergeven

@@ -0,0 +1,20 @@
1
+import React from "react";
2
+
3
+export default (fn) => {
4
+  const [loading, setLoading] = React.useState(false);
5
+
6
+  const p = React.useCallback((...args) => {
7
+    return new Promise((resolve, reject) => {
8
+      setLoading(true);
9
+      fn(...args).then((res) => {
10
+        setLoading(false);
11
+        resolve(res);
12
+      }).catch((err) => {
13
+        setLoading(false);
14
+        reject(err)
15
+      })
16
+    })
17
+  }, []);
18
+
19
+  return [p, loading];
20
+}