ModuleBD.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. selectedDeviceID.value = options.value[0]?.value;
  114. },
  115. {
  116. immediate: true,
  117. }
  118. );
  119. </script>
  120. <style scoped lang="less">
  121. @import '/@/design/theme.less';
  122. @{theme-deepblue} {
  123. .dane-bd {
  124. --image-module-title: url('@/assets/images/themify/deepblue/configurable/firehome/module-title.png');
  125. --image-common-border: url('@/assets/images/themify/deepblue/configurable/firehome/common-border.png');
  126. --image-common-border2: url('@/assets/images/themify/deepblue/configurable/firehome/common-border2.png');
  127. --image-module-title-long: url('@/assets/images/themify/deepblue/configurable/firehome/module-title-long.png');
  128. }
  129. }
  130. .dane-bd {
  131. --image-module-title: url('@/assets/images/home-container/configurable/firehome/module-title.png');
  132. --image-common-border: url('@/assets/images/home-container/configurable/firehome/common-border.png');
  133. --image-common-border2: url('@/assets/images/home-container/configurable/firehome/common-border2.png');
  134. --image-module-title-long: url('@/assets/images/home-container/configurable/firehome/module-title-long.png');
  135. position: absolute;
  136. width: 100%;
  137. height: 100%;
  138. background-image: var(--image-module-title);
  139. background-repeat: no-repeat;
  140. background-position: center top;
  141. background-size: 100% auto;
  142. z-index: 2;
  143. .dane-title {
  144. display: flex;
  145. box-sizing: border-box;
  146. align-items: center;
  147. justify-content: space-between;
  148. width: 100%;
  149. height: 38px;
  150. padding: 0 40px 0 50px;
  151. .common-navL {
  152. display: flex;
  153. position: relative;
  154. align-items: center;
  155. color: #fff;
  156. font-size: 14px;
  157. }
  158. .common-navR {
  159. display: flex;
  160. align-items: center;
  161. justify-content: flex-end;
  162. }
  163. // .common-navR-switch {
  164. // display: flex;
  165. // align-items: center;
  166. // justify-content: space-around;
  167. // width: 90%;
  168. // .status-text {
  169. // color: #1fb3f7;
  170. // font-size: 14px;
  171. // }
  172. // .status-text1 {
  173. // color: #a1dff8;
  174. // font-size: 14px;
  175. // }
  176. // }
  177. }
  178. .dane-content {
  179. height: calc(100% - 38px);
  180. // border-image: linear-gradient(#1dabeb, #1dabeb22);
  181. border-image: var(--vent-configurable-module-border-bd) 30;
  182. // border-left: 1px;
  183. // border-right: 1px;
  184. border-width: 2px;
  185. border-style: solid;
  186. box-sizing: border-box;
  187. border-top: none;
  188. background-image: linear-gradient(#000723 94%, #1dabeb11);
  189. }
  190. }
  191. .dane-l {
  192. background: var(--image-common-border) no-repeat;
  193. background-size: 100% auto;
  194. }
  195. .dane-m {
  196. // background: url('@/assets/images/home-container/configurable/firehome/common-border1.png') no-repeat;
  197. background-size: 100% auto;
  198. }
  199. .dane-s {
  200. background: var(--image-common-border2) no-repeat;
  201. background-size: 100% auto;
  202. }
  203. .dane-w {
  204. background-image: var(--image-module-title-long);
  205. background-size: 100% 37px;
  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>