张延森 3 years ago
parent
commit
8af614af80

+ 6
- 9
src/pages/History/Item.jsx View File

@@ -6,13 +6,12 @@ import { useMemo } from 'react';
6 6
 export default (props) => {
7 7
   const { barData, person } = props;
8 8
 
9
-  const { tagShow, tagType, tagText } = useMemo(() => {
10
-    if (barData.reqStat !== '6') return { tagShow: false };
9
+  const { tagType, tagText } = useMemo(() => {
10
+    const hasReport = barData.reqStat === '6'
11 11
 
12 12
     return {
13
-      tagShow: true, 
14
-      tagType: 'success',
15
-      tagText: '阴性'
13
+      tagType: hasReport ? 'success' : undefined,
14
+      tagText: hasReport ? '阴性' : '报告未出',
16 15
      }
17 16
   }, [barData])
18 17
 
@@ -23,11 +22,9 @@ export default (props) => {
23 22
       </View>
24 23
       <View className='history-item-info'>
25 24
         <View>{person?.personName}</View>
26
-        <View>{barData.sampledDt}</View>
25
+        <View>{barData.sampledDt || <View style={{ color: 'red' }} >未采样</View>}</View>
27 26
         <View>
28
-        {
29
-          tagShow && <Tag size='large' type={tagType}>{tagText}</Tag>
30
-        }
27
+          <Tag size='large' type={tagType}>{tagText}</Tag>
31 28
         </View>
32 29
       </View>
33 30
     </View>

+ 12
- 14
src/pages/History/index.jsx View File

@@ -1,7 +1,7 @@
1 1
 import { useEffect, useState } from 'react';
2 2
 import dayjs from 'dayjs';
3 3
 import { View } from '@tarojs/components'
4
-import { PowerScrollView } from '@antmjs/vantui';
4
+import { PowerScrollView, Empty } from '@antmjs/vantui';
5 5
 import { useModel } from '@/store';
6 6
 import { getBarcode } from '@/services/user';
7 7
 import Item from './Item';
@@ -10,15 +10,7 @@ import './style.less'
10 10
 
11 11
 export default (props) => {
12 12
   const { person } = useModel('userData')
13
-  const [loading, setLoading] = useState(false)
14
-  const [list, setList] = useState([
15
-    { barcode: '32013201', sampledDt: '2022-05-15', reqStat: '0' },
16
-    { barcode: '32013202', sampledDt: '2022-05-15', reqStat: '6' },
17
-    { barcode: '32013203', sampledDt: '2022-05-15', reqStat: '6' },
18
-    { barcode: '32013204', sampledDt: '2022-05-15', reqStat: '6' },
19
-    { barcode: '32013205', sampledDt: '2022-05-15', reqStat: '6' },
20
-    { barcode: '32013206', sampledDt: '2022-05-15', reqStat: '6' },
21
-  ])
13
+  const [list, setList] = useState([])
22 14
 
23 15
   useEffect(() => {
24 16
     if (person && person.personId) {
@@ -28,17 +20,23 @@ export default (props) => {
28 20
         endDate: today.format('YYYY-MM-DD'),
29 21
         idNo: person.idNo,
30 22
       }
31
-      setLoading(true)
23
+
32 24
       getBarcode(person.personId, params).then((res) => {
33
-        setList(res || [])
34
-        setLoading(false)
25
+        if (!res) {
26
+          setList([])
27
+        } else {
28
+          setList(JSON.parse(res))
29
+        }
35 30
       }).catch(err => {
36 31
         console.error(err)
37
-        setLoading(false)
38 32
       })
39 33
     }
40 34
   }, [person])
41 35
 
36
+  if (!list || !list.length) {
37
+    <Empty description='暂无数据' />
38
+  }
39
+
42 40
   return (
43 41
     <PowerScrollView
44 42
       className='barcode-history-list'

+ 7
- 7
src/pages/index/components/QRItem.jsx View File

@@ -5,13 +5,13 @@ import { Tag } from "@antmjs/vantui"
5 5
 import './style.less'
6 6
 
7 7
 const TagStatus = {
8
-  0: '可采样',
9
-  1: '可采样',
10
-  2: '可采样',
11
-  3: '送出',
12
-  4: '接收',
13
-  5: '部分报告',
14
-  6: '确认报告',
8
+  '0': '可采样',
9
+  '1': '可采样',
10
+  '2': '可采样',
11
+  '3': '送出',
12
+  '4': '接收',
13
+  '5': '部分报告',
14
+  '6': '确认报告',
15 15
 }
16 16
 
17 17
 export default (props) => {

+ 3
- 1
src/pages/index/index.jsx View File

@@ -63,7 +63,9 @@ export default (props) => {
63 63
         }
64 64
       })
65 65
     }
66
+  }, [person])
66 67
 
68
+  useEffect(() => {
67 69
     if (user && user.userId) {
68 70
       if (!person || !person.idNo) {
69 71
         setIdCardVisible(true)
@@ -71,7 +73,7 @@ export default (props) => {
71 73
         setIdCardVisible(false)
72 74
       }
73 75
     }
74
-  }, [person, user])
76
+  }, [user, person])
75 77
 
76 78
   return (
77 79
     <View className='index-page'>

+ 1
- 1
src/services/user.js View File

@@ -42,5 +42,5 @@ export const setUserInfo = (data) => request('/person', { data, method: 'PUT' })
42 42
  */
43 43
 export const getBarcode = (id, params) => {
44 44
   const data = { queryStr : getQueryString(params) }
45
-  return request(`/person/${id}/barcode`, { data, method: 'GET' })
45
+  return request(`/person/${id}/barcode`, { data, pageLoading: true, method: 'POST' })
46 46
 }

+ 0
- 25
src/store/userData.js View File

@@ -12,12 +12,6 @@ export default () => {
12 12
   const [deptName, setDeptName] = useState()
13 13
   const [formValue, setFormValue] = useState()
14 14
 
15
-
16
-
17
-
18
-
19
-
20
-
21 15
   const logins = (params) => {
22 16
     console.log('login');
23 17
 
@@ -29,25 +23,6 @@ export default () => {
29 23
       setPerson(taPerson);
30 24
       setUser(taUser);
31 25
       setSessionKey(skey);
32
-      // if (!res.person) {
33
-      //   console.log('没有身份证',);
34
-      //   Taro.showModal({
35
-      //     title: '提示',
36
-      //     content: '未添加个人信息!',
37
-      //     showCancel: false,
38
-      //     success: function (res) {
39
-      //       if (res.confirm) {
40
-      //         Taro.redirectTo({
41
-      //           url: '/pages/setUserInfo/index'
42
-      //         })
43
-
44
-      //       }
45
-      //     }
46
-      //   })
47
-
48
-      // } else {
49
-      //   console.log('有身份证',);
50
-      // }
51 26
     })
52 27
   }
53 28
   console.log("🚀 来自store的打印 person数据formValue", person, formValue)

+ 15
- 1
src/utils/request.js View File

@@ -4,7 +4,7 @@ import { getQueryString } from './codeSegment'
4 4
 let appid
5 5
 
6 6
 export default (url, options) => {
7
-  const { params, skipError, header, ...leftOptions } = options || {}
7
+  const { params, skipError, header, pageLoading, ...leftOptions } = options || {}
8 8
   const queryStr = getQueryString(params)
9 9
 
10 10
   if (!appid) {
@@ -24,11 +24,21 @@ export default (url, options) => {
24 24
   }
25 25
 
26 26
   return new Promise((resolve, reject) => {
27
+    if (pageLoading) {
28
+      Taro.showLoading({
29
+        title: '请稍后...',
30
+      });
31
+    }
32
+
27 33
     Taro.request({
28 34
       ...leftOptions,
29 35
       url: nwUrl,
30 36
       header: nwHeader,
31 37
       success: (res) => {
38
+        if (pageLoading) {
39
+          Taro.hideLoading();
40
+        }
41
+
32 42
         const { code, message, data, token } = res.data
33 43
 
34 44
         if (token || data?.token) {
@@ -50,6 +60,10 @@ export default (url, options) => {
50 60
       },
51 61
 
52 62
       fail: (err) => {
63
+        if (pageLoading) {
64
+          Taro.hideLoading();
65
+        }
66
+
53 67
         console.error(err)
54 68
         const message = err.message || err.errMsg || err
55 69
         if (!skipError) {