|
@@ -1,207 +1,67 @@
|
|
<template>
|
|
<template>
|
|
<div>
|
|
<div>
|
|
<el-form ref="form" :rules='rules' :model="form">
|
|
<el-form ref="form" :rules='rules' :model="form">
|
|
- <el-form-item prop="dict">
|
|
|
|
- <el-cascader style='width: 100%;' :options='options' v-model='form.dict' @active-item-change='handleChange' :props='props' filterable
|
|
|
|
- @change="changeSelect" ref="dictCas"></el-cascader>
|
|
|
|
|
|
+ <el-form-item prop="dict" class="cascader-container">
|
|
|
|
+ <el-cascader :options='options' v-model='form.dict' :props='props' filterable @change="changeSelect" ref="dictCas">
|
|
|
|
+ </el-cascader>
|
|
|
|
+ <el-tooltip class="item" effect="dark" :content="`于${cacheTime}缓存,点击重新缓存`" placement="top">
|
|
|
|
+ <el-button icon="el-icon-refresh" class="update-button" @click="getDictionary"></el-button>
|
|
|
|
+ </el-tooltip>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
-import {
|
|
|
|
- getDataDictionary,//查询信息点
|
|
|
|
- queryPhysicsAllType,//查询所有部件类型
|
|
|
|
- queryDictionaryHead,//查询所有空间类型
|
|
|
|
-
|
|
|
|
-} from "@/api/scan/request"
|
|
|
|
-import { mapGetters, mapActions } from "vuex";
|
|
|
|
|
|
+import { mapGetters, mapMutations, mapActions } from "vuex";
|
|
import tools from "@/utils/scan/tools";
|
|
import tools from "@/utils/scan/tools";
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- options: [
|
|
|
|
- {
|
|
|
|
- Code: 'Pj',
|
|
|
|
- Name: '项目',
|
|
|
|
- children: []
|
|
|
|
- }, {
|
|
|
|
- Code: 'Bd',
|
|
|
|
- Name: '建筑',
|
|
|
|
- children: []
|
|
|
|
- }, {
|
|
|
|
- Code: 'Fl',
|
|
|
|
- Name: '楼层',
|
|
|
|
- children: []
|
|
|
|
- }, {
|
|
|
|
- Code: 'Eq',
|
|
|
|
- Name: '设备',
|
|
|
|
- children: []
|
|
|
|
- }, {
|
|
|
|
- Code: 'Ec',
|
|
|
|
- Name: '部件',
|
|
|
|
- children: []
|
|
|
|
- }, {
|
|
|
|
- Code: 'Sy',
|
|
|
|
- Name: '系统',
|
|
|
|
- children: []
|
|
|
|
- }, {
|
|
|
|
- Code: 'Sp',
|
|
|
|
- Name: '空间',
|
|
|
|
- children: []
|
|
|
|
- }, {
|
|
|
|
- Code: 'VOTn',
|
|
|
|
- Name: '租户',
|
|
|
|
- children: []
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
|
|
+ options: [],
|
|
form: {
|
|
form: {
|
|
dict: [],
|
|
dict: [],
|
|
},
|
|
},
|
|
props: {
|
|
props: {
|
|
- value: 'Code',
|
|
|
|
- label: 'Name',
|
|
|
|
- children: 'children'
|
|
|
|
|
|
+ value: 'InfoPointCode',
|
|
|
|
+ label: 'InfoPointName',
|
|
|
|
+ children: 'Content'
|
|
},
|
|
},
|
|
rules: {
|
|
rules: {
|
|
dict: [{ required: true, message: '请选择对应数据字典', trigger: 'blur' }]
|
|
dict: [{ required: true, message: '请选择对应数据字典', trigger: 'blur' }]
|
|
},
|
|
},
|
|
- typeRelation: {
|
|
|
|
- Pj: 'Project',
|
|
|
|
- Bd: 'Building',
|
|
|
|
- Fl: 'Floor',
|
|
|
|
- VOTn: 'Tenant',
|
|
|
|
- },
|
|
|
|
- timer: null
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapGetters("project", ["dictionary", "cacheTime"]),
|
|
|
|
+ },
|
|
created() {
|
|
created() {
|
|
- this.getAllData()
|
|
|
|
|
|
+ if (!this.dictionary.length) {
|
|
|
|
+ this.getDictionary().then(res => {
|
|
|
|
+ this.getDictSuc(res.Content)
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ this.getDictSuc(this.dictionary);
|
|
|
|
+ }
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- //选择
|
|
|
|
- handleChange(val) {
|
|
|
|
- let type = val[0];
|
|
|
|
- let singleStr = "Pj-Bd-Fl-VOTn";
|
|
|
|
- console.log(val)
|
|
|
|
- if (type == "Eq" && val.length == 2) {
|
|
|
|
- this.getDataPoint(val[1])
|
|
|
|
- } else if (type == "Ec" && val.length == 2) {
|
|
|
|
- this.getDataPoint(val[1])
|
|
|
|
- } else if (type == "Sy" && val.length == 3) {
|
|
|
|
- this.getDataPoint(val[2])
|
|
|
|
- } else if (type == "Sp" && val.length == 2) {
|
|
|
|
- this.getDataPoint(val[1])
|
|
|
|
- } else if (singleStr.indexOf(type) > -1) {
|
|
|
|
- this.hasChildren(type) && this.getDataPoint(type)
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
+ ...mapActions('project', ['getDictionary']),
|
|
//获取物理世界所有设备类型
|
|
//获取物理世界所有设备类型
|
|
- getAllData() {
|
|
|
|
- queryPhysicsAllType('Equipment', res => {
|
|
|
|
- this.options[3].children = this.formatOptions(res.Content)
|
|
|
|
- })
|
|
|
|
- queryPhysicsAllType('Component', res => {
|
|
|
|
- this.options[4].children = this.formatOptions(res.Content)
|
|
|
|
- })
|
|
|
|
- queryPhysicsAllType('Major-System', res => {
|
|
|
|
- let data = JSON.parse(JSON.stringify(res.Content).replace(/ListClassDef/g, 'children'));
|
|
|
|
- this.options[5].children = this.formatOptions(data)
|
|
|
|
- })
|
|
|
|
- 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,
|
|
|
|
- Orders: 'InfoPointName asc'
|
|
|
|
- },
|
|
|
|
- type: this.typeRelation[type] || type
|
|
|
|
- }
|
|
|
|
- getDataDictionary(param, res => {
|
|
|
|
- let tempArr = res.Content.map(item => {
|
|
|
|
- return {
|
|
|
|
- Code: item.InfoPointCode,
|
|
|
|
- Name: item.InfoPointName
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- this.pointDataSource = {}
|
|
|
|
- res.Content.map(item => {
|
|
|
|
- let code = item.InfoPointCode
|
|
|
|
- this.pointDataSource[code] = item
|
|
|
|
- })
|
|
|
|
- this.timer = setTimeout(() => {
|
|
|
|
- if (this.interval()) {
|
|
|
|
- this.pushPoints(this.options, tempArr, type);
|
|
|
|
- this.changeSelect(this.form.dict);
|
|
|
|
- clearTimeout(this.timer);
|
|
|
|
- this.timer = null;
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- this.timer()
|
|
|
|
- }, 100);
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- interval() {
|
|
|
|
- for (let i = 0; i < this.options.length; i++) {
|
|
|
|
- if (this.options[i].children.length > 0) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
- },
|
|
|
|
- //根据返回数据拼接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)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ getDictSuc(list) {
|
|
|
|
+ this.options = list;
|
|
|
|
+ this.changeSelect(this.form.dict);
|
|
},
|
|
},
|
|
changeSelect(val) {
|
|
changeSelect(val) {
|
|
- if (this.$refs.dictCas.getCheckedNodes()[0]) {
|
|
|
|
- let labels = this.$refs.dictCas.getCheckedNodes()[0].pathLabels
|
|
|
|
- this.$emit('change', { val: val, labels: labels })
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- //减少请求次数
|
|
|
|
- hasChildren(Code) {
|
|
|
|
- let flag = true;
|
|
|
|
- this.options.map(option => {
|
|
|
|
- if (option.Code == Code && option.children.length) {
|
|
|
|
- flag = false;
|
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ if (this.$refs.dictCas.getCheckedNodes()[0]) {
|
|
|
|
+ let labels = this.$refs.dictCas.getCheckedNodes()[0].pathLabels;
|
|
|
|
+ let data = this.$refs.dictCas.getCheckedNodes()[0].data;
|
|
|
|
+ this.$emit('change', { val: val, labels: labels, data: data })
|
|
}
|
|
}
|
|
- })
|
|
|
|
- return flag;
|
|
|
|
|
|
+ }, 500)
|
|
},
|
|
},
|
|
//设置值
|
|
//设置值
|
|
setCascaderVal(value) {
|
|
setCascaderVal(value) {
|
|
this.form.dict = tools.deepCopy(value)
|
|
this.form.dict = tools.deepCopy(value)
|
|
- value.splice(value.length - 1, 1)
|
|
|
|
- this.handleChange(value)
|
|
|
|
},
|
|
},
|
|
//校验是否选择
|
|
//校验是否选择
|
|
validate(cb) {
|
|
validate(cb) {
|
|
@@ -217,4 +77,21 @@ export default {
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|
|
-</style>
|
|
|
|
|
|
+.cascader-container {
|
|
|
|
+ /deep/ .el-cascader {
|
|
|
|
+ width: 89%;
|
|
|
|
+ display: block;
|
|
|
|
+ float: left;
|
|
|
|
+ .el-input .el-input__inner {
|
|
|
|
+ border-radius: 4px 0 0 4px;
|
|
|
|
+ vertical-align: bottom;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ .update-button {
|
|
|
|
+ display: block;
|
|
|
|
+ float: left;
|
|
|
|
+ border-left: 0;
|
|
|
|
+ border-radius: 0 4px 4px 0;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+</style>
|