|
@@ -15,14 +15,6 @@ export default (props) => {
|
15
|
15
|
const [loading, startLoading, stopLoading] = useBool();
|
16
|
16
|
const [open, setOpen] = React.useState(false);
|
17
|
17
|
|
18
|
|
- const onEdit = (row) => {
|
19
|
|
- // console.log('________________________>', row);
|
20
|
|
- setCurItem(row);
|
21
|
|
- setOpen(true);
|
22
|
|
- }
|
23
|
|
-
|
24
|
|
-
|
25
|
|
-
|
26
|
18
|
const columns = [
|
27
|
19
|
{
|
28
|
20
|
title: '点位名称',
|
|
@@ -53,7 +45,7 @@ export default (props) => {
|
53
|
45
|
title: '小计',
|
54
|
46
|
dataIndex: 'fullScore',
|
55
|
47
|
key: 'fullScore',
|
56
|
|
- render: (_, row) => row.fullScore ? Number(row.fullScore * (row.num || 1)).toFixed(2) : '-',
|
|
48
|
+ render: (_, row) => row.fullScore ? Number(row.fullScore * (row.num || 0)).toFixed(2) : '-',
|
57
|
49
|
},
|
58
|
50
|
{
|
59
|
51
|
title: '测评得分',
|
|
@@ -74,19 +66,31 @@ export default (props) => {
|
74
|
66
|
},
|
75
|
67
|
]
|
76
|
68
|
|
77
|
|
- const onChange = (item) => {
|
78
|
|
- const newList = list.map(x => x.itemId === item.itemId ? item : x);
|
79
|
|
- setList(newList);
|
80
|
|
- }
|
|
69
|
+ const summary = React.useMemo(() => {
|
|
70
|
+ let fullScore = 0;
|
|
71
|
+ let answerNum = 0;
|
|
72
|
+ let num = 0;
|
|
73
|
+ let score = 0;
|
|
74
|
+ let subtotal = 0;
|
81
|
75
|
|
82
|
|
- const getRowClassName = (row) => {
|
83
|
|
- return [
|
84
|
|
- styles['yz-table-row'],
|
85
|
|
- (row.itemId == curItem?.itemId) ? styles.active : false,
|
86
|
|
- ].filter(Boolean).join(' ');
|
87
|
|
- }
|
|
76
|
+ list.forEach((x) => {
|
|
77
|
+ fullScore += (x.fullScore || 0);
|
|
78
|
+ answerNum += (x.answerNum || 0);
|
|
79
|
+ num += (x.num || 0);
|
|
80
|
+ score += (x.score || 0);
|
|
81
|
+ subtotal += (x.fullScore || 0) * (x.num || 0);
|
|
82
|
+ });
|
88
|
83
|
|
89
|
|
- React.useEffect(() => {
|
|
84
|
+ return {
|
|
85
|
+ fullScore,
|
|
86
|
+ answerNum,
|
|
87
|
+ num,
|
|
88
|
+ score,
|
|
89
|
+ subtotal: Number(subtotal).toFixed(2),
|
|
90
|
+ }
|
|
91
|
+ }, [list]);
|
|
92
|
+
|
|
93
|
+ const queryList = React.useCallback(() => {
|
90
|
94
|
if (checkId) {
|
91
|
95
|
startLoading();
|
92
|
96
|
getTaCheckItem({ pageSize: 500, checkId, itemType: "loc" }).then(res => {
|
|
@@ -98,7 +102,30 @@ export default (props) => {
|
98
|
102
|
}
|
99
|
103
|
}, [checkId]);
|
100
|
104
|
|
101
|
|
- // console.log('---------------------------------------------------------->', list?.map((x) => Number(x.fullScore / (x.num || 1)).toFixed(2)))
|
|
105
|
+ const onEdit = (row) => {
|
|
106
|
+ setCurItem(row);
|
|
107
|
+ setOpen(true);
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ const onChange = (item) => {
|
|
111
|
+ const newList = list.map(x => x.itemId === item.itemId ? item : x);
|
|
112
|
+ setList(newList);
|
|
113
|
+ }
|
|
114
|
+
|
|
115
|
+ const onQuChange = () => {
|
|
116
|
+ queryList();
|
|
117
|
+ }
|
|
118
|
+
|
|
119
|
+ const getRowClassName = (row) => {
|
|
120
|
+ return [
|
|
121
|
+ styles['yz-table-row'],
|
|
122
|
+ (row.itemId == curItem?.itemId) ? styles.active : false,
|
|
123
|
+ ].filter(Boolean).join(' ');
|
|
124
|
+ }
|
|
125
|
+
|
|
126
|
+ React.useEffect(() => {
|
|
127
|
+ queryList();
|
|
128
|
+ }, [queryList]);
|
102
|
129
|
|
103
|
130
|
return (
|
104
|
131
|
<Row gutter={24}>
|
|
@@ -107,15 +134,13 @@ export default (props) => {
|
107
|
134
|
<Table
|
108
|
135
|
sticky
|
109
|
136
|
summary={() => (
|
110
|
|
- <Table.Summary>
|
|
137
|
+ <Table.Summary fixed="top">
|
111
|
138
|
<Table.Summary.Row style={{ fontWeight: 'bolder' }}>
|
112
|
139
|
<Table.Summary.Cell index={0}>合计</Table.Summary.Cell>
|
113
|
|
- <Table.Summary.Cell index={1}>{list?.map((x) => x.fullScore).reduce((total, num) => total + num, 0)}</Table.Summary.Cell>
|
114
|
|
- <Table.Summary.Cell index={2}>
|
115
|
|
- {list?.map((x) => x.answerNum).reduce((total, num) => total + num, 0)} / {list?.map((x) => x.num).reduce((total, num) => total + num, 0)}
|
116
|
|
- </Table.Summary.Cell>
|
117
|
|
- <Table.Summary.Cell index={3}>{list?.map((x) => Number(x.fullScore * (x.num || 1))).reduce((total, num) => total + num, 0).toFixed(2)}</Table.Summary.Cell>
|
118
|
|
- <Table.Summary.Cell index={4}>{list?.map((x) => x.score).reduce((total, num) => total + num, 0)}</Table.Summary.Cell>
|
|
140
|
+ <Table.Summary.Cell index={1}>{summary.fullScore}</Table.Summary.Cell>
|
|
141
|
+ <Table.Summary.Cell index={2}>{`${summary.answerNum} / ${summary.num}`}</Table.Summary.Cell>
|
|
142
|
+ <Table.Summary.Cell index={3}>{summary.subtotal}</Table.Summary.Cell>
|
|
143
|
+ <Table.Summary.Cell index={4}>{summary.score}</Table.Summary.Cell>
|
119
|
144
|
</Table.Summary.Row>
|
120
|
145
|
</Table.Summary>
|
121
|
146
|
)}
|
|
@@ -140,7 +165,7 @@ export default (props) => {
|
140
|
165
|
</Card>
|
141
|
166
|
</Col>
|
142
|
167
|
<Col span={12}>
|
143
|
|
- <QuList itemId={curItem?.itemId} />
|
|
168
|
+ <QuList itemId={curItem?.itemId} onChange={onQuChange} />
|
144
|
169
|
</Col>
|
145
|
170
|
</Row>
|
146
|
171
|
)
|