|
|
@@ -26,12 +26,6 @@
|
|
|
>
|
|
|
层级
|
|
|
</el-dropdown-item>
|
|
|
- <el-dropdown-item
|
|
|
- icon="el-icon-menu"
|
|
|
- command="rect"
|
|
|
- >
|
|
|
- 方块图
|
|
|
- </el-dropdown-item>
|
|
|
<el-dropdown-item
|
|
|
v-if="isTenantAdmin"
|
|
|
icon="el-icon-star-off"
|
|
|
@@ -53,13 +47,27 @@
|
|
|
</div>
|
|
|
<slot />
|
|
|
<div class="l-flex__fill" />
|
|
|
- <div
|
|
|
- v-if="supportCardStyle"
|
|
|
- class="l-flex__none l-flex--row u-color--blue u-font-size--sm has-active"
|
|
|
- @click="onSwitchCardStyle"
|
|
|
+ <el-dropdown
|
|
|
+ class="l-flex__none c-sibling-item"
|
|
|
+ trigger="click"
|
|
|
+ @command="onSwitchCardStyle"
|
|
|
>
|
|
|
- {{ tip }}
|
|
|
- </div>
|
|
|
+ <div class="l-flex--row inline u-font-size--sm has-active">
|
|
|
+ <span class="c-sibling-item ">{{ cardStyleTip }}</span>
|
|
|
+ <i class="c-sibling-item nearer el-icon-arrow-down" />
|
|
|
+ </div>
|
|
|
+ <el-dropdown-menu slot="dropdown">
|
|
|
+ <el-dropdown-item command="big">
|
|
|
+ 详情
|
|
|
+ </el-dropdown-item>
|
|
|
+ <el-dropdown-item command="medium">
|
|
|
+ 简略
|
|
|
+ </el-dropdown-item>
|
|
|
+ <el-dropdown-item command="rect">
|
|
|
+ 方块
|
|
|
+ </el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </el-dropdown>
|
|
|
</div>
|
|
|
<component
|
|
|
:is="activeComponent"
|
|
|
@@ -76,26 +84,34 @@
|
|
|
import { mapGetters } from 'vuex'
|
|
|
import DeviceGroupTile from './DeviceGroupTile.vue'
|
|
|
import DeviceGroupLevel from './DeviceGroupLevel.vue'
|
|
|
-import DeviceGroupRect from './DeviceGroupRect.vue'
|
|
|
import DeviceGroupAttention from './DeviceGroupAttention.vue'
|
|
|
import VolumeDrawer from './DrawerVolumeSettings.vue'
|
|
|
|
|
|
-const groupStyleCommands = ['tile', 'level', 'rect']
|
|
|
-const cardStyleCommands = ['big', 'medium']
|
|
|
+const groupStyleCommands = new Set(['tile', 'level'])
|
|
|
+const defaultGroupStyle = 'tile'
|
|
|
+const cardStyleCommands = new Set(['big', 'medium', 'rect'])
|
|
|
+const defaultcardStyle = 'big'
|
|
|
|
|
|
export default {
|
|
|
name: 'DeviceGroups',
|
|
|
components: {
|
|
|
DeviceGroupTile,
|
|
|
DeviceGroupLevel,
|
|
|
- DeviceGroupRect,
|
|
|
DeviceGroupAttention,
|
|
|
VolumeDrawer
|
|
|
},
|
|
|
data () {
|
|
|
+ if (this.$store.getters.isTenantAdmin) {
|
|
|
+ if (!groupStyleCommands.has('attention')) {
|
|
|
+ groupStyleCommands.add('attention')
|
|
|
+ }
|
|
|
+ } else if (groupStyleCommands.has('attention')) {
|
|
|
+ groupStyleCommands.delete('attention')
|
|
|
+ }
|
|
|
+
|
|
|
let options = {
|
|
|
- groupStyle: groupStyleCommands[0],
|
|
|
- cardStyle: cardStyleCommands[0]
|
|
|
+ groupStyle: defaultGroupStyle,
|
|
|
+ cardStyle: defaultcardStyle
|
|
|
}
|
|
|
try {
|
|
|
options = {
|
|
|
@@ -107,8 +123,8 @@ export default {
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
- groupStyle: groupStyleCommands.includes(options.groupStyle) ? options.groupStyle : groupStyleCommands[0],
|
|
|
- cardStyle: cardStyleCommands.includes(options.cardStyle) ? options.cardStyle : cardStyleCommands[0],
|
|
|
+ groupStyle: groupStyleCommands.has(options.groupStyle) ? options.groupStyle : defaultGroupStyle,
|
|
|
+ cardStyle: cardStyleCommands.has(options.cardStyle) ? options.cardStyle : defaultcardStyle,
|
|
|
groups: []
|
|
|
}
|
|
|
},
|
|
|
@@ -118,8 +134,6 @@ export default {
|
|
|
switch (this.groupStyle) {
|
|
|
case 'attention':
|
|
|
return '我的关注'
|
|
|
- case 'rect':
|
|
|
- return '方块图'
|
|
|
default:
|
|
|
return '设备列表'
|
|
|
}
|
|
|
@@ -128,8 +142,6 @@ export default {
|
|
|
switch (this.groupStyle) {
|
|
|
case 'tile':
|
|
|
return 'el-icon-s-grid'
|
|
|
- case 'rect':
|
|
|
- return 'el-icon-menu'
|
|
|
case 'attention':
|
|
|
return 'el-icon-star-off'
|
|
|
default:
|
|
|
@@ -140,36 +152,30 @@ export default {
|
|
|
switch (this.groupStyle) {
|
|
|
case 'tile':
|
|
|
return 'DeviceGroupTile'
|
|
|
- case 'rect':
|
|
|
- return 'DeviceGroupRect'
|
|
|
case 'attention':
|
|
|
return 'DeviceGroupAttention'
|
|
|
default:
|
|
|
return 'DeviceGroupLevel'
|
|
|
}
|
|
|
},
|
|
|
- hasData () {
|
|
|
- return this.groups.some(({ children }) => children.some(({ onlineStatus }) => onlineStatus === 1))
|
|
|
- },
|
|
|
- supportCardStyle () {
|
|
|
- switch (this.groupStyle) {
|
|
|
+ cardStyleTip () {
|
|
|
+ switch (this.cardStyle) {
|
|
|
+ case 'medium':
|
|
|
+ return '简略'
|
|
|
case 'rect':
|
|
|
- return false
|
|
|
+ return '方块'
|
|
|
default:
|
|
|
- return true
|
|
|
+ return '详情'
|
|
|
}
|
|
|
},
|
|
|
- tip () {
|
|
|
- if (this.cardStyle === 'big') {
|
|
|
- return '切换至简洁模式'
|
|
|
- }
|
|
|
- return '切换至详情模式'
|
|
|
+ hasData () {
|
|
|
+ return this.groups.some(({ children }) => children.some(({ onlineStatus }) => onlineStatus === 1))
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
onCommand (groupStyle) {
|
|
|
this.groupStyle = groupStyle
|
|
|
- this.saveOptions(groupStyleCommands.includes(groupStyle) ? groupStyle : '', this.cardStyle)
|
|
|
+ this.saveOptions(groupStyleCommands.has(groupStyle) ? groupStyle : '', this.cardStyle)
|
|
|
},
|
|
|
onVolume () {
|
|
|
this.$refs.drawer.show(this.groups)
|
|
|
@@ -177,10 +183,9 @@ export default {
|
|
|
onChange (groups) {
|
|
|
this.groups = groups
|
|
|
},
|
|
|
- onSwitchCardStyle () {
|
|
|
- const next = this.cardStyle === 'big' ? 'medium' : 'big'
|
|
|
- this.cardStyle = next
|
|
|
- this.saveOptions(this.groupStyle, cardStyleCommands.includes(next) ? next : '')
|
|
|
+ onSwitchCardStyle (cardStyle) {
|
|
|
+ this.cardStyle = cardStyle
|
|
|
+ this.saveOptions(this.groupStyle, cardStyleCommands.has(cardStyle) ? cardStyle : '')
|
|
|
},
|
|
|
saveOptions (groupStyle, cardStyle) {
|
|
|
localStorage.setItem(`MSR_DASHBOARD__STYLE__${this.account}`, JSON.stringify({ groupStyle, cardStyle }))
|