Yansen 2 anni fa
parent
commit
730e1a48a9

+ 0
- 4
src/components/Money/float.js Vedi File

@@ -1,4 +0,0 @@
1
-const epsilonN = N => num => Math.round( num * N + Number.EPSILON ) / N;
2
-const epsilon2 = epsilonN(1e2);
3
-
4
-export default epsilon2;

+ 3
- 1
src/components/Money/index.jsx Vedi File

@@ -1,6 +1,8 @@
1 1
 import { InputNumber } from "antd"
2 2
 import { useEffect, useState } from "react"
3
-import epsilon2 from './float'
3
+
4
+const epsilonN = N => num => Math.round( num * N + Number.EPSILON ) / N;
5
+const epsilon2 = epsilonN(1e2);
4 6
 
5 7
 export default (props) => {
6 8
 

+ 28
- 3
src/components/Page/index.jsx Vedi File

@@ -1,6 +1,8 @@
1 1
 import React from 'react';
2 2
 import { Typography } from 'antd';
3
+import { useNavigate } from 'react-router-dom';
3 4
 import useRoute from '@/utils/hooks/useRoute';
5
+import { ArrowLeftOutlined } from '@ant-design/icons';
4 6
 
5 7
 const pageStyle = {
6 8
   // margin: '24px 24px 0 24px',
@@ -14,24 +16,47 @@ const titleStyle = {
14 16
   paddingBottom: '12px',
15 17
 }
16 18
 
19
+const backStyle = {
20
+  color: '#333',
21
+  marginRight: '0.5em',
22
+}
23
+
17 24
 const Title = (props) => {
25
+  const { extra, back } = props;
26
+  const navigate = useNavigate();
27
+
28
+  const goBack = (e) => {
29
+    e.preventDefault();
30
+    e.stopPropagation();
31
+
32
+    navigate(-1);
33
+  }
18 34
 
19 35
   return (
20 36
     <div style={titleStyle}>
21
-      <Typography.Title level={3} style={{fontWeight: 400, flex: 'none'}}>{props.children}</Typography.Title>
22
-      <div style={{flex: 'none'}}>{props.extra}</div>
37
+      <Typography.Title level={3} style={{fontWeight: 400, flex: 'none'}}>
38
+        {
39
+          back && (
40
+            <span onClick={goBack}><ArrowLeftOutlined style={backStyle} /></span>
41
+          )
42
+        }
43
+        {props.children}
44
+      </Typography.Title>
45
+      <div style={{flex: 'none'}}>{extra}</div>
23 46
     </div>
24 47
   )
25 48
 }
26 49
 
27 50
 export default (props) => {
51
+  const { extra, back } = props;
52
+
28 53
   const { meta = {} } = useRoute() || {};
29 54
   const style = meta.noLayout ? { height: '100%' } : pageStyle;
30 55
   const title = props.title || meta.title;
31 56
 
32 57
   return (
33 58
     <div style={style}>
34
-      { title && !meta.noLayout && <Title extra={props.extra}>{ title }</Title> }
59
+      { title && !meta.noLayout && <Title extra={extra} back={back}>{ title }</Title> }
35 60
       {props.children}
36 61
     </div>
37 62
   )

+ 32
- 0
src/components/Percent/index.jsx Vedi File

@@ -0,0 +1,32 @@
1
+import { InputNumber } from "antd"
2
+import { useEffect, useState } from "react"
3
+
4
+const epsilonN = N => num => Math.round( num * N + Number.EPSILON ) / N;
5
+const epsilon2 = epsilonN(1e2);
6
+
7
+export default (props) => {
8
+
9
+  const { value, onChange, ...leftProps } = props
10
+
11
+  const [percent, setPercent] = useState(0)
12
+
13
+  useEffect(() => {
14
+    setPercent(epsilon2(value * 100))
15
+  }, [value])
16
+
17
+  const handleChange = (val) => {
18
+    onChange(epsilon2(val / 100))
19
+  }
20
+
21
+  return (
22
+    <InputNumber
23
+      min='0'
24
+      {...leftProps}
25
+      value={percent}
26
+      onChange={handleChange}
27
+      precision={2}
28
+      formatter={value => `${value} %`}
29
+      parser={value => value.replace(/\s?%/g, '')}
30
+    />
31
+  )
32
+}

+ 1
- 1
src/pages/check/Edit.jsx Vedi File

@@ -33,7 +33,7 @@ export default (props) => {
33 33
   }, [id]);
34 34
 
35 35
   return (
36
-    <Page>
36
+    <Page back>
37 37
       <CheckForm
38 38
         checkInfo={checkInfo}
39 39
         onChange={setCheckInfo}

+ 30
- 9
src/pages/check/components/CheckForm.jsx Vedi File

@@ -1,10 +1,12 @@
1 1
 import React from 'react';
2 2
 import dayjs from 'dayjs';
3 3
 import { EditOutlined } from '@ant-design/icons';
4
-import { Card, Tabs, Button, Form, Input, DatePicker } from 'antd';
4
+import { Row, Col, Card, Tabs, Button, Form, Input, DatePicker } from 'antd';
5 5
 import { ModalForm } from '@ant-design/pro-components';
6 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 10
 
9 11
 export default (props) => {
10 12
   const navigate = useNavigate();
@@ -49,13 +51,15 @@ export default (props) => {
49 51
   }, [checkInfo]);
50 52
 
51 53
   return (
52
-    <Card bodyStyle={{ padding: 0 }}>
53
-      <div style={{ display: 'flex', padding: '1em', alignItems: 'center' }}>
54
-        <div style={{ flex: 'none' }}><Button type="link" onClick={onEdit} icon={<EditOutlined />} /></div>
55
-        <div style={{ flex: 'none', margin: '0 1em' }}>{dateStr}</div>
56
-        <div style={{ flex: '1', fontSize: '1.6em' }}>{title}</div>
57
-        <div style={{ flex: 'none', fontSize: '1.6em' }}><Button type="primary" onClick={() => navigate(-1)}>返回</Button></div>
58
-      </div>
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>
59
+        </div>
60
+      )}
61
+      extra={<Button type="link"  icon={<EditOutlined />} onClick={onEdit}>编辑</Button>}
62
+    >
59 63
       <Tabs
60 64
         defaultActiveKey='1'
61 65
         onChange={onTabChange}
@@ -66,7 +70,12 @@ export default (props) => {
66 70
             key: '1',
67 71
           },
68 72
           {
69
-            label: '问卷调查',
73
+            label: (
74
+              <div>
75
+                <span>调查问卷</span>
76
+                <SurverForm checkId={checkInfo?.checkId} />
77
+              </div>
78
+            ),
70 79
             key: '2',
71 80
           }
72 81
         ]}
@@ -81,6 +90,18 @@ export default (props) => {
81 90
         <Form.Item name="endDate" label="结束时间" required>
82 91
           <DatePicker placeholder="请选择" style={{ width: '100%' }} />
83 92
         </Form.Item>
93
+        <Row gutter={24}>
94
+          <Col span={12}>
95
+            <Form.Item name="locScorePercent" label="实地占比 (%)" required>
96
+              <Percent placeholder="请设置" style={{ width: '100%' }} />
97
+            </Form.Item>
98
+          </Col>
99
+          <Col span={12}>
100
+            <Form.Item name="surveyScorePercent" label="问卷占比 (%)" required>
101
+              <Percent placeholder="请设置" style={{ width: '100%' }} />
102
+            </Form.Item>
103
+          </Col>
104
+        </Row>
84 105
       </ModalForm>
85 106
     </Card>
86 107
   )

+ 5
- 5
src/pages/check/components/QuForm.jsx Vedi File

@@ -253,7 +253,7 @@ export default (props) => {
253 253
                 }
254 254
                 return (
255 255
                   <Row gutter={24} style={{ width: '730px' }}>
256
-                    <Col span={6}>
256
+                    <Col span={8}>
257 257
                       <ProFormText
258 258
                         name="answerCode"
259 259
                         label="选项"
@@ -261,7 +261,7 @@ export default (props) => {
261 261
                         initialValue={'A'}
262 262
                       />
263 263
                     </Col>
264
-                    <Col span={6}>
264
+                    <Col span={8}>
265 265
                       <ProFormDigit
266 266
                         name="score"
267 267
                         label="计分"
@@ -270,7 +270,7 @@ export default (props) => {
270 270
                         fieldProps={{ precision: 2 }}
271 271
                       />
272 272
                     </Col>
273
-                    <Col span={6}>
273
+                    {/* <Col span={6}>
274 274
                       <ProFormSelect
275 275
                         name="reportIssue"
276 276
                         label="上报问题"
@@ -281,8 +281,8 @@ export default (props) => {
281 281
                           1: '上报',
282 282
                         }}
283 283
                       />
284
-                    </Col>
285
-                    <Col span={6}>
284
+                    </Col> */}
285
+                    <Col span={8}>
286 286
                       <ProFormText
287 287
                         name="answer"
288 288
                         label="答案"

+ 83
- 0
src/pages/check/components/SurveyForm.jsx Vedi File

@@ -0,0 +1,83 @@
1
+import React from 'react';
2
+import { Button, Tabs, Form, Row, Col, InputNumber, message } from 'antd';
3
+import { EditOutlined } from '@ant-design/icons';
4
+import { ModalForm, ProFormDigit, ProFormDependency } from '@ant-design/pro-components';
5
+import { getTaCheckItem, postTaCheckItem } from '@/service/tacheckitem';
6
+
7
+const itemType = 'survey';
8
+
9
+const SurveyForm = (props) => {
10
+  const { checkId } = props;
11
+
12
+  const [show, setShow] = React.useState(false);
13
+  const [loading, setLoading] = React.useState(false);
14
+  const [checkItem, setCheckItem] = React.useState();
15
+  const [form] = Form.useForm();
16
+  
17
+  const onClick = (e) => {
18
+    e.preventDefault();
19
+    e.stopPropagation();
20
+    setShow(true);
21
+  }
22
+
23
+  const onFinish = async (values) => {
24
+    const data = { ...(checkItem || {}), ...values, itemType }
25
+    const res = await postTaCheckItem(data);
26
+    setCheckItem(res);
27
+    form.setFieldsValue(res);
28
+    return true;
29
+  }
30
+
31
+  const reset = () => {
32
+    form.resetFields();
33
+    form.setFieldsValue({ num: 1 });
34
+  }
35
+
36
+  React.useEffect(() => {
37
+    if (checkItem) {
38
+      form.setFieldsValue(checkItem);
39
+    } else {
40
+      reset();
41
+    }
42
+  }, [checkItem]);
43
+
44
+  
45
+  React.useEffect(() => {
46
+    if (checkId) {
47
+      setLoading(true);
48
+      getTaCheckItem({ checkId, itemType }).then(res => {
49
+        const item = (res.records || [])[0]
50
+        if (item) {
51
+          setCheckItem(item);
52
+          form.setFieldsValue(item);
53
+        }
54
+        setLoading(false);
55
+      }).catch(() => {
56
+        setLoading(false);
57
+      });
58
+    }
59
+  }, [checkId]);
60
+
61
+  return (
62
+    <ModalForm
63
+      title={`问卷调查维护`}
64
+      width={600}
65
+      open={show}
66
+      form={form}
67
+      onFinish={onFinish}
68
+      onOpenChange={setShow}
69
+      trigger={(
70
+        <>
71
+          <span style={{ display: 'inline-block', marginLeft: '1em' }}>{`预收 ${checkItem?.num || 0} 份`}</span>
72
+          <Button type="link" size="middle" loading={loading} onClick={onClick}>
73
+            <EditOutlined />
74
+          </Button>
75
+        </>
76
+      )}
77
+    >
78
+      <ProFormDigit label="预收数量" name="num" min={1} fieldProps={{precision: 0}} />
79
+    </ModalForm>
80
+  )
81
+}
82
+
83
+export default SurveyForm;

+ 2
- 0
src/pages/check/index.jsx Vedi File

@@ -69,11 +69,13 @@ export default (props) => {
69 69
       title: "实地测评得分",
70 70
       dataIndex: "locScore",
71 71
       hideInSearch: true,
72
+      render: (_, row) => (row.locScore || 0) * (row.locScorePercent || 0),
72 73
     },
73 74
     {
74 75
       title: "调查问卷得分",
75 76
       dataIndex: "surveyScore",
76 77
       hideInSearch: true,
78
+      render: (_, row) => (row.surveyScore || 0) * (row.surveyScorePercent || 0),
77 79
     },
78 80
     {
79 81
       title: "状态",