ModuleDustNew.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. if (headerPosition === 'centerBottom') {
  111. return 'center-Bottom';
  112. }
  113. return 'dane-m'; // 默认返回顶部模块
  114. });
  115. //切换时间选项
  116. // function onChange(value, dateString) {
  117. // console.log('Selected Time: ', value);
  118. // console.log('Formatted Selected Time: ', dateString);
  119. // }
  120. // function onOk(val) {
  121. // console.log('onOk: ', val);
  122. // }
  123. //下拉框选项切换
  124. function selectHandler(id) {
  125. selectedDeviceID.value = id;
  126. emit('select', selectedDevice);
  127. }
  128. function redirectTo() {
  129. const { to } = props.moduleData;
  130. if (!to) return;
  131. openWindow(to);
  132. }
  133. watch(
  134. () => props.data,
  135. (d) => {
  136. init(d);
  137. selectedDeviceID.value = options.value[0]?.value;
  138. },
  139. {
  140. immediate: true,
  141. }
  142. );
  143. </script>
  144. <style scoped lang="less">
  145. @import '/@/design/theme.less';
  146. @{theme-deepblue} {
  147. .dane-bd {
  148. --image-Left1: url('@/assets/images/vent/homeNew/left1.png');
  149. --image-Left2: url('@/assets/images/vent/homeNew/left2.png');
  150. --image-Left3: url('@/assets/images/vent/homeNew/left3.png');
  151. --image-Right1: url('@/assets/images/vent/homeNew/right1.png');
  152. --image-Right2: url('@/assets/images/vent/homeNew/right2.png');
  153. --image-Right3: url('@/assets/images/vent/homeNew/right3.png');
  154. --image-CenterBottom: url('@/assets/images/vent/homeNew/center-Bottom.png');
  155. }
  156. }
  157. .dane-bd {
  158. --image-Left1: url('@/assets/images/vent/homeNew/left1.png');
  159. --image-Left2: url('@/assets/images/vent/homeNew/left2.png');
  160. --image-Left3: url('@/assets/images/vent/homeNew/left3.png');
  161. --image-Right1: url('@/assets/images/vent/homeNew/right1.png');
  162. --image-Right2: url('@/assets/images/vent/homeNew/right2.png');
  163. --image-Right3: url('@/assets/images/vent/homeNew/right3.png');
  164. --image-CenterBottom: url('@/assets/images/vent/homeNew/center-Bottom.png');
  165. position: absolute;
  166. width: 100%;
  167. height: 100%;
  168. z-index: 2;
  169. .dane-title {
  170. display: flex;
  171. align-items: center;
  172. justify-content: space-between;
  173. width: 100%;
  174. height: 40px;
  175. padding: 0 40px 15px 20px;
  176. .common-navL {
  177. display: flex;
  178. position: relative;
  179. align-items: center;
  180. color: #fff;
  181. font-size: 14px;
  182. }
  183. .common-navR {
  184. display: flex;
  185. align-items: center;
  186. justify-content: flex-end;
  187. }
  188. }
  189. .dane-content {
  190. height: calc(100% - 38px);
  191. box-sizing: border-box;
  192. border-top: none;
  193. }
  194. }
  195. .left-1 {
  196. background: var(--image-Left1) no-repeat;
  197. background-size: 100% 100%;
  198. }
  199. .left-2 {
  200. background: var(--image-Left2) no-repeat;
  201. background-size: 100% 100%;
  202. }
  203. .left-3 {
  204. background: var(--image-Left3) no-repeat;
  205. background-size: 100% 100%;
  206. }
  207. .right-1 {
  208. background: var(--image-Right1) no-repeat;
  209. background-size: 100% 100%;
  210. }
  211. .right-2 {
  212. background: var(--image-Right2) no-repeat;
  213. background-size: 100% 100%;
  214. }
  215. .right-3 {
  216. background: var(--image-Right3) no-repeat;
  217. background-size: 100% 100%;
  218. }
  219. .center-Bottom {
  220. background: var(--image-CenterBottom) no-repeat;
  221. background-size: 100% 100%;
  222. }
  223. :deep(.zxm-select-selector) {
  224. height: 22px !important;
  225. border: none !important;
  226. // background-color: rgb(15 64 88) !important;
  227. background-color: transparent !important;
  228. color: #8087a1 !important;
  229. }
  230. :deep(.zxm-select-selection-placeholder) {
  231. color: #8087a1 !important;
  232. }
  233. :deep(.zxm-select-arrow) {
  234. color: #8087a1 !important;
  235. }
  236. :deep(.zxm-picker) {
  237. border: none !important;
  238. background-color: rgb(15 64 88) !important;
  239. box-shadow: none;
  240. color: #a1dff8 !important;
  241. }
  242. :deep(.zxm-picker-input > input) {
  243. color: #a1dff8 !important;
  244. text-align: center !important;
  245. }
  246. :deep(.zxm-picker-separator) {
  247. color: #a1dff8 !important;
  248. }
  249. :deep(.zxm-picker-active-bar) {
  250. display: none !important;
  251. }
  252. :deep(.zxm-picker-suffix) {
  253. color: #a1dff8 !important;
  254. }
  255. :deep(.zxm-switch) {
  256. min-width: 48px !important;
  257. }
  258. :deep(.zxm-switch-checked) {
  259. background-color: rgb(15 64 89) !important;
  260. }
  261. :deep(.zxm-switch-handle::before) {
  262. background-color: rgb(33 179 247) !important;
  263. }
  264. :deep(.zxm-select-selection-item) {
  265. color: #fff !important;
  266. }
  267. </style>