核心代码:
//监听单元格编辑
table.on('edit(demoEvent)', function(obj){
var value = obj.value //得到修改后的值
,data = obj.data //得到所在行所有键值
,field = obj.field; //得到字段
console.log(obj);
window.console.log( field + ' 字段更改为:'+ value);
var $cur = obj.tr.find('td[data-field="'+field+'"]').eq(0);
console.log("cur",$cur);
var x = $cur.prevAll().length;
var y = $cur.parent().attr('data-index');
var plantValue = "";
var energyValue = "";
var countNum = timeType=="1"?5:(timeType=="2"?15:24);
if(x==1){
plantValue = value;
energyValue = plantValue*countNum;
obj.tr.find('td[data-field="energyvalue"]').eq(0).children().text(energyValue)
}
if(x==2){
energyValue = value;
plantValue = (energyValue/countNum).toFixed(2);
obj.tr.find('td[data-field="planvalue"]').eq(0).children().text(plantValue)
}
var myChart = echarts.init(document.getElementById('leftEcharshow2'));
var charData = leftEcharData;
charData.series[0].data[y]=plantValue;
charData.series[1].data[y]=energyValue;
var option = config.leftEcharOption;
option.title.text=data.ptitle;
option.series[0].data=charData.series[0].data;
option.series[1].data=charData.series[1].data;
option.series[2].data=charData.series[2].data;
option.series[3].data=charData.series[3].data;
option.xAxis.data =data.xAxis;
myChart.setOption(option,true);
myChart.resize();
});
效果图:![](https://i-blog.csdnimg.cn/blog_migrate/11e7c6da53943bad500a3048b0829a68.png)