content.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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' && background.isBoard"
  9. class="content__background"
  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. <video
  21. v-if="background.show && background.type === 'video' && !background.isBoard"
  22. class="content__background_1"
  23. width="100%"
  24. autoplay
  25. loop
  26. muted
  27. disablepictureinpicture
  28. playsinline
  29. >
  30. <source :src="background.link" />
  31. Not Supportted Link Or Browser
  32. </video>
  33. <div class="flex w-full h-full" :style="{ flexDirection: layout.direction }">
  34. <div v-for="config in layoutConfig" :key="config.name" :style="{ flexBasis: config.basis, overflow: config.overflow ? 'auto' : 'none' }">
  35. <!-- 通常列表部分 -->
  36. <template v-if="config.name === 'list'">
  37. <CustomList class="content__module" :type="config.type" :list-config="config.items" />
  38. </template>
  39. <!-- 复杂列表部分 -->
  40. <template v-if="config.name === 'gallery_list'">
  41. <GalleryList class="content__module" :type="config.type" :list-config="config.items" :gallery-config="config.galleryItems" />
  42. </template>
  43. <!-- 复杂列表部分 -->
  44. <template v-if="config.name === 'complex_list'">
  45. <ComplexList class="content__module" :type="config.type" :list-config="config.items" />
  46. </template>
  47. <template v-if="config.name === 'complex_list1'">
  48. <ComplexList1 class="content__module" :type="config.type" :list-config="config.items" />
  49. </template>
  50. <!-- 表格部分,这部分通常是占一整个模块的 -->
  51. <template v-if="config.name === 'table'">
  52. <CustomTable
  53. class="content__module text-center overflow-auto"
  54. :type="config.type"
  55. :columns="config.columns"
  56. :auto-scroll="config.autoScroll"
  57. :data="config.data"
  58. />
  59. </template>
  60. </div>
  61. </div>
  62. </div>
  63. </template>
  64. <script lang="ts" setup>
  65. import { computed } from 'vue';
  66. import { CommonItem, Config } from '../../../deviceManager/configurationTable/types';
  67. import CustomList from './detail/ListOne.vue';
  68. import ComplexList from './detail/ListTwo.vue';
  69. import ComplexList1 from './detail/ListThree.vue';
  70. // import GalleryList from './detail/ListThree.vue';
  71. import CustomTable from './detail/CustomTable.vue';
  72. import { clone } from 'lodash-es';
  73. import { getData, getFormattedText } from '../../../home/configurable/hooks/helper';
  74. // import FIreWarn from './preset/FIreWarn.vue';
  75. // import FIreControl from './preset/FIreControl.vue';
  76. const props = defineProps<{
  77. data: any;
  78. moduleData: Config['moduleData'];
  79. chartData: any;
  80. }>();
  81. const { background, layout } = props.moduleData;
  82. // 获取当原始配置带 items 项时的最终 items 配置
  83. function getItems(raw, items: CommonItem[]) {
  84. return items.map((i) => {
  85. return {
  86. ...i,
  87. label: getFormattedText(raw, i.label, i.trans),
  88. value: getFormattedText(raw, i.value, i.trans),
  89. };
  90. });
  91. }
  92. // 获取当 List 组件配置带 items 项时的最终 items 配置
  93. function getListItems(raw: any, items: CommonItem[], mapFromData?: boolean) {
  94. if (mapFromData && Array.isArray(raw)) {
  95. return raw.map((data) => {
  96. const item = items[0];
  97. return {
  98. ...item,
  99. label: getFormattedText(data, item.label, item.trans),
  100. value: getFormattedText(data, item.value, item.trans),
  101. };
  102. });
  103. }
  104. return getItems(raw, items);
  105. }
  106. /** 根据配置里的layout将配置格式化为带 key 的具体配置,例如:[{ key: 'list', value: any, ...ModuleDataList }] */
  107. const layoutConfig = computed(() => {
  108. const refData = props.data;
  109. const list = clone(props.moduleData.list) || [];
  110. const complex_list = clone(props.moduleData.complex_list) || [];
  111. const complex_list1 = clone(props.moduleData.complex_list1) || [];
  112. const table = clone(props.moduleData.table) || [];
  113. const mockData = clone(props.chartData) || [];
  114. return layout.items.reduce((arr: any[], item) => {
  115. switch (item.name) {
  116. case 'list': {
  117. const cfg = list.shift();
  118. if (!cfg) break;
  119. const data = getData(refData, cfg.readFrom, cfg.parser);
  120. arr.push({
  121. overflow: true,
  122. ...item,
  123. ...cfg,
  124. items: getListItems(data, cfg.items, cfg.mapFromData),
  125. });
  126. break;
  127. }
  128. case 'complex_list': {
  129. const cfg = complex_list.shift();
  130. if (!cfg) break;
  131. const data = getData(refData, cfg.readFrom, cfg.parser);
  132. if (cfg.mapFromData) {
  133. const firstListItem = cfg.items[0];
  134. arr.push({
  135. overflow: true,
  136. ...item,
  137. ...cfg,
  138. items: (data || []).map((d) => {
  139. return {
  140. title: getFormattedText(d, firstListItem.title, firstListItem.trans),
  141. contents: firstListItem.contents.map((e) => {
  142. return {
  143. ...e,
  144. label: getFormattedText(d, e.label, e.trans),
  145. value: getFormattedText(d, e.value, e.trans),
  146. };
  147. }),
  148. };
  149. }),
  150. });
  151. } else {
  152. arr.push({
  153. overflow: true,
  154. ...item,
  155. ...cfg,
  156. items: cfg.items.map((i) => {
  157. return {
  158. title: getFormattedText(data, i.title, i.trans),
  159. contents: i.contents.map((e) => {
  160. return {
  161. ...e,
  162. label: getFormattedText(data, e.label, e.trans),
  163. value: getFormattedText(data, e.value, e.trans),
  164. };
  165. }),
  166. };
  167. }),
  168. });
  169. }
  170. break;
  171. }
  172. case 'gallery_list': {
  173. const cfg = gallery_list.shift();
  174. if (!cfg) break;
  175. const data = getData(refData, cfg.readFrom, cfg.parser);
  176. arr.push({
  177. overflow: true,
  178. ...item,
  179. ...cfg,
  180. items: getItems(data, cfg.items),
  181. galleryItems: getItems(data, cfg.galleryItems),
  182. });
  183. break;
  184. }
  185. case 'complex_list1': {
  186. const cfg = complex_list1.shift();
  187. if (!cfg) break;
  188. const data = getData(refData, cfg.readFrom, cfg.parser);
  189. if (cfg.mapFromData) {
  190. const firstListItem = cfg.items[0];
  191. arr.push({
  192. overflow: true,
  193. ...item,
  194. ...cfg,
  195. items: (data || []).map((d) => {
  196. return {
  197. title: getFormattedText(d, firstListItem.title, firstListItem.trans),
  198. contents: firstListItem.contents.map((e) => {
  199. return {
  200. ...e,
  201. label: getFormattedText(d, e.label, e.trans),
  202. value: getFormattedText(d, e.value, e.trans),
  203. };
  204. }),
  205. };
  206. }),
  207. });
  208. } else {
  209. arr.push({
  210. overflow: true,
  211. ...item,
  212. ...cfg,
  213. items: cfg.items.map((i) => {
  214. return {
  215. title: getFormattedText(data, i.title, i.trans),
  216. contents: i.contents.map((e) => {
  217. return {
  218. ...e,
  219. label: getFormattedText(data, e.label, e.trans),
  220. value: getFormattedText(data, e.value, e.trans),
  221. };
  222. }),
  223. };
  224. }),
  225. });
  226. }
  227. break;
  228. }
  229. case 'table': {
  230. const cfg = table.shift();
  231. if (!cfg) break;
  232. const data = getData(refData, cfg.readFrom, cfg.parser);
  233. arr.push({
  234. ...cfg,
  235. ...item,
  236. columns: cfg.columns,
  237. data,
  238. });
  239. console.log(arr, '11111111111');
  240. break;
  241. }
  242. default: {
  243. const cfg = preset.shift();
  244. if (!cfg) break;
  245. const data = getData(refData, cfg.readFrom, cfg.parser);
  246. arr.push({
  247. ...item,
  248. data,
  249. config: cfg,
  250. });
  251. break;
  252. }
  253. }
  254. // console.log(arr,'arr---')
  255. return arr;
  256. }, []);
  257. });
  258. </script>
  259. <style lang="less" scoped>
  260. @import '@/design/theme.less';
  261. .content {
  262. height: calc(100% - 30px);
  263. position: relative;
  264. // z-index: -2;
  265. display: flex;
  266. flex-direction: column;
  267. overflow-y: auto; // 这里会导致样式无故添加滚动条
  268. overflow-x: hidden;
  269. }
  270. .content__background {
  271. width: 100%;
  272. // height: 100%;
  273. height: calc(100% - 65px);
  274. position: absolute;
  275. top: 65px;
  276. left: 0;
  277. z-index: 0;
  278. object-fit: fill;
  279. padding: 5px;
  280. box-sizing: border-box;
  281. }
  282. .content__background_1 {
  283. width: 100%;
  284. height: 100%;
  285. position: absolute;
  286. top: 0px;
  287. left: 0;
  288. z-index: 0;
  289. object-fit: fill;
  290. }
  291. .image__background {
  292. width: 35%;
  293. height: 61%;
  294. left: 30%;
  295. }
  296. .content__module {
  297. // margin-top: 5px;
  298. // margin-bottom: 5px;
  299. width: 100%;
  300. height: 100%;
  301. }
  302. .content__module1 {
  303. background: url('@/assets/images/vent/homeNew/databg/4.png');
  304. background-repeat: no-repeat;
  305. background-size: 100% 100%;
  306. height: 129px;
  307. margin-top: 20%;
  308. }
  309. .content__moduleFire {
  310. width: 100%;
  311. height: 100%;
  312. margin-left: -24% !important;
  313. }
  314. .content__module_dust {
  315. background: url('@/assets/images/vent/homeNew/bottomBg.png');
  316. background-repeat: no-repeat;
  317. background-size: 100% 100%;
  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>