ModuleDustNew.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div class="dane-bd" :style="style">
  3. <div v-if="moduleName" class="dane-title" :class="daneClass">
  4. <div class="common-navL" :class="{ 'cursor-pointer': !!moduleData.to }" @click="redirectTo"
  5. ><span class="title">{{ moduleName }}</span></div
  6. >
  7. <div class="common-navR">
  8. <!-- 下拉框 -->
  9. <div class="common-navR-select" v-if="header.show && header.selector.show">
  10. <a-select
  11. style="width: 140px"
  12. size="small"
  13. placeholder="请选择"
  14. v-model:value="selectedDeviceID"
  15. allowClear
  16. :options="options"
  17. @change="selectHandler"
  18. />
  19. </div>
  20. <div v-if="header.show && header.slot.show">
  21. {{ getFormattedText(selectedDevice, header.slot.value) }}
  22. </div>
  23. </div>
  24. </div>
  25. <div class="dane-content">
  26. <slot>
  27. <ContentNew style="height: 100%" :moduleData="moduleData" :data="selectedDevice" />
  28. </slot>
  29. </div>
  30. </div>
  31. </template>
  32. <script setup lang="ts">
  33. import ContentNew from './content-New.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 headerPosition = props.showStyle.headerPosition;
  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. if (headerPosition === 'leftTop') {
  75. return 'left-1';
  76. }
  77. if (headerPosition === 'leftCenter') {
  78. return 'left-2';
  79. }
  80. if (headerPosition === 'leftBottom') {
  81. return 'left-3';
  82. }
  83. if (headerPosition === 'rightTop') {
  84. return 'right-1';
  85. }
  86. if (headerPosition === 'rightCenter') {
  87. return 'right-2';
  88. }
  89. if (headerPosition === 'rightBottom') {
  90. return 'right-3';
  91. }
  92. if (headerPosition === 'centerBottom') {
  93. return 'center-Bottom';
  94. }
  95. return 'dane-m'; // 默认返回顶部模块
  96. });
  97. //切换时间选项
  98. // function onChange(value, dateString) {
  99. // console.log('Selected Time: ', value);
  100. // console.log('Formatted Selected Time: ', dateString);
  101. // }
  102. // function onOk(val) {
  103. // console.log('onOk: ', val);
  104. // }
  105. //下拉框选项切换
  106. function selectHandler(id) {
  107. selectedDeviceID.value = id;
  108. emit('select', selectedDevice);
  109. }
  110. function redirectTo() {
  111. const { to } = props.moduleData;
  112. if (!to) return;
  113. openWindow(to);
  114. }
  115. watch(
  116. () => props.data,
  117. (d) => {
  118. init(d);
  119. selectedDeviceID.value = options.value[0]?.value;
  120. },
  121. {
  122. immediate: true,
  123. }
  124. );
  125. </script>
  126. <style scoped lang="less">
  127. @import '/@/design/theme.less';
  128. @{theme-deepblue} {
  129. .dane-bd {
  130. --image-Left1: url('@/assets/images/vent/homeNew/left1.png');
  131. --image-Left2: url('@/assets/images/vent/homeNew/left2.png');
  132. --image-Left3: url('@/assets/images/vent/homeNew/left3.png');
  133. --image-Right1: url('@/assets/images/vent/homeNew/right1.png');
  134. --image-Right2: url('@/assets/images/vent/homeNew/right2.png');
  135. --image-Right3: url('@/assets/images/vent/homeNew/right3.png');
  136. --image-CenterBottom: url('@/assets/images/vent/homeNew/center-Bottom.png');
  137. }
  138. }
  139. .dane-bd {
  140. --image-Left1: url('@/assets/images/vent/homeNew/left1.png');
  141. --image-Left2: url('@/assets/images/vent/homeNew/left2.png');
  142. --image-Left3: url('@/assets/images/vent/homeNew/left3.png');
  143. --image-Right1: url('@/assets/images/vent/homeNew/right1.png');
  144. --image-Right2: url('@/assets/images/vent/homeNew/right2.png');
  145. --image-Right3: url('@/assets/images/vent/homeNew/right3.png');
  146. --image-CenterBottom: url('@/assets/images/vent/homeNew/center-Bottom.png');
  147. position: absolute;
  148. width: 100%;
  149. height: 100%;
  150. z-index: 2;
  151. .dane-title {
  152. display: flex;
  153. align-items: center;
  154. justify-content: space-between;
  155. width: 100%;
  156. height: 40px;
  157. padding: 0 40px 15px 20px;
  158. .common-navL {
  159. display: flex;
  160. position: relative;
  161. align-items: center;
  162. color: #fff;
  163. font-size: 14px;
  164. }
  165. .common-navR {
  166. display: flex;
  167. align-items: center;
  168. justify-content: flex-end;
  169. }
  170. }
  171. .dane-content {
  172. height: calc(100% - 38px);
  173. box-sizing: border-box;
  174. border-top: none;
  175. }
  176. }
  177. .left-1 {
  178. background: var(--image-Left1) no-repeat;
  179. background-size: 100% 100%;
  180. margin-left: 35px;
  181. }
  182. .left-2 {
  183. background: var(--image-Left2) no-repeat;
  184. background-size: 100% 100%;
  185. }
  186. .left-3 {
  187. background: var(--image-Left3) no-repeat;
  188. background-size: 100% 100%;
  189. }
  190. .right-1 {
  191. background: var(--image-Right1) no-repeat;
  192. background-size: 100% 100%;
  193. margin-left: -32px;
  194. }
  195. .right-2 {
  196. background: var(--image-Right2) no-repeat;
  197. background-size: 100% 100%;
  198. }
  199. .right-3 {
  200. background: var(--image-Right3) no-repeat;
  201. background-size: 100% 100%;
  202. }
  203. .center-Bottom {
  204. background: var(--image-CenterBottom) no-repeat;
  205. background-size: 100% 100%;
  206. }
  207. :deep(.zxm-select-selector) {
  208. height: 22px !important;
  209. border: none !important;
  210. // background-color: rgb(15 64 88) !important;
  211. background-color: transparent !important;
  212. color: #8087a1 !important;
  213. }
  214. :deep(.zxm-select-selection-placeholder) {
  215. color: #8087a1 !important;
  216. }
  217. :deep(.zxm-select-arrow) {
  218. color: #8087a1 !important;
  219. }
  220. :deep(.zxm-picker) {
  221. border: none !important;
  222. background-color: rgb(15 64 88) !important;
  223. box-shadow: none;
  224. color: #a1dff8 !important;
  225. }
  226. :deep(.zxm-picker-input > input) {
  227. color: #a1dff8 !important;
  228. text-align: center !important;
  229. }
  230. :deep(.zxm-picker-separator) {
  231. color: #a1dff8 !important;
  232. }
  233. :deep(.zxm-picker-active-bar) {
  234. display: none !important;
  235. }
  236. :deep(.zxm-picker-suffix) {
  237. color: #a1dff8 !important;
  238. }
  239. :deep(.zxm-switch) {
  240. min-width: 48px !important;
  241. }
  242. :deep(.zxm-switch-checked) {
  243. background-color: rgb(15 64 89) !important;
  244. }
  245. :deep(.zxm-switch-handle::before) {
  246. background-color: rgb(33 179 247) !important;
  247. }
  248. :deep(.zxm-select-selection-item) {
  249. color: #fff !important;
  250. }
  251. </style>