ModuleFireNew.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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"
  5. ><span class="title">{{ moduleName }}</span></div
  6. >
  7. </div>
  8. <div class="dane-content">
  9. <div class="common-navR">
  10. <!-- 下拉框 -->
  11. <div class="common-navR-select" v-if="header.show && header.selector.show">
  12. <a-select
  13. style="width: 350px; font-size: 16px"
  14. size="small"
  15. placeholder="请选择"
  16. v-model:value="selectedDeviceID"
  17. allowClear
  18. :options="options"
  19. @change="selectHandler"
  20. />
  21. </div>
  22. <div v-if="header.show && header.slot.show">
  23. {{ getFormattedText(selectedDevice, header.slot.value) }}
  24. </div>
  25. </div>
  26. <slot>
  27. <ContentFireNew style="height: 100%" :moduleData="moduleData" :data="selectedDevice" />
  28. </slot>
  29. </div>
  30. </div>
  31. </template>
  32. <script setup lang="ts">
  33. import ContentFireNew from './content-FireNew.vue';
  34. import { defineProps, defineEmits, computed, watch } from 'vue';
  35. import { useInitModule } from '../hooks/useInit';
  36. import { getFormattedText } from '../hooks/helper';
  37. import { openWindow } from '/@/utils';
  38. // import { ModuleProps } from '../types';
  39. const props = defineProps<{
  40. /** 配置的详细模块信息 */
  41. moduleData: any;
  42. /** 配置的详细样式信息 */
  43. showStyle: any;
  44. /** 该模块配置中的设备标识符 */
  45. deviceType: string;
  46. /** api返回的数据 */
  47. data: any;
  48. moduleName: string;
  49. visible: boolean;
  50. }>();
  51. const emit = defineEmits(['close', 'select']);
  52. const { header } = props.moduleData;
  53. const { selectedDeviceID, selectedDevice, options, init } = useInitModule(props.deviceType, props.moduleData);
  54. const style = computed(() => {
  55. const size = props.showStyle.size;
  56. const position = props.showStyle.position;
  57. return size + position;
  58. });
  59. // 根据配置里的定位判断应该使用哪个module组件
  60. const daneClass = computed(() => {
  61. const position = props.showStyle.position;
  62. const size = props.showStyle.size;
  63. const [_, width] = size.match(/width:([0-9]+)px/) || [];
  64. if (position.includes('bottom') || parseInt(width) > 800) {
  65. return 'dane-w';
  66. }
  67. if (position.includes('left')) {
  68. return 'dane-m';
  69. }
  70. if (position.includes('right')) {
  71. return 'dane-m';
  72. }
  73. // return 'dane-m';
  74. return 'dane-m'; // 默认返回顶部模块
  75. });
  76. //切换时间选项
  77. // function onChange(value, dateString) {
  78. // console.log('Selected Time: ', value);
  79. // console.log('Formatted Selected Time: ', dateString);
  80. // }
  81. // function onOk(val) {
  82. // console.log('onOk: ', val);
  83. // }
  84. //下拉框选项切换
  85. function selectHandler(id) {
  86. selectedDeviceID.value = id;
  87. emit('select', selectedDevice);
  88. }
  89. function redirectTo() {
  90. const { to } = props.moduleData;
  91. if (!to) return;
  92. openWindow(to);
  93. }
  94. watch(
  95. () => props.data,
  96. (d) => {
  97. init(d);
  98. selectedDeviceID.value = options.value[0]?.value;
  99. },
  100. {
  101. immediate: true,
  102. }
  103. );
  104. </script>
  105. <style scoped lang="less">
  106. @import '/@/design/theme.less';
  107. @font-face {
  108. font-family: 'douyuFont';
  109. src: url('/@/assets/font/douyuFont.otf');
  110. }
  111. @{theme-deepblue} {
  112. .dane-bd {
  113. --image-Content: url('@/assets/images/fireNew/4-3.png');
  114. --image-Select: url('@/assets/images/fireNew/5.png');
  115. }
  116. }
  117. .dane-bd {
  118. --image-Select: url('@/assets/images/fireNew/5.png');
  119. --image-Content: url('@/assets/images/fireNew/4-3.png');
  120. position: absolute;
  121. width: 100%;
  122. height: 100%;
  123. z-index: 2;
  124. .dane-title {
  125. width: 94%;
  126. height: 40px;
  127. text-align: center;
  128. padding-top: 9px;
  129. .common-navL {
  130. position: relative;
  131. align-items: center;
  132. color: #fff;
  133. font-size: 13px;
  134. font-weight: bold;
  135. font-family: 'douyuFont';
  136. }
  137. }
  138. .dane-content {
  139. height: calc(100% - 38px);
  140. box-sizing: border-box;
  141. border-top: none;
  142. .common-navR {
  143. display: flex;
  144. align-items: center;
  145. justify-content: center;
  146. background: var(--image-Select) no-repeat;
  147. background-size: 100% 100%;
  148. width: 87%;
  149. margin-left: 30px;
  150. }
  151. }
  152. }
  153. .dane-m {
  154. background: var(--image-Content) no-repeat;
  155. background-size: 100% 100%;
  156. }
  157. :deep(.zxm-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(.zxm-select-selection-placeholder) {
  165. color: #8087a1 !important;
  166. }
  167. :deep(.zxm-select-arrow) {
  168. color: #8087a1 !important;
  169. }
  170. :deep(.zxm-picker) {
  171. border: none !important;
  172. background-color: rgb(15 64 88) !important;
  173. box-shadow: none;
  174. color: #a1dff8 !important;
  175. }
  176. :deep(.zxm-picker-input > input) {
  177. color: #a1dff8 !important;
  178. text-align: center !important;
  179. }
  180. :deep(.zxm-picker-separator) {
  181. color: #a1dff8 !important;
  182. }
  183. :deep(.zxm-picker-active-bar) {
  184. display: none !important;
  185. }
  186. :deep(.zxm-picker-suffix) {
  187. color: #a1dff8 !important;
  188. }
  189. :deep(.zxm-switch) {
  190. min-width: 48px !important;
  191. }
  192. :deep(.zxm-switch-checked) {
  193. background-color: rgb(15 64 89) !important;
  194. }
  195. :deep(.zxm-switch-handle::before) {
  196. background-color: rgb(33 179 247) !important;
  197. }
  198. :deep(.zxm-select-selection-item) {
  199. color: #fff !important;
  200. }
  201. </style>