张涛 1 год назад
Родитель
Сommit
9a07b17747

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

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
 import { useNavigate } from "react-router-dom";
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
 export default (props) => {
11
 export default (props) => {
12
   const navigate = useNavigate();
12
   const navigate = useNavigate();
17
 
17
 
18
   const onEdit = () => {
18
   const onEdit = () => {
19
     setOpen(true);
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
   const onFinish = async (values) => {
31
   const onFinish = async (values) => {
26
     const data = {
32
     const data = {
27
       ...values,
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
     if (!checkInfo) {
38
     if (!checkInfo) {
33
       const res = await postTaCheck(data);
39
       const res = await postTaCheck(data);
34
       onChange(res);
40
       onChange(res);
41
+      console.log(123);
35
     } else {
42
     } else {
36
       const res = await putTaCheck(checkInfo.checkId, data);
43
       const res = await putTaCheck(checkInfo.checkId, data);
37
       onChange(res);
44
       onChange(res);
38
     }
45
     }
39
-
40
     return true;
46
     return true;
41
-  }
47
+  };
48
+
49
+
42
 
50
 
43
   React.useEffect(() => {
51
   React.useEffect(() => {
44
     if (checkInfo) {
52
     if (checkInfo) {
51
   }, [checkInfo]);
59
   }, [checkInfo]);
52
 
60
 
53
   return (
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
         </div>
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
       <Tabs
80
       <Tabs
64
-        defaultActiveKey='1'
81
+        defaultActiveKey="1"
65
         onChange={onTabChange}
82
         onChange={onTabChange}
66
-        tabBarStyle={{ margin: '0 2em' }}
83
+        tabBarStyle={{ margin: "0 2em" }}
67
         items={[
84
         items={[
68
           {
85
           {
69
-            label: '实地测评',
70
-            key: '1',
86
+            label: "实地测评",
87
+            key: "1",
71
           },
88
           },
72
           {
89
           {
73
             label: (
90
             label: (
76
                 <SurverForm checkId={checkInfo?.checkId} />
93
                 <SurverForm checkId={checkInfo?.checkId} />
77
               </div>
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
         <Form.Item name="title" label="测评名称" required>
108
         <Form.Item name="title" label="测评名称" required>
85
           <Input placeholder="请输入测评名称" />
109
           <Input placeholder="请输入测评名称" />
86
         </Form.Item>
110
         </Form.Item>
87
         <Form.Item name="startDate" label="开始时间" required>
111
         <Form.Item name="startDate" label="开始时间" required>
88
-          <DatePicker placeholder="请选择" style={{ width: '100%' }} />
112
+          <DatePicker placeholder="请选择" style={{ width: "100%" }} />
89
         </Form.Item>
113
         </Form.Item>
90
         <Form.Item name="endDate" label="结束时间" required>
114
         <Form.Item name="endDate" label="结束时间" required>
91
-          <DatePicker placeholder="请选择" style={{ width: '100%' }} />
115
+          <DatePicker placeholder="请选择" style={{ width: "100%" }} />
92
         </Form.Item>
116
         </Form.Item>
93
         <Row gutter={24}>
117
         <Row gutter={24}>
94
           <Col span={12}>
118
           <Col span={12}>
95
             <Form.Item name="locScorePercent" label="实地占比 (%)" required>
119
             <Form.Item name="locScorePercent" label="实地占比 (%)" required>
96
-              <Percent placeholder="请设置" style={{ width: '100%' }} />
120
+              <Percent placeholder="请设置" style={{ width: "100%" }} />
97
             </Form.Item>
121
             </Form.Item>
98
           </Col>
122
           </Col>
99
           <Col span={12}>
123
           <Col span={12}>
100
             <Form.Item name="surveyScorePercent" label="问卷占比 (%)" required>
124
             <Form.Item name="surveyScorePercent" label="问卷占比 (%)" required>
101
-              <Percent placeholder="请设置" style={{ width: '100%' }} />
125
+              <Percent placeholder="请设置" style={{ width: "100%" }} />
102
             </Form.Item>
126
             </Form.Item>
103
           </Col>
127
           </Col>
104
         </Row>
128
         </Row>
105
       </ModalForm>
129
       </ModalForm>
106
     </Card>
130
     </Card>
107
-  )
108
-}
131
+  );
132
+};

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

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
 export default (props) => {
10
 export default (props) => {
11
   const { checkId } = props;
11
   const { checkId } = props;
18
 
18
 
19
   const columns = [
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
       render: (_, row) => {
33
       render: (_, row) => {
34
         return (
34
         return (
35
           <Space>
35
           <Space>
36
             <span>
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
             </span>
42
             </span>
39
             <span>/</span>
43
             <span>/</span>
40
             <span>{row.num || 0}</span>
44
             <span>{row.num || 0}</span>
41
           </Space>
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
       width: 100,
64
       width: 100,
60
       render: (_, row) => {
65
       render: (_, row) => {
61
         return (
66
         return (
62
           <Space>
67
           <Space>
63
-            <Button type="link" onClick={() => onEdit(row)}>编辑</Button>
68
+            <Button type="link" onClick={() => onEdit(row)}>
69
+              编辑
70
+            </Button>
64
           </Space>
71
           </Space>
65
-        )
66
-      }
72
+        );
73
+      },
67
     },
74
     },
68
-  ]
75
+  ];
69
 
76
 
70
   const summary = React.useMemo(() => {
77
   const summary = React.useMemo(() => {
71
     let fullScore = 0;
78
     let fullScore = 0;
75
     let subtotal = 0;
82
     let subtotal = 0;
76
 
83
 
77
     list.forEach((x) => {
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
       subtotal += (x.fullScore || 0) * (x.num || 0);
89
       subtotal += (x.fullScore || 0) * (x.num || 0);
83
     });
90
     });
84
 
91
 
88
       num,
95
       num,
89
       score,
96
       score,
90
       subtotal: Number(subtotal).toFixed(2),
97
       subtotal: Number(subtotal).toFixed(2),
91
-    }
98
+    };
92
   }, [list]);
99
   }, [list]);
93
 
100
 
94
   const queryList = React.useCallback(() => {
101
   const queryList = React.useCallback(() => {
95
     if (checkId) {
102
     if (checkId) {
96
       startLoading();
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
   }, [checkId]);
113
   }, [checkId]);
105
 
114
 
106
   const onEdit = (row) => {
115
   const onEdit = (row) => {
107
     setCurItem(row);
116
     setCurItem(row);
108
     setOpen(true);
117
     setOpen(true);
109
-  }
118
+  };
110
 
119
 
111
   const onExport = () => {
120
   const onExport = () => {
112
     startExpLoading();
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
   const onChange = (item) => {
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
     setList(newList);
133
     setList(newList);
123
-  }
134
+  };
124
 
135
 
125
   const onQuChange = () => {
136
   const onQuChange = () => {
126
     queryList();
137
     queryList();
127
-  }
138
+  };
128
 
139
 
129
   const getRowClassName = (row) => {
140
   const getRowClassName = (row) => {
130
     return [
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
   React.useEffect(() => {
149
   React.useEffect(() => {
137
     queryList();
150
     queryList();
138
   }, [queryList]);
151
   }, [queryList]);
139
 
152
 
153
+  const onSync = () => {
154
+    // getTaCheckItem({ pageSize: 500, checkId, itemType: "loc" }).then((res) => {
155
+    // setList(res.records || []);
156
+    // });
157
+  };
140
   return (
158
   return (
141
     <Row gutter={24}>
159
     <Row gutter={24}>
142
       <Col span={12}>
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
           <Table
182
           <Table
145
             sticky
183
             sticky
146
             summary={() => (
184
             summary={() => (
147
               <Table.Summary fixed="top">
185
               <Table.Summary fixed="top">
148
-                <Table.Summary.Row style={{ fontWeight: 'bolder' }}>
186
+                <Table.Summary.Row style={{ fontWeight: "bolder" }}>
149
                   <Table.Summary.Cell index={0}>合计</Table.Summary.Cell>
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
                 </Table.Summary.Row>
200
                 </Table.Summary.Row>
155
               </Table.Summary>
201
               </Table.Summary>
156
             )}
202
             )}
178
         <QuList itemId={curItem?.itemId} onChange={onQuChange} />
224
         <QuList itemId={curItem?.itemId} onChange={onQuChange} />
179
       </Col>
225
       </Col>
180
     </Row>
226
     </Row>
181
-  )
182
-}
227
+  );
228
+};

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

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

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

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