whychdw
2019-08-31 74d8534a366850995e2403ebe4af58097eb67843
src/pages/battery/batteryInfo.js
@@ -29,6 +29,158 @@
                    batt_test_cap: '',      // 测试容量
                    batt_test_recordtime: '',   // 更新日期
                    batt_test_tlong: 0,     // 测试时长
                },
                tbls: {
                    monList: {
                        columns: [
                            {
                                title: '单体',
                                key: 'key1',
                            },
                            {
                                title: '电压(V)',
                                key: 'key2',
                            },
                            {
                                title: '内阻(mΩ)',
                                key: 'key3',
                            },
                            {
                                title: ' ',
                                key: 'key4',
                                width: 8,
                                className: 'split-td',
                            },
                            {
                                title: '单体',
                                key: 'key5',
                            },
                            {
                                title: '电压(V)',
                                key: 'key6',
                            },
                            {
                                title: '内阻(mΩ)',
                                key: 'key7',
                            },
                            {
                                title: ' ',
                                key: 'key8',
                                width: 8,
                                className: 'split-td',
                            },
                            {
                                title: '单体',
                                key: 'key9',
                            },
                            {
                                title: '电压(V)',
                                key: 'key10',
                            },
                            {
                                title: '内阻(mΩ)',
                                key: 'key11',
                            }
                        ],
                        data: []
                    }
                },
                options: {
                    monVol:{    // 单体电压
                        title: new Title(),
                        option: {
                            title: {
                                subtext: '',
                                x: 'center',
                            },
                            xAxis: {
                                type: 'category',
                                data: []
                            },
                            yAxis: {
                                type: 'value',
                                name: '单位(V)',
                                min: 0,
                                max: 10
                            },
                            series: [{
                                name: '电压',
                                type: 'bar',
                                data: []
                            }]
                        }
                    },
                    monRes: {   // 单体内阻
                        title: new Title(),
                        option: {
                            title: {
                                subtext: '',
                                x: 'center',
                            },
                            xAxis: {
                                type: 'category',
                                data: []
                            },
                            yAxis: {
                                type: 'value',
                                name: '单位(mΩ)',
                                min: 0,
                                max: 10
                            },
                            series: [{
                                name: '内阻',
                                type: 'bar',
                                data: []
                            }]
                        }
                    },
                    monTmp: {   // 单体内阻
                        title: new Title(),
                        option: {
                            title: {
                                subtext: '',
                                x: 'center',
                            },
                            xAxis: {
                                type: 'category',
                                data: []
                            },
                            yAxis: {
                                type: 'value',
                                name: '单位(℃)',
                                min: 0,
                                max: 10
                            },
                            series: [{
                                name: '温度',
                                type: 'bar',
                                data: []
                            }]
                        }
                    },
                    monSer: {   // 单体内阻
                        title: new Title(),
                        option: {
                            title: {
                                subtext: '',
                                x: 'center',
                            },
                            xAxis: {
                                type: 'category',
                                data: []
                            },
                            yAxis: {
                                type: 'value',
                                min: 0,
                                max: 10
                            },
                            series: [{
                                name: '电导',
                                type: 'bar',
                                data: []
                            }]
                        }
                    }
                }
            },
            methods: {
@@ -53,8 +205,71 @@
                            }
                        }
                    });
                },
                searchRtData: function() {
                    var self = this;
                    var json = JSON.stringify({
                        BattGroupId: self.params.battGroupId
                    });
                    // 查询后台
                    ajax({
                        type: 'post',
                        async: true,
                        url: 'Batt_rtdataAction!serchByCondition',
                        data: 'json='+json,
                        dataType: 'json',
                        success: function(res) {
                            var rs = JSON.parse(res.result);
                            // console.log(rs);
                            if(rs.code == 1) {
                                var data = rs.data;
                                console.log(data);
                                self.setOptions(data);
                            }
                        }
                    });
                },
                setOptions: function(data) {
                    // 遍历data的值
                    var monNum = [];        // 单体编号
                    var monVol = [];        // 单体电压
                    var monRes = [];        // 单体内阻
                    var monTmp = [];        // 单体温度
                    for(var i=0; i<data.length; i++) {
                        var _data = data[i];
                        monNum.push('#'+_data.mon_num);
                        monVol.push(_data.mon_vol);
                        monRes.push(_data.mon_res);
                        monTmp.push(_data.mon_tmp);
                    }
                    // 单体电压
                    this.options.monVol.option.xAxis.data = monNum;
                    this.options.monVol.option.series[0].data = monVol;
                }
                    // 单体内阻
                    this.options.monRes.option.xAxis.data = monNum;
                    this.options.monRes.option.series[0].data = monRes;
                    // 单体温度
                    this.options.monTmp.option.xAxis.data = monNum;
                    this.options.monTmp.option.series[0].data = monTmp;
                    this.updateGraph();
                },
                // 更新图谱
                updateGraph: function() {
                    // 更新单体电压
                    this.$refs['monVolBar'].setOption(this.options.monVol.option);
                    // 更新单体内阻
                    this.$refs['monResBar'].setOption(this.options.monRes.option);
                    // 更新单体温度
                    this.$refs['monTmpBar'].setOption(this.options.monTmp.option);
                    // 更新单体电导
                    // this.$refs['monSerBar'].setOption(this.options.monSer.option);
                },
            },
            computed: {
                getTitle: function() {
@@ -73,13 +288,22 @@
                }
            },
            mounted() {
                // 查询电池组状态
                this.searchRtState();
                // 脚本都需要在这里执行
                var uiTab = bui.tab({
                    id:"#uiTab"
                });
                // 显示图表
                this.updateGraph();
                // 查询电池组状态
                this.searchRtState();
                // 查询电池组信息
                this.searchRtData();
            },
        });
    }
    },
    destroyed() {
        // 销毁vue实例
        this.vm.$destroy();
    },
});