张延森 vor 4 Jahren
Ursprung
Commit
67caf8b81b

+ 144
- 96
src/components/TestQuestions/index.jsx Datei anzeigen

@@ -1,32 +1,63 @@
1
-import React, { useState } from 'react';
2
-import { Button, Row, Col, Checkbox, Radio, Input, Space } from 'antd';
3
-import WangEditor from '@/components/WangEditor';
1
+import React, { useEffect, useState } from 'react';
2
+import { Button, Row, Col, Checkbox, Radio, Input, Space, notification } from 'antd';
3
+// import WangEditor from '@/components/WangEditor';
4
+
5
+const RedRequire = () => <i style={{ color: 'red' }}>*</i>
6
+
7
+const defaultData = {
8
+  title: undefined,
9
+  question: undefined,
10
+  answerType: 'radio',
11
+  correctAnswers: undefined,
12
+  optionA: undefined,
13
+  optionB: undefined,
14
+  optionC: undefined,
15
+  optionD: undefined,
16
+}
4 17
 
5 18
 export default (props) => {
6
-  const [formData, setFormData] = useState({
7
-    question: undefined,
8
-    answerType: 'radio',
9
-    correctAnswers: undefined,
10
-    optionA: undefined,
11
-    optionB: undefined,
12
-    optionC: undefined,
13
-    optionD: undefined,
14
-  });
15
-
16
-  // const [answerTypeValue, setAnswerTypeValue] = useState([])
19
+  const [formData, setFormData] = useState(defaultData);
20
+
21
+  const [correctAnswers, setCorrectAnswers] = useState([])
17 22
 
18 23
   const handleFormChange = (field) => (e) => {
19 24
     const value = e && e.target ? e.target.value : e;
20
-    console.log('------111--->', field, e, value);
21 25
     setFormData({
22 26
       ...formData,
23 27
       [field]: value,
24 28
     });
25 29
   };
26 30
 
27
-  const handleCorrectAnswers = () => {};
31
+  const handleCorrectAnswers = (e) => {
32
+    if (formData.answerType === 'radio' || formData.answerType === 'switch') {
33
+      setCorrectAnswers([e.target.value])
34
+    } else {
35
+      setCorrectAnswers(e && e.length > 0 ? e : [])
36
+    }
37
+  };
28 38
 
29
-  const handleSubmit = () => {};
39
+  const handleSubmit = () => {
40
+    if (!formData.title) {
41
+      notification.warning({ message: '请填写考题' })
42
+      return
43
+    }
44
+    if (!formData.optionA && !formData.optionB && !formData.optionC && !formData.optionD) {
45
+      notification.warning({ message: '请填写选项' })
46
+      return
47
+    }
48
+    if (!formData.answerType) {
49
+      notification.warning({ message: '请设置题型' })
50
+      return
51
+    }
52
+    if (!formData.correctAnswers) {
53
+      notification.warning({ message: '请设置正确答案' })
54
+      return
55
+    }
56
+
57
+    if (props.onSubmit) {
58
+      props.onSubmit(formData)
59
+    }
60
+  };
30 61
 
31 62
   const handleCancel = () => {
32 63
     if (props.onCancel) {
@@ -34,104 +65,121 @@ export default (props) => {
34 65
     }
35 66
   };
36 67
 
37
-  const answerTypeDict = [
38
-    { value: 'switch', label: '判断' },
39
-    { value: 'radio', label: '单选' },
40
-    { value: 'checkbox', label: '多选' },
41
-  ];
68
+  const answerTypeDict = Object.keys(props.answerTypeDict).map((key) => ({ value: key, label: props.answerTypeDict[key] }));
69
+
70
+  useEffect(() => {
71
+    formData.correctAnswers = (correctAnswers || []).join(',')
72
+  }, [correctAnswers, formData])
73
+
74
+  useEffect(() => {
75
+    setFormData(props.value || defaultData)
76
+    if (props.value?.correctAnswers) {
77
+      setCorrectAnswers(props.value.correctAnswers.split(','))
78
+    }
79
+  }, [props.value])
42 80
 
43 81
   return (
44 82
     <div>
45 83
       <Space size="large" direction="vertical" style={{ width: '100%' }}>
46 84
         <section>
47
-          <h3>试题:</h3>
48
-          <WangEditor value={formData.question} onChange={handleFormChange('question')} />
85
+          <h3><RedRequire />题型:</h3>
86
+          <Radio.Group
87
+            options={answerTypeDict}
88
+            value={formData.answerType}
89
+            onChange={handleFormChange('answerType')}
90
+          />
49 91
         </section>
50 92
 
51 93
         <section>
52
-          <h3>选项:</h3>
94
+          <h3><RedRequire />考题:</h3>
95
+          <Input placeholder="不能超过 300 字" value={formData.title} onChange={handleFormChange('title')} />
96
+        </section>
97
+
98
+        {/* <section>
99
+          <h3>详细内容:</h3>
100
+          <WangEditor
101
+            height={120}
102
+            value={formData.question}
103
+            onChange={handleFormChange('question')}
104
+          />
105
+        </section> */}
106
+
107
+        <section>
108
+          <h3><RedRequire />选项:</h3>
53 109
           <Space size="large" direction="vertical" style={{ width: '100%' }}>
54 110
             <Row gutter="24">
55 111
               <Col span={12}>
56
-                <Input addonBefore="A" onChange={handleFormChange('optionA')} />
57
-              </Col>
58
-              <Col span={12}>
59
-                <Input addonBefore="B" onChange={handleFormChange('optionB')} />
60
-              </Col>
61
-            </Row>
62
-            <Row gutter="24">
63
-              <Col span={12}>
64
-                <Input addonBefore="C" onChange={handleFormChange('optionC')} />
112
+                <Input addonBefore="A" value={formData.optionA} onChange={handleFormChange('optionA')} />
65 113
               </Col>
66 114
               <Col span={12}>
67
-                <Input addonBefore="D" onChange={handleFormChange('optionD')} />
115
+                <Input addonBefore="B" value={formData.optionB} onChange={handleFormChange('optionB')} />
68 116
               </Col>
69 117
             </Row>
118
+            {
119
+              formData.answerType !== 'switch' && (
120
+                <Row gutter="24">
121
+                  <Col span={12}>
122
+                    <Input addonBefore="C" value={formData.optionC} onChange={handleFormChange('optionC')} />
123
+                  </Col>
124
+                  <Col span={12}>
125
+                    <Input addonBefore="D" value={formData.optionD} onChange={handleFormChange('optionD')} />
126
+                  </Col>
127
+                </Row>
128
+              )
129
+            }
70 130
           </Space>
71 131
         </section>
72 132
 
73 133
         <section>
74
-          <Row gutter="24">
75
-            <Col span={12}>
76
-              <h3>题型:</h3>
77
-              <Radio.Group
78
-                options={answerTypeDict}
79
-                value={formData.answerType}
80
-                onChange={handleFormChange('answerType')}
81
-              />
82
-            </Col>
83
-            <Col span={12}>
84
-              <h3>正确答案:</h3>
85
-              {formData.answerType === 'switch' && (
86
-                <Radio.Group onChange={handleCorrectAnswers} style={{ width: '100%' }}>
87
-                  <Row gutter="12">
88
-                    <Col span={6}>
89
-                      <Radio value="A">是</Radio>
90
-                    </Col>
91
-                    <Col span={6}>
92
-                      <Radio value="B">否</Radio>
93
-                    </Col>
94
-                  </Row>
95
-                </Radio.Group>
96
-              )}
97
-              {formData.answerType === 'radio' && (
98
-                <Radio.Group onChange={handleCorrectAnswers} style={{ width: '100%' }}>
99
-                  <Row gutter="12">
100
-                    <Col span={6}>
101
-                      <Radio value="A">A</Radio>
102
-                    </Col>
103
-                    <Col span={6}>
104
-                      <Radio value="B">B</Radio>
105
-                    </Col>
106
-                    <Col span={6}>
107
-                      <Radio value="C">C</Radio>
108
-                    </Col>
109
-                    <Col span={6}>
110
-                      <Radio value="D">D</Radio>
111
-                    </Col>
112
-                  </Row>
113
-                </Radio.Group>
114
-              )}
115
-              {formData.answerType === 'checkbox' && (
116
-                <Checkbox.Group onChange={handleCorrectAnswers} style={{ width: '100%' }}>
117
-                  <Row gutter="12">
118
-                    <Col span={6}>
119
-                      <Checkbox value="A">A</Checkbox>
120
-                    </Col>
121
-                    <Col span={6}>
122
-                      <Checkbox value="B">B</Checkbox>
123
-                    </Col>
124
-                    <Col span={6}>
125
-                      <Checkbox value="C">C</Checkbox>
126
-                    </Col>
127
-                    <Col span={6}>
128
-                      <Checkbox value="D">D</Checkbox>
129
-                    </Col>
130
-                  </Row>
131
-                </Checkbox.Group>
132
-              )}
133
-            </Col>
134
-          </Row>
134
+          <h3><RedRequire />正确答案:</h3>
135
+          {formData.answerType === 'switch' && (
136
+            <Radio.Group value={correctAnswers[0]} onChange={handleCorrectAnswers} style={{ width: '100%' }}>
137
+              <Row gutter="12">
138
+                <Col span={6}>
139
+                  <Radio value="A">是</Radio>
140
+                </Col>
141
+                <Col span={6}>
142
+                  <Radio value="B">否</Radio>
143
+                </Col>
144
+              </Row>
145
+            </Radio.Group>
146
+          )}
147
+          {formData.answerType === 'radio' && (
148
+            <Radio.Group value={correctAnswers[0]} onChange={handleCorrectAnswers} style={{ width: '100%' }}>
149
+              <Row gutter="12">
150
+                <Col span={6}>
151
+                  <Radio value="A">A</Radio>
152
+                </Col>
153
+                <Col span={6}>
154
+                  <Radio value="B">B</Radio>
155
+                </Col>
156
+                <Col span={6}>
157
+                  <Radio value="C">C</Radio>
158
+                </Col>
159
+                <Col span={6}>
160
+                  <Radio value="D">D</Radio>
161
+                </Col>
162
+              </Row>
163
+            </Radio.Group>
164
+          )}
165
+          {formData.answerType === 'checkbox' && (
166
+            <Checkbox.Group value={correctAnswers} onChange={handleCorrectAnswers} style={{ width: '100%' }}>
167
+              <Row gutter="12">
168
+                <Col span={6}>
169
+                  <Checkbox value="A">A</Checkbox>
170
+                </Col>
171
+                <Col span={6}>
172
+                  <Checkbox value="B">B</Checkbox>
173
+                </Col>
174
+                <Col span={6}>
175
+                  <Checkbox value="C">C</Checkbox>
176
+                </Col>
177
+                <Col span={6}>
178
+                  <Checkbox value="D">D</Checkbox>
179
+                </Col>
180
+              </Row>
181
+            </Checkbox.Group>
182
+          )}
135 183
         </section>
136 184
 
137 185
         <section>

+ 19
- 83
src/components/WangEditor/WangEditor.jsx Datei anzeigen

@@ -1,114 +1,50 @@
1
-import React, { useState, useRef, useEffect, useCallback } from 'react';
2
-import E from 'wangeditor';
1
+import React, { useRef, useEffect } from 'react';
2
+
3 3
 // import PreviewMenu from './PreviewMenu'
4
-import Preview from './Preview';
5
-import { uploadImage } from '@/utils/uploadFile';
4
+// import Preview from './Preview';
5
+import initEditor from './initEditor';
6 6
 
7 7
 export default (props) => {
8 8
   const ref = useRef();
9
-  const editorRef = useRef();
10
-  const [preview, setPreview] = useState(false);
9
+  const inited = useRef(false);
10
+  // const [preview, setPreview] = useState(false);
11 11
   // const [content, setContent] = useState()
12
+  const updateContent= useRef()
12 13
 
13
-  const inited = useRef(false);
14
-  const handleChange = useCallback(
15
-    (html) => {
14
+  const editorConfig = useRef({
15
+    onchange: (html) => {
16 16
       if ((inited.current || html) && typeof props.onChange === 'function') {
17 17
         inited.current = true;
18 18
         props.onChange(html);
19 19
       }
20 20
     },
21
-    [props],
22
-  );
23
-
24
-  const initEditor = useCallback(() => {
25
-    const editor = new E(ref.current);
26
-    editorRef.current = editor;
27
-
28
-    // 取消自动 focus
29
-    editor.config.focus = false;
30
-
31
-    // 触发 change
32
-    editor.config.onchange = handleChange;
33
-
34
-    editor.config.zIndex = 100;
35
-
36
-    // 自定义图片上传
37
-    editor.config.uploadImgMaxLength = 1;
38
-    editor.config.customUploadImg = (files, insert) => {
39
-      if (!files.length) return;
40
-
41
-      uploadImage(files[0]).then(insert);
42
-    };
43
-
44
-    // 扩展预览按钮
45
-    // editor.menus.extend('previewMenu', PreviewMenu)
46
-    // PreviewMenu.preview = (html) => setPreview(true)
47
-
48
-    // 配置菜单
49
-    editor.config.menus = [
50
-      'head', // 标题
51
-      'bold', // 粗体
52
-      'fontSize', // 字号
53
-      'fontName', // 字体
54
-      'italic', // 斜体
55
-      'underline', // 下划线
56
-      'strikeThrough', // 删除线
57
-      'foreColor', // 文字颜色
58
-      'backColor', // 背景颜色
59
-      'list', // 列表
60
-      'justify', // 对齐方式
61
-      'quote', // 引用
62
-      'image', // 插入图片
63
-      'undo', // 撤销
64
-      'redo', // 重复
65
-      // 'previewMenu'
66
-    ];
67
-
68
-    // 过滤 word 字符
69
-    editor.config.pasteFilterStyle = false;
70
-    editor.config.pasteTextHandle = (ctt) => {
71
-      const regs = [
72
-        /<!--\[if [\s\S]*?endif\]-->/gi,
73
-        /<[a-zA-Z0-9]+:[^>]+>[^>]*<\/[a-zA-Z0-9]+:[^>]+>/gi,
74
-        /<[a-zA-Z0-9]+:[^>]+\/>/gi,
75
-        /<style>[\s\S]*?<\/style>/gi,
76
-        new RegExp('\u2029', 'ig'), // 替换word分隔符 序号 8233
77
-      ];
78
-
79
-      return regs.reduce((acc, reg) => {
80
-        return acc.replace(reg, '');
81
-      }, ctt);
82
-    };
83
-
84
-    editor.create();
85
-    editor.$textElem.attr('contenteditable', props.contenteditable !== false);
86
-
87
-    return () => editor.destroy();
88
-  }, [props, handleChange]);
21
+    height: props.height || 300,
22
+  })
89 23
 
90 24
   useEffect(() => {
91
-    initEditor();
92
-  }, [initEditor]);
25
+    const { editor, updateHtml } = initEditor (ref.current, editorConfig.current)
26
+    updateContent.current = updateHtml
27
+    return () => editor.destroy();
28
+  }, []);
93 29
 
94 30
   //
95 31
   useEffect(() => {
96
-    if (props.value && !inited.current && editorRef.current) {
32
+    if (props.value && !inited.current && updateContent.current) {
97 33
       inited.current = true;
98
-      editorRef.current.txt.html(props.value);
34
+      updateContent.current(props.value);
99 35
     }
100 36
   }, [props.value]);
101 37
 
102 38
   return (
103 39
     <>
104 40
       <div ref={ref} style={{ textAlign: 'left' }} />
105
-      <Preview
41
+      {/* <Preview
106 42
         width={426}
107 43
         style={{ width: '426px', height: '863px', margin: 0, padding: 0 }}
108 44
         visible={preview}
109 45
         html={props.value}
110 46
         onCancel={() => setPreview(false)}
111
-      />
47
+      /> */}
112 48
     </>
113 49
   );
114 50
 };

+ 71
- 0
src/components/WangEditor/initEditor.js Datei anzeigen

@@ -0,0 +1,71 @@
1
+import E from 'wangeditor';
2
+import { uploadImage } from '@/utils/uploadFile';
3
+
4
+export default (elm, config) => {
5
+  const editor = new E(elm);
6
+
7
+  // 取消自动 focus
8
+  editor.config.focus = false;
9
+
10
+  // 触发 change
11
+  // editor.config.onchange = onchange;
12
+
13
+  editor.config.zIndex = 100;
14
+
15
+  // 自定义图片上传
16
+  editor.config.uploadImgMaxLength = 1;
17
+  editor.config.customUploadImg = (files, insert) => {
18
+    if (!files.length) return;
19
+
20
+    uploadImage(files[0]).then(insert);
21
+  };
22
+
23
+  // 扩展预览按钮
24
+  // editor.menus.extend('previewMenu', PreviewMenu)
25
+  // PreviewMenu.preview = (html) => setPreview(true)
26
+
27
+  // 配置菜单
28
+  editor.config.menus = [
29
+    'head', // 标题
30
+    'bold', // 粗体
31
+    'fontSize', // 字号
32
+    'fontName', // 字体
33
+    'italic', // 斜体
34
+    'underline', // 下划线
35
+    'strikeThrough', // 删除线
36
+    'foreColor', // 文字颜色
37
+    'backColor', // 背景颜色
38
+    'list', // 列表
39
+    'justify', // 对齐方式
40
+    'quote', // 引用
41
+    'image', // 插入图片
42
+    'undo', // 撤销
43
+    'redo', // 重复
44
+    // 'previewMenu'
45
+  ];
46
+
47
+  // 过滤 word 字符
48
+  editor.config.pasteFilterStyle = false;
49
+  editor.config.pasteTextHandle = (ctt) => {
50
+    const regs = [
51
+      /<!--\[if [\s\S]*?endif\]-->/gi,
52
+      /<[a-zA-Z0-9]+:[^>]+>[^>]*<\/[a-zA-Z0-9]+:[^>]+>/gi,
53
+      /<[a-zA-Z0-9]+:[^>]+\/>/gi,
54
+      /<style>[\s\S]*?<\/style>/gi,
55
+      new RegExp('\u2029', 'ig'), // 替换word分隔符 序号 8233
56
+    ];
57
+
58
+    return regs.reduce((acc, reg) => {
59
+      return acc.replace(reg, '');
60
+    }, ctt);
61
+  };
62
+
63
+  Object.assign(editor.config, config || {})
64
+
65
+  editor.create();
66
+  // editor.$textElem.attr('contenteditable', props.contenteditable !== false);
67
+  return {
68
+    editor,
69
+    updateHtml: (html) => editor.txt.html(html)
70
+  };
71
+}

+ 4
- 4
src/layouts/BasicLayout.jsx Datei anzeigen

@@ -153,10 +153,10 @@ const BasicLayout = (props) => {
153 153
       }}
154 154
       menuDataRender={menuDataRender(menus)}
155 155
       rightContentRender={() => <RightContent />}
156
-      waterMarkProps={{
157
-        content: '云致科技',
158
-        fontColor: 'rgba(24,144,255,0.15)',
159
-      }}
156
+      // waterMarkProps={{
157
+      //   content: '云致科技',
158
+      //   fontColor: 'rgba(24,144,255,0.15)',
159
+      // }}
160 160
     >
161 161
       <Authorized authority={authorized.authority} noMatch={noMatch}>
162 162
         {children}

+ 135
- 3
src/pages/Post/Edit/components/Answer.jsx Datei anzeigen

@@ -1,10 +1,142 @@
1
-import React from 'react';
1
+import React, { useEffect, useRef, useState } from 'react';
2
+import { Drawer, Button, Row, Col, Space, notification } from 'antd';
3
+import ProTable from '@ant-design/pro-table';
4
+import request from '@/utils/request';
2 5
 import TestQuestions from '@/components/TestQuestions';
3 6
 
4
-export default () => {
7
+const answerTypeDict = {
8
+  switch: '判断',
9
+  radio: '单选题',
10
+  checkbox: '多选题',
11
+}
12
+
13
+export default (props) => {
14
+  const [visible, setVisible] = useState(false)
15
+  const tableRef = useRef()
16
+  const [ postTest, setPostTest ] = useState({})
17
+
18
+  const handleEdit = (item) => {
19
+    setVisible(true)
20
+    setPostTest(item)
21
+  }
22
+
23
+  const columns = [
24
+    {
25
+      title: '题型',
26
+      width: 80,
27
+      key: 'answerType',
28
+      dataIndex: 'answerType',
29
+      valueEnum: Object.keys(answerTypeDict).reduce((acc, key) => ({
30
+        ...acc,
31
+        [key]: { text: answerTypeDict[key] }
32
+      }), {}),
33
+    },
34
+    {
35
+      title: '考题',
36
+      key: 'title',
37
+      dataIndex: 'title',
38
+      ellipsis: true,
39
+    },
40
+    {
41
+      title: '选项',
42
+      width: 300,
43
+      key: 'optionA',
44
+      dataIndex: 'optionA',
45
+      render: (_, item) => (
46
+        <Space direction="vertical" style={{ width: '100%' }}>
47
+          <Row gutter={24}>
48
+            <Col span={12}>{`A. ${item.optionA}`}</Col>
49
+            <Col span={12}>{`B. ${item.optionB}`}</Col>
50
+          </Row>
51
+          {
52
+            item.answerType !== 'switch' && (
53
+              <Row gutter={24}>
54
+                <Col span={12}>{`C. ${item.optionC}`}</Col>
55
+                <Col span={12}>{`D. ${item.optionD}`}</Col>
56
+              </Row>
57
+            )
58
+          }
59
+        </Space>
60
+      )
61
+    },
62
+    {
63
+      title: '正确答案',
64
+      width: 100,
65
+      key: 'correctAnswers',
66
+      dataIndex: 'correctAnswers',
67
+    },
68
+    {
69
+      title: '操作',
70
+      width: 80,
71
+      key: 'option',
72
+      render: (_, item) => (
73
+        <a onClick={() => handleEdit(item)}>编辑</a>
74
+      )
75
+    },
76
+  ]
77
+
78
+  const actions = [
79
+    <Button key="add" type="primary" onClick={() => handleEdit({})}>新增</Button>,
80
+  ]
81
+
82
+  const requestMock = () => {
83
+    const postTestList = props.post.postTestList || []
84
+    return Promise.resolve({
85
+      data: postTestList,
86
+      success: true,
87
+      total: postTestList.length,
88
+    })
89
+  }
90
+
91
+  const handleSubmit = (value) => {
92
+    const data = {
93
+      ...value,
94
+      postId: props.post.postId,
95
+    }
96
+
97
+    if (!data.serialNo) {
98
+      // 新增
99
+      request('/post-test', { method: 'post', data }).then((res) => {
100
+        setVisible(false)
101
+  
102
+        if (props.onChange) {
103
+          const postTestList = props.post.postTestList || []
104
+          props.onChange([res].concat(postTestList))
105
+        }
106
+      }).catch((e) => {
107
+        notification.error({ message: e.message })
108
+      })
109
+    } else {
110
+      //
111
+    }
112
+  }
113
+
114
+  useEffect(() => {
115
+    if (tableRef.current) {
116
+      tableRef.current.reload()
117
+    }
118
+  }, [props.post.postTestList])
119
+
5 120
   return (
6 121
     <div>
7
-      <TestQuestions />
122
+      <Drawer
123
+        title="试题维护"
124
+        placement="right"
125
+        onClose={() => setVisible(false)}
126
+        visible={visible}
127
+        width={850}
128
+      >
129
+        <TestQuestions value={postTest} answerTypeDict={answerTypeDict} onSubmit={handleSubmit} onCancel={() => setVisible(false)} />
130
+      </Drawer>
131
+      <ProTable
132
+        actionRef={tableRef}
133
+        request={requestMock}
134
+        columns={columns}
135
+        headerTitle="题库"
136
+        rowKey="serialNo"
137
+        search={false}
138
+        toolBarRender={() => actions}
139
+      />
8 140
     </div>
9 141
   );
10 142
 };

+ 18
- 5
src/pages/Post/Edit/components/Form.jsx Datei anzeigen

@@ -27,8 +27,14 @@ export default (props) => {
27 27
   }, [props.typeList]);
28 28
 
29 29
   const handleSubmit = (values) => {
30
-    if (!values.postId) {
31
-      return request('/post', { method: 'post', data: values })
30
+    const data = {
31
+      ...props.post || {},
32
+      ...values,
33
+    }
34
+
35
+    if (!data.postId) {
36
+      // 新增
37
+      return request('/post', { method: 'post', data })
32 38
         .then((res) => {
33 39
           props.onChange(res);
34 40
         })
@@ -38,8 +44,15 @@ export default (props) => {
38 44
         });
39 45
     }
40 46
 
41
-    // eslint-disable-next-line
42
-    return;
47
+    // 编辑
48
+    return request(`/post/${data.postId}`, { method: 'put', data })
49
+    .then((res) => {
50
+      props.onChange(res);
51
+    })
52
+    .catch((e) => {
53
+      notification.error({ message: e.message });
54
+      return Promise.reject(e.message);
55
+    });
43 56
   };
44 57
 
45 58
   const handleValueChange = (changed) => {
@@ -99,7 +112,7 @@ export default (props) => {
99 112
           </Form.Item>
100 113
         </>
101 114
       ) : (
102
-        <Form.Item name="videoUrl" label="图文内容" placeholder="请填写图文内容">
115
+        <Form.Item name="content" label="图文内容" placeholder="请填写图文内容">
103 116
           <WangEditor />
104 117
         </Form.Item>
105 118
       )}

+ 8
- 3
src/pages/Post/Edit/index.jsx Datei anzeigen

@@ -18,6 +18,13 @@ const PostEdit = (props) => {
18 18
     setPost(newPost);
19 19
   };
20 20
 
21
+  const handlePostTestChange = (postTestList) => {
22
+    setPost({
23
+      ...post,
24
+      postTestList,
25
+    })
26
+  }
27
+
21 28
   useEffect(() => {
22 29
     setLoading(true);
23 30
     request(`/post/${id}`)
@@ -50,9 +57,7 @@ const PostEdit = (props) => {
50 57
             </Container>
51 58
           </TabPane>
52 59
           <TabPane tab="题库设置" key="2">
53
-            <Container>
54
-              <Answer />
55
-            </Container>
60
+            <Answer post={post} onChange={handlePostTestChange} />
56 61
           </TabPane>
57 62
         </Tabs>
58 63
       </Container>