fangmingyue 2 лет назад
Родитель
Сommit
430590c7a7

+ 9
- 8
src/pages/check/Edit.jsx Просмотреть файл

@@ -24,7 +24,7 @@ export default (props) => {
24 24
       getTaCheckById(id).then(setCheckInfo);
25 25
 
26 26
       // 查询测评调查问卷主表
27
-      getTaCheckItem({checkId: id, itemType: 'survey'}).then(res => {
27
+      getTaCheckItem({ checkId: id, itemType: 'survey' }).then(res => {
28 28
         if (res.records && res.records[0]) {
29 29
           setSurvey(res.records[0])
30 30
         }
@@ -32,6 +32,7 @@ export default (props) => {
32 32
     }
33 33
   }, [id]);
34 34
 
35
+  console.log('-----survey----->', survey);
35 36
   return (
36 37
     <Page back>
37 38
       <CheckForm
@@ -39,13 +40,13 @@ export default (props) => {
39 40
         onChange={setCheckInfo}
40 41
         onTabChange={setTab}
41 42
       />
42
-      <div style={{marginTop: '24px'}}>
43
-      {
44
-        tab == '1' && <LocTable checkId={checkInfo?.checkId} />
45
-      }
46
-      {
47
-        tab == '2' && <QuList itemId={survey?.itemId} itemType="survey" />
48
-      }
43
+      <div style={{ marginTop: '24px' }}>
44
+        {
45
+          tab == '1' && <LocTable checkId={checkInfo?.checkId} />
46
+        }
47
+        {
48
+          tab == '2' && <QuList itemId={survey?.itemId} itemType="survey" />
49
+        }
49 50
       </div>
50 51
       {/* <Row gutter={24} style={{marginTop: '24px'}}>
51 52
         <Col span={12}>

+ 43
- 8
src/pages/check/components/LocForm.jsx Просмотреть файл

@@ -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
   )

+ 23
- 2
src/pages/check/components/LocTable.jsx Просмотреть файл

@@ -16,10 +16,13 @@ export default (props) => {
16 16
   const [open, setOpen] = React.useState(false);
17 17
 
18 18
   const onEdit = (row) => {
19
+    // console.log('________________________>', row);
19 20
     setCurItem(row);
20 21
     setOpen(true);
21 22
   }
22 23
 
24
+
25
+
23 26
   const columns = [
24 27
     {
25 28
       title: '点位名称',
@@ -28,8 +31,7 @@ export default (props) => {
28 31
     },
29 32
     {
30 33
       title: '分值',
31
-      key: 'avgScore',
32
-      render: (_, row) => row.fullScore ? Number(row.fullScore / (row.num || 1)).toFixed(2) : '-',
34
+      dataIndex: 'fullScore',
33 35
     },
34 36
     {
35 37
       title: '已收/计划数',
@@ -51,6 +53,7 @@ export default (props) => {
51 53
       title: '小计',
52 54
       dataIndex: 'fullScore',
53 55
       key: 'fullScore',
56
+      render: (_, row) => row.fullScore ? Number(row.fullScore * (row.num || 1)).toFixed(2) : '-',
54 57
     },
55 58
     {
56 59
       title: '测评得分',
@@ -95,11 +98,27 @@ export default (props) => {
95 98
     }
96 99
   }, [checkId]);
97 100
 
101
+  // console.log('---------------------------------------------------------->', list?.map((x) => Number(x.fullScore / (x.num || 1)).toFixed(2)))
102
+
98 103
   return (
99 104
     <Row gutter={24}>
100 105
       <Col span={12}>
101 106
         <Card>
102 107
           <Table
108
+            sticky
109
+            summary={() => (
110
+              <Table.Summary>
111
+                <Table.Summary.Row style={{ fontWeight: 'bolder' }}>
112
+                  <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>
119
+                </Table.Summary.Row>
120
+              </Table.Summary>
121
+            )}
103 122
             rowKey="typeId"
104 123
             loading={loading}
105 124
             columns={columns}
@@ -111,6 +130,8 @@ export default (props) => {
111 130
             })}
112 131
           />
113 132
           <LocForm
133
+            checkId={checkId}
134
+            itemId={curItem?.itemId}
114 135
             open={open}
115 136
             checkItem={curItem}
116 137
             onOpenChange={setOpen}

+ 2
- 2
src/pages/check/components/QuForm.jsx Просмотреть файл

@@ -173,7 +173,7 @@ export default (props) => {
173 173
                   <ProFormDigit
174 174
                     name="anScore"
175 175
                     label="单项计分"
176
-                    min={0}
176
+                    min={-100}
177 177
                     fieldProps={{ precision: 2 }}
178 178
                     rules={[
179 179
                       {
@@ -255,8 +255,8 @@ export default (props) => {
255 255
                       <ProFormDigit
256 256
                         name="score"
257 257
                         label="计分"
258
-                        help="计分"
259 258
                         min={0}
259
+                        help="计分"
260 260
                         fieldProps={{ precision: 2 }}
261 261
                       />
262 262
                     </Col>

+ 12
- 0
src/pages/check/components/QuList.jsx Просмотреть файл

@@ -117,6 +117,18 @@ export default (props) => {
117 117
       }
118 118
     >
119 119
       <Table
120
+        // sticky
121
+        // summary={() => (
122
+        //   <Table.Summary>
123
+        //     <Table.Summary.Row style={{ fontWeight: 'bolder' }}>
124
+        //       <Table.Summary.Cell index={0}>合计</Table.Summary.Cell>
125
+        //       <Table.Summary.Cell index={1}>1</Table.Summary.Cell>
126
+        //       <Table.Summary.Cell index={2}>{list?.map((x) => x.maxScore).reduce((total, num) => total + num, 0)}</Table.Summary.Cell>
127
+        //     </Table.Summary.Row>
128
+        //   </Table.Summary>
129
+        // )}
130
+        title={() => (<div style={{ fontWeight: 'bolder' }}>分值合计:{list?.map((x) => x.maxScore).reduce((total, num) => total + num, 0)}</div>)}
131
+        bordered
120 132
         rowKey="quId"
121 133
         loading={loading}
122 134
         columns={columns}

+ 3
- 1
src/pages/check/components/style.module.less Просмотреть файл

@@ -1,4 +1,3 @@
1
-
2 1
 .yz-table-row {
3 2
   & > td:first-child {
4 3
     border-left: 2px solid transparent;
@@ -10,3 +9,6 @@
10 9
     }
11 10
   }
12 11
 }
12
+.ant-table-summary {
13
+  display: table-header-group;
14
+}

+ 1
- 1
src/service/tacheckiteman.js Просмотреть файл

@@ -18,7 +18,7 @@ export const getTaCheckItemAnById = (id) => request(`/api/taCheckItemAn/${id}`);
18 18
 /*
19 19
  * 更新数据
20 20
  */
21
-export const putTaCheckItemAn = (id, data) => request(`/api/taCheckItemAn/${id}`, { data, method: 'put' });
21
+export const putTaCheckItemAn = (id, data) => request(`An/${id}`, { data, method: 'put' });
22 22
 
23 23
 /*
24 24
  * 通过主键删除数据