index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <div class="dustMonitor">
  3. <customHeader>束管日报分析</customHeader>
  4. <div class="content-container">
  5. <div class="file-list">
  6. <ul>
  7. <li v-for="item in selectList" :key="item.fileId" :class="{ selected: item.fileId === selectedFileId }" @click="handleFileClick(item)">
  8. {{ item.fileName }}
  9. </li>
  10. </ul>
  11. </div>
  12. <div class="table-container">
  13. <a-table :columns="columns" :data-source="tableData" size="small" :scroll="{ y: 300 }" class="tableW">
  14. <template #bodyCell="{ column, record }">
  15. <template v-if="column.dataIndex === 'action'">
  16. <a class="action-link" @click="toDetail(record)">数据分析</a>
  17. </template>
  18. </template>
  19. </a-table>
  20. <div id="barChart" class="bar-chart"></div>
  21. </div>
  22. </div>
  23. <a-modal style="width: 50%; height: 300px" title="爆炸三角形" v-model:visible="modalVisible" :draggable="true" :footer="null">
  24. <div class="blast-delta-container">
  25. <BlastDelta :posMonitor="posMonitor" style="width: 50%" />
  26. <BlastDelta1 :posMonitor="posMonitor" style="width: 50%" />
  27. </div>
  28. </a-modal>
  29. </div>
  30. </template>
  31. <script setup lang="ts">
  32. import { ref, onMounted, shallowRef, reactive, nextTick } from 'vue';
  33. import { columns } from './bundle-table.data';
  34. import { getBundleInfoList, getAllFileList } from './bundle-table.api';
  35. import customHeader from '/@/components/vent/customHeader.vue';
  36. // import { blastDelta } from './modal/blastDelta.vue';
  37. import BlastDelta from './modal/blastDelta.vue';
  38. import BlastDelta1 from './modal/blastDelta1.vue';
  39. import * as echarts from 'echarts';
  40. import { color } from 'echarts/core';
  41. let selectList = ref<any[]>([]);
  42. let jcddArr = ref<any[]>([]);
  43. let formSearch = reactive({
  44. pageNum: 1,
  45. pageSize: 1000,
  46. fileId: '',
  47. fileName: '',
  48. });
  49. let tableData = ref<any[]>([]);
  50. let modalVisible = ref(false);
  51. let selectedFileId = ref<string | null>(null);
  52. const posMonitor = shallowRef({});
  53. function updateChart(data: any) {
  54. const chartDom = document.getElementById('barChart');
  55. const myChart = echarts.init(chartDom);
  56. const categories = data.map((item: any) => item.jcdd);
  57. const c2h2MaxValues = data.map((item: any) => parseFloat(item.c2h2_max));
  58. const c2h2AveValues = data.map((item: any) => parseFloat(item.c2h2_ave));
  59. const c2h4MaxValues = data.map((item: any) => parseFloat(item.c2h4_max));
  60. const c2h4AveValues = data.map((item: any) => parseFloat(item.c2h4_ave));
  61. const ch4MaxValues = data.map((item: any) => parseFloat(item.ch4_max));
  62. const ch4AveValues = data.map((item: any) => parseFloat(item.ch4_ave));
  63. const co2MaxValues = data.map((item: any) => parseFloat(item.co2_max));
  64. const co2AveValues = data.map((item: any) => parseFloat(item.co2_ave));
  65. const coMaxValues = data.map((item: any) => parseFloat(item.co_max));
  66. const coAveValues = data.map((item: any) => parseFloat(item.co_ave));
  67. const o2MinValues = data.map((item: any) => parseFloat(item.o2_min));
  68. const o2AveValues = data.map((item: any) => parseFloat(item.o2_ave));
  69. const option = {
  70. title: {
  71. text: '束管日报分析',
  72. textStyle: {
  73. color: '#ffffff', // 设置标题颜色
  74. },
  75. },
  76. tooltip: {
  77. trigger: 'axis',
  78. backgroundColor: 'rgba(28, 72, 105, 0.5)', // 设置 tooltip 背景为透明
  79. textStyle: {
  80. color: '#ffffff', // 设置 tooltip 字体颜色为白色
  81. },
  82. axisPointer: {
  83. type: 'shadow',
  84. label: {
  85. show: true,
  86. backgroundColor: '#1c4869',
  87. },
  88. },
  89. },
  90. legend: {
  91. top: 10,
  92. textStyle: {
  93. color: '#ffffffff',
  94. },
  95. },
  96. xAxis: {
  97. type: 'category',
  98. data: categories,
  99. splitLine: { show: true, lineStyle: { color: 'rgba(28, 72, 105, 0.5)' } },
  100. axisLabel: {
  101. interval: 0, // 显示所有标签
  102. color: '#ffffff', // 设置 x 轴字体颜色
  103. formatter: function (value: string) {
  104. return value.length > 11 ? value.slice(0, 11) + '...' : value; // 截断长标签
  105. },
  106. },
  107. },
  108. yAxis: {
  109. type: 'value',
  110. splitLine: { show: true, lineStyle: { color: 'rgba(28, 72, 105, 0.5)' } },
  111. axisLabel: {
  112. color: '#ffffff',
  113. },
  114. },
  115. series: [
  116. {
  117. name: 'C₂H₂ 最大值',
  118. data: c2h2MaxValues,
  119. type: 'bar',
  120. },
  121. {
  122. name: 'C₂H₂ 平均值',
  123. data: c2h2AveValues,
  124. type: 'bar',
  125. },
  126. {
  127. name: 'C₂H₄ 最大值',
  128. data: c2h4MaxValues,
  129. type: 'bar',
  130. },
  131. {
  132. name: 'C₂H₄ 平均值',
  133. data: c2h4AveValues,
  134. type: 'bar',
  135. },
  136. {
  137. name: 'CH₄ 最大值',
  138. data: ch4MaxValues,
  139. type: 'bar',
  140. },
  141. {
  142. name: 'CH₄ 平均值',
  143. data: ch4AveValues,
  144. type: 'bar',
  145. },
  146. {
  147. name: 'CO₂ 最大值',
  148. data: co2MaxValues,
  149. type: 'bar',
  150. },
  151. {
  152. name: 'CO₂ 平均值',
  153. data: co2AveValues,
  154. type: 'bar',
  155. },
  156. {
  157. name: 'CO 最大值',
  158. data: coMaxValues,
  159. type: 'bar',
  160. },
  161. {
  162. name: 'CO 平均值',
  163. data: coAveValues,
  164. type: 'bar',
  165. },
  166. {
  167. name: 'O₂ 最小值',
  168. data: o2MinValues,
  169. type: 'bar',
  170. },
  171. {
  172. name: 'O₂ 平均值',
  173. data: o2AveValues,
  174. type: 'bar',
  175. },
  176. ],
  177. };
  178. myChart.setOption(option);
  179. }
  180. //跳转到爆炸三角形
  181. function toDetail(record: any) {
  182. posMonitor.value = record;
  183. modalVisible.value = true;
  184. }
  185. //获取色谱仪报表
  186. async function getTableList(params: any) {
  187. let res = await getBundleInfoList({ type: 'bundle', ...params });
  188. const content = res.content;
  189. let contentArr = JSON.parse(content);
  190. tableData.value = contentArr;
  191. nextTick(() => {
  192. updateChart(contentArr);
  193. });
  194. }
  195. //获取所有文件列表
  196. async function getAllFile() {
  197. let res = await getAllFileList({ type: 'bundle' });
  198. selectList.value = res.records.map((item: any) => ({
  199. fileId: item.fileId,
  200. fileName: item.fileName,
  201. }));
  202. jcddArr.value = res.records.map((item: any) => ({
  203. fileId: item.jcdd,
  204. }));
  205. if (selectList.value.length > 0) {
  206. formSearch.fileId = selectList.value[0].fileId;
  207. getSearch();
  208. }
  209. }
  210. // 处理文件点击事件
  211. function handleFileClick(item: any) {
  212. formSearch.fileId = item.fileId;
  213. formSearch.fileName = item.fileName;
  214. selectedFileId.value = item.fileId;
  215. getSearch();
  216. }
  217. //查询
  218. function getSearch() {
  219. const selectedFile = selectList.value.find((item) => item.fileId === formSearch.fileId);
  220. const params = {
  221. fileId: formSearch.fileId,
  222. fileName: selectedFile ? selectedFile.fileName : '',
  223. };
  224. getTableList(params);
  225. }
  226. onMounted(() => {
  227. getTableList({ type: 'bundle' });
  228. getAllFile().then(() => {
  229. if (selectList.value.length > 0) {
  230. formSearch.fileId = selectList.value[0].fileId;
  231. selectedFileId.value = selectList.value[0].fileId;
  232. getSearch();
  233. }
  234. });
  235. });
  236. </script>
  237. <style lang="less" scoped>
  238. @import '/@/design/theme.less';
  239. .content-container {
  240. display: flex;
  241. width: 100%;
  242. height: 100%;
  243. }
  244. .file-list {
  245. width: 20%;
  246. padding: 10px;
  247. margin-right: 10px;
  248. margin-bottom: 50px;
  249. border: 1px solid #99e8ff66;
  250. background: #27546e1a;
  251. box-shadow: 0px 0px 20px 7px rgba(145, 233, 254, 0.7) inset;
  252. -moz-box-shadow: 0px 0px 20px 7px rgba(145, 233, 254, 0.7) inset;
  253. -webkit-box-shadow: 0px 0px 50px 1px rgb(149 235 255 / 5%) inset;
  254. }
  255. .file-list ul {
  256. list-style: none;
  257. padding: 0;
  258. }
  259. .file-list li {
  260. color: #fff;
  261. padding: 5px;
  262. cursor: pointer;
  263. }
  264. .file-list li:hover,
  265. .file-list li.selected {
  266. background: #1c4869;
  267. }
  268. .table-container {
  269. margin-top: 10px;
  270. width: 80%;
  271. box-sizing: border-box;
  272. }
  273. .dustMonitor {
  274. width: 100%;
  275. height: 100%;
  276. padding: 10px 10px 15px 10px;
  277. box-sizing: border-box;
  278. position: relative;
  279. }
  280. :deep(.zxm-table-thead > tr > th:last-child) {
  281. border-right: 1px solid #91e9fe !important;
  282. }
  283. :deep(.zxm-picker-input > input) {
  284. color: #fff;
  285. }
  286. :deep(.zxm-select:not(.zxm-select-customize-input) .zxm-select-selector) {
  287. border: 1px solid var(--vent-form-item-border) !important;
  288. background-color: #ffffff00 !important;
  289. }
  290. :deep(.zxm-select-selection-item) {
  291. color: #fff !important;
  292. }
  293. .blast-delta-container {
  294. margin: 50px;
  295. display: flex;
  296. justify-content: space-between;
  297. }
  298. .bar-chart {
  299. width: 100%;
  300. height: 400px;
  301. margin-top: 50px;
  302. }
  303. </style>