index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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="computedColumns" :data-source="tableData" size="small" :scroll="{ y: 250 }" class="tableW">
  14. <template #bodyCell="{ record, column }">
  15. <template v-if="record[column.dataIndex] === null">
  16. <span>-</span>
  17. </template>
  18. </template>
  19. </a-table>
  20. <div class="tab-container">
  21. <a-tabs v-model:activeKey="activeTab">
  22. <a-tab-pane key="workplace" class="tab1" tab="监测地点粉尘情况分析">
  23. <div class="filter-container" v-if="workplaceList.length > 0">
  24. <a-select
  25. v-if="sysOrgCode != 'sdmtjtdltmk'"
  26. :key="DefaultValue"
  27. :default-value="DefaultValue"
  28. v-model="selectedWorkplace"
  29. @change="workPlaceChange"
  30. placeholder="选择工作场所"
  31. style="width: 280px; margin: 5px"
  32. >
  33. <a-select-option v-for="workplace in workplaceList" :key="workplace.index" :value="workplace">
  34. {{ workplace }}
  35. </a-select-option>
  36. </a-select>
  37. </div>
  38. <a-table :columns="DataComputedColumns" :data-source="filteredResultByWorkplace" size="small" :scroll="{ y: 260 }" class="tableW" />
  39. </a-tab-pane>
  40. <a-tab-pane key="overall" class="tab2" tab="当日粉尘情况分析">
  41. <a-table :columns="AllDataComputedColumns" :data-source="AllMaxValues" size="small" :scroll="{ y: 300 }" class="tableW" />
  42. </a-tab-pane>
  43. </a-tabs>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. </template>
  49. <script setup lang="ts">
  50. import { ref, onMounted, reactive, computed, watch, nextTick } from 'vue';
  51. import {
  52. columns,
  53. Dltcolumns,
  54. Swcolumns,
  55. dataColumns,
  56. dataDltColumns,
  57. dataSwColumns,
  58. AllDataColumns,
  59. AllDataDltColumns,
  60. AllDataSwColumns,
  61. } from './dust-table.data';
  62. import { getDustInfoList, getAllFileList } from './dsut-table.api';
  63. import customHeader from '/@/components/vent/customHeader.vue';
  64. import { result } from 'lodash-es';
  65. // import { nextTick } from 'process';
  66. import { useGlobSetting } from '/@/hooks/setting';
  67. let tableData = ref<any[]>([]);
  68. let selectList = ref<any[]>([]);
  69. let resultByWorkplace = ref<any[]>([]);
  70. let AllMaxValues = ref<any[]>([]);
  71. let resultValues = ref<any[]>([]);
  72. let filteredResultByWorkplace = ref<any[]>([]); //根据工作场所查询的数据
  73. let workplaceList = ref<any[]>([]); //根据工作场所查询的数据
  74. let activeTab = ref<string>('workplace');
  75. let selectedFileId = ref<string | null>(null);
  76. let selectedWorkplace = ref<string | null>(null);
  77. let DefaultValue = ref<string | null>(null);
  78. const { sysOrgCode } = useGlobSetting();
  79. let formSearch = reactive({
  80. pageNum: 1,
  81. pageSize: 1000,
  82. fileId: '',
  83. fileName: '',
  84. });
  85. //获取粉尘监测列展示数据
  86. const computedColumns = computed(() => {
  87. switch (sysOrgCode) {
  88. case 'sdmtjtbetmk':
  89. return columns; // 布尔台对应的列配置
  90. case 'sdmtjtdltmk':
  91. return Dltcolumns; // 大柳塔对应的列配置
  92. case 'sdmtjtswmk':
  93. return Swcolumns; // 上湾对应的列配置
  94. default:
  95. return columns; // 默认情况下返回的列配置
  96. }
  97. });
  98. const AllDataComputedColumns = computed(() => {
  99. switch (sysOrgCode) {
  100. case 'sdmtjtbetmk':
  101. return AllDataColumns; // 布尔台对应的列配置
  102. case 'sdmtjtdltmk':
  103. return AllDataDltColumns; // 大柳塔对应的列配置
  104. case 'sdmtjtswmk':
  105. return AllDataSwColumns; // 上湾对应的列配置
  106. default:
  107. return AllDataColumns; // 默认情况下返回的列配置
  108. }
  109. });
  110. const DataComputedColumns = computed(() => {
  111. switch (sysOrgCode) {
  112. case 'sdmtjtbetmk':
  113. return dataColumns; // 布尔台对应的列配置
  114. case 'sdmtjtdltmk':
  115. return dataDltColumns; // 大柳塔对应的列配置
  116. case 'sdmtjtswmk':
  117. return dataSwColumns; // 上湾对应的列配置
  118. default:
  119. return dataColumns; // 默认情况下返回的列配置
  120. }
  121. });
  122. //获取粉尘监测结果数据
  123. async function getTableList(params: any) {
  124. let res = await getDustInfoList({ type: 'smoke', ...params });
  125. const content = res.content;
  126. let contentArr = JSON.parse(content);
  127. tableData.value = contentArr;
  128. processTableData(contentArr);
  129. if (workplaceList.value.length > 0) {
  130. console.log(workplaceList.value, 'workplaceList');
  131. DefaultValue.value = workplaceList.value[0];
  132. workPlaceChange(selectedWorkplace.value);
  133. }
  134. }
  135. // 处理 tableData 数据
  136. function processTableData(data: any) {
  137. // 根据 gzcs 字段进行分组
  138. const groupedData = data.reduce((acc: any, item: any) => {
  139. const workplace = item.gzcs;
  140. if (!acc[workplace]) {
  141. acc[workplace] = [];
  142. }
  143. acc[workplace].push(item);
  144. return acc;
  145. }, {});
  146. // 筛选每个工作场所下的最大值
  147. const result = Object.keys(groupedData).flatMap((workplace) => {
  148. const items = groupedData[workplace];
  149. const maxValues = [
  150. { key: 'sc_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  151. { key: 'jx_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  152. { key: 'sc_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  153. { key: 'jx_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  154. { key: 'zcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  155. { key: 'hcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  156. { key: 'zcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  157. { key: 'zcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  158. { key: 'hcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  159. { key: 'hcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  160. ];
  161. const DltMaxValues = [
  162. { key: 'sc_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  163. { key: 'jx_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  164. { key: 'sc_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  165. { key: 'jx_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  166. { key: 'zcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  167. { key: 'hcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  168. ];
  169. const SwMaxValues = [
  170. { key: 'zcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  171. { key: 'hcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  172. ];
  173. items.forEach((item: any) => {
  174. maxValues.forEach((maxValue) => {
  175. if (item[maxValue.key] > maxValue.value) {
  176. maxValue.value = item[maxValue.key];
  177. maxValue.gz = item.gz;
  178. maxValue.jcdd = item.jcdd;
  179. maxValue.fczl = item.fczl;
  180. }
  181. });
  182. DltMaxValues.forEach((maxValue) => {
  183. if (item[maxValue.key] > maxValue.value) {
  184. maxValue.value = item[maxValue.key];
  185. maxValue.gz = item.gz;
  186. maxValue.jcdd = item.jcdd;
  187. maxValue.fczl = item.fczl;
  188. maxValue.gzcs = item.gzcs;
  189. }
  190. });
  191. SwMaxValues.forEach((maxValue) => {
  192. if (item[maxValue.key] > maxValue.value) {
  193. maxValue.value = item[maxValue.key];
  194. maxValue.gz = item.gz;
  195. maxValue.jcdd = item.jcdd;
  196. maxValue.fczl = item.fczl;
  197. maxValue.gzcs = item.gzcs;
  198. }
  199. });
  200. });
  201. switch (sysOrgCode) {
  202. case 'sdmtjtbetmk':
  203. return maxValues; // 布尔台对应的列配置
  204. case 'sdmtjtdltmk':
  205. return DltMaxValues; // 大柳塔对应的列配置
  206. case 'sdmtjtswmk':
  207. return SwMaxValues; // 上湾对应的列配置
  208. default:
  209. return maxValues; // 默认情况下返回的列配置
  210. }
  211. });
  212. resultByWorkplace.value = result;
  213. workplaceList.value = Array.from(new Set(resultByWorkplace.value.map((item) => item.gzcs)));
  214. if (workplaceList.value.length > 0) {
  215. selectedWorkplace.value = workplaceList.value[0];
  216. workPlaceChange(selectedWorkplace.value);
  217. }
  218. // 筛选整个 tableData 下的最大值
  219. const overallMaxValues = [
  220. { key: 'sc_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  221. { key: 'jx_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  222. { key: 'sc_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  223. { key: 'jx_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  224. { key: 'zcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  225. { key: 'hcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  226. { key: 'zcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  227. { key: 'zcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  228. { key: 'hcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  229. { key: 'hcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  230. ];
  231. const overallDltMaxValues = [
  232. { key: 'sc_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  233. { key: 'jx_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  234. { key: 'sc_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  235. { key: 'jx_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  236. { key: 'zcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  237. { key: 'hcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  238. ];
  239. const overallSwMaxValues = [
  240. { key: 'zcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  241. { key: 'hcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  242. ];
  243. data.forEach((item: any) => {
  244. overallMaxValues.forEach((maxValue) => {
  245. if (item[maxValue.key] > maxValue.value) {
  246. maxValue.value = item[maxValue.key];
  247. maxValue.gz = item.gz;
  248. maxValue.jcdd = item.jcdd;
  249. maxValue.fczl = item.fczl;
  250. maxValue.gzcs = item.gzcs;
  251. }
  252. });
  253. overallDltMaxValues.forEach((maxValue) => {
  254. if (item[maxValue.key] > maxValue.value) {
  255. maxValue.value = item[maxValue.key];
  256. maxValue.gz = item.gz;
  257. maxValue.jcdd = item.jcdd;
  258. maxValue.fczl = item.fczl;
  259. maxValue.gzcs = item.gzcs;
  260. }
  261. });
  262. overallSwMaxValues.forEach((maxValue) => {
  263. if (item[maxValue.key] > maxValue.value) {
  264. maxValue.value = item[maxValue.key];
  265. maxValue.gz = item.gz;
  266. maxValue.jcdd = item.jcdd;
  267. maxValue.fczl = item.fczl;
  268. maxValue.gzcs = item.gzcs;
  269. }
  270. });
  271. });
  272. AllMaxValues = computed(() => {
  273. switch (sysOrgCode) {
  274. case 'sdmtjtbetmk':
  275. return overallMaxValues; // 布尔台对应的列配置
  276. case 'sdmtjtdltmk':
  277. return overallDltMaxValues; // 大柳塔对应的列配置
  278. case 'sdmtjtswmk':
  279. return overallSwMaxValues; // 上湾对应的列配置
  280. default:
  281. return overallMaxValues; // 默认情况下返回的列配置
  282. }
  283. });
  284. }
  285. //获取所有文件列表
  286. async function getAllFile() {
  287. let res = await getAllFileList({ type: 'smoke' });
  288. selectList.value = res.records.map((item: any) => ({
  289. fileId: item.fileId,
  290. fileName: item.fileName,
  291. }));
  292. if (selectList.value.length > 0) {
  293. formSearch.fileId = selectList.value[0].fileId;
  294. getSearch();
  295. }
  296. }
  297. //查询
  298. // 处理文件点击事件
  299. function handleFileClick(item: any) {
  300. formSearch.fileId = item.fileId;
  301. formSearch.fileName = item.fileName;
  302. selectedFileId.value = item.fileId;
  303. getSearch();
  304. }
  305. function getSearch() {
  306. const selectedFile = selectList.value.find((item) => item.fileId === formSearch.fileId);
  307. const params = {
  308. fileId: formSearch.fileId,
  309. fileName: selectedFile ? selectedFile.fileName : '',
  310. };
  311. getTableList(params);
  312. }
  313. function workPlaceChange(value: any) {
  314. selectedWorkplace.value = value;
  315. filteredResultByWorkplace.value = resultByWorkplace.value.filter((item) => item.gzcs === value);
  316. }
  317. onMounted(() => {
  318. getTableList({ type: 'smoke' });
  319. getAllFile().then(() => {
  320. if (selectList.value.length > 0) {
  321. formSearch.fileId = selectList.value[0].fileId;
  322. selectedFileId.value = selectList.value[0].fileId;
  323. getSearch();
  324. }
  325. });
  326. });
  327. </script>
  328. <style lang="less" scoped>
  329. @import '/@/design/theme.less';
  330. .content-container {
  331. display: flex;
  332. width: 100%;
  333. height: 100%;
  334. padding-top: 54px;
  335. }
  336. .file-list {
  337. width: 20%;
  338. padding: 10px;
  339. margin-right: 10px;
  340. margin-bottom: 50px;
  341. border: 1px solid #99e8ff66;
  342. background: #27546e1a;
  343. box-shadow: 0px 0px 20px 7px rgba(145, 233, 254, 0.7) inset;
  344. -moz-box-shadow: 0px 0px 20px 7px rgba(145, 233, 254, 0.7) inset;
  345. -webkit-box-shadow: 0px 0px 50px 1px rgb(149 235 255 / 5%) inset;
  346. }
  347. .file-list ul {
  348. list-style: none;
  349. padding: 0;
  350. }
  351. .file-list li {
  352. color: #fff;
  353. padding: 5px;
  354. cursor: pointer;
  355. }
  356. .file-list li:hover,
  357. .file-list li.selected {
  358. background: #1c4869;
  359. }
  360. .table-container {
  361. margin-top: 10px;
  362. width: 80%;
  363. box-sizing: border-box;
  364. }
  365. .tab-container {
  366. display: flex;
  367. align-items: center;
  368. }
  369. .tab-container .ant-tabs {
  370. flex-grow: 1;
  371. }
  372. :deep(.zxm-tabs-nav) {
  373. margin: 0 !important;
  374. .zxm-tabs-tab {
  375. width: 180px;
  376. height: 45px;
  377. background: url('@/assets/images/defaultbg.png') center no-repeat;
  378. background-size: 100%;
  379. display: flex;
  380. justify-content: center;
  381. font-size: 16px;
  382. margin-right: 10px;
  383. }
  384. .zxm-tabs-tab-active {
  385. width: 180px;
  386. position: relative;
  387. background: url('@/assets/images/selected.png') center no-repeat;
  388. background-size: 100%;
  389. .zxm-tabs-tab-btn {
  390. color: #fff !important;
  391. }
  392. }
  393. .zxm-tabs-ink-bar {
  394. width: 0 !important;
  395. }
  396. .zxm-tabs-tab + .zxm-tabs-tab {
  397. margin: 0 !important;
  398. }
  399. }
  400. .dustMonitor {
  401. width: 100%;
  402. height: 100%;
  403. padding: 10px 10px 15px 10px;
  404. box-sizing: border-box;
  405. position: relative;
  406. }
  407. :deep(.zxm-table-thead > tr > th:last-child) {
  408. border-right: 1px solid #91e9fe !important;
  409. }
  410. :deep(.zxm-picker-input > input) {
  411. color: #fff;
  412. }
  413. :deep(.zxm-select:not(.zxm-select-customize-input) .zxm-select-selector) {
  414. border: 1px solid var(--vent-form-item-border) !important;
  415. background-color: #ffffff00 !important;
  416. }
  417. :deep(.zxm-select-selection-item) {
  418. color: #fff !important;
  419. }
  420. </style>