|
@@ -1,38 +1,61 @@
|
1
|
1
|
import React from 'react';
|
2
|
2
|
import Taro from '@tarojs/taro';
|
3
|
3
|
import { View } from '@tarojs/components';
|
4
|
|
-import { Notify, Field, Cell, CellGroup, Uploader } from '@antmjs/vantui';
|
|
4
|
+import { Button, Notify, Field, Cell, CellGroup, Uploader } from '@antmjs/vantui';
|
5
|
5
|
import Page from '@/layouts/index';
|
6
|
6
|
import LocType from '@/components/locType';
|
7
|
7
|
import IssueType from '@/components/issueType';
|
8
|
8
|
import Map from '@/components/map';
|
|
9
|
+import ImageUploader from '@/components/Uploader/ImageUploader';
|
9
|
10
|
import getAuthorize from '@/utils/authorize';
|
10
|
11
|
import { ROLE_INSPECTOR } from '@/utils/user';
|
11
|
12
|
import mapIcon from '@/assets/icons/marker.png';
|
12
|
13
|
|
13
|
14
|
export default (props) => {
|
14
|
15
|
|
|
16
|
+ const [formData, setFormData] = React.useState({
|
|
17
|
+ typeId: undefined,
|
|
18
|
+ typeName: undefined,
|
|
19
|
+ locId: undefined,
|
|
20
|
+ locName: undefined,
|
|
21
|
+ location: undefined,
|
|
22
|
+ addr: undefined,
|
|
23
|
+ content: undefined,
|
|
24
|
+ images: [],
|
|
25
|
+ });
|
15
|
26
|
const [showLocType, setShowLocType] = React.useState(false);
|
16
|
27
|
const [showIssueType, setShowIssueType] = React.useState(false);
|
17
|
|
- const [loc, setLoc] = React.useState();
|
18
|
|
- const [locType, setLocType] = React.useState();
|
19
|
|
- const [issueType, setIssueType] = React.useState();
|
20
|
|
- const [address, setAddress] = React.useState();
|
21
|
28
|
|
22
|
29
|
const onLocTypeChange = (_, it) => {
|
23
|
|
- setLocType(it);
|
|
30
|
+ setFormData({
|
|
31
|
+ ...formData,
|
|
32
|
+ locId: it.typeId,
|
|
33
|
+ locName: it.name,
|
|
34
|
+ });
|
24
|
35
|
setShowLocType(false);
|
25
|
36
|
}
|
|
37
|
+
|
26
|
38
|
const onIssueTypeChange = (_, it) => {
|
27
|
|
- setIssueType(it);
|
|
39
|
+ setFormData({
|
|
40
|
+ ...formData,
|
|
41
|
+ typeId: it.typeId,
|
|
42
|
+ typeName: it.name,
|
|
43
|
+ });
|
28
|
44
|
setShowIssueType(false);
|
29
|
45
|
}
|
|
46
|
+
|
|
47
|
+ const onFieldChange = (field, value) => {
|
|
48
|
+ setFormData({
|
|
49
|
+ ...formData,
|
|
50
|
+ [field]: value,
|
|
51
|
+ })
|
|
52
|
+ }
|
30
|
53
|
|
31
|
54
|
React.useMemo(() => {
|
32
|
55
|
getAuthorize('scope.userLocation').then(() => {
|
33
|
56
|
Taro.getLocation({
|
34
|
57
|
success(res) {
|
35
|
|
- setLoc(`${res.longitude},${res.latitude}`);
|
|
58
|
+ onFieldChange('location', `${res.longitude},${res.latitude}`);
|
36
|
59
|
},
|
37
|
60
|
fail() {
|
38
|
61
|
Notify.show({
|
|
@@ -53,32 +76,32 @@ export default (props) => {
|
53
|
76
|
<Page roles={[ROLE_INSPECTOR]}>
|
54
|
77
|
<LocType
|
55
|
78
|
show={showLocType}
|
56
|
|
- value={locType?.typeId}
|
|
79
|
+ value={formData.addr}
|
57
|
80
|
onCancel={() => setShowLocType(false)}
|
58
|
81
|
onChange={onLocTypeChange}
|
59
|
82
|
/>
|
60
|
83
|
|
61
|
84
|
<IssueType
|
62
|
85
|
show={showIssueType}
|
63
|
|
- value={issueType?.typeId}
|
|
86
|
+ value={formData.typeName}
|
64
|
87
|
onCancel={() => setShowIssueType(false)}
|
65
|
88
|
onChange={onIssueTypeChange}
|
66
|
89
|
/>
|
67
|
90
|
|
68
|
|
- <Map location={loc} />
|
|
91
|
+ <Map location={formData.location} />
|
69
|
92
|
|
70
|
93
|
<Field
|
71
|
|
- value={address}
|
|
94
|
+ value={formData.addr}
|
72
|
95
|
leftIcon={mapIcon}
|
73
|
96
|
placeholder="请输入地址"
|
74
|
|
- onChange={e => setAddress(e.detail)}
|
|
97
|
+ onChange={e => onFieldChange('addr', e.detail)}
|
75
|
98
|
/>
|
76
|
99
|
|
77
|
100
|
<CellGroup style={{marginTop: '20px'}}>
|
78
|
101
|
<Cell
|
79
|
102
|
isLink
|
80
|
103
|
title="点位"
|
81
|
|
- value={locType?.name}
|
|
104
|
+ value={formData.locName}
|
82
|
105
|
onClick={() => setShowLocType(true)}
|
83
|
106
|
/>
|
84
|
107
|
|
|
@@ -88,6 +111,8 @@ export default (props) => {
|
88
|
111
|
type="textarea"
|
89
|
112
|
placeholder="请输入问题描述"
|
90
|
113
|
autosize={{ minHeight: '120px' }}
|
|
114
|
+ value={formData.content}
|
|
115
|
+ onChange={e => onFieldChange('content', e.detail)}
|
91
|
116
|
/>
|
92
|
117
|
</CellGroup>
|
93
|
118
|
|
|
@@ -95,7 +120,7 @@ export default (props) => {
|
95
|
120
|
isLink
|
96
|
121
|
title="问题分类"
|
97
|
122
|
style={{marginTop: '20px'}}
|
98
|
|
- value={issueType?.name}
|
|
123
|
+ value={formData.typeName}
|
99
|
124
|
onClick={() => setShowIssueType(true)}
|
100
|
125
|
/>
|
101
|
126
|
|
|
@@ -105,12 +130,14 @@ export default (props) => {
|
105
|
130
|
|
106
|
131
|
<Cell
|
107
|
132
|
renderTitle={
|
108
|
|
- <Uploader
|
109
|
|
- deletable
|
110
|
|
- />
|
|
133
|
+ <ImageUploader value={formData.images} onChange={e => onFieldChange('images',e)} />
|
111
|
134
|
}
|
112
|
135
|
/>
|
113
|
136
|
</CellGroup>
|
|
137
|
+
|
|
138
|
+ <View style={{margin: '20px auto', padding: '0 1em'}}>
|
|
139
|
+ <Button block type="primary">提交</Button>
|
|
140
|
+ </View>
|
114
|
141
|
</Page>
|
115
|
142
|
)
|
116
|
143
|
}
|