content.vue 12 KB

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