|
@@ -5,29 +5,14 @@
|
|
|
<span class="hui-left-tree-sub">资产列表</span>
|
|
|
</div>
|
|
|
<div class="hui-left-tree-content">
|
|
|
- <el-collapse>
|
|
|
- <el-collapse-item v-for="item in treeData" :key="item.id">
|
|
|
- <template slot="title">
|
|
|
- <div :class="nowData.id === item.id ? 'collapse-title active':'collapse-title'"
|
|
|
- @click.stop="filterDevice(item)">
|
|
|
- <i class="iconfont huifont-shuzhuangcaidantubiao"></i>
|
|
|
- <span class="el-collapse-name">{{item.name}}</span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <div>
|
|
|
- <el-tree :data="item.children" :props="defaultProps">
|
|
|
- <div class="custom-tree-node" slot-scope="{ node, data }">
|
|
|
- <div class="label">{{node.label}}</div>
|
|
|
- <div :class="nowData.id === data.id ? 'active':''" @click.stop="filterDevice(data)">
|
|
|
- <i
|
|
|
- :class="'iconfont ' + (data.deviceId ? 'huifont-shebeiguanli' : 'huifont-xiangmuguanli')">
|
|
|
- </i>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </el-tree>
|
|
|
- </div>
|
|
|
- </el-collapse-item>
|
|
|
- </el-collapse>
|
|
|
+ <el-tree :data="treeData" :props="defaultProps">
|
|
|
+ <div :class="nowData.id === data.id ? 'custom-tree-node active':'custom-tree-node'"
|
|
|
+ @click.stop="filterDevice(data)" slot-scope="{ node, data }">
|
|
|
+ <i :class="'iconfont ' + (data.deviceId ? 'huifont-shebeiguanli' : 'huifont-xiangmuguanli')">
|
|
|
+ </i>
|
|
|
+ <div class="label">{{node.label}}</div>
|
|
|
+ </div>
|
|
|
+ </el-tree>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -38,6 +23,7 @@
|
|
|
getDevicePartList
|
|
|
} from '@/httpApi/property'
|
|
|
export default {
|
|
|
+ props: ['type'],
|
|
|
data() {
|
|
|
return {
|
|
|
treeData: [],
|
|
@@ -62,15 +48,34 @@
|
|
|
})
|
|
|
} else {
|
|
|
this.treeData = res.data;
|
|
|
- this.returnChildren(this.treeData);
|
|
|
+ this.returnChildren(this.treeData, []);
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- returnChildren(data) {
|
|
|
- data.forEach(item => {
|
|
|
- if (item.children && item.children.length > 0) this.returnChildren(item.children);
|
|
|
- });
|
|
|
+ returnChildren(data, parentData) {
|
|
|
+ if (this.type === 1) {
|
|
|
+ data.forEach(item => {
|
|
|
+ item['parentData'] = [...parentData, item.name];
|
|
|
+ if (item.children && item.deviceList) {
|
|
|
+ let obj = item.deviceList.map(res => {
|
|
|
+ res['deviceId'] = res.id;
|
|
|
+ res['id'] = -res.id;
|
|
|
+ return res;
|
|
|
+ })
|
|
|
+ item.children = item.children.concat(obj);
|
|
|
+ }
|
|
|
+ if (item.children && item.children.length > 0) this.returnChildren(item.children,
|
|
|
+ [...parentData, item.name]);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ data.forEach(item => {
|
|
|
+ item['parentData'] = [...parentData, item.name];
|
|
|
+ if (item.children && item.children.length > 0) this.returnChildren(item.children, [...
|
|
|
+ parentData, item.name
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
filterDevice(data) {
|
|
|
let option = {};
|
|
@@ -84,7 +89,7 @@
|
|
|
option['deviceLevelIds'] = this.getStorageIds([data]);
|
|
|
}
|
|
|
}
|
|
|
- this.$emit('filterDevice', option);
|
|
|
+ this.$emit('filterDevice', option, data.parentData);
|
|
|
},
|
|
|
getStorageIds(array) {
|
|
|
//获取档案库id
|