Yansen 2 gadus atpakaļ
vecāks
revīzija
4e4c1556fd

+ 14
- 2
src/pages/check/Edit.jsx Parādīt failu

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

+ 3
- 1
src/pages/check/components/LocTable.jsx Parādīt failu

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

+ 23
- 9
src/pages/check/components/QuList.jsx Parādīt failu

6
 import QuForm from './QuForm';
6
 import QuForm from './QuForm';
7
 
7
 
8
 export default (props) => {
8
 export default (props) => {
9
-  const { itemId } = props;
9
+  const { itemId, itemType = 'loc' } = props;
10
 
10
 
11
   const [open, setOpen] = React.useState(false);
11
   const [open, setOpen] = React.useState(false);
12
   const [list, setList] = React.useState([]);
12
   const [list, setList] = React.useState([]);
18
       title: '序号',
18
       title: '序号',
19
       dataIndex: 'sortNo',
19
       dataIndex: 'sortNo',
20
       key: 'sortNo',
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
       title: '题干',
31
       title: '题干',
27
     },
34
     },
28
     {
35
     {
29
       title: '分值',
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
       title: '操作',
42
       title: '操作',
36
       key: 'options',
43
       key: 'options',
37
-      width: 100,
44
+      width: itemType === 'loc' ? 100 : 200,
38
       render: (_, row) => {
45
       render: (_, row) => {
39
         return (
46
         return (
40
           <Space>
47
           <Space>
49
         )
56
         )
50
       }
57
       }
51
     },
58
     },
52
-  ]
59
+  ].filter(Boolean)
53
 
60
 
54
   const onAdd = () => {
61
   const onAdd = () => {
55
     setCurItem();
62
     setCurItem();
86
       newList.push(res);
93
       newList.push(res);
87
     }
94
     }
88
 
95
 
89
-    setList(list);
96
+    setList(newList);
90
   }
97
   }
91
 
98
 
92
   React.useEffect(() => {
99
   React.useEffect(() => {
102
   }, [itemId]);
109
   }, [itemId]);
103
 
110
 
104
   return (
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
       <Table
120
       <Table
107
         rowKey="quId"
121
         rowKey="quId"
108
         loading={loading}
122
         loading={loading}