Yansen 2 年之前
父節點
當前提交
62f83c4c95

+ 2
- 1
src/components/SearchSelect/index.jsx 查看文件

11
   return s => {
11
   return s => {
12
     const pageSize = !s ? 10 : 100;
12
     const pageSize = !s ? 10 : 100;
13
     return fn({ pageSize, [searchKey]: s }).then(res => {
13
     return fn({ pageSize, [searchKey]: s }).then(res => {
14
-      return (res.records || []).map(x => ({label: x[labelKey], value: x[valueKey]}));
14
+      return (res.records || []).map(x => ({...x, label: x[labelKey], value: x[valueKey]}));
15
     })
15
     })
16
   }
16
   }
17
 }
17
 }
41
   return (
41
   return (
42
     <Select
42
     <Select
43
       showSearch
43
       showSearch
44
+      allowClear
44
       defaultActiveFirstOption={false}
45
       defaultActiveFirstOption={false}
45
       showArrow={false}
46
       showArrow={false}
46
       filterOption={false}
47
       filterOption={false}

+ 50
- 25
src/pages/check/components/QuForm.jsx 查看文件

9
 import { Form, Row, Col } from 'antd';
9
 import { Form, Row, Col } from 'antd';
10
 import WangEditor from '@/components/Wangeditor';
10
 import WangEditor from '@/components/Wangeditor';
11
 import SearchSelect, { transformQuery } from '@/components/SearchSelect';
11
 import SearchSelect, { transformQuery } from '@/components/SearchSelect';
12
-import { postTaCheckItemQu } from '@/service/tdlocquestion';
12
+import { postTaCheckItemQu } from '@/service/tacheckitemqu';
13
+import { getTdQuestion } from '@/service/tdquestion';
13
 
14
 
15
+const queryQu = transformQuery(getTdQuestion, { searchKey: 'title', labelKey: 'title', valueKey: 'quId' });
14
 
16
 
15
 export default (props) => {
17
 export default (props) => {
16
   const {open, onOpenChange, quInfo, itemId, itemType, onChange} = props;
18
   const {open, onOpenChange, quInfo, itemId, itemType, onChange} = props;
17
   const [form] = Form.useForm();
19
   const [form] = Form.useForm();
18
-  
20
+
19
   const onFinish = async (values) => {
21
   const onFinish = async (values) => {
20
     const data = {
22
     const data = {
21
       ...(quInfo || {}),
23
       ...(quInfo || {}),
29
     return true;
31
     return true;
30
   }
32
   }
31
 
33
 
34
+  const onTplChange = (_, tpl) => {
35
+    if (tpl) {
36
+      form.resetFields();
37
+      form.setFieldsValue({
38
+        quType: tpl.quType,
39
+        title: tpl.title,
40
+        answerList: (tpl.quAnswerList || []).map(x => ({
41
+          answerCode: x.answerCode,
42
+          answer: x.answer,
43
+        })),
44
+      });
45
+    }
46
+  }
47
+
32
   React.useEffect(() => {
48
   React.useEffect(() => {
33
     if (quInfo) {
49
     if (quInfo) {
34
       form.setFieldsValue(quInfo);
50
       form.setFieldsValue(quInfo);
43
       open={open}
59
       open={open}
44
       width={800}
60
       width={800}
45
       form={form}
61
       form={form}
46
-      destroyOnClose
47
       onFinish={onFinish}
62
       onFinish={onFinish}
48
       onOpenChange={onOpenChange}
63
       onOpenChange={onOpenChange}
49
       drawerProps={{
64
       drawerProps={{
65
+        destroyOnClose: true,
50
         extra: (
66
         extra: (
51
           <>
67
           <>
52
           {
68
           {
53
             itemType == 'survey' && (
69
             itemType == 'survey' && (
54
-              <div></div>
70
+              <SearchSelect
71
+                placeholder="请输入题干搜索题库"
72
+                style={{width: '300px'}}
73
+                request={queryQu}
74
+                onChange={onTplChange}
75
+              />
55
             )
76
             )
56
           }
77
           }
57
           </>
78
           </>
156
           />
177
           />
157
         </Col>
178
         </Col>
158
       </Row>
179
       </Row>
159
-      <Form.Item name="stand" label="评分标准">
160
-        <WangEditor
161
-          height="200px"
162
-          toolbarConfig={{
163
-            toolbarKeys: [
164
-              'headerSelect',
165
-              'blockquote',
166
-              '|',
167
-              'bold',
168
-              'underline',
169
-              'italic',
170
-              'color',
171
-              'fontSize',
172
-              '|',
173
-              'bulletedList',
174
-              'numberedList',
175
-            ]
176
-          }}
177
-        />
178
-      </Form.Item>
180
+      {
181
+        itemType == 'loc' && (
182
+          <Form.Item name="stand" label="评分标准">
183
+            <WangEditor
184
+              height="200px"
185
+              toolbarConfig={{
186
+                toolbarKeys: [
187
+                  'headerSelect',
188
+                  'blockquote',
189
+                  '|',
190
+                  'bold',
191
+                  'underline',
192
+                  'italic',
193
+                  'color',
194
+                  'fontSize',
195
+                  '|',
196
+                  'bulletedList',
197
+                  'numberedList',
198
+                ]
199
+              }}
200
+            />
201
+          </Form.Item>
202
+        )
203
+      }
179
       <ProFormList
204
       <ProFormList
180
         name="answerList"
205
         name="answerList"
181
         label="选项列表"
206
         label="选项列表"
182
         copyIconProps={false}
207
         copyIconProps={false}
183
       >
208
       >
184
-        <Row gutter={24} style={{width: '730px'}}>
209
+        <Row gutter={24} style={{ width: '730px' }}>
185
           <Col span={6}>
210
           <Col span={6}>
186
             <ProFormText
211
             <ProFormText
187
               name="answerCode"
212
               name="answerCode"

+ 4
- 5
src/pages/check/components/QuList.jsx 查看文件

1
 import React from 'react';
1
 import React from 'react';
2
 import { Button, Card, Table, Space, Popconfirm } from 'antd';
2
 import { Button, Card, Table, Space, Popconfirm } from 'antd';
3
 import useBool from '@/utils/hooks/useBool';
3
 import useBool from '@/utils/hooks/useBool';
4
-import { getTaCheckItemQu } from '@/service/tdlocquestion';
5
-import { deleteTaCheckItemQu } from '@/service/tacheckitemqu';
4
+import { getTaCheckItemQu, deleteTaCheckItemQu } from '@/service/tacheckitemqu';
6
 import QuForm from './QuForm';
5
 import QuForm from './QuForm';
7
 
6
 
8
 export default (props) => {
7
 export default (props) => {
62
     setCurItem();
61
     setCurItem();
63
     setOpen(true);
62
     setOpen(true);
64
   }
63
   }
65
-  
64
+
66
   const onEdit = (qu) => {
65
   const onEdit = (qu) => {
67
     setCurItem(qu);
66
     setCurItem(qu);
68
     setOpen(true);
67
     setOpen(true);
77
       setList(list.filter(x => x.quId !== qu.quId));
76
       setList(list.filter(x => x.quId !== qu.quId));
78
     }
77
     }
79
   }
78
   }
80
-  
79
+
81
   const onFinish = (res) => {
80
   const onFinish = (res) => {
82
     let found = false;
81
     let found = false;
83
     const newList = list.map(item => {
82
     const newList = list.map(item => {
99
   React.useEffect(() => {
98
   React.useEffect(() => {
100
     if (itemId) {
99
     if (itemId) {
101
       startLoading();
100
       startLoading();
102
-      getTaCheckItemQu({pageSize: 500, itemId}).then((res) => {
101
+      getTaCheckItemQu({ pageSize: 500, itemId }).then((res) => {
103
         stopLoading();
102
         stopLoading();
104
         setList(res.records);
103
         setList(res.records);
105
       }).catch(() => {
104
       }).catch(() => {

+ 5
- 5
src/pages/question/list/index.jsx 查看文件

7
   ProFormList,
7
   ProFormList,
8
   PageContainer
8
   PageContainer
9
 } from '@ant-design/pro-components';
9
 } from '@ant-design/pro-components';
10
-import { postTdLocQuestion, getTdLocQuestion, deleteTdLocQuestion, getTdLocQuestionById } from '@/service/tdlocquestion';
10
+import { postTdQuestion, getTdQuestion, deleteTdQuestion, getTdQuestionById } from '@/service/tdquestion';
11
 
11
 
12
 const QuItem = (props) => {
12
 const QuItem = (props) => {
13
   const { qu, onEdit, onDelete } = props;
13
   const { qu, onEdit, onDelete } = props;
70
 
70
 
71
   const onFinish = async (values) => {
71
   const onFinish = async (values) => {
72
     const data = { ...(quInfo || {}), ...values, itemId };
72
     const data = { ...(quInfo || {}), ...values, itemId };
73
-    const res = await postTdLocQuestion(data).then(x => x);
73
+    const res = await postTdQuestion(data).then(x => x);
74
     let found = false;
74
     let found = false;
75
     const newList = list.map(item => {
75
     const newList = list.map(item => {
76
       if (item.quId === res.quId) {
76
       if (item.quId === res.quId) {
98
 
98
 
99
   const onDeleteQu = (qu) => {
99
   const onDeleteQu = (qu) => {
100
     if (qu?.quId) {
100
     if (qu?.quId) {
101
-      deleteTdLocQuestion(qu.quId).then(() => {
101
+      deleteTdQuestion(qu.quId).then(() => {
102
         setList(list.filter(x => x.quId !== qu.quId));
102
         setList(list.filter(x => x.quId !== qu.quId));
103
       })
103
       })
104
     } else {
104
     } else {
114
 
114
 
115
   // React.useEffect(() => {
115
   // React.useEffect(() => {
116
   //   if (itemId) {
116
   //   if (itemId) {
117
-  //     getTdLocQuestion({ pageSize: 500, itemId }).then((res) => {
117
+  //     getTdQuestion({ pageSize: 500, itemId }).then((res) => {
118
   //       setList(res.records);
118
   //       setList(res.records);
119
   //     });
119
   //     });
120
   //   }
120
   //   }
122
 
122
 
123
   React.useEffect(() => {
123
   React.useEffect(() => {
124
     if (itemId) {
124
     if (itemId) {
125
-      getTdLocQuestionById({ pageSize: 500, itemId }).then((res) => {
125
+      getTdQuestionById({ pageSize: 500, itemId }).then((res) => {
126
         setList(res.records);
126
         setList(res.records);
127
       });
127
       });
128
     }
128
     }

+ 0
- 26
src/service/tdlocquanswer.js 查看文件

1
-import request from '@/utils/request';
2
-
3
-/*
4
- * 分页查询
5
- */
6
-export const getTdLocQuAnswer = (params) => request('/api/tdLocQuAnswer', { params });
7
-
8
-/*
9
- * 新增数据
10
- */
11
-export const postTdLocQuAnswer = (data) => request('/api/tdLocQuAnswer', { data, method: 'post' });
12
-
13
-/*
14
- * 通过ID查询单条数据
15
- */
16
-export const getTdLocQuAnswerById = (id) => request(`/api/tdLocQuAnswer/${id}`);
17
-
18
-/*
19
- * 更新数据
20
- */
21
-export const putTdLocQuAnswer = (id, data) => request(`/api/tdLocQuAnswer/${id}`, { data, method: 'put' });
22
-
23
-/*
24
- * 通过主键删除数据
25
- */
26
-export const deleteTdLocQuAnswer = (id) => request(`/api/tdLocQuAnswer/${id}`, { method: 'delete' });

+ 0
- 51
src/service/tdlocquestion.js 查看文件

1
-import request from '@/utils/request';
2
-
3
-/*
4
- * 分页查询
5
- */
6
-export const getTaCheckItemQu = (params) => request('/api/taCheckItemQu', { params });
7
-
8
-/*
9
- * 新增数据
10
- */
11
-export const postTaCheckItemQu = (data) => request('/api/taCheckItemQu', { data, method: 'post' });
12
-
13
-/*
14
- * 通过ID查询单条数据
15
- */
16
-export const getTaCheckItemQuById = (id) => request(`/api/taCheckItemQu/${id}`);
17
-
18
-/*
19
- * 更新数据
20
- */
21
-export const putTaCheckItemQu = (id, data) => request(`/api/taCheckItemQu/${id}`, { data, method: 'put' });
22
-
23
-/*
24
- * 通过主键删除数据
25
- */
26
-export const deleteTaCheckItemQu = (id) => request(`/api/taCheckItemQu/${id}`, { method: 'delete' });
27
-
28
-/*
29
- * 分页查询
30
- */
31
-export const getTdLocQuestion = (params) => request('/api/tdLocQuestion', { params });
32
-
33
-/*
34
- * 新增数据
35
- */
36
-export const postTdLocQuestion = (data) => request('/api/tdLocQuestion', { data, method: 'post' });
37
-
38
-/*
39
- * 通过ID查询单条数据
40
- */
41
-export const getTdLocQuestionById = (id) => request(`/api/tdLocQuestion/${id}`);
42
-
43
-/*
44
- * 更新数据
45
- */
46
-export const putTdLocQuestion = (id, data) => request(`/api/tdLocQuestion/${id}`, { data, method: 'put' });
47
-
48
-/*
49
- * 通过主键删除数据
50
- */
51
-export const deleteTdLocQuestion = (id) => request(`/api/tdLocQuestion/${id}`, { method: 'delete' });

+ 26
- 0
src/service/tdquanswer.js 查看文件

1
+import request from '@/utils/request';
2
+
3
+/*
4
+ * 分页查询
5
+ */
6
+export const getTdQuAnswer = (params) => request('/api/tdQuAnswer', { params });
7
+
8
+/*
9
+ * 新增数据
10
+ */
11
+export const postTdQuAnswer = (data) => request('/api/tdQuAnswer', { data, method: 'post' });
12
+
13
+/*
14
+ * 通过ID查询单条数据
15
+ */
16
+export const getTdQuAnswerById = (id) => request(`/api/tdQuAnswer/${id}`);
17
+
18
+/*
19
+ * 更新数据
20
+ */
21
+export const putTdQuAnswer = (id, data) => request(`/api/tdQuAnswer/${id}`, { data, method: 'put' });
22
+
23
+/*
24
+ * 通过主键删除数据
25
+ */
26
+export const deleteTdQuAnswer = (id) => request(`/api/tdQuAnswer/${id}`, { method: 'delete' });

+ 26
- 0
src/service/tdquestion.js 查看文件

1
+import request from '@/utils/request';
2
+
3
+/*
4
+ * 分页查询
5
+ */
6
+export const getTdQuestion = (params) => request('/api/tdQuestion', { params });
7
+
8
+/*
9
+ * 新增数据
10
+ */
11
+export const postTdQuestion = (data) => request('/api/tdQuestion', { data, method: 'post' });
12
+
13
+/*
14
+ * 通过ID查询单条数据
15
+ */
16
+export const getTdQuestionById = (id) => request(`/api/tdQuestion/${id}`);
17
+
18
+/*
19
+ * 更新数据
20
+ */
21
+export const putTdQuestion = (id, data) => request(`/api/tdQuestion/${id}`, { data, method: 'put' });
22
+
23
+/*
24
+ * 通过主键删除数据
25
+ */
26
+export const deleteTdQuestion = (id) => request(`/api/tdQuestion/${id}`, { method: 'delete' });