content.vue 18 KB

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