ModuleFireNew.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. <!-- 日期组件 -->
  24. <!-- <div class="common-navR-date" v-if="header.show && header.showSlot">
  25. <a-range-picker
  26. size="small"
  27. style="width: 140px"
  28. :show-time="{ format: 'HH:mm' }"
  29. format="YYYY-MM-DD HH:mm"
  30. :placeholder="['开始时间', '结束时间']"
  31. @change="onChange"
  32. @ok="onOk"
  33. />
  34. </div> -->
  35. <!-- 开关组件 -->
  36. <!-- <div class="common-navR-switch" v-if="commonTitle == 'switchs'">
  37. <div :class="checked ? 'status-text1' : 'status-text'">风险来源</div>
  38. <a-switch v-model:checked="checked" />
  39. <div :class="checked ? 'status-text' : 'status-text1'">危险位置</div>
  40. </div> -->
  41. </div>
  42. </div>
  43. <div class="dane-content">
  44. <slot>
  45. <Content style="height: 100%" :moduleData="moduleData" :data="selectedDevice" />
  46. </slot>
  47. </div>
  48. </div>
  49. </template>
  50. <script setup lang="ts">
  51. import Content from './content.vue';
  52. import { defineProps, defineEmits, computed, watch } from 'vue';
  53. import { useInitModule } from '../hooks/useInit';
  54. import { getFormattedText } from '../hooks/helper';
  55. import { openWindow } from '/@/utils';
  56. // import { ModuleProps } from '../types';
  57. const props = defineProps<{
  58. /** 配置的详细模块信息 */
  59. moduleData: any;
  60. /** 配置的详细样式信息 */
  61. showStyle: any;
  62. /** 该模块配置中的设备标识符 */
  63. deviceType: string;
  64. /** api返回的数据 */
  65. data: any;
  66. moduleName: string;
  67. visible: boolean;
  68. }>();
  69. const emit = defineEmits(['close', 'select']);
  70. const { header } = props.moduleData;
  71. const { selectedDeviceID, selectedDevice, options, init } = useInitModule(props.deviceType, props.moduleData);
  72. const style = computed(() => {
  73. const size = props.showStyle.size;
  74. const position = props.showStyle.position;
  75. return size + position;
  76. });
  77. // 根据配置里的定位判断应该使用哪个module组件
  78. const daneClass = computed(() => {
  79. const headerPosition = props.showStyle.headerPosition;
  80. const size = props.showStyle.size;
  81. const [_, width] = size.match(/width:([0-9]+)px/) || [];
  82. // if (position.includes('bottom') || parseInt(width) > 800) {
  83. // return 'dane-w';
  84. // }
  85. // if (position.includes('left')) {
  86. // return 'dane-m';
  87. // }
  88. // if (position.includes('right')) {
  89. // return 'dane-m';
  90. // }
  91. // return 'dane-m';
  92. if (headerPosition === 'leftTop') {
  93. return 'left-1';
  94. }
  95. if (headerPosition === 'leftCenter') {
  96. return 'left-2';
  97. }
  98. if (headerPosition === 'leftBottom') {
  99. return 'left-3';
  100. }
  101. if (headerPosition === 'rightTop') {
  102. return 'right-1';
  103. }
  104. if (headerPosition === 'rightCenter') {
  105. return 'right-1';
  106. }
  107. if (headerPosition === 'rightBottom') {
  108. return 'right-3';
  109. }
  110. return 'dane-m'; // 默认返回顶部模块
  111. });
  112. //切换时间选项
  113. // function onChange(value, dateString) {
  114. // console.log('Selected Time: ', value);
  115. // console.log('Formatted Selected Time: ', dateString);
  116. // }
  117. // function onOk(val) {
  118. // console.log('onOk: ', val);
  119. // }
  120. //下拉框选项切换
  121. function selectHandler(id) {
  122. selectedDeviceID.value = id;
  123. emit('select', selectedDevice);
  124. }
  125. function redirectTo() {
  126. const { to } = props.moduleData;
  127. if (!to) return;
  128. openWindow(to);
  129. }
  130. watch(
  131. () => props.data,
  132. (d) => {
  133. init(d);
  134. selectedDeviceID.value = options.value[0]?.value;
  135. },
  136. {
  137. immediate: true,
  138. }
  139. );
  140. </script>
  141. <style scoped lang="less">
  142. @import '/@/design/theme.less';
  143. @{theme-deepblue} {
  144. .dane-bd {
  145. --image-Left1: url('@/assets/images/vent/homeNew/left1.png');
  146. --image-Left2: url('@/assets/images/vent/homeNew/left2.png');
  147. --image-Left3: url('@/assets/images/vent/homeNew/left3.png');
  148. --image-Right1: url('@/assets/images/vent/homeNew/right1.png');
  149. --image-Right2: url('@/assets/images/vent/homeNew/right2.png');
  150. --image-Right3: url('@/assets/images/vent/homeNew/right3.png');
  151. }
  152. }
  153. .dane-bd {
  154. --image-Left1: url('@/assets/images/vent/homeNew/left1.png');
  155. --image-Left2: url('@/assets/images/vent/homeNew/left2.png');
  156. --image-Left3: url('@/assets/images/vent/homeNew/left3.png');
  157. --image-Right1: url('@/assets/images/vent/homeNew/right1.png');
  158. --image-Right2: url('@/assets/images/vent/homeNew/right2.png');
  159. --image-Right3: url('@/assets/images/vent/homeNew/right3.png');
  160. position: absolute;
  161. width: 100%;
  162. height: 100%;
  163. z-index: 2;
  164. .dane-title {
  165. display: flex;
  166. align-items: center;
  167. justify-content: space-between;
  168. width: 100%;
  169. height: 40px;
  170. padding: 0 40px 15px 20px;
  171. .common-navL {
  172. display: flex;
  173. position: relative;
  174. align-items: center;
  175. color: #fff;
  176. font-size: 14px;
  177. }
  178. .common-navR {
  179. display: flex;
  180. align-items: center;
  181. justify-content: flex-end;
  182. }
  183. }
  184. .dane-content {
  185. height: calc(100% - 38px);
  186. box-sizing: border-box;
  187. border-top: none;
  188. }
  189. }
  190. .left-1 {
  191. background: var(--image-Left1) no-repeat;
  192. background-size: 100% 100%;
  193. }
  194. .left-2 {
  195. background: var(--image-Left2) no-repeat;
  196. background-size: 100% 100%;
  197. }
  198. .left-3 {
  199. background: var(--image-Left3) no-repeat;
  200. background-size: 100% 100%;
  201. }
  202. .right-1 {
  203. background: var(--image-Right1) no-repeat;
  204. background-size: 100% 100%;
  205. }
  206. .right-2 {
  207. background: var(--image-Right2) no-repeat;
  208. background-size: 100% 100%;
  209. }
  210. .right-3 {
  211. background: var(--image-Right3) no-repeat;
  212. background-size: 100% 100%;
  213. }
  214. :deep(.zxm-select-selector) {
  215. height: 22px !important;
  216. border: none !important;
  217. // background-color: rgb(15 64 88) !important;
  218. background-color: transparent !important;
  219. color: #8087a1 !important;
  220. }
  221. :deep(.zxm-select-selection-placeholder) {
  222. color: #8087a1 !important;
  223. }
  224. :deep(.zxm-select-arrow) {
  225. color: #8087a1 !important;
  226. }
  227. :deep(.zxm-picker) {
  228. border: none !important;
  229. background-color: rgb(15 64 88) !important;
  230. box-shadow: none;
  231. color: #a1dff8 !important;
  232. }
  233. :deep(.zxm-picker-input > input) {
  234. color: #a1dff8 !important;
  235. text-align: center !important;
  236. }
  237. :deep(.zxm-picker-separator) {
  238. color: #a1dff8 !important;
  239. }
  240. :deep(.zxm-picker-active-bar) {
  241. display: none !important;
  242. }
  243. :deep(.zxm-picker-suffix) {
  244. color: #a1dff8 !important;
  245. }
  246. :deep(.zxm-switch) {
  247. min-width: 48px !important;
  248. }
  249. :deep(.zxm-switch-checked) {
  250. background-color: rgb(15 64 89) !important;
  251. }
  252. :deep(.zxm-switch-handle::before) {
  253. background-color: rgb(33 179 247) !important;
  254. }
  255. :deep(.zxm-select-selection-item) {
  256. color: #fff !important;
  257. }
  258. </style>