Yansen 2 anni fa
parent
commit
38e955dd89

+ 6
- 1
src/layouts/index.jsx Vedi File

@@ -8,8 +8,10 @@ import Auth from '@/components/Auth';
8 8
 import TabBar from './TabBar';
9 9
 import laySty from './layout.module.less';
10 10
 
11
+const f = x => x;
12
+
11 13
 export default (props) => {
12
-  const { className, style, roles, tabBar = false, loading } = props;
14
+  const { className, style, roles, tabBar = false, loading, onShow = f, onHide = f } = props;
13 15
 
14 16
   const { person, user, duty } = useModel('user');
15 17
 
@@ -32,6 +34,9 @@ export default (props) => {
32 34
     };
33 35
   });
34 36
 
37
+  Taro.useDidShow(onShow);
38
+  Taro.useDidHide(onHide);
39
+
35 40
   return (
36 41
     <View className={laySty['page-wrapper']}>
37 42
       <Notify id="vanNotify" />

+ 10
- 7
src/pages/check/edit/components/LocForm.jsx Vedi File

@@ -108,13 +108,16 @@ export default (props) => {
108 108
           </CellGroup>
109 109
         )
110 110
       }
111
-      <CellGroup style={{ marginTop: '20px' }}>
112
-        <Field
113
-          value="您已完成X份"
114
-          inputAlign="center"
115
-          readonly
116
-        />
117
-      </CellGroup>
111
+      {
112
+        checkType == 'survey' && (
113
+          <CellGroup style={{ marginTop: '20px' }}>
114
+            <Cell
115
+              title="已完成"
116
+              value={`${checkItemInfo?.answerNum || 0} 份`}
117
+            />
118
+          </CellGroup>
119
+        )
120
+      }
118 121
     </View >
119 122
   )
120 123
 }

+ 10
- 2
src/pages/home/components/StatCard.jsx Vedi File

@@ -4,7 +4,7 @@ import { ROLE_CITIZEN } from '@/utils/user';
4 4
 import { getIndexData } from '@/services/stat';
5 5
 import style from './stat-card.module.less';
6 6
 
7
-export default (props) => {
7
+export default React.forwardRef((props, ref) => {
8 8
   const { duty } = props;
9 9
 
10 10
   const [list, setList] = React.useState([]);
@@ -22,6 +22,14 @@ export default (props) => {
22 22
     }
23 23
   }, [duty]);
24 24
 
25
+  React.useImperativeHandle(ref, () => ({
26
+    refresh: () => {
27
+      if (duty) {
28
+        getIndexData(duty).then(setList);
29
+      }
30
+    }
31
+  }), [duty]);
32
+
25 33
   return (
26 34
     <View className={classNames}>
27 35
       <View className={style['stat-card']}>
@@ -36,4 +44,4 @@ export default (props) => {
36 44
       </View>
37 45
     </View>
38 46
   )
39
-}
47
+})

+ 7
- 2
src/pages/home/index.jsx Vedi File

@@ -74,6 +74,7 @@ const menus = {
74 74
 
75 75
 export default (props) => {
76 76
 
77
+  const statRef = React.useRef();
77 78
   const userModel = useModel('user');
78 79
   const { user, duty, signOut, changePwd } = userModel || {};
79 80
 
@@ -83,15 +84,19 @@ export default (props) => {
83 84
     return menus[duty];
84 85
   }, [duty])
85 86
 
87
+  const onShow = () => {
88
+    statRef.current?.refresh();
89
+  }
90
+
86 91
   return (
87
-    <Page tabBar="home" className="home-page">
92
+    <Page tabBar="home" className="home-page" onShow={onShow}>
88 93
       <Head
89 94
         userModel={userModel}
90 95
         onChangePwd={changePwd}
91 96
         onExit={signOut}
92 97
       />
93 98
       <Banner duty={duty} />
94
-      <StatCard duty={duty} />
99
+      <StatCard duty={duty} ref={statRef} />
95 100
 
96 101
       <View className="menu-icons">
97 102
         {

+ 27
- 13
src/pages/user/list/index.jsx Vedi File

@@ -2,6 +2,7 @@ import React from "react";
2 2
 import Taro from "@tarojs/taro";
3 3
 import { View } from "@tarojs/components";
4 4
 import { Cell, Button, Dialog } from "@antmjs/vantui";
5
+import { ROLES } from "@/utils/user";
5 6
 import Page from "@/layouts/index";
6 7
 import PowerList from "@/components/PowerList";
7 8
 import { getSysUser, deleteSysUser } from "@/services/sysuser";
@@ -19,12 +20,12 @@ export default (props) => {
19 20
 
20 21
   const onDelete = (user) => {
21 22
     Dialog.confirm({
23
+      width: '70vw',
22 24
       title: "确认删除用户?",
23
-    }).then((e) => {
24
-      const { action } = e.detail;
25
+    }).then((action) => {
25 26
       if (action === "confirm") {
26 27
         setLoading(true);
27
-        deleteSysUser(user.id)
28
+        deleteSysUser(user.userId)
28 29
           .then(() => {
29 30
             setLoading(false);
30 31
 
@@ -38,8 +39,12 @@ export default (props) => {
38 39
     });
39 40
   };
40 41
 
42
+  const onShow = () => {
43
+    listRef.current.refresh();
44
+  }
45
+
41 46
   return (
42
-    <Page loading={loading}>
47
+    <Page loading={loading} onShow={onShow}>
43 48
       <view className={styles["user-warpper"]}>
44 49
         <view className={styles["user-warpper-list"]}>
45 50
           <PowerList
@@ -49,17 +54,26 @@ export default (props) => {
49 54
             renderItem={(item) => (
50 55
               <Cell
51 56
                 key={item.userId}
52
-                title={item.name}
57
+                title={`${item.name} ${item.phone}`}
53 58
                 label={item.createDate.substring(0, 10)}
54 59
               >
55
-                <Button
56
-                  plain
57
-                  type="danger"
58
-                  size="small"
59
-                  onClick={() => onDelete(item)}
60
-                >
61
-                  删除
62
-                </Button>
60
+                <View>
61
+                  <View>
62
+                    {
63
+                      item.dutyList?.map(x => ROLES[x]).join(' ')
64
+                    }
65
+                  </View>
66
+                  <View>
67
+                    <Button
68
+                      plain
69
+                      type="danger"
70
+                      size="small"
71
+                      onClick={() => onDelete(item)}
72
+                    >
73
+                      删除
74
+                    </Button>
75
+                  </View>
76
+                </View>
63 77
               </Cell>
64 78
             )}
65 79
           />