content.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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 === 'qh_curve'">
  68. <QHCurve class="content__module" :mainfan="config.data" />
  69. </template>
  70. <template v-if="config.name === 'measure_detail'">
  71. <MeasureDetail
  72. class="content__module"
  73. :show-title="false"
  74. :composite-data="config.data"
  75. :topconfig="config.config.topconfig"
  76. :btnconfig="config.config.btnconfig"
  77. />
  78. </template>
  79. <!-- <template v-if="config.key === 'fire_control'">
  80. <FIreControl class="content__module" />
  81. </template>
  82. <template v-if="config.key === 'fire_warn'">
  83. <FIreWarn class="content__module" />
  84. </template> -->
  85. </div>
  86. </div>
  87. </div>
  88. </template>
  89. <script lang="ts" setup>
  90. import { computed } from 'vue';
  91. import {
  92. CommonItem,
  93. Config,
  94. // ModuleDataBoard,
  95. // ModuleDataChart,
  96. // ModuleDataList,
  97. // ModuleDataPreset,
  98. // ModuleDataTable,
  99. } from '../../../deviceManager/configurationTable/types';
  100. import MiniBoard from './detail/MiniBoard.vue';
  101. import TimelineList from './detail/TimelineList.vue';
  102. import CustomList from './detail/CustomList.vue';
  103. import CustomGallery from './detail/CustomGallery.vue';
  104. import ComplexList from './detail/ComplexList.vue';
  105. import GalleryList from './detail/GalleryList.vue';
  106. import CustomTable from './detail/CustomTable.vue';
  107. import CustomChart from './detail/CustomChart.vue';
  108. import { clone } from 'lodash-es';
  109. import { getData, getFormattedText } from '../hooks/helper';
  110. import BlastDelta from '../../../monitorManager/deviceMonitor/components/device/modal/blastDelta.vue';
  111. import QHCurve from './preset/QHCurve.vue';
  112. import MeasureDetail from './preset/MeasureDetail.vue';
  113. // import FIreWarn from './preset/FIreWarn.vue';
  114. // import FIreControl from './preset/FIreControl.vue';
  115. const props = defineProps<{
  116. data: any;
  117. moduleData: Config['moduleData'];
  118. }>();
  119. const { background, layout } = props.moduleData;
  120. // 获取当原始配置带 items 项时的最终 items 配置
  121. function getItems(raw, items: CommonItem[]) {
  122. return items.map((i) => {
  123. return {
  124. ...i,
  125. label: getFormattedText(raw, i.label, i.trans),
  126. value: getFormattedText(raw, i.value, i.trans),
  127. };
  128. });
  129. }
  130. // 获取当 List 组件配置带 items 项时的最终 items 配置
  131. function getListItems(raw: any, items: CommonItem[], mapFromData?: boolean) {
  132. if (mapFromData && Array.isArray(raw)) {
  133. return raw.map((data) => {
  134. const item = items[0];
  135. return {
  136. ...item,
  137. label: getFormattedText(data, item.label, item.trans),
  138. value: getFormattedText(data, item.value, item.trans),
  139. };
  140. });
  141. }
  142. return getItems(raw, items);
  143. }
  144. /** 根据配置里的layout将配置格式化为带 key 的具体配置,例如:[{ key: 'list', value: any, ...ModuleDataList }] */
  145. const layoutConfig = computed(() => {
  146. const refData = props.data;
  147. const board = clone(props.moduleData.board) || [];
  148. const list = clone(props.moduleData.list) || [];
  149. const gallery = clone(props.moduleData.gallery) || [];
  150. const complex_list = clone(props.moduleData.complex_list) || [];
  151. const gallery_list = clone(props.moduleData.gallery_list) || [];
  152. const chart = clone(props.moduleData.chart) || [];
  153. const table = clone(props.moduleData.table) || [];
  154. const preset = clone(props.moduleData.preset) || [];
  155. return layout.items.reduce((arr: any[], item) => {
  156. switch (item.name) {
  157. case 'board': {
  158. const cfg = board.shift();
  159. if (!cfg) break;
  160. const data = getData(refData, cfg.readFrom, cfg.parser);
  161. arr.push({
  162. overflow: true,
  163. ...item,
  164. ...cfg,
  165. items: getItems(data, cfg.items),
  166. });
  167. break;
  168. }
  169. case 'list': {
  170. const cfg = list.shift();
  171. if (!cfg) break;
  172. const data = getData(refData, cfg.readFrom, cfg.parser);
  173. arr.push({
  174. overflow: true,
  175. ...item,
  176. ...cfg,
  177. items: getListItems(data, cfg.items, cfg.mapFromData),
  178. });
  179. break;
  180. }
  181. case 'gallery': {
  182. const cfg = gallery.shift();
  183. if (!cfg) break;
  184. const data = getData(refData, cfg.readFrom, cfg.parser);
  185. arr.push({
  186. overflow: true,
  187. ...item,
  188. ...cfg,
  189. items: getItems(data, cfg.items),
  190. });
  191. break;
  192. }
  193. case 'complex_list': {
  194. const cfg = complex_list.shift();
  195. if (!cfg) break;
  196. const data = getData(refData, cfg.readFrom, cfg.parser);
  197. if (cfg.mapFromData) {
  198. const firstListItem = cfg.items[0];
  199. arr.push({
  200. overflow: true,
  201. ...item,
  202. ...cfg,
  203. items: (data || []).map((d) => {
  204. return {
  205. title: getFormattedText(d, firstListItem.title),
  206. contents: firstListItem.contents.map((e) => {
  207. return {
  208. ...e,
  209. label: getFormattedText(d, e.label, e.trans),
  210. value: getFormattedText(d, e.value, e.trans),
  211. };
  212. }),
  213. };
  214. }),
  215. });
  216. } else {
  217. arr.push({
  218. overflow: true,
  219. ...item,
  220. ...cfg,
  221. items: cfg.items.map((i) => {
  222. return {
  223. title: getFormattedText(data, i.title),
  224. contents: i.contents.map((e) => {
  225. return {
  226. ...e,
  227. label: getFormattedText(data, e.label, e.trans),
  228. value: getFormattedText(data, e.value, e.trans),
  229. };
  230. }),
  231. };
  232. }),
  233. });
  234. }
  235. break;
  236. }
  237. case 'gallery_list': {
  238. const cfg = gallery_list.shift();
  239. if (!cfg) break;
  240. const data = getData(refData, cfg.readFrom, cfg.parser);
  241. arr.push({
  242. overflow: true,
  243. ...item,
  244. ...cfg,
  245. items: getItems(data, cfg.items),
  246. galleryItems: getItems(data, cfg.galleryItems),
  247. });
  248. break;
  249. }
  250. case 'chart': {
  251. const cfg = chart.shift();
  252. if (!cfg) break;
  253. debugger;
  254. const data = getData(refData, cfg.readFrom, cfg.parser);
  255. arr.push({
  256. ...item,
  257. config: cfg,
  258. data,
  259. });
  260. break;
  261. }
  262. case 'table': {
  263. const cfg = table.shift();
  264. if (!cfg) break;
  265. const data = getData(refData, cfg.readFrom, cfg.parser);
  266. arr.push({
  267. ...cfg,
  268. ...item,
  269. columns: cfg.columns,
  270. data,
  271. });
  272. break;
  273. }
  274. default: {
  275. const cfg = preset.shift();
  276. if (!cfg) break;
  277. const data = getData(refData, cfg.readFrom, cfg.parser);
  278. arr.push({
  279. ...item,
  280. data,
  281. config: cfg,
  282. });
  283. break;
  284. }
  285. }
  286. return arr;
  287. }, []);
  288. });
  289. </script>
  290. <style lang="less" scoped>
  291. @import '@/design/theme.less';
  292. .content {
  293. height: calc(100% - 30px);
  294. position: relative;
  295. // z-index: -2;
  296. display: flex;
  297. flex-direction: column;
  298. }
  299. .content__background {
  300. width: 100%;
  301. height: 100%;
  302. position: absolute;
  303. top: 0;
  304. left: 0;
  305. z-index: 0;
  306. object-fit: fill;
  307. }
  308. .content__module {
  309. // margin-top: 5px;
  310. // margin-bottom: 5px;
  311. width: 100%;
  312. height: 100%;
  313. }
  314. // .content__module:first-of-type {
  315. // margin-top: 0;
  316. // }
  317. // .content__module:last-of-type {
  318. // margin-bottom: 0;
  319. // }
  320. ::-webkit-scrollbar {
  321. width: 5px !important;
  322. }
  323. ::-webkit-scrollbar-thumb {
  324. width: 5px !important;
  325. }
  326. ::v-deep .zxm-select:not(.zxm-select-customize-input) .zxm-select-selector {
  327. /* background-color: transparent; */
  328. color: #fff;
  329. }
  330. ::v-deep .zxm-select-arrow {
  331. color: #fff;
  332. }
  333. ::v-deep .zxm-select-selection-item {
  334. color: #fff !important;
  335. }
  336. ::v-deep .zxm-select-selection-placeholder {
  337. color: #fff !important;
  338. }
  339. ::-webkit-scrollbar {
  340. width: 5px !important;
  341. }
  342. ::-webkit-scrollbar-thumb {
  343. width: 5px !important;
  344. }
  345. </style>