index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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"> </a-table>
  14. <div id="lineChart" class="line-chart"></div>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script setup lang="ts">
  20. import { ref, onMounted, reactive } from 'vue';
  21. import { columns } from './bundleSpy-table.data';
  22. import { getbundleSpyInfoList, getAllFileList } from './bundleSpy-table.api';
  23. import customHeader from '/@/components/vent/customHeader.vue';
  24. import * as echarts from 'echarts';
  25. let selectList = ref<any[]>([]);
  26. let formSearch = reactive({
  27. pageNum: 1,
  28. pageSize: 1000,
  29. fileId: '',
  30. fileName: '',
  31. });
  32. let tableData = ref<any[]>([]);
  33. let selectedFileId = ref<string | null>(null);
  34. //获取色谱仪报表
  35. async function getTableList(params: any) {
  36. let res = await getbundleSpyInfoList({ type: 'bundleSpy', ...params });
  37. const content = res.content;
  38. let contentArr = JSON.parse(content);
  39. tableData.value = contentArr;
  40. console.log(contentArr, 'contentArr');
  41. updateChart(contentArr);
  42. }
  43. //折线图
  44. function updateChart(data: any) {
  45. const chartDom = document.getElementById('lineChart');
  46. const myChart = echarts.init(chartDom);
  47. const categories = data.map((item: any) => item.jcdd);
  48. const c2h2AveValues = data.map((item: any) => parseFloat(item.c2h2_ave));
  49. const c2h4AveValues = data.map((item: any) => parseFloat(item.c2h4_ave));
  50. const ch4AveValues = data.map((item: any) => parseFloat(item.ch4_ave));
  51. const co2AveValues = data.map((item: any) => parseFloat(item.co2_ave));
  52. const coAveValues = data.map((item: any) => parseFloat(item.co_ave));
  53. const o2AveValues = data.map((item: any) => parseFloat(item.o2_ave));
  54. const n2AveValues = data.map((item: any) => parseFloat(item.n2_ave));
  55. const c2h6AveValues = data.map((item: any) => parseFloat(item.c2h6_ave));
  56. const option = {
  57. title: {
  58. text: '色谱仪报表分析',
  59. textStyle: {
  60. color: '#ffffff', // 设置标题颜色
  61. },
  62. },
  63. tooltip: {
  64. trigger: 'axis',
  65. backgroundColor: 'rgba(28, 72, 105, 0.5)', // 设置 tooltip 背景为透明
  66. textStyle: {
  67. color: '#ffffff', // 设置 tooltip 字体颜色为白色
  68. },
  69. axisPointer: {
  70. label: {
  71. show: true,
  72. backgroundColor: '#071c44',
  73. },
  74. },
  75. },
  76. legend: {
  77. top: 10,
  78. textStyle: {
  79. color: '#ffffffff',
  80. },
  81. },
  82. xAxis: {
  83. type: 'category',
  84. data: categories,
  85. splitLine: { show: true, lineStyle: { color: 'rgba(21,80,126,.5)' } },
  86. axisLabel: {
  87. interval: 0, // 显示所有标签
  88. color: '#ffffff',
  89. formatter: function (value: string) {
  90. return value.length > 15 ? value.slice(0, 15) + '...' : value; // 截断长标签
  91. },
  92. },
  93. },
  94. yAxis: [
  95. {
  96. type: 'value',
  97. name: 'O₂/N₂',
  98. max: 100,
  99. splitLine: { show: true, lineStyle: { color: 'rgba(21,80,126,.5)' } },
  100. axisLabel: {
  101. color: '#ffffff', // 设置 y 轴字体颜色
  102. },
  103. },
  104. {
  105. type: 'value',
  106. name: '其他气体',
  107. splitLine: { show: true, lineStyle: { color: 'rgba(21,80,126,.5)' } },
  108. axisLabel: {
  109. color: '#ffffff', // 设置 y 轴字体颜色
  110. },
  111. },
  112. ],
  113. series: [
  114. {
  115. name: 'C₂H₂平均值',
  116. data: c2h2AveValues,
  117. type: 'line',
  118. yAxisIndex: 1,
  119. },
  120. {
  121. name: 'C₂H₄平均值',
  122. data: c2h4AveValues,
  123. type: 'line',
  124. yAxisIndex: 1,
  125. },
  126. {
  127. name: 'CH₄平均值',
  128. data: ch4AveValues,
  129. yAxisIndex: 1,
  130. type: 'line',
  131. },
  132. {
  133. name: 'CO₂平均值',
  134. data: co2AveValues,
  135. yAxisIndex: 1,
  136. type: 'line',
  137. },
  138. {
  139. name: 'CO平均值',
  140. data: coAveValues,
  141. yAxisIndex: 1,
  142. type: 'line',
  143. },
  144. {
  145. name: 'O₂平均值',
  146. data: o2AveValues,
  147. yAxisIndex: 0,
  148. type: 'line',
  149. },
  150. {
  151. name: 'N₂平均值',
  152. data: n2AveValues,
  153. yAxisIndex: 0,
  154. type: 'line',
  155. },
  156. {
  157. name: 'C2H6平均值',
  158. data: c2h6AveValues,
  159. yAxisIndex: 1,
  160. type: 'line',
  161. },
  162. ],
  163. };
  164. myChart.setOption(option);
  165. }
  166. //获取所有文件列表
  167. async function getAllFile() {
  168. let res = await getAllFileList({ type: 'bundleSpy' });
  169. selectList.value = res.records.map((item: any) => ({
  170. fileId: item.fileId,
  171. fileName: item.fileName,
  172. }));
  173. if (selectList.value.length > 0) {
  174. formSearch.fileId = selectList.value[0].fileId;
  175. getSearch();
  176. }
  177. }
  178. // 处理文件点击事件
  179. function handleFileClick(item: any) {
  180. formSearch.fileId = item.fileId;
  181. formSearch.fileName = item.fileName;
  182. selectedFileId.value = item.fileId;
  183. getSearch();
  184. }
  185. //查询
  186. function getSearch() {
  187. const selectedFile = selectList.value.find((item) => item.fileId === formSearch.fileId);
  188. const params = {
  189. fileId: formSearch.fileId,
  190. fileName: selectedFile ? selectedFile.fileName : '',
  191. };
  192. getTableList(params);
  193. }
  194. onMounted(() => {
  195. getTableList({ type: 'bundleSpy' });
  196. getAllFile().then(() => {
  197. if (selectList.value.length > 0) {
  198. formSearch.fileId = selectList.value[0].fileId;
  199. selectedFileId.value = selectList.value[0].fileId;
  200. getSearch();
  201. }
  202. });
  203. });
  204. </script>
  205. <style lang="less" scoped>
  206. @import '/@/design/theme.less';
  207. .content-container {
  208. display: flex;
  209. width: 100%;
  210. height: 100%;
  211. }
  212. .file-list {
  213. width: 20%;
  214. padding: 10px;
  215. margin-right: 10px;
  216. margin-bottom: 50px;
  217. border: 1px solid #99e8ff66;
  218. background: #27546e1a;
  219. box-shadow: 0px 0px 20px 7px rgba(145, 233, 254, 0.7) inset;
  220. -moz-box-shadow: 0px 0px 20px 7px rgba(145, 233, 254, 0.7) inset;
  221. -webkit-box-shadow: 0px 0px 50px 1px rgb(149 235 255 / 5%) inset;
  222. }
  223. .file-list ul {
  224. list-style: none;
  225. padding: 0;
  226. }
  227. .file-list li {
  228. color: #fff;
  229. padding: 5px;
  230. cursor: pointer;
  231. }
  232. .file-list li:hover,
  233. .file-list li.selected {
  234. background: #1c4869;
  235. }
  236. .table-container {
  237. margin-top: 10px;
  238. width: 80%;
  239. box-sizing: border-box;
  240. }
  241. .dustMonitor {
  242. width: 100%;
  243. height: 100%;
  244. padding: 10px 10px 15px 10px;
  245. box-sizing: border-box;
  246. position: relative;
  247. }
  248. :deep(.zxm-table-thead > tr > th:last-child) {
  249. border-right: 1px solid #91e9fe !important;
  250. }
  251. :deep(.zxm-picker-input > input) {
  252. color: #fff;
  253. }
  254. :deep(.zxm-select:not(.zxm-select-customize-input) .zxm-select-selector) {
  255. border: 1px solid var(--vent-form-item-border) !important;
  256. background-color: #ffffff00 !important;
  257. }
  258. :deep(.zxm-select-selection-item) {
  259. color: #fff !important;
  260. }
  261. .line-chart {
  262. width: 100%;
  263. height: 400px;
  264. margin-top: 50px;
  265. }
  266. </style>