module-green.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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-green.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-deepblue} {
  125. .dane-bd {
  126. --image-module-title: url('@/assets/images/themify/deepblue/home-container/configurable/firehome/module-title.png');
  127. --image-common-border: url('@/assets/images/themify/deepblue/home-container/configurable/firehome/common-border.png');
  128. --image-common-border2: url('@/assets/images/themify/deepblue/home-container/configurable/firehome/common-border2.png');
  129. --image-module-title-long: url('@/assets/images/themify/deepblue/home-container/configurable/firehome/module-title-long.png');
  130. }
  131. }
  132. .dane-bd {
  133. --image-module-title: url('@/assets/images/home-container/configurable/firehome/module-title.png');
  134. --image-common-border: url('@/assets/images/home-container/configurable/firehome/common-border.png');
  135. --image-common-border2: url('@/assets/images/home-container/configurable/firehome/common-border2.png');
  136. --image-module-title-long: url('@/assets/images/home-container/configurable/firehome/module-title-long.png');
  137. position: absolute;
  138. width: 100%;
  139. height: 100%;
  140. background-image: var(--image-module-title);
  141. background-repeat: no-repeat;
  142. background-position: center top;
  143. background-size: 100% auto;
  144. z-index: 2;
  145. .dane-title {
  146. display: flex;
  147. box-sizing: border-box;
  148. align-items: center;
  149. justify-content: space-between;
  150. width: 100%;
  151. height: 38px;
  152. padding: 0 40px 0 50px;
  153. .common-navL {
  154. display: flex;
  155. position: relative;
  156. align-items: center;
  157. color: #fff;
  158. font-size: 14px;
  159. }
  160. .common-navR {
  161. display: flex;
  162. align-items: center;
  163. justify-content: flex-end;
  164. }
  165. // .common-navR-switch {
  166. // display: flex;
  167. // align-items: center;
  168. // justify-content: space-around;
  169. // width: 90%;
  170. // .status-text {
  171. // color: #1fb3f7;
  172. // font-size: 14px;
  173. // }
  174. // .status-text1 {
  175. // color: #a1dff8;
  176. // font-size: 14px;
  177. // }
  178. // }
  179. }
  180. .dane-content {
  181. height: calc(100% - 38px);
  182. // border-image: linear-gradient(#1dabeb, #1dabeb22);
  183. border-image: var(--vent-configurable-module-border-bd) 30;
  184. // border-left: 1px;
  185. // border-right: 1px;
  186. border-width: 2px;
  187. border-style: solid;
  188. box-sizing: border-box;
  189. border-top: none;
  190. background-image: linear-gradient(#000723 94%, #1dabeb11);
  191. }
  192. }
  193. .dane-l {
  194. background: var(--image-common-border) no-repeat;
  195. background-size: 100% auto;
  196. }
  197. .dane-m {
  198. // background: url('@/assets/images/home-container/configurable/firehome/common-border1.png') no-repeat;
  199. background-size: 100% auto;
  200. }
  201. .dane-s {
  202. background: var(--image-common-border2) no-repeat;
  203. background-size: 100% auto;
  204. }
  205. .dane-w {
  206. background-image: var(--image-module-title-long);
  207. background-size: 100% 37px;
  208. }
  209. :deep(.zxm-select-selector) {
  210. height: 22px !important;
  211. border: none !important;
  212. // background-color: rgb(15 64 88) !important;
  213. background-color: transparent !important;
  214. color: #8087a1 !important;
  215. }
  216. :deep(.zxm-select-selection-placeholder) {
  217. color: #8087a1 !important;
  218. }
  219. :deep(.zxm-select-arrow) {
  220. color: #8087a1 !important;
  221. }
  222. :deep(.zxm-picker) {
  223. border: none !important;
  224. background-color: rgb(15 64 88) !important;
  225. box-shadow: none;
  226. color: #a1dff8 !important;
  227. }
  228. :deep(.zxm-picker-input > input) {
  229. color: #a1dff8 !important;
  230. text-align: center !important;
  231. }
  232. :deep(.zxm-picker-separator) {
  233. color: #a1dff8 !important;
  234. }
  235. :deep(.zxm-picker-active-bar) {
  236. display: none !important;
  237. }
  238. :deep(.zxm-picker-suffix) {
  239. color: #a1dff8 !important;
  240. }
  241. :deep(.zxm-switch) {
  242. min-width: 48px !important;
  243. }
  244. :deep(.zxm-switch-checked) {
  245. background-color: rgb(15 64 89) !important;
  246. }
  247. :deep(.zxm-switch-handle::before) {
  248. background-color: rgb(33 179 247) !important;
  249. }
  250. :deep(.zxm-select-selection-item) {
  251. color: #fff !important;
  252. }
  253. </style>