content-New.vue 17 KB

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