张涛 11 kuukautta sitten
vanhempi
commit
d465b331c1

+ 62
- 42
src/components/OrgTree/index.jsx Näytä tiedosto

@@ -1,69 +1,89 @@
1
-import React from 'react';
2
-import Taro from '@tarojs/taro';
3
-import { Popup, Button, Cell, Icon } from '@antmjs/vantui';
4
-import { ScrollView, View } from '@tarojs/components';
5
-import { getSysOrg } from '@/services/sysorg';
6
-import VABC from '@/components/VABC';
7
-import Tree from '@/components/Tree';
8
-import { arr2Tree } from '@/utils/array';
1
+import React from "react";
2
+import Taro from "@tarojs/taro";
3
+import { Popup, Button, Cell, Icon, Empty } from "@antmjs/vantui";
4
+import { ScrollView, View } from "@tarojs/components";
5
+import { getSysOrg } from "@/services/sysorg";
6
+import VABC from "@/components/VABC";
7
+import Tree from "@/components/Tree";
8
+import { arr2Tree } from "@/utils/array";
9 9
 
10 10
 const wrapperStyle = {
11
-  width: '90vw',
12
-  height: '100vh',
13
-  paddingBottom: 'env(safe-area-inset-bottom)',
14
-}
11
+  width: "90vw",
12
+  height: "100vh",
13
+  paddingBottom: "env(safe-area-inset-bottom)",
14
+};
15 15
 
16 16
 export default function OrgTree(props) {
17 17
   const { show, onCancel, onChange } = props;
18 18
 
19 19
   const [dict, setDict] = React.useState([]);
20 20
   const [checked, setChecked] = React.useState();
21
-  
21
+
22 22
   const onSubmit = () => {
23 23
     if (!checked) return;
24
-    onChange(checked?.orgId, checked)
25
-  }
24
+    onChange(checked?.orgId, checked);
25
+  };
26 26
 
27 27
   const onCheck = (e, it) => {
28 28
     // e.stopPropagation();
29 29
     // e.preventDefault();
30 30
     setChecked(it);
31
-  }
32
-  
31
+  };
32
+
33 33
   React.useEffect(() => {
34
-    getSysOrg({pageSize: 500, isResponsible: 1, parentId: props.parentId }).then(res => {
35
-      const [treeData] = arr2Tree(res.records || [], 'orgPId', 'orgId');
36
-      console.log('-------treeData-------', treeData)
34
+    getSysOrg({
35
+      pageSize: 500,
36
+      isResponsible: 1,
37
+      parentId: props.parentId,
38
+    }).then((res) => {
39
+      const [treeData] = arr2Tree(res.records || [], "orgPId", "orgId");
40
+      console.log("-------treeData-------", treeData);
37 41
       setDict(treeData);
38
-    })
42
+    });
39 43
   }, [props.parentId]);
40 44
 
41 45
   return (
42
-    <Popup position="right" show={show} onClose={onCancel} >
46
+    <Popup position="right" show={show} onClose={onCancel}>
43 47
       <VABC
44
-        footer={(
45
-          <View style={{ padding: '8px 2em' }}>
46
-            <Button block type="primary" disabled={!checked} onClick={onSubmit}>确定</Button>
48
+        footer={
49
+          <View style={{ padding: "8px 2em" }}>
50
+            <Button block type="primary" disabled={!checked} onClick={onSubmit}>
51
+              确定
52
+            </Button>
47 53
           </View>
48
-        )}
54
+        }
49 55
         style={wrapperStyle}
50 56
       >
51
-        <ScrollView scrollY style={{ height: '100%' }}>
52
-          <Tree
53
-            data={dict}
54
-            renderTitle={(it) => (
55
-              <Cell
56
-                title={it.name}
57
-                value={(
58
-                  <View>
59
-                    { checked?.orgId == it.orgId ? <Icon name="success" color="#1A7565" /> : <View style={{ width: '100%', minHeight: '10px' }} /> }
60
-                  </View>
61
-                )}
62
-                renderIcon={it.children?.length > 0 ? <Icon name="arrow" /> : <View style={{ minWidth: '16px' }} />}
63
-                onClick={e => onCheck(e, it)}
64
-              />
65
-            )}
66
-          />
57
+        <ScrollView scrollY style={{ height: "100%" }}>
58
+          {dict.length == 0 ? (
59
+            <Empty description="暂无数据" />
60
+          ) : (
61
+            <Tree
62
+              data={dict}
63
+              renderTitle={(it) => (
64
+                <Cell
65
+                  title={it.name}
66
+                  value={
67
+                    <View>
68
+                      {checked?.orgId == it.orgId ? (
69
+                        <Icon name="success" color="#1A7565" />
70
+                      ) : (
71
+                        <View style={{ width: "100%", minHeight: "10px" }} />
72
+                      )}
73
+                    </View>
74
+                  }
75
+                  renderIcon={
76
+                    it.children?.length > 0 ? (
77
+                      <Icon name="arrow" />
78
+                    ) : (
79
+                      <View style={{ minWidth: "16px" }} />
80
+                    )
81
+                  }
82
+                  onClick={(e) => onCheck(e, it)}
83
+                />
84
+              )}
85
+            />
86
+          )}
67 87
         </ScrollView>
68 88
       </VABC>
69 89
     </Popup>

+ 16
- 21
src/layouts/index.jsx Näytä tiedosto

@@ -12,7 +12,7 @@ import { useEffect } from "react";
12 12
 export default (props) => {
13 13
   const { className, style, roles, tabBar = false, loading } = props;
14 14
 
15
-  const { person, user, duty, current } = useModel("user");
15
+  const { person, user, duty, current, setUser, initDuty } = useModel("user");
16 16
 
17 17
   const containerClass = `${laySty["page-conatiner"]} ${
18 18
     tabBar ? laySty["with-tabbar"] : ""
@@ -22,26 +22,21 @@ export default (props) => {
22 22
 
23 23
   React.useEffect(() => {
24 24
     const isLoginPage = currentPage.route.includes("pages/login/index");
25
-
25
+console.log(isLoginPage)
26 26
     if (!user) {
27
-      try {
28
-        current()
29
-          .then((res) => {
30
-            console.log("---当前人员----", res);
31
-          })
32
-          .catch((err) => {
33
-            console.log("---当前人员--报错了--");
34
-            console.error(err);
35
-
36
-            if (!isLoginPage) {
37
-              Taro.navigateTo({
38
-                url: "/pages/login/index",
39
-              });
40
-            }
41
-          });
42
-      } catch (error) {
43
-        console.error(error);
44
-      }
27
+      current()
28
+        .then((res) => {
29
+          console.log("---当前人员----", res);
30
+        })
31
+        .catch((err) => {
32
+          console.log("---当前人员--报错了--");
33
+          console.error(err);
34
+          if (!isLoginPage) {
35
+            Taro.switchTab({
36
+              url: "/pages/login/index",
37
+            });
38
+          }
39
+        });
45 40
     }
46 41
 
47 42
     // if (!person || !user) {
@@ -105,7 +100,7 @@ export default (props) => {
105 100
             </Loading>
106 101
           </View>
107 102
         )} */}
108
-  
103
+
109 104
         <Auth roles={roles}>{props.children}</Auth>
110 105
         {!tabBar && <View className={laySty["pdm-space"]}></View>}
111 106
       </View>

+ 4
- 5
src/pages/issue/components/Issue/index.jsx Näytä tiedosto

@@ -4,8 +4,7 @@ import { Textarea, View } from "@tarojs/components";
4 4
 import { Field, Cell, CellGroup } from "@antmjs/vantui";
5 5
 import LocType from "@/components/LocType";
6 6
 import IssueType from "@/components/IssueType";
7
-// import OrgPicker from "@/components/OrgPicker";
8
-import OrgTree from "@/components/OrgTree";
7
+import OrgPicker from "@/components/OrgPicker";
9 8
 import DatePicker from "@/components/DatePicker";
10 9
 import Map from "@/components/map";
11 10
 import Uploader from "@/components/Uploader/index";
@@ -103,8 +102,8 @@ export default (props) => {
103 102
   };
104 103
 
105 104
   const setFieldChange = (field, value) => {
106
-    // console.log("field->>>>>>>>>>>>>>>>",field)
107
-    // console.log("value->>>>>>>>>>>>>>>>",value)
105
+    console.log("field->>>>>>>>>>>>>>>>",field)
106
+    console.log("value->>>>>>>>>>>>>>>>",value)
108 107
     const data = {
109 108
       ...fmRef.current,
110 109
       [field]: value,
@@ -167,7 +166,7 @@ export default (props) => {
167 166
         onChange={onIssueTypeChange}
168 167
       />
169 168
 
170
-      <OrgTree
169
+      <OrgPicker
171 170
         show={showOrgPicker}
172 171
         value={formData.orgName}
173 172
         onCancel={() => setShowOrgPicker(false)}

+ 1
- 0
src/pages/issue/edit/components/Assigned.jsx Näytä tiedosto

@@ -15,6 +15,7 @@ export default (props) => {
15 15
 
16 16
   // 交办
17 17
   const onAssigned = () => {
18
+    console.log(formData)
18 19
     try {
19 20
       warn(!formData.addr, '请填写地址')
20 21
       warn(!formData.locId, '请选择点位')

+ 2
- 2
src/pages/login/components/Form1.jsx Näytä tiedosto

@@ -106,8 +106,8 @@ export default (props) => {
106 106
           <Button
107 107
             block
108 108
             type="primary"
109
-            // formType="submit"
110
-            loading={loading}
109
+            formType="submit"
110
+            // loading={loading}
111 111
             disabled={loading}
112 112
             onClick={handleClick}
113 113
           >

+ 15
- 12
src/store/user.js Näytä tiedosto

@@ -11,7 +11,7 @@ import {
11 11
 } from "@/services/wxma";
12 12
 import { changePassword } from "@/services/sysuser";
13 13
 import { ROLE_CITIZEN } from "@/utils/user";
14
-import { setToken } from "@/utils/token";
14
+import { setToken ,clearToken} from "@/utils/token";
15 15
 
16 16
 export default function useUser() {
17 17
   const [person, setPerson] = React.useState();
@@ -65,14 +65,16 @@ export default function useUser() {
65 65
 
66 66
   const maSignup = (data) => {
67 67
     return new Promise((resolve, reject) => {
68
-      signup(data).then(res => {
69
-        setPerson(res.person);
70
-        setUser(res.user);
71
-        initDuty(res.user);
72
-        resolve(res);
73
-      }).catch(reject);
68
+      signup(data)
69
+        .then((res) => {
70
+          setPerson(res.person);
71
+          setUser(res.user);
72
+          initDuty(res.user);
73
+          resolve(res);
74
+        })
75
+        .catch(reject);
74 76
     });
75
-  }
77
+  };
76 78
 
77 79
   const current = () => {
78 80
     return new Promise((resolve, reject) => {
@@ -109,11 +111,11 @@ export default function useUser() {
109 111
   };
110 112
 
111 113
   const signOut = () => {
112
-    console.log(111111)
114
+    console.log(111111);
113 115
     setPerson(null);
114 116
     setUser(null);
115 117
     initDuty(null);
116
-    setToken();
118
+    clearToken();
117 119
     Taro.navigateTo({
118 120
       url: "/pages/login/index",
119 121
     });
@@ -127,8 +129,7 @@ export default function useUser() {
127 129
 
128 130
     changePassword(data)
129 131
       .then((res) => {
130
-        signOut()
131
-
132
+        signOut();
132 133
       })
133 134
       .catch((e) => {
134 135
         console.error(e);
@@ -149,5 +150,7 @@ export default function useUser() {
149 150
     changePwd,
150 151
     setPerson,
151 152
     signup: maSignup,
153
+    setUser,
154
+    initDuty,
152 155
   };
153 156
 }

+ 1
- 0
src/utils/message.js Näytä tiedosto

@@ -7,6 +7,7 @@ export function warn(predicate, message) {
7 7
       message,
8 8
       type: 'warning',
9 9
     })
10
+    throw new Error(message)
10 11
     // //Weapp
11 12
     // throw new Error(message);
12 13
   }

+ 3
- 0
src/utils/token.js Näytä tiedosto

@@ -7,6 +7,9 @@ export const getToken = function () {
7 7
 export const setToken = function (data) {
8 8
   return Taro.setStorage({ key: "token", data });
9 9
 };
10
+export const clearToken = function (data) {
11
+  return Taro.clearStorage({ key: "token" });
12
+};
10 13
 
11 14
 export const TARO_ENV = process.env.TARO_ENV; //那个端的
12 15