ModuleBD.vue 5.8 KB

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