content.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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. chartData: any;
  191. }>();
  192. const { background, layout } = props.moduleData;
  193. // 获取当原始配置带 items 项时的最终 items 配置
  194. function getItems(raw, items: CommonItem[]) {
  195. return items.map((i) => {
  196. return {
  197. ...i,
  198. label: getFormattedText(raw, i.label, i.trans),
  199. value: getFormattedText(raw, i.value, i.trans),
  200. };
  201. });
  202. }
  203. // 获取当 List 组件配置带 items 项时的最终 items 配置
  204. function getListItems(raw: any, items: CommonItem[], mapFromData?: boolean) {
  205. if (mapFromData && Array.isArray(raw)) {
  206. return raw.map((data) => {
  207. const item = items[0];
  208. return {
  209. ...item,
  210. label: getFormattedText(data, item.label, item.trans),
  211. value: getFormattedText(data, item.value, item.trans),
  212. };
  213. });
  214. }
  215. return getItems(raw, items);
  216. }
  217. /** 根据配置里的layout将配置格式化为带 key 的具体配置,例如:[{ key: 'list', value: any, ...ModuleDataList }] */
  218. const layoutConfig = computed(() => {
  219. const refData = props.data;
  220. const board = clone(props.moduleData.board) || [];
  221. const list = clone(props.moduleData.list) || [];
  222. const gallery = clone(props.moduleData.gallery) || [];
  223. const complex_list = clone(props.moduleData.complex_list) || [];
  224. const gallery_list = clone(props.moduleData.gallery_list) || [];
  225. const tabs = clone(props.moduleData.tabs) || [];
  226. const chart = clone(props.moduleData.chart) || [];
  227. const table = clone(props.moduleData.table) || [];
  228. const preset = clone(props.moduleData.preset) || [];
  229. const partition = clone(props.moduleData.partition) || [];
  230. const mockData = clone(props.chartData) || [];
  231. return layout.items.reduce((arr: any[], item) => {
  232. switch (item.name) {
  233. case 'board': {
  234. const cfg = board.shift();
  235. if (!cfg) break;
  236. const data = getData(refData, cfg.readFrom, cfg.parser);
  237. arr.push({
  238. overflow: true,
  239. ...item,
  240. ...cfg,
  241. items: getItems(data, cfg.items),
  242. });
  243. break;
  244. }
  245. case 'list': {
  246. const cfg = list.shift();
  247. if (!cfg) break;
  248. const data = getData(refData, cfg.readFrom, cfg.parser);
  249. arr.push({
  250. overflow: true,
  251. ...item,
  252. ...cfg,
  253. items: getListItems(data, cfg.items, cfg.mapFromData),
  254. });
  255. break;
  256. }
  257. case 'gallery': {
  258. const cfg = gallery.shift();
  259. if (!cfg) break;
  260. const data = getData(refData, cfg.readFrom, cfg.parser);
  261. arr.push({
  262. overflow: true,
  263. ...item,
  264. ...cfg,
  265. items: getItems(data, cfg.items),
  266. });
  267. break;
  268. }
  269. case 'complex_list': {
  270. const cfg = complex_list.shift();
  271. if (!cfg) break;
  272. const data = getData(refData, cfg.readFrom, cfg.parser);
  273. if (cfg.mapFromData) {
  274. const firstListItem = cfg.items[0];
  275. arr.push({
  276. overflow: true,
  277. ...item,
  278. ...cfg,
  279. items: (data || []).map((d) => {
  280. return {
  281. title: getFormattedText(d, firstListItem.title, firstListItem.trans),
  282. contents: firstListItem.contents.map((e) => {
  283. return {
  284. ...e,
  285. label: getFormattedText(d, e.label, e.trans),
  286. value: getFormattedText(d, e.value, e.trans),
  287. };
  288. }),
  289. };
  290. }),
  291. });
  292. } else {
  293. arr.push({
  294. overflow: true,
  295. ...item,
  296. ...cfg,
  297. items: cfg.items.map((i) => {
  298. return {
  299. title: getFormattedText(data, i.title, i.trans),
  300. contents: i.contents.map((e) => {
  301. return {
  302. ...e,
  303. label: getFormattedText(data, e.label, e.trans),
  304. value: getFormattedText(data, e.value, e.trans),
  305. };
  306. }),
  307. };
  308. }),
  309. });
  310. }
  311. break;
  312. }
  313. case 'gallery_list': {
  314. const cfg = gallery_list.shift();
  315. if (!cfg) break;
  316. const data = getData(refData, cfg.readFrom, cfg.parser);
  317. arr.push({
  318. overflow: true,
  319. ...item,
  320. ...cfg,
  321. items: getItems(data, cfg.items),
  322. galleryItems: getItems(data, cfg.galleryItems),
  323. });
  324. break;
  325. }
  326. case 'tabs': {
  327. const cfg = tabs.shift();
  328. if (!cfg) break;
  329. const data = getData(refData, cfg.readFrom, cfg.parser);
  330. if (cfg.mapFromData) {
  331. const firstListItem = cfg.items[0];
  332. arr.push({
  333. overflow: true,
  334. ...item,
  335. ...cfg,
  336. items: (data || []).map((d) => {
  337. return {
  338. title: getFormattedText(d, firstListItem.title, firstListItem.trans),
  339. contents: firstListItem.contents.map((e) => {
  340. return {
  341. ...e,
  342. label: getFormattedText(d, e.label, e.trans),
  343. value: getFormattedText(d, e.value, e.trans),
  344. };
  345. }),
  346. };
  347. }),
  348. });
  349. } else {
  350. arr.push({
  351. overflow: true,
  352. ...item,
  353. ...cfg,
  354. items: cfg.items.map((i) => {
  355. return {
  356. title: getFormattedText(data, i.title, i.trans),
  357. contents: i.contents.map((e) => {
  358. return {
  359. ...e,
  360. label: getFormattedText(data, e.label, e.trans),
  361. value: getFormattedText(data, e.value, e.trans),
  362. };
  363. }),
  364. };
  365. }),
  366. });
  367. }
  368. break;
  369. }
  370. case 'chart': {
  371. const cfg = chart.shift();
  372. if (cfg?.type == 'scatter') {
  373. if (!cfg) break;
  374. const data = getData(mockData, cfg.readFrom, cfg.parser);
  375. arr.push({
  376. ...item,
  377. config: cfg,
  378. data,
  379. });
  380. break;
  381. } else {
  382. if (!cfg) break;
  383. const data = getData(refData, cfg.readFrom, cfg.parser);
  384. arr.push({
  385. ...item,
  386. config: cfg,
  387. data,
  388. });
  389. break;
  390. }
  391. }
  392. case 'table': {
  393. const cfg = table.shift();
  394. if (!cfg) break;
  395. const data = getData(refData, cfg.readFrom, cfg.parser);
  396. arr.push({
  397. ...cfg,
  398. ...item,
  399. columns: cfg.columns,
  400. data,
  401. });
  402. break;
  403. }
  404. case 'partition': {
  405. const cfg = partition.shift();
  406. if (!cfg) break;
  407. const data = getData(refData, cfg.readFrom, cfg.parser);
  408. arr.push({
  409. overflow: true,
  410. ...item,
  411. data,
  412. ...cfg,
  413. });
  414. break;
  415. }
  416. default: {
  417. const cfg = preset.shift();
  418. if (!cfg) break;
  419. const data = getData(refData, cfg.readFrom, cfg.parser);
  420. arr.push({
  421. ...item,
  422. data,
  423. config: cfg,
  424. });
  425. break;
  426. }
  427. }
  428. // console.log(arr,'arr---')
  429. return arr;
  430. }, []);
  431. });
  432. </script>
  433. <style lang="less" scoped>
  434. @import '@/design/theme.less';
  435. .content {
  436. height: calc(100% - 30px);
  437. position: relative;
  438. // z-index: -2;
  439. display: flex;
  440. flex-direction: column;
  441. overflow-y: auto; // 这里会导致样式无故添加滚动条
  442. overflow-x: hidden;
  443. }
  444. .content__background {
  445. width: 100%;
  446. height: 100%;
  447. position: absolute;
  448. top: 0;
  449. left: 0;
  450. z-index: 0;
  451. object-fit: fill;
  452. }
  453. .image__background {
  454. width: 35%;
  455. height: 61%;
  456. left: 30%;
  457. }
  458. .content__module {
  459. // margin-top: 5px;
  460. // margin-bottom: 5px;
  461. width: 100%;
  462. height: 100%;
  463. }
  464. .content__module1 {
  465. background: url('@/assets/images/vent/homeNew/databg/4.png');
  466. background-repeat: no-repeat;
  467. background-size: 100% 100%;
  468. height: 129px;
  469. margin-top: 20%;
  470. }
  471. .content__moduleFire {
  472. width: 100%;
  473. height: 100%;
  474. margin-left: -24% !important;
  475. }
  476. .content__module_dust {
  477. background: url('@/assets/images/vent/homeNew/bottomBg.png');
  478. background-repeat: no-repeat;
  479. background-size: 100% 100%;
  480. width: 100%;
  481. height: 100%;
  482. }
  483. // .content__module:first-of-type {
  484. // margin-top: 0;
  485. // }
  486. // .content__module:last-of-type {
  487. // margin-bottom: 0;
  488. // }
  489. ::-webkit-scrollbar {
  490. width: 5px !important;
  491. }
  492. ::-webkit-scrollbar-thumb {
  493. width: 5px !important;
  494. }
  495. :deep(.zxm-select:not(.zxm-select-customize-input) .zxm-select-selector) {
  496. /* background-color: transparent; */
  497. color: #fff;
  498. }
  499. :deep(.zxm-select-arrow) {
  500. color: #fff;
  501. }
  502. :deep(.zxm-select-selection-item) {
  503. color: #fff !important;
  504. }
  505. :deep(.zxm-select-selection-placeholder) {
  506. color: #fff !important;
  507. }
  508. :deep(.dialog-overlay) {
  509. width: 100%;
  510. height: 100%;
  511. position: unset;
  512. box-shadow: unset;
  513. }
  514. ::-webkit-scrollbar {
  515. width: 5px !important;
  516. }
  517. ::-webkit-scrollbar-thumb {
  518. width: 5px !important;
  519. }
  520. </style>