瀏覽代碼

多看板切换key刷新

zhuth 6 年之前
父節點
當前提交
cfde950498

+ 2 - 0
kanban-client/README.md

@@ -78,6 +78,8 @@ columns[i].rowStyle---------------指定列数据列样式
 * 消息提示框字段调整
 ##### 20190108
 * 折线图区域填充实现
+##### 20191011
+* 多看板切换因为key值使用索引导致table未能正确刷新的bug
 
 #### 已知小bug
 * 多模板看板第一次进入需要多等待一个刷新时才会切换到下一个模板。

+ 4 - 4
kanban-client/app/component/Layout.js

@@ -2,7 +2,7 @@ import React from 'react';
 import { WidthProvider } from 'react-grid-layout';
 var ReactGridLayout = WidthProvider(require('react-grid-layout'));
 import '../assets/layoutStyle.less';
-
+import {hashcode} from '../utils/BaseUtils';
 import Form from '../src/Form/index.js';
 import Table from './Table.jsx';
 import Charts from '../src/Charts/ECharts.js';
@@ -43,11 +43,11 @@ class BasicLayout extends React.Component {
     return items.map(function (item, i) {
       let { type, config } = item;
       if (type == 'form') {
-        return (<div key={i}><Form theme={theme} themeConfig={themeConfig.form} {...config} /></div>);
+        return (<div key={i}><Form key={hashcode({theme, themeConfig: themeConfig.form, config})} theme={theme} themeConfig={themeConfig.form} {...config} /></div>);
       } else if (type == 'table') {
-        return (<div key={i}><Table theme={theme} themeConfig={themeConfig.table} {...config} /></div>);
+        return (<div key={i}><Table key={hashcode({theme, themeConfig: themeConfig.table, config})} theme={theme} themeConfig={themeConfig.table} {...config} /></div>);
       } else if (type == 'charts') {
-        return <div key={i}><Charts theme={theme} themeConfig={themeConfig.charts} {...config} /></div>
+        return <div key={i}><Charts key={hashcode({theme, themeConfig: themeConfig.charts, config})} theme={theme} themeConfig={themeConfig.charts} {...config} /></div>
       } else {
         return (<div key={i}><span className="text">{i}</span></div>);
       }

+ 1 - 1
kanban-client/app/component/converter.js

@@ -212,7 +212,7 @@ function lineConfig(model, theme) {
     lineconfig = parseObjectStr(lineconfig);
     color = eval(color);
     series = series ? ((series instanceof Array) ? series : [series]) : [];
-    let xf = (xfields instanceof Array) ? xfields : (xfields.replace(['['], '').replace([']'], '').split(',')),
+    let xf = (xfields instanceof Array) ? xfields : ((xfields+'').replace(['['], '').replace([']'], '').split(',')),
         areaLeft = Number(areaconfig.left)>=0 ? areaconfig.left+'%' : '5%',
         areaRight = Number(areaconfig.right)>=0 ? areaconfig.right+'%' : '5%',
         areaTop = Number(areaconfig.top)>=0 ? areaconfig.top+'%' : (layout.h * getScreenSize().height / 100 < 310 ? '35%' : '28%'),

+ 3 - 4
kanban-client/app/component/factory.dev.js

@@ -7,14 +7,13 @@ import URL from '../constants/url.dev.json';
 import 'whatwg-fetch';
 import { getThemeConfig, applyTheme } from './theme/applyTheme.js';
 
-import tempdata from '../data/testline.json';
+import tempdata from '../data/bug/bug.json';
 
 class Factory extends React.Component {
 
     constructor(props) {
         super(props);
-        this.dev = 'local ';
-        this.theme = 'blue';
+        this.dev = 'local';
         
         this.index = 0;
         this.state = {
@@ -149,7 +148,7 @@ class Factory extends React.Component {
                 this.setState({
                     model: converter(tempdata.data[this.index],  tempdata.theme || 'dark'),
                 });
-            }.bind(this), 7000)
+            }.bind(this), 5000)
         }else {
             let reg = /(.*){code}(.*){index}(.*)/g;
             this.getModelConfig(URL.defaultPath.replace(reg, '$1' + code + '$2' + index));

+ 2 - 2
kanban-client/app/constants/url.dev.json

@@ -1,4 +1,4 @@
 {
-    "defaultPath": "http://localhost:8098/panelView/parseData/{code}?index={index}",
-    "completelyPath": "http://localhost:8098/panelView/parseData/{code}?index={index}&kanbanCode={kanbanCode}"
+    "defaultPath": "http://183.238.39.179:8099/kanban/panelView/parseData/{code}?index={index}",
+    "completelyPath": "http://183.238.39.179:8099/kanban/panelView/parseData/{code}?index={index}&kanbanCode={kanbanCode}"
 }

+ 26 - 2
kanban-client/app/data/testtable.json

@@ -1,4 +1,5 @@
 {
+    "theme": "blue",
     "data": [
         {
             "content": {
@@ -13,9 +14,32 @@
                         "type": "table",
                         "config": {
                             "title": {"text": "车间执行看板"},
-                            "pagesize": 10,
+                            "interval": 7,
                             "data": [{
-                                
+                                "时段": "10~11",
+                                "达成率": "42%",
+                                "投入数": 367,
+                                "良品产出": 76,
+                                "不良数": 15,
+                                "计划数": 180,
+                                "直通率": "95.9%"
+                            }, {
+                                "时段": "11~12",
+                                "达成率": "129%",
+                                "投入数": 399,
+                                "良品产出": 129,
+                                "不良数": 0,
+                                "计划数": 100,
+                                "直通率": "100%"
+                            }, {
+                                "时段": "上午",
+                                "达成率": "78%",
+                                "投入数": 1340,
+                                "良品产出": 530,
+                                "不良数": 30,
+                                "计划数": 680,
+                                "直通率": "97.8%"
+                            }, {
                                 "时段": "10~11",
                                 "达成率": "42%",
                                 "投入数": 367,

+ 1 - 1
kanban-client/app/main.dev.js

@@ -29,7 +29,7 @@ if (!window.Promise) {
 	window.Promise = Promise;  
 }  
 
-var code = 'B9E84580644';
+var code = '10626BB19FDD';
 var index = 0;
 
 ReactDOM.render(