Browse Source

看板组件权限控制

zhuth 7 years ago
parent
commit
637eef4b4c

+ 0 - 19
src/components/chart/distributeObjectBox.jsx

@@ -1,19 +0,0 @@
-import React from 'react'
-import { Modal } from 'antd'
-
-
-class DistributeObjectBox extends React.Component {
-    render() {
-        const { visibleDistributeObjectBox, onCancel} = this.props
-        return (
-            <Modal
-                visible={visibleDistributeObjectBox}
-                onCancel={onCancel}
-            >
-                <span>Test</span>
-            </Modal>
-        )
-    }
-}
-
-export default DistributeObjectBox

+ 0 - 19
src/components/chart/distributePolicyRuleBox.jsx

@@ -1,19 +0,0 @@
-import React from 'react'
-import { Modal } from 'antd'
-
-
-class DistributePolicyRuleBox extends React.Component {
-    render() {
-        const { visibleDistributePolicyRuleBox, onCancel } = this.props
-        return (
-            <Modal 
-                visible={visibleDistributePolicyRuleBox}
-                onCancel={onCancel}
-            >
-                <span>Test</span>
-            </Modal>
-        )
-    }
-}
-
-export default DistributePolicyRuleBox

+ 4 - 4
src/components/chart/list.jsx

@@ -449,12 +449,12 @@ class ChartList extends React.Component {
                         </div>
                     </Card>
                 </Content>
-                <DistributeBox key={this.state.selectedRecord ? this.state.selectedRecord.code : 'notkey'} visibleDistributeBox={visibleDistributeBox} selectedRecord={this.state.selectedRecord} hideBox={() => {
+                {visibleDistributeBox && <DistributeBox visibleDistributeBox={visibleDistributeBox} selectedRecord={this.state.selectedRecord} hideBox={() => {
                     this.setState({
                         visibleDistributeBox: false
                     });
-                }} />
-                <TransferBox
+                }} />}
+                {visibleTransferBox && <TransferBox
                     visibleBox={visibleTransferBox}
                     title='选择移交对象'
                     okHandler={(user) => {
@@ -465,7 +465,7 @@ class ChartList extends React.Component {
                             visibleTransferBox: false
                         })
                     }}
-                />
+                />}
                 {visibleDeleteBox && <DeleteBox
                     visibleDeleteBox={visibleDeleteBox}
                     type='chart'

+ 12 - 3
src/components/common/filterBox/filterBox.jsx

@@ -1,7 +1,7 @@
 import React from 'react'
 import PropTypes from 'prop-types'
-import { Modal, Form, Row, Col, Input, Icon, Button, Select, InputNumber, DatePicker, Spin } from 'antd'
-import OPERATORS from './filterOperators.json';
+import { Modal, Form, Row, Col, Input, Icon, Button, Select, InputNumber, DatePicker, Spin, Cascader, Dropdown, Menu } from 'antd'
+import OPERATORS from './filterOperators.js';
 import './filterBox.less'
 import * as service from '../../../services/index'
 import URLS from '../../../constants/url'
@@ -351,11 +351,20 @@ class FilterBox extends React.Component {
                             <FormItem key={key} className='filterOperator'>
                                 {getFieldDecorator(`filterOperator${key}`, {
                                     initialValue: operator?{key: operator}:undefined,
+                                    // initialValue: operator ? [operator.split(',')[0]] : undefined,
                                     rules: [{ required: true, message: '操作类型不能为空' }]
                                 })(
+                                    // <Cascader
+                                    //     options={OPERATORS[type]}
+                                    //     expandTrigger='hover'
+                                    //     changeOnSelect={true}
+                                    //     onChange={(value) => {
+                                    //         console.log(value);
+                                    //     }}
+                                    // />,
                                     <Select
                                         labelInValue={true}
-                                        onChange={(value) => {this.changeFilterOperator(f, value)}}
+                                        onChange={(value) => {console.log(value);this.changeFilterOperator(f, value)}}
                                     >
                                         {OPERATORS[type].map((o, i) => {
                                             return <SelectOption key={i} value={o.value}>{o.label}</SelectOption>;

+ 150 - 0
src/components/common/filterBox/filterOperators.js

@@ -0,0 +1,150 @@
+export default {
+    index: [{
+        value: "contain",
+        label: "包含"
+    }, {
+        value: "notContain",
+        label: "不包含"
+    }, {
+        value: "startsWith",
+        label: "开头是"
+    }, {
+        value: "endsWith",
+        label: "结尾是"
+    }, {
+        value: "equals",
+        label: "等于"
+    }, {
+        value: "notEquals",
+        label: "不等于"
+    }, {
+        value: "null",
+        label: "为空"
+    }, {
+        value: "notNull",
+        label: "不为空"
+    }],
+    string: [{
+        value: "contain",
+        label: "包含"
+    }, {
+        value: "notContain",
+        label: "不包含"
+    }, {
+        value: "startsWith",
+        label: "开头是"
+    }, {
+        value: "endsWith",
+        label: "结尾是"
+    }, {
+        value: "equals",
+        label: "等于"
+    }, {
+        value: "notEquals",
+        label: "不等于"
+    }, {
+        value: "null",
+        label: "为空"
+    }, {
+        value: "notNull",
+        label: "不为空"
+    }],
+    scale: [{
+        value: ">",
+        label: "大于"
+    }, {
+        value: ">=",
+        label: "大于等于"
+    }, {
+        value: "=",
+        label: "等于"
+    }, {
+        value: "<=",
+        label: "小于等于"
+    }, {
+        value: "<",
+        label: "小于"
+    }, {
+        value: "<>",
+        label: "不等于"
+    }, {
+        value: "between",
+        label: "介于"
+    }, {
+        value: "null",
+        label: "为空"
+    }, {
+        value: "notNull",
+        label: "不为空"
+    }],
+    time: [{
+        value: "=",
+        label: "等于"
+    }, {
+        value: ">",
+        label: "开始于"
+    }, {
+        value: "<=",
+        label: "结束于"
+    }, {
+        value: "between",
+        label: "介于"
+    }, {
+        value: "null",
+        label: "为空"
+    }, {
+        value: "notNull",
+        label: "不为空"
+    }],
+    categorical: [{
+        value: "=",
+        label: "等于"
+    }, {
+        value: "in",
+        label: "包含"
+    }, {
+        value: "<>",
+        label: "不等于"
+    }, {
+        value: "noIn",
+        label: "不包含"
+    }, {
+        value: "null",
+        label: "为空"
+    }, {
+        value: "notNull",
+        label: "不为空"
+    }],
+    ordinal: [{
+        value: ">",
+        label: "大于"
+    }, {
+        value: ">=",
+        label: "大于等于"
+    }, {
+        value: "=",
+        label: "等于"
+    }, {
+        value: "<=",
+        label: "小于等于"
+    }, {
+        value: "<",
+        label: "小于"
+    }, {
+        value: "<>",
+        label: "不等于"
+    }, {
+        value: "between",
+        label: "介于"
+    }, {
+        value: "null",
+        label: "为空"
+    }, {
+        value: "notNull",
+        label: "不为空"
+    }],
+    "undefined": [{
+        value: "null",
+        label: "无"
+    }]
+}

+ 0 - 150
src/components/common/filterBox/filterOperators.json

@@ -1,150 +0,0 @@
-{
-    "index": [{
-        "value": "contain",
-        "label": "包含"
-    }, {
-        "value": "notContain",
-        "label": "不包含"
-    }, {
-        "value": "startsWith",
-        "label": "开头是"
-    }, {
-        "value": "endsWith",
-        "label": "结尾是"
-    }, {
-        "value": "equals",
-        "label": "等于"
-    }, {
-        "value": "notEquals",
-        "label": "不等于"
-    }, {
-        "value": "null",
-        "label": "为空"
-    }, {
-        "value": "notNull",
-        "label": "不为空"
-    }],
-    "string": [{
-        "value": "contain",
-        "label": "包含"
-    }, {
-        "value": "notContain",
-        "label": "不包含"
-    }, {
-        "value": "startsWith",
-        "label": "开头是"
-    }, {
-        "value": "endsWith",
-        "label": "结尾是"
-    }, {
-        "value": "equals",
-        "label": "等于"
-    }, {
-        "value": "notEquals",
-        "label": "不等于"
-    }, {
-        "value": "null",
-        "label": "为空"
-    }, {
-        "value": "notNull",
-        "label": "不为空"
-    }],
-    "scale": [{
-        "value": ">",
-        "label": "大于"
-    }, {
-        "value": ">=",
-        "label": "大于等于"
-    }, {
-        "value": "=",
-        "label": "等于"
-    }, {
-        "value": "<=",
-        "label": "小于等于"
-    }, {
-        "value": "<",
-        "label": "小于"
-    }, {
-        "value": "<>",
-        "label": "不等于"
-    }, {
-        "value": "between",
-        "label": "介于"
-    }, {
-        "value": "null",
-        "label": "为空"
-    }, {
-        "value": "notNull",
-        "label": "不为空"
-    }],
-    "time": [{
-        "value": "=",
-        "label": "等于"
-    }, {
-        "value": ">",
-        "label": "开始于"
-    }, {
-        "value": "<=",
-        "label": "结束于"
-    }, {
-        "value": "between",
-        "label": "介于"
-    }, {
-        "value": "null",
-        "label": "为空"
-    }, {
-        "value": "notNull",
-        "label": "不为空"
-    }],
-    "categorical": [{
-        "value": "=",
-        "label": "等于"
-    }, {
-        "value": "in",
-        "label": "包含"
-    }, {
-        "value": "<>",
-        "label": "不等于"
-    }, {
-        "value": "noIn",
-        "label": "不包含"
-    }, {
-        "value": "null",
-        "label": "为空"
-    }, {
-        "value": "notNull",
-        "label": "不为空"
-    }],
-    "ordinal": [{
-        "value": ">",
-        "label": "大于"
-    }, {
-        "value": ">=",
-        "label": "大于等于"
-    }, {
-        "value": "=",
-        "label": "等于"
-    }, {
-        "value": "<=",
-        "label": "小于等于"
-    }, {
-        "value": "<",
-        "label": "小于"
-    }, {
-        "value": "<>",
-        "label": "不等于"
-    }, {
-        "value": "between",
-        "label": "介于"
-    }, {
-        "value": "null",
-        "label": "为空"
-    }, {
-        "value": "notNull",
-        "label": "不为空"
-    }],
-    "undefined": [{
-        "value": "null",
-        "label": "无"
-    }]
-}

+ 26 - 17
src/components/dashboard/list.jsx

@@ -1,11 +1,10 @@
 import React from 'react'
 import { Layout, Button, Icon, Input, Menu, Dropdown, Card, Col, Row } from 'antd'
 import { connect } from 'dva'
-import { dateFormat } from '../../utils/baseUtils'
+import moment from 'moment'
 import Ellipsis from 'ant-design-pro/lib/Ellipsis'
-import DistributeBox from './distributeBox'
 import TransferBox from '../common/selectUserBox/selectUserBox';
-import 'ant-design-pro/dist/ant-design-pro.css'
+import AccessObjectBox from '../datasource/accessObjectBox'
 import Thumbnail from './thumbnail'
 import './list.less'
 import DeleteBox from '../common/deleteBox/deleteBox'
@@ -61,26 +60,32 @@ class DashboardList extends React.Component {
 
         const operationMenu = (
             <Menu className='menu-operation'>
-                { selectedRecord && currentUser.code === selectedRecord.code && <Menu.Item onClick={() => {
+                <Menu.Item
+                    onClick={(e) => {
+                        this.setState({ visibleDeleteBox: true})
+                    }}
+                >
+                    <Icon type="delete" />分享
+                </Menu.Item>
+                { selectedRecord && currentUser.code === selectedRecord.creatorCode && <Menu.Divider />}
+                { selectedRecord && currentUser.code === selectedRecord.creatorCode && <Menu.Item onClick={() => {
                     this.setState({visibleDistributeBox: true})
                 }}> 
                     <Icon type='share-alt'/>分发
                 </Menu.Item>}
-                { selectedRecord && currentUser.code === selectedRecord.code && <Menu.Divider />}
-                { selectedRecord && currentUser.code === selectedRecord.code && <Menu.Item
+                { selectedRecord && currentUser.code === selectedRecord.creatorCode && <Menu.Item
                     onClick={()=>{
                         this.setState({ visibleTransferBox: true})
                     }}
                 >
                     <Icon type="swap" />移交
                 </Menu.Item>}
-                { selectedRecord && currentUser.code === selectedRecord.code && <Menu.Item
+                { selectedRecord && currentUser.code === selectedRecord.creatorCode && <Menu.Item
                     onClick={(e) => {
                         this.setState({ visibleDeleteBox: true})
                     }}
                 >
                     <Icon type="delete" />删除
-                    
                 </Menu.Item>}
             </Menu>
         )
@@ -140,7 +145,7 @@ class DashboardList extends React.Component {
                             </Row>
                             <Row className='footer' type='flex' justify='end' align='bottom'>
                                 <Col style={{ textAlign: 'left' }} span={22}>
-                                    <Row>{l.creator} {dateFormat(l.createTime, 'yyyy-MM-dd')}</Row>
+                                    <Row>{l.creatorName} {moment(l.createTime).format('YYYY-MM-DD')}</Row>
                                 </Col>
                                 <Col span={2} style={{ textAlign: 'right' }}>
                                     <Dropdown overlay={operationMenu} trigger={['click']}>
@@ -170,6 +175,10 @@ class DashboardList extends React.Component {
         });
     }
 
+    distribute = (groups, gerens) => {
+        console.log(groups, gerens);
+    }
+
     render() {
         const { dispatch, dashboard } = this.props;
         const { visibleDistributeBox, visibleTransferBox, visibleDeleteBox, selectedRecord } = this.state
@@ -205,18 +214,18 @@ class DashboardList extends React.Component {
                         </div>
                     </Card>
                 </Content>
-                <DistributeBox
-                    visibleDistributeBox={visibleDistributeBox}
-                    selectedRecord={this.state.selectedRecord}
+                {visibleDistributeBox && <AccessObjectBox
+                    visibleBox={visibleDistributeBox}
                     hideBox={() => {
                         this.setState({
                             visibleDistributeBox: false
-                        });
-                    }} />
-                <TransferBox
+                        })
+                    }}
+                    okHandler={this.distribute} />}
+                {visibleTransferBox && <TransferBox
                     visibleBox={visibleTransferBox}
                     title='选择移交对象'
-                    onOk={(user) => {
+                    okHandler={(user) => {
                         dispatch({ type: 'dashboard/transfer', dashboardCode: this.state.selectedRecord.code, userCode: user.code });
                     }}
                     hideBox={() => {
@@ -224,7 +233,7 @@ class DashboardList extends React.Component {
                             visibleTransferBox: false
                         })
                     }}
-                />
+                />}
                 <DeleteBox
                     visibleDeleteBox={visibleDeleteBox}
                     type='dashboard'

+ 1 - 22
src/components/dashboardDesigner/chooseChartBox.jsx

@@ -22,6 +22,7 @@ class ChooseChartBox extends React.Component {
     componentDidMount() {
         const { dispatch } = this.props;
         dispatch({ type: 'chart/fetchList' });
+        window.addEventListener('resize', this.onWindowResize);
     }
 
     onWindowResize = () => {
@@ -189,28 +190,6 @@ class ChooseChartBox extends React.Component {
                 />
             </Modal>
         )
-        // return (
-        //     <Modal
-        //         className='element-config'
-        //         title={`${operation==='create'?'新增':'修改'}元素`}
-        //         visible={visibleBox}
-        //         onOk={() => {this.okHandler()}}
-        //         onCancel={hideElementConfigBox}
-        //         maskClosable={false}
-        //         destroyOnClose={true}
-        //     >
-        //         <div>
-        //             <Select defaultValue={dashboardDesigner.configBoxForm.type} style={{ width: 120 }} 
-        //                 onChange={(value) => { dispatch( {type: 'dashboardDesigner/handleFieldChange', name: 'type', value: value})}}>
-        //                 <Option value="chart">图表</Option>
-        //                 <Option value="simple">基础元素</Option>
-        //             </Select>
-        //         </div>
-        //         <div style={{display: `${dashboardDesigner.configBoxForm.type === "simple" ? "inline":"none"}`}}>
-        //             <BraftEditor {...this.editorProps}/>
-        //         </div>
-        //     </Modal>
-        // )
     } 
 }
 

+ 4 - 2
src/components/dashboardDesigner/configForm.jsx

@@ -30,12 +30,14 @@ class ConfigForm extends React.Component {
     render() {
         const { dashboardDesigner, dispatch } = this.props;
         const { activeKey, editing, selectedDataSource, selectedColumn } = this.state;
-        const { relationColumns, dataSources, columnFetching } = dashboardDesigner;
+        const { relationColumns, dataSources, description, columnFetching } = dashboardDesigner;
 
         return <Form className='config-form'>
             <Divider>基础设置</Divider>
             <Form.Item label='备注'>
-                <TextArea autosize={{ minRows: 2, maxRows: 6 }} />
+                <TextArea value={description} autosize={{ minRows: 2, maxRows: 6 }} onChange={(e) => {
+                    dispatch({ type: 'dashboardDesigner/setField', name: 'description', value: e.target.value });
+                }}/>
             </Form.Item>
             <Divider>自定义过滤字段</Divider>
             <div className='filtercolumns'>

+ 12 - 26
src/components/dashboardDesigner/content.jsx

@@ -150,6 +150,13 @@ class DashboardDesignerContent extends React.Component {
         }) });
     }
 
+    isOwner = () => {
+        const { dashboardDesigner, main } = this.props;
+        const { creatorCode } = dashboardDesigner;
+        const { currentUser } = main;
+        return currentUser.code === creatorCode;
+    }
+
     render() {
         const { dashboardDesigner, dispatch } = this.props;
         const { code, editMode, filters } = dashboardDesigner;
@@ -186,25 +193,7 @@ class DashboardDesignerContent extends React.Component {
                         </Tag>
                     </div>
                     {visibleFilterBox && <FilterBox type='dashboard' code={code} columns={this.getRelationFilterColumns()} filterData={filters} visibleFilterBox={visibleFilterBox} showFilterBox={this.showFilterBox} hideFilterBox={this.hideFilterBox} createFilters={this.createFilters} />}
-                <div className='viewtype'>
-                    {/* {editMode && <Dropdown overlay={(
-                        <Menu onClick={(item) => {
-                            const type = item.key;
-                            if(type === 'chart') {
-                                this.showBox("create");
-                            }else {
-                                const { dispatch } = this.props;
-                                dispatch({ type: 'dashboardDesigner/addRichText' });
-                            }
-                        }}>
-                            <Menu.Item key='chart'>图表</Menu.Item>
-                            <Menu.Item key='richText'>富文本</Menu.Item>
-                        </Menu>
-                    )} trigger={['click']}>
-                        <Button>
-                            <Icon type="plus" />添加
-                        </Button>
-                    </Dropdown>} */}
+                {this.isOwner() && <div className='viewtype'>
                     <Tooltip title="图表">
                         <Icon className='viewtype-icon' type="area-chart" theme="outlined" onClick={(item) => {
                             this.showBox("create");
@@ -216,14 +205,14 @@ class DashboardDesignerContent extends React.Component {
                         }}/>
                     </Tooltip>
                     <ChooseChartBox visibleBox={visibleChooseChartBox} hideBox={this.hideBox} />
-                </div>
+                </div>}
             </Header>
             <Content className='dashboard-content'>
                 <Layout className='content-layout'>
                     <Content className='viewlayout' ref='contentEl'>
                         <ViewLayout contentSize={contentSize} reset={this.refreshContentSize} editMode={editMode}/>
                     </Content>
-                    <Sider className='config-sider' width={!!editMode ? 380 : 0}>
+                    <Sider className='config-sider' width={this.isOwner() && editMode ? 380 : 0}>
                         <ConfigForm />
                     </Sider>
                 </Layout>
@@ -231,8 +220,5 @@ class DashboardDesignerContent extends React.Component {
         </Layout>
     }
 }
-function mapStateToProps(state) {
-    const dashboardDesigner = state.present.dashboardDesigner;
-    return { dashboardDesigner }
-}
-export default connect(mapStateToProps)(DashboardDesignerContent);
+
+export default connect(({ present: { main, dashboardDesigner } }) => ({ main, dashboardDesigner }))(DashboardDesignerContent);

+ 23 - 14
src/components/dashboardDesigner/header.jsx

@@ -17,6 +17,13 @@ class Header extends React.Component {
         this.setState({ visibleConfirm: visible });
     }
 
+    isOwner = () => {
+        const { dashboardDesigner, main } = this.props;
+        const { creatorCode } = dashboardDesigner;
+        const { currentUser } = main;
+        return currentUser.code === creatorCode;
+    }
+
     render() {
         const { dashboardDesigner, dispatch } = this.props;
         const { editMode } = dashboardDesigner;
@@ -24,7 +31,7 @@ class Header extends React.Component {
         return (
             <div className='dashboarddesigner-header'>
                 <div className='header-item toolbar-back'>
-                    <Popconfirm
+                    {this.isOwner() && <Popconfirm
                         placement="bottomLeft"
                         title="离开前保存修改吗?"
                         visible={this.state.visibleConfirm}
@@ -52,37 +59,43 @@ class Header extends React.Component {
                         <Button onClick={() => {
                             console.log(dashboardDesigner.dirty);
                             if(!dashboardDesigner.dirty) {
-                                dispatch({ type: 'main/redirect', path: '/dashboard' });
+                                dispatch({ type: 'main/goBack', path: '/chart' });
                             }
                         }}>
                             <Icon type='left' />返回
                         </Button>
-                    </Popconfirm>
-                    <Button onClick={() => {
+                    </Popconfirm>}
+                    {!this.isOwner() && <Button onClick={(e) => {
+                        dispatch({ type: 'main/goBack', path: '/chart' });
+                    }}>
+                        <Icon type='left' />返回
+                    </Button>}
+                    {this.isOwner() && <Button onClick={() => {
                         if(dashboardDesigner.code && dashboardDesigner.code !== -1) {
                             dispatch({ type: 'dashboardDesigner/saveWithThumbnail' });
                         }else {
                             dispatch({ type: 'dashboard/remoteAdd' });
                         }
-                    }}><Icon type='save' />保存</Button>
+                    }}><Icon type='save' />保存</Button>}
                 </div>
                 <div className='header-item toolbar-title'>
                     <Input
                         className='input-title'
                         value={dashboardDesigner.name}
-                        addonAfter={<Icon type="edit" 
+                        disabled={!this.isOwner()}
+                        addonAfter={this.isOwner() ? <Icon type="edit" 
                             onClick={(e) => {
                                 const input = e.currentTarget.parentElement.parentElement.getElementsByTagName('input')[0];
                                 input && input.focus()
                             }}
-                        />}
+                        /> : null}
                         onChange={(e) => {
                             dispatch({ type: 'dashboardDesigner/setField', name: 'name', value: e.target.value });
                         }}
                     />
                 </div>
                 <div className='header-item toolbar-viewswitch'>
-                    <Switch
+                    {this.isOwner() && <Switch
                         className={`mode-switch ${editMode ? 'edit-mode-switch' : 'view-mode-switch'}`}
                         checked={editMode}
                         checkedChildren="编辑"
@@ -96,15 +109,11 @@ class Header extends React.Component {
                                 window.dispatchEvent(e);
                             }, 300);
                         }}
-                    />
+                    />}
                 </div>
             </div>
         );
     }
 }
 
-function mapStateToProps(state) {
-    const dashboardDesigner = state.present.dashboardDesigner;
-    return { dashboardDesigner }
-}
-export default connect(mapStateToProps)(Header);
+export default connect(({ present: { main, dashboardDesigner } }) => ({ main, dashboardDesigner }))(Header);

+ 15 - 22
src/components/dashboardDesigner/header.less

@@ -5,29 +5,22 @@
     .toolbar-title {
         flex: 1;
         text-align: center;
-        .ant-input-group-wrapper {
-            display: inline-block;
-            vertical-align: middle;
-            width: 200px;
-            margin-bottom: 5px;
+        .input-title {
+            text-align: center;
+            font-size: 18px;
+            color: rgba(0, 0, 0, 0.65);
+            cursor: text;
+            border: none;
+            border-bottom-right-radius: 4px;
+            border-top-right-radius: 4px;
+            background-color: transparent;
         }
-        .ant-input-group{
-            width: 300px;
-            .input-title {
-                text-align: center;
-                font-size: 18px;
-                border: none;
-                border-bottom-right-radius: 4px;
-                border-top-right-radius: 4px;
-                background-color: transparent;
-            }
-            .ant-input-group-addon {
-                cursor: pointer;
-                border: none;
-                background: transparent;
-                :hover {
-                    color: #40a9ff;
-                }
+        .ant-input-group-addon {
+            cursor: pointer;
+            border: none;
+            background: transparent;
+            :hover {
+                color: #40a9ff;
             }
         }
     }

+ 5 - 4
src/components/dashboardDesigner/viewLayout.jsx

@@ -31,7 +31,8 @@ class ViewLayout extends React.PureComponent {
     }
 
     createElement = (item, isPreview) => {
-        const { dispatch, dashboardDesigner } = this.props;
+        const { dispatch, main, dashboardDesigner } = this.props;
+        const { currentUser } = main;
         const { editMode } = dashboardDesigner;
         const { code, name, viewType, layout, chartCode, filters } = item;
         return (
@@ -43,12 +44,12 @@ class ViewLayout extends React.PureComponent {
                             <Icon className='visible-icon' type="info-circle" theme="outlined" />
                         </Tooltip>}
                         {!isPreview && viewType !== 'richText' && <Icon type="arrows-alt" onClick={() => this.showPreviewBox(item)}/>}
-                        {editMode && viewType !== 'richText' &&  <Icon type='edit' onClick={() => {
+                        {editMode && item.creatorCode === currentUser.code && viewType !== 'richText' &&  <Icon type='edit' onClick={() => {
                             dispatch({ type: 'dashboard/remoteModify' });
                             dispatch({ type: 'chartDesigner/reset' });
                             dispatch({ type: 'main/redirect', path: '/chart/' + chartCode });
                         }}/>}
-                        {!isPreview && editMode && <Icon type='delete' onClick={() => {
+                        {!isPreview && editMode && item.creatorCode === currentUser.code && <Icon type='delete' onClick={() => {
                             dispatch({ type: 'dashboardDesigner/deleteItem', item });
                         }} />}
                         {isPreview && <Icon type="close" onClick={this.hidePreviewBox}/>}
@@ -124,4 +125,4 @@ class ViewLayout extends React.PureComponent {
     }
 }
 
-export default connect(({ present: { dashboardDesigner } }) => ({ dashboardDesigner }))(ViewLayout);
+export default connect(({ present: { main, dashboardDesigner } }) => ({ main, dashboardDesigner }))(ViewLayout);

+ 8 - 4
src/components/datasource/accessObjectBox.jsx

@@ -25,8 +25,8 @@ class AccessObjectBox extends React.Component {
     getAccessObject = () => {
         const { okHandler, hideBox } = this.props;
         const { selectedGroups, selectedUsers } = this.state;
-        okHandler(selectedGroups, selectedUsers);
-        hideBox();
+        typeof okHandler === 'function' && okHandler(selectedGroups, selectedUsers);
+        typeof hideBox === 'function' && hideBox();
     }
 
     render() {
@@ -124,9 +124,11 @@ class AccessObjectBox extends React.Component {
         return (
             <Modal
                 className='accessobject-box'
+                height='80%'
+                width='60%'
                 title={
                     <Row>
-                        <Col span={14}>选择分配对象</Col>
+                        <Col span={14}>选择用户组或用户</Col>
                         <Col span={8}><Search 
                             placeholder="请输入关键字"
                             value={this.state.filterLabel}
@@ -151,7 +153,9 @@ class AccessObjectBox extends React.Component {
                     <TabPane tab="用户组" key="userGroup" >
                         <Table
                             className='usergroup-table'
-                            columns={userGroupColumns}
+                            columns={userGroupColumns.map(c => ({
+                                ...c, width: 100
+                            }))}
                             dataSource={userGroup.list.filter(l => {
                                 let reg = new RegExp('(' + filterLabel + '){1}', 'ig');
                                 return (l.name || '').search(reg) !== -1;

+ 10 - 3
src/components/datasource/accessObjectBox.less

@@ -1,11 +1,18 @@
 .accessobject-box {
-    width: 60% !important;
     .ant-modal-body {
         padding: 0;
-        .ant-tabs {
-            .ant-tabs-bar {
+        max-height: 50vh;
+        overflow-y: auto;
+        .accessobject-tabs {
+            .accessobject-tabs {
                 margin: 0;
             }
         }
+        .choosechart-table {
+            .ant-table-header {
+                overflow-y: hidden;
+                margin-right: 6px;
+            }
+        }
     }
 }

+ 2 - 0
src/constants/url.js

@@ -159,5 +159,7 @@ const URLS = {
     DASHBOARD_DELETE: BASE_URL + '/delDashboards', // 删除看板
 
     DASHBOARD_UPDATE: BASE_URL + '/updateDashboards', // 更新看板
+
+    DASHBOARD_TRANSFER: BASE_URL + '/changeDashOrder', // 看板移交
 }
 export default URLS

+ 3 - 2
src/models/chart.js

@@ -337,7 +337,7 @@ export default {
             try{
                 const chartDesigner = yield select(state => state.present.chartDesigner);
                 const { filters, code, header, baseConfig, pieConfig, lineConfig, aggregateTableConfig, dataViewConfig,
-                    barConfig, scatterConfig, otherConfig, description, group, chartOption, styleConfig } = chartDesigner;
+                    barConfig, scatterConfig, otherConfig, description, group, chartOption, fetchConfig, styleConfig } = chartDesigner;
                 let body = {
                     chartId: code,
                     filters: JSON.stringify(filters),
@@ -348,7 +348,8 @@ export default {
                     style: '',
                     otherConfig: JSON.stringify(otherConfig),
                     chartsGroup: group+'' ? group : '-1',
-                    chartOption: JSON.stringify(chartOption)
+                    chartOption: JSON.stringify(chartOption),
+                    fetchConfig: JSON.stringify(fetchConfig),
                 }; // 基本属性
                 if(baseConfig.viewType === 'bar') {
                     body.chartType = 'Histogram';

+ 11 - 2
src/models/chartDesigner.js

@@ -47,7 +47,8 @@ export default {
             styleConfig: { visibleIndex: true },
             filters: [],
             chartOption: {},
-            dirty: false
+            dirty: false,
+            fetchConfig: {}
         },
         columns: [],
         allPermission: [
@@ -70,7 +71,8 @@ export default {
         description: '',
         filters: [],
         chartOption: {},
-        dirty: false
+        dirty: false,
+        fetchConfig: {}
     },
     reducers: {
         /**
@@ -325,6 +327,7 @@ export default {
             const { baseConfig } = chartDesigner;
             const { viewType } = baseConfig;
 
+            yield put({ type: 'silentSetField', name: 'fetchConfig', value: {} });
             if(viewType === 'bar') {
                 const { barConfig } = chartDesigner;
                 if(barConfig.xAxis.column.value && barConfig.yAxis.column.value) {
@@ -417,6 +420,7 @@ export default {
                     message.error('请求柱状图数据失败: ' + (res.err || res.data.msg));
                     yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
                 }
+                yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
             }catch(e) {
                 console.error(e);
                 yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
@@ -462,6 +466,7 @@ export default {
                     message.error('请求饼图数据失败: ' + (res.err || res.data.msg));
                     yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
                 }
+                yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
             }catch(e) {
                 console.error(e);
                 yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
@@ -508,6 +513,7 @@ export default {
                     message.error('请求折线图数据失败: ' + (res.err || res.data.msg));
                     yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
                 }
+                yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
             }catch(e) {
                 console.error(e);
                 yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
@@ -554,6 +560,7 @@ export default {
                     message.error('请求散点图数据失败: ' + (res.err || res.data.msg));
                     yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
                 }
+                yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
             }catch(e) {
                 console.error(e);
                 yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
@@ -596,6 +603,7 @@ export default {
                     message.error('请求列表数据失败: ' + (res.err || res.data.msg));
                     yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
                 }
+                yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
             }catch(e) {
                 console.error(e);
                 yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
@@ -677,6 +685,7 @@ export default {
                     message.error('请求统计数据失败: ' + (res.err || res.data.msg));
                     yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
                 }
+                yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
             }catch(e) {
                 console.error(e);
                 yield put({ type: 'silentSetField', name: 'chartOption', value: {} });

+ 17 - 13
src/models/dashboard.js

@@ -35,6 +35,7 @@ export default {
                 const res = yield call(service.fetch, {
                     url: URLS.DASHBOARD_LIST
                 });
+                console.log('请求看板列表', res);
                 if(!res.err && res.data.code > 0) {
                     const resData = res.data.data;
                     let list = resData.map(d => {
@@ -45,11 +46,11 @@ export default {
                             items: items,
                             description: d.bdNote || '',
                             thumbnail: d.thumbnail,
-                            creator: d.createBy,
+                            creatorCode: d.createId + '',
+                            creatorName: d.createBy,
                             createTime: d.createDate,
                         }
                     })
-                    console.log('请求看板列表', list);
                     yield put({ type: 'list', list: list });
                 }else {
                     message.error('请求看板列表失败: ' + (res.err || res.data.msg));
@@ -73,6 +74,7 @@ export default {
                 if(!res.err && res.data.code > 0) {
                     const resData = res.data.data;
                     let items = resData.bdConfiguration ? JSON.parse(resData.bdConfiguration) : [];
+                    let relationColumns = resData.relationColumns ? JSON.parse(resData.relationColumns) : [];
 
                     let data = {
                         code:  resData.id+'',
@@ -80,10 +82,11 @@ export default {
                         items: items,
                         description: resData.bdNote || '',
                         thumbnail: resData.thumbnail,
-                        creator: resData.createBy,
+                        creatorCode: resData.createId + '',
+                        creatorName: resData.createBy,
                         createTime: resData.createDate,
                         dataSources: [],
-                        relationColumns: [],
+                        relationColumns: relationColumns
                     }
 
                     let fields = [];
@@ -105,12 +108,13 @@ export default {
         *remoteAdd(action, { select, call, put }) {
             try {
                 const dashboardDesigner = yield select(state => state.present.dashboardDesigner);
-                const { name, items, thumbnail } = dashboardDesigner;
+                const { name, items, thumbnail, relationColumns } = dashboardDesigner;
                 let body = {
                     bdName: name,
                     bdNote: '',
                     bdConfiguration: JSON.stringify(items),
                     thumbnail: thumbnail,
+                    relationColumns: JSON.stringify(relationColumns),
                     createBy: 'zhuth'
                 }
                 console.log('新增看板', body);
@@ -161,13 +165,14 @@ export default {
         *remoteModify(action, { select, call, put }) {
             try {
                 const dashboardDesigner = yield select(state => state.present.dashboardDesigner);
-                const { code, name, items, thumbnail } = dashboardDesigner;
+                const { code, name, items, thumbnail, description, relationColumns } = dashboardDesigner;
                 let body = {
                     id: code,
                     bdName: name,
-                    bdNote: '',
+                    bdNote: description,
                     bdConfiguration: JSON.stringify(items),
                     thumbnail: thumbnail,
+                    relationColumns: JSON.stringify(relationColumns),
                     createBy: 'zhuth'
                 }
                 console.log('修改看板', body);
@@ -222,12 +227,11 @@ export default {
                 id: dashboardCode
             };
             try {
-                // const res = yield call(service.fetch, {
-                //     url: URLS.DASHBOARD_TRANSFER,
-                //     body
-                // });
-                // console.log('看板移交', body, res);
-                const res = {data:{code:1}};
+                const res = yield call(service.fetch, {
+                    url: URLS.DASHBOARD_TRANSFER,
+                    body
+                });
+                console.log('看板移交', body, res);
                 if(!res.err && res.data.code > 0) {
                     const dashboard = yield select(state => state.present.dashboard);
                     const list = dashboard.list;

+ 2 - 0
src/models/dashboardDesigner.js

@@ -89,6 +89,8 @@ export default {
                 code: chart.code,
                 chartCode: chart.code,
                 name: chart.name,
+                creatorCode: chart.creatorCode,
+                creatorName: chart.creatorName,
                 dataSourceCode: chart.dataSourceCode+'',
                 dataSourceName: chart.dataSourceName,
                 viewType: 'chart',

+ 1 - 1
src/utils/request.js

@@ -48,7 +48,7 @@ export default function request(url, options) {
     }) {
       this.url = url;
       this.retry = retry || 0;
-      this.timeout = timeout || 30000;
+      this.timeout = timeout || 60000;
       this.options = options;
     }