whychw
2020-09-16 c486dfad1e88f8c60423aabade0f99ec51f233af
U 电池组列表修改
4个文件已修改
136 ■■■■ 已修改文件
src/components/HomeTree/index.vue 113 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/PageHeader.vue 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index.vue 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/getters.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/HomeTree/index.vue
@@ -3,7 +3,7 @@
        <div class="home-tree-inner">
            <div class="home-tree-title">
                <div class="home-tree-title-text">
                    机房列表
                    电池组列表
                </div>
            </div>
            <div class="home-tree-content">
@@ -26,7 +26,6 @@
<script>
import json from '@/assets/json/province-city-county.json'
export default {
    data() {
        return {
@@ -40,46 +39,15 @@
    methods: {
        treeInit () {
          let data = this.$store.state.allBattList;
          let list = [];
          var obj = {};
          console.log(data);
          data.forEach((v) => {
              obj[v.StationName1] = obj[v.StationName1] || {
                  id: this.getCode(v.StationName1),
                  label: v.StationName1
              };
              obj[v.StationName1][v.StationName2] = obj[v.StationName1][v.StationName2] || {
                  id: this.getCode(v.StationName1 + '>' + v.StationName2),
                  label: v.StationName2
              };
              obj[v.StationName1][v.StationName2][v.StationName5] = obj[v.StationName1][v.StationName2][v.StationName5] || {
                  id: this.getCode(v.StationName1 + '>' + v.StationName2 + '>' + v.StationName5),
                  label: v.StationName5
              };
              obj[v.StationName1][v.StationName2][v.StationName5][v.StationName3] = obj[v.StationName1][v.StationName2][v.StationName5][v.StationName3] || {
                  id: v.StationId,
                  label: v.StationName3,
                  children: []
              };
              obj[v.StationName1][v.StationName2][v.StationName5][v.StationName3].children.push({
                  StationName1: v.StationName1,
                  StationName2: v.StationName2,
                  StationName5: v.StationName5,
                  StationName3: v.StationName3,
                  StationName: v.StationName,
                  id: v.BattGroupId,
                  BattGroupId: v.BattGroupId,
                  BattGroupName: v.BattGroupName,
                  label: v.StationName4 + '-' + v.BattGroupName,
                  StationId: v.StationId,
                  FBSDeviceId: v.FBSDeviceId
              });
          });
          Object.keys(obj).forEach((v) => {
              var _obj = this.formatObj(obj[v]);
              list.push(_obj);
            v.id = v.BattGroupId;
            v.label = v.BattGroupName;
          });
          this.treeData = list;
          console.log(data, 2);
          this.treeData = data;
        },
        homeClick(data) {
            // 如果点击的元素的数据中有  BattGroupId 则认为是点的
@@ -87,73 +55,6 @@
                this.setCurrent(data.id);
                this.$emit('select-click', data);
            }
        },
        // 由省市区名得到对应的行政区划代码 参数省市区之间用>分隔
        getCode (txt) {
            var code = 0;
            var arr = txt.split('>');
            var len = arr.length;
            Object.keys(json).forEach((v) => {
                if (json[v].name.indexOf(arr[0]) > -1) {
                    if (len == 1) {
                        code = v
                        return;
                    }
                    var obj = json[v].child;
                    Object.keys(obj).forEach((v1) => {
                        if (obj[v1].name.indexOf(arr[1]) > -1) {
                            if (len == 2) {
                                code = v1;
                                return;
                            }
                            var obj1 = obj[v1].child;
                            Object.keys(obj1).forEach((v2) => {
                                if (obj1[v2].indexOf(arr[2]) > -1) {
                                    code = v2;
                                }
                            });
                        }
                    });
                }
            });
            return code;
        },
        formatObj (obj) {
            if (this.getJSType(obj) == 'object') {
                var children = [];
                Object.keys(obj).forEach((v) => {
                    if (this.getJSType(obj[v]) == 'object') {
                        children.push(obj[v])
                        this.formatObj(obj[v]);
                    }
                });
                obj.children = obj.children || children;
            }
            return obj;
        },
        getJSType (param) {
            var res = '';
            switch (Object.prototype.toString.call(param)) {
                case '[object Object]':
                    res = 'object';
                    break;
                case '[object Array]':
                    res = 'array';
                    break;
                case '[object Function]':
                    res = 'function';
                    break;
                case '[object Number]':
                    res = 'number';
                    break;
                case '[object String]':
                    res = 'string';
                    break;
                case '[object Boolean]':
                    res = 'boolean';
                    break;
            }
            return res;
        }
        // 设置高亮
        ,setCurrent (key) {
src/components/PageHeader.vue
@@ -5,7 +5,7 @@
                <ul>
                    <li @click="showBattTree">
                        <i class="el-icon-s-home"></i>
                        <a href="javascript:;">站点列表</a>
                        <a href="javascript:;">电池组列表</a>
                    </li>
                    <li 
                    v-for="(nav, key) in navs" 
@@ -137,8 +137,9 @@
.page-header-subtitle {
    height: 1.4rem;
    line-height: 1.4rem;
    font-size: 0.7rem;
    color: rgba(255,255,255,.7);
    font-size: 1rem;
    font-weight: 700;
    color: #0f0;
}
.page-header-time {
    font-size: 0.9rem;
src/pages/index.vue
@@ -344,12 +344,12 @@
                        maxResList.push(_data.mon_num);
                      }
                      this.minIdxList.monVol = minVolList.join(',');
                      this.maxIdxList.monVol = maxVolList.join(',');
                      this.minIdxList.monTmp = minTmpList.join(',');
                      this.maxIdxList.monTmp = maxTmpList.join(',');
                      this.minIdxList.monRes = minResList.join(',');
                      this.maxIdxList.monRes = maxResList.join(',');
                      this.minIdxList.monVol = minVolList.length >= 5 ? (minVolList.slice(0, 5).join(',') + '...') : minVolList.join(',');
                      this.maxIdxList.monVol = maxVolList.length >= 5 ? (maxVolList.slice(0, 5).join(',') + '...') : maxVolList.join(',');
                      this.minIdxList.monTmp = minTmpList.length >= 5 ? (minTmpList.slice(0, 5).join(',') + '...') : minTmpList.join(',');
                      this.maxIdxList.monTmp = maxTmpList.length >= 5 ? (maxTmpList.slice(0, 5).join(',') + '...') : maxTmpList.join(',');
                      this.minIdxList.monRes = minResList.length >= 5 ? (minResList.slice(0, 5).join(',') + '...') : minResList.join(',');
                      this.maxIdxList.monRes = maxResList.length >= 5 ? (maxResList.slice(0, 5).join(',') + '...') : maxResList.join(',');
                    }
                    this.tableData_monVol = tableData_monVol;
src/store/getters.js
@@ -1,9 +1,9 @@
export default {
    getFullName(state) {
        if(state.fullName == "") {
            state.fullName = "机房名称-电池组名称";
            state.fullName = "电池组名称";
        }else {
            state.fullName = state.battGroup.StationName+'-'+state.battGroup.BattGroupName;
            state.fullName = state.battGroup.BattGroupName;
        }
        return state.fullName;
    }