Browse Source

添加浏览历史逻辑

zhuth 7 years ago
parent
commit
4d628bff85

+ 2 - 2
src/components/chart/distributeBox.jsx

@@ -209,7 +209,7 @@ class DistributeBox extends React.Component {
             dataIndex: 'targets',
             render: (targets, record, index) => <div key={index}>
                 {
-                    targets.map((item, index) => <Tag className='user-tag' key={index}>{item.isGroup ? <Icon type='group' /> : <Icon type='geren' />}{item.name}</Tag>)
+                    targets.map((item, index) => <Tag className='user-tag' key={index}>{item.isGroup ? <Icon type="team" theme="outlined" /> : <Icon type="user" theme="outlined" />}{item.name}</Tag>)
                 }
                 <Tag className='user-tag' onClick={this.showAccessObjectBox}><Icon type="plus" /></Tag>
             </div>,
@@ -224,7 +224,7 @@ class DistributeBox extends React.Component {
         
         return (
             <Modal
-                width={1200}
+                width='80%'
                 className='distribute-box'
                 title='图表分发策略'
                 visible={visibleDistributeBox}

+ 1 - 0
src/components/chart/list.jsx

@@ -165,6 +165,7 @@ class ChartList extends React.Component {
                             <Row className='thumb' onClick={l.access ? () => {
                                 dispatch({ type: 'chartDesigner/reset' });
                                 dispatch({ type: 'main/redirect', path: '/chart/' + l.code });
+                                dispatch({ type: 'chart/addHistory', code: l.code });
                             } : () => {}}>
                                 {!l.access && <div className='deny-body'>
                                     <div className='deny-tip'>无数据权限</div>

+ 5 - 5
src/components/chartDesigner/header.jsx

@@ -36,7 +36,7 @@ class Header extends React.Component {
 
     render() {
         const { chartDesigner, dispatch, past, future } = this.props;
-        const { newHeaderLabel } = this.state;
+        const { visibleCopyBox, newHeaderLabel } = this.state;
         return (
             <div className='header'>
                 <div className='header-item toolbar-back'>
@@ -109,9 +109,9 @@ class Header extends React.Component {
                             }}>
                             </Button>
                         </Tooltip>}
-                        {this.isOwner() && <Modal
+                        {this.isOwner() && visibleCopyBox && <Modal
                             title="以当前图表配置创建新的图表副本"
-                            visible={this.state.visibleCopyBox}
+                            visible={visibleCopyBox}
                             okText='创建'
                             onOk={this.copyHandler}
                             onCancel={() => {this.setState({visibleCopyBox:false})}}
@@ -123,7 +123,7 @@ class Header extends React.Component {
                                 });
                             }} />
                         </Modal>}
-                        <Tooltip title='撤销'>
+                        {/* <Tooltip title='撤销'>
                             <Button className='tools-btn' icon='undo' disabled={past.length === 0} onClick={() => {
                                 dispatch(ActionCreators.undo());
                             }}></Button>
@@ -132,7 +132,7 @@ class Header extends React.Component {
                             <Button className='tools-btn' icon='redo' disabled={future.length === 0} onClick={() => {
                                 dispatch(ActionCreators.redo());
                             }}></Button>
-                        </Tooltip>
+                        </Tooltip> */}
                     </div>
                 </div>
             </div>

+ 1 - 0
src/components/dashboard/list.jsx

@@ -123,6 +123,7 @@ class DashboardList extends React.Component {
                             <Row className='thumb' onClick={() => {
                                 dispatch({ type: 'dashboardDesigner/reset' });
                                 dispatch({ type: 'main/redirect', path: '/dashboard/' + l.code });
+                                dispatch({ type: 'dashboard/addHistory', code: l.code });
                             }}>
                                 <Thumbnail type={l.type} code={l.code} option={l.chartOption} thumbnail={l.thumbnail}/>
                             </Row>

+ 2 - 2
src/components/dashboardDesigner/content.jsx

@@ -24,10 +24,10 @@ class DashboardDesignerContent extends React.Component {
     }
 
     componentDidMount() {
-        // 这里强制延迟2.5s等待页面渲染结束,也许有更好的办法。
+        // 这里延迟等待页面渲染结束,也许有更好的办法。
         window.setTimeout(() => {
             this.refreshContentSize(true);
-        }, 2500);
+        }, 1500);
         window.addEventListener("resize", () => {
             this.refreshContentSize(true);
         });

+ 1 - 1
src/components/datasource/columnConfig.jsx

@@ -341,7 +341,7 @@ class DataSourceColumnConfig extends React.Component {
                                     >
                                         <Button disabled={!dataSource.newOne.address || loading.models.dataSource} onClick={() => {
                                             if(!dataSource.newOne.columns || dataSource.newOne.columns.length === 0) {
-                                                dispatch({ type: 'dataSource/importNewModelColumns' });
+                                                dispatch({ type: 'dataSource/importNewModelColumns', cover: true });
                                             }
                                         }}>
                                         {

+ 12 - 3
src/constants/url.js

@@ -1,5 +1,5 @@
 const BASE_URL = 'http://192.168.253.189:8081/BI';
-// const BASE_URL = 'http://192.168.253.129:8080';
+// const BASE_URL = 'http://192.168.253.129:8011';
 
 /**后台接口地址 */
 const URLS = {
@@ -50,7 +50,7 @@ const URLS = {
     
     DATASOURCE_QUERY_DATACOLUMNS: BASE_URL + '/DataBase/getColumnData', // 获得数据源下的列
 
-    DATASOURCE_QUERY_COLUMNDATA: BASE_URL + '/getScreenByBaseId', // 数据源获得列去重之后的数据
+    DATASOURCE_QUERY_COLUMNDATA: BASE_URL + '/getScreenByBaseId', // 数据源关键字查询获得列去重之后的数据(20条)
 
     DATASOURCE_POLICY_LIST: BASE_URL + '/getDbStrategys', // 获得数据源的策略
 
@@ -90,7 +90,7 @@ const URLS = {
 
     CHART_LIST: BASE_URL + '/getListCharts', // 获得图表列表
 
-    CHART_QUERY_COLUMNDATA: BASE_URL + '/showScreenData', // 图表获得列去重之后的数据
+    CHART_QUERY_COLUMNDATA: BASE_URL + '/showScreenData', // 图表获得关键字查询过滤列去重之后的数据(20条)
 
     CHART_DETAIL: BASE_URL + '/getChartsConfig', // 获得单个图表详细数据
 
@@ -165,5 +165,14 @@ const URLS = {
     DASHBOARD_SHARE: BASE_URL + '/addObject', // 看板分发
 
     DASHBOARD_TRANSFER: BASE_URL + '/changeDashOrder', // 看板移交
+
+    /***************************************浏览记录***************************************/
+    
+    HISTORY_ADD: BASE_URL + '/addRecord', // 添加图表、看板浏览记录 0 - 图表  1 - 看板
+    
+    HISTORY_CHART_LIST: BASE_URL + '/getChartRecode', // 查询图表浏览记录列表
+
+    HISTORY_DASHBOARD_LIST: BASE_URL + '/getDashRecode', // 查询看板浏览记录列表
+
 }
 export default URLS

+ 19 - 0
src/models/chart.js

@@ -802,6 +802,25 @@ export default {
                 console.log(body, e);
                 message.error('移交失败: ' + e);
             }
+        },
+        *addHistory(action, { put, call, select }) {
+            const { code } = action;
+            const body = {
+                tarId: code,
+                type: '0'
+            };
+            try {
+               const res = yield call(service.fetch, {
+                   url: URLS.HISTORY_ADD,
+                   body
+               });
+               if(res.err || res.data.code <= 0) {
+                   message.error('添加图表浏览历史失败: ' + (res.err || res.data.msg));
+               }
+            }catch(e) {
+                console.error(body, e);
+                message.error('添加图表浏览历史失败: ' + e);
+            }
         }
     },
     subscriptions: {

+ 19 - 0
src/models/dashboard.js

@@ -289,6 +289,25 @@ export default {
                 console.log(body, e);
                 message.error('移交失败: ' + e);
             }
+        },
+        *addHistory(action, { put, call, select }) {
+            const { code } = action;
+            const body = {
+                tarId: code,
+                type: '1'
+            };
+            try {
+               const res = yield call(service.fetch, {
+                   url: URLS.HISTORY_ADD,
+                   body
+               });
+               if(res.err || res.data.code <= 0) {
+                   message.error('添加看板浏览历史失败: ' + (res.err || res.data.msg));
+               }
+            }catch(e) {
+                console.error(body, e);
+                message.error('添加看板浏览历史失败: ' + e);
+            }
         }
     },
     subscriptions: {

+ 6 - 0
src/models/dashboardDesigner.js

@@ -404,6 +404,12 @@ export default {
             }finally {
                 yield put({ type: 'dashboardDesigner/silentSetField', name: 'loading', value: false });
                 yield put({ type: 'setItemFetching', code: chartCode, fetching: false });
+                // 主动触发一次window的resize事件
+                window.setTimeout(() => {
+                    var e = document.createEvent("Event");
+                    e.initEvent("resize", true, true);
+                    window.dispatchEvent(e);
+                }, 300);
             }
         },
         *saveWithThumbnail(action, {put, call}) {