张延森 пре 4 година
родитељ
комит
85381d16d2

+ 8
- 8
config/routes.js Прегледај датотеку

@@ -642,17 +642,17 @@ export default [
642 642
                 name: '角色管理',
643 643
                 component: './staff/list/RoleList',
644 644
               },
645
-              {
646
-                path: '/staff/editRole',
647
-                name: '编辑角色',
648
-                hideInMenu: true,
649
-                component: './staff/list/editRole',
650
-              },
645
+              // {
646
+              //   path: '/staff/editRole',
647
+              //   name: '编辑角色',
648
+              //   hideInMenu: true,
649
+              //   component: './staff/list/editRole',
650
+              // },
651 651
               {
652 652
                 path: '/staff/list/addRole',
653
-                name: '添加角色',
653
+                name: '编辑角色',
654 654
                 hideInMenu: true,
655
-                component: './staff/list/addRole',
655
+                component: './staff/list/role',
656 656
               },
657 657
               {
658 658
                 path: '/staff/list/distribution',

+ 2
- 6
src/components/GlobalHeader/AvatarDropdown.jsx Прегледај датотеку

@@ -80,13 +80,9 @@ class AvatarDropdown extends React.Component {
80 80
     return currentUser && currentUser.userName ? (
81 81
       <>
82 82
         <HeaderDropdown overlay={menuHeaderDropdown}>
83
-            <div className={`${styles.action} ${styles.account}`} style={{display:'flex'}}>
83
+          <div className={`${styles.action} ${styles.account}`} style={{display:'flex'}}>
84 84
               
85
-         <div style={{margin:'10px 0' }}>
86
-              <p align="right" className={styles.name}>{currentUser.loginName}</p>
87
-     
88
-              <p align="right" className={styles.name}>欢迎登录{currentUser.miniAppName}</p>
89
-          </div>
85
+          <div className={styles.name}>{currentUser.userName}</div>
90 86
           <Avatar size="small" className={styles.avatar} src={currentUser.avatar === null ? currentUser.photo:currentUser.avatar} alt="avatar" />
91 87
             </div>
92 88
         </HeaderDropdown>

+ 3
- 2
src/components/GlobalHeader/index.less Прегледај датотеку

@@ -6,8 +6,9 @@
6 6
   // color: #fff;
7 7
   padding: 0;
8 8
   margin: 0;
9
-  height: 20px;
10
-  line-height: 20px;
9
+  // height: 60px;
10
+  // line-height: 60px;
11
+  vertical-align: middle;
11 12
     
12 13
 }
13 14
 .logo {

+ 6
- 6
src/pages/activity/detailActivity.jsx Прегледај датотеку

@@ -415,12 +415,12 @@ const Edit = props => {
415 415
         {tab === 'share' && <Share  dynamicId={dynamicId} />}
416 416
       </div>
417 417
       <div style={{ textAlign: 'center' }}>
418
-        <AuthButton name="admin.SignList.get" noRight={null}>
419
-          {(detailData.activityStatus === 0 || detailData.activityStatus === 2) && <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={getSignList.bind(this, detailData.dynamicId)}><Button>报名记录</Button></span>}
420
-        </AuthButton>
421
-        <AuthButton name="admin.dymic.qrcode" noRight={null}>
422
-          {(detailData.activityStatus === 0 || detailData.activityStatus === 2) && <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={newQrcode.bind(this, detailData)}>{<Button>下载二维码</Button>}</span>}
423
-        </AuthButton>
418
+        {/* <AuthButton name="admin.SignList.get" noRight={null}> */}
419
+          <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={getSignList.bind(this, detailData.dynamicId)}><Button>报名记录</Button></span>
420
+        {/* </AuthButton> */}
421
+        {/* <AuthButton name="admin.dymic.qrcode" noRight={null}> */}
422
+          <span style={{ color: '#1990FF', marginRight: '20px', cursor: 'pointer' }} onClick={newQrcode.bind(this, detailData)}>{<Button>下载二维码</Button>}</span>
423
+        {/* </AuthButton> */}
424 424
         <Button onClick={() => cancelPage()}>
425 425
           取消
426 426
           </Button>

+ 8
- 6
src/pages/dashboard/components/BuildingStatic.jsx Прегледај датотеку

@@ -9,12 +9,14 @@ export default props => {
9 9
   const [data, setData] = useState({})
10 10
 
11 11
   useEffect(() => {
12
-    setLoading(true)
13
-    getHouseVerified().then(res => {
14
-      setData(res)
15
-      setLoading(false)
16
-    }).catch(e => console.error(e) || setLoading(false))
17
-  }, [])
12
+    if (props.communityId) {
13
+      setLoading(true)
14
+      getHouseVerified({params: {communityId: props.communityId}}).then(res => {
15
+        setData(res)
16
+        setLoading(false)
17
+      }).catch(e => console.error(e) || setLoading(false))
18
+    }
19
+  }, [props.communityId])
18 20
 
19 21
 
20 22
   return (

+ 8
- 6
src/pages/dashboard/components/CommAlert.jsx Прегледај датотеку

@@ -10,12 +10,14 @@ export default props => {
10 10
   const [data, setData] = useState({})
11 11
 
12 12
   useEffect(() => {
13
-    setLoading(true)
14
-    getTips().then(res => {
15
-      setData(res)
16
-      setLoading(false)
17
-    }).catch(e => console.error(e) || setLoading(false))
18
-  }, [])
13
+    if (props.communityId) {
14
+      setLoading(true)
15
+      getTips({params: {communityId: props.communityId}}).then(res => {
16
+        setData(res)
17
+        setLoading(false)
18
+      }).catch(e => console.error(e) || setLoading(false))
19
+    }
20
+  }, [props.communityId])
19 21
 
20 22
   const ticket = data.ticketNum ? `您有 ${data.ticketNum} 个待处理工单, 点击处理` : '暂无未处理工单'
21 23
   const verify = data.verifyNum ? `您有 ${data.verifyNum} 条待审核记录, 点击处理` : '暂无业主申请'

+ 32
- 30
src/pages/dashboard/components/ScrollAlert.jsx Прегледај датотеку

@@ -21,37 +21,39 @@ export default props => {
21 21
   const [showSlides, setShowSlides] = useState(0)
22 22
 
23 23
   useEffect(() => {
24
-    const today = moment()
25
-    // 取最近 15 天的记录
26
-    const endDate = today.format('YYYY-MM-DD')
27
-    today.subtract(15, 'days')
28
-    const startDate = today.format('YYYY-MM-DD')
29
-
30
-    setLoading(true)
31
-    getDynamic({params: {startDate, endDate}}).then(res => {
32
-      const { ticketList, propList, billList } = res
33
-
34
-      // 组合list
35
-      const compList = [
36
-        ...(ticketList || []).map(x => ({...x, createDate: moment(x.createDate).format('MM-DD HH:mm'), desc: '提了一个工单'})),
37
-        ...(propList || []).map(x => ({...x, createDate: moment(x.createDate).format('MM-DD HH:mm'), desc: '申请了一个业主认证'})),
38
-        ...(billList || []).map(x => ({...x, createDate: moment(x.createDate).format('MM-DD HH:mm'), desc: '缴了一笔费用'})),
39
-      ]
40
-      
41
-      if (compList.length === 0) {
42
-        setShowSlides(0)
43
-      } else {
44
-        setShowSlides(compList.length > showMax ? showMax : compList.length - 1)
45
-      }
46
-
47
-      // 按照时间倒叙
48
-      const newList = orderBy(compList, ['createDate'], ['desc'])
49
-      setList(newList)
50
-
51
-      setLoading(false)
52
-    }).catch(e => console.error(e) || setLoading(false))
24
+    if (props.communityId) {
25
+      const today = moment()
26
+      // 取最近 15 天的记录
27
+      const endDate = today.format('YYYY-MM-DD')
28
+      today.subtract(15, 'days')
29
+      const startDate = today.format('YYYY-MM-DD')
30
+  
31
+      setLoading(true)
32
+      getDynamic({params: {startDate, endDate, communityId: props.communityId}}).then(res => {
33
+        const { ticketList, propList, billList } = res
34
+  
35
+        // 组合list
36
+        const compList = [
37
+          ...(ticketList || []).map(x => ({...x, createDate: moment(x.createDate).format('MM-DD HH:mm'), desc: '提了一个工单'})),
38
+          ...(propList || []).map(x => ({...x, createDate: moment(x.createDate).format('MM-DD HH:mm'), desc: '申请了一个业主认证'})),
39
+          ...(billList || []).map(x => ({...x, createDate: moment(x.createDate).format('MM-DD HH:mm'), desc: '缴了一笔费用'})),
40
+        ]
41
+        
42
+        if (compList.length === 0) {
43
+          setShowSlides(0)
44
+        } else {
45
+          setShowSlides(compList.length > showMax ? showMax : compList.length - 1)
46
+        }
47
+  
48
+        // 按照时间倒叙
49
+        const newList = orderBy(compList, ['createDate'], ['desc'])
50
+        setList(newList)
51
+  
52
+        setLoading(false)
53
+      }).catch(e => console.error(e) || setLoading(false))
53 54
 
54
-  }, [])
55
+    }
56
+  }, [props.communityId])
55 57
 
56 58
   return (
57 59
     <Card title="最新动态" loading={loading}>

+ 17
- 15
src/pages/dashboard/components/ShortCut.jsx Прегледај датотеку

@@ -15,20 +15,22 @@ export default props => {
15 15
   const [data, setData] = useState({})
16 16
 
17 17
   useEffect(() => {
18
-    const today = moment()
19
-    // 当月第一天
20
-    const startDate = today.format('YYYY-MM-01')
21
-
22
-    // 当月最后一天,
23
-    // 因为当前日期是业务数据最大值, 因此当天的数据跟月末是一致的
24
-    const endDate = today.format(`YYYY-MM-DD`)
25
-
26
-    setLoading(true)
27
-    getStatis({params: {startDate, endDate}}).then(res => {
28
-      setData(res)
29
-      setLoading(false)
30
-    }).catch(er => setLoading(false))
31
-  }, [])
18
+    if (props.communityId) {
19
+      const today = moment()
20
+      // 当月第一天
21
+      const startDate = today.format('YYYY-MM-01')
22
+  
23
+      // 当月最后一天,
24
+      // 因为当前日期是业务数据最大值, 因此当天的数据跟月末是一致的
25
+      const endDate = today.format(`YYYY-MM-DD`)
26
+  
27
+      setLoading(true)
28
+      getStatis({params: {startDate, endDate, communityId: props.communityId}}).then(res => {
29
+        setData(res)
30
+        setLoading(false)
31
+      }).catch(er => setLoading(false))
32
+    }
33
+  }, [props.communityId])
32 34
 
33 35
   return (
34 36
     <Row gutter={24}>
@@ -72,7 +74,7 @@ export default props => {
72 74
         </Link>
73 75
       </Col>
74 76
       <Col span={6}>
75
-        <Link to="/property/bill/ticket">
77
+        <Link to="/property/ticket">
76 78
           <Card title={false}>
77 79
             <ABPart
78 80
               align="middle"

+ 6
- 11
src/pages/dashboard/index.jsx Прегледај датотеку

@@ -8,12 +8,7 @@ import CommAlert from './components/CommAlert'
8 8
 import ScrollAlert from './components/ScrollAlert'
9 9
 
10 10
 export default props => {
11
-  // const [] = useState()
12
-
13
-
14
-  // useEffect(() => {
15
-
16
-  // }, [])
11
+  const [communityId, setCommunityId] = useState()
17 12
 
18 13
   const randText = `精铸致远,盛道自来。
19 14
   今天的远道集团,以卓越的产品和服务创造高品质生活与理想工作为使命,建设家园,服务社会,创造美好生活。
@@ -26,22 +21,22 @@ export default props => {
26 21
         backIcon={false}
27 22
         ghost={false}
28 23
         extra={[
29
-          <CommunitySelect key="1" style={{minWidth: 200}} autoInited />
24
+          <CommunitySelect key="1" value={communityId} style={{minWidth: 200}} onChange={v => setCommunityId(v)} autoInited />
30 25
         ]}
31 26
       >
32 27
         <ABPart
33 28
           align="middle"
34 29
           a={<div style={{verticalAlign: 'center'}}><p>管理员您好, 祝您开心每一天! </p><p>{randText}</p></div>}
35
-          b={<BuildingStatic />}
30
+          b={<BuildingStatic communityId={communityId} />}
36 31
         />
37 32
       </PageHeader>
38 33
 
39
-      <div style={{marginTop: 24}}><ShortCut /></div>
34
+      <div style={{marginTop: 24}}><ShortCut communityId={communityId} /></div>
40 35
       
41 36
       <div style={{marginTop: 24}}>
42 37
         <ABPart
43
-          a={<CommAlert />}
44
-          b={<ScrollAlert />}
38
+          a={<CommAlert communityId={communityId} />}
39
+          b={<ScrollAlert communityId={communityId} />}
45 40
         />
46 41
       </div>
47 42
     </div>

+ 4
- 2
src/pages/property/building/BatchImport.jsx Прегледај датотеку

@@ -16,6 +16,8 @@ export default props => {
16 16
 
17 17
   const excelRef = useRef()
18 18
 
19
+  const communityId = props.location.query.community
20
+
19 21
   const downloadExcel = () => {
20 22
     const link = document.createElement('a')
21 23
     link.href = "https://zhiyun-image.oss-cn-shanghai.aliyuncs.com/xiangsong/%E6%A5%BC%E6%A0%8B%E5%BA%93%E6%A8%A1%E6%9D%BF.xlsx"
@@ -32,7 +34,7 @@ export default props => {
32 34
         excelRef.current = files[0]
33 35
         const formData = new FormData()
34 36
         formData.append('file', excelRef.current)
35
-        formData.append("communityId", props.community)
37
+        formData.append("communityId", communityId)
36 38
         
37 39
         setLoading(true)
38 40
         uploadBuildingTreeExcel({ data: formData }).then(res => {
@@ -59,7 +61,7 @@ export default props => {
59 61
 
60 62
     const formData = new FormData()
61 63
     formData.append('file', excelRef.current)
62
-    formData.append("communityId", props.community)
64
+    formData.append("communityId", communityId)
63 65
 
64 66
     setLoading(true)
65 67
     submitBuildingTreeExcel({ data: formData }).then(res => {

+ 2
- 2
src/pages/property/community/index.jsx Прегледај датотеку

@@ -84,7 +84,7 @@ export default props => {
84 84
       </div>
85 85
       <Table loading={loading} dataSource={listData} rowKey="id">
86 86
         <Table.Column title="名称" dataIndex="name" key="name" width={480} />
87
-        <Table.Column title="状态" dataIndex="status" key="status" render={t => t === 1 ? '正常' : '未发布'} />
87
+        {/* <Table.Column title="状态" dataIndex="status" key="status" render={t => t === 1 ? '正常' : '未发布'} /> */}
88 88
         <Table.Column title="创建时间" dataIndex="createDate" key="createDate" render={t => moment(t).format('YYYY-MM-DD HH:mm')} />
89 89
         <Table.Column
90 90
           title="操作"
@@ -117,7 +117,7 @@ export default props => {
117 117
           }}
118 118
         />
119 119
       </Table>
120
-      <Prompt visible={showPrompt} onOk={handleRowEdit} placeholder="请输入小区名称" />
120
+      <Prompt visible={showPrompt} onOk={handleRowEdit} onCancel={() => setShowPrompt(false)} placeholder="请输入小区名称" />
121 121
     </div>
122 122
   )
123 123
 }

+ 8
- 6
src/pages/property/lifeConsultant/index.jsx Прегледај датотеку

@@ -70,12 +70,14 @@ export default props => {
70 70
 
71 71
   useEffect(() => {
72 72
     setLoading(true)
73
-    lifeConsultant({...queryParams, communityId}).then(res => {
74
-      const [list, pageInfo] = res || {}
75
-      setListData(list)
76
-      setPagination(pageInfo)
77
-      setLoading(false)
78
-    }).catch(() => setLoading(false))
73
+    if (communityId) {
74
+      lifeConsultant({...queryParams, communityId}).then(res => {
75
+        const [list, pageInfo] = res || {}
76
+        setListData(list)
77
+        setPagination(pageInfo)
78
+        setLoading(false)
79
+      }).catch(() => setLoading(false))
80
+    }
79 81
   }, [queryParams, communityId])
80 82
 
81 83
   return (

+ 9
- 7
src/pages/property/proprietor/Audit.jsx Прегледај датотеку

@@ -158,13 +158,15 @@ export default props => {
158 158
   }
159 159
 
160 160
   useEffect(() => {
161
-    setLoading(true)
162
-    userVerifyAll({...queryParams, communityId}).then(res => {
163
-      const [records, pagi] = res || []
164
-      setListData(records)
165
-      setPagination({total: pagi.total, pageSize: pagi.size, pageNum: pagi.current})
166
-      setLoading(false)
167
-    }).catch(() => setLoading(false))
161
+    if (communityId) {
162
+      setLoading(true)
163
+      userVerifyAll({...queryParams, communityId}).then(res => {
164
+        const [records, pagi] = res || []
165
+        setListData(records)
166
+        setPagination({total: pagi.total, pageSize: pagi.size, pageNum: pagi.current})
167
+        setLoading(false)
168
+      }).catch(() => setLoading(false))
169
+    }
168 170
   }, [queryParams, communityId])
169 171
 
170 172
   return (

+ 0
- 5
src/pages/property/proprietor/Detail.jsx Прегледај датотеку

@@ -86,11 +86,6 @@ export default props => {
86 86
       <Section title="关联本小区其他房屋" subTitle="使用用户手机号在小区用户列表中搜索查看">
87 87
         <List dataSource={userData.roomInfoList || []} renderItem={x => (<List.Item>{x}</List.Item>)} size="small" />
88 88
       </Section>
89
-      <p style={{ color: '#888' }}>
90
-        若想修改户主登录手机号,需要户主自己登录APP在个人中心修改。
91
-        或者联系荟房网络运营人员核实后修改,因为此手机号可能在其他社区在用。
92
-        若想修改成员为其他成员的手机号,请删除此成员后添加新成员。 
93
-      </p>
94 89
       <Edit
95 90
         visible={editorShow}
96 91
         userData={userData}

+ 1
- 0
src/pages/property/proprietor/index.jsx Прегледај датотеку

@@ -186,6 +186,7 @@ export default props => {
186 186
   const [pagination, setPagination] = useState({})
187 187
   const [communityId, setCommunityId] = useState()
188 188
   const [queryParams, setQueryParams] = useState({ pageNum: 1, pageSize: 10 })
189
+  const [sortList, setSortList] = useState([{}, {}])
189 190
 
190 191
   const rowSelection = {
191 192
     onChange: (selectedRowKeys, selectedRows) => {

+ 2
- 0
src/pages/staff/list/addRole.jsx Прегледај датотеку

@@ -18,6 +18,8 @@ const { TextArea } = Input;
18 18
  * @returns
19 19
  */
20 20
 const Poster = props => {
21
+  console.log('-----props.user.currentUser-----', props.user)
22
+
21 23
   const userMenus = props.user.currentUser.menus;
22 24
   const userBtns = props.user.currentUser.buttons;
23 25
   console.log(userMenus)

+ 10
- 0
src/pages/staff/list/role/components/MenuItem.jsx Прегледај датотеку

@@ -0,0 +1,10 @@
1
+import React, { useEffect, useState } from 'react'
2
+import { Checkbox } from 'antd'
3
+
4
+export default props => {
5
+  const handleChange = e => {
6
+    props.onChange(props.menu.menuId, e.target.checked)
7
+  }
8
+
9
+  return <Checkbox checked={props.checked} indeterminate={props.indeterminate} onChange={handleChange}>{props.menu.name}</Checkbox>
10
+}

+ 72
- 0
src/pages/staff/list/role/components/ModuleCard.jsx Прегледај датотеку

@@ -0,0 +1,72 @@
1
+import React, { useEffect, useState } from 'react'
2
+import { Card } from 'antd'
3
+import MenuItem from './MenuItem'
4
+
5
+const gridStyle = {
6
+  width: '25%',
7
+  textAlign: 'center',
8
+};
9
+
10
+export default props => {
11
+  // 当前 module 的所有 id , 包含 moduleId
12
+  const [allIds, setAllIds] = useState([])
13
+  // 当前 module 的选中列表
14
+  const [checkList, setCheckList] = useState([])
15
+  // 是否全选
16
+  const [checkAll, setCheckAll] = useState(false)
17
+  // 是否选择部分
18
+  const [indeterminate, setIndeterminate] = useState(false)
19
+
20
+  // 模块的勾选, 就是全选,全不选的操作
21
+  const handleModuleChange = (moduleId, checked) => {
22
+    const list = checked ? [...allIds] : []
23
+    props.onChange(list)
24
+  }
25
+
26
+  const handleMenuCheck = (menuId, checked) => {
27
+    const list = checkList.filter(x => x !== menuId)
28
+    if (checked) {
29
+      list.push(menuId)
30
+    }
31
+
32
+    props.onChange(list)
33
+  }
34
+
35
+  useEffect(() => {
36
+    //
37
+    const checkedArr = props.value || []
38
+    setCheckList(checkedArr.concat(checkedArr.includes(props.module.menuId) ? [props.module.menuId] : []))
39
+    
40
+    // 不单单是这一个模块的
41
+    const children = props.module.children || []
42
+    if (checkedArr.length >= children.length) {
43
+      setCheckAll(true)
44
+      setIndeterminate(false)
45
+    } else {
46
+      setCheckAll(false)
47
+      setIndeterminate(checkedArr.length > 0)
48
+    }
49
+
50
+    const allIdList = [props.module.menuId].concat(children.map(x => x.menuId))
51
+    setAllIds(allIdList)
52
+    
53
+  }, [props.value, props.module])
54
+
55
+
56
+  return (
57
+    <div style={{marginBottom: 16}}>
58
+      <Card title={<MenuItem checked={checkAll} indeterminate={indeterminate} menu={props.module} onChange={handleModuleChange} />} >
59
+      {
60
+        (props.module.children || []).map(menu => {
61
+          const menuChecked = checkList.includes(menu.menuId)
62
+          return (
63
+            <Card.Grid key={menu.menuId} style={gridStyle}>
64
+              <MenuItem menu={menu} checked={menuChecked} onChange={handleMenuCheck} />
65
+            </Card.Grid>
66
+          )
67
+        })
68
+      }
69
+      </Card>
70
+    </div>
71
+  )
72
+}

+ 141
- 0
src/pages/staff/list/role/index.jsx Прегледај датотеку

@@ -0,0 +1,141 @@
1
+import React, { useEffect, useMemo, useState } from 'react'
2
+import { connect } from 'dva'
3
+import { Row, Col, Card, Spin, Checkbox, Button, Popconfirm, Input, notification } from 'antd'
4
+import { fetch, apis } from '@/utils/request'
5
+import router from 'umi/router'
6
+import ModuleCard from './components/ModuleCard'
7
+
8
+const getRoleMenus = fetch(apis.role.buttonAndMenuList)
9
+const saveRoleMenus = fetch(apis.role.updateAuthMenu)
10
+
11
+const Role = props => {
12
+  const [loading, setLoading] = useState(false)
13
+  const [roleName, setRoleName] = useState()
14
+  const [checkList, setCheckList] = useState({})
15
+
16
+  const roleId = props.location.query.id
17
+
18
+  const modules = useMemo(() => {
19
+    if (!props.user || !props.user.menus || !props.user.menus.length) {
20
+      return []
21
+    }
22
+
23
+    return props.user.menus.reduce((acc, menu) => {
24
+      const menuRoot = acc[menu.menuRoot] || {}
25
+
26
+      const isModule = menu.menuId === menu.menuRoot
27
+      if (isModule) {
28
+        return {
29
+          ...acc,
30
+          [menu.menuRoot]: {
31
+            ...menuRoot,
32
+            ...menu
33
+          }
34
+        }
35
+      } else {
36
+        return {
37
+          ...acc,
38
+          [menu.menuRoot]: {
39
+            ...menuRoot,
40
+            children: (menuRoot.children || []).concat(menu)
41
+          }
42
+        }
43
+      }
44
+
45
+    }, {})
46
+
47
+  }, [props.user])
48
+
49
+  const handleCheck = moduleId => checkArr => {
50
+    checkList[moduleId] = checkArr
51
+    setCheckList({...checkList})
52
+  }
53
+
54
+  const handleSubmit = () => {
55
+    if (!roleName) {
56
+      notification.warn({ message: '请填写角色名称' })
57
+      return
58
+    }
59
+
60
+    const ids = Object.keys(checkList).reduce((acc, key) => {
61
+      const arr = checkList[key] || []
62
+      return [
63
+        ...acc,
64
+        ...arr
65
+      ]
66
+    }, [])
67
+
68
+    setLoading(true)
69
+    saveRoleMenus({data: {
70
+      id: roleId,
71
+      name: roleName,
72
+      sysMenu: ids.map(menuId => ({ menuId })),
73
+      sysButton: []
74
+    }}).then(res => {
75
+      setLoading(false)
76
+      notification.success({ message: '操作成功' })
77
+    }).catch(e => console.error(e) || setLoading(false))
78
+  }
79
+
80
+  useEffect(() => {
81
+    if (roleId) {
82
+      setLoading(true)
83
+      getRoleMenus({urlData: {id: roleId}}).then(res => {
84
+        if (res) {
85
+          const roleMenus = res.sysMenuList || []
86
+          setRoleName(res.roleName)
87
+          setCheckList(roleMenus.reduce((acc, menu) => {
88
+            const moduleId = menu.menuRoot // menu.parentCode - 0 === -1 ? menu.menuId : menu.menuRoot
89
+            const menuRoot = acc[moduleId] || []
90
+
91
+            return {
92
+              ...acc,
93
+              [moduleId]: menuRoot.concat(menu.menuId)
94
+            }
95
+          }, {}))
96
+        }
97
+        setLoading(false)
98
+      }).catch(e => console.error(e) || setLoading(false))
99
+    }
100
+  }, [roleId])
101
+
102
+  return (
103
+    <div>
104
+      <Spin spinning={loading}>
105
+        <Row style={{marginBottom: 32}}>
106
+          <Col span={12}>
107
+            <div style={{display: 'flex'}}>
108
+              <div style={{flex: 'none'}}>角色名称:</div>
109
+              <div style={{flex: 'none', marginLeft: 16}}><Input value={roleName} onChange={e => setRoleName(e.target.value)} placeholder="请填写角色名称" required /></div>
110
+            </div>
111
+          </Col>
112
+          <Col span={12}>
113
+            <div style={{textAlign: 'right'}}>
114
+              <Popconfirm
115
+                title="确定进行提交操作?"
116
+                onConfirm={handleSubmit}
117
+              >
118
+                <Button type="primary" icon="audit">提交</Button>
119
+              </Popconfirm>
120
+              <Button icon="arrow-left" onClick={() => router.go(-1)} style={{marginLeft: 16}}>返回</Button>
121
+            </div>
122
+          </Col>
123
+        </Row>
124
+      {
125
+        Object.keys(modules).map(modlueId => {
126
+          return (
127
+            <ModuleCard
128
+              key={modlueId}
129
+              module={modules[modlueId]}
130
+              value={checkList[modlueId]}
131
+              onChange={handleCheck(modlueId)}
132
+            />
133
+          )
134
+        })
135
+      }
136
+      </Spin>
137
+    </div>
138
+  )
139
+}
140
+
141
+export default connect(s => ({user: s.user.currentUser}))(Role)