3
0

HistoricalDetailsModal.vue 11 KB

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