|
@@ -1,15 +1,21 @@
|
1
|
1
|
import React from 'react';
|
2
|
2
|
import { Button, Tabs, Form, Row, Col, InputNumber, message } from 'antd';
|
|
3
|
+import useBool from '@/utils/hooks/useBool';
|
3
|
4
|
import { ModalForm, ProFormDigit, ProFormDependency } from '@ant-design/pro-components';
|
4
|
|
-import { postTaCheckItem } from '@/service/tacheckitem';
|
|
5
|
+import { getTaCheckItemQu } from '@/service/tacheckitemqu';
|
|
6
|
+import { getTaCheckItem, postTaCheckItem } from '@/service/tacheckitem';
|
5
|
7
|
|
6
|
8
|
const LocForm = (props) => {
|
7
|
|
- const {checkItem, open, onOpenChange, onChange} = props;
|
|
9
|
+ const { checkItem, open, onOpenChange, onChange, itemId, checkId } = props;
|
|
10
|
+
|
|
11
|
+ const [loading, startLoading, stopLoading] = useBool();
|
|
12
|
+ const [list, setList] = React.useState();
|
|
13
|
+ // const [listData, setListData] = React.useState();
|
8
|
14
|
|
9
|
15
|
const [form] = Form.useForm();
|
10
|
16
|
|
11
|
17
|
const onFinish = async (values) => {
|
12
|
|
- const data = { ...(checkItem || {}), ...values, itemType: 'loc'}
|
|
18
|
+ const data = { ...(checkItem || {}), ...values, itemType: 'loc' }
|
13
|
19
|
const res = await postTaCheckItem(data);
|
14
|
20
|
onChange(res);
|
15
|
21
|
return true;
|
|
@@ -28,6 +34,35 @@ const LocForm = (props) => {
|
28
|
34
|
}
|
29
|
35
|
}, [checkItem]);
|
30
|
36
|
|
|
37
|
+ React.useEffect(() => {
|
|
38
|
+ if (itemId) {
|
|
39
|
+ startLoading();
|
|
40
|
+ getTaCheckItemQu({ pageSize: 500, itemId }).then((res) => {
|
|
41
|
+ stopLoading();
|
|
42
|
+ setList(...res.records);
|
|
43
|
+ }).catch(() => {
|
|
44
|
+ stopLoading();
|
|
45
|
+ });
|
|
46
|
+ }
|
|
47
|
+ }, [itemId]);
|
|
48
|
+
|
|
49
|
+ // React.useEffect(() => {
|
|
50
|
+ // if (checkId) {
|
|
51
|
+ // startLoading();
|
|
52
|
+ // getTaCheckItem({ pageSize: 500, checkId, itemType: "loc" }).then(res => {
|
|
53
|
+ // setListData(...res.records || []);
|
|
54
|
+ // stopLoading();
|
|
55
|
+ // }).catch(() => {
|
|
56
|
+ // stopLoading();
|
|
57
|
+ // });
|
|
58
|
+ // }
|
|
59
|
+ // }, [checkId]);
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+ // console.log('list?.maxScore', list?.maxScore);
|
|
64
|
+ // console.log('checkItem?.answerNum', checkItem?.answerNum);
|
|
65
|
+ // console.log('list?.maxScore / checkItem?.answerNum', list?.maxScore / checkItem?.answerNum);
|
31
|
66
|
return (
|
32
|
67
|
<ModalForm
|
33
|
68
|
title={`${checkItem?.name} 维护`}
|
|
@@ -37,12 +72,12 @@ const LocForm = (props) => {
|
37
|
72
|
onFinish={onFinish}
|
38
|
73
|
onOpenChange={onOpenChange}
|
39
|
74
|
>
|
40
|
|
- <ProFormDigit label="计分" name="fullScore" min={0.00} fieldProps={{precision: 2}} />
|
41
|
|
- <ProFormDigit label="数量" name="num" min={1} fieldProps={{precision: 0}} />
|
42
|
|
- <ProFormDependency name={['fullScore' , 'num']}>
|
|
75
|
+ <ProFormDigit readonly label="分值" value={checkItem?.answerNum == 0 ? 0 : list?.maxScore / checkItem?.answerNum} />
|
|
76
|
+ <ProFormDigit label="数量" name="num" min={1} fieldProps={{ precision: 0 }} />
|
|
77
|
+ <ProFormDependency name={['fullScore', 'num']}>
|
43
|
78
|
{
|
44
|
|
- ({fullScore, num}) => <ProFormDigit readonly label="分值" value={fullScore / num} fieldProps={{precision: 2}} />
|
45
|
|
- }
|
|
79
|
+ ({ fullScore, num }) => <ProFormDigit readonly label="小计" value={fullScore / num} fieldProps={{ precision: 2 }} />
|
|
80
|
+ }
|
46
|
81
|
</ProFormDependency>
|
47
|
82
|
</ModalForm>
|
48
|
83
|
)
|