Yansen vor 2 Jahren
Ursprung
Commit
4e4c1556fd

+ 14
- 2
src/pages/check/Edit.jsx Datei anzeigen

@@ -5,21 +5,30 @@ import Page from '@/components/Page';
5 5
 import CheckForm from './components/CheckForm';
6 6
 import { useSearchParams } from 'react-router-dom';
7 7
 import { getTaCheckById } from '@/service/tacheck';
8
-import LocForm from './components/LocForm';
8
+import { getTaCheckItem } from '@/service/tacheckitem';
9 9
 import LocTable from './components/LocTable';
10
+import QuList from './components/QuList';
10 11
 
11 12
 export default (props) => {
12 13
   const [searchParams] = useSearchParams();
13 14
 
14 15
   const [checkInfo, setCheckInfo] = React.useState();
16
+  const [survey, setSurvey] = React.useState();
15 17
   const [tab, setTab] = React.useState('1');
16
-  const locRef = React.useRef();
17 18
 
18 19
   const id = searchParams.get('id');
19 20
 
20 21
   React.useEffect(() => {
21 22
     if (id) {
23
+      // 查询测评主表信息
22 24
       getTaCheckById(id).then(setCheckInfo);
25
+
26
+      // 查询测评调查问卷主表
27
+      getTaCheckItem({checkId: id, itemType: 'survey'}).then(res => {
28
+        if (res.records && res.records[0]) {
29
+          setSurvey(res.records[0])
30
+        }
31
+      })
23 32
     }
24 33
   }, [id]);
25 34
 
@@ -34,6 +43,9 @@ export default (props) => {
34 43
       {
35 44
         tab == '1' && <LocTable checkId={checkInfo?.checkId} />
36 45
       }
46
+      {
47
+        tab == '2' && <QuList itemId={survey?.itemId} itemType="survey" />
48
+      }
37 49
       </div>
38 50
       {/* <Row gutter={24} style={{marginTop: '24px'}}>
39 51
         <Col span={12}>

+ 3
- 1
src/pages/check/components/LocTable.jsx Datei anzeigen

@@ -52,7 +52,6 @@ export default (props) => {
52 52
         return (
53 53
           <Space>
54 54
             <Button type="link" onClick={() => onEdit(row)}>编辑</Button>
55
-            <Button type="link" onClick={() => setCurItem(row)}>试题</Button>
56 55
           </Space>
57 56
         )
58 57
       }
@@ -86,6 +85,9 @@ export default (props) => {
86 85
             columns={columns}
87 86
             dataSource={list}
88 87
             pagination={false}
88
+            onRow={(row) => ({
89
+              onClick: () => setCurItem(row),
90
+            })}
89 91
           />
90 92
           <LocForm
91 93
             open={open}

+ 23
- 9
src/pages/check/components/QuList.jsx Datei anzeigen

@@ -6,7 +6,7 @@ import { deleteTaCheckItemQu } from '@/service/tacheckitemqu';
6 6
 import QuForm from './QuForm';
7 7
 
8 8
 export default (props) => {
9
-  const { itemId } = props;
9
+  const { itemId, itemType = 'loc' } = props;
10 10
 
11 11
   const [open, setOpen] = React.useState(false);
12 12
   const [list, setList] = React.useState([]);
@@ -18,7 +18,14 @@ export default (props) => {
18 18
       title: '序号',
19 19
       dataIndex: 'sortNo',
20 20
       key: 'sortNo',
21
-      width: 100,
21
+      width: itemType === 'loc' ? 100 : undefined,
22
+    },
23
+    itemType !== 'loc' &&
24
+    {
25
+      title: '题型',
26
+      dataIndex: 'quType',
27
+      key: 'quType',
28
+      render: t => !t ? '-' : (t == 'radio' ? '选择' : '填空'),
22 29
     },
23 30
     {
24 31
       title: '题干',
@@ -27,14 +34,14 @@ export default (props) => {
27 34
     },
28 35
     {
29 36
       title: '分值',
30
-      dataIndex: 'anScore',
31
-      key: 'anScore',
32
-      width: 100,
37
+      dataIndex: 'maxScore',
38
+      key: 'maxScore',
39
+      width: itemType === 'loc' ? 100 : undefined,
33 40
     },
34 41
     {
35 42
       title: '操作',
36 43
       key: 'options',
37
-      width: 100,
44
+      width: itemType === 'loc' ? 100 : 200,
38 45
       render: (_, row) => {
39 46
         return (
40 47
           <Space>
@@ -49,7 +56,7 @@ export default (props) => {
49 56
         )
50 57
       }
51 58
     },
52
-  ]
59
+  ].filter(Boolean)
53 60
 
54 61
   const onAdd = () => {
55 62
     setCurItem();
@@ -86,7 +93,7 @@ export default (props) => {
86 93
       newList.push(res);
87 94
     }
88 95
 
89
-    setList(list);
96
+    setList(newList);
90 97
   }
91 98
 
92 99
   React.useEffect(() => {
@@ -102,7 +109,14 @@ export default (props) => {
102 109
   }, [itemId]);
103 110
 
104 111
   return (
105
-    <Card title="试题列表" extra={<Button type="link" disabled={!itemId} onClick={onAdd}>新增</Button>}>
112
+    <Card
113
+      title="试题列表"
114
+      extra={
115
+        itemType == 'loc' ?
116
+          <Button type="link" disabled={!itemId} onClick={onAdd}>新增</Button> :
117
+          <Button type="primary" ghost disabled={!itemId} onClick={onAdd}>新增</Button>
118
+      }
119
+    >
106 120
       <Table
107 121
         rowKey="quId"
108 122
         loading={loading}