ModuleBDDual.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. if (position.includes('left:0')) {
  106. return 'dane-m';
  107. }
  108. if (position.includes('right:0')) {
  109. return 'dane-m';
  110. }
  111. return 'dane-w';
  112. });
  113. //切换时间选项
  114. // function onChange(value, dateString) {
  115. // console.log('Selected Time: ', value);
  116. // console.log('Formatted Selected Time: ', dateString);
  117. // }
  118. // function onOk(val) {
  119. // console.log('onOk: ', val);
  120. // }
  121. //下拉框选项切换
  122. function selectHandlerA(id) {
  123. selectedDeviceIDA.value = id;
  124. emit('select', selectedDeviceA);
  125. }
  126. function selectHandlerB(id) {
  127. selectedDeviceIDB.value = id;
  128. emit('select', selectedDeviceB);
  129. }
  130. watch(
  131. () => props.data,
  132. (d) => {
  133. initA(d);
  134. initB(d);
  135. selectedDeviceIDA.value = optionsA.value[0]?.value;
  136. selectedDeviceIDB.value = optionsB.value[0]?.value;
  137. },
  138. {
  139. immediate: true,
  140. }
  141. );
  142. </script>
  143. <style scoped lang="less">
  144. .dane-bd {
  145. position: absolute;
  146. width: 100%;
  147. height: 100%;
  148. background-image: url('@/assets/images/home-container/configurable/firehome/module-title.png');
  149. background-repeat: no-repeat;
  150. background-position: center top;
  151. background-size: 100% auto;
  152. z-index: 2;
  153. .dane-title {
  154. display: flex;
  155. box-sizing: border-box;
  156. align-items: center;
  157. justify-content: space-between;
  158. width: 100%;
  159. height: 34px;
  160. padding: 0 40px 0 50px;
  161. .common-navL {
  162. display: flex;
  163. position: relative;
  164. align-items: center;
  165. color: #fff;
  166. font-size: 14px;
  167. }
  168. .common-navR {
  169. display: flex;
  170. align-items: center;
  171. justify-content: flex-end;
  172. }
  173. // .common-navR-switch {
  174. // display: flex;
  175. // align-items: center;
  176. // justify-content: space-around;
  177. // width: 90%;
  178. // .status-text {
  179. // color: #1fb3f7;
  180. // font-size: 14px;
  181. // }
  182. // .status-text1 {
  183. // color: #a1dff8;
  184. // font-size: 14px;
  185. // }
  186. // }
  187. }
  188. .dane-content {
  189. height: calc(100% - 34px);
  190. // border-image: linear-gradient(#1dabeb, #1dabeb22);
  191. border-image: linear-gradient(#1dabeb 0%, #1dabeb 60%, #000723) 30;
  192. // border-left: 1px;
  193. // border-right: 1px;
  194. border-width: 2px;
  195. border-style: solid;
  196. box-sizing: border-box;
  197. border-top: none;
  198. background-image: linear-gradient(#000723 94%, #1dabeb11);
  199. }
  200. }
  201. .dane-l {
  202. background: url('@/assets/images/home-container/configurable/firehome/common-border.png') no-repeat;
  203. background-size: 100% auto;
  204. }
  205. .dane-m {
  206. // background: url('@/assets/images/home-container/configurable/firehome/common-border1.png') no-repeat;
  207. background-size: 100% auto;
  208. }
  209. .dane-s {
  210. background: url('@/assets/images/home-container/configurable/firehome/common-border2.png') no-repeat;
  211. background-size: 100% auto;
  212. }
  213. .dane-w {
  214. background-image: url('@/assets/images/home-container/configurable/firehome/module-title-long.png');
  215. background-size: 100% 37px;
  216. }
  217. .deactived {
  218. cursor: pointer;
  219. color: #8087a1;
  220. }
  221. :deep(.zxm-select-selector) {
  222. height: 22px !important;
  223. border: none !important;
  224. // background-color: rgb(15 64 88) !important;
  225. background-color: transparent !important;
  226. color: #8087a1 !important;
  227. }
  228. :deep(.zxm-select-selection-placeholder) {
  229. color: #8087a1 !important;
  230. }
  231. :deep(.zxm-select-arrow) {
  232. color: #8087a1 !important;
  233. }
  234. :deep(.zxm-picker) {
  235. border: none !important;
  236. background-color: rgb(15 64 88) !important;
  237. box-shadow: none;
  238. color: #a1dff8 !important;
  239. }
  240. :deep(.zxm-picker-input > input) {
  241. color: #a1dff8 !important;
  242. text-align: center !important;
  243. }
  244. :deep(.zxm-picker-separator) {
  245. color: #a1dff8 !important;
  246. }
  247. :deep(.zxm-picker-active-bar) {
  248. display: none !important;
  249. }
  250. :deep(.zxm-picker-suffix) {
  251. color: #a1dff8 !important;
  252. }
  253. :deep(.zxm-switch) {
  254. min-width: 48px !important;
  255. }
  256. :deep(.zxm-switch-checked) {
  257. background-color: rgb(15 64 89) !important;
  258. }
  259. :deep(.zxm-switch-handle::before) {
  260. background-color: rgb(33 179 247) !important;
  261. }
  262. :deep(.zxm-select-selection-item) {
  263. color: #fff !important;
  264. }
  265. </style>