|
|
@@ -4,7 +4,16 @@
|
|
|
margin
|
|
|
>
|
|
|
<div class="l-flex__none l-flex--row c-sibling-item--v c-count">
|
|
|
- <div class="l-flex__none u-color--black u-bold">设备统计</div>
|
|
|
+ <div
|
|
|
+ class="l-flex__none u-color--black u-width--sm u-bold u-ellipsis has-active"
|
|
|
+ @click="onChooseDepartment"
|
|
|
+ >
|
|
|
+ <i
|
|
|
+ v-if="loading"
|
|
|
+ class="el-icon-loading"
|
|
|
+ />
|
|
|
+ {{ group.name }}
|
|
|
+ </div>
|
|
|
<div class="l-flex__none c-count__item u-color--black u-bold u-text--center">
|
|
|
<div>总数</div>
|
|
|
<i
|
|
|
@@ -39,7 +48,7 @@
|
|
|
</div>
|
|
|
<i
|
|
|
class="el-icon-refresh o-icon md u-color--blue has-active"
|
|
|
- @click="refreshDevices"
|
|
|
+ @click="onRefresh"
|
|
|
/>
|
|
|
</div>
|
|
|
<div
|
|
|
@@ -77,11 +86,16 @@
|
|
|
>
|
|
|
<i class="el-icon-loading" />
|
|
|
</div>
|
|
|
+ <department-drawer
|
|
|
+ ref="departmentDrawer"
|
|
|
+ remember
|
|
|
+ @change="onGroupChanged"
|
|
|
+ @loaded="onGroupLoaded"
|
|
|
+ />
|
|
|
</wrapper>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { mapGetters } from 'vuex'
|
|
|
import {
|
|
|
subscribe,
|
|
|
unsubscribe
|
|
|
@@ -100,16 +114,15 @@ export default {
|
|
|
},
|
|
|
data () {
|
|
|
return {
|
|
|
- monitor: { loading: false },
|
|
|
+ monitor: { loading: true },
|
|
|
deviceOptions: {
|
|
|
list: [],
|
|
|
loaded: false
|
|
|
- }
|
|
|
+ },
|
|
|
+ loading: false,
|
|
|
+ group: {}
|
|
|
}
|
|
|
},
|
|
|
- computed: {
|
|
|
- ...mapGetters(['tenant'])
|
|
|
- },
|
|
|
created () {
|
|
|
this.$timer = -1
|
|
|
subscribe([
|
|
|
@@ -117,7 +130,6 @@ export default {
|
|
|
'+/+/offline',
|
|
|
'+/+/calendar/update'
|
|
|
], this.onMessage)
|
|
|
- this.refreshDevices()
|
|
|
this.getDevices()
|
|
|
},
|
|
|
beforeDestroy () {
|
|
|
@@ -190,8 +202,25 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- refreshDevices () {
|
|
|
- if (this.monitor.loading) {
|
|
|
+ onGroupLoaded () {
|
|
|
+ this.loading = false
|
|
|
+ },
|
|
|
+ onGroupChanged ({ path, name }) {
|
|
|
+ if (!this.group || this.group.path !== path) {
|
|
|
+ this.group = { path, name }
|
|
|
+ this.refreshDevices(true)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onChooseDepartment () {
|
|
|
+ this.$refs.departmentDrawer.show().then(visible => {
|
|
|
+ this.loading = !visible
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onRefresh () {
|
|
|
+ this.refreshDevices()
|
|
|
+ },
|
|
|
+ refreshDevices (force) {
|
|
|
+ if (!force && this.monitor.loading) {
|
|
|
return
|
|
|
}
|
|
|
const monitor = {
|
|
|
@@ -202,7 +231,7 @@ export default {
|
|
|
inactive: '-'
|
|
|
}
|
|
|
this.monitor = monitor
|
|
|
- getDeviceStatisticsByPath(this.tenant).then(({ data }) => {
|
|
|
+ getDeviceStatisticsByPath(this.group.path).then(({ data }) => {
|
|
|
const { deactivatedTotal, notConnectedTotal, offLineTotal, onLineTotal, total } = data
|
|
|
monitor.total = total
|
|
|
monitor.online = onLineTotal
|