Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
maoxiaoquan committed Jul 25, 2019
1 parent 8b4ec38 commit 6c5f664
Show file tree
Hide file tree
Showing 93 changed files with 2,087 additions and 2,160 deletions.
18 changes: 9 additions & 9 deletions admin/src/components/Parts/Aside.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import axios from 'axios'
import ScrollBar from '../ScrollBar'

import './aside.scss'
import { get_admin_user_info } from '../../stores/actions'
import { getAdminUserInfo } from '../../stores/actions'

const { Header, Content, Footer, Sider } = Layout
const SubMenu = Menu.SubMenu
Expand Down Expand Up @@ -163,7 +163,7 @@ class Aside extends Component {

render() {
const { aside_list = [], isMobile } = this.state
const { collapsed, onCollapseChange, state_mange } = this.props
const { collapsed, onCollapseChange, stateMange } = this.props
return (
<Layout.Sider
breakpoint="lg"
Expand All @@ -179,7 +179,7 @@ class Aside extends Component {
<div className="admin-aside-menu-view">
<div className="admin-aside-header">
<Link className="admin-logo-text" to="/manager/index">
{state_mange.website && state_mange.website.website_name}
{stateMange.website && stateMange.website.website_name}
</Link>
</div>

Expand All @@ -200,8 +200,8 @@ class Aside extends Component {
{aside_list.map(item => {
if (
item.link &&
state_mange.asideList &&
~state_mange.asideList.indexOf(item.key)
stateMange.asideList &&
~stateMange.asideList.indexOf(item.key)
) {
return (
<Menu.Item key={item.key}>
Expand All @@ -212,8 +212,8 @@ class Aside extends Component {
</Menu.Item>
)
} else if (
state_mange.asideList &&
~state_mange.asideList.indexOf(item.key)
stateMange.asideList &&
~stateMange.asideList.indexOf(item.key)
) {
return (
<SubMenu
Expand All @@ -226,7 +226,7 @@ class Aside extends Component {
}
>
{item.children.map(child_item => {
if (~state_mange.asideList.indexOf(child_item.key)) {
if (~stateMange.asideList.indexOf(child_item.key)) {
return (
<Menu.Item key={child_item.key}>
<Link to={child_item.link}>
Expand Down Expand Up @@ -254,4 +254,4 @@ class Aside extends Component {
}
}

export default connect(({ state_mange }) => ({ state_mange }))(Aside)
export default connect(({ stateMange }) => ({ stateMange }))(Aside)
9 changes: 4 additions & 5 deletions admin/src/components/Parts/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from 'antd'
import './header.scss'
import { getAdminIndexStatistics } from '../../containers/Index/actions'
import state_title from '../../stores/reducers/title'

const SubMenu = Menu.SubMenu
const MenuItemGroup = Menu.ItemGroup
Expand All @@ -39,9 +38,9 @@ const menu = (
)

@withRouter
@connect(({ state_title, state_mange }) => ({
state_title,
state_mange
@connect(({ stateTitle, stateMange }) => ({
stateTitle,
stateMange
}))
class Header extends Component {
state = {
Expand All @@ -63,7 +62,7 @@ class Header extends Component {
const {
collapsed,
onCollapseChange,
state_mange: { user = {} }
stateMange: { user = {} }
} = this.props
return (
<Layout.Header
Expand Down
12 changes: 6 additions & 6 deletions admin/src/containers/AdminAuthority/view/AdminAuthority.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AdminAuthority extends React.Component {
if (!value) {
this.props.form.setFields({
authority_sort: {
value: await this.props.state_admin_authority.admin_authority_list
value: await this.props.stateAdminAuthority.admin_authority_list
.length
}
})
Expand Down Expand Up @@ -162,7 +162,7 @@ class AdminAuthority extends React.Component {
await this.props.dispatch(
updateAdminAuthority(
{
authority_id: this.props.state_admin_authority.current_authority_info
authority_id: this.props.stateAdminAuthority.current_authority_info
.authority_id,
authority_name: values.authority_name,
authority_type: values.authority_type,
Expand Down Expand Up @@ -213,7 +213,7 @@ class AdminAuthority extends React.Component {
}

render() {
const { state_admin_authority } = this.props
const { stateAdminAuthority } = this.props
const { getFieldDecorator } = this.props.form
const { authority_type_select, authority_parent_name } = this.state

Expand Down Expand Up @@ -428,7 +428,7 @@ class AdminAuthority extends React.Component {

<div className="layout-card-view">
<Tree defaultExpandAll={true} showLine ref="tree">
{state_admin_authority.admin_authority_list.map(item => {
{stateAdminAuthority.admin_authority_list.map(item => {
return (
<TreeNode key={item.authority_id} title={customLabel(item)}>
{TreeNodeTree(item.children)}
Expand All @@ -445,8 +445,8 @@ class AdminAuthority extends React.Component {

const AdminAuthorityForm = Form.create()(AdminAuthority)

export default connect(({ state_admin_authority }) => {
export default connect(({ stateAdminAuthority }) => {
return {
state_admin_authority
stateAdminAuthority
}
})(AdminAuthorityForm)
63 changes: 32 additions & 31 deletions admin/src/containers/AdminRole/view/AdminRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AdminRole extends React.Component {
<div className="table-right-btn">
<Button
onClick={async () => {
this.edit_role(record)
this.editRole(record)
await this.props.dispatch({
type: 'SET_CURRENT_ADMIN_ROLE_INFO',
data: record
Expand All @@ -76,7 +76,7 @@ class AdminRole extends React.Component {
type: 'SET_CURRENT_ADMIN_ROLE_INFO',
data: record
})
this.delete_role()
this.deleteRole()
}}
size="small"
>
Expand All @@ -88,7 +88,7 @@ class AdminRole extends React.Component {
onClick={async () => {
this.setState({
visible_set_authority_modal: true,
role_authority_list: this.init_tree_data(
role_authority_list: this.initTreeData(
record.admin_authority_ids
? record.admin_authority_ids.split(',')
: ''
Expand Down Expand Up @@ -123,7 +123,7 @@ class AdminRole extends React.Component {

componentDidMount() {
/*获取后台角色分页列表*/
this.fetch_admin_role_list()
this.fetchAdminRoleList()
/*获取后台权限所有*/
this.props.dispatch(getAdminAuthorityList())
}
Expand All @@ -133,13 +133,13 @@ class AdminRole extends React.Component {
visible_create_role_modal: true,
is_create: true
})
this.init_role_from()
this.initRoleFrom()
}

init_tree_data = val => {
initTreeData = val => {
/* 初始化选中树 */
let tree_arr = []
const { admin_authority_source_list } = this.props.state_admin_authority
const { admin_authority_source_list } = this.props.stateAdminAuthority
admin_authority_source_list.map(item => {
if (
Number(item.authority_type) === 2 &&
Expand All @@ -151,15 +151,15 @@ class AdminRole extends React.Component {
return tree_arr
}

init_role_from = () => {
initRoleFrom = () => {
/*初始化角色表单*/
this.setState({
role_name: '',
role_description: ''
})
}

edit_role = val => {
editRole = val => {
/*修改角色*/
this.setState({
visible_create_role_modal: true,
Expand All @@ -169,9 +169,9 @@ class AdminRole extends React.Component {
})
}

delete_role = () => {
deleteRole = () => {
/* 删除角色 删除角色的同时要删除3张表之前的关联 用户角色表 角色表 角色权限表 */
const { current_role_info } = this.props.state_admin_role
const { current_role_info } = this.props.stateAdminRole
confirm({
title: '确认要删除当前角色吗?',
content: '删除当前角色会删除角色用户关联,以及角色权限关联',
Expand All @@ -182,7 +182,7 @@ class AdminRole extends React.Component {
await this.props.dispatch(
deleteAdminRole({ role_id: current_role_info.role_id }, res => {
/*获取后台角色分页列表*/
this.fetch_admin_role_list()
this.fetchAdminRoleList()
})
)
},
Expand All @@ -195,9 +195,9 @@ class AdminRole extends React.Component {
handleOk = () => {
/*判断是修改还是创建*/
if (this.state.is_create) {
this.fetch_admin_create_role()
this.fetchAdminCreateRole()
} else {
this.fetch_admin_edit_role()
this.fetchAdminEditRole()
}
}

Expand All @@ -216,29 +216,30 @@ class AdminRole extends React.Component {
current: pages.current
}
})
this.fetch_admin_role_list()
this.fetchAdminRoleList()
}

fetch_admin_edit_role = () => {
fetchAdminEditRole = () => {
/*修改角色*/
this.props.dispatch(
editAdminRole(
{
role_id: this.props.state_admin_role.current_role_info.role_id,
role_id: this.props.stateAdminRole.current_role_info.role_id,
role_name: this.state.role_name,
role_description: this.state.role_description
},
() => {
alert.message_success('修改角色成功')
this.fetch_admin_role_list()
this.fetchAdminRoleList()
this.setState({
visible_create_role_modal: false
})
}
)
)
}
fetch_admin_create_role = () => {

fetchAdminCreateRole = () => {
/*创建角色*/
let params = {
role_name: this.state.role_name,
Expand All @@ -247,20 +248,20 @@ class AdminRole extends React.Component {
this.props.dispatch(
createAdminRole(params, () => {
alert.message_success('角色创建成功')
this.fetch_admin_role_list()
this.fetchAdminRoleList()
this.setState({
visible_create_role_modal: false
})
})
)
}

fetch_set_admin_role_authority = () => {
fetchSetAdminRoleAuthority = () => {
/* 传递tyepe=2子节点 */
const {
current_role_info,
role_authority_list_all
} = this.props.state_admin_role
} = this.props.stateAdminRole
this.props.dispatch(
setAdminRoleAuthority(
{
Expand All @@ -269,7 +270,7 @@ class AdminRole extends React.Component {
},
() => {
alert.message_success('角色权限设置成功')
this.fetch_admin_role_list()
this.fetchAdminRoleList()
this.setState({
visible_set_authority_modal: false
})
Expand All @@ -278,7 +279,7 @@ class AdminRole extends React.Component {
)
}

fetch_admin_role_list = () => {
fetchAdminRoleList = () => {
/*获取角色分页列表*/
const that = this
this.setState({ loading: true })
Expand Down Expand Up @@ -325,7 +326,7 @@ class AdminRole extends React.Component {
}

render() {
const { state_admin_role, state_admin_authority } = this.props
const { stateAdminRole, stateAdminAuthority } = this.props
const { loading, role_name, role_description, is_create } = this.state

const formItemLayout = {
Expand Down Expand Up @@ -426,13 +427,13 @@ class AdminRole extends React.Component {
ref="tree"
showLine
>
{this.renderTreeNodes(state_admin_authority.admin_authority_list)}
{this.renderTreeNodes(stateAdminAuthority.admin_authority_list)}
</Tree>
<div className="admin-role-foot">
<Button
icon="save"
onClick={() => {
this.fetch_set_admin_role_authority()
this.fetchSetAdminRoleAuthority()
}}
type="primary"
>
Expand All @@ -453,7 +454,7 @@ class AdminRole extends React.Component {
<div className="layout-table">
<Table
columns={this.state.columns}
dataSource={state_admin_role.admin_role_list}
dataSource={stateAdminRole.admin_role_list}
loading={loading}
onChange={this.handleTableChange.bind(this)}
pagination={this.state.pagination}
Expand All @@ -466,9 +467,9 @@ class AdminRole extends React.Component {
}
}

export default connect(({ state_admin_role, state_admin_authority }) => {
export default connect(({ stateAdminRole, stateAdminAuthority }) => {
return {
state_admin_role,
state_admin_authority
stateAdminRole,
stateAdminAuthority
}
})(AdminRole)
Loading

0 comments on commit 6c5f664

Please sign in to comment.