HistoricalDetailsModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. <template>
  2. <BasicModal
  3. v-bind="$attrs"
  4. title="密闭监测详情"
  5. width="1400px"
  6. :bodyStyle="{ padding: `0 20px 0 20px` }"
  7. :showOkBtn="false"
  8. cancelText="返回"
  9. @register="register"
  10. @close="okHandler"
  11. @ok="okHandler"
  12. @cancel="okHandler"
  13. style="top: 10px"
  14. >
  15. <!-- 基础信息栏(修改布局:每行4列,共两行) -->
  16. <div class="base-info">
  17. <div v-for="(item, index) in modalDetailsData.basicInfo" :key="index" class="info-item" :style="item.style">
  18. <span class="label">{{ item.label }}:</span>
  19. <component :is="contextRender(item)"></component>
  20. </div>
  21. </div>
  22. <a-tabs v-model:activeKey="activeKey" type="card" :destroyInactiveTabPane="true">
  23. <a-tab-pane key="1" tab="密闭墙内">
  24. <!-- 监测数据卡片 -->
  25. <div class="data-cards">
  26. <MiniBoard
  27. v-for="(item, index) in modalDetailsData.board"
  28. :key="index"
  29. type="J"
  30. :label="item.label"
  31. :value="dataRef[item.value] || '-'"
  32. layout="label-top"
  33. />
  34. </div>
  35. <!-- 图表区域 -->
  36. <div class="chart-area">
  37. <div v-if="modalDetailsData.blastDeltaConfig" class="chart-item">
  38. <div class="chart-title pl-20px">爆炸三角形</div>
  39. <div class="chart-placeholder">
  40. <BlastDelta class="chart-blast" :posMonitor="dataRef" :canvas-size="{ width: 196, height: 125 }" text-color="#000" />
  41. </div>
  42. </div>
  43. <div v-if="modalDetailsData.gasConcentrationConfig" class="chart-item">
  44. <div class="chart-title pl-20px">气体浓度曲线</div>
  45. <div class="chart-placeholder">
  46. <CustomChart
  47. :chart-data="{ chartData: dataArray }"
  48. :chart-config="modalDetailsData.gasConcentrationConfig"
  49. :chart-option="{
  50. textStyle: {
  51. color: '#000',
  52. },
  53. tooltip: {
  54. trigger: 'axis',
  55. axisPointer: {
  56. type: 'none',
  57. },
  58. },
  59. }"
  60. style="height: 100%; width: 100%"
  61. />
  62. </div>
  63. </div>
  64. <div v-if="modalDetailsData.pressureConfig" class="chart-item">
  65. <div class="chart-title pl-20px">内外压力及压差曲线</div>
  66. <div class="chart-placeholder">
  67. <CustomChart
  68. :chart-data="{ chartData: dataArray }"
  69. :chart-config="modalDetailsData.pressureConfig"
  70. :chart-option="{
  71. textStyle: {
  72. color: '#000',
  73. },
  74. tooltip: {
  75. trigger: 'axis',
  76. axisPointer: {
  77. type: 'none',
  78. },
  79. },
  80. }"
  81. style="height: 100%; width: 100%"
  82. />
  83. </div>
  84. </div>
  85. </div>
  86. </a-tab-pane>
  87. <a-tab-pane key="2" tab="密闭墙外">
  88. <!-- 监测数据卡片 -->
  89. <div class="data-cards">
  90. <MiniBoard
  91. v-for="(item, index) in modalDetailsData.boardOut"
  92. :key="index"
  93. type="J"
  94. :label="item.label"
  95. :value="dataRef[item.value] || '-'"
  96. layout="label-top"
  97. />
  98. </div>
  99. <!-- 图表区域 -->
  100. <div class="chart-area">
  101. <div v-if="modalDetailsData.blastDeltaOutConfig" class="chart-item">
  102. <div class="chart-title pl-20px">爆炸危险性判定</div>
  103. <div class="chart-placeholder">
  104. <BlastDelta class="chart-blast" :posMonitor="dataRef" :canvas-size="{ width: 196, height: 125 }" text-color="#000" />
  105. </div>
  106. </div>
  107. <div v-if="modalDetailsData.gasConcentrationOutConfig" class="chart-item">
  108. <div class="chart-title pl-20px">气体浓度曲线</div>
  109. <div class="chart-placeholder">
  110. <CustomChart
  111. :chart-data="{ chartData: dataArray }"
  112. :chart-config="modalDetailsData.gasConcentrationOutConfig"
  113. :chart-option="{
  114. textStyle: {
  115. color: '#000',
  116. },
  117. tooltip: {
  118. trigger: 'axis',
  119. axisPointer: {
  120. type: 'none',
  121. },
  122. },
  123. }"
  124. style="height: 100%; width: 100%"
  125. />
  126. </div>
  127. </div>
  128. <div v-if="modalDetailsData.pressureOutConfig" class="chart-item">
  129. <div class="chart-title pl-20px">内外压力及压差曲线</div>
  130. <div class="chart-placeholder">
  131. <CustomChart
  132. :chart-data="{ chartData: dataArray }"
  133. :chart-config="modalDetailsData.pressureOutConfig"
  134. :chart-option="{
  135. textStyle: {
  136. color: '#000',
  137. },
  138. tooltip: {
  139. trigger: 'axis',
  140. axisPointer: {
  141. type: 'none',
  142. },
  143. },
  144. }"
  145. style="height: 100%; width: 100%"
  146. />
  147. </div>
  148. </div>
  149. </div>
  150. </a-tab-pane>
  151. </a-tabs>
  152. </BasicModal>
  153. </template>
  154. <script lang="ts">
  155. import { defineComponent } from 'vue';
  156. import { BasicModal, useModalInner } from '/@/components/Modal';
  157. import { ref } from 'vue';
  158. import MiniBoard from '/@/components/Configurable/detail/MiniBoard.vue';
  159. import BlastDelta from '/@/components/Configurable/preset/BlastDelta.vue';
  160. import CustomChart from '/@/components/Configurable/detail/CustomChart.vue';
  161. import { get, isFunction } from 'lodash-es';
  162. import { h } from 'vue';
  163. import { getGoafHistory } from '../monitor.api';
  164. // import { useIntervalFn } from '@vueuse/core';
  165. import dayjs from 'dayjs';
  166. import { propTypes } from '/@/utils/propTypes';
  167. import { message } from 'ant-design-vue';
  168. export default defineComponent({
  169. components: { BasicModal, MiniBoard, BlastDelta, CustomChart },
  170. props: {
  171. identifyField: propTypes.string.def('goafId'),
  172. modalDetailsData: propTypes.any,
  173. },
  174. emits: ['close', 'register'],
  175. setup(props, { emit }) {
  176. const dataRef = ref<any>({});
  177. const dataArray = ref<any[]>([]);
  178. const activeKey = ref('1');
  179. // 添加元素,数组最多15项,按队列排布
  180. // const push = (item) => {
  181. // item.readTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
  182. // dataArray.value = takeRight(concat(dataArray.value, item), 15);
  183. // };
  184. const [register] = useModalInner((d) => {
  185. if (!d) return;
  186. // 没数据或者新传入的数据id不同,说明是首次/点击别的数据列进入的该组件
  187. // if (!dataRef.value || d[props.identifyField] !== dataRef.value[props.identifyField]) {
  188. // dataArray.value = [];
  189. // }
  190. dataRef.value = d;
  191. getGoafHistory({
  192. goafId: dataRef.value.goafId,
  193. startTime: dayjs().add(-3, 'day').format('YYYY-MM-DD 00:00:00'),
  194. endTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
  195. pageSize: 100,
  196. sort: 'asc',
  197. }).then((r) => {
  198. if (r && r.records) {
  199. dataArray.value = r.records;
  200. } else {
  201. message.info('暂无历史数据');
  202. dataArray.value = [];
  203. }
  204. });
  205. // push(d);
  206. // resume();
  207. });
  208. function contextRender({ value, customRender }: any) {
  209. if (isFunction(customRender)) return customRender({ record: dataRef.value });
  210. return h('span', get(dataRef.value, value));
  211. }
  212. // function fetchDetailData() {
  213. // const { deptId, goafId } = dataRef.value;
  214. // getGoafData({ deptId, goafId }).then(({ records }) => {
  215. // dataRef.value = {
  216. // ...dataRef.value,
  217. // ...last(records),
  218. // };
  219. // push(dataRef.value);
  220. // });
  221. // }
  222. // const { pause, resume } = useIntervalFn(
  223. // () => {
  224. // fetchDetailData();
  225. // },
  226. // 1000,
  227. // {
  228. // immediate: false,
  229. // }
  230. // );
  231. function okHandler() {
  232. // pause();
  233. emit('close');
  234. }
  235. return {
  236. dataRef,
  237. dataArray,
  238. get,
  239. register,
  240. contextRender,
  241. okHandler,
  242. activeKey,
  243. };
  244. },
  245. });
  246. </script>
  247. <style lang="less" scoped>
  248. .base-info {
  249. display: grid;
  250. grid-template-columns: repeat(3, 1fr); /* 强制每行4列 */
  251. grid-template-rows: auto auto; /* 两行自动高度 */
  252. gap: 12px 12px; /* 行列间距(行间距16px,列间距12px) */
  253. margin-bottom: 20px;
  254. padding: 20px 10px;
  255. // border: 1px solid @border-color-base;
  256. border-radius: 10px;
  257. background: #ecf4fd;
  258. }
  259. .info-item {
  260. display: flex;
  261. align-items: center;
  262. /* 适配文字过长的情况 */
  263. white-space: nowrap;
  264. overflow: hidden;
  265. text-overflow: ellipsis;
  266. background-image: linear-gradient(to right, #d7eafe, transparent);
  267. padding: 5px 10px;
  268. border-radius: 5px;
  269. }
  270. .label {
  271. color: #666;
  272. margin-right: 8px;
  273. // min-width: 90px;
  274. flex-shrink: 0; /* 标签宽度不收缩 */
  275. }
  276. .value {
  277. color: #333;
  278. flex: 1;
  279. overflow: hidden;
  280. text-overflow: ellipsis;
  281. }
  282. .data-cards {
  283. display: flex;
  284. // grid-template-columns: repeat(8, 1fr);
  285. // gap: 16px;
  286. justify-content: space-evenly;
  287. margin-bottom: 20px;
  288. padding: 20px;
  289. // border: 1px solid @border-color-base;
  290. border-radius: 10px;
  291. // background: @card-bg-color;
  292. background: #ecf4fd;
  293. }
  294. .data-card {
  295. background: #fafafa;
  296. border-radius: 8px;
  297. padding: 12px;
  298. text-align: center;
  299. }
  300. .card-value {
  301. font-size: 20px;
  302. font-weight: bold;
  303. color: #1890ff;
  304. margin-bottom: 4px;
  305. }
  306. .card-label {
  307. font-size: 14px;
  308. color: #666;
  309. }
  310. .chart-area {
  311. display: flex;
  312. flex-wrap: wrap;
  313. gap: 20px;
  314. padding: 20px;
  315. // border: 1px solid @border-color-base;
  316. border-radius: 10px;
  317. justify-content: space-evenly;
  318. /* background: black; */
  319. // background: @card-bg-color;
  320. background: #ecf4fd;
  321. --image-title-2: url(/@/assets/images/sealedGoaf/module/module-title-2.png);
  322. // --image-bg: linear-gradient();
  323. }
  324. .chart-item {
  325. flex: 1;
  326. // flex-basis: 6;
  327. // flex-shrink: 1;
  328. // min-width: 200px;
  329. width: 300px;
  330. &:first-child {
  331. // flex-basis: 380px;
  332. flex: 0 0 380px;
  333. // flex-shrink: 0;
  334. // flex-grow: 1;
  335. }
  336. }
  337. .chart-title {
  338. font-size: 14px;
  339. font-weight: 500;
  340. // margin-bottom: 8px;
  341. font-weight: bold;
  342. color: @text-color-call-out;
  343. background-image: var(--image-title-2);
  344. background-size: 100% 100%;
  345. height: 32px;
  346. line-height: 32px;
  347. }
  348. .chart-placeholder {
  349. width: 100%;
  350. height: 200px;
  351. border-radius: 4px;
  352. overflow: hidden;
  353. background-image: @gradient-thirdary-color;
  354. .chart-blast {
  355. height: 170px;
  356. margin-top: 20px;
  357. }
  358. }
  359. .chart-placeholder img {
  360. width: 100%;
  361. height: 100%;
  362. object-fit: cover;
  363. }
  364. </style>