content.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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 image__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
  25. v-if="config.pageType == 'vent_New'"
  26. style="padding-top: 11%"
  27. class="content__module content__module1 flex flex-justify-around flex-items-center flex-wrap"
  28. >
  29. <MiniBoard
  30. v-for="item in config.items"
  31. :key="item.prop"
  32. :label="item.label"
  33. :value="item.value"
  34. :type="config.type"
  35. :layout="config.layout"
  36. />
  37. </div>
  38. <div v-else class="content__module flex flex-justify-around flex-items-center flex-wrap">
  39. <MiniBoard
  40. v-for="item in config.items"
  41. :key="item.prop"
  42. :label="item.label"
  43. :value="item.value"
  44. :type="config.type"
  45. :layout="config.layout"
  46. />
  47. </div>
  48. </template>
  49. <!-- 图表部分,这部分通常需要填充,有告示板、Header等内容需要填充父级 -->
  50. <template v-if="config.name === 'chart'">
  51. <CustomChart v-if="config.pageType == 'New_dust'" class="content__module_dust" :chart-config="config.config" :chart-data="config.data" />
  52. <CustomChart v-else class="content__module" :chart-config="config.config" :chart-data="config.data" />
  53. </template>
  54. <!-- 通常列表部分 -->
  55. <template v-if="config.name === 'list'">
  56. <template v-if="config.type === 'timeline'">
  57. <TimelineList class="content__module" :list-config="config.items" />
  58. </template>
  59. <template v-else-if="config.type === 'timelineNew'">
  60. <TimelineListNew class="content__module" :list-config="config.items" />
  61. </template>
  62. <template v-else>
  63. <CustomList class="content__module" :type="config.type" :list-config="config.items" />
  64. </template>
  65. </template>
  66. <template v-if="config.name === 'fireList'">
  67. <CustomList class="content__module" :type="config.type" :list-config="config.items" />
  68. </template>
  69. <!-- 画廊部分 -->
  70. <template v-if="config.name === 'gallery'">
  71. <CustomGallery class="content__module" :type="config.type" :gallery-config="config.items" />
  72. </template>
  73. <!-- 复杂列表部分 -->
  74. <template v-if="config.name === 'gallery_list'">
  75. <GalleryList class="content__module" :type="config.type" :list-config="config.items" :gallery-config="config.galleryItems" />
  76. </template>
  77. <!-- 复杂列表部分 -->
  78. <template v-if="config.name === 'complex_list'">
  79. <ComplexList class="content__module" :type="config.type" :list-config="config.items" />
  80. </template>
  81. <!-- 表格部分,这部分通常是占一整个模块的 -->
  82. <template v-if="config.name === 'table'">
  83. <CustomTable class="content__module text-center overflow-auto" :type="config.type" :columns="config.columns" :data="config.data" />
  84. </template>
  85. <template v-if="config.name === 'tabs'">
  86. <CustomTabs class="content__module" :type="config.type" :tab-config="config.items" :overflow="config.overflow" />
  87. </template>
  88. <template v-if="config.name === 'blast_delta'">
  89. <BlastDelta
  90. v-if="config.pageType === 'New_fire'"
  91. class="content__moduleFire"
  92. :pos-monitor="config.data"
  93. :canvasSize="{ width: 250, height: 200 }"
  94. />
  95. <BlastDelta v-else class="content__module" :pos-monitor="config.data" :canvasSize="{ width: 250, height: 200 }" />
  96. </template>
  97. <template v-if="config.name === 'qh_curve'">
  98. <QHCurve class="content__module" :mainfan="config.data" :fan1-prop="config.config.fan1Prop" :fan2-prop="config.config.fan2Prop" />
  99. </template>
  100. <template v-if="config.name === 'ai_chat'">
  101. <AIChat class="content__module" />
  102. </template>
  103. <template v-if="config.name === 'device_alarm'">
  104. <DeviceAlarm class="content__module" :devicedata="config.data" />
  105. </template>
  106. <template v-if="config.name === 'measure_detail'">
  107. <MeasureDetail
  108. class="content__module"
  109. :show-title="false"
  110. :composite-data="config.data"
  111. :topconfig="config.config.topconfig"
  112. :btnconfig="config.config.btnconfig"
  113. />
  114. </template>
  115. <!-- <template v-if="config.key === 'fire_control'">
  116. <FIreControl class="content__module" />
  117. </template>
  118. <template v-if="config.key === 'fire_warn'">
  119. <FIreWarn class="content__module" />
  120. </template> -->
  121. </div>
  122. </div>
  123. </div>
  124. </template>
  125. <script lang="ts" setup>
  126. import { computed } from 'vue';
  127. import {
  128. CommonItem,
  129. Config,
  130. // ModuleDataBoard,
  131. // ModuleDataChart,
  132. // ModuleDataList,
  133. // ModuleDataPreset,
  134. // ModuleDataTable,
  135. } from '../../../deviceManager/configurationTable/types';
  136. import MiniBoard from './detail/MiniBoard.vue';
  137. import TimelineList from './detail/TimelineList.vue';
  138. import TimelineListNew from './detail/TimelineListNew.vue';
  139. import CustomList from './detail/CustomList.vue';
  140. import CustomGallery from './detail/CustomGallery.vue';
  141. import ComplexList from './detail/ComplexList.vue';
  142. import GalleryList from './detail/GalleryList.vue';
  143. import CustomTable from './detail/CustomTable.vue';
  144. import CustomChart from './detail/CustomChart.vue';
  145. import { clone } from 'lodash-es';
  146. import { getData, getFormattedText } from '../hooks/helper';
  147. import BlastDelta from '../../../monitorManager/deviceMonitor/components/device/modal/blastDelta.vue';
  148. import QHCurve from './preset/QHCurve.vue';
  149. import MeasureDetail from './preset/MeasureDetail.vue';
  150. import CustomTabs from './preset/CustomTabs.vue';
  151. import AIChat from '/@/components/AIChat/MiniChat.vue';
  152. import DeviceAlarm from './preset/DeviceAlarm.vue';
  153. // import FIreWarn from './preset/FIreWarn.vue';
  154. // import FIreControl from './preset/FIreControl.vue';
  155. const props = defineProps<{
  156. data: any;
  157. moduleData: Config['moduleData'];
  158. }>();
  159. const { background, layout } = props.moduleData;
  160. // 获取当原始配置带 items 项时的最终 items 配置
  161. function getItems(raw, items: CommonItem[]) {
  162. return items.map((i) => {
  163. return {
  164. ...i,
  165. label: getFormattedText(raw, i.label, i.trans),
  166. value: getFormattedText(raw, i.value, i.trans),
  167. };
  168. });
  169. }
  170. // 获取当 List 组件配置带 items 项时的最终 items 配置
  171. function getListItems(raw: any, items: CommonItem[], mapFromData?: boolean) {
  172. if (mapFromData && Array.isArray(raw)) {
  173. return raw.map((data) => {
  174. const item = items[0];
  175. return {
  176. ...item,
  177. label: getFormattedText(data, item.label, item.trans),
  178. value: getFormattedText(data, item.value, item.trans),
  179. };
  180. });
  181. }
  182. return getItems(raw, items);
  183. }
  184. /** 根据配置里的layout将配置格式化为带 key 的具体配置,例如:[{ key: 'list', value: any, ...ModuleDataList }] */
  185. const layoutConfig = computed(() => {
  186. const refData = props.data;
  187. const board = clone(props.moduleData.board) || [];
  188. const list = clone(props.moduleData.list) || [];
  189. const gallery = clone(props.moduleData.gallery) || [];
  190. const complex_list = clone(props.moduleData.complex_list) || [];
  191. const gallery_list = clone(props.moduleData.gallery_list) || [];
  192. const tabs = clone(props.moduleData.tabs) || [];
  193. const chart = clone(props.moduleData.chart) || [];
  194. const table = clone(props.moduleData.table) || [];
  195. const preset = clone(props.moduleData.preset) || [];
  196. return layout.items.reduce((arr: any[], item) => {
  197. switch (item.name) {
  198. case 'board': {
  199. const cfg = board.shift();
  200. if (!cfg) break;
  201. const data = getData(refData, cfg.readFrom, cfg.parser);
  202. arr.push({
  203. overflow: true,
  204. ...item,
  205. ...cfg,
  206. items: getItems(data, cfg.items),
  207. });
  208. break;
  209. }
  210. case 'list': {
  211. const cfg = list.shift();
  212. if (!cfg) break;
  213. const data = getData(refData, cfg.readFrom, cfg.parser);
  214. arr.push({
  215. overflow: true,
  216. ...item,
  217. ...cfg,
  218. items: getListItems(data, cfg.items, cfg.mapFromData),
  219. });
  220. break;
  221. }
  222. case 'gallery': {
  223. const cfg = gallery.shift();
  224. if (!cfg) break;
  225. const data = getData(refData, cfg.readFrom, cfg.parser);
  226. arr.push({
  227. overflow: true,
  228. ...item,
  229. ...cfg,
  230. items: getItems(data, cfg.items),
  231. });
  232. break;
  233. }
  234. case 'complex_list': {
  235. const cfg = complex_list.shift();
  236. if (!cfg) break;
  237. const data = getData(refData, cfg.readFrom, cfg.parser);
  238. if (cfg.mapFromData) {
  239. const firstListItem = cfg.items[0];
  240. arr.push({
  241. overflow: true,
  242. ...item,
  243. ...cfg,
  244. items: (data || []).map((d) => {
  245. return {
  246. title: getFormattedText(d, firstListItem.title, firstListItem.trans),
  247. contents: firstListItem.contents.map((e) => {
  248. return {
  249. ...e,
  250. label: getFormattedText(d, e.label, e.trans),
  251. value: getFormattedText(d, e.value, e.trans),
  252. };
  253. }),
  254. };
  255. }),
  256. });
  257. } else {
  258. arr.push({
  259. overflow: true,
  260. ...item,
  261. ...cfg,
  262. items: cfg.items.map((i) => {
  263. return {
  264. title: getFormattedText(data, i.title, i.trans),
  265. contents: i.contents.map((e) => {
  266. return {
  267. ...e,
  268. label: getFormattedText(data, e.label, e.trans),
  269. value: getFormattedText(data, e.value, e.trans),
  270. };
  271. }),
  272. };
  273. }),
  274. });
  275. }
  276. break;
  277. }
  278. case 'gallery_list': {
  279. const cfg = gallery_list.shift();
  280. if (!cfg) break;
  281. const data = getData(refData, cfg.readFrom, cfg.parser);
  282. arr.push({
  283. overflow: true,
  284. ...item,
  285. ...cfg,
  286. items: getItems(data, cfg.items),
  287. galleryItems: getItems(data, cfg.galleryItems),
  288. });
  289. break;
  290. }
  291. case 'tabs': {
  292. const cfg = tabs.shift();
  293. if (!cfg) break;
  294. const data = getData(refData, cfg.readFrom, cfg.parser);
  295. if (cfg.mapFromData) {
  296. const firstListItem = cfg.items[0];
  297. arr.push({
  298. overflow: true,
  299. ...item,
  300. ...cfg,
  301. items: (data || []).map((d) => {
  302. return {
  303. title: getFormattedText(d, firstListItem.title, firstListItem.trans),
  304. contents: firstListItem.contents.map((e) => {
  305. return {
  306. ...e,
  307. label: getFormattedText(d, e.label, e.trans),
  308. value: getFormattedText(d, e.value, e.trans),
  309. };
  310. }),
  311. };
  312. }),
  313. });
  314. } else {
  315. arr.push({
  316. overflow: true,
  317. ...item,
  318. ...cfg,
  319. items: cfg.items.map((i) => {
  320. return {
  321. title: getFormattedText(data, i.title, i.trans),
  322. contents: i.contents.map((e) => {
  323. return {
  324. ...e,
  325. label: getFormattedText(data, e.label, e.trans),
  326. value: getFormattedText(data, e.value, e.trans),
  327. };
  328. }),
  329. };
  330. }),
  331. });
  332. }
  333. break;
  334. }
  335. case 'chart': {
  336. const cfg = chart.shift();
  337. if (!cfg) break;
  338. const data = getData(refData, cfg.readFrom, cfg.parser);
  339. arr.push({
  340. ...item,
  341. config: cfg,
  342. data,
  343. });
  344. break;
  345. }
  346. case 'table': {
  347. const cfg = table.shift();
  348. if (!cfg) break;
  349. const data = getData(refData, cfg.readFrom, cfg.parser);
  350. arr.push({
  351. ...cfg,
  352. ...item,
  353. columns: cfg.columns,
  354. data,
  355. });
  356. break;
  357. }
  358. default: {
  359. const cfg = preset.shift();
  360. if (!cfg) break;
  361. const data = getData(refData, cfg.readFrom, cfg.parser);
  362. arr.push({
  363. ...item,
  364. data,
  365. config: cfg,
  366. });
  367. break;
  368. }
  369. }
  370. return arr;
  371. }, []);
  372. });
  373. </script>
  374. <style lang="less" scoped>
  375. @import '@/design/theme.less';
  376. .content {
  377. height: calc(100% - 30px);
  378. position: relative;
  379. // z-index: -2;
  380. display: flex;
  381. flex-direction: column;
  382. }
  383. .content__background {
  384. width: 100%;
  385. height: 100%;
  386. position: absolute;
  387. top: 0;
  388. left: 0;
  389. z-index: 0;
  390. object-fit: fill;
  391. }
  392. .image__background {
  393. width: 35%;
  394. height: 61%;
  395. left: 30%;
  396. }
  397. .content__module {
  398. // margin-top: 5px;
  399. // margin-bottom: 5px;
  400. width: 100%;
  401. height: 100%;
  402. }
  403. .content__module1 {
  404. background: url('@/assets/images/vent/homeNew/databg/4.png');
  405. background-repeat: no-repeat;
  406. background-size: 100% 100%;
  407. height: 129px;
  408. margin-top: 20%;
  409. }
  410. .content__moduleFire {
  411. width: 100%;
  412. height: 100%;
  413. margin-left: -24% !important;
  414. }
  415. .content__module_dust {
  416. background: url('@/assets/images/vent/homeNew/bottomBg.png');
  417. background-repeat: no-repeat;
  418. background-size: 100% 100%;
  419. width: 100%;
  420. height: 100%;
  421. }
  422. // .content__module:first-of-type {
  423. // margin-top: 0;
  424. // }
  425. // .content__module:last-of-type {
  426. // margin-bottom: 0;
  427. // }
  428. ::-webkit-scrollbar {
  429. width: 5px !important;
  430. }
  431. ::-webkit-scrollbar-thumb {
  432. width: 5px !important;
  433. }
  434. :deep(.zxm-select:not(.zxm-select-customize-input) .zxm-select-selector) {
  435. /* background-color: transparent; */
  436. color: #fff;
  437. }
  438. :deep(.zxm-select-arrow) {
  439. color: #fff;
  440. }
  441. :deep(.zxm-select-selection-item) {
  442. color: #fff !important;
  443. }
  444. :deep(.zxm-select-selection-placeholder) {
  445. color: #fff !important;
  446. }
  447. :deep(.dialog-overlay) {
  448. width: 100%;
  449. height: 100%;
  450. position: unset;
  451. box-shadow: unset;
  452. }
  453. ::-webkit-scrollbar {
  454. width: 5px !important;
  455. }
  456. ::-webkit-scrollbar-thumb {
  457. width: 5px !important;
  458. }
  459. </style>