|
|
@@ -1,64 +1,119 @@
|
|
|
import React from 'react'
|
|
|
import { connect } from 'dva'
|
|
|
import '../../models/dataSource'
|
|
|
-import { Table, Input, Col, Button } from 'antd'
|
|
|
+import { Table, Input, Col, Button, Switch, Icon } from 'antd'
|
|
|
+import PolicyRuleBox from './policyRuleBox'
|
|
|
+import AccessObjectBox from './accessObjectBox'
|
|
|
|
|
|
const Search = Input.Search;
|
|
|
|
|
|
-const DataSourceAccessConfig = ({ dataSource, dispatch }) => {
|
|
|
+class DataSourceAccessConfig extends React.Component{
|
|
|
+ constructor(props){
|
|
|
+ super(props);
|
|
|
+ this.state={
|
|
|
+ visibleAccessObjectBox: false,
|
|
|
+ visiblePolicyRuleBox: false
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- const columns = [{
|
|
|
- title: '策略名',
|
|
|
- dataIndex: 'policyName',
|
|
|
- render: policyName => <span>{policyName}</span>
|
|
|
- }, {
|
|
|
- title: '开放对象',
|
|
|
- dataIndex: 'targets',
|
|
|
- render: targets => {return targets.map(item => {return <p>{item.value}</p>})}
|
|
|
- }, {
|
|
|
- title: '行开放策略',
|
|
|
- dataIndex: 'rowFilters',
|
|
|
- render: rowFilters => {return rowFilters.map(filter => {return <p>{filter.value}</p>})}
|
|
|
- }, {
|
|
|
- title: '列开放策略',
|
|
|
- dataIndex: 'columns',
|
|
|
- render: columns => {return columns.filter((column) => !column.enabled).map(column => {return <p>屏蔽:{column.alias}</p>})}
|
|
|
- }];
|
|
|
+ hideAccessObjectBox= () => {
|
|
|
+ this.setState(
|
|
|
+ {visibleAccessObjectBox:false})
|
|
|
+ }
|
|
|
|
|
|
- const data = [{
|
|
|
- key: '1',
|
|
|
- policyName: '开放策略1',
|
|
|
- targets: [{value:'部门为销售'}, {value:'部门为售后'}],
|
|
|
- rowFilters: [{value:'部门字段包含售后,销售'}, {value:'公司名包含公司A'}],
|
|
|
- columns: [{name:'department', alias:'部门', enabled: true}, {name:'company', alias:'公司', enabled: false}]
|
|
|
- }];
|
|
|
+ hidePolicyRuleBox= () => {
|
|
|
+ this.setState(
|
|
|
+ {visiblePolicyRuleBox:false})
|
|
|
+ }
|
|
|
|
|
|
- return (
|
|
|
- <Table
|
|
|
- columns={columns}
|
|
|
- dataSource={data}
|
|
|
- bordered
|
|
|
- title={() => {
|
|
|
+
|
|
|
+ render() {
|
|
|
+ const { dataSource, dispatch } = this.props
|
|
|
+ const { visibleAccessObjectBox, visiblePolicyRuleBox } = this.state
|
|
|
+ const columns = [{
|
|
|
+ title: '策略名',
|
|
|
+ dataIndex: 'policyName',
|
|
|
+ render: policyName => <span>{policyName}<Icon type='copy' /></span>
|
|
|
+ }, {
|
|
|
+ title: '开放对象',
|
|
|
+ dataIndex: 'targets',
|
|
|
+ render: targets => {
|
|
|
return (
|
|
|
- <div style={{display:"flex", justifyContent:"space-between"}}>
|
|
|
- <Col>
|
|
|
- <Search
|
|
|
- style={{display:"inline"}}
|
|
|
- placeholder="input search text"
|
|
|
- onSearch={value => console.log(value)}
|
|
|
- enterButton
|
|
|
- />
|
|
|
- </Col>
|
|
|
- <Col>
|
|
|
- <Button>显示影响</Button>
|
|
|
- <Button>新增策略</Button>
|
|
|
- </Col>
|
|
|
- </div>) }
|
|
|
+ <div>
|
|
|
+ {targets.map((item,index) => { return <p key={index}>{item.value}</p> })}
|
|
|
+ <Button onClick={() => {this.setState({visibleAccessObjectBox:true})}}>添加对象</Button>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
}
|
|
|
- />
|
|
|
- );
|
|
|
-}
|
|
|
+ }, {
|
|
|
+ title: '行开放策略',
|
|
|
+ dataIndex: 'rowFilters',
|
|
|
+ render: rowFilters => {
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ {rowFilters.map((filter, index) => { return <p key={index}>{filter.value}</p> })}
|
|
|
+ <Button onClick={() => {this.setState({visiblePolicyRuleBox:true})}}>设置策略</Button>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ title: '列开放策略',
|
|
|
+ dataIndex: 'columns',
|
|
|
+ render: columns => { return columns.filter((column) => !column.enabled).map((column, index) => { return (<span key={index}>全部开放</span>) }) }
|
|
|
+ }];
|
|
|
+
|
|
|
+ const data = [{
|
|
|
+ key: '1',
|
|
|
+ policyName: '开放策略1',
|
|
|
+ targets: [{ value: '部门为销售' }, { value: '部门为售后' }],
|
|
|
+ rowFilters: [{ value: '部门字段包含售后,销售' }, { value: '公司名包含公司A' }],
|
|
|
+ columns: [{ name: 'department', alias: '部门', enabled: true }, { name: 'company', alias: '公司', enabled: false }]
|
|
|
+ }];
|
|
|
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <Table
|
|
|
+ columns={columns}
|
|
|
+ dataSource={data}
|
|
|
+ bordered
|
|
|
+ title={() => {
|
|
|
+ return (
|
|
|
+ <div style={{ display: "flex", justifyContent: "space-between" }}>
|
|
|
+ <Col span={4}>
|
|
|
+ <Search
|
|
|
+ style={{ display: "inline" }}
|
|
|
+ placeholder="input search text"
|
|
|
+ onSearch={value => console.log(value)}
|
|
|
+ enterButton
|
|
|
+ />
|
|
|
+ </Col>
|
|
|
+ <Col span={4}>
|
|
|
+ <Switch></Switch><span>完全开放</span>
|
|
|
+ </Col>
|
|
|
+ <Col span={8}>
|
|
|
+ </Col>
|
|
|
+ <Col span={4}>
|
|
|
+ <Button>显示影响</Button>
|
|
|
+ <Button>新增策略</Button>
|
|
|
+ </Col>
|
|
|
+ </div>)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ />
|
|
|
+ <AccessObjectBox
|
|
|
+ visibleAccessObjectBox={visibleAccessObjectBox}
|
|
|
+ onCancel={this.hideAccessObjectBox}
|
|
|
+ />
|
|
|
+ <PolicyRuleBox
|
|
|
+ visiblePolicyRuleBox={visiblePolicyRuleBox}
|
|
|
+ onCancel={this.hidePolicyRuleBox}
|
|
|
+
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
function mapStateToProps({ present: {dataSource} }) {
|
|
|
return { dataSource }
|
|
|
}
|