张涛 1 年之前
父節點
當前提交
9a07b17747

+ 60
- 36
src/pages/check/components/CheckForm.jsx 查看文件

@@ -1,12 +1,12 @@
1
-import React from 'react';
2
-import dayjs from 'dayjs';
3
-import { EditOutlined } from '@ant-design/icons';
4
-import { Row, Col, Card, Tabs, Button, Form, Input, DatePicker } from 'antd';
5
-import { ModalForm } from '@ant-design/pro-components';
6
-import { postTaCheck, putTaCheck } from '@/service/tacheck';
1
+import React, { useEffect } from "react";
2
+import dayjs from "dayjs";
3
+import { EditOutlined } from "@ant-design/icons";
4
+import { Row, Col, Card, Tabs, Button, Form, Input, DatePicker } from "antd";
5
+import { ModalForm } from "@ant-design/pro-components";
6
+import { postTaCheck, putTaCheck } from "@/service/tacheck";
7 7
 import { useNavigate } from "react-router-dom";
8
-import Percent from '@/components/Percent';
9
-import SurverForm from './SurveyForm'
8
+import Percent from "@/components/Percent";
9
+import SurverForm from "./SurveyForm";
10 10
 
11 11
 export default (props) => {
12 12
   const navigate = useNavigate();
@@ -17,28 +17,36 @@ export default (props) => {
17 17
 
18 18
   const onEdit = () => {
19 19
     setOpen(true);
20
-  }
20
+  };
21 21
 
22
-  const title = checkInfo ? checkInfo.title : <div onClick={onEdit}>点击编辑创建</div>;
23
-  const dateStr = checkInfo ? `${checkInfo.startDate} ~ ${checkInfo.endDate}` : '';
22
+  const title = checkInfo ? (
23
+    checkInfo.title
24
+  ) : (
25
+    <div onClick={onEdit}>点击编辑创建</div>
26
+  );
27
+  const dateStr = checkInfo
28
+    ? `${checkInfo.startDate} ~ ${checkInfo.endDate}`
29
+    : "";
24 30
 
25 31
   const onFinish = async (values) => {
26 32
     const data = {
27 33
       ...values,
28
-      startDate: dayjs(values.startDate).format('YYYY-MM-DD'),
29
-      endDate: dayjs(values.endDate).format('YYYY-MM-DD'),
30
-    }
34
+      startDate: dayjs(values.startDate).format("YYYY-MM-DD"),
35
+      endDate: dayjs(values.endDate).format("YYYY-MM-DD"),
36
+    };
31 37
 
32 38
     if (!checkInfo) {
33 39
       const res = await postTaCheck(data);
34 40
       onChange(res);
41
+      console.log(123);
35 42
     } else {
36 43
       const res = await putTaCheck(checkInfo.checkId, data);
37 44
       onChange(res);
38 45
     }
39
-
40 46
     return true;
41
-  }
47
+  };
48
+
49
+
42 50
 
43 51
   React.useEffect(() => {
44 52
     if (checkInfo) {
@@ -51,23 +59,32 @@ export default (props) => {
51 59
   }, [checkInfo]);
52 60
 
53 61
   return (
54
-    <Card bodyStyle={{ padding: 0 }}
55
-      title={(
56
-        <div style={{ fontWeight: 'normal' }}>
57
-          <span style={{ display: 'inline-block', fontSize: '1.6em' }}>{title}</span>
58
-          <span style={{ display: 'inline-block', margin: '0 1em' }}>{dateStr}</span>
62
+    <Card
63
+      bodyStyle={{ padding: 0 }}
64
+      title={
65
+        <div style={{ fontWeight: "normal" }}>
66
+          <span style={{ display: "inline-block", fontSize: "1.6em" }}>
67
+            {title}
68
+          </span>
69
+          <span style={{ display: "inline-block", margin: "0 1em" }}>
70
+            {dateStr}
71
+          </span>
59 72
         </div>
60
-      )}
61
-      extra={<Button type="link"  icon={<EditOutlined />} onClick={onEdit}>编辑</Button>}
73
+      }
74
+      extra={
75
+        <Button type="link" icon={<EditOutlined />} onClick={onEdit}>
76
+          编辑
77
+        </Button>
78
+      }
62 79
     >
63 80
       <Tabs
64
-        defaultActiveKey='1'
81
+        defaultActiveKey="1"
65 82
         onChange={onTabChange}
66
-        tabBarStyle={{ margin: '0 2em' }}
83
+        tabBarStyle={{ margin: "0 2em" }}
67 84
         items={[
68 85
           {
69
-            label: '实地测评',
70
-            key: '1',
86
+            label: "实地测评",
87
+            key: "1",
71 88
           },
72 89
           {
73 90
             label: (
@@ -76,33 +93,40 @@ export default (props) => {
76 93
                 <SurverForm checkId={checkInfo?.checkId} />
77 94
               </div>
78 95
             ),
79
-            key: '2',
80
-          }
96
+            key: "2",
97
+          },
81 98
         ]}
82 99
       />
83
-      <ModalForm title="测评维护" open={open} width={480} form={form} onFinish={onFinish} onOpenChange={setOpen}>
100
+      <ModalForm
101
+        title="测评维护"
102
+        open={open}
103
+        width={480}
104
+        form={form}
105
+        onFinish={onFinish}
106
+        onOpenChange={setOpen}
107
+      >
84 108
         <Form.Item name="title" label="测评名称" required>
85 109
           <Input placeholder="请输入测评名称" />
86 110
         </Form.Item>
87 111
         <Form.Item name="startDate" label="开始时间" required>
88
-          <DatePicker placeholder="请选择" style={{ width: '100%' }} />
112
+          <DatePicker placeholder="请选择" style={{ width: "100%" }} />
89 113
         </Form.Item>
90 114
         <Form.Item name="endDate" label="结束时间" required>
91
-          <DatePicker placeholder="请选择" style={{ width: '100%' }} />
115
+          <DatePicker placeholder="请选择" style={{ width: "100%" }} />
92 116
         </Form.Item>
93 117
         <Row gutter={24}>
94 118
           <Col span={12}>
95 119
             <Form.Item name="locScorePercent" label="实地占比 (%)" required>
96
-              <Percent placeholder="请设置" style={{ width: '100%' }} />
120
+              <Percent placeholder="请设置" style={{ width: "100%" }} />
97 121
             </Form.Item>
98 122
           </Col>
99 123
           <Col span={12}>
100 124
             <Form.Item name="surveyScorePercent" label="问卷占比 (%)" required>
101
-              <Percent placeholder="请设置" style={{ width: '100%' }} />
125
+              <Percent placeholder="请设置" style={{ width: "100%" }} />
102 126
             </Form.Item>
103 127
           </Col>
104 128
         </Row>
105 129
       </ModalForm>
106 130
     </Card>
107
-  )
108
-}
131
+  );
132
+};

+ 111
- 65
src/pages/check/components/LocTable.jsx 查看文件

@@ -1,11 +1,11 @@
1
-import React from 'react';
2
-import { Link } from 'react-router-dom';
3
-import useBool from '@/utils/hooks/useBool';
4
-import { Table, Space, Button, Row, Col, Card } from 'antd';
5
-import { getTaCheckItem, exportTaCheckItem } from '@/service/tacheckitem';
6
-import QuList from './QuList';
7
-import LocForm from './LocForm';
8
-import styles from './style.module.less';
1
+import React from "react";
2
+import { Link } from "react-router-dom";
3
+import useBool from "@/utils/hooks/useBool";
4
+import { Table, Space, Button, Row, Col, Card } from "antd";
5
+import { getTaCheckItem, exportTaCheckItem } from "@/service/tacheckitem";
6
+import QuList from "./QuList";
7
+import LocForm from "./LocForm";
8
+import styles from "./style.module.less";
9 9
 
10 10
 export default (props) => {
11 11
   const { checkId } = props;
@@ -18,54 +18,61 @@ export default (props) => {
18 18
 
19 19
   const columns = [
20 20
     {
21
-      title: '点位名称',
22
-      dataIndex: 'name',
23
-      key: 'name',
21
+      title: "点位名称",
22
+      dataIndex: "name",
23
+      key: "name",
24 24
     },
25 25
     {
26
-      title: '分值',
27
-      dataIndex: 'fullScore',
26
+      title: "分值",
27
+      dataIndex: "fullScore",
28 28
     },
29 29
     {
30
-      title: '已收/计划数',
31
-      dataIndex: 'num',
32
-      key: 'num',
30
+      title: "已收/计划数",
31
+      dataIndex: "num",
32
+      key: "num",
33 33
       render: (_, row) => {
34 34
         return (
35 35
           <Space>
36 36
             <span>
37
-              <Link to={`/checkAnswer/loc?checkId=${row.checkId}&typeId=${row.typeId}&back=true`}>{row.answerNum || 0}</Link>
37
+              <Link
38
+                to={`/checkAnswer/loc?checkId=${row.checkId}&typeId=${row.typeId}&back=true`}
39
+              >
40
+                {row.answerNum || 0}
41
+              </Link>
38 42
             </span>
39 43
             <span>/</span>
40 44
             <span>{row.num || 0}</span>
41 45
           </Space>
42
-        )
43
-      }
46
+        );
47
+      },
44 48
     },
45 49
     {
46
-      title: '小计',
47
-      dataIndex: 'fullScore',
48
-      key: 'fullScore',
49
-      render: (_, row) => row.fullScore ? Number(row.fullScore * (row.num || 0)).toFixed(2) : '-',
50
+      title: "小计",
51
+      dataIndex: "fullScore",
52
+      key: "fullScore",
53
+      render: (_, row) =>
54
+        row.fullScore ? Number(row.fullScore * (row.num || 0)).toFixed(2) : "-",
50 55
     },
51 56
     {
52
-      title: '测评得分',
53
-      dataIndex: 'score',
54
-      key: 'score',
57
+      title: "测评得分",
58
+      dataIndex: "score",
59
+      key: "score",
55 60
     },
56 61
     {
57
-      title: '操作',
58
-      key: 'options',
62
+      title: "操作",
63
+      key: "options",
59 64
       width: 100,
60 65
       render: (_, row) => {
61 66
         return (
62 67
           <Space>
63
-            <Button type="link" onClick={() => onEdit(row)}>编辑</Button>
68
+            <Button type="link" onClick={() => onEdit(row)}>
69
+              编辑
70
+            </Button>
64 71
           </Space>
65
-        )
66
-      }
72
+        );
73
+      },
67 74
     },
68
-  ]
75
+  ];
69 76
 
70 77
   const summary = React.useMemo(() => {
71 78
     let fullScore = 0;
@@ -75,10 +82,10 @@ export default (props) => {
75 82
     let subtotal = 0;
76 83
 
77 84
     list.forEach((x) => {
78
-      fullScore += (x.fullScore || 0);
79
-      answerNum += (x.answerNum || 0);
80
-      num += (x.num || 0);
81
-      score += (x.score || 0);
85
+      fullScore += x.fullScore || 0;
86
+      answerNum += x.answerNum || 0;
87
+      num += x.num || 0;
88
+      score += x.score || 0;
82 89
       subtotal += (x.fullScore || 0) * (x.num || 0);
83 90
     });
84 91
 
@@ -88,69 +95,108 @@ export default (props) => {
88 95
       num,
89 96
       score,
90 97
       subtotal: Number(subtotal).toFixed(2),
91
-    }
98
+    };
92 99
   }, [list]);
93 100
 
94 101
   const queryList = React.useCallback(() => {
95 102
     if (checkId) {
96 103
       startLoading();
97
-      getTaCheckItem({ pageSize: 500, checkId, itemType: "loc" }).then(res => {
98
-        setList(res.records || []);
99
-        stopLoading();
100
-      }).catch(() => {
101
-        stopLoading();
102
-      });
104
+      getTaCheckItem({ pageSize: 500, checkId, itemType: "loc" })
105
+        .then((res) => {
106
+          setList(res.records || []);
107
+          stopLoading();
108
+        })
109
+        .catch(() => {
110
+          stopLoading();
111
+        });
103 112
     }
104 113
   }, [checkId]);
105 114
 
106 115
   const onEdit = (row) => {
107 116
     setCurItem(row);
108 117
     setOpen(true);
109
-  }
118
+  };
110 119
 
111 120
   const onExport = () => {
112 121
     startExpLoading();
113
-    exportTaCheckItem(checkId).then(() => {
114
-      stopExpLoading();
115
-    }).catch(() => {
116
-      stopExpLoading();
117
-    });
118
-  }
122
+    exportTaCheckItem(checkId)
123
+      .then(() => {
124
+        stopExpLoading();
125
+      })
126
+      .catch(() => {
127
+        stopExpLoading();
128
+      });
129
+  };
119 130
 
120 131
   const onChange = (item) => {
121
-    const newList = list.map(x => x.itemId === item.itemId ? item : x);
132
+    const newList = list.map((x) => (x.itemId === item.itemId ? item : x));
122 133
     setList(newList);
123
-  }
134
+  };
124 135
 
125 136
   const onQuChange = () => {
126 137
     queryList();
127
-  }
138
+  };
128 139
 
129 140
   const getRowClassName = (row) => {
130 141
     return [
131
-      styles['yz-table-row'],
132
-      (row.itemId == curItem?.itemId) ? styles.active : false,
133
-    ].filter(Boolean).join(' ');
134
-  }
142
+      styles["yz-table-row"],
143
+      row.itemId == curItem?.itemId ? styles.active : false,
144
+    ]
145
+      .filter(Boolean)
146
+      .join(" ");
147
+  };
135 148
 
136 149
   React.useEffect(() => {
137 150
     queryList();
138 151
   }, [queryList]);
139 152
 
153
+  const onSync = () => {
154
+    // getTaCheckItem({ pageSize: 500, checkId, itemType: "loc" }).then((res) => {
155
+    // setList(res.records || []);
156
+    // });
157
+  };
140 158
   return (
141 159
     <Row gutter={24}>
142 160
       <Col span={12}>
143
-        <Card extra={<Button loading={expLoading} type="primary" onClick={onExport}>导出</Button>}>
161
+        <Card
162
+          extra={
163
+            <>
164
+              {checkId ? (
165
+                <Button
166
+                  style={{ marginRight: "20px" }}
167
+                  type="primary"
168
+                  onClick={onSync}
169
+                >
170
+                  同步点位
171
+                </Button>
172
+              ) : (
173
+                ""
174
+              )}
175
+
176
+              <Button loading={expLoading} type="primary" onClick={onExport}>
177
+                导出
178
+              </Button>
179
+            </>
180
+          }
181
+        >
144 182
           <Table
145 183
             sticky
146 184
             summary={() => (
147 185
               <Table.Summary fixed="top">
148
-                <Table.Summary.Row style={{ fontWeight: 'bolder' }}>
186
+                <Table.Summary.Row style={{ fontWeight: "bolder" }}>
149 187
                   <Table.Summary.Cell index={0}>合计</Table.Summary.Cell>
150
-                  <Table.Summary.Cell index={1}>{summary.fullScore}</Table.Summary.Cell>
151
-                  <Table.Summary.Cell index={2}>{`${summary.answerNum} / ${summary.num}`}</Table.Summary.Cell>
152
-                  <Table.Summary.Cell index={3}>{summary.subtotal}</Table.Summary.Cell>
153
-                  <Table.Summary.Cell index={4}>{summary.score}</Table.Summary.Cell>
188
+                  <Table.Summary.Cell index={1}>
189
+                    {summary.fullScore}
190
+                  </Table.Summary.Cell>
191
+                  <Table.Summary.Cell
192
+                    index={2}
193
+                  >{`${summary.answerNum} / ${summary.num}`}</Table.Summary.Cell>
194
+                  <Table.Summary.Cell index={3}>
195
+                    {summary.subtotal}
196
+                  </Table.Summary.Cell>
197
+                  <Table.Summary.Cell index={4}>
198
+                    {summary.score}
199
+                  </Table.Summary.Cell>
154 200
                 </Table.Summary.Row>
155 201
               </Table.Summary>
156 202
             )}
@@ -178,5 +224,5 @@ export default (props) => {
178 224
         <QuList itemId={curItem?.itemId} onChange={onQuChange} />
179 225
       </Col>
180 226
     </Row>
181
-  )
182
-}
227
+  );
228
+};

+ 1
- 0
src/pages/check/components/SurveyForm.jsx 查看文件

@@ -24,6 +24,7 @@ const SurveyForm = (props) => {
24 24
   const onFinish = async (values) => {
25 25
     const data = { ...(checkItem || {}), ...values, itemType }
26 26
     const res = await postTaCheckItem(data);
27
+    console.log(res)
27 28
     setCheckItem(res);
28 29
     form.setFieldsValue(res);
29 30
     return true;

+ 0
- 1
src/pages/check/index.jsx 查看文件

@@ -124,7 +124,6 @@ export default (props) => {
124 124
       valueType: "option",
125 125
       width: 240,
126 126
       render: (_, record) => [
127
-        console.log('record', record),
128 127
         // <Button
129 128
         //   key={1}
130 129
         //   style={{ padding: 0 }}