Commit 8576f971 authored by superman's avatar superman

1.3.6-3

parent 04f979a1
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -63,9 +63,9 @@ export default class EditItem extends Component { ...@@ -63,9 +63,9 @@ export default class EditItem extends Component {
const {params:{id}} = this.props; const {params:{id}} = this.props;
if (id) { if (id) {
this.fetchItem(id); this.fetchItem(id);
if (id !== 'ROLE_ADMIN') { }
this.fetchResourceList(); if (id !== 'ROLE_ADMIN') {
} this.fetchResourceList(1);
} }
}; };
...@@ -76,9 +76,11 @@ export default class EditItem extends Component { ...@@ -76,9 +76,11 @@ export default class EditItem extends Component {
history.replace('/admin/authorities/' + item.id); history.replace('/admin/authorities/' + item.id);
return; return;
} }
if (item && item.permissions && resources) { // if (item && item.permissions && resources) {
if (resources) {
this.analysisCheckedKeys(nextProps); this.analysisCheckedKeys(nextProps);
} }
// }
}; };
fetchItem(id) { fetchItem(id) {
...@@ -88,7 +90,8 @@ export default class EditItem extends Component { ...@@ -88,7 +90,8 @@ export default class EditItem extends Component {
}); });
}; };
fetchResourceList() { fetchResourceList(a) {
console.log('fetchResourceList', a);
this.props.dispatch({ this.props.dispatch({
type: 'FETCH_RESOURCE_LIST', type: 'FETCH_RESOURCE_LIST',
query: {s: 100} query: {s: 100}
...@@ -102,15 +105,21 @@ export default class EditItem extends Component { ...@@ -102,15 +105,21 @@ export default class EditItem extends Component {
if (this.props.params.id) { if (this.props.params.id) {
data.id = this.props.params.id; data.id = this.props.params.id;
} }
if (!data.id) {
data.status = 1;
}
const permissions = {}; if (data.id) {
this.state.checkedKeys.forEach(key=> { //创建的时候是不能分配权限的
const [ka, cn, mask] = key.split('-'); const permissions = {};
if (ka === 'a' && mask) { this.state.checkedKeys.forEach(key=> {
permissions[cn] = ( permissions[cn] || 0) + parseInt(mask, 10); const [ka, cn, mask] = key.split('-');
} if (ka === 'a' && mask) {
}); permissions[cn] = ( permissions[cn] || 0) + parseInt(mask, 10);
data.permissions = JSON.stringify(permissions); }
});
data.permissions = JSON.stringify(permissions);
}
if (isNaN(data.status)) { if (isNaN(data.status)) {
ENABLE_STATUS_LIST.forEach(item=> { ENABLE_STATUS_LIST.forEach(item=> {
if (item.text === data.status) { if (item.text === data.status) {
...@@ -119,11 +128,11 @@ export default class EditItem extends Component { ...@@ -119,11 +128,11 @@ export default class EditItem extends Component {
} }
}) })
} }
if(data.name){ if (data.name) {
if(!/^ROLE_/g.test(data.name)){ if (!/^ROLE_/g.test(data.name)) {
data.name = 'ROLE_' + data.name; data.name = 'ROLE_' + data.name;
} }
data.name = (data.name+'').toUpperCase(); data.name = (data.name + '').toUpperCase();
} }
console.log(data); console.log(data);
this.props.dispatch({ this.props.dispatch({
...@@ -133,7 +142,8 @@ export default class EditItem extends Component { ...@@ -133,7 +142,8 @@ export default class EditItem extends Component {
} }
analysisCheckedKeys(props) { analysisCheckedKeys(props) {
const {item:{permissions}, resources, isEdit} = props; const {item, resources, isEdit} = props;
const permissions = item && item.permissions || null;
//对权限资源分组 //对权限资源分组
const resourcesCategoryMap = {}; const resourcesCategoryMap = {};
const checkedKeys = []; const checkedKeys = [];
...@@ -176,6 +186,7 @@ export default class EditItem extends Component { ...@@ -176,6 +186,7 @@ export default class EditItem extends Component {
resourcesCategoryMap, resourcesCategoryMap,
checkedKeys checkedKeys
}); });
// console.log('analysisCheckedKeys', resourcesCategoryMap, checkedKeys);
} }
...@@ -205,6 +216,8 @@ export default class EditItem extends Component { ...@@ -205,6 +216,8 @@ export default class EditItem extends Component {
/> />
); );
// console.log('params=>', params, this.state);
return ( return (
<Layout header={header}> <Layout header={header}>
<Spin spinning={loading}> <Spin spinning={loading}>
...@@ -229,19 +242,22 @@ export default class EditItem extends Component { ...@@ -229,19 +242,22 @@ export default class EditItem extends Component {
item.description || NULL item.description || NULL
} }
</Form.Item> </Form.Item>
<Form.Item label="状态" {...smallFormItemLayout}> {
{ !isCreate &&
isEdit ? <Form.Item label="状态" {...smallFormItemLayout}>
<Select {
placeholder="请选择状态" {...getFieldProps('status', {initialValue: enableStatusToString(item.status)})} > isEdit ?
<Select.Option value="1">系统</Select.Option> <Select
<Select.Option value="5">禁用</Select.Option> placeholder="请选择状态" {...getFieldProps('status', {initialValue: enableStatusToString(item.status)})} >
<Select.Option value="9">启用</Select.Option> <Select.Option value="1">系统</Select.Option>
</Select> <Select.Option value="5">禁用</Select.Option>
: <Select.Option value="9">启用</Select.Option>
(typeof item.status !== 'undefined' ? enableStatusToString(item.status) : NULL) </Select>
} :
</Form.Item> (typeof item.status !== 'undefined' ? enableStatusToString(item.status) : NULL)
}
</Form.Item>
}
{ {
!isCreate && !isCreate &&
<Form.Item label="创建时间" {...smallFormItemLayout}> <Form.Item label="创建时间" {...smallFormItemLayout}>
...@@ -260,48 +276,49 @@ export default class EditItem extends Component { ...@@ -260,48 +276,49 @@ export default class EditItem extends Component {
</Col> </Col>
{ {
params.id !== 'ROLE_ADMIN' && (params.id && params.id !== 'ROLE_ADMIN') ?
<Col span="12"> <Col span="12">
<Tree checkable={isEdit} <Tree checkable={isEdit}
defaultExpandAll={true} defaultExpandAll={true}
checkedKeys={this.state.checkedKeys} checkedKeys={this.state.checkedKeys}
onCheck={(checkedKeys)=> { onCheck={(checkedKeys)=> {
this.setState({checkedKeys}); this.setState({checkedKeys});
}}> }}>
{ {
Object.keys(this.state.resourcesCategoryMap).map((key, index)=> Object.keys(this.state.resourcesCategoryMap).map((key, index)=>
<Tree.TreeNode className="resource-category" key={'c-' + key} <Tree.TreeNode className="resource-category" key={'c-' + key}
title={key}> title={key}>
{ {
this.state.resourcesCategoryMap[key].map(res=> this.state.resourcesCategoryMap[key].map(res=>
res.action && res.action &&
<Tree.TreeNode className="resource-item" <Tree.TreeNode className="resource-item"
key={ key={
res.action.length === 1 ? res.action.length === 1 ?
('a-' + res.controllerName + '-' + res.action[0].value) : ('a-' + res.controllerName + '-' + res.action[0].value) :
('r-' + res.id) ('r-' + res.id)
} }
title={ title={
res.description + ( res.description + (
res.action.length === 1 ? ' - ' + res.action[0].label : '' res.action.length === 1 ? ' - ' + res.action[0].label : ''
) )
}> }>
{ {
res.action.length > 1 && res.action.map(action=> res.action.length > 1 && res.action.map(action=>
<Tree.TreeNode className="resource-action" <Tree.TreeNode className="resource-action"
key={'a-' + res.controllerName + '-' + action.value} key={'a-' + res.controllerName + '-' + action.value}
title={action.label}/> title={action.label}/>
) )
} }
</Tree.TreeNode> </Tree.TreeNode>
) )
} }
</Tree.TreeNode> </Tree.TreeNode>
) )
} }
</Tree> </Tree>
</Col> </Col>
: null
} }
</Row> </Row>
</Form> </Form>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment