Yansen 2 jaren geleden
bovenliggende
commit
c6c0387058

+ 2
- 0
src/app.config.js Bestand weergeven

@@ -20,6 +20,8 @@ export default defineAppConfig({
20 20
     'pages/reporting/detail/index',
21 21
     'pages/reset-password/index',
22 22
     'pages/check/list/index',
23
+    'pages/check/loc/list/index',
24
+    'pages/check/loc/edit/index',
23 25
     'pages/check/edit/index',
24 26
   ],
25 27
   window: {

+ 18
- 16
src/components/Pickerful/index.jsx Bestand weergeven

@@ -44,22 +44,24 @@ export default (props) => {
44 44
           onSearch={onSearch}
45 45
           clearable
46 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>
47
+        <View style={{ flex: 1, overflow: 'hidden' }}>
48
+          <ScrollView scrollY style={{ height: '100%' }}>
49
+            {
50
+              list.map(item => (
51
+                <Cell
52
+                  key={item[keyValue]}
53
+                  title={item[labelValue]}
54
+                  renderRightIcon={
55
+                    checked && checked[keyValue] == item[keyValue] ?
56
+                    <Icon name="success" color="#1A7565" /> :
57
+                    null
58
+                  }
59
+                  onClick={() => setChecked(item)}
60
+                />
61
+              ))
62
+            }
63
+          </ScrollView>
64
+        </View>
63 65
         <View style={{ padding: '8px 2em' }}>
64 66
           <Button block type="primary" disabled={!checked} onClick={onClick}>确定</Button>
65 67
         </View>

+ 1
- 2
src/components/Pickerful/style.module.less Bestand weergeven

@@ -1,8 +1,7 @@
1 1
 
2 2
 .pickerful-box {
3 3
   width: 90vw;
4
-  height: 100vh;
5
-  padding-bottom: env(safe-area-inset-bottom);
4
+  height: 100%;
6 5
   display: flex;
7 6
   flex-direction: column;
8 7
 

+ 2
- 1
src/components/map/index.jsx Bestand weergeven

@@ -6,7 +6,7 @@ import iconPath from '@/assets/icons/marker.png';
6 6
 import style from './style.module.less';
7 7
 
8 8
 export default (props) => {
9
-  const { location } = props;
9
+  const { location, onLocChange } = props;
10 10
 
11 11
   const [currentPos, setCurPos] = React.useState();
12 12
   const [lngLat, setLngLat] = React.useState([,]);
@@ -39,6 +39,7 @@ export default (props) => {
39 39
   React.useEffect(() => {
40 40
     getLocation().then((res) => {
41 41
       setCurPos(res);
42
+      onLocChange([res.longitude, res.latitude].join(','))
42 43
     }).catch((err) => {
43 44
       Taro.showToast({
44 45
         title: '定位失败',

+ 51
- 0
src/pages/check/list/components/Card.jsx Bestand weergeven

@@ -0,0 +1,51 @@
1
+import React from 'react';
2
+import Taro from '@tarojs/taro';
3
+import { View, Text } from '@tarojs/components';
4
+import { Cell, Button } from '@antmjs/vantui';
5
+import style from './style.module.less';
6
+
7
+export default (props) => {
8
+  const { detail, onClick } = props;
9
+
10
+  const handleClick = (e) => {
11
+    if (onClick) {
12
+      onClick(e)
13
+    }
14
+  }
15
+  
16
+  return (
17
+    <View className={style['check-card-wrapper']}>
18
+      <Cell
19
+        renderTitle={(
20
+          <View className={style['check-card-title']}>
21
+            <View>{detail?.title}</View>
22
+            <View className={style['check-card-subtitle']}>
23
+              <View>{detail?.startDate}</View>
24
+              <View>{detail?.endDate}</View>
25
+            </View>
26
+          </View>
27
+        )}
28
+        renderLabel={(
29
+          <View className={style['check-card-actions']}>
30
+            <View>
31
+              <Button
32
+                plain
33
+                type="primary"
34
+                icon="location-o"
35
+                onClick={() => handleClick('loc')}
36
+              >实地测评</Button>
37
+            </View>
38
+            <View>
39
+              <Button
40
+                plain
41
+                type="primary"
42
+                icon="orders-o"
43
+                onClick={() => handleClick('survey')}
44
+              >调查问卷</Button>
45
+            </View>
46
+          </View>
47
+        )}
48
+      />
49
+    </View>
50
+  )
51
+}

+ 39
- 0
src/pages/check/list/components/style.module.less Bestand weergeven

@@ -0,0 +1,39 @@
1
+
2
+.check-card-wrapper {
3
+  width: calc(100% - var(--main-space) * 2);
4
+  margin: var(--main-space);
5
+  background: #FFFFFF;
6
+  box-shadow: 0px 18px 22px 1px rgba(0,0,0,0.06);
7
+  border-radius: 8px;
8
+  overflow: hidden;
9
+
10
+  .check-card-title {
11
+    font-size: 30px;
12
+    color: #333;
13
+
14
+    display: flex;
15
+
16
+    & > View {
17
+      flex: 1;
18
+    }
19
+
20
+    .check-card-subtitle {
21
+      flex: none;
22
+      font-size: 24px;
23
+      color: #757575;
24
+      margin-left: 1em;
25
+    }
26
+  }
27
+
28
+  .check-card-actions {
29
+    display: flex;
30
+    align-items: center;
31
+    width: 100%;
32
+
33
+    & > view {
34
+      flex: 1;
35
+      text-align: center;
36
+      font-size: 28px;
37
+    }
38
+  }
39
+}

+ 19
- 10
src/pages/check/list/index.jsx Bestand weergeven

@@ -5,20 +5,29 @@ import { ROLE_INSPECTOR, ROLE_MANAGER } from '@/utils/user';
5 5
 import { View } from '@tarojs/components';
6 6
 import Taro from '@tarojs/taro';
7 7
 import PowerList from '@/components/PowerList';
8
-import List from "../components/List";
9
-
8
+import { getTaCheck } from '@/services/tacheck';
9
+import Card from './components/Card';
10 10
 
11
+const queryParams = {isValid: true};
11 12
 export default (props) => {
13
+
14
+  const onClick = (typ, item) => {
15
+    if (typ == 'loc') {
16
+      Taro.navigateTo({
17
+        url: `/pages/check/loc/list/index?checkId=${item.checkId}`
18
+      })
19
+    }
20
+  }
21
+
12 22
   return (
13 23
     <Page roles={[ROLE_INSPECTOR]}>
14
-      <Tabs sticky>
15
-        <Tab title="实地测评">
16
-          <List />
17
-        </Tab>
18
-        <Tab title="问卷调查">
19
-
20
-        </Tab>
21
-      </Tabs>
24
+      <PowerList
25
+        request={getTaCheck}
26
+        params={queryParams}
27
+        renderItem={item => (
28
+          <Card key={item.checkId} detail={item} onClick={(e) => onClick(e, item)} />
29
+        )}
30
+      />
22 31
     </Page>
23 32
   )
24 33
 }

+ 32
- 0
src/pages/check/loc/edit/components/FormTpl.jsx Bestand weergeven

@@ -0,0 +1,32 @@
1
+import React from 'react';
2
+import Taro from '@tarojs/taro';
3
+import { View, ScrollView } from '@tarojs/components';
4
+
5
+const fullHeight = {
6
+  height: '100%',
7
+}
8
+
9
+const fmBdStyle = {
10
+  height: 'calc(100% - 80px)',
11
+}
12
+
13
+const fmActStyle = {
14
+  padding: 'var(--main-space)',
15
+  height: '80px',
16
+}
17
+
18
+export default (props) => {
19
+
20
+  const { action } = props;
21
+  
22
+  return (
23
+    <View style={fullHeight}>
24
+      <View style={fmBdStyle}>
25
+        <ScrollView scrollY style={fullHeight}>
26
+          {props.children}
27
+        </ScrollView>
28
+      </View>
29
+      <View style={fmActStyle}>{action}</View>
30
+    </View>
31
+  )
32
+}

+ 42
- 0
src/pages/check/loc/edit/components/LocForm.jsx Bestand weergeven

@@ -0,0 +1,42 @@
1
+import React from 'react';
2
+import Taro from '@tarojs/taro';
3
+import { View } from '@tarojs/components';
4
+import { CellGroup, Cell, Field, Button } from '@antmjs/vantui';
5
+import Map from '@/components/map';
6
+import mapIcon from '@/assets/icons/marker.png';
7
+import FormTpl from './FormTpl';
8
+
9
+export default (props) => {
10
+
11
+  const { detail, onDetailChange, onClick } = props;
12
+  
13
+  const setFieldChange = (key, val) => {
14
+    onDetailChange({
15
+      ...detail,
16
+      [key]: val,
17
+    })
18
+  }
19
+  
20
+  return (
21
+    <FormTpl
22
+      action={(
23
+        <Button block type="primary" onClick={onClick}>下一步</Button>
24
+      )}
25
+    >
26
+      <Map onLocChange={e => setFieldChange('location', e)} />
27
+      <CellGroup>
28
+        <Cell
29
+          isLink
30
+          title="点位"
31
+          value={detail?.name}
32
+        />
33
+        <Field
34
+          placeholder="请输入地址"
35
+          value={detail?.addr}
36
+          leftIcon={mapIcon}
37
+          onChange={e => setFieldChange('addr', e.detail)}
38
+        />
39
+      </CellGroup>
40
+    </FormTpl>
41
+  )
42
+}

+ 4
- 0
src/pages/check/loc/edit/index.config.js Bestand weergeven

@@ -0,0 +1,4 @@
1
+// eslint-disable-next-line no-undef
2
+export default definePageConfig({
3
+  navigationBarTitleText: '实地测评'
4
+})

+ 41
- 0
src/pages/check/loc/edit/index.jsx Bestand weergeven

@@ -0,0 +1,41 @@
1
+import React from 'react';
2
+import Taro from '@tarojs/taro';
3
+import { View } from '@tarojs/components';
4
+import Page from '@/layouts/index';
5
+import { getTaCheckItemById, preCheck } from '@/services/tacheckitem';
6
+import { getTaCheckItemQu } from '@/services/tacheckitemqu';
7
+import LocForm from './components/LocForm';
8
+
9
+export default (props) => {
10
+
11
+  const router = Taro.useRouter();
12
+  const { id } = router.params;
13
+
14
+  const [loading, setLoading] = React.useState(false);
15
+  const [checkInfo, setCheckInfo] = React.useState();
16
+  const [quList, setQuList] = React.useState([]);
17
+
18
+  React.useEffect(() => {
19
+    setLoading(true);
20
+    preCheck(id).then(() => {
21
+      getTaCheckItemById(id).then(res => {
22
+        setCheckInfo(res);
23
+      });
24
+  
25
+      getTaCheckItemQu({pageSize: 200, itemId: id}).then(res => {
26
+        setLoading(false);
27
+        setQuList(res.records || []);
28
+      }).catch(() => {
29
+        setLoading(false);
30
+      });
31
+    }).catch(() => {
32
+      setLoading(false);
33
+    });
34
+  }, [id]);
35
+  
36
+  return (
37
+    <Page loading={loading}>
38
+      <LocForm />
39
+    </Page>
40
+  )
41
+}

+ 4
- 0
src/pages/check/loc/list/index.config.js Bestand weergeven

@@ -0,0 +1,4 @@
1
+// eslint-disable-next-line no-undef
2
+export default definePageConfig({
3
+  navigationBarTitleText: '实地测评'
4
+})

+ 37
- 0
src/pages/check/loc/list/index.jsx Bestand weergeven

@@ -0,0 +1,37 @@
1
+import React from 'react';
2
+import Taro from '@tarojs/taro';
3
+import { View } from '@tarojs/components';
4
+import { Cell } from '@antmjs/vantui';
5
+import Page from '@/layouts/index';
6
+import PowerList from '@/components/PowerList';
7
+import { getTaCheckItem } from '@/services/tacheckitem';
8
+
9
+export default (props) => {
10
+
11
+  const router = Taro.useRouter();
12
+  const { checkId } = router.params;
13
+
14
+  const params = React.useMemo(() => ({
15
+    checkId,
16
+    itemType: 'loc',
17
+    pageSize: 100,
18
+  }), [checkId]);
19
+
20
+  const onClick = (item) => {
21
+    Taro.navigateTo({
22
+      url: `/pages/check/loc/edit/index?id=${item.itemId}`
23
+    })
24
+  }
25
+  
26
+  return (
27
+    <Page>
28
+      <PowerList
29
+        request={getTaCheckItem}
30
+        params={params}
31
+        renderItem={item => (
32
+          <Cell key={item.itemId} title={item.name} onClick={() => onClick(item)} />
33
+        )}
34
+      />
35
+    </Page>
36
+  )
37
+}

+ 1
- 1
src/pages/issue/components/Issue/index.jsx Bestand weergeven

@@ -108,7 +108,7 @@ export default (props) => {
108 108
     <View>
109 109
       <LocType
110 110
         show={showLocType}
111
-        value={formData.addr}
111
+        value={formData.locId}
112 112
         onCancel={() => setShowLocType(false)}
113 113
         onChange={onLocTypeChange}
114 114
       />

+ 29
- 0
src/services/tacheck.js Bestand weergeven

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

+ 31
- 0
src/services/tacheckitem.js Bestand weergeven

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

+ 29
- 0
src/services/tacheckitemqu.js Bestand weergeven

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

+ 1
- 1
src/utils/request.js Bestand weergeven

@@ -53,7 +53,7 @@ export default function request(api, options = {}) {
53 53
       }
54 54
 
55 55
       if (data.code === 1000) {
56
-        if (data.data.token) {
56
+        if (data.data?.token) {
57 57
           setToken(data.data.token);
58 58
         }
59 59