ModuleBDDual.vue 8.9 KB

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