Yansen 2 vuotta sitten
vanhempi
commit
7526a0a581

+ 1
- 0
src/app.config.js Näytä tiedosto

@@ -26,6 +26,7 @@ export default defineAppConfig({
26 26
     "pages/my/edit/index",
27 27
     "pages/feedback/issue/index",
28 28
     "pages/feedback/issuelist/index",
29
+    "pages/user/list/index",
29 30
   ],
30 31
   subpackages: [
31 32
     {

+ 2
- 0
src/components/Icon.jsx Näytä tiedosto

@@ -14,6 +14,7 @@ import icon9 from '@/assets/icons/icon9.png';
14 14
 import icon10 from '@/assets/icons/icon10.png';
15 15
 import icon11 from '@/assets/icons/icon11.png';
16 16
 import icon12 from '@/assets/icons/icon12.png';
17
+import person from '@/assets/icons/peopleicon.png';
17 18
 
18 19
 const icons = {
19 20
   icon1,
@@ -28,6 +29,7 @@ const icons = {
28 29
   icon10,
29 30
   icon11,
30 31
   icon12,
32
+  person,
31 33
 }
32 34
 
33 35
 export default (props) => {

+ 9
- 2
src/components/PowerList/index.jsx Näytä tiedosto

@@ -3,7 +3,7 @@ import Taro from '@tarojs/taro';
3 3
 import { View } from '@tarojs/components';
4 4
 import { PowerScrollView } from '@antmjs/vantui';
5 5
 
6
-export default (props) => {
6
+export default React.forwardRef((props, ref) => {
7 7
   const { request, params, renderItem, onLoadingChange } = props;
8 8
 
9 9
   const pageSize = 20;
@@ -56,6 +56,13 @@ export default (props) => {
56 56
     pageNumRef.current = 1;
57 57
     queryData({pageNum : pageNumRef.current});
58 58
   }, [queryData]);
59
+
60
+  React.useImperativeHandle(ref, () => ({
61
+    refresh: () => {
62
+      pageNumRef.current = 1;
63
+      queryData({pageNum : pageNumRef.current});
64
+    }
65
+  }));
59 66
   
60 67
   return (
61 68
     <PowerScrollView
@@ -72,4 +79,4 @@ export default (props) => {
72 79
       }
73 80
     </PowerScrollView>
74 81
   )
75
-}
82
+})

+ 2
- 1
src/layouts/index.jsx Näytä tiedosto

@@ -2,7 +2,7 @@ import React from 'react';
2 2
 import Taro from '@tarojs/taro';
3 3
 import { View, Image } from '@tarojs/components';
4 4
 import { useModel } from '@/store';
5
-import { Loading, Notify } from '@antmjs/vantui';
5
+import { Loading, Notify, Dialog } from '@antmjs/vantui';
6 6
 import NavLoading from '@/components/NavLoading';
7 7
 import Auth from '@/components/Auth';
8 8
 import TabBar from './TabBar';
@@ -35,6 +35,7 @@ export default (props) => {
35 35
   return (
36 36
     <View className={laySty['page-wrapper']}>
37 37
       <Notify id="vanNotify" />
38
+      <Dialog id="vanDialog" />
38 39
       <NavLoading loading={loading} />
39 40
       <View className={containerClass} style={style}>
40 41
         {

+ 7
- 2
src/pages/home/index.jsx Näytä tiedosto

@@ -53,6 +53,7 @@ const menus = {
53 53
     { icon: 'icon5', text: '已 逾 期', link: '/pages/org/issue/list/index?title=已办结&bizStatus=expired' },
54 54
     { icon: 'icon9', text: '审核申请', request: getVerifyApply, link: `/pages/apply/list/index?title=审核申请&applyType=${PROCESS_APPLY_VERIFY}` },
55 55
     { icon: 'icon11', text: '消息通知', link: '/pages/message/list/index' },
56
+    { icon: 'person', text: '人员管理', link: '/pages/user/list/index' },
56 57
   ],
57 58
 
58 59
   // 查询人员
@@ -74,7 +75,7 @@ const menus = {
74 75
 export default (props) => {
75 76
 
76 77
   const userModel = useModel('user');
77
-  const { user, duty } = userModel || {};
78
+  const { user, duty, signOut, changePwd } = userModel || {};
78 79
 
79 80
   const menuArr = React.useMemo(() => {
80 81
     if (!duty) return [];
@@ -84,7 +85,11 @@ export default (props) => {
84 85
 
85 86
   return (
86 87
     <Page tabBar="home" className="home-page">
87
-      <Head userModel={userModel} />
88
+      <Head
89
+        userModel={userModel}
90
+        onChangePwd={changePwd}
91
+        onExit={signOut}
92
+      />
88 93
       <Banner duty={duty} />
89 94
       <StatCard duty={duty} />
90 95
 

+ 35
- 2
src/pages/my/components/Head/index.jsx Näytä tiedosto

@@ -1,20 +1,53 @@
1 1
 import React from 'react';
2 2
 import Taro from '@tarojs/taro';
3 3
 import { View, Image } from '@tarojs/components';
4
+import { ActionSheet } from '@antmjs/vantui';
5
+import ResetPwd from '../ResetPwd';
4 6
 import styles from './style.module.less';
5 7
 
6 8
 export default (props) => {
7 9
 
8
-  const { name, avatar } = props;
10
+  const { name, avatar, onChangePwd, onExit } = props;
11
+  const [show, setShow] = React.useState(false);
12
+  const [show2, setShow2] = React.useState(false);
13
+
14
+  const actions =[
15
+    { name: '重置密码', value: 'reset-pwd' },
16
+    { name: '退出', value: 'exit' },
17
+  ]
18
+
19
+  const onAction = (e) => {
20
+    const { value } = e.detail;
21
+
22
+    if (value === 'reset-pwd') {
23
+      setShow(false);
24
+      setShow2(true);
25
+    }
26
+
27
+    if (value === 'exit') {
28
+      onExit();
29
+    }
30
+  }
9 31
   
10 32
   return (
11 33
     <View className={styles['my-head-box']}>
12 34
       <View className={styles['profile-box']}>
13
-        <View className={styles['profile-avatar']}>
35
+        <View className={styles['profile-avatar']} onClick={() => setShow(true)}>
14 36
           <Image src={avatar} />
15 37
         </View>
16 38
         <View className={styles['profile-name']}>{name}</View>
17 39
       </View>
40
+      <ActionSheet
41
+        show={show}
42
+        actions={actions}
43
+        onClose={() => setShow(false)}
44
+        onSelect={onAction}
45
+      />
46
+      <ResetPwd
47
+        show={show2}
48
+        onClose={() => setShow2(false)}
49
+        onSubmit={onChangePwd}
50
+      />
18 51
     </View>
19 52
   )
20 53
 }

+ 82
- 0
src/pages/my/components/ResetPwd/index.jsx Näytä tiedosto

@@ -0,0 +1,82 @@
1
+import React from 'react';
2
+import Taro from '@tarojs/taro';
3
+import { View } from '@tarojs/components';
4
+import { Dialog, CellGroup, Field, Button } from '@antmjs/vantui';
5
+import { warn } from '@/utils/message';
6
+
7
+export default (props) => {
8
+
9
+  const { show, onClose, onSubmit } = props;
10
+  const id = React.useMemo(() => {
11
+    return `dialog-${Math.random().toString(36).substring(2, 10)}`
12
+  }, []);
13
+
14
+  const [formData, setFormData] = React.useState({});
15
+
16
+  const setField = (name, value) => {
17
+    setFormData({
18
+      ...formData,
19
+      [name]: value,
20
+    })
21
+  }
22
+
23
+  const onConfirm = () => {
24
+    console.log(formData.newPassword)
25
+    try {
26
+      warn(formData.newPassword != formData.newPassword2, '两次新密码不一致');
27
+      warn(!formData.originPassword, '请输入原始密码');
28
+      warn(!formData.newPassword, '请输入新密码');
29
+    } catch (er) {
30
+      return ;
31
+    }
32
+
33
+    onClose();
34
+    onSubmit(formData);
35
+  }
36
+  
37
+  return (
38
+    <Dialog
39
+      showConfirmButton={false}
40
+      showCancelButton={false}
41
+      id={id}
42
+      show={show}
43
+      onClose={onClose}
44
+    >
45
+      <View style={{ padding: 'var(--main-space)', textAlign: 'center' }}>修改密码</View>
46
+      <CellGroup style={{ padding: 'var(--main-space)' }}>
47
+        <Field
48
+          required
49
+          label="原始密码"
50
+          type="password"
51
+          placeholder="请输入原始密码"
52
+          value={formData.originPassword}
53
+          onChange={(e) => setField('originPassword', e.detail)}
54
+        />
55
+        <Field
56
+          required
57
+          label="新密码"
58
+          type="password"
59
+          placeholder="请输入新密码"
60
+          value={formData.newPassword}
61
+          onChange={(e) => setField('newPassword', e.detail)}
62
+        />
63
+        <Field
64
+          required
65
+          label="确认密码"
66
+          type="password"
67
+          placeholder="请再次输入新密码"
68
+          value={formData.newPassword2}
69
+          onChange={(e) => setField('newPassword2', e.detail)}
70
+        />
71
+      </CellGroup>
72
+      <View style={{ display: 'flex', justifyContent: "space-around", alignItems: 'center' }}>
73
+        <View style={{ flex: 'none' }}>
74
+          <Button plain onClick={onClose}>取消</Button>
75
+        </View>
76
+        <View style={{ flex: 'none' }}>
77
+          <Button plain type="primary" onClick={onConfirm}>确定</Button>
78
+        </View>
79
+      </View>
80
+    </Dialog>
81
+  )
82
+}

+ 7
- 5
src/pages/my/index.jsx Näytä tiedosto

@@ -14,7 +14,7 @@ import styles from './style.module.less';
14 14
 
15 15
 export default (props) => {
16 16
 
17
-  const { user, person, duty, signOut } = useModel('user');
17
+  const { user, person, duty, signOut, changePwd } = useModel('user');
18 18
   const [org, setOrg] = React.useState();
19 19
 
20 20
   const [
@@ -51,6 +51,10 @@ export default (props) => {
51 51
     })
52 52
   }
53 53
 
54
+  const onChangePwd = (data) => {
55
+    changePwd(data);
56
+  }
57
+
54 58
   React.useEffect(() => {
55 59
     if (user) {
56 60
       getSysOrgById(user.orgId).then(setOrg);
@@ -62,6 +66,8 @@ export default (props) => {
62 66
       <Head
63 67
         avatar={user?.avatar || person?.avatar || logo}
64 68
         name={user?.name || person?.name || '市民先生'}
69
+        onChangePwd={onChangePwd}
70
+        onExit={onExit}
65 71
       />
66 72
       <View className={styles['bg-menu-box']}>
67 73
         {
@@ -82,10 +88,6 @@ export default (props) => {
82 88
           )
83 89
         }
84 90
       </View>
85
-      <View className={styles.exit} onClick={onExit}>
86
-        退出
87
-        <Image src={iconExit} />
88
-      </View>
89 91
     </Page>
90 92
   )
91 93
 }

+ 4
- 0
src/pages/user/list/index.config.js Näytä tiedosto

@@ -0,0 +1,4 @@
1
+// eslint-disable-next-line no-undef
2
+export default definePageConfig({
3
+  navigationBarTitleText: '人员列表'
4
+})

+ 48
- 0
src/pages/user/list/index.jsx Näytä tiedosto

@@ -0,0 +1,48 @@
1
+import React from 'react';
2
+import Taro from '@tarojs/taro';
3
+import { View } from '@tarojs/components';
4
+import { Cell, Button, Dialog } from '@antmjs/vantui';
5
+import Page from '@/layouts/index';
6
+import PowerList from '@/components/PowerList';
7
+import { getSysUser, deleteSysUser } from '@/services/sysuser';
8
+
9
+export default (props) => {
10
+
11
+  const [loading, setLoading] = React.useState(false);
12
+  const listRef = React.useRef();
13
+
14
+  const onDelete = (user) => {
15
+    Dialog.confirm({
16
+      title: '确认删除用户?',      
17
+    }).then((e) => {
18
+      const { action } = e.detail;
19
+      if (action === 'confirm') {
20
+        setLoading(true);
21
+        deleteSysUser(user.id).then(() => {
22
+          setLoading(false);
23
+
24
+          // 刷新列表
25
+          listRef.current.refresh();
26
+        }).catch(() => {
27
+          setLoading(false);
28
+        })
29
+      }
30
+    })
31
+  }
32
+  
33
+  return (
34
+    <Page loading={loading}>
35
+      <PowerList
36
+        ref={listRef}
37
+        request={getSysUser}
38
+        onLoadingChange={setLoading}
39
+        renderItem={(item) => (
40
+          <Cell key={item.userId} title={item.name} label={item.createDate.substring(0, 10)}>
41
+            <Button plain type="danger" size="small" onClick={() => onDelete(item)}>删除</Button>
42
+          </Cell>
43
+        )}
44
+      />
45
+
46
+    </Page>
47
+  )
48
+}

+ 21
- 0
src/services/sysuser.js Näytä tiedosto

@@ -0,0 +1,21 @@
1
+import request from '@/utils/request';
2
+
3
+/*
4
+ * 分页查询
5
+ */
6
+export const getSysUser = (params) => request('/api/ma/sysUser', { params });
7
+
8
+/*
9
+ * 新增数据
10
+ */
11
+export const postSysUser = (data) => request('/api/ma/sysUser', { data, method: 'post' });
12
+
13
+/*
14
+ * 通过主键删除数据
15
+ */
16
+export const deleteSysUser = (id) => request(`/api/ma/sysUser/${id}`, { method: 'delete' });
17
+
18
+/*
19
+ * 修改密码
20
+ */
21
+export const changePassword = (data) => request('/api/ma/sysUser/change-password', { method: 'put', data });

+ 11
- 0
src/store/user.js Näytä tiedosto

@@ -2,6 +2,7 @@ import React from 'react';
2 2
 import Taro from '@tarojs/taro';
3 3
 import md5 from 'md5';
4 4
 import { login, signin, currentUser, authPhone, authUser } from '@/services/wxma';
5
+import { changePassword } from '@/services/sysuser';
5 6
 import { ROLE_CITIZEN } from '@/utils/user';
6 7
 
7 8
 export default function useUser() {
@@ -75,6 +76,15 @@ export default function useUser() {
75 76
     initDuty([]);
76 77
   }
77 78
 
79
+  const changePwd = (params) => {
80
+    const data = {
81
+      originPassword: md5(params.originPassword),
82
+      newPassword: md5(params.newPassword),
83
+    }
84
+
85
+    changePassword(data);
86
+  }
87
+
78 88
   return {
79 89
     user,
80 90
     person,
@@ -86,5 +96,6 @@ export default function useUser() {
86 96
     signinByPhone,
87 97
     authProfile,
88 98
     signOut,
99
+    changePwd,
89 100
   }
90 101
 }