content.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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-if="config.type === 'timelineNew'">
  45. <TimelineListNew class="content__module" :list-config="config.items" />
  46. </template>
  47. <template v-else>
  48. <CustomList class="content__module" :type="config.type" :list-config="config.items" />
  49. </template>
  50. </template>
  51. <!-- 画廊部分 -->
  52. <template v-if="config.name === 'gallery'">
  53. <CustomGallery class="content__module" :type="config.type" :gallery-config="config.items" />
  54. </template>
  55. <!-- 复杂列表部分 -->
  56. <template v-if="config.name === 'gallery_list'">
  57. <GalleryList class="content__module" :type="config.type" :list-config="config.items" :gallery-config="config.galleryItems" />
  58. </template>
  59. <!-- 复杂列表部分 -->
  60. <template v-if="config.name === 'complex_list'">
  61. <ComplexList class="content__module" :type="config.type" :list-config="config.items" />
  62. </template>
  63. <!-- 表格部分,这部分通常是占一整个模块的 -->
  64. <template v-if="config.name === 'table'">
  65. <CustomTable class="content__module text-center overflow-auto" :type="config.type" :columns="config.columns" :data="config.data" />
  66. </template>
  67. <template v-if="config.name === 'blast_delta'">
  68. <BlastDelta class="content__module" :pos-monitor="config.data" :canvasSize="{ width: 250, height: 200 }" />
  69. </template>
  70. <template v-if="config.name === 'qh_curve'">
  71. <QHCurve class="content__module" :mainfan="config.data" :fan1-prop="config.config.fan1Prop" :fan2-prop="config.config.fan2Prop" />
  72. </template>
  73. <template v-if="config.name === 'ai_chat'">
  74. <AIChat class="content__module" />
  75. </template>
  76. <template v-if="config.name === 'device_alarm'">
  77. <DeviceAlarm class="content__module" :devicedata="config.data" />
  78. </template>
  79. <template v-if="config.name === 'measure_detail'">
  80. <MeasureDetail
  81. class="content__module"
  82. :show-title="false"
  83. :composite-data="config.data"
  84. :topconfig="config.config.topconfig"
  85. :btnconfig="config.config.btnconfig"
  86. />
  87. </template>
  88. <!-- <template v-if="config.key === 'fire_control'">
  89. <FIreControl class="content__module" />
  90. </template>
  91. <template v-if="config.key === 'fire_warn'">
  92. <FIreWarn class="content__module" />
  93. </template> -->
  94. </div>
  95. </div>
  96. </div>
  97. </template>
  98. <script lang="ts" setup>
  99. import { computed } from 'vue';
  100. import {
  101. CommonItem,
  102. Config,
  103. // ModuleDataBoard,
  104. // ModuleDataChart,
  105. // ModuleDataList,
  106. // ModuleDataPreset,
  107. // ModuleDataTable,
  108. } from '../../../deviceManager/configurationTable/types';
  109. import MiniBoard from './detail/MiniBoard.vue';
  110. import TimelineList from './detail/TimelineList.vue';
  111. import TimelineListNew from './detail/TimelineListNew.vue';
  112. import CustomList from './detail/CustomList.vue';
  113. import CustomGallery from './detail/CustomGallery.vue';
  114. import ComplexList from './detail/ComplexList.vue';
  115. import GalleryList from './detail/GalleryList.vue';
  116. import CustomTable from './detail/CustomTable.vue';
  117. import CustomChart from './detail/CustomChart.vue';
  118. import { clone } from 'lodash-es';
  119. import { getData, getFormattedText } from '../hooks/helper';
  120. import BlastDelta from '../../../monitorManager/deviceMonitor/components/device/modal/blastDelta.vue';
  121. import QHCurve from './preset/QHCurve.vue';
  122. import MeasureDetail from './preset/MeasureDetail.vue';
  123. import AIChat from '/@/components/AIChat/MiniChat.vue';
  124. import DeviceAlarm from './preset/DeviceAlarm.vue';
  125. // import FIreWarn from './preset/FIreWarn.vue';
  126. // import FIreControl from './preset/FIreControl.vue';
  127. const props = defineProps<{
  128. data: any;
  129. moduleData: Config['moduleData'];
  130. }>();
  131. const { background, layout } = props.moduleData;
  132. // 获取当原始配置带 items 项时的最终 items 配置
  133. function getItems(raw, items: CommonItem[]) {
  134. return items.map((i) => {
  135. return {
  136. ...i,
  137. label: getFormattedText(raw, i.label, i.trans),
  138. value: getFormattedText(raw, i.value, i.trans),
  139. };
  140. });
  141. }
  142. // 获取当 List 组件配置带 items 项时的最终 items 配置
  143. function getListItems(raw: any, items: CommonItem[], mapFromData?: boolean) {
  144. if (mapFromData && Array.isArray(raw)) {
  145. return raw.map((data) => {
  146. const item = items[0];
  147. return {
  148. ...item,
  149. label: getFormattedText(data, item.label, item.trans),
  150. value: getFormattedText(data, item.value, item.trans),
  151. };
  152. });
  153. }
  154. return getItems(raw, items);
  155. }
  156. /** 根据配置里的layout将配置格式化为带 key 的具体配置,例如:[{ key: 'list', value: any, ...ModuleDataList }] */
  157. const layoutConfig = computed(() => {
  158. const refData = props.data;
  159. const board = clone(props.moduleData.board) || [];
  160. const list = clone(props.moduleData.list) || [];
  161. const gallery = clone(props.moduleData.gallery) || [];
  162. const complex_list = clone(props.moduleData.complex_list) || [];
  163. const gallery_list = clone(props.moduleData.gallery_list) || [];
  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 'chart': {
  263. const cfg = chart.shift();
  264. if (!cfg) break;
  265. const data = getData(refData, cfg.readFrom, cfg.parser);
  266. arr.push({
  267. ...item,
  268. config: cfg,
  269. data,
  270. });
  271. break;
  272. }
  273. case 'table': {
  274. const cfg = table.shift();
  275. if (!cfg) break;
  276. const data = getData(refData, cfg.readFrom, cfg.parser);
  277. arr.push({
  278. ...cfg,
  279. ...item,
  280. columns: cfg.columns,
  281. data,
  282. });
  283. break;
  284. }
  285. default: {
  286. const cfg = preset.shift();
  287. if (!cfg) break;
  288. const data = getData(refData, cfg.readFrom, cfg.parser);
  289. arr.push({
  290. ...item,
  291. data,
  292. config: cfg,
  293. });
  294. break;
  295. }
  296. }
  297. return arr;
  298. }, []);
  299. });
  300. </script>
  301. <style lang="less" scoped>
  302. @import '@/design/theme.less';
  303. .content {
  304. height: calc(100% - 30px);
  305. position: relative;
  306. // z-index: -2;
  307. display: flex;
  308. flex-direction: column;
  309. }
  310. .content__background {
  311. width: 100%;
  312. height: 100%;
  313. position: absolute;
  314. top: 0;
  315. left: 0;
  316. z-index: 0;
  317. object-fit: fill;
  318. }
  319. .content__module {
  320. // margin-top: 5px;
  321. // margin-bottom: 5px;
  322. width: 100%;
  323. height: 100%;
  324. }
  325. // .content__module:first-of-type {
  326. // margin-top: 0;
  327. // }
  328. // .content__module:last-of-type {
  329. // margin-bottom: 0;
  330. // }
  331. ::-webkit-scrollbar {
  332. width: 5px !important;
  333. }
  334. ::-webkit-scrollbar-thumb {
  335. width: 5px !important;
  336. }
  337. :deep(.zxm-select:not(.zxm-select-customize-input) .zxm-select-selector) {
  338. /* background-color: transparent; */
  339. color: #fff;
  340. }
  341. :deep(.zxm-select-arrow) {
  342. color: #fff;
  343. }
  344. :deep(.zxm-select-selection-item) {
  345. color: #fff !important;
  346. }
  347. :deep(.zxm-select-selection-placeholder) {
  348. color: #fff !important;
  349. }
  350. :deep(.dialog-overlay) {
  351. width: 100%;
  352. height: 100%;
  353. position: unset;
  354. box-shadow: unset;
  355. }
  356. ::-webkit-scrollbar {
  357. width: 5px !important;
  358. }
  359. ::-webkit-scrollbar-thumb {
  360. width: 5px !important;
  361. }
  362. </style>