fangmingyue 2 年前
父节点
当前提交
430590c7a7

+ 9
- 8
src/pages/check/Edit.jsx 查看文件

24
       getTaCheckById(id).then(setCheckInfo);
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
         if (res.records && res.records[0]) {
28
         if (res.records && res.records[0]) {
29
           setSurvey(res.records[0])
29
           setSurvey(res.records[0])
30
         }
30
         }
32
     }
32
     }
33
   }, [id]);
33
   }, [id]);
34
 
34
 
35
+  console.log('-----survey----->', survey);
35
   return (
36
   return (
36
     <Page back>
37
     <Page back>
37
       <CheckForm
38
       <CheckForm
39
         onChange={setCheckInfo}
40
         onChange={setCheckInfo}
40
         onTabChange={setTab}
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
       </div>
50
       </div>
50
       {/* <Row gutter={24} style={{marginTop: '24px'}}>
51
       {/* <Row gutter={24} style={{marginTop: '24px'}}>
51
         <Col span={12}>
52
         <Col span={12}>

+ 43
- 8
src/pages/check/components/LocForm.jsx 查看文件

1
 import React from 'react';
1
 import React from 'react';
2
 import { Button, Tabs, Form, Row, Col, InputNumber, message } from 'antd';
2
 import { Button, Tabs, Form, Row, Col, InputNumber, message } from 'antd';
3
+import useBool from '@/utils/hooks/useBool';
3
 import { ModalForm, ProFormDigit, ProFormDependency } from '@ant-design/pro-components';
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
 const LocForm = (props) => {
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
   const [form] = Form.useForm();
15
   const [form] = Form.useForm();
10
 
16
 
11
   const onFinish = async (values) => {
17
   const onFinish = async (values) => {
12
-    const data = { ...(checkItem || {}), ...values, itemType: 'loc'}
18
+    const data = { ...(checkItem || {}), ...values, itemType: 'loc' }
13
     const res = await postTaCheckItem(data);
19
     const res = await postTaCheckItem(data);
14
     onChange(res);
20
     onChange(res);
15
     return true;
21
     return true;
28
     }
34
     }
29
   }, [checkItem]);
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
   return (
66
   return (
32
     <ModalForm
67
     <ModalForm
33
       title={`${checkItem?.name} 维护`}
68
       title={`${checkItem?.name} 维护`}
37
       onFinish={onFinish}
72
       onFinish={onFinish}
38
       onOpenChange={onOpenChange}
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
       </ProFormDependency>
81
       </ProFormDependency>
47
     </ModalForm>
82
     </ModalForm>
48
   )
83
   )

+ 23
- 2
src/pages/check/components/LocTable.jsx 查看文件

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

+ 2
- 2
src/pages/check/components/QuForm.jsx 查看文件

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

+ 12
- 0
src/pages/check/components/QuList.jsx 查看文件

117
       }
117
       }
118
     >
118
     >
119
       <Table
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
         rowKey="quId"
132
         rowKey="quId"
121
         loading={loading}
133
         loading={loading}
122
         columns={columns}
134
         columns={columns}

+ 3
- 1
src/pages/check/components/style.module.less 查看文件

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

+ 1
- 1
src/service/tacheckiteman.js 查看文件

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
  * 通过主键删除数据