whychdw
2020-08-26 599ac35544a6ca7e3eab8f4450d86828c377b1c2
提交内容
4个文件已修改
306 ■■■■ 已修改文件
package-lock.json 155 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/js/realTime.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/MyElTree.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/dataTest/realTime.vue 141 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package-lock.json
@@ -1344,8 +1344,8 @@
    },
    "@types/mini-css-extract-plugin": {
      "version": "0.9.1",
      "resolved": "https://registry.npm.taobao.org/@types/mini-css-extract-plugin/download/@types/mini-css-extract-plugin-0.9.1.tgz",
      "integrity": "sha1-1L3eUZcyb8oDnUGPS92gPcdNxFE=",
      "resolved": "https://registry.npmjs.org/@types/mini-css-extract-plugin/-/mini-css-extract-plugin-0.9.1.tgz",
      "integrity": "sha512-+mN04Oszdz9tGjUP/c1ReVwJXxSniLd7lF++sv+8dkABxVNthg6uccei+4ssKxRHGoMmPxdn7uBdJWONSJGTGQ==",
      "dev": true,
      "optional": true,
      "requires": {
@@ -1746,17 +1746,6 @@
          "integrity": "sha1-4a1IbmxUUBY0xsOXxcEh2qODYHw=",
          "dev": true
        },
        "ansi-styles": {
          "version": "4.2.1",
          "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
          "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
          "dev": true,
          "optional": true,
          "requires": {
            "@types/color-name": "^1.1.1",
            "color-convert": "^2.0.1"
          }
        },
        "cacache": {
          "version": "13.0.1",
          "resolved": "https://registry.npm.taobao.org/cacache/download/cacache-13.0.1.tgz?cache=0&sync_timestamp=1594429684526&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcacache%2Fdownload%2Fcacache-13.0.1.tgz",
@@ -1783,34 +1772,6 @@
            "unique-filename": "^1.1.1"
          }
        },
        "chalk": {
          "version": "3.0.0",
          "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
          "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
          "dev": true,
          "optional": true,
          "requires": {
            "ansi-styles": "^4.1.0",
            "supports-color": "^7.1.0"
          }
        },
        "color-convert": {
          "version": "2.0.1",
          "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
          "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
          "dev": true,
          "optional": true,
          "requires": {
            "color-name": "~1.1.4"
          }
        },
        "color-name": {
          "version": "1.1.4",
          "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
          "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
          "dev": true,
          "optional": true
        },
        "find-cache-dir": {
          "version": "3.3.1",
          "resolved": "https://registry.npm.taobao.org/find-cache-dir/download/find-cache-dir-3.3.1.tgz?cache=0&sync_timestamp=1583734591888&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffind-cache-dir%2Fdownload%2Ffind-cache-dir-3.3.1.tgz",
@@ -1831,13 +1792,6 @@
            "locate-path": "^5.0.0",
            "path-exists": "^4.0.0"
          }
        },
        "has-flag": {
          "version": "4.0.0",
          "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
          "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
          "dev": true,
          "optional": true
        },
        "locate-path": {
          "version": "5.0.0",
@@ -1903,16 +1857,6 @@
            "minipass": "^3.1.1"
          }
        },
        "supports-color": {
          "version": "7.1.0",
          "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
          "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
          "dev": true,
          "optional": true,
          "requires": {
            "has-flag": "^4.0.0"
          }
        },
        "terser-webpack-plugin": {
          "version": "2.3.8",
          "resolved": "https://registry.npm.taobao.org/terser-webpack-plugin/download/terser-webpack-plugin-2.3.8.tgz?cache=0&sync_timestamp=1597229611059&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fterser-webpack-plugin%2Fdownload%2Fterser-webpack-plugin-2.3.8.tgz",
@@ -1928,21 +1872,6 @@
            "source-map": "^0.6.1",
            "terser": "^4.6.12",
            "webpack-sources": "^1.4.3"
          }
        },
        "vue-loader-v16": {
          "version": "npm:vue-loader@16.0.0-beta.5",
          "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.5.tgz",
          "integrity": "sha512-ciWfzNefqWlmzKznCWY9hl+fPP4KlQ0A9MtHbJ/8DpyY+dAM8gDrjufIdxwTgC4szE4EZC3A6ip/BbrqM84GqA==",
          "dev": true,
          "optional": true,
          "requires": {
            "@types/mini-css-extract-plugin": "^0.9.1",
            "chalk": "^3.0.0",
            "hash-sum": "^2.0.0",
            "loader-utils": "^1.2.3",
            "merge-source-map": "^1.1.0",
            "source-map": "^0.6.1"
          }
        }
      }
@@ -11149,6 +11078,86 @@
        }
      }
    },
    "vue-loader-v16": {
      "version": "npm:vue-loader@16.0.0-beta.5",
      "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.0.0-beta.5.tgz",
      "integrity": "sha512-ciWfzNefqWlmzKznCWY9hl+fPP4KlQ0A9MtHbJ/8DpyY+dAM8gDrjufIdxwTgC4szE4EZC3A6ip/BbrqM84GqA==",
      "dev": true,
      "optional": true,
      "requires": {
        "@types/mini-css-extract-plugin": "^0.9.1",
        "chalk": "^3.0.0",
        "hash-sum": "^2.0.0",
        "loader-utils": "^1.2.3",
        "merge-source-map": "^1.1.0",
        "source-map": "^0.6.1"
      },
      "dependencies": {
        "ansi-styles": {
          "version": "4.2.1",
          "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
          "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
          "dev": true,
          "optional": true,
          "requires": {
            "@types/color-name": "^1.1.1",
            "color-convert": "^2.0.1"
          }
        },
        "chalk": {
          "version": "3.0.0",
          "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
          "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
          "dev": true,
          "optional": true,
          "requires": {
            "ansi-styles": "^4.1.0",
            "supports-color": "^7.1.0"
          }
        },
        "color-convert": {
          "version": "2.0.1",
          "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
          "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
          "dev": true,
          "optional": true,
          "requires": {
            "color-name": "~1.1.4"
          }
        },
        "color-name": {
          "version": "1.1.4",
          "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
          "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
          "dev": true,
          "optional": true
        },
        "has-flag": {
          "version": "4.0.0",
          "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
          "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
          "dev": true,
          "optional": true
        },
        "source-map": {
          "version": "0.6.1",
          "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
          "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
          "dev": true,
          "optional": true
        },
        "supports-color": {
          "version": "7.1.0",
          "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
          "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
          "dev": true,
          "optional": true,
          "requires": {
            "has-flag": "^4.0.0"
          }
        }
      }
    },
    "vue-router": {
      "version": "3.4.3",
      "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.4.3.tgz",
src/assets/js/realTime.js
@@ -46,7 +46,7 @@
    return axios({
        method: "post",
        url: "/yckj/zijing_sx/Batt_rtstateAction_serchByCondition?rtstate.battGroupId=" + params,
        data: null
        data: params
    })
}
src/components/MyElTree.vue
@@ -5,7 +5,6 @@
    node-key="id"
    ref="tree"  
    :data="data"
    :load="loadNode" lazy
    @node-click="nodeClick">
    </el-tree>
</template>
@@ -27,6 +26,7 @@
            defaultProps: {
                children: 'children',
                label: 'label',
                isLeaf: 'leaf',
            }
        }
    },
@@ -35,7 +35,9 @@
            node.isCurrent = node.isLeaf;
            if(node.isLeaf && this.current != node.key) {
                this.current = node.key;
                this.$emit('node-click', data);
                this.$emit('leaf-click', data, node);
            }else {
                this.$emit('node-click', data, node);
            }
            this.$refs.tree.setCurrentKey(this.current);
        },
@@ -43,7 +45,7 @@
}
</script>
<style scoped lang="less">
<style scoped>
.filter-tree {
    -webkit-user-select: none;
    -moz-user-select: none;
src/pages/dataTest/realTime.vue
@@ -6,7 +6,9 @@
        @toggleChange="toggleChange" 
        style="width:320px">
            <my-el-tree
            :data="data"></my-el-tree>
            :data="data"
            @node-click="nodeClick"
            @leaf-click="leafClick"></my-el-tree>
        </content-box>
        <content-box style="margin-left: 4px; margin-right: 4px;" :title="battFullName">
           <flex-layout>
@@ -92,6 +94,14 @@
import ContentBox from '../../components/ContentBox'
import MyElTree from '../../components/MyElTree'
import BarChart from '../../components/chart/BarChart'
import {
   searchStation,
   searchBattInfo,
} from '../../assets/js/api'
import {
    realTimeSearch
} from '../../assets/js/realTime'
let vol, res, temp, conduct, curr;
export default {
@@ -143,7 +153,8 @@
                        num1: '#1',
                    },
                ]
            }
            },
            batt:{},
        }
    },
    methods: {
@@ -174,12 +185,7 @@
                    {
                        name: '电压',
                        type: 'bar',
                        data: [
                            ["#1", 2.2],
                            ["#2", 2.3],
                            ["#3", 2.9],
                            ["#4", 2.8],
                        ]
                        data: []
                    }
                ]
            };
@@ -267,12 +273,129 @@
            this.$refs.temp.setOption(temp);
            this.$refs.conduct.setOption(conduct);
            this.$refs.curr.setOption(curr);
        },
        // 查询机房的信息
        searchStation() {
            searchStation({
                StationName1:"",
                StationName2:"",
                StationName5:"",
            }).then((res)=>{
                let rs = JSON.parse(res.data.result);
                let data = [];
                if(rs.code == 1) {
                    data = rs.data;
                }
                // 格式化数据
                this.formatData(data);
            });
        },
        formatData(data) {
            let result = [];
            // 遍历数据构造树状
            data.forEach(item=>{
                // 省
                let provice = this.addData(result, item.StationName1);
                // 市
                let city = this.addData(provice.children, item.StationName2, provice);
                // 区县
                let county = this.addData(city.children, item.StationName5, city);
                // 机房
                let home = this.addData(county.children, item.StationName3, county, item);
                // 添加空白位置占位
                home.children.push({
                    id: home.id+'temp',
                    label: '数据加载中...'
                });
            });
            // 设置树状列表
            this.data = result;
        },
        addData(list, val, parent, data) {
            let item;
            let index = this.checkValIsIn(val, list);
            let parentId  = parent?parent.id+'-':"";
            if(index == -1) {
                item = {
                    id: parentId+val,
                    label: val,
                    children: [],
                    data: data,
                };
                list.push(item);
            }else {
                item = list[index];
            }
            return item;
        },
        checkValIsIn(val, arr) {
            for(let i=0; i<arr.length; i++) {
                if(arr[i].label == val) {
                    return i;
                }
            }
            return -1;
        },
        nodeClick(data, node) {
            if(data.children[0].label == "数据加载中...") {
                this.searchBattInfo(data, node)
            }
        },
        searchBattInfo(data, node) {
            // 加载等待
            node.loading=true;
            searchBattInfo(data.data).then((res)=>{
                node.loading=false;
                let rs = JSON.parse(res.data.result);
                let result=[{
                    id: Math.random(),
                    label: '暂无电池组',
                }];
                // 查询到结果
                if(rs.code == 1) {
                    result = rs.data.map(item=>{
                        item.id = item.StationName+'-'+item.BattGroupName;
                        item.label = item.BattGroupName;
                        item.leaf = true;
                        return item;
                    });
                }
                data.children = result;
            });
        },
        leafClick(data) {
            if(data.leaf) {
                this.batt = data;
                this.realTimeSearch();
            }
        },
        realTimeSearch() {
            var batt = this.batt;
            realTimeSearch({
                BattGroupId: batt.BattGroupId,
            }).then(res=>{
                let rs = JSON.parse(res.data.result);
                // 电压值
                let volTemp = [];
                if(rs.code == 1) {
                    volTemp= rs.data.map(item=> {
                        return ['#'+item.mon_num, item.mon_vol]
                    });
                }
                vol.series[0].data = volTemp;
                // 更新电压图表
                this.$refs.vol.setOption(vol);
            });
        }
    },
    mounted() {
        // 初始化图表
        this.initChart();
        // 查询电池组
        this.searchStation();
        this.$nextTick(()=>{
            this.$G.chartManage.resize(this.acTabs);
        });