DeviceStatus.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="l-flex--col">
  3. <div class="l-flex--row l-flex__none c-status-bar">
  4. <div
  5. v-for="tab in tabs"
  6. :key="tab.key"
  7. class="l-flex__none c-status-bar__item u-pointer"
  8. :class="{ active: tab.key === active }"
  9. @click="active = tab.key"
  10. >
  11. {{ tab.name }}
  12. </div>
  13. </div>
  14. <div class="l-flex__fill u-overflow-y--auto">
  15. <component
  16. :is="activeComponent"
  17. v-bind="$attrs"
  18. />
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. import DeviceRuntime from './DeviceRuntime'
  24. import DeviceSensor from './DeviceSensor'
  25. export default {
  26. name: 'DeviceStatus',
  27. components: {
  28. DeviceRuntime,
  29. DeviceSensor
  30. },
  31. data () {
  32. return {
  33. active: 'runtime',
  34. tabs: [
  35. { key: 'runtime', name: '播控器状态' },
  36. __SENSOR__ ? { key: 'sensor', name: '传感器状态' } : null
  37. ].filter(val => val)
  38. }
  39. },
  40. computed: {
  41. activeComponent () {
  42. switch (this.active) {
  43. case 'runtime':
  44. return 'DeviceRuntime'
  45. case 'sensor':
  46. return 'DeviceSensor'
  47. default:
  48. return null
  49. }
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .c-status-bar {
  56. align-self: flex-start;
  57. padding: 8px 12px;
  58. margin-bottom: $spacing;
  59. border-radius: 2px;
  60. background-color: #f4f7fb;
  61. overflow-x: auto;
  62. &__item {
  63. color: #8e929c;
  64. font-size: 16px;
  65. line-height: 1;
  66. & + & {
  67. margin-left: 32px;
  68. }
  69. &.active {
  70. color: $blue;
  71. }
  72. }
  73. }
  74. </style>
  75. <style lang="scss">
  76. .c-runtime {
  77. padding: 12px 16px 16px;
  78. color: #d5d9e4;
  79. font-size: 14px;
  80. line-height: 1;
  81. .medium {
  82. font-size: 18px;
  83. }
  84. .large {
  85. font-size: 32px;
  86. }
  87. &__icon {
  88. display: inline-block;
  89. width: 32px;
  90. height: 32px;
  91. margin-right: 8px;
  92. background-position: 0 0;
  93. background-size: 100% 100%;
  94. background-repeat: no-repeat;
  95. &.running {
  96. background-image: url("~@/assets/icon_condition.png");
  97. }
  98. &.screenshot {
  99. background-image: url("~@/assets/icon_image.png");
  100. }
  101. &.download {
  102. background-image: url("~@/assets/icon_download.png");
  103. }
  104. &.temperature {
  105. background-image: url("~@/assets/icon_temperature.png");
  106. }
  107. &.smoke {
  108. background-image: url("~@/assets/icon_smoke.png");
  109. }
  110. &.flooding {
  111. background-image: url("~@/assets/icon_flooding.png");
  112. }
  113. &.light {
  114. background-image: url("~@/assets/icon_light.png");
  115. }
  116. }
  117. &__title {
  118. color: #8e929c;
  119. }
  120. &__list {
  121. color: $blue;
  122. font-size: 18px;
  123. }
  124. }
  125. </style>