Newer
Older
Nanping_sponge_SJJC / src / views / dataAnalysis / dataService / waterAnalysis / trendAnalysisRain.vue
@liyingjing liyingjing on 25 Oct 2023 4 KB 数据检测
<template>
  <!--趋势分析-晴雨天 -->
  <div class="">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="" prop="stCode">
        <el-select v-model="queryParams.stCode" filterable placeholder="请选择站点" style="width: 300px">
          <el-option
            v-for="dict in searchSiteList"
            :key="dict.stCode"
            :label="`${dict.stName}-${dict.stCode}`"
            :value="dict.stCode"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="dateRange">
        <dateSelect valueFormat="YYYY-MM-DD" :dateTime="queryParams.dateRange" @update="changeTime"></dateSelect>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="getTrendAnalysisRainSectionHeads">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="tableData" border>
      <el-table-column label="序号" type="index" width="55" />
      <template v-for="item in tableHeads" :key="item.key">
        <el-table-column v-if="item.isChild === 1" :label="item.title" :prop="item.key" show-overflow-tooltip />
        <el-table-column v-else :label="item.title">
          <el-table-column
            v-for="child in item.childList"
            :key="child.key"
            :label="child.title"
            :prop="child.key"
            width="120"
            show-overflow-tooltip
          ></el-table-column>
        </el-table-column>
      </template>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getData"
    />
  </div>
</template>

<script setup>
import { listRepairAllSite } from '@/api/dataAnalysis/repairdata';
import { trendAnalysisRainSection, trendAnalysisRainSectionHeads } from '@/api/dataAnalysis/dataCapability';
import dateSelect from '@/views/dataAnalysis/components/dateSelect'; //日期组件
import { findDictObj } from '@/utils/ruoyi.js';
const { proxy } = getCurrentInstance();
const activeName = ref('first');
const loading = ref(false);
const showSearch = ref(true);
const searchSiteList = ref([]); //站点搜索列表
const total = ref(0);
const tableData = ref([]);
const tableHeads = ref([]); //动态表头数据
const data = reactive({
  queryParams: {
    stCode: null,
    pageNum: 1,
    pageSize: 10,
    dateRange: [proxy.moment(new Date()).format('YYYY-MM-DD'), proxy.moment(new Date()).add(1, 'days').format('YYYY-MM-DD')],
  },
});

const { queryParams } = toRefs(data);

//获取站点列表
function getSearchSiteList() {
  loading.value = true;
  listRepairAllSite({ platformCode: 111211 }).then(res => {
    searchSiteList.value = res.data;
    queryParams.value.stCode = searchSiteList.value.length ? searchSiteList.value[0].stCode : '';
    getTrendAnalysisRainSectionHeads();
  });
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  queryParams.value.stCode = searchSiteList.value.length ? searchSiteList.value[0].stCode : '';
  getTrendAnalysisRainSectionHeads();
}

//动态获取表头数据
function getTrendAnalysisRainSectionHeads() {
  loading.value = true;
  trendAnalysisRainSectionHeads({ stCode: queryParams.value.stCode }).then(res => {
    tableHeads.value = res.data;
    getData();
  });
}

//获取数据
function getData() {
  let params = proxy.formatAddDateRange(queryParams.value, queryParams.value.dateRange, 'startTime', 'endTime');
  //   let data = {
  //     stCode: '0555010017',
  //     startTime: '2023-01-01',
  //     endTime: '2023-06-01',
  //     pageNum: 1,
  //     pageSize: 10,
  //   };
  loading.value = true;
  trendAnalysisRainSection(params).then(res => {
    loading.value = false;
    tableData.value = res.data;
    total.value = res.total;
  });
}
//修改时间
function changeTime(val) {
  queryParams.value.dateRange = val;
}
getSearchSiteList();
</script>
<style lang="scss" scoped></style>