content.vue 12 KB

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