content.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <!-- Header部分 -->
  4. <div v-if="headerConfig.show" class="w-100% flex content__header">
  5. <!-- 选择下拉框,自动填充剩余空间,这种实现是因为 Select 不支持 suffix -->
  6. <Dropdown
  7. v-if="headerConfig.showSelector"
  8. class="flex-grow-1 content__header_left"
  9. :trigger="['click']"
  10. :bordered="false"
  11. @open-change="headerVisible = $event"
  12. >
  13. <div class="w-100% flex flex-items-center" @click.prevent>
  14. <SwapOutlined class="w-30px" />
  15. <div class="flex-grow-1">
  16. {{ selectedDeviceLabel }}
  17. </div>
  18. <CaretUpOutlined class="w-30px" v-if="headerVisible" />
  19. <CaretDownOutlined class="w-30px" v-else />
  20. </div>
  21. <template #overlay>
  22. <Menu :selected-keys="[selectedDeviceID]" @click="headerSelectHandler">
  23. <MenuItem v-for="item in options" :key="item.value" :title="item.label">
  24. {{ item.label }}
  25. </MenuItem>
  26. </Menu>
  27. </template>
  28. </Dropdown>
  29. <template v-if="headerConfig.showSlot">
  30. <div class="flex flex-items-center flex-grow-1 content__header_right">
  31. <SwapOutlined class="w-30px" />
  32. <div class="flex-grow-1">
  33. {{ selectedDeviceSlot }}
  34. </div>
  35. </div>
  36. </template>
  37. </div>
  38. <!-- 主体内容部分 -->
  39. <div class="content" :class="{ content_without_header: !headerConfig.show }">
  40. <!-- 背景 -->
  41. <img v-if="background.show && background.type === 'image'" class="content__background" :src="background.link" />
  42. <video
  43. v-if="background.show && background.type === 'video'"
  44. class="content__background content__background_video"
  45. width="100%"
  46. autoplay
  47. loop
  48. muted
  49. >
  50. <source :src="background.link" />
  51. Not Supportted Link Or Browser
  52. </video>
  53. <template v-for="config in layoutConfig" :key="config.key">
  54. <!-- 告示板部分 -->
  55. <div v-if="config.key === 'board'" class="content__module flex flex-justify-around pt-10px pb-10px">
  56. <MiniBoard
  57. v-for="item in config.items"
  58. :key="item.prop"
  59. :label="item.label"
  60. :value="item.value"
  61. :type="config.type"
  62. :layout="config.layout"
  63. />
  64. </div>
  65. <!-- 图表部分,这部分通常需要填充,有告示板、Header等内容需要填充父级 -->
  66. <template v-if="config.key === 'chart'">
  67. <CustomChart class="content__module flex-grow" :chart-config="config.config" :chart-data="config.data" />
  68. </template>
  69. <!-- 通常列表部分 -->
  70. <template v-if="config.key === 'list'">
  71. <template v-if="config.type === 'timeline'">
  72. <TimelineList class="content__module" :list-config="config.items" />
  73. </template>
  74. <template v-else>
  75. <CustomList class="content__module" :type="config.type" :list-config="config.items" />
  76. </template>
  77. </template>
  78. <!-- 画廊部分 -->
  79. <template v-if="config.key === 'gallery'">
  80. <CustomGallery class="content__module" :type="config.type" :gallery-config="config.items" />
  81. </template>
  82. <!-- 复杂列表部分 -->
  83. <template v-if="config.key === 'complex_list'">
  84. <ComplexList class="content__module" :type="config.type" :list-config="config.items" :gallery-config="config.galleryItems" />
  85. </template>
  86. <!-- 表格部分,这部分通常是占一整个模块的 -->
  87. <template v-if="config.key === 'table'">
  88. <CommonTable
  89. v-if="config.type === 'A'"
  90. :columns="config.columns"
  91. :data="config.data"
  92. class="content__module text-center flex-grow overflow-auto"
  93. />
  94. <CustomTable
  95. v-else
  96. :type="config.type"
  97. :columns="config.columns"
  98. :data="config.data"
  99. class="content__module text-center flex-grow overflow-auto"
  100. />
  101. </template>
  102. <template v-if="config.key === 'blast_delta'">
  103. <BlastDelta class="content__module" :pos-monitor="blastDeltaData" :canvas-size="{ width: 250, height: 137 }" />
  104. </template>
  105. <template v-if="config.key === 'fire_control'">
  106. <FIreControl class="content__module" />
  107. </template>
  108. <template v-if="config.key === 'fire_warn'">
  109. <FIreWarn class="content__module" />
  110. </template>
  111. </template>
  112. </div>
  113. </template>
  114. <script lang="ts" setup>
  115. import { computed, onMounted, ref } from 'vue';
  116. import {
  117. Config,
  118. // ModuleDataBoard,
  119. // ModuleDataChart,
  120. // ModuleDataList,
  121. // ModuleDataPreset,
  122. // ModuleDataTable,
  123. } from '../../../deviceManager/configurationTable/types';
  124. import { useInitDevices } from '../hooks/useInit';
  125. import { MenuItem, Menu, Dropdown } from 'ant-design-vue';
  126. import { SwapOutlined, CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons-vue';
  127. import MiniBoard from './MiniBoard.vue';
  128. import TimelineList from './TimelineList.vue';
  129. import CustomList from './CustomList.vue';
  130. import CustomGallery from './CustomGallery.vue';
  131. import ComplexList from './ComplexList.vue';
  132. import CustomTable from './CustomTable.vue';
  133. import { getFormattedText } from '../../../deviceManager/configurationTable/adapters';
  134. import CustomChart from './CustomChart.vue';
  135. import { get, clone } from 'lodash-es';
  136. import CommonTable from '../../billboard/components/CommonTable.vue';
  137. import BlastDelta from '../../../monitorManager/deviceMonitor/components/device/modal/blastDelta.vue';
  138. import FIreWarn from './FIreWarn.vue';
  139. import FIreControl from './FIreControl.vue';
  140. import { posMonitorData } from '../configurable.data';
  141. const props = defineProps<{
  142. deviceType: Config['deviceType'];
  143. moduleData: Config['moduleData'];
  144. showStyle: Config['showStyle'];
  145. }>();
  146. const { header: headerConfig, background, layout, mock } = props.moduleData;
  147. // 额外的 header 相关的变量
  148. const headerVisible = ref(false);
  149. function headerSelectHandler({ key }) {
  150. selectedDeviceID.value = key;
  151. }
  152. const blastDeltaData = ref();
  153. const { selectedDeviceID, selectedDevice, selectedDeviceSlot, selectedDeviceLabel, options, fetchDevices } = useInitDevices(
  154. props.deviceType,
  155. headerConfig
  156. );
  157. /** 根据配置里的layout将配置格式化为带 key 的具体配置,例如:[{ key: 'list', value: any, ...ModuleDataList }] */
  158. const layoutConfig = computed(() => {
  159. const refData = selectedDevice.value;
  160. const board = clone(props.moduleData.board);
  161. const list = clone(props.moduleData.list);
  162. const gallery = clone(props.moduleData.gallery);
  163. const complex_list = clone(props.moduleData.complex_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.reduce((arr: any[], key) => {
  168. switch (key) {
  169. case 'board': {
  170. const cfg = board.shift();
  171. if (!cfg) break;
  172. const data = mock || cfg.readFrom ? get(refData, cfg.readFrom) : refData;
  173. arr.push({
  174. ...cfg,
  175. key,
  176. items: cfg.items.map((i) => {
  177. return {
  178. ...i,
  179. label: getFormattedText(data, i.label),
  180. value: getFormattedText(data, i.value),
  181. };
  182. }),
  183. });
  184. break;
  185. }
  186. case 'list': {
  187. const cfg = list.shift();
  188. if (!cfg) break;
  189. const data = mock || cfg.readFrom ? get(refData, cfg.readFrom) : refData;
  190. arr.push({
  191. ...cfg,
  192. key,
  193. items: cfg.items.map((i) => {
  194. return {
  195. ...i,
  196. label: getFormattedText(data, i.label),
  197. value: getFormattedText(data, i.value),
  198. };
  199. }),
  200. });
  201. break;
  202. }
  203. case 'gallery': {
  204. const cfg = gallery.shift();
  205. if (!cfg) break;
  206. const data = mock || cfg.readFrom ? get(refData, cfg.readFrom) : refData;
  207. arr.push({
  208. ...cfg,
  209. key,
  210. items: cfg.items.map((i) => {
  211. return {
  212. ...i,
  213. label: getFormattedText(data, i.label),
  214. value: getFormattedText(data, i.value),
  215. };
  216. }),
  217. });
  218. break;
  219. }
  220. case 'complex_list': {
  221. const cfg = complex_list.shift();
  222. if (!cfg) break;
  223. const data = mock || cfg.readFrom ? get(refData, cfg.readFrom) : refData;
  224. arr.push({
  225. ...cfg,
  226. key,
  227. items: cfg.items.map((i) => {
  228. return {
  229. ...i,
  230. label: getFormattedText(data, i.label),
  231. value: getFormattedText(data, i.value),
  232. };
  233. }),
  234. galleryItems: cfg.galleryItems.map((i) => {
  235. return {
  236. ...i,
  237. label: getFormattedText(data, i.label),
  238. value: getFormattedText(data, i.value),
  239. };
  240. }),
  241. });
  242. break;
  243. }
  244. case 'chart': {
  245. const cfg = chart.shift();
  246. if (!cfg) break;
  247. const data = mock || cfg.readFrom ? get(refData, cfg.readFrom) : refData;
  248. arr.push({
  249. key,
  250. config: cfg,
  251. data: get(data, cfg.readFrom, []),
  252. });
  253. break;
  254. }
  255. case 'table': {
  256. const cfg = table.shift();
  257. if (!cfg) break;
  258. const data = mock || cfg.readFrom ? get(refData, cfg.readFrom) : refData;
  259. arr.push({
  260. ...cfg,
  261. key,
  262. columns: cfg.columns,
  263. data: get(data, cfg.readFrom, []),
  264. });
  265. break;
  266. }
  267. default: {
  268. const cfg = preset.shift();
  269. if (!cfg) break;
  270. const data = mock || cfg.readFrom ? get(refData, cfg.readFrom) : refData;
  271. arr.push({
  272. key,
  273. data,
  274. config: cfg,
  275. });
  276. break;
  277. }
  278. }
  279. return arr;
  280. }, []);
  281. });
  282. onMounted(() => {
  283. blastDeltaData.value = posMonitorData;
  284. fetchDevices();
  285. });
  286. </script>
  287. <style lang="less" scoped>
  288. @import '@/design/vent/color.less';
  289. /* Header 相关的样式 */
  290. .content__header {
  291. height: 30px;
  292. background-image: linear-gradient(90deg, #3df6ff44, transparent 20%, transparent 80%, #3df6ff44);
  293. }
  294. .content__header_left {
  295. border-left: 3px solid;
  296. border-right: 3px solid;
  297. border-image-source: linear-gradient(to top, #185f7188, #3df6ff, #185f7188);
  298. border-image-slice: 1;
  299. }
  300. .content__header_right {
  301. border-left: 3px solid;
  302. border-right: 3px solid;
  303. border-image-source: linear-gradient(to top, #185f7188, #3df6ff, #185f7188);
  304. border-image-slice: 1;
  305. min-width: 160px;
  306. }
  307. .content {
  308. height: calc(100% - 30px);
  309. position: relative;
  310. // z-index: -2;
  311. display: flex;
  312. flex-direction: column;
  313. }
  314. .content_without_header {
  315. height: 100%;
  316. }
  317. .content__background {
  318. width: 100%;
  319. height: 100%;
  320. position: absolute;
  321. top: 0;
  322. left: 0;
  323. z-index: -1;
  324. object-fit: fill;
  325. }
  326. .content__module {
  327. margin-top: 5px;
  328. margin-bottom: 5px;
  329. }
  330. // .content__module:first-of-type {
  331. // margin-top: 0;
  332. // }
  333. // .content__module:last-of-type {
  334. // margin-bottom: 0;
  335. // }
  336. ::v-deep .zxm-select:not(.zxm-select-customize-input) .zxm-select-selector {
  337. /* background-color: transparent; */
  338. color: #fff;
  339. }
  340. ::v-deep .zxm-select-arrow {
  341. color: #fff;
  342. }
  343. ::v-deep .zxm-select-selection-item {
  344. color: #fff !important;
  345. }
  346. ::v-deep .zxm-select-selection-placeholder {
  347. color: #fff !important;
  348. }
  349. </style>