123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- <template>
- <div class="dustMonitor">
- <div class="search-area">
- <a-row>
- <a-col :span="12">
- <div class="area-item">
- <div class="item-text">录入时间:</div>
- <span style="width: 240px; color: #fff">{{ createTime }}</span>
- </div>
- </a-col>
- <a-col :span="12">
- <div class="area-item">
- <div class="item-text">录入人员:</div>
- <span style="width: 240px; color: #fff">{{ createBy }}</span>
- </div>
- </a-col>
- </a-row>
- </div>
- <div class="content-area">
- <a-table
- v-if="columns.length > 0"
- :columns="columns"
- :data-source="tableData"
- :pagination="false"
- size="small"
- class="tableW"
- :scroll="{ y: 620 }"
- >
- <template #bodyCell="{ column, record }">
- <a v-if="column.dataIndex === 'operation'" class="table-action-link" @click="handlerLocation(record)">定位</a>
- </template>
- </a-table>
- </div>
- </div>
- </template>
- <script setup lang="ts">
- import { ref, onMounted, reactive, computed, watch, nextTick } from 'vue';
- import { dsutColumns, dsutDltColumns, dustSwColumns } from './comment.data';
- import { getInfoList, getAllFileList, getFileListById } from './comment.api';
- import { useGlobSetting } from '/@/hooks/setting';
- const emit = defineEmits(['locate']);
- const props = defineProps({
- isShowAction: {
- type: Boolean,
- default: false,
- },
- });
- let tableData = ref<any[]>([]);
- let selectList = ref<any[]>([]);
- let resultByWorkplace = ref<any[]>([]);
- let AllMaxValues = ref<any[]>([]);
- let filteredResultByWorkplace = ref<any[]>([]); //根据工作场所查询的数据
- let workplaceList = ref<any[]>([]); //根据工作场所查询的数据
- let selectedFileId = ref<string | null>(null);
- let selectedWorkplace = ref<string | null>(null);
- let DefaultValue = ref<string | null>(null);
- let createBy = ref<any[]>([]);
- let createTime = ref<any[]>([]);
- const { sysOrgCode } = useGlobSetting();
- let formSearch = reactive({
- pageNum: 1,
- pageSize: 1000,
- fileId: '',
- fileName: '',
- });
- const columns = ref([]);
- watch(
- () => props.isShowAction,
- (value) => {
- if (value) {
- const computedColumns = computed(() => {
- switch (sysOrgCode) {
- case 'sdmtjtbetmk':
- return dsutColumns; // 布尔台对应的列配置
- case 'sdmtjtdltmk':
- return dsutDltColumns; // 大柳塔对应的列配置
- case 'sdmtjtswmk':
- return dustSwColumns; // 上湾对应的列配置
- default:
- return dsutColumns; // 默认情况下返回的列配置
- }
- });
- computedColumns.value.push({
- title: '操作',
- dataIndex: 'operation',
- width: 100,
- align: 'center',
- });
- if (columns.value.length == 0) columns.value = computedColumns.value;
- } else {
- if (columns.value.length == 0) columns.value = computedColumns.value;
- }
- },
- { immediate: true }
- );
- function handlerLocation(record) {
- emit('locate', record);
- }
- //获取粉尘监测结果数据
- async function getTableList(params: any) {
- let res = await getInfoList({ type: 'smoke', ...params });
- const content = res.content;
- let contentArr = JSON.parse(content);
- tableData.value = contentArr;
- createBy.value = res.createBy;
- createTime.value = res.createTime;
- processTableData(contentArr);
- if (workplaceList.value.length > 0) {
- console.log(workplaceList.value, 'workplaceList');
- DefaultValue.value = workplaceList.value[0];
- workPlaceChange(selectedWorkplace.value);
- }
- }
- // 处理 tableData 数据
- function processTableData(data: any) {
- // 根据 gzcs 字段进行分组
- const groupedData = data.reduce((acc: any, item: any) => {
- const workplace = item.gzcs;
- if (!acc[workplace]) {
- acc[workplace] = [];
- }
- acc[workplace].push(item);
- return acc;
- }, {});
- // 筛选每个工作场所下的最大值
- const result = Object.keys(groupedData).flatMap((workplace) => {
- const items = groupedData[workplace];
- const maxValues = [
- { key: 'sc_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
- { key: 'jx_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
- { key: 'sc_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
- { key: 'jx_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
- { key: 'zcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
- { key: 'hcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
- // { key: 'zcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
- // { key: 'zcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
- // { key: 'hcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
- // { key: 'hcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: workplace },
- ];
- items.forEach((item: any) => {
- maxValues.forEach((maxValue) => {
- if (item[maxValue.key] > maxValue.value) {
- maxValue.value = item[maxValue.key];
- maxValue.gz = item.gz;
- maxValue.jcdd = item.jcdd;
- maxValue.fczl = item.fczl;
- }
- });
- });
- return maxValues;
- });
- resultByWorkplace.value = result;
- workplaceList.value = Array.from(new Set(resultByWorkplace.value.map((item) => item.gzcs)));
- if (workplaceList.value.length > 0) {
- selectedWorkplace.value = workplaceList.value[0];
- workPlaceChange(selectedWorkplace.value);
- }
- // 筛选整个 tableData 下的最大值
- const overallMaxValues = [
- { key: 'sc_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
- { key: 'jx_zcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
- { key: 'sc_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
- { key: 'jx_hcds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
- { key: 'zcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
- { key: 'hcjqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
- // { key: 'zcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
- // { key: 'zcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
- // { key: 'hcrxd_ds', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
- // { key: 'hcrxd_jqpj', value: -Infinity, gz: '', jcdd: '', fczl: '', gzcs: '' },
- ];
- data.forEach((item: any) => {
- overallMaxValues.forEach((maxValue) => {
- if (item[maxValue.key] > maxValue.value) {
- maxValue.value = item[maxValue.key];
- maxValue.gz = item.gz;
- maxValue.jcdd = item.jcdd;
- maxValue.fczl = item.fczl;
- maxValue.gzcs = item.gzcs;
- }
- });
- });
- AllMaxValues.value = overallMaxValues;
- }
- //获取所有文件列表
- async function getAllFile() {
- let res = await getAllFileList({ type: 'smoke' });
- selectList.value = res.records.map((item: any) => ({
- fileId: item.fileId,
- fileName: item.fileName,
- }));
- if (selectList.value.length > 0) {
- formSearch.fileId = selectList.value[0].fileId;
- getSearch();
- }
- }
- //查询
- function getSearch() {
- const selectedFile = selectList.value.find((item) => item.fileId === formSearch.fileId);
- const params = {
- fileId: formSearch.fileId,
- fileName: selectedFile ? selectedFile.fileName : '',
- };
- getTableList(params);
- }
- function workPlaceChange(value: any) {
- selectedWorkplace.value = value;
- filteredResultByWorkplace.value = resultByWorkplace.value.filter((item) => item.gzcs === value);
- }
- onMounted(() => {
- getTableList({ type: 'smoke' });
- getAllFile().then(() => {
- if (selectList.value.length > 0) {
- formSearch.fileId = selectList.value[0].fileId;
- selectedFileId.value = selectList.value[0].fileId;
- getSearch();
- }
- });
- });
- </script>
- <style lang="less" scoped>
- @ventSpace: zxm;
- .dustMonitor {
- .search-area {
- margin: 15px;
- .area-item {
- display: flex;
- align-items: center;
- .item-text {
- color: #fff;
- }
- }
- }
- .zxm-picker,
- .zxm-input {
- border: 1px solid #3ad8ff77;
- background-color: #ffffff00;
- color: #fff;
- }
- }
- :deep(.@{ventSpace}-table-body) {
- height: auto !important;
- tr > td {
- background: #ffffff00 !important;
- }
- tr.@{ventSpace}-table-row-selected {
- td {
- background: #007cc415 !important;
- }
- }
- }
- :deep(.jeecg-basic-table .@{ventSpace}-table-wrapper .@{ventSpace}-table-title) {
- min-height: 0;
- }
- :deep(.@{ventSpace}-pagination) {
- margin-right: 20px !important;
- }
- :deep(.zxm-table-thead > tr > th:last-child) {
- border-right: 1px solid #91e9fe55 !important;
- }
- </style>
|