|
@@ -1,252 +1,250 @@
|
1
|
|
-import React from 'react';
|
2
|
|
-import Map from '@/components/map';
|
3
|
|
-import Page from '@/layouts/index';
|
4
|
|
-import { Button, Field, Cell, CellGroup, Row, Col, Image } from '@antmjs/vantui';
|
5
|
|
-import mapIcon from '@/assets/icons/marker.png';
|
6
|
|
-import LocType from '@/components/LocType';
|
7
|
|
-import { View, Input } from '@tarojs/components';
|
8
|
|
-import Uploader from '@/components/Uploader/index';
|
9
|
|
-import ScrollPage from '@/components/ScrollPage/index';
|
10
|
|
-import icon from '@/assets/icons/box.png';
|
11
|
|
-import Choice from "./components/Choice";
|
12
|
|
-
|
13
|
|
-export default (props) => {
|
14
|
|
- const {
|
15
|
|
- issue,
|
16
|
|
- readOnly,
|
17
|
|
- showOrg,
|
18
|
|
- showExpireDate,
|
19
|
|
- renderFields,
|
20
|
|
- renderAction,
|
21
|
|
- } = props;
|
22
|
|
-
|
23
|
|
- const [inx, setInx] = React.useState(-1);
|
24
|
|
-
|
25
|
|
- const num = 1;
|
26
|
|
- const count = 15;
|
27
|
|
-
|
28
|
|
- const [formData, setFormData] = React.useState({
|
29
|
|
- typeId: undefined,
|
30
|
|
- typeName: undefined,
|
31
|
|
- locId: undefined,
|
32
|
|
- locName: undefined,
|
33
|
|
- location: undefined,
|
34
|
|
- addr: undefined,
|
35
|
|
- content: undefined,
|
36
|
|
- attachList: [],
|
37
|
|
- });
|
38
|
|
-
|
39
|
|
- const [showLocType, setShowLocType] = React.useState(false);
|
40
|
|
- const [evaluationPage, setEvaluationPage] = React.useState(true);
|
41
|
|
- const [evaluationPage2, setEvaluationPage2] = React.useState(false);
|
42
|
|
- const [evaluationPage3, setEvaluationPage3] = React.useState(false);
|
43
|
|
- const [scrollPage, setScrollPage] = React.useState(false);
|
44
|
|
-
|
45
|
|
- const onLocTypeChange = (_, it) => {
|
46
|
|
- setFormData({
|
47
|
|
- ...formData,
|
48
|
|
- locId: it.typeId,
|
49
|
|
- locName: it.name,
|
50
|
|
- });
|
51
|
|
- setShowLocType(false);
|
52
|
|
- }
|
53
|
|
-
|
54
|
|
- const setFieldChange = (field, value) => {
|
55
|
|
- setFormData({
|
56
|
|
- ...formData,
|
57
|
|
- [field]: value,
|
58
|
|
- })
|
59
|
|
- }
|
60
|
|
-
|
61
|
|
- const onChangePage = () => {
|
62
|
|
- setEvaluationPage(false);
|
63
|
|
- setEvaluationPage2(true);
|
64
|
|
- }
|
65
|
|
-
|
66
|
|
- const onChangePage2 = () => {
|
67
|
|
- setEvaluationPage2(false);
|
68
|
|
- setEvaluationPage3(true);
|
69
|
|
- }
|
70
|
|
-
|
71
|
|
- const onChangePage3 = () => {
|
72
|
|
- setEvaluationPage3(false);
|
73
|
|
- setScrollPage(true);
|
74
|
|
- }
|
75
|
|
-
|
76
|
|
- return (
|
77
|
|
- <>
|
78
|
|
- <Page>
|
79
|
|
- {
|
80
|
|
- evaluationPage && (<>
|
81
|
|
- <LocType
|
82
|
|
- show={showLocType}
|
83
|
|
- value={formData.addr}
|
84
|
|
- onCancel={() => setShowLocType(false)}
|
85
|
|
- onChange={onLocTypeChange}
|
86
|
|
- />
|
87
|
|
- <Map location={formData.location} />
|
88
|
|
- <CellGroup>
|
89
|
|
- <Cell
|
90
|
|
- title="点位"
|
91
|
|
- isLink
|
92
|
|
- value={formData.locName}
|
93
|
|
- onClick={() => !readOnly && setShowLocType(true)}
|
94
|
|
- />
|
95
|
|
- <Field
|
96
|
|
- placeholder="请输入地址"
|
97
|
|
- value={formData.addr}
|
98
|
|
- leftIcon={mapIcon}
|
99
|
|
- // readonly={readOnly}
|
100
|
|
- // onChange={e => setFieldChange('addr', e.detail)}
|
101
|
|
- />
|
102
|
|
- </CellGroup>
|
103
|
|
-
|
104
|
|
- <CellGroup style={{ padding: 'var(--main-space)', position: 'relative', top: '330px' }}>
|
105
|
|
- <Button
|
106
|
|
- type="primary"
|
107
|
|
- block
|
108
|
|
- onClick={onChangePage}
|
109
|
|
- >
|
110
|
|
- 下一步
|
111
|
|
- </Button>
|
112
|
|
- </CellGroup>
|
113
|
|
- </>)
|
114
|
|
- }
|
115
|
|
-
|
116
|
|
- {
|
117
|
|
- evaluationPage2 && (
|
118
|
|
- <View style={{ flex: '1' }}>
|
119
|
|
-
|
120
|
|
- <Choice />
|
121
|
|
-
|
122
|
|
- <CellGroup>
|
123
|
|
- <Cell title="评测标准" border={false} size="large" />
|
124
|
|
- <Row>
|
125
|
|
- <Col offset="2" span="20">
|
126
|
|
- <Cell
|
127
|
|
- title="
|
128
|
|
- 在显著位置看到市民公约或居民公约展示"
|
129
|
|
- border={false}
|
130
|
|
- style={{ paddingTop: '0px' }}
|
131
|
|
- />
|
132
|
|
- </Col>
|
133
|
|
- </Row>
|
134
|
|
- </CellGroup>
|
135
|
|
-
|
136
|
|
- <CellGroup style={{ marginTop: '20px' }}>
|
137
|
|
- <Cell title="拍照" border={false} size="large" />
|
138
|
|
-
|
139
|
|
- <Cell
|
140
|
|
- renderTitle={
|
141
|
|
- <Uploader
|
142
|
|
- value={formData.attachList}
|
143
|
|
- disabled={readOnly}
|
144
|
|
- onChange={e => setFieldChange('attachList', e)}
|
145
|
|
- />
|
146
|
|
- }
|
147
|
|
- />
|
148
|
|
- </CellGroup>
|
149
|
|
-
|
150
|
|
- <View style={{ position: 'relative', marginBottom: '20px', flex: 'none' }}>
|
151
|
|
- <View style={{ position: 'absolute', width: '100%', top: '100px' }}>
|
152
|
|
- <CellGroup style={{ marginTop: '20px', padding: 'var(--main-space)' }}>
|
153
|
|
- <Button
|
154
|
|
- type="primary"
|
155
|
|
- block
|
156
|
|
- onClick={onChangePage2}
|
157
|
|
- >
|
158
|
|
- 下一题
|
159
|
|
- </Button>
|
160
|
|
- </CellGroup>
|
161
|
|
-
|
162
|
|
- <CellGroup>
|
163
|
|
- <Cell
|
164
|
|
- style={{ textAlign: 'right' }}
|
165
|
|
- >
|
166
|
|
- <Image src={icon} width="25px" height="25px"
|
167
|
|
- style={{ verticalAlign: 'middle', marginRight: '10px' }}
|
168
|
|
- />
|
169
|
|
- {num + '/' + count}
|
170
|
|
- </Cell>
|
171
|
|
- </CellGroup>
|
172
|
|
- </View>
|
173
|
|
- </View>
|
174
|
|
- </View>)
|
175
|
|
- }
|
176
|
|
-
|
177
|
|
- {
|
178
|
|
- evaluationPage3 && (
|
179
|
|
- <ScrollPage>
|
180
|
|
- <CellGroup>
|
181
|
|
- <Cell title="测评内容" border={false} size="large" style={{ paddingBottom: '0px' }} />
|
182
|
|
- <View style={{ padding: 'var(--main-space)', paddingTop: '0px' }}>
|
183
|
|
- <View style={{ padding: 'var(--main-space)', fontSize: '14px', color: 'var(--main-bg-color)' }}>
|
184
|
|
- 垃圾乱扔,乱张贴(具体标准),测评结果:<Input type="text" style={{ width: '45px', display: 'inline-block', verticalAlign: 'middle' }} />处。(此处填写数字)
|
185
|
|
- </View>
|
186
|
|
- </View>
|
187
|
|
- </CellGroup>
|
188
|
|
-
|
189
|
|
- <CellGroup>
|
190
|
|
- <Cell title="评测标准" border={false} size="large" />
|
191
|
|
- <Row>
|
192
|
|
- <Col offset="2" span="20">
|
193
|
|
- <Cell
|
194
|
|
- title="
|
195
|
|
- (1)每看到1处垃圾乱扔(1平方米以内的垃圾算作1处)计为1处;
|
196
|
|
- (2)每看到1处乱张贴乱涂写乱刻画《1平米内出现的算作1 处在统一设置的信息栏中张贴的小广告不算作失分点)计为1处;
|
197
|
|
- (3)每看到建筑物外立面的1处大面积破损污损《高3米以上、宽2米以上)计为1处。"
|
198
|
|
- border={false}
|
199
|
|
- style={{ paddingTop: '0px' }}
|
200
|
|
- />
|
201
|
|
- </Col>
|
202
|
|
- </Row>
|
203
|
|
- </CellGroup>
|
204
|
|
-
|
205
|
|
- <CellGroup style={{ marginTop: '20px' }}>
|
206
|
|
- <Cell title="拍照" border={false} size="large" />
|
207
|
|
-
|
208
|
|
- <Cell
|
209
|
|
- renderTitle={
|
210
|
|
- <Uploader
|
211
|
|
- value={formData.attachList}
|
212
|
|
- disabled={readOnly}
|
213
|
|
- onChange={e => setFieldChange('attachList', e)}
|
214
|
|
- />
|
215
|
|
- }
|
216
|
|
- />
|
217
|
|
- </CellGroup>
|
218
|
|
-
|
219
|
|
- <CellGroup style={{ marginTop: '20px', padding: 'var(--main-space)' }}>
|
220
|
|
- <Row>
|
221
|
|
- <Col offset="1" span="10">
|
222
|
|
- <Button
|
223
|
|
- type="primary"
|
224
|
|
- block
|
225
|
|
- >
|
226
|
|
- 上一题
|
227
|
|
- </Button>
|
228
|
|
- </Col>
|
229
|
|
- <Col offset="2" span="10">
|
230
|
|
- <Button
|
231
|
|
- type="primary"
|
232
|
|
- block
|
233
|
|
- onClick={onChangePage3}
|
234
|
|
- >
|
235
|
|
- 下一题
|
236
|
|
- </Button>
|
237
|
|
- </Col>
|
238
|
|
- </Row>
|
239
|
|
- </CellGroup>
|
240
|
|
- </ScrollPage>)
|
241
|
|
- }
|
242
|
|
- </Page >
|
243
|
|
- <View>
|
244
|
|
- {
|
245
|
|
- scrollPage && (
|
246
|
|
- <ScrollPage />
|
247
|
|
- )
|
248
|
|
- }
|
249
|
|
- </View>
|
250
|
|
- </>
|
251
|
|
- )
|
252
|
|
-}
|
|
1
|
+import React from 'react';
|
|
2
|
+import Taro from '@tarojs/taro';
|
|
3
|
+import { View, ScrollView } from '@tarojs/components';
|
|
4
|
+import { Notify } from '@antmjs/vantui';
|
|
5
|
+import Page from '@/layouts/index';
|
|
6
|
+import {
|
|
7
|
+ getTaCheckItemById,
|
|
8
|
+ getTaCheckItemByCheck,
|
|
9
|
+ preCheck,
|
|
10
|
+ getTaCheckItemAnswer,
|
|
11
|
+ putTaCheckItemAnswer,
|
|
12
|
+} from '@/services/tacheckitem';
|
|
13
|
+import { getTaCheckItemQu } from '@/services/tacheckitemqu';
|
|
14
|
+import VABC from '@/components/VABC';
|
|
15
|
+import { ROLE_INSPECTOR } from '@/utils/user';
|
|
16
|
+import LocForm from './components/LocForm';
|
|
17
|
+import Question from './components/Question';
|
|
18
|
+import Footer from './components/Footer/index';
|
|
19
|
+
|
|
20
|
+export default (props) => {
|
|
21
|
+
|
|
22
|
+ const router = Taro.useRouter();
|
|
23
|
+ const { id, checkId, typ } = router.params;
|
|
24
|
+
|
|
25
|
+ const [loading, setLoading] = React.useState(false);
|
|
26
|
+ const [readonly, setReadonly] = React.useState(false);
|
|
27
|
+ const [checkItemInfo, setCheckItemInfo] = React.useState();
|
|
28
|
+ const [quList, setQuList] = React.useState([]);
|
|
29
|
+ const [index, setIndex] = React.useState(-1);
|
|
30
|
+ const [answer, setAnswer] = React.useState();
|
|
31
|
+
|
|
32
|
+ React.useMemo(() => {
|
|
33
|
+ if (typ == 'loc') {
|
|
34
|
+ Taro.setNavigationBarTitle('实地测评');
|
|
35
|
+ } else {
|
|
36
|
+ Taro.setNavigationBarTitle('调查问卷');
|
|
37
|
+ }
|
|
38
|
+ }, [typ]);
|
|
39
|
+
|
|
40
|
+ const onIndexChange = (n) => {
|
|
41
|
+ if (index == -1 && n != -1) {
|
|
42
|
+ if (!readonly) {
|
|
43
|
+ if (!answer?.addr) {
|
|
44
|
+ Notify.show({
|
|
45
|
+ message: typ == 'loc' ? '请填写地址' : '请填写小区名称',
|
|
46
|
+ type: 'warning',
|
|
47
|
+ })
|
|
48
|
+ return;
|
|
49
|
+ }
|
|
50
|
+ if (!answer?.location) {
|
|
51
|
+ Notify.show({
|
|
52
|
+ message: '未能获取定位信息, 请重试',
|
|
53
|
+ type: 'warning',
|
|
54
|
+ })
|
|
55
|
+ return;
|
|
56
|
+ }
|
|
57
|
+ }
|
|
58
|
+ }
|
|
59
|
+
|
|
60
|
+ setIndex(n);
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ const onAnswerItemChange = (answerItem, quInfo) => {
|
|
64
|
+ if (!answerItem) return;
|
|
65
|
+
|
|
66
|
+ const an = {...(answer || {})}
|
|
67
|
+ const answerItemList = an.answerItemList || []
|
|
68
|
+
|
|
69
|
+ if ((answerItem.answerCode || answerItem.answer) &&
|
|
70
|
+ answerItem.attachList?.length) {
|
|
71
|
+ // 说明这一题已经回答完毕
|
|
72
|
+ quInfo.finished = true
|
|
73
|
+ } else {
|
|
74
|
+ quInfo.finished = false
|
|
75
|
+ }
|
|
76
|
+
|
|
77
|
+ // 更新问题列表中是否作答的标志位
|
|
78
|
+ setQuList(quList.map(x => x.quId == quInfo.quId ? quInfo : x));
|
|
79
|
+
|
|
80
|
+ if (answerItemList.length) {
|
|
81
|
+ let found = false;
|
|
82
|
+ an.answerItemList = answerItemList.map(x => {
|
|
83
|
+ if (x.quId == answerItem.quId) {
|
|
84
|
+ found = true;
|
|
85
|
+ return answerItem;
|
|
86
|
+ } else {
|
|
87
|
+ return x;
|
|
88
|
+ }
|
|
89
|
+ });
|
|
90
|
+
|
|
91
|
+ if (!found) {
|
|
92
|
+ answerItemList.push(answerItem);
|
|
93
|
+ an.answerItemList = answerItemList;
|
|
94
|
+ }
|
|
95
|
+ } else {
|
|
96
|
+ answerItemList.push(answerItem);
|
|
97
|
+ an.answerItemList = answerItemList;
|
|
98
|
+ }
|
|
99
|
+
|
|
100
|
+ setAnswer(an);
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ // 作答
|
|
104
|
+ const onSubmit = () => {
|
|
105
|
+ if (readonly) return;
|
|
106
|
+
|
|
107
|
+ const finished = quList.filter(x => x.finished).length == quList.length;
|
|
108
|
+ if (!answer || !answer.answerItemList || !finished) {
|
|
109
|
+ Notify.show({
|
|
110
|
+ message: '请作答完成所有题目',
|
|
111
|
+ type: 'warning',
|
|
112
|
+ })
|
|
113
|
+ return;
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ setLoading(true);
|
|
117
|
+ putTaCheckItemAnswer(id, answer).then(() => {
|
|
118
|
+ setLoading(false);
|
|
119
|
+ const t = setTimeout(() => {
|
|
120
|
+ clearTimeout(t);
|
|
121
|
+ Taro.navigateBack({delta: 1});
|
|
122
|
+ }, 1000);
|
|
123
|
+ }).catch(() => {
|
|
124
|
+ setLoading(false);
|
|
125
|
+ });
|
|
126
|
+ }
|
|
127
|
+
|
|
128
|
+ // 查询当前测评点位主记录
|
|
129
|
+ React.useEffect(() => {
|
|
130
|
+ if (id) {
|
|
131
|
+ setLoading(true);
|
|
132
|
+ getTaCheckItemById(id).then(res => {
|
|
133
|
+ setLoading(false);
|
|
134
|
+ setCheckItemInfo(res);
|
|
135
|
+ }).catch(() => {
|
|
136
|
+ setLoading(false);
|
|
137
|
+ });
|
|
138
|
+ }
|
|
139
|
+ }, [id]);
|
|
140
|
+
|
|
141
|
+ // 查询当前测评调查问卷主记录
|
|
142
|
+ React.useEffect(() => {
|
|
143
|
+ if (checkId && typ == 'survey') {
|
|
144
|
+ setLoading(true);
|
|
145
|
+ getTaCheckItemByCheck(checkId, typ).then(res => {
|
|
146
|
+ setLoading(false);
|
|
147
|
+ setCheckItemInfo(res);
|
|
148
|
+ }).catch(() => {
|
|
149
|
+ setLoading(false);
|
|
150
|
+ });
|
|
151
|
+ }
|
|
152
|
+ }, [checkId, typ]);
|
|
153
|
+
|
|
154
|
+ // 查询其他信息
|
|
155
|
+ React.useEffect(() => {
|
|
156
|
+ if (checkItemInfo?.itemId) {
|
|
157
|
+ const { itemId } = checkItemInfo;
|
|
158
|
+ setLoading(true);
|
|
159
|
+
|
|
160
|
+ preCheck(itemId, { noSuccesTip: true }).then((checkRes) => {
|
|
161
|
+ if (checkRes.errorCode < 0) {
|
|
162
|
+ setLoading(false);
|
|
163
|
+ Notify.show({
|
|
164
|
+ message: checkRes.message,
|
|
165
|
+ type: 'warning',
|
|
166
|
+ })
|
|
167
|
+
|
|
168
|
+ Taro.navigateBack({delta: 1})
|
|
169
|
+ return;
|
|
170
|
+ }
|
|
171
|
+
|
|
172
|
+ if (checkRes.errorCode > 0) {
|
|
173
|
+ setReadonly(true);
|
|
174
|
+ // Notify.show({
|
|
175
|
+ // message: checkRes.message,
|
|
176
|
+ // type: 'warning',
|
|
177
|
+ // })
|
|
178
|
+ }
|
|
179
|
+
|
|
180
|
+ // 查询我的答案
|
|
181
|
+ getTaCheckItemAnswer(itemId).then(setAnswer);
|
|
182
|
+
|
|
183
|
+ // 查询当前测评主记录的所有问题
|
|
184
|
+ getTaCheckItemQu({pageSize: 200, itemId}).then(res => {
|
|
185
|
+ setLoading(false);
|
|
186
|
+ setQuList(res.records || []);
|
|
187
|
+ }).catch(() => {
|
|
188
|
+ setLoading(false);
|
|
189
|
+ });
|
|
190
|
+
|
|
191
|
+ }).catch(() => {
|
|
192
|
+ setLoading(false);
|
|
193
|
+ });
|
|
194
|
+ }
|
|
195
|
+ }, [checkItemInfo]);
|
|
196
|
+
|
|
197
|
+ return (
|
|
198
|
+ <Page loading={loading} roles={[ROLE_INSPECTOR]}>
|
|
199
|
+ <VABC
|
|
200
|
+ footer={(
|
|
201
|
+ <Footer
|
|
202
|
+ value={index}
|
|
203
|
+ readonly={readonly}
|
|
204
|
+ list={quList}
|
|
205
|
+ onChange={onIndexChange}
|
|
206
|
+ onSubmit={onSubmit}
|
|
207
|
+ />
|
|
208
|
+ )}
|
|
209
|
+ >
|
|
210
|
+ <ScrollView scrollY style={{height: '100%'}}>
|
|
211
|
+ {
|
|
212
|
+ index == -1 && (
|
|
213
|
+ <LocForm
|
|
214
|
+ checkType={typ}
|
|
215
|
+ readonly={readonly}
|
|
216
|
+ checkItemInfo={checkItemInfo}
|
|
217
|
+ answer={answer}
|
|
218
|
+ onChange={setAnswer}
|
|
219
|
+ onLoadingChange={setLoading}
|
|
220
|
+ />
|
|
221
|
+ )
|
|
222
|
+ }
|
|
223
|
+ {
|
|
224
|
+ quList.map((x, inx) => {
|
|
225
|
+ const answerItem = answer?.answerItemList?.filter(y => y.quId == x.quId)[0];
|
|
226
|
+
|
|
227
|
+ return (
|
|
228
|
+ index == inx && (
|
|
229
|
+ <Question
|
|
230
|
+ key={x.quId}
|
|
231
|
+ cursor={inx}
|
|
232
|
+ readonly={readonly}
|
|
233
|
+ quInfo={x}
|
|
234
|
+ answerItem={answerItem}
|
|
235
|
+ total={quList?.length}
|
|
236
|
+ onChange={e => onAnswerItemChange(e, x)}
|
|
237
|
+ onPrev={() => onIndexChange(null, -1)}
|
|
238
|
+ onNext={() => onIndexChange(null, 1)}
|
|
239
|
+ onLoadingChange={setLoading}
|
|
240
|
+ />
|
|
241
|
+ )
|
|
242
|
+ )
|
|
243
|
+ })
|
|
244
|
+ }
|
|
245
|
+
|
|
246
|
+ </ScrollView>
|
|
247
|
+ </VABC>
|
|
248
|
+ </Page>
|
|
249
|
+ )
|
|
250
|
+}
|