修改存储

dev
夜笙歌 1 year ago
parent 8f986b4855
commit fa73d199ca

@ -55,7 +55,7 @@ export default {
selectSecnesList: [], selectSecnesList: [],
name: '智慧场景', name: '智慧场景',
isIndex: true, isIndex: true,
sceneId: 0, sceneId: this.$store.getters.sceneId,
} }
}, },
props: { props: {
@ -66,6 +66,11 @@ export default {
}, },
async mounted() { async mounted() {
if (this.$route.name === 'SmartScene' || this.$route.name === 'GPS' || this.$route.name === 'index' || this.$store.getters.sceneId) {
}else{
await this.$router.replace({path: "/board/index"});
}
await this.setSelectSecnes() await this.setSelectSecnes()
if (this.$route.name === 'SmartScene' || this.$route.name === 'GPS') { if (this.$route.name === 'SmartScene' || this.$route.name === 'GPS') {
if (this.$route.query?.name) { if (this.$route.query?.name) {
@ -83,31 +88,35 @@ export default {
} else { } else {
this.isIndex = false this.isIndex = false
} }
}, },
methods: { methods: {
async setSelectSecnes() { async setSelectSecnes() {
const {data} = await selectSecnes() const {data} = await selectSecnes()
this.selectSecnesList = data this.selectSecnesList = data
if (!this.$route.query.name) { if (!this.$store.getters.sceneId) {
this.sceneId = data.find(e => e.defaultFlag === '1').sceneId this.sceneId = data.find(e => e.defaultFlag === '1').sceneId
}else{ }
if (this.$route.query.name) {
this.sceneId = data.find(e => e.sceneName === this.$route.query.name).sceneId this.sceneId = data.find(e => e.sceneName === this.$route.query.name).sceneId
} }
this.$emit('sceneIdChange', this.sceneId); this.$emit('sceneIdChange', this.sceneId);
await this.$store.dispatch('app/setSceneId', this.sceneId)
}, },
// sceneIdChange(){ // sceneIdChange(){
// //
// }, // },
toLink(e) { toLink(e) {
this.$router.push({path: "/board/" + e}); this.$router.replace({path: "/board/" + e});
}, },
dropdownLink(e) { dropdownLink(e) {
this.name = e.name
this.$emit('sceneIdChange', e.sceneId); this.$emit('sceneIdChange', e.sceneId);
this.$router.push({path: "/board/" + (e.router || 'smartScene'), query: {name: e.name}}); this.name = e.name
this.$store.dispatch('app/setSceneId', e.sceneId)
this.$router.replace({path: "/board/" + (e.router || 'smartScene'), query: {name: e.name}});
}, },
toIndex() { toIndex() {
this.$router.push({path: "/index"}); this.$router.replace({path: "/index"});
} }
} }
}; };

@ -16,5 +16,6 @@ const getters = {
defaultRoutes:state => state.permission.defaultRoutes, defaultRoutes:state => state.permission.defaultRoutes,
sidebarRouters:state => state.permission.sidebarRouters, sidebarRouters:state => state.permission.sidebarRouters,
language: state => state.app.language, language: state => state.app.language,
sceneId: state => state.app.sceneId,
} }
export default getters export default getters

@ -8,7 +8,8 @@ const state = {
}, },
device: 'desktop', device: 'desktop',
size: Cookies.get('size') || 'medium', size: Cookies.get('size') || 'medium',
language: Cookies.get('language') || 'en_US' language: Cookies.get('language') || 'en_US',
sceneId:0
} }
const mutations = { const mutations = {
@ -42,6 +43,9 @@ const mutations = {
SET_LANGUAGE: (state, language) => { SET_LANGUAGE: (state, language) => {
state.language = language state.language = language
Cookies.set('language', language) Cookies.set('language', language)
},
SET_SCENEID:(state,sceneId) =>{
state.sceneId = sceneId
} }
} }
@ -64,6 +68,10 @@ const actions = {
}, },
setLanguage({ commit }, language) { setLanguage({ commit }, language) {
commit('SET_LANGUAGE', language) commit('SET_LANGUAGE', language)
},
setSceneId({ commit }, sceneId) {
commit('SET_SCENEID', sceneId)
} }
} }

@ -220,7 +220,7 @@ export default {
map.setFitView() map.setFitView()
}, },
async getAlarmStats() { async getAlarmStats() {
const {data} = await alarmStats(this.sceneId) const {data} = await alarmStats(this.$store.getters.sceneId)
let option1 = { let option1 = {
...this.chart1Option, ...this.chart1Option,
yAxis: { yAxis: {
@ -268,7 +268,7 @@ export default {
this.$refs.chart1.setData(option1) this.$refs.chart1.setData(option1)
}, },
async getAubDevice() { async getAubDevice() {
let data = await subDevice(this.sceneId) let data = await subDevice(this.$store.getters.sceneId)
this.num1 = data.deviceNum this.num1 = data.deviceNum
this.num2 = data.subSum this.num2 = data.subSum
this.num3 = data.onlineDeviceNum this.num3 = data.onlineDeviceNum
@ -285,7 +285,7 @@ export default {
}) })
}, },
async setElectronicNumVo() { async setElectronicNumVo() {
const {data} = await ElectronicNumVo(this.sceneId) const {data} = await ElectronicNumVo(this.$store.getters.sceneId)
data.forEach(e => { data.forEach(e => {
if (e.areaPoints?.length > 0) { if (e.areaPoints?.length > 0) {
this.setPolygon(e.areaPoints) this.setPolygon(e.areaPoints)

@ -1,7 +1,7 @@
<template> <template>
<div class="container"> <div class="container">
<div class="centerImg"></div> <div class="centerImg"></div>
<BoardTopNav nowMenu="3" @sceneIdChange="sceneIdChange"></BoardTopNav> <BoardTopNav ref="boardTopNav" nowMenu="3" @sceneIdChange="sceneIdChange"></BoardTopNav>
<div class="title">物联网平台</div> <div class="title">物联网平台</div>
<div class="tree"> <div class="tree">
@ -33,7 +33,7 @@
<span style="color: #d9dee3">{{ MonitorInfo.monitorUnitTypeId }}</span> <span style="color: #d9dee3">{{ MonitorInfo.monitorUnitTypeId }}</span>
</p> </p>
</div> </div>
<div class="img" v-if="show"></div> <div v-if="show" class="img"></div>
<div class="terminal"> <div class="terminal">
<el-form :model="form" class="demo-form-inline"> <el-form :model="form" class="demo-form-inline">
<el-form-item label="传感器名称:"> <el-form-item label="传感器名称:">
@ -110,7 +110,8 @@ export default {
} }
}, },
async mounted() { async mounted() {
setInterval(this.getDevice, 30 * 1000) this.sceneId = this.$store.getters.sceneId
}, },
methods: { methods: {
sceneIdChange(e) { sceneIdChange(e) {
@ -139,33 +140,40 @@ export default {
}); });
}, },
async getTree() { async getTree() {
const {data} = await treeList(this.sceneId) const {data} = await treeList(this.$store.getters.sceneId)
this.treeData = data this.treeData = data
}, },
treeClick(e) { treeClick(e) {
if (e.child.length === 0) { if (!e.children?.length > 0) {
this.monitorUnitId = e.monitorUnitId this.monitorUnitId = e.id
this.getDevice(e.monitorUnitId) this.getDevice(e.id)
this.getRightDevice(e.monitorUnitId) this.getRightDevice(e.id)
this.setMonitorById() this.setMonitorById()
this.show = true this.show = true
if(!getDeviceInterval){
var getDeviceInterval = setInterval(this.getDevice, 30 * 1000)
clearInterval(getDeviceInterval)
getDeviceInterval = setInterval(this.getDevice, 30 * 1000)
}
} }
}, },
async getDevice(e) { async getDevice(e) {
const {data} = await selectDeviceByDeviceModeByMonitorUnitId(this.sceneId, e) console.log('getDevice')
const {data} = await selectDeviceByDeviceModeByMonitorUnitId(this.$store.getters.sceneId, e)
this.controlList = data.control this.controlList = data.control
this.acquisitionList = data.acquisition this.acquisitionList = data.acquisition
console.log(data)
}, },
async getRightDevice(e) { async getRightDevice(e) {
const data = await selectDeviceModeFunctionByFunctionType({ const data = await selectDeviceModeFunctionByFunctionType({
"sceneId": this.sceneId, "sceneId": this.$store.getters.sceneId,
"deviceModeId": 1, "deviceModeId": 1,
"offset": 0, "offset": 0,
"limit": 1 "limit": 1
}) })
}, },
async setMonitorById() { async setMonitorById() {
const {data} = await getMonitorById(this.sceneId) const {data} = await getMonitorById(this.$store.getters.sceneId)
this.MonitorInfo = data this.MonitorInfo = data
}, },
toHistory() { toHistory() {

@ -69,9 +69,8 @@
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
type="primary" type="primary"
icon="el-icon-edit"
@click="toHistory" @click="toHistory"
>修改</el-button> >查看历史</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -132,18 +131,18 @@ export default {
}, },
async setSelectLatestDataByDeviceMode(){ async setSelectLatestDataByDeviceMode(){
const {data} = await selectLatestDataByDeviceMode({ const {data} = await selectLatestDataByDeviceMode({
"sceneId": this.sceneId, "sceneId": this.$store.getters.sceneId,
"deviceModeId": 1, "deviceModeId": 1,
"startTime": 1222222222222, "startTime": 1222222222222,
"offset": 0, "offset": 0,
"limit": 10 "limit": 10
}) })
this.tableData = data.latestData?.rows || [] this.tableData = data.latestData || []
console.log(this.tableData) console.log(this.tableData)
}, },
async setDeviceModesBySceneId(){ async setDeviceModesBySceneId(){
const {data} = await getDeviceModesBySceneId( { const {data} = await getDeviceModesBySceneId( {
"sceneId": this.sceneId, "sceneId": this.$store.getters.sceneId,
}) })
this.deviceList = data this.deviceList = data
}, },

@ -142,7 +142,7 @@ export default {
} }
}, },
async setDeviceInfo() { async setDeviceInfo() {
const {data} = await getDeviceInfo(this.sceneId) const {data} = await getDeviceInfo(this.$store.getters.sceneId)
this.topData = data || {} this.topData = data || {}
}, },
async setHistoryData() { async setHistoryData() {
@ -161,7 +161,7 @@ export default {
}) })
}, },
async setLinkDevices() { async setLinkDevices() {
const {data} = await getLinkDevices(this.sceneId) const {data} = await getLinkDevices(this.$store.getters.sceneId)
this.bottomData = data this.bottomData = data
} }
} }

@ -72,7 +72,7 @@
<div class="titleBg"></div> <div class="titleBg"></div>
<div class="title"> <div class="title">
<span style="margin-right: 28px;"> {{ i.monitorUnitName }} </span> <span style="margin-right: 28px;"> {{ i.monitorUnitName }} </span>
<el-tag :type="i.alarmStatus === 1 ?'success' : 'danger'">{{ i.alarmStatus === 1 ? '正常' : '异常' }}</el-tag> <!-- <el-tag :type="i.alarmStatus === 1 ?'success' : 'danger'">{{ i.alarmStatus === 1 ? '正常' : '异常' }}</el-tag>-->
</div> </div>
<div class="img"></div> <div class="img"></div>
</div> </div>
@ -139,12 +139,12 @@ export default {
await this.setAlarmInfos() await this.setAlarmInfos()
}, },
async setAllNum() { async setAllNum() {
const {subSum, sum} = await sceneAllNums(this.sceneId) const {subSum, sum} = await sceneAllNums(this.$store.getters.sceneId)
this.num1 = subSum this.num1 = subSum
this.num2 = sum this.num2 = sum
}, },
async setLimitSubMonitorUnit() { async setLimitSubMonitorUnit() {
const data = await getLimitSubMonitorUnit(this.sceneId) const data = await getLimitSubMonitorUnit(this.$store.getters.sceneId)
this.LimitSubMonitorUnitList = data.rows this.LimitSubMonitorUnitList = data.rows
this.tableData = data.rows.slice(0, 4) this.tableData = data.rows.slice(0, 4)
this.total = data.total this.total = data.total
@ -153,7 +153,7 @@ export default {
this.tableData = this.LimitSubMonitorUnitList.slice(4 * (e - 1), 4 * (e - 1) + 4) this.tableData = this.LimitSubMonitorUnitList.slice(4 * (e - 1), 4 * (e - 1) + 4)
}, },
async setAlarmCountGroupAlarmType() { async setAlarmCountGroupAlarmType() {
let {data: data} = await getAlarmCountGroupAlarmType(this.sceneId) let {data: data} = await getAlarmCountGroupAlarmType(this.$store.getters.sceneId)
data.sort((a, b) => { data.sort((a, b) => {
return b.alarmCount - a.alarmCount return b.alarmCount - a.alarmCount
}) })
@ -162,9 +162,7 @@ export default {
}, },
async setAlarmInfos() { async setAlarmInfos() {
const {rows: data} = await getAlarmInfos() const {rows: data} = await getAlarmInfos()
console.log(data)
this.table1Data = data.map((e,i)=>{ this.table1Data = data.map((e,i)=>{
console.log(e)
return { return {
data1: i+1, data1: i+1,
data2: e.alarmLevelName, data2: e.alarmLevelName,

Loading…
Cancel
Save