dischargeGas.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <BasicModal
  3. @register="register"
  4. title="智能排放瓦斯"
  5. :maskStyle="{ backgroundColor: '#000000aa', backdropFilter: 'blur(3px)' }"
  6. width="1600px"
  7. style="height: 60%"
  8. v-bind="$attrs"
  9. @ok="onSubmit"
  10. :canFullscreen="false"
  11. :destroyOnClose="true"
  12. :footer="null"
  13. :maskClosable="false"
  14. >
  15. <div class="modal-box">
  16. <div class="left-box" style="width: 900px; height: 400px"> </div>
  17. <div class="right-box">
  18. <!-- <div ref="ChartRef" class="line-chart" style="height: 400px; width: 100%"></div> -->
  19. <BarAndLine
  20. class="echarts-line"
  21. xAxisPropType="readTime"
  22. height="400px"
  23. :dataSource="echartsData"
  24. :chartsColumns="chartsColumnListGas"
  25. :option="echatsOption1"
  26. />
  27. </div>
  28. </div>
  29. <div class="setting-box">
  30. <div class="right-inputs">
  31. <div class="vent-flex-row">
  32. <div class="input-title">出风口风量(m³/min):</div>
  33. <span class="input-box" size="large">{{ data.ductOutletAirVolume_merge }}</span>
  34. <div class="input-title">局扇供风量(m³/min):</div>
  35. <span class="input-box" size="large">{{ data.inletAirVolume_merge }}</span>
  36. <div class="input-title">瓦斯超限浓度(%):</div>
  37. <span class="input-box" size="large">{{ props.gasMax }}</span>
  38. <div class="btn btn1" @click="onHide">隐 藏</div>
  39. <div class="btn btn1" @click="stop">紧急停止</div>
  40. </div>
  41. </div>
  42. </div>
  43. </BasicModal>
  44. </template>
  45. <script lang="ts" setup>
  46. import { BasicModal, useModalInner } from '/@/components/Modal';
  47. import { ref, nextTick, onMounted, watch } from 'vue';
  48. import { option, chartsColumnListGas, echatsOption1 } from '../fanLocal.data';
  49. import BarAndLine from '/@/components/chart/BarAndLine.vue';
  50. import { autoAdjust } from '../fanLocal.api';
  51. import { message } from 'ant-design-vue';
  52. const props = defineProps({
  53. data: {
  54. type: Object,
  55. default: () => {},
  56. },
  57. gasMax: {
  58. type: Number,
  59. },
  60. fanlocalId: {
  61. type: Number,
  62. },
  63. });
  64. const emit = defineEmits(['close', 'register', 'openModal']);
  65. // 注册 modal
  66. const [register, { closeModal }] = useModalInner((data) => {
  67. nextTick(() => {
  68. if (option['xAxis']) option['xAxis']['data'] = xData;
  69. option['series'] = yDataList;
  70. initEcharts();
  71. });
  72. });
  73. const ChartRef = ref();
  74. const myChart = ref();
  75. const refresh = ref(true);
  76. const xData: any[] = [];
  77. const yDataList: [] = [];
  78. const echartsData = ref<Record<string, any>[]>([]);
  79. const monitorData = ref<Record<string, any>>({});
  80. watch(
  81. () => props.data,
  82. (newVal) => {
  83. // 创建新对象,合并 newVal 和 targetVolume
  84. const combinedData = {
  85. gasT1: newVal.gasT1,
  86. gasT2: newVal.gasT2,
  87. gasT3: newVal.gasT3,
  88. gasT4: newVal.gasT4,
  89. readTime: newVal.readTime || new Date().toISOString(), // 确保有时间字段
  90. };
  91. monitorData.value = combinedData;
  92. if (echartsData.value.length > 20) {
  93. echartsData.value.shift();
  94. }
  95. echartsData.value = [...echartsData.value, combinedData];
  96. }
  97. );
  98. function initEcharts() {
  99. if (ChartRef.value) {
  100. myChart.value = echarts.init(ChartRef.value);
  101. option && myChart.value.setOption(option);
  102. refresh.value = false;
  103. nextTick(() => {
  104. if (option['xAxis']) option['xAxis']['data'] = xData;
  105. option['series'] = yDataList;
  106. initEcharts();
  107. });
  108. });
  109. const ChartRef = ref();
  110. const myChart = ref();
  111. const refresh = ref(true);
  112. const xData: any[] = [];
  113. const yDataList: [] = [];
  114. const echartsData = ref<Record<string, any>[]>([]);
  115. const monitorData = ref<Record<string, any>>({});
  116. watch(
  117. () => props.data,
  118. (newVal) => {
  119. // 创建新对象,合并 newVal 和 targetVolume
  120. const combinedData = {
  121. gasT1: newVal.gasT1,
  122. gasT2: newVal.gasT2,
  123. gasT3: newVal.gasT3,
  124. gasT4: newVal.gasT4,
  125. readTime: newVal.readTime || new Date().toISOString(), // 确保有时间字段
  126. };
  127. monitorData.value = combinedData;
  128. if (echartsData.value.length > 20) {
  129. echartsData.value.shift();
  130. }
  131. echartsData.value = [...echartsData.value, combinedData];
  132. }
  133. );
  134. function initEcharts() {
  135. if (ChartRef.value) {
  136. myChart.value = echarts.init(ChartRef.value);
  137. option && myChart.value.setOption(option);
  138. refresh.value = false;
  139. nextTick(() => {
  140. setTimeout(() => {
  141. refresh.value = true;
  142. }, 0);
  143. });
  144. }
  145. }
  146. onMounted(() => {});
  147. function onSubmit() {
  148. emit('close');
  149. closeModal();
  150. }
  151. }
  152. function onHide() {
  153. closeModal();
  154. }
  155. function stop() {
  156. const params = { auto: 0, fanlocalId: props.fanlocalId };
  157. autoAdjust(params)
  158. .then(() => {
  159. message.success('指令已下发成功!');
  160. })
  161. .catch(() => {
  162. message.error('指令下发失败');
  163. });
  164. }
  165. onMounted(() => {});
  166. function onSubmit() {
  167. emit('close');
  168. closeModal();
  169. }
  170. </script>
  171. <style scoped lang="less">
  172. .modal-box {
  173. display: flex;
  174. flex-direction: row;
  175. background-color: #ffffff05;
  176. padding: 10px 8px 0 8px;
  177. border: 1px solid #00d8ff22;
  178. position: relative;
  179. // min-height: 600px;
  180. .left-box {
  181. flex: 1; /* 占据 3/4 的空间 */
  182. background-image: url(../../../../../assets/images/dischargeGas.svg);
  183. background-repeat: no-repeat;
  184. background-size: contain; /* 确保背景图片完整显示 */
  185. background-position: center; /* 确保背景图片居中 */
  186. }
  187. .right-box {
  188. flex: 1; /* 占据 3/4 的空间 */
  189. height: 400px;
  190. width: 100%;
  191. }
  192. }
  193. .setting-box {
  194. width: 100%;
  195. height: 70px;
  196. margin: 10px 0;
  197. background-color: #ffffff05;
  198. border: 1px solid #00d8ff22;
  199. display: flex;
  200. align-items: center;
  201. justify-content: space-between;
  202. .right-inputs {
  203. width: 100%;
  204. display: flex;
  205. height: 40px;
  206. margin: 0 10px;
  207. justify-content: space-between;
  208. }
  209. .left-buttons {
  210. display: flex;
  211. height: 40px;
  212. .btn {
  213. margin: 0 10px;
  214. }
  215. }
  216. .border-clip {
  217. width: 1px;
  218. height: 25px;
  219. border-right: 1px solid #8b8b8b77;
  220. }
  221. .input-title {
  222. max-width: 150px;
  223. }
  224. .input-box {
  225. width: 120px !important;
  226. background: transparent !important;
  227. border-color: #00d8ff44 !important;
  228. margin-right: 20px;
  229. color: #fff !important;
  230. }
  231. .btn {
  232. padding: 8px 20px;
  233. position: relative;
  234. margin: 10px;
  235. border-radius: 2px;
  236. color: #fff;
  237. width: fit-content;
  238. cursor: pointer;
  239. float: right;
  240. &::before {
  241. position: absolute;
  242. display: block;
  243. content: '';
  244. width: calc(100% - 4px);
  245. height: calc(100% - 4px);
  246. top: 2px;
  247. left: 2px;
  248. border-radius: 2px;
  249. z-index: -1;
  250. }
  251. }
  252. .setting-box {
  253. width: 1570px;
  254. height: 70px;
  255. margin: 10px 0;
  256. background-color: #ffffff05;
  257. border: 1px solid #00d8ff22;
  258. display: flex;
  259. align-items: center;
  260. justify-content: space-between;
  261. .right-inputs {
  262. width: 100%;
  263. display: flex;
  264. height: 40px;
  265. margin: 0 10px;
  266. justify-content: space-between;
  267. }
  268. .left-buttons {
  269. display: flex;
  270. height: 40px;
  271. .btn {
  272. margin: 0 10px;
  273. }
  274. }
  275. .border-clip {
  276. width: 1px;
  277. height: 25px;
  278. border-right: 1px solid #8b8b8b77;
  279. }
  280. .input-title {
  281. max-width: 150px;
  282. }
  283. .input-box {
  284. width: 220px !important;
  285. background: transparent !important;
  286. border-color: #00d8ff44 !important;
  287. margin-right: 20px;
  288. color: #fff !important;
  289. }
  290. .btn {
  291. padding: 8px 20px;
  292. position: relative;
  293. border-radius: 2px;
  294. color: #fff;
  295. width: fit-content;
  296. cursor: pointer;
  297. &::before {
  298. position: absolute;
  299. display: block;
  300. content: '';
  301. width: calc(100% - 4px);
  302. height: calc(100% - 4px);
  303. top: 2px;
  304. left: 2px;
  305. border-radius: 2px;
  306. z-index: -1;
  307. }
  308. }
  309. .btn1 {
  310. border: 1px solid #5cfaff;
  311. &::before {
  312. background-image: linear-gradient(#2effee92, #0cb1d592);
  313. }
  314. &:hover {
  315. border: 1px solid #5cfaffaa;
  316. &::before {
  317. background-image: linear-gradient(#2effee72, #0cb1d572);
  318. }
  319. }
  320. }
  321. }
  322. @keyframes open {
  323. 0% {
  324. height: 0px;
  325. }
  326. 100% {
  327. height: fit-content;
  328. }
  329. }
  330. @keyframes close {
  331. 0% {
  332. height: fit-content;
  333. }
  334. 100% {
  335. height: 0px;
  336. }
  337. }
  338. :deep(.zxm-divider-inner-text) {
  339. color: #cacaca88 !important;
  340. }
  341. :deep(.zxm-form-item) {
  342. margin-bottom: 10px;
  343. }
  344. </style>