forked from YunaiV/yudao-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89d875d
commit aa42de2
Showing
9 changed files
with
179 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { message } from 'antd'; | ||
import { deptTreePage } from '../../services/admin'; | ||
|
||
export default { | ||
namespace: 'deptmentList', | ||
|
||
state: { | ||
list: [], | ||
selectTree: [], | ||
deptmentData: { | ||
list: [], | ||
}, | ||
}, | ||
|
||
effects: { | ||
*getDeptmentList({ payload }, { call, put }) { | ||
const result = yield call(deptTreePage, payload); | ||
let deptmentData = {}; | ||
if (result.code === 0) { | ||
deptmentData = result.data; | ||
} | ||
yield put({ | ||
type: 'save', | ||
payload: { | ||
deptmentData, | ||
}, | ||
}); | ||
}, | ||
}, | ||
|
||
reducers: { | ||
save(state, action) { | ||
return { | ||
...state, | ||
...action.payload, | ||
}; | ||
}, | ||
|
||
treeSuccess(state, { payload }) { | ||
const resultData = payload; | ||
const treeData = buildSelectTree(resultData); | ||
|
||
// value 要保护 displayName 不然,搜索会失效 | ||
const rootNode = [ | ||
{ | ||
title: '根节点', | ||
value: `根节点-0`, | ||
key: 0, | ||
children: [], | ||
}, | ||
]; | ||
|
||
const selectTree = rootNode.concat(treeData); | ||
return { | ||
...state, | ||
list: resultData, | ||
selectTree, | ||
}; | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import React, { PureComponent, Fragment } from 'react'; | ||
import { Button, Card, Table, Form, Divider } from 'antd'; | ||
import PageHeaderWrapper from '@/components/PageHeaderWrapper'; | ||
import { connect } from 'dva'; | ||
import styles from './DeptmentList.less'; | ||
import PaginationHelper from '../../../helpers/PaginationHelper'; | ||
import moment from 'moment'; | ||
|
||
@connect(({ deptmentList, loading }) => ({ | ||
deptmentList, | ||
deptmentData: deptmentList.deptmentData, | ||
loading: loading.models.deptmentList, | ||
})) | ||
@Form.create() | ||
export default class DepetmentList extends PureComponent { | ||
componentDidMount() { | ||
const { dispatch } = this.props; | ||
dispatch({ | ||
type: 'deptmentList/getDeptmentList', | ||
payload: { | ||
...PaginationHelper.defaultPayload, | ||
}, | ||
}); | ||
} | ||
|
||
render() { | ||
const { deptmentData, deptmentList } = this.props; | ||
const columns = [ | ||
{ | ||
title: '部门名称', | ||
dataIndex: 'name', | ||
}, | ||
{ | ||
title: '排序', | ||
dataIndex: 'sort', | ||
}, | ||
{ | ||
title: '创建时间', | ||
dataIndex: 'createTime', | ||
sorter: true, | ||
render: val => <span>{moment(val).format('YYYY-MM-DD')}</span>, | ||
}, | ||
{ | ||
title: '操作', | ||
render: (text, record) => ( | ||
<Fragment> | ||
<a onClick={() => this.handleModalVisible(true, 'update', record)}>编辑</a> | ||
<Divider type="vertical" /> | ||
<a className={styles.tableDelete} onClick={() => this.handleDelete(record)}> | ||
删除 | ||
</a> | ||
</Fragment> | ||
), | ||
}, | ||
]; | ||
|
||
// const { | ||
// deptmentList: {deptmentData}, | ||
// loading, | ||
// } = this.props; | ||
|
||
return ( | ||
<PageHeaderWrapper> | ||
<Card bordered={false}> | ||
<div className={styles.tableList}> | ||
<div className={styles.tableListOperator}> | ||
<Button | ||
icon="plus" | ||
type="primary" | ||
onClick={() => this.handleModalVisible(true, 'add', {})} | ||
> | ||
新建部门 | ||
</Button> | ||
</div> | ||
</div> | ||
<Table | ||
defaultExpandAllRows={true} | ||
columns={columns} | ||
dataSource={deptmentData.list ? deptmentData.list : []} | ||
rowKey="id" | ||
/> | ||
</Card> | ||
</PageHeaderWrapper> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@import '~antd/lib/style/themes/default.less'; | ||
@import '~@/utils/utils.less'; | ||
|
||
.tableList { | ||
.tableListOperator { | ||
margin-bottom: 16px; | ||
button { | ||
margin-right: 8px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters