张涛 11 months ago
parent
commit
d465b331c1

+ 62
- 42
src/components/OrgTree/index.jsx View File

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
 const wrapperStyle = {
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
 export default function OrgTree(props) {
16
 export default function OrgTree(props) {
17
   const { show, onCancel, onChange } = props;
17
   const { show, onCancel, onChange } = props;
18
 
18
 
19
   const [dict, setDict] = React.useState([]);
19
   const [dict, setDict] = React.useState([]);
20
   const [checked, setChecked] = React.useState();
20
   const [checked, setChecked] = React.useState();
21
-  
21
+
22
   const onSubmit = () => {
22
   const onSubmit = () => {
23
     if (!checked) return;
23
     if (!checked) return;
24
-    onChange(checked?.orgId, checked)
25
-  }
24
+    onChange(checked?.orgId, checked);
25
+  };
26
 
26
 
27
   const onCheck = (e, it) => {
27
   const onCheck = (e, it) => {
28
     // e.stopPropagation();
28
     // e.stopPropagation();
29
     // e.preventDefault();
29
     // e.preventDefault();
30
     setChecked(it);
30
     setChecked(it);
31
-  }
32
-  
31
+  };
32
+
33
   React.useEffect(() => {
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
       setDict(treeData);
41
       setDict(treeData);
38
-    })
42
+    });
39
   }, [props.parentId]);
43
   }, [props.parentId]);
40
 
44
 
41
   return (
45
   return (
42
-    <Popup position="right" show={show} onClose={onCancel} >
46
+    <Popup position="right" show={show} onClose={onCancel}>
43
       <VABC
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
           </View>
53
           </View>
48
-        )}
54
+        }
49
         style={wrapperStyle}
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
         </ScrollView>
87
         </ScrollView>
68
       </VABC>
88
       </VABC>
69
     </Popup>
89
     </Popup>

+ 16
- 21
src/layouts/index.jsx View File

12
 export default (props) => {
12
 export default (props) => {
13
   const { className, style, roles, tabBar = false, loading } = props;
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
   const containerClass = `${laySty["page-conatiner"]} ${
17
   const containerClass = `${laySty["page-conatiner"]} ${
18
     tabBar ? laySty["with-tabbar"] : ""
18
     tabBar ? laySty["with-tabbar"] : ""
22
 
22
 
23
   React.useEffect(() => {
23
   React.useEffect(() => {
24
     const isLoginPage = currentPage.route.includes("pages/login/index");
24
     const isLoginPage = currentPage.route.includes("pages/login/index");
25
-
25
+console.log(isLoginPage)
26
     if (!user) {
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
     // if (!person || !user) {
42
     // if (!person || !user) {
105
             </Loading>
100
             </Loading>
106
           </View>
101
           </View>
107
         )} */}
102
         )} */}
108
-  
103
+
109
         <Auth roles={roles}>{props.children}</Auth>
104
         <Auth roles={roles}>{props.children}</Auth>
110
         {!tabBar && <View className={laySty["pdm-space"]}></View>}
105
         {!tabBar && <View className={laySty["pdm-space"]}></View>}
111
       </View>
106
       </View>

+ 4
- 5
src/pages/issue/components/Issue/index.jsx View File

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

+ 1
- 0
src/pages/issue/edit/components/Assigned.jsx View File

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

+ 2
- 2
src/pages/login/components/Form1.jsx View File

106
           <Button
106
           <Button
107
             block
107
             block
108
             type="primary"
108
             type="primary"
109
-            // formType="submit"
110
-            loading={loading}
109
+            formType="submit"
110
+            // loading={loading}
111
             disabled={loading}
111
             disabled={loading}
112
             onClick={handleClick}
112
             onClick={handleClick}
113
           >
113
           >

+ 15
- 12
src/store/user.js View File

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

+ 1
- 0
src/utils/message.js View File

7
       message,
7
       message,
8
       type: 'warning',
8
       type: 'warning',
9
     })
9
     })
10
+    throw new Error(message)
10
     // //Weapp
11
     // //Weapp
11
     // throw new Error(message);
12
     // throw new Error(message);
12
   }
13
   }

+ 3
- 0
src/utils/token.js View File

7
 export const setToken = function (data) {
7
 export const setToken = function (data) {
8
   return Taro.setStorage({ key: "token", data });
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
 export const TARO_ENV = process.env.TARO_ENV; //那个端的
14
 export const TARO_ENV = process.env.TARO_ENV; //那个端的
12
 
15