Your Name пре 2 година
родитељ
комит
15c5e49ac6

+ 5
- 1
src/app.config.js Прегледај датотеку

@@ -5,6 +5,7 @@ export default defineAppConfig({
5 5
     'pages/index3/index',
6 6
     'pages/index4/index',
7 7
     'pages/index5/index',
8
+    'pages/issue/add/index',
8 9
     'pages/reporting/index',
9 10
     'pages/reporting/detail/index',
10 11
     'pages/reset-password/index',
@@ -57,5 +58,8 @@ export default defineAppConfig({
57 58
   },
58 59
   requiredPrivateInfos: [
59 60
     'getLocation'
60
-  ]
61
+  ],
62
+  setting: {
63
+    urlCheck: false,
64
+  }
61 65
 })

BIN
src/assets/icons/marker.png Прегледај датотеку


+ 69
- 0
src/components/Pickerful/index.jsx Прегледај датотеку

@@ -0,0 +1,69 @@
1
+import React from 'react';
2
+import { View, ScrollView } from '@tarojs/components';
3
+import { Button, Popup, Search, Cell, Icon } from '@antmjs/vantui';
4
+import style from './style.module.less';
5
+
6
+export default (props) => {
7
+  const { show, value, keyValue, labelValue = 'name', dictAPI, onChange, onCancel } = props;
8
+
9
+  const [dict, setDict] = React.useState([]);
10
+  const [checked, setChecked] = React.useState();
11
+  const [searchText, setSearchText] = React.useState('')
12
+  const onSearch = () => {
13
+    // todo
14
+  }
15
+
16
+  const list = React.useMemo(() => {
17
+    if (!searchText) return dict;
18
+    return dict.filter(x => x.name.indexOf(searchText) > -1);
19
+  }, [searchText, dict]);
20
+
21
+  const onClick = () => {
22
+    if (!checked) return;
23
+    onChange(checked[keyValue], checked)
24
+  }
25
+
26
+  React.useEffect(() => {
27
+    dictAPI({pageSize: 500}).then(res => {
28
+      setDict(res.records || []);
29
+    })
30
+  }, []);
31
+
32
+  React.useEffect(() => {
33
+    if (value && dict) {
34
+      setChecked(dict.filter(x => x[keyValue] == value)[0]);
35
+    }
36
+  }, [value, dict]);
37
+  
38
+  return (
39
+    <Popup position="right" show={show} onClose={onCancel}>
40
+      <View className={style['pickerful-box']}>
41
+        <Search
42
+          onChange={(e) => setSearchText(e.detail)}
43
+          placeholder="请输入搜索关键词"
44
+          onSearch={onSearch}
45
+          clearable
46
+        />
47
+        <ScrollView scrollY style={{ flex: 1 }}>
48
+          {
49
+            list.map(item => (
50
+              <Cell
51
+                key={item[keyValue]}
52
+                title={item[labelValue]}
53
+                renderRightIcon={
54
+                  checked && checked[keyValue] == item[keyValue] ?
55
+                  <Icon name="success" color="#1A7565" /> :
56
+                  null
57
+                }
58
+                onClick={() => setChecked(item)}
59
+              />
60
+            ))
61
+          }
62
+        </ScrollView>
63
+        <View style={{ padding: '8px 2em' }}>
64
+          <Button block type="primary" disabled={!checked} onClick={onClick}>确定</Button>
65
+        </View>
66
+      </View>
67
+    </Popup>
68
+  )
69
+}

+ 12
- 0
src/components/Pickerful/style.module.less Прегледај датотеку

@@ -0,0 +1,12 @@
1
+
2
+.pickerful-box {
3
+  width: 90vw;
4
+  height: 100vh;
5
+  display: flex;
6
+  flex-direction: column;
7
+
8
+  & > view {
9
+    flex: none;
10
+  }
11
+}
12
+

+ 9
- 0
src/components/issueType/index.jsx Прегледај датотеку

@@ -0,0 +1,9 @@
1
+import React from 'react';
2
+import Pickerful from '@/components/Pickerful';
3
+import { getTdIssueType } from '@/services/tdissuetype';
4
+
5
+export default (props) => {
6
+  return (
7
+    <Pickerful {...props} keyValue="typeId" dictAPI={getTdIssueType} />
8
+  )
9
+}

+ 9
- 0
src/components/locType/index.jsx Прегледај датотеку

@@ -0,0 +1,9 @@
1
+import React from 'react';
2
+import { getTdLocType } from '@/services/tdloctype';
3
+import Pickerful from '@/components/Pickerful';
4
+
5
+export default (props) => {
6
+  return (
7
+    <Pickerful {...props} keyValue="typeId" dictAPI={getTdLocType} />
8
+  )
9
+}

+ 31
- 0
src/components/map/index.jsx Прегледај датотеку

@@ -0,0 +1,31 @@
1
+import React from 'react';
2
+import { View, Map, Marker } from '@tarojs/components';
3
+import iconPath from '@/assets/icons/marker.png';
4
+import style from './style.module.less';
5
+
6
+export default (props) => {
7
+  const { location = '' } = props;
8
+  const {lng, lat} = location.split(',');
9
+
10
+  const markers = React.useMemo(() => {
11
+    if (lng == undefined || lat == undefined) return [];
12
+  
13
+    return [{
14
+      longitude: lng - 0,
15
+      latitude: lat - 0,
16
+      iconPath,
17
+      width: 50,
18
+      height: 58
19
+    }];
20
+  }, [lng, lat]);
21
+  
22
+  return (
23
+    <View className={style['map-wrapper']}>
24
+      <Map
25
+        longitude={lng}
26
+        latitude={lat}
27
+        markers={markers}
28
+      ></Map>
29
+    </View>
30
+  )
31
+}

+ 15
- 0
src/components/map/style.module.less Прегледај датотеку

@@ -0,0 +1,15 @@
1
+
2
+.map-wrapper {
3
+  width: 100%;
4
+  height: 0;
5
+  padding-bottom: 50%;
6
+  position: relative;
7
+
8
+  map {
9
+    width: 100%;
10
+    height: 100%;
11
+    position: absolute;
12
+    top: 0;
13
+    left: 0;
14
+  }
15
+}

+ 3
- 0
src/pages/issue/add/index.config.js Прегледај датотеку

@@ -0,0 +1,3 @@
1
+export default definePageConfig({
2
+  navigationBarTitleText: '我要上报'
3
+})

+ 116
- 0
src/pages/issue/add/index.jsx Прегледај датотеку

@@ -0,0 +1,116 @@
1
+import React from 'react';
2
+import Taro from '@tarojs/taro';
3
+import { View } from '@tarojs/components';
4
+import { Notify, Field, Cell, CellGroup, Uploader } from '@antmjs/vantui';
5
+import Page from '@/layouts/index';
6
+import LocType from '@/components/locType';
7
+import IssueType from '@/components/issueType';
8
+import Map from '@/components/map';
9
+import getAuthorize from '@/utils/authorize';
10
+import { ROLE_INSPECTOR } from '@/utils/user';
11
+import mapIcon from '@/assets/icons/marker.png';
12
+
13
+export default (props) => {
14
+
15
+  const [showLocType, setShowLocType] = React.useState(false);
16
+  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
+
22
+  const onLocTypeChange = (_, it) => {
23
+    setLocType(it);
24
+    setShowLocType(false);
25
+  }
26
+  const onIssueTypeChange = (_, it) => {
27
+    setIssueType(it);
28
+    setShowIssueType(false);
29
+  }
30
+  
31
+  React.useMemo(() => {
32
+    getAuthorize('scope.userLocation').then(() => {
33
+      Taro.getLocation({
34
+        success(res) {
35
+          setLoc(`${res.longitude},${res.latitude}`);
36
+        },
37
+        fail() {
38
+          Notify.show({
39
+            message: '获取位置失败, 请退出重试',
40
+            type: 'warning',
41
+          })
42
+        }
43
+      });
44
+    }).catch((err) => {
45
+      Notify.show({
46
+        message: '未能获取位置, 程序部分功能将不能正常使用',
47
+        type: 'warning',
48
+      })
49
+    });
50
+  }, []);
51
+
52
+  return (
53
+    <Page roles={[ROLE_INSPECTOR]}>
54
+      <LocType
55
+        show={showLocType}
56
+        value={locType?.typeId}
57
+        onCancel={() => setShowLocType(false)}
58
+        onChange={onLocTypeChange}
59
+      />
60
+
61
+      <IssueType
62
+        show={showIssueType}
63
+        value={issueType?.typeId}
64
+        onCancel={() => setShowIssueType(false)}
65
+        onChange={onIssueTypeChange}
66
+      />
67
+
68
+      <Map location={loc} />
69
+
70
+      <Field
71
+        value={address}
72
+        leftIcon={mapIcon}
73
+        placeholder="请输入地址"
74
+        onChange={e => setAddress(e.detail)}
75
+      />
76
+
77
+      <CellGroup style={{marginTop: '20px'}}>
78
+        <Cell
79
+          isLink
80
+          title="点位"
81
+          value={locType?.name}
82
+          onClick={() => setShowLocType(true)}
83
+        />
84
+
85
+        <Cell title="问题描述" border={false} />
86
+
87
+        <Field
88
+          type="textarea"
89
+          placeholder="请输入问题描述"
90
+          autosize={{ minHeight: '120px' }}
91
+        />
92
+      </CellGroup>
93
+      
94
+      <Cell
95
+        isLink
96
+        title="问题分类"
97
+        style={{marginTop: '20px'}}
98
+        value={issueType?.name}
99
+        onClick={() => setShowIssueType(true)}
100
+      />
101
+
102
+      
103
+      <CellGroup style={{marginTop: '20px'}}>        
104
+        <Cell title="拍照" border={false} />
105
+
106
+        <Cell
107
+          renderTitle={
108
+            <Uploader
109
+              deletable
110
+            />
111
+          }
112
+        />
113
+      </CellGroup>
114
+    </Page>
115
+  )
116
+}

+ 3
- 7
src/pages/reporting/detail/components/Map.jsx Прегледај датотеку

@@ -1,18 +1,14 @@
1 1
 import React from 'react';
2
-import { View, Map } from '@tarojs/components';
2
+import { View } from '@tarojs/components';
3
+import Map from '@/components/map';
3 4
 import style from './map.module.less';
4 5
 
5 6
 export default (props) => {
6 7
   const { location } = props;
7
-  const loc = location ? location.split(',') : [,];
8 8
   
9 9
   return (
10 10
     <View className={style['map-box']}>
11
-      <Map
12
-        className={style.map}
13
-        longitude={loc[0]}
14
-        latitude={loc[1]}
15
-      ></Map>
11
+      <Map location={location} />
16 12
       <View className={style.address}>
17 13
         阳光丽景小区
18 14
       </View>

+ 0
- 5
src/pages/reporting/detail/components/map.module.less Прегледај датотеку

@@ -2,11 +2,6 @@
2 2
 .map-box {
3 3
   width: 100vw;
4 4
 
5
-  .map {
6
-    width: 100%;
7
-    height: 50vw;
8
-  }
9
-
10 5
   .address {
11 6
     width: 100%;
12 7
     background: #fff;

+ 1
- 1
src/pages/reporting/detail/index.jsx Прегледај датотеку

@@ -1,9 +1,9 @@
1 1
 import React from 'react';
2 2
 import Taro from '@tarojs/taro';
3 3
 import { View } from '@tarojs/components';
4
+import { Notify } from '@antmjs/vantui';
4 5
 import Page from '@/layouts/index';
5 6
 import getAuthorize from '@/utils/authorize';
6
-import { Notify } from '@antmjs/vantui';
7 7
 import Map from './components/Map';
8 8
 import Issue from './components/Issue';
9 9
 

+ 26
- 0
src/services/tdissuetype.js Прегледај датотеку

@@ -0,0 +1,26 @@
1
+import request from '@/utils/request';
2
+
3
+/*
4
+ * 分页查询
5
+ */
6
+export const getTdIssueType = (params) => request('/api/tdIssueType', { params });
7
+
8
+/*
9
+ * 新增数据
10
+ */
11
+export const postTdIssueType = (data) => request('/api/tdIssueType', { data, method: 'post' });
12
+
13
+/*
14
+ * 通过ID查询单条数据
15
+ */
16
+export const getTdIssueTypeById = (id) => request(`/api/tdIssueType/${id}`);
17
+
18
+/*
19
+ * 更新数据
20
+ */
21
+export const putTdIssueType = (id, data) => request(`/api/tdIssueType/${id}`, { data, method: 'put' });
22
+
23
+/*
24
+ * 通过主键删除数据
25
+ */
26
+export const deleteTdIssueType = (id) => request(`/api/tdIssueType/${id}`, { method: 'delete' });

+ 29
- 0
src/services/tdloctype.js Прегледај датотеку

@@ -0,0 +1,29 @@
1
+import request from '@/utils/request';
2
+
3
+/*
4
+ * 分页查询
5
+ */
6
+export const getTdLocType = (params) => request('/api/tdLocType', { params });
7
+
8
+/*
9
+ * 新增数据
10
+ */
11
+export const postTdLocType = (data) => request('/api/tdLocType', { data, method: 'post' });
12
+
13
+/*
14
+ * 通过ID查询单条数据
15
+ */
16
+export const getTdLocTypeById = (id) => request(`/api/tdLocType/${id}`);
17
+
18
+/**
19
+ * 更新数据
20
+ * @param {*} id
21
+ * @param {*} data
22
+ * @returns
23
+ */
24
+export const putTdLocType = (id, data) => request(`/api/tdLocType/${id}`, { data, method: 'put' });
25
+
26
+/*
27
+ * 通过主键删除数据
28
+ */
29
+export const deleteTdLocType = (id) => request(`/api/tdLocType/${id}`, { method: 'delete' });