ModuleBD.vue 8.3 KB

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