content.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <!-- 主体内容部分 -->
  4. <div class="content">
  5. <!-- 背景 -->
  6. <img v-if="background.show && background.type === 'image'" class="content__background" :src="background.link" />
  7. <video
  8. v-if="background.show && background.type === 'video'"
  9. class="content__background content__background_video"
  10. width="100%"
  11. autoplay
  12. loop
  13. muted
  14. disablepictureinpicture
  15. playsinline
  16. >
  17. <source :src="background.link" />
  18. Not Supportted Link Or Browser
  19. </video>
  20. <div class="flex w-full h-full" :style="{ flexDirection: layout.direction }">
  21. <div v-for="config in layoutConfig" :key="config.name" :style="{ flexBasis: config.basis, overflow: config.overflow ? 'auto' : 'none' }">
  22. <!-- 告示板部分 -->
  23. <template v-if="config.name === 'board'">
  24. <div class="content__module flex flex-justify-around flex-items-center flex-wrap pt-10px pb-10px">
  25. <MiniBoard
  26. v-for="item in config.items"
  27. :key="item.prop"
  28. :label="item.label"
  29. :value="item.value"
  30. :type="config.type"
  31. :layout="config.layout"
  32. />
  33. </div>
  34. </template>
  35. <!-- 图表部分,这部分通常需要填充,有告示板、Header等内容需要填充父级 -->
  36. <template v-if="config.name === 'chart'">
  37. <CustomChart class="content__module" :chart-config="config.config" :chart-data="config.data" />
  38. </template>
  39. <!-- 通常列表部分 -->
  40. <template v-if="config.name === 'list'">
  41. <template v-if="config.type === 'timeline'">
  42. <TimelineList class="content__module" :list-config="config.items" />
  43. </template>
  44. <template v-else>
  45. <CustomList class="content__module" :type="config.type" :list-config="config.items" />
  46. </template>
  47. </template>
  48. <!-- 画廊部分 -->
  49. <template v-if="config.name === 'gallery'">
  50. <CustomGallery class="content__module" :type="config.type" :gallery-config="config.items" />
  51. </template>
  52. <!-- 复杂列表部分 -->
  53. <template v-if="config.name === 'gallery_list'">
  54. <GalleryList class="content__module" :type="config.type" :list-config="config.items" :gallery-config="config.galleryItems" />
  55. </template>
  56. <!-- 复杂列表部分 -->
  57. <template v-if="config.name === 'complex_list'">
  58. <ComplexList class="content__module" :type="config.type" :list-config="config.items" />
  59. </template>
  60. <!-- 表格部分,这部分通常是占一整个模块的 -->
  61. <template v-if="config.name === 'table'">
  62. <CustomTable class="content__module text-center overflow-auto" :type="config.type" :columns="config.columns" :data="config.data" />
  63. </template>
  64. <template v-if="config.name === 'blast_delta'">
  65. <BlastDelta class="content__module" :pos-monitor="config.data" :canvasSize="{ width: 250, height: 200 }" />
  66. </template>
  67. <template v-if="config.name === 'measure_detail'">
  68. <MeasureDetail
  69. class="content__module"
  70. :show-title="false"
  71. :composite-data="config.data"
  72. :topconfig="config.config.topconfig"
  73. :btnconfig="config.config.btnconfig"
  74. />
  75. </template>
  76. <!-- <template v-if="config.key === 'fire_control'">
  77. <FIreControl class="content__module" />
  78. </template>
  79. <template v-if="config.key === 'fire_warn'">
  80. <FIreWarn class="content__module" />
  81. </template> -->
  82. </div>
  83. </div>
  84. </div>
  85. </template>
  86. <script lang="ts" setup>
  87. import { computed } from 'vue';
  88. import {
  89. CommonItem,
  90. Config,
  91. // ModuleDataBoard,
  92. // ModuleDataChart,
  93. // ModuleDataList,
  94. // ModuleDataPreset,
  95. // ModuleDataTable,
  96. } from '../../../deviceManager/configurationTable/types';
  97. import MiniBoard from './detail/MiniBoard.vue';
  98. import TimelineList from './detail/TimelineList.vue';
  99. import CustomList from './detail/CustomList.vue';
  100. import CustomGallery from './detail/CustomGallery.vue';
  101. import ComplexList from './detail/ComplexList.vue';
  102. import GalleryList from './detail/GalleryList.vue';
  103. import CustomTable from './detail/CustomTable.vue';
  104. import CustomChart from './detail/CustomChart.vue';
  105. import { clone } from 'lodash-es';
  106. import { getData, getFormattedText } from '../hooks/helper';
  107. import BlastDelta from '../../../monitorManager/deviceMonitor/components/device/modal/blastDelta.vue';
  108. import MeasureDetail from './preset/MeasureDetail.vue';
  109. // import FIreWarn from './preset/FIreWarn.vue';
  110. // import FIreControl from './preset/FIreControl.vue';
  111. const props = defineProps<{
  112. data: any;
  113. moduleData: Config['moduleData'];
  114. }>();
  115. const { background, layout } = props.moduleData;
  116. // 获取当原始配置带 items 项时的最终 items 配置
  117. function getItems(raw, items: CommonItem[]) {
  118. return items.map((i) => {
  119. return {
  120. ...i,
  121. label: getFormattedText(raw, i.label, i.trans),
  122. value: getFormattedText(raw, i.value, i.trans),
  123. };
  124. });
  125. }
  126. // 获取当 List 组件配置带 items 项时的最终 items 配置
  127. function getListItems(raw: any, items: CommonItem[], mapFromData?: boolean) {
  128. if (mapFromData && Array.isArray(raw)) {
  129. return raw.map((data) => {
  130. const item = items[0];
  131. return {
  132. ...item,
  133. label: getFormattedText(data, item.label, item.trans),
  134. value: getFormattedText(data, item.value, item.trans),
  135. };
  136. });
  137. }
  138. return getItems(raw, items);
  139. }
  140. /** 根据配置里的layout将配置格式化为带 key 的具体配置,例如:[{ key: 'list', value: any, ...ModuleDataList }] */
  141. const layoutConfig = computed(() => {
  142. const refData = props.data;
  143. const board = clone(props.moduleData.board) || [];
  144. const list = clone(props.moduleData.list) || [];
  145. const gallery = clone(props.moduleData.gallery) || [];
  146. const complex_list = clone(props.moduleData.complex_list) || [];
  147. const gallery_list = clone(props.moduleData.gallery_list) || [];
  148. const chart = clone(props.moduleData.chart) || [];
  149. const table = clone(props.moduleData.table) || [];
  150. const preset = clone(props.moduleData.preset) || [];
  151. return layout.items.reduce((arr: any[], item) => {
  152. switch (item.name) {
  153. case 'board': {
  154. const cfg = board.shift();
  155. if (!cfg) break;
  156. const data = getData(refData, cfg.readFrom, cfg.parser);
  157. arr.push({
  158. overflow: true,
  159. ...item,
  160. ...cfg,
  161. items: getItems(data, cfg.items),
  162. });
  163. break;
  164. }
  165. case 'list': {
  166. const cfg = list.shift();
  167. if (!cfg) break;
  168. const data = getData(refData, cfg.readFrom, cfg.parser);
  169. arr.push({
  170. overflow: true,
  171. ...item,
  172. ...cfg,
  173. items: getListItems(data, cfg.items, cfg.mapFromData),
  174. });
  175. break;
  176. }
  177. case 'gallery': {
  178. const cfg = gallery.shift();
  179. if (!cfg) break;
  180. const data = getData(refData, cfg.readFrom, cfg.parser);
  181. arr.push({
  182. overflow: true,
  183. ...item,
  184. ...cfg,
  185. items: getItems(data, cfg.items),
  186. });
  187. break;
  188. }
  189. case 'complex_list': {
  190. const cfg = complex_list.shift();
  191. if (!cfg) break;
  192. const data = getData(refData, cfg.readFrom, cfg.parser);
  193. if (cfg.mapFromData) {
  194. const firstListItem = cfg.items[0];
  195. arr.push({
  196. overflow: true,
  197. ...item,
  198. ...cfg,
  199. items: (data || []).map((d) => {
  200. return {
  201. title: getFormattedText(d, firstListItem.title),
  202. contents: firstListItem.contents.map((e) => {
  203. return {
  204. ...e,
  205. label: getFormattedText(d, e.label, e.trans),
  206. value: getFormattedText(d, e.value, e.trans),
  207. };
  208. }),
  209. };
  210. }),
  211. });
  212. } else {
  213. arr.push({
  214. overflow: true,
  215. ...item,
  216. ...cfg,
  217. items: cfg.items.map((i) => {
  218. return {
  219. title: getFormattedText(data, i.title),
  220. contents: i.contents.map((e) => {
  221. return {
  222. ...e,
  223. label: getFormattedText(data, e.label, e.trans),
  224. value: getFormattedText(data, e.value, e.trans),
  225. };
  226. }),
  227. };
  228. }),
  229. });
  230. }
  231. break;
  232. }
  233. case 'gallery_list': {
  234. const cfg = gallery_list.shift();
  235. if (!cfg) break;
  236. const data = getData(refData, cfg.readFrom, cfg.parser);
  237. arr.push({
  238. overflow: true,
  239. ...item,
  240. ...cfg,
  241. items: getItems(data, cfg.items),
  242. galleryItems: getItems(data, cfg.galleryItems),
  243. });
  244. break;
  245. }
  246. case 'chart': {
  247. const cfg = chart.shift();
  248. if (!cfg) break;
  249. const data = getData(refData, cfg.readFrom, cfg.parser);
  250. arr.push({
  251. ...item,
  252. config: cfg,
  253. data,
  254. });
  255. break;
  256. }
  257. case 'table': {
  258. const cfg = table.shift();
  259. if (!cfg) break;
  260. const data = getData(refData, cfg.readFrom, cfg.parser);
  261. arr.push({
  262. ...cfg,
  263. ...item,
  264. columns: cfg.columns,
  265. data,
  266. });
  267. break;
  268. }
  269. default: {
  270. const cfg = preset.shift();
  271. if (!cfg) break;
  272. const data = getData(refData, cfg.readFrom, cfg.parser);
  273. arr.push({
  274. ...item,
  275. data,
  276. config: cfg,
  277. });
  278. break;
  279. }
  280. }
  281. return arr;
  282. }, []);
  283. });
  284. </script>
  285. <style lang="less" scoped>
  286. @import '@/design/vent/color.less';
  287. /* Header 相关的样式 */
  288. .content__header {
  289. height: 30px;
  290. background-image: linear-gradient(90deg, #3df6ff44, transparent 20%, transparent 80%, #3df6ff44);
  291. }
  292. .content__header_left {
  293. border-left: 3px solid;
  294. border-right: 3px solid;
  295. border-image-source: linear-gradient(to top, #185f7188, #3df6ff, #185f7188);
  296. border-image-slice: 1;
  297. }
  298. .content__header_right {
  299. border-left: 3px solid;
  300. border-right: 3px solid;
  301. border-image-source: linear-gradient(to top, #185f7188, #3df6ff, #185f7188);
  302. border-image-slice: 1;
  303. min-width: 160px;
  304. }
  305. .content {
  306. height: calc(100% - 30px);
  307. position: relative;
  308. // z-index: -2;
  309. display: flex;
  310. flex-direction: column;
  311. }
  312. .content__background {
  313. width: 100%;
  314. height: 100%;
  315. position: absolute;
  316. top: 0;
  317. left: 0;
  318. z-index: 0;
  319. object-fit: fill;
  320. }
  321. .content__module {
  322. // margin-top: 5px;
  323. // margin-bottom: 5px;
  324. width: 100%;
  325. height: 100%;
  326. }
  327. // .content__module:first-of-type {
  328. // margin-top: 0;
  329. // }
  330. // .content__module:last-of-type {
  331. // margin-bottom: 0;
  332. // }
  333. ::-webkit-scrollbar {
  334. width: 5px !important;
  335. }
  336. ::-webkit-scrollbar-thumb {
  337. width: 5px !important;
  338. }
  339. ::v-deep .zxm-select:not(.zxm-select-customize-input) .zxm-select-selector {
  340. /* background-color: transparent; */
  341. color: #fff;
  342. }
  343. ::v-deep .zxm-select-arrow {
  344. color: #fff;
  345. }
  346. ::v-deep .zxm-select-selection-item {
  347. color: #fff !important;
  348. }
  349. ::v-deep .zxm-select-selection-placeholder {
  350. color: #fff !important;
  351. }
  352. ::-webkit-scrollbar {
  353. width: 5px !important;
  354. }
  355. ::-webkit-scrollbar-thumb {
  356. width: 5px !important;
  357. }
  358. </style>