content-warn.vue 13 KB

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