ModuleBD.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div class="dane-bd" :style="style" :class="daneClass">
  3. <div v-if="moduleName" class="dane-title">
  4. <div class="common-navL" :class="{ 'cursor-pointer': !!moduleData.to }" @click="redirectTo">{{ moduleName }}</div>
  5. <div class="common-navR">
  6. <!-- 下拉框 -->
  7. <div class="common-navR-select" v-if="header.show && header.showSelector">
  8. <a-select
  9. style="width: 140px"
  10. size="small"
  11. placeholder="请选择"
  12. v-model:value="selectedDeviceID"
  13. allowClear
  14. :options="options"
  15. @change="selectHandler"
  16. />
  17. </div>
  18. <div v-if="header.show && header.showSlot">
  19. {{ getFormattedText(selectedDevice, header.slot.value) }}
  20. </div>
  21. <!-- 日期组件 -->
  22. <!-- <div class="common-navR-date" v-if="header.show && header.showSlot">
  23. <a-range-picker
  24. size="small"
  25. style="width: 140px"
  26. :show-time="{ format: 'HH:mm' }"
  27. format="YYYY-MM-DD HH:mm"
  28. :placeholder="['开始时间', '结束时间']"
  29. @change="onChange"
  30. @ok="onOk"
  31. />
  32. </div> -->
  33. <!-- 开关组件 -->
  34. <!-- <div class="common-navR-switch" v-if="commonTitle == 'switchs'">
  35. <div :class="checked ? 'status-text1' : 'status-text'">风险来源</div>
  36. <a-switch v-model:checked="checked" />
  37. <div :class="checked ? 'status-text' : 'status-text1'">危险位置</div>
  38. </div> -->
  39. </div>
  40. </div>
  41. <div class="dane-content">
  42. <slot>
  43. <Content style="height: 100%" :moduleData="moduleData" :data="selectedDevice" />
  44. </slot>
  45. </div>
  46. </div>
  47. </template>
  48. <script setup lang="ts">
  49. import Content from './content.vue';
  50. import { defineProps, defineEmits, computed, onMounted, onUnmounted } from 'vue';
  51. import { ModuleData, ShowStyle } from '../../../deviceManager/configurationTable/types';
  52. import { useInitDevicesBD } from '../hooks/useInit';
  53. import { getFormattedText } from '../../../deviceManager/configurationTable/adapters';
  54. import { openWindow } from '/@/utils';
  55. const props = defineProps<{
  56. moduleData: ModuleData;
  57. showStyle: ShowStyle;
  58. moduleName: string;
  59. deviceType: string;
  60. visible: boolean;
  61. pageType: string;
  62. }>();
  63. const emit = defineEmits(['close', 'select']);
  64. const { header } = props.moduleData;
  65. const { selectedDeviceID, selectedDevice, options, fetchDevices } = useInitDevicesBD(props.deviceType, props.pageType, props.moduleData);
  66. const style = computed(() => {
  67. const size = props.showStyle.size;
  68. const position = props.showStyle.position;
  69. return size + position;
  70. });
  71. let interval: any = null;
  72. // 根据配置里的定位判断应该使用哪个module组件
  73. const daneClass = computed(() => {
  74. const position = props.showStyle.position;
  75. if (position.includes('left:0')) {
  76. return 'dane-m';
  77. }
  78. if (position.includes('right:0')) {
  79. return 'dane-m';
  80. }
  81. return 'dane-w';
  82. });
  83. //切换时间选项
  84. // function onChange(value, dateString) {
  85. // console.log('Selected Time: ', value);
  86. // console.log('Formatted Selected Time: ', dateString);
  87. // }
  88. // function onOk(val) {
  89. // console.log('onOk: ', val);
  90. // }
  91. //下拉框选项切换
  92. function selectHandler(id) {
  93. selectedDeviceID.value = id;
  94. emit('select', selectedDevice);
  95. }
  96. function redirectTo() {
  97. const { to } = props.moduleData;
  98. if (!to) return;
  99. openWindow(to);
  100. }
  101. onMounted(() => {
  102. fetchDevices({ init: true });
  103. interval = setInterval(() => {
  104. fetchDevices();
  105. }, 60000);
  106. });
  107. onUnmounted(() => {
  108. clearInterval(interval);
  109. });
  110. </script>
  111. <style scoped lang="less">
  112. .dane-bd {
  113. position: absolute;
  114. width: 100%;
  115. height: 100%;
  116. background-image: url('@/assets/images/home-container/configurable/firehome/module-title.png');
  117. background-repeat: no-repeat;
  118. background-position: center top;
  119. background-size: 100% auto;
  120. z-index: 2;
  121. .dane-title {
  122. display: flex;
  123. box-sizing: border-box;
  124. align-items: center;
  125. justify-content: space-between;
  126. width: 100%;
  127. height: 34px;
  128. padding: 0 40px 0 50px;
  129. .common-navL {
  130. display: flex;
  131. position: relative;
  132. align-items: center;
  133. color: #fff;
  134. font-size: 14px;
  135. }
  136. .common-navR {
  137. display: flex;
  138. align-items: center;
  139. justify-content: flex-end;
  140. }
  141. // .common-navR-switch {
  142. // display: flex;
  143. // align-items: center;
  144. // justify-content: space-around;
  145. // width: 90%;
  146. // .status-text {
  147. // color: #1fb3f7;
  148. // font-size: 14px;
  149. // }
  150. // .status-text1 {
  151. // color: #a1dff8;
  152. // font-size: 14px;
  153. // }
  154. // }
  155. }
  156. .dane-content {
  157. height: calc(100% - 34px);
  158. // border-image: linear-gradient(#1dabeb, #1dabeb22);
  159. border-image: linear-gradient(#1dabeb 0%, #1dabeb 60%, #000723) 30;
  160. // border-left: 1px;
  161. // border-right: 1px;
  162. border-width: 2px;
  163. border-style: solid;
  164. box-sizing: border-box;
  165. border-top: none;
  166. background-image: linear-gradient(#000723 94%, #1dabeb11);
  167. }
  168. }
  169. .dane-l {
  170. background: url('@/assets/images/home-container/configurable/firehome/common-border.png') no-repeat;
  171. background-size: 100% auto;
  172. }
  173. .dane-m {
  174. // background: url('@/assets/images/home-container/configurable/firehome/common-border1.png') no-repeat;
  175. background-size: 100% auto;
  176. }
  177. .dane-s {
  178. background: url('@/assets/images/home-container/configurable/firehome/common-border2.png') no-repeat;
  179. background-size: 100% auto;
  180. }
  181. .dane-w {
  182. background-image: url('@/assets/images/home-container/configurable/firehome/module-title-long.png');
  183. background-size: 100% 37px;
  184. }
  185. :deep(.zxm-select-selector) {
  186. height: 22px !important;
  187. border: none !important;
  188. // background-color: rgb(15 64 88) !important;
  189. background-color: transparent !important;
  190. color: #8087a1 !important;
  191. }
  192. :deep(.zxm-select-selection-placeholder) {
  193. color: #8087a1 !important;
  194. }
  195. :deep(.zxm-select-arrow) {
  196. color: #8087a1 !important;
  197. }
  198. :deep(.zxm-picker) {
  199. border: none !important;
  200. background-color: rgb(15 64 88) !important;
  201. box-shadow: none;
  202. color: #a1dff8 !important;
  203. }
  204. :deep(.zxm-picker-input > input) {
  205. color: #a1dff8 !important;
  206. text-align: center !important;
  207. }
  208. :deep(.zxm-picker-separator) {
  209. color: #a1dff8 !important;
  210. }
  211. :deep(.zxm-picker-active-bar) {
  212. display: none !important;
  213. }
  214. :deep(.zxm-picker-suffix) {
  215. color: #a1dff8 !important;
  216. }
  217. :deep(.zxm-switch) {
  218. min-width: 48px !important;
  219. }
  220. :deep(.zxm-switch-checked) {
  221. background-color: rgb(15 64 89) !important;
  222. }
  223. :deep(.zxm-switch-handle::before) {
  224. background-color: rgb(33 179 247) !important;
  225. }
  226. :deep(.zxm-select-selection-item) {
  227. color: #fff !important;
  228. }
  229. </style>