2021-12-21 11:59:37 +08:00

140 lines
2.9 KiB
JavaScript

// 查看页面和编辑页面公用的参数和方法
import common from '@/config'
import {
config
} from '@/option/config'
import container from '@/page/group/container'
import {
getList
} from '@/api/map'
export default {
components: {
container
},
props: ['id', 'panoramaId'],
provide() {
return {
main: this,
contain: this
};
},
data() {
return {
DIC: {
MAP: []
},
contentWidth: '',
config: config,
obj: {},
id: '',
visual: {},
nav: [],
common: common,
active: [],
overactive: '',
}
},
computed: {
list() {
let result = [];
//循环处理数据
const detail = (item) => {
if (item.children) {
item.children.forEach(ele => {
detail(ele);
})
} else {
result.push(item)
}
}
this.nav.forEach(ele => {
detail(ele);
})
const len = result.length - 1;
result.forEach((ele, index) => {
ele.zIndex = len - index;
})
return result
}
},
created() {
this.initDic();
this.handleCheckExpire()
},
beforeDestroy() {
clearInterval(this.timer)
},
methods: {
//初始化字典
initDic() {
getList({
pageNum: 1,
pageSize: 100,
}).then(res => {
const data = res.data;
this.DIC.MAP = data.records.map(ele => {
return {
label: ele.name,
value: this.url + '/map/data?id=' + ele.id
}
});
})
},
findnav(id, type) {
//循环处理数据
let obj = undefined;
let count = 0;
let parent = undefined;
let pcount = 0;
let len = 0;
const detail = (item, list, i, number = 0) => {
if (!item.children || type) {
if (id === item.index) {
obj = item;
len = Array.isArray(list) ? list.length - 1 : list.children.length - 1;
parent = list;
pcount = number;
count = i;
}
}
if (item.children) {
item.children.forEach((ele, index) => {
detail(ele, item, index, number + 1);
})
}
}
this.nav.forEach((ele, index) => {
detail(ele, this.nav, index);
})
return {
obj,
count,
len,
pcount,
parent
}
},
findlist(index) {
return this.list.find(ele => ele.index == index) || {}
},
handleInitActive() {
this.active = []
},
handleMouseDown() {
this.handleInitActive();
},
handleCheckExpire() {
this.timer = setInterval(() => {
setTimeout(() => {
checkExpire(this.id, this.panoramaId).then(res => {
console.log('权限正常')
}).catch(err => {
alert('您的权限已过期')
window.close()
})
}, 0)
}, 10000 * 60 * 60)
}
}
}