dustMonitorTable.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="dustMonitor">
  3. <div class="search-area">
  4. <a-row>
  5. <a-col :span="12">
  6. <div class="area-item">
  7. <div class="item-text">录入时间:</div>
  8. <span style="width: 240px; color: #fff">{{ createTime }}</span>
  9. </div>
  10. </a-col>
  11. <a-col :span="12">
  12. <div class="area-item">
  13. <div class="item-text">录入人员:</div>
  14. <span style="width: 240px; color: #fff">{{ createBy }}</span>
  15. </div>
  16. </a-col>
  17. </a-row>
  18. </div>
  19. <div class="content-area">
  20. <a-table
  21. v-if="columns.length > 0"
  22. :columns="columns"
  23. :data-source="tableData"
  24. :pagination="false"
  25. size="small"
  26. class="tableW"
  27. :scroll="{ y: 620 }"
  28. >
  29. <template #bodyCell="{ column, record }">
  30. <a v-if="column.dataIndex === 'operation'" class="table-action-link" @click="handlerLocation(record)">定位</a>
  31. </template>
  32. </a-table>
  33. </div>
  34. </div>
  35. </template>
  36. <script setup lang="ts">
  37. import { ref, onMounted, reactive, computed, watch, nextTick } from 'vue';
  38. import { dsutColumns, dsutDltColumns } from './comment.data';
  39. import { getInfoList, getAllFileList } from './comment.api';
  40. const emit = defineEmits(['locate']);
  41. const props = defineProps({
  42. isShowAction: {
  43. type: Boolean,
  44. default: false,
  45. },
  46. });
  47. let tableData = ref<any[]>([]);
  48. let selectList = ref<any[]>([]);
  49. let resultByWorkplace = ref<any[]>([]);
  50. let AllMaxValues = ref<any[]>([]);
  51. let filteredResultByWorkplace = ref<any[]>([]); //根据工作场所查询的数据
  52. let workplaceList = ref<any[]>([]); //根据工作场所查询的数据
  53. let selectedFileId = ref<string | null>(null);
  54. let selectedWorkplace = ref<string | null>(null);
  55. let DefaultValue = ref<string | null>(null);
  56. let createBy = ref<any[]>([]);
  57. let createTime = ref<any[]>([]);
  58. let formSearch = reactive({
  59. pageNum: 1,
  60. pageSize: 1000,
  61. fileId: '',
  62. fileName: '',
  63. });
  64. const columns = ref([]);
  65. watch(
  66. () => props.isShowAction,
  67. (value) => {
  68. if (value) {
  69. dsutDltColumns.push({
  70. title: '操作',
  71. dataIndex: 'operation',
  72. width: 100,
  73. align: 'center',
  74. });
  75. if (columns.value.length == 0) columns.value = dsutDltColumns;
  76. } else {
  77. if (columns.value.length == 0) columns.value = dsutDltColumns;
  78. }
  79. },
  80. { immediate: true }
  81. );
  82. function handlerLocation(record) {
  83. emit('locate', record);
  84. }
  85. //获取粉尘监测结果数据
  86. async function getTableList(params: any) {
  87. let res = await getInfoList({ type: 'smoke', ...params });
  88. const content = res.content;
  89. let contentArr = JSON.parse(content);
  90. tableData.value = contentArr;
  91. createBy.value = res.createBy;
  92. createTime.value = res.createTime;
  93. processTableData(contentArr);
  94. if (workplaceList.value.length > 0) {
  95. console.log(workplaceList.value, 'workplaceList');
  96. DefaultValue.value = workplaceList.value[0];
  97. workPlaceChange(selectedWorkplace.value);
  98. }
  99. }
  100. // 处理 tableData 数据
  101. function processTableData(data: any) {
  102. // 根据 gzcs 字段进行分组
  103. const groupedData = data.reduce((acc: any, item: any) => {
  104. const workplace = item.gzcs;
  105. if (!acc[workplace]) {
  106. acc[workplace] = [];
  107. }
  108. acc[workplace].push(item);
  109. return acc;
  110. }, {});
  111. // 筛选每个工作场所下的最大值
  112. const result = Object.keys(groupedData).flatMap((workplace) => {
  113. const items = groupedData[workplace];
  114. const maxValues = [
  115. { key: 'sc_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  116. { key: 'jx_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  117. { key: 'sc_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  118. { key: 'jx_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  119. { key: 'zcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  120. { key: 'hcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  121. // { key: 'zcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  122. // { key: 'zcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  123. // { key: 'hcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  124. // { key: 'hcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
  125. ];
  126. items.forEach((item: any) => {
  127. maxValues.forEach((maxValue) => {
  128. if (item[maxValue.key] > maxValue.value) {
  129. maxValue.value = item[maxValue.key];
  130. maxValue.gz = item.gz;
  131. maxValue.jcdd = item.jcdd;
  132. maxValue.fczl = item.fczl;
  133. }
  134. });
  135. });
  136. return maxValues;
  137. });
  138. resultByWorkplace.value = result;
  139. workplaceList.value = Array.from(new Set(resultByWorkplace.value.map((item) => item.gzcs)));
  140. if (workplaceList.value.length > 0) {
  141. selectedWorkplace.value = workplaceList.value[0];
  142. workPlaceChange(selectedWorkplace.value);
  143. }
  144. // 筛选整个 tableData 下的最大值
  145. const overallMaxValues = [
  146. { key: 'sc_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  147. { key: 'jx_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  148. { key: 'sc_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  149. { key: 'jx_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  150. { key: 'zcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  151. { key: 'hcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  152. // { key: 'zcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  153. // { key: 'zcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  154. // { key: 'hcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  155. // { key: 'hcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
  156. ];
  157. data.forEach((item: any) => {
  158. overallMaxValues.forEach((maxValue) => {
  159. if (item[maxValue.key] > maxValue.value) {
  160. maxValue.value = item[maxValue.key];
  161. maxValue.gz = item.gz;
  162. maxValue.jcdd = item.jcdd;
  163. maxValue.fczl = item.fczl;
  164. maxValue.gzcs = item.gzcs;
  165. }
  166. });
  167. });
  168. AllMaxValues.value = overallMaxValues;
  169. }
  170. //获取所有文件列表
  171. async function getAllFile() {
  172. let res = await getAllFileList({ type: 'smoke' });
  173. selectList.value = res.records.map((item: any) => ({
  174. fileId: item.fileId,
  175. fileName: item.fileName,
  176. }));
  177. if (selectList.value.length > 0) {
  178. formSearch.fileId = selectList.value[0].fileId;
  179. getSearch();
  180. }
  181. }
  182. //查询
  183. function getSearch() {
  184. const selectedFile = selectList.value.find((item) => item.fileId === formSearch.fileId);
  185. const params = {
  186. fileId: formSearch.fileId,
  187. fileName: selectedFile ? selectedFile.fileName : '',
  188. };
  189. getTableList(params);
  190. }
  191. function workPlaceChange(value: any) {
  192. selectedWorkplace.value = value;
  193. filteredResultByWorkplace.value = resultByWorkplace.value.filter((item) => item.gzcs === value);
  194. }
  195. onMounted(() => {
  196. getTableList({ type: 'smoke' });
  197. getAllFile().then(() => {
  198. if (selectList.value.length > 0) {
  199. formSearch.fileId = selectList.value[0].fileId;
  200. selectedFileId.value = selectList.value[0].fileId;
  201. getSearch();
  202. }
  203. });
  204. });
  205. </script>
  206. <style lang="less" scoped>
  207. @ventSpace: zxm;
  208. .dustMonitor {
  209. .search-area {
  210. margin: 15px;
  211. .area-item {
  212. display: flex;
  213. align-items: center;
  214. .item-text {
  215. color: #fff;
  216. }
  217. }
  218. }
  219. .zxm-picker,
  220. .zxm-input {
  221. border: 1px solid #3ad8ff77;
  222. background-color: #ffffff00;
  223. color: #fff;
  224. }
  225. }
  226. :deep(.@{ventSpace}-table-body) {
  227. height: auto !important;
  228. tr > td {
  229. background: #ffffff00 !important;
  230. }
  231. tr.@{ventSpace}-table-row-selected {
  232. td {
  233. background: #007cc415 !important;
  234. }
  235. }
  236. }
  237. :deep(.jeecg-basic-table .@{ventSpace}-table-wrapper .@{ventSpace}-table-title) {
  238. min-height: 0;
  239. }
  240. :deep(.@{ventSpace}-pagination) {
  241. margin-right: 20px !important;
  242. }
  243. :deep(.zxm-table-thead > tr > th:last-child) {
  244. border-right: 1px solid #91e9fe55 !important;
  245. }
  246. </style>