|
@@ -1,16 +1,31 @@
|
1
|
|
-import React from 'react';
|
2
|
|
-import Taro from '@tarojs/taro';
|
3
|
|
-import { View, CoverView } from '@tarojs/components';
|
4
|
|
-import { CellGroup, Cell, Field, RadioGroup, Radio, Icon, Loading } from '@antmjs/vantui';
|
5
|
|
-import Map from '@/components/map';
|
6
|
|
-import { getTaCheckItemAnswer } from '@/services/tacheckitem';
|
7
|
|
-import { getTaCheckAnswer } from '@/services/tacheckanswer';
|
8
|
|
-import { geocoder } from '@/utils/map';
|
9
|
|
-import mapIcon from '@/assets/icons/marker.png';
|
10
|
|
-import AgePicker from './AgePicker';
|
|
1
|
+import React from "react";
|
|
2
|
+import Taro from "@tarojs/taro";
|
|
3
|
+import { View, CoverView } from "@tarojs/components";
|
|
4
|
+import {
|
|
5
|
+ CellGroup,
|
|
6
|
+ Cell,
|
|
7
|
+ Field,
|
|
8
|
+ RadioGroup,
|
|
9
|
+ Radio,
|
|
10
|
+ Icon,
|
|
11
|
+ Loading,
|
|
12
|
+} from "@antmjs/vantui";
|
|
13
|
+import Map from "@/components/map";
|
|
14
|
+import { getTaCheckItemAnswer } from "@/services/tacheckitem";
|
|
15
|
+import { getTaCheckAnswer } from "@/services/tacheckanswer";
|
|
16
|
+import { geocoder } from "@/utils/map";
|
|
17
|
+import mapIcon from "@/assets/icons/marker.png";
|
|
18
|
+import AgePicker from "./AgePicker";
|
11
|
19
|
|
12
|
20
|
export default (props) => {
|
13
|
|
- const { checkItemInfo, checkType, answer, readonly, onChange, onLoadingChange } = props;
|
|
21
|
+ const {
|
|
22
|
+ checkItemInfo,
|
|
23
|
+ checkType,
|
|
24
|
+ answer,
|
|
25
|
+ readonly,
|
|
26
|
+ onChange,
|
|
27
|
+ onLoadingChange,
|
|
28
|
+ } = props;
|
14
|
29
|
|
15
|
30
|
const [showAgePicker, setShowAgePicker] = React.useState(false);
|
16
|
31
|
const answerRef = React.useRef();
|
|
@@ -18,28 +33,35 @@ export default (props) => {
|
18
|
33
|
|
19
|
34
|
const setLoading = (v) => {
|
20
|
35
|
if (onLoadingChange) {
|
21
|
|
- onLoadingChange(v)
|
|
36
|
+ onLoadingChange(v);
|
22
|
37
|
}
|
23
|
|
- }
|
|
38
|
+ };
|
24
|
39
|
|
25
|
40
|
const setFieldChange = (key, val) => {
|
26
|
41
|
const newAnswer = {
|
27
|
|
- ...answerRef.current || {},
|
|
42
|
+ ...(answerRef.current || {}),
|
28
|
43
|
[key]: val,
|
29
|
|
- }
|
|
44
|
+ };
|
30
|
45
|
|
31
|
46
|
answerRef.current = newAnswer;
|
32
|
47
|
onChange(newAnswer);
|
33
|
|
- }
|
|
48
|
+ };
|
34
|
49
|
|
35
|
50
|
const onLocationChange = (loc) => {
|
36
|
|
- setFieldChange('location', loc);
|
37
|
|
-
|
38
|
|
- if (checkType == 'loc' && loc) {
|
|
51
|
+ setFieldChange("location", loc);
|
|
52
|
+
|
|
53
|
+ if (checkType == "loc" && loc) {
|
39
|
54
|
// 交换经纬度位置
|
40
|
|
- const [x, y] = loc.split(',');
|
41
|
|
- const reLoc = [y, x].join(',');
|
42
|
|
- geocoder(reLoc).then(e => setFieldChange('addr', e?.address_component?.street_number || e?.address)).catch(console.error)
|
|
55
|
+ const [x, y] = loc.split(",");
|
|
56
|
+ const reLoc = [y, x].join(",");
|
|
57
|
+ geocoder(reLoc)
|
|
58
|
+ .then((e) =>
|
|
59
|
+ setFieldChange(
|
|
60
|
+ "addr",
|
|
61
|
+ e?.address_component?.street_number || e?.address
|
|
62
|
+ )
|
|
63
|
+ )
|
|
64
|
+ .catch(console.error);
|
43
|
65
|
}
|
44
|
66
|
};
|
45
|
67
|
|
|
@@ -54,77 +76,68 @@ export default (props) => {
|
54
|
76
|
<Loading type="spinner" vertical />
|
55
|
77
|
</View> */}
|
56
|
78
|
<CellGroup>
|
57
|
|
- {
|
58
|
|
- checkType == 'loc' && (
|
59
|
|
- <Cell
|
60
|
|
- title="点位"
|
61
|
|
- value={checkItemInfo?.name}
|
62
|
|
- />
|
63
|
|
- )
|
64
|
|
- }
|
65
|
|
- {
|
66
|
|
- checkType == 'survey' && (
|
67
|
|
- <Field
|
68
|
|
- key="01"
|
69
|
|
- label="社区"
|
70
|
|
- placeholder="请填写社区名称"
|
71
|
|
- readonly={readonly}
|
72
|
|
- value={answer?.communityName}
|
73
|
|
- onChange={e => setFieldChange('communityName', e.detail)}
|
74
|
|
- />
|
75
|
|
- )
|
76
|
|
- }
|
|
79
|
+ {checkType == "loc" && (
|
|
80
|
+ <Cell title="点位" value={checkItemInfo?.name} />
|
|
81
|
+ )}
|
|
82
|
+ {checkType == "survey" && <Cell title="文明用语" value={checkItemInfo?.cultureTerm} />}
|
|
83
|
+ {checkType == "survey" && (
|
|
84
|
+ <Field
|
|
85
|
+ key="01"
|
|
86
|
+ label="社区"
|
|
87
|
+ placeholder="请填写社区名称"
|
|
88
|
+ readonly={readonly}
|
|
89
|
+ value={answer?.communityName}
|
|
90
|
+ onChange={(e) => setFieldChange("communityName", e.detail)}
|
|
91
|
+ />
|
|
92
|
+ )}
|
77
|
93
|
<Field
|
78
|
94
|
key="02"
|
79
|
95
|
readonly={readonly}
|
80
|
|
- label={checkType == 'loc' ? '地址' : '小区'}
|
81
|
|
- placeholder={checkType == 'loc' ? '请输入地址' : '请填写小区名称'}
|
|
96
|
+ label={checkType == "loc" ? "地址" : "小区"}
|
|
97
|
+ placeholder={checkType == "loc" ? "请输入地址" : "请填写小区名称"}
|
82
|
98
|
value={answer?.addr}
|
83
|
|
- onChange={e => setFieldChange('addr', e.detail)}
|
|
99
|
+ onChange={(e) => setFieldChange("addr", e.detail)}
|
84
|
100
|
/>
|
85
|
101
|
</CellGroup>
|
86
|
|
- {
|
87
|
|
- checkType == 'survey' && (
|
88
|
|
- <CellGroup style={{ marginTop: '20px' }}>
|
89
|
|
- <Cell title="性别">
|
90
|
|
- <View style={{ textAlign: 'right' }}>
|
91
|
|
- <RadioGroup
|
92
|
|
- disabled={readonly}
|
93
|
|
- direction="horizontal"
|
94
|
|
- value={answer?.sex}
|
95
|
|
- style={{ display: 'inline-flex' }}
|
96
|
|
- onChange={(e) => setFieldChange('sex', e.detail)}
|
97
|
|
- >
|
98
|
|
- <Radio name="1" checkedColor="var(--main-bg-color)">男</Radio>
|
99
|
|
- <Radio name="2" checkedColor="red">女</Radio>
|
100
|
|
- </RadioGroup>
|
101
|
|
- </View>
|
102
|
|
- </Cell>
|
103
|
|
- <Cell
|
104
|
|
- title="年龄"
|
105
|
|
- isLink
|
106
|
|
- value={answer?.age}
|
107
|
|
- onClick={() => !readonly && setShowAgePicker(true)}
|
108
|
|
- />
|
109
|
|
- <AgePicker
|
110
|
|
- show={showAgePicker}
|
111
|
|
- onShowChange={setShowAgePicker}
|
112
|
|
- onChange={(e) => setFieldChange('age', e)}
|
113
|
|
- />
|
114
|
|
- </CellGroup>
|
115
|
|
- )
|
116
|
|
- }
|
|
102
|
+ {checkType == "survey" && (
|
|
103
|
+ <CellGroup style={{ marginTop: "20px" }}>
|
|
104
|
+ <Cell title="性别">
|
|
105
|
+ <View style={{ textAlign: "right" }}>
|
|
106
|
+ <RadioGroup
|
|
107
|
+ disabled={readonly}
|
|
108
|
+ direction="horizontal"
|
|
109
|
+ value={answer?.sex}
|
|
110
|
+ style={{ display: "inline-flex" }}
|
|
111
|
+ onChange={(e) => setFieldChange("sex", e.detail)}
|
|
112
|
+ >
|
|
113
|
+ <Radio name="1" checkedColor="var(--main-bg-color)">
|
|
114
|
+ 男
|
|
115
|
+ </Radio>
|
|
116
|
+ <Radio name="2" checkedColor="red">
|
|
117
|
+ 女
|
|
118
|
+ </Radio>
|
|
119
|
+ </RadioGroup>
|
|
120
|
+ </View>
|
|
121
|
+ </Cell>
|
|
122
|
+ <Cell
|
|
123
|
+ title="年龄"
|
|
124
|
+ isLink
|
|
125
|
+ value={answer?.age}
|
|
126
|
+ onClick={() => !readonly && setShowAgePicker(true)}
|
|
127
|
+ />
|
|
128
|
+ <AgePicker
|
|
129
|
+ show={showAgePicker}
|
|
130
|
+ onShowChange={setShowAgePicker}
|
|
131
|
+ onChange={(e) => setFieldChange("age", e)}
|
|
132
|
+ />
|
|
133
|
+ </CellGroup>
|
|
134
|
+ )}
|
117
|
135
|
|
118
|
|
- {
|
119
|
|
- checkType == 'survey' && (
|
120
|
|
- <CellGroup style={{ marginTop: '20px' }}>
|
121
|
|
- <Cell
|
122
|
|
- title="已完成"
|
123
|
|
- value={`${checkItemInfo?.answerNum || 0} 份`}
|
124
|
|
- />
|
125
|
|
- </CellGroup>
|
126
|
|
- )
|
127
|
|
- }
|
128
|
|
- </View >
|
129
|
|
- )
|
130
|
|
-}
|
|
136
|
+ {checkType == "survey" && (
|
|
137
|
+ <CellGroup style={{ marginTop: "20px" }}>
|
|
138
|
+ <Cell title="已完成" value={`${checkItemInfo?.answerNum || 0} 份`} />
|
|
139
|
+ </CellGroup>
|
|
140
|
+ )}
|
|
141
|
+ </View>
|
|
142
|
+ );
|
|
143
|
+};
|