|
@@ -0,0 +1,163 @@
|
|
|
|
+<template>
|
|
|
|
+ <el-cascader style='width: 100%;' :options='options' v-model='dict' @active-item-change='handleChange' :props='props' filterable
|
|
|
|
+ @change="changeSelect"></el-cascader>
|
|
|
|
+</template>
|
|
|
|
+<script>
|
|
|
|
+import {
|
|
|
|
+ getDataDictionary,//查询信息点
|
|
|
|
+ queryPhysicsAllType,//查询所有部件类型
|
|
|
|
+ queryDictionaryHead,//查询所有空间类型
|
|
|
|
+} from "@/api/scan/request"
|
|
|
|
+import { mapGetters, mapActions } from "vuex";
|
|
|
|
+import tools from "@/utils/scan/tools";
|
|
|
|
+export default {
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ options: [
|
|
|
|
+ {
|
|
|
|
+ Code: 'Project',
|
|
|
|
+ Name: '项目',
|
|
|
|
+ children: []
|
|
|
|
+ }, {
|
|
|
|
+ Code: 'Building',
|
|
|
|
+ Name: '建筑',
|
|
|
|
+ children: []
|
|
|
|
+ }, {
|
|
|
|
+ Code: 'Floor',
|
|
|
|
+ Name: '楼层',
|
|
|
|
+ children: []
|
|
|
|
+ }, {
|
|
|
|
+ Code: 'Equipment',
|
|
|
|
+ Name: '设备',
|
|
|
|
+ children: []
|
|
|
|
+ }, {
|
|
|
|
+ Code: 'Component',
|
|
|
|
+ Name: '部件',
|
|
|
|
+ children: []
|
|
|
|
+ }, {
|
|
|
|
+ Code: 'System',
|
|
|
|
+ Name: '系统',
|
|
|
|
+ children: []
|
|
|
|
+ }, {
|
|
|
|
+ Code: 'Space',
|
|
|
|
+ Name: '空间',
|
|
|
|
+ children: []
|
|
|
|
+ }, {
|
|
|
|
+ Code: 'Tenant',
|
|
|
|
+ Name: '租户',
|
|
|
|
+ children: []
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ dict: [],
|
|
|
|
+ props: {
|
|
|
|
+ value: 'Code',
|
|
|
|
+ label: 'Name',
|
|
|
|
+ children: 'children'
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ created() {
|
|
|
|
+ this.getAllData()
|
|
|
|
+ let val = ["Equipment", "SICU", "OnlineStatus"]
|
|
|
|
+ this.setCascaderVal(val)
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ //选择
|
|
|
|
+ handleChange(val) {
|
|
|
|
+ let type = val[0];
|
|
|
|
+ let singleStr = "ProjectBuildingFloorTenant";
|
|
|
|
+ console.log(val)
|
|
|
|
+ if (type == "Equipment" && val.length == 2) {
|
|
|
|
+ this.getDataPoint(val[1])
|
|
|
|
+ } else if (type == "Component" && val.length == 2) {
|
|
|
|
+ this.getDataPoint(val[1])
|
|
|
|
+ } else if (type == "System" && val.length == 2) {
|
|
|
|
+ this.getDataPoint(val[1])
|
|
|
|
+ } else if (type == "Space" && val.length == 2) {
|
|
|
|
+ this.getDataPoint(val[1])
|
|
|
|
+ } else if (singleStr.indexOf(type) > -1) {
|
|
|
|
+ this.hasChildren(type) && this.getDataPoint(type)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ //获取物理世界所有设备类型
|
|
|
|
+ getAllData() {
|
|
|
|
+ queryPhysicsAllType('Equipment', res => {
|
|
|
|
+ this.options[3].children = this.formatOptions(res.Content)
|
|
|
|
+ })
|
|
|
|
+ queryPhysicsAllType('Component', res => {
|
|
|
|
+ this.options[4].children = this.formatOptions(res.Content)
|
|
|
|
+ })
|
|
|
|
+ let param1 = {
|
|
|
|
+ Distinct: true,
|
|
|
|
+ Filters: "ParentId='Space'"
|
|
|
|
+ }
|
|
|
|
+ queryDictionaryHead(param1, res => {
|
|
|
|
+ this.options[6].children = this.formatOptions(res.Content)
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ //格式化options数据
|
|
|
|
+ formatOptions(arr) {
|
|
|
|
+ return arr.map(item => {
|
|
|
|
+ return {
|
|
|
|
+ Code: item.Code,
|
|
|
|
+ Name: item.Name,
|
|
|
|
+ children: item.children && item.children.length ? this.formatOptions(item.children) : []
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ //请求信息点
|
|
|
|
+ getDataPoint(type) {
|
|
|
|
+ let param = {
|
|
|
|
+ data: {
|
|
|
|
+ Filters: "InputMode='M' or InputMode='L'",
|
|
|
|
+ PageNumber: 1,
|
|
|
|
+ PageSize: 500
|
|
|
|
+ },
|
|
|
|
+ type: type
|
|
|
|
+ }
|
|
|
|
+ getDataDictionary(param, res => {
|
|
|
|
+ let tempArr = res.Content.map(item => {
|
|
|
|
+ return {
|
|
|
|
+ Code: item.InfoPointCode,
|
|
|
|
+ Name: item.InfoPointName
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ this.pushPoints(this.options, tempArr, type);
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ //根据返回数据拼接options
|
|
|
|
+ pushPoints(options, arr, Code) {
|
|
|
|
+ options.map(option => {
|
|
|
|
+ if (option.Code == Code) {
|
|
|
|
+ option.children = arr;
|
|
|
|
+ } else {
|
|
|
|
+ if (option.children) {
|
|
|
|
+ this.pushPoints(option.children, arr, Code)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ changeSelect(val) {
|
|
|
|
+ console.log(val)
|
|
|
|
+ },
|
|
|
|
+ //减少请求次数
|
|
|
|
+ hasChildren(Code) {
|
|
|
|
+ let flag = true;
|
|
|
|
+ this.options.map(option => {
|
|
|
|
+ if (option.Code == Code && option.children.length) {
|
|
|
|
+ flag = false;
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ return flag;
|
|
|
|
+ },
|
|
|
|
+ //设置值
|
|
|
|
+ setCascaderVal(value) {
|
|
|
|
+ this.dict = tools.deepCopy(value)
|
|
|
|
+ value.splice(value.length - 1, 1)
|
|
|
|
+ this.handleChange(value)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</script>
|
|
|
|
+<style lang="less" scoped>
|
|
|
|
+</style>
|