ModuleFireNewDual.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div class="dane-bd" :style="style" :class="daneClass">
  3. <div class="dane-title">
  4. <div class="common-navL">
  5. <span :class="{ deactived: index === 1 }" @click="index = 0">
  6. {{ moduleNameA }}
  7. </span>
  8. <span class="ml-5px mr-5px">|</span>
  9. <span :class="{ deactived: index === 0 }" @click="index = 1">
  10. {{ moduleNameB }}
  11. </span>
  12. </div>
  13. <div class="common-navR">
  14. <!-- 下拉框 -->
  15. <div class="common-navR-select" v-if="index === 0 && headerA.show && headerA.selector.show">
  16. <a-select
  17. style="width: 160px"
  18. size="small"
  19. placeholder="请选择"
  20. v-model:value="selectedDeviceIDA"
  21. allowClear
  22. :options="optionsA"
  23. @change="selectHandlerA"
  24. />
  25. </div>
  26. <div class="common-navR-select" v-if="index === 1 && headerB.show && headerB.selector.show">
  27. <a-select
  28. style="width: 160px"
  29. size="small"
  30. placeholder="请选择"
  31. v-model:value="selectedDeviceIDB"
  32. allowClear
  33. :options="optionsB"
  34. @change="selectHandlerB"
  35. />
  36. </div>
  37. </div>
  38. </div>
  39. <div class="dane-content">
  40. <slot>
  41. <Content v-if="index === 0" style="height: 100%" :moduleData="moduleDataA" :data="selectedDeviceA" />
  42. <Content v-if="index === 1" style="height: 100%" :moduleData="moduleDataB" :data="selectedDeviceB" />
  43. </slot>
  44. </div>
  45. </div>
  46. </template>
  47. <script setup lang="ts">
  48. import Content from './content-FireNew.vue';
  49. import { defineProps, defineEmits, computed, ref, watch } from 'vue';
  50. import { ModuleData, ShowStyle } from '../../../../deviceManager/configurationTable/types';
  51. import { useInitModule } from '../../hooks/useInit';
  52. const props = defineProps<{
  53. moduleDataA: ModuleData;
  54. moduleNameA: string;
  55. deviceTypeA: string;
  56. moduleDataB: ModuleData;
  57. moduleNameB: string;
  58. deviceTypeB: string;
  59. showStyle: ShowStyle;
  60. visible: boolean;
  61. data: any;
  62. }>();
  63. const emit = defineEmits(['close', 'select']);
  64. const index = ref(0);
  65. const headerA = props.moduleDataA.header;
  66. const headerB = props.moduleDataB.header;
  67. const {
  68. selectedDeviceID: selectedDeviceIDA,
  69. selectedDevice: selectedDeviceA,
  70. options: optionsA,
  71. init: initA,
  72. } = useInitModule(props.deviceTypeA, props.moduleDataA);
  73. const {
  74. selectedDeviceID: selectedDeviceIDB,
  75. selectedDevice: selectedDeviceB,
  76. options: optionsB,
  77. init: initB,
  78. } = useInitModule(props.deviceTypeB, props.moduleDataB);
  79. const style = computed(() => {
  80. const size = props.showStyle.size;
  81. const position = props.showStyle.position;
  82. return size + position;
  83. });
  84. // 根据配置里的定位判断应该使用哪个module组件
  85. const daneClass = computed(() => {
  86. const headerPosition = props.showStyle.headerPosition;
  87. const size = props.showStyle.size;
  88. const [_, width] = size.match(/width:([0-9]+)px/) || [];
  89. // if (position.includes('bottom') || parseInt(width) > 800) {
  90. // return 'dane-w';
  91. // }
  92. // if (position.includes('left')) {
  93. // return 'dane-m';
  94. // }
  95. // if (position.includes('right')) {
  96. // return 'dane-m';
  97. // }
  98. if (headerPosition === 'centerBottom') {
  99. return 'center-Bottom';
  100. }
  101. if (headerPosition === 'centerTop') {
  102. return 'center-Top';
  103. }
  104. return 'dane-m'; // 默认返回顶部模块
  105. });
  106. //切换时间选项
  107. // function onChange(value, dateString) {
  108. // console.log('Selected Time: ', value);
  109. // console.log('Formatted Selected Time: ', dateString);
  110. // }
  111. // function onOk(val) {
  112. // console.log('onOk: ', val);
  113. // }
  114. //下拉框选项切换
  115. function selectHandlerA(id) {
  116. selectedDeviceIDA.value = id;
  117. emit('select', selectedDeviceA);
  118. }
  119. function selectHandlerB(id) {
  120. selectedDeviceIDB.value = id;
  121. emit('select', selectedDeviceB);
  122. }
  123. watch(
  124. () => props.data,
  125. (d) => {
  126. initA(d);
  127. initB(d);
  128. selectedDeviceIDA.value = optionsA.value[0]?.value;
  129. selectedDeviceIDB.value = optionsB.value[0]?.value;
  130. },
  131. {
  132. immediate: true,
  133. }
  134. );
  135. </script>
  136. <style scoped lang="less">
  137. @import '/@/design/theme.less';
  138. @font-face {
  139. font-family: 'douyuFont';
  140. src: url('/@/assets/font/douyuFont.otf');
  141. }
  142. @{theme-deepblue} {
  143. .dane-bd {
  144. --image-CenterBottom: url('@/assets/images/fireNew/4-2.png');
  145. --image-CenterTop: url('@/assets/images/fireNew/3-1.png');
  146. }
  147. }
  148. .dane-bd {
  149. --image-CenterBottom: url('@/assets/images/fireNew/4-2.png');
  150. --image-CenterTop: url('@/assets/images/fireNew/3-1.png');
  151. position: absolute;
  152. width: 100%;
  153. height: 100%;
  154. background-repeat: no-repeat;
  155. background-position: center top;
  156. background-size: 100% auto;
  157. z-index: 2;
  158. .dane-title {
  159. display: flex;
  160. box-sizing: border-box;
  161. align-items: center;
  162. justify-content: space-between;
  163. width: 100%;
  164. height: 34px;
  165. padding: 20px 173px 15px 133px;
  166. .common-navL {
  167. display: flex;
  168. position: relative;
  169. align-items: center;
  170. color: #fff;
  171. font-size: 15px;
  172. font-family: 'douyuFont';
  173. .common-navR {
  174. display: flex;
  175. align-items: center;
  176. justify-content: flex-end;
  177. .common-navR-select {
  178. background: url('@/assets/images/fireNew/4-1.png') no-repeat;
  179. background-size: 100% 100%;
  180. }
  181. }
  182. }
  183. }
  184. .dane-content {
  185. height: calc(100% - 34px);
  186. box-sizing: border-box;
  187. border-top: none;
  188. }
  189. }
  190. .center-Top {
  191. background: var(--image-CenterTop) no-repeat;
  192. background-size: 100% 100%;
  193. }
  194. .center-Bottom {
  195. background: var(--image-CenterBottom) no-repeat;
  196. background-size: 100% 100%;
  197. }
  198. .dane-m {
  199. background-image: var(--image-MidBottom);
  200. background-size: 100% 100%;
  201. }
  202. .deactived {
  203. cursor: pointer;
  204. color: #8087a1;
  205. }
  206. :deep(.zxm-select-selector) {
  207. height: 22px !important;
  208. border: none !important;
  209. // background-color: rgb(15 64 88) !important;
  210. background-color: transparent !important;
  211. color: #8087a1 !important;
  212. }
  213. :deep(.zxm-select-selection-placeholder) {
  214. color: #8087a1 !important;
  215. }
  216. :deep(.zxm-select-arrow) {
  217. color: #8087a1 !important;
  218. }
  219. :deep(.zxm-picker) {
  220. border: none !important;
  221. background-color: rgb(15 64 88) !important;
  222. box-shadow: none;
  223. color: #a1dff8 !important;
  224. }
  225. :deep(.zxm-picker-input > input) {
  226. color: #a1dff8 !important;
  227. text-align: center !important;
  228. }
  229. :deep(.zxm-picker-separator) {
  230. color: #a1dff8 !important;
  231. }
  232. :deep(.zxm-picker-active-bar) {
  233. display: none !important;
  234. }
  235. :deep(.zxm-picker-suffix) {
  236. color: #a1dff8 !important;
  237. }
  238. :deep(.zxm-switch) {
  239. min-width: 48px !important;
  240. }
  241. :deep(.zxm-switch-checked) {
  242. background-color: rgb(15 64 89) !important;
  243. }
  244. :deep(.zxm-switch-handle::before) {
  245. background-color: rgb(33 179 247) !important;
  246. }
  247. :deep(.zxm-select-selection-item) {
  248. color: #fff !important;
  249. }
  250. </style>