Просмотр исходного кода

Merge branch 'master' of ssh://10.10.100.21/source/platform-bi-web

zhuth 6 лет назад
Родитель
Сommit
35d8bea0c0

+ 2 - 2
src/components/chartDesigner/charts/drillDownBar.jsx

@@ -5,9 +5,9 @@ import './drillDownBar.less';
 
 class DrillDownBar extends Component {
     render() { 
-        const { drillDown } = this.props
+        const { drillDown, className } = this.props
         return ( 
-            <Breadcrumb className="drillDownBar"
+            <Breadcrumb className={className}
                 separator=">"
             > 
             {drillDown.map((g,index) => (

+ 1 - 1
src/components/chartDesigner/charts/drillDownBar.less

@@ -1,4 +1,4 @@
-.drillDownBar{
+.drilldownbar{
     margin:0px 0px 0px 15px;
 }
 .linkItem {

+ 9 - 3
src/components/chartDesigner/charts/echartsView.jsx

@@ -7,15 +7,21 @@ import { connect } from 'dva'
 import { Icon,message } from 'antd';
 import moment from 'moment';
 moment.locale('zh-cn');
+moment.suppressDeprecationWarnings = true;
+const isMobile = function() {
+    if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)))
+        return true;
+    else
+        return false;
+};
 class EchartsView extends Component {
     render() { 
         const { chartOption, inDashBoard, item } = this.props;
-        const { themeConfig } = chartOption;
-        const { name: themeName } = themeConfig || {};
         if(!chartOption || ((!chartOption.series || chartOption.series.length === 0) && (!chartOption.baseOption || !chartOption.baseOption.series || chartOption.baseOption.series.length === 0))) {
             return <EmptyContent />
         }else {
             const { baseOption } = chartOption;
+            const { name } = baseOption;//主题
             //drillDown 钻取层级数组
             let { drillDown } = chartOption;
             const { originConfig } = baseOption;
@@ -48,7 +54,7 @@ class EchartsView extends Component {
                                      *  在钻取开启后 drillDown会生成钻取数组 默认为第一层
                                      *  DrillDownBar组件为钻取层级工具栏
                                      */
-                                    <DrillDownBar className={`drilldownbar ${themeName}`} inDashBoard={inDashBoard} item={item} key={hashcode(drillDown)} drillDown={drillDown}></DrillDownBar>
+                                    <DrillDownBar className={`drilldownbar ${name}`} inDashBoard={inDashBoard} item={item} key={hashcode(drillDown)} drillDown={drillDown}></DrillDownBar>
                                 }
                             </div>
                         )

+ 15 - 0
src/components/chartDesigner/sections/style/theme/theme2.less

@@ -198,4 +198,19 @@
             }
         }
     }
+}
+
+.drilldownbar.theme2{
+    .linkItem{
+        color: #31e6dfdd;
+        cursor: pointer;
+    }
+    .lastItem {
+        color: #fff;
+        cursor: context-menu;
+    }
+    .ant-breadcrumb-separator{
+        color: #fff;
+        cursor: context-menu;
+    }
 }

+ 33 - 11
src/models/chartDesigner.js

@@ -405,7 +405,7 @@ export default {
             const { page, pageSize, drillDown } = action;
 
             try{
-                yield put({ type: 'silentSetField', name: 'fetchConfig', value: {} });
+                //yield put({ type: 'silentSetField', name: 'fetchConfig', value: {} });
                 if(viewType === 'bar') {
                     const { barConfig } = chartDesigner;
                     if(barConfig.xAxis.column.value && barConfig.yAxis.column.value &&
@@ -420,20 +420,21 @@ export default {
                 }else if(viewType === 'pie') {
                     const { pieConfig } = chartDesigner;
                     if(pieConfig.xAxis.column.value && pieConfig.yAxis.column.value &&
-                        pieConfig.drillable?pieConfig.drillList.filter(item=>{
+                        (pieConfig.drillable?pieConfig.drillList.filter(item=>{
                             return Object.keys(item.column).length===0
-                        }).length===0:true) {
+                        }).length===0:true)) {
                         //开启了钻取 并且钻取配置不能有空的配置 否则不显示图表   
                         yield put({ type: 'fetchPieData', drillDown });
                     }else {
                         yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
                     }
                 }else if(viewType === 'line') {
+                    console.log(chartDesigner);
                     const { lineConfig } = chartDesigner;
                     if(lineConfig.xAxis.column.value && lineConfig.yAxis.column.value &&
-                        lineConfig.drillable?lineConfig.drillList.filter(item=>{
+                        (lineConfig.drillable?lineConfig.drillList.filter(item=>{
                             return Object.keys(item.column).length===0
-                        }).length===0:true) {
+                        }).length===0:true)) {
                         //开启了钻取 并且钻取配置不能有空的配置 否则不显示图表 
                         yield put({ type: 'fetchLineData', drillDown });
                     }else {
@@ -483,7 +484,6 @@ export default {
                 if(inDashBoard){
                     code = item.code;
                     filters = item.filters || [];
-                    styleConfig = item.styleConfig;
                     theme = dashboardDesigner.theme;
                     barConfig = item.chartOption.baseOption.originConfig
                 }
@@ -531,16 +531,23 @@ export default {
                 
                 let res = yield call(service.fetch, {
                     url: URLS.CHART_BAR_OPTION,
+                    allow: true,
                     body: body,
                     timeout: 30000
                 });
                 let option;
                 if(res.code > 0) {
+                    if( inDashBoard ){
+                        styleConfig = JSON.parse(res.data.chartsColumnConfig.chartStyle || '{}');
+                    }
                     option = parseChartOption('bar', res.data, barConfig, theme, styleConfig.bar || {}, drillDown );
                     yield put({ type: 'silentSetFields', fields: [
                         { name: 'resData', value: res.data },
                         { name: 'chartOption', value: option },
                     ] });
+                    if(!drillDown || drillDown.length===1 ){
+                        yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
+                    }
                 }else {
                     option = {}
                     message.error('请求柱状图数据失败: ' + res.msg);
@@ -548,14 +555,15 @@ export default {
                         { name: 'resData', value: null },
                         { name: 'chartOption', value: {} },
                     ] });
+                    yield put({ type: 'silentSetField', name: 'fetchConfig', value: {} });
                 }
-                yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
                 return option
             }catch(e) {
                 yield put({ type: 'silentSetFields', fields: [
                     { name: 'resData', value: null },
                     { name: 'chartOption', value: {} },
                 ] });
+                yield put({ type: 'silentSetField', name: 'fetchConfig', value: {} });
                 message.error('请求柱状图数据失败: ' + e.message);
                 return {}
             }
@@ -569,7 +577,6 @@ export default {
                 if(inDashBoard){
                     code = item.code;
                     filters = item.filters || [];
-                    styleConfig = item.styleConfig;
                     theme = dashboardDesigner.theme;
                     pieConfig = item.chartOption.baseOption.originConfig
                 }
@@ -615,15 +622,22 @@ export default {
                 let res = yield call(service.fetch, {
                     url: URLS.CHART_PIE_OPTION,
                     body: body,
+                    allow: true,
                     timeout: 30000
                 });
                 let option;
                 if(res.code > 0) {
+                    if( inDashBoard ){
+                        styleConfig = JSON.parse(res.data.chartsColumnConfig.chartStyle || '{}');
+                    }
                     option = parseChartOption('pie', res.data, pieConfig, theme, styleConfig.pie || {}, drillDown );
                     yield put({ type: 'silentSetFields', fields: [
                         { name: 'resData', value: res.data },
                         { name: 'chartOption', value: option },
                     ] });
+                    if(!drillDown || drillDown.length===1 ){
+                        yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
+                    }
                 }else {
                     option = {}
                     message.error('请求饼图数据失败: ' + res.msg);
@@ -631,14 +645,15 @@ export default {
                         { name: 'resData', value: null },
                         { name: 'chartOption', value: {} },
                     ] });
+                    yield put({ type: 'silentSetField', name: 'fetchConfig', value: {} });
                 }
-                yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
                 return option
             }catch(e) {
                 yield put({ type: 'silentSetFields', fields: [
                     { name: 'resData', value: null },
                     { name: 'chartOption', value: {} },
                 ] });
+                yield put({ type: 'silentSetField', name: 'fetchConfig', value: {} });
                 message.error('请求饼图数据失败: ' + e.message);
                 return {}
             }
@@ -652,7 +667,6 @@ export default {
                 if(inDashBoard){
                     code = item.code;
                     filters = item.filters || [];
-                    styleConfig = item.styleConfig;
                     theme = dashboardDesigner.theme;
                     lineConfig = item.chartOption.baseOption.originConfig
                 }
@@ -698,15 +712,22 @@ export default {
                 let res = yield call(service.fetch, {
                     url: URLS.CHART_LINE_OPTION,
                     body: body,
+                    allow: true,
                     timeout: 30000
                 });
                 let option;
                 if(res.code > 0) {
+                    if( inDashBoard ){
+                        styleConfig = JSON.parse(res.data.chartsColumnConfig.chartStyle || '{}');
+                    }
                     option = parseChartOption('line', res.data, lineConfig, theme, styleConfig.line || {}, drillDown );
                     yield put({ type: 'silentSetFields', fields: [
                         { name: 'resData', value: res.data },
                         { name: 'chartOption', value: option },
                     ] });
+                    if(!drillDown || drillDown.length===1 ){
+                        yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
+                    }
                 }else {
                     option = {}
                     message.error('请求折线图数据失败: ' + res.msg);
@@ -714,14 +735,15 @@ export default {
                         { name: 'resData', value: null },
                         { name: 'chartOption', value: {} },
                     ] });
+                    yield put({ type: 'silentSetField', name: 'fetchConfig', value: {} });
                 }
-                yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
                 return option
             }catch(e) {
                 yield put({ type: 'silentSetFields', fields: [
                     { name: 'resData', value: null },
                     { name: 'chartOption', value: {} },
                 ] });
+                yield put({ type: 'silentSetField', name: 'fetchConfig', value: {} });
                 message.error('请求折线图数据失败: ' + e.message);
                 return {}
             }