content.vue 18 KB

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