zmc
2023-09-27 eeef5d4039d2b3fee6854ddc2789aa23232b2cfb
src/views/line_graph/DataRiskRank.vue
@@ -1,13 +1,18 @@
<script>
import TimeSelectWithShortCuts from '@/sfc/TimeSelectWithShortCuts.vue';
import TimeShortCuts from '@/sfc/TimeShortCuts.vue';
import AreaAndmonitorType from '@/sfc/AreaAndmonitorType.vue';
import {useCommonFunction} from '../../utils/common.js';
import requetsApi from '@/api/exportExcel/requetsApi.js'
import requetsApi from '@/api/exportExcel/requetsApi.js';
import dayjs from 'dayjs';
import ButtonExportExcel from '@/sfc/ButtonExportExcel.vue'
import ButtonClick from '@/sfc/ButtonClick.vue'
export default {
  components: {
    TimeSelectWithShortCuts,
    AreaAndmonitorType
    TimeShortCuts,
    AreaAndmonitorType,
    ButtonExportExcel,
    ButtonClick
  },
  data() {
    return {
@@ -18,9 +23,12 @@
      total: 0,
      //   表格数据
      tableData: [],
      isNoData: false,
      isNoData: true,
      loading: false,
      // 统计分析按钮加载中
      queryButton:false,
      // 导出按钮加载中
      exportButton:false,
      form: {
        // 开始时间
        beginTime: '',
@@ -31,10 +39,9 @@
  },
  setup(){
     // 引入 百分号比较大小 导出功能
     const {cmpp,exportToExcel} = useCommonFunction()
    return {cmpp,exportToExcel}
    const { cmpp, exportToExcel } = useCommonFunction();
    return { cmpp, exportToExcel };
  },
  mounted() {
    this.form.name = '';
@@ -43,12 +50,12 @@
    // 功能:导出为Excel
    exportData(){
      let params  ={
        'beginTime':this.form.beginTime,
        'endTime': this.form.endTime
      }
      requetsApi.fetchAllData(params).then(res => {
        const data = res.data.data
        console.log('长度:',data.length);
        beginTime: this.form.beginTime,
        endTime: this.form.endTime
      };
      this.exportButton = true
      requetsApi.fetchAllData(params).then((res) => {
        const data = res.data.data;
        const  tableColumns = [
        'name',
@@ -59,18 +66,25 @@
        'max',
        'dayOnline',
        'dayValid',
        'dayExceeding',
      ]
      const excelColumns = [['A1','站点名称'],
      ['B1','设备编号'],['C1','监测日期'],['D1','平均值'],
      ['E1','最小值'],['F1','最大值'],['G1','在线率'],
      ['H1','有效率'],['I1','超标率']]
      this.exportToExcel(data,tableColumns,excelColumns,'分析表.xlsx')
      })
          'dayExceeding'
        ];
        const excelColumns = [
          ['A1', '站点名称'],
          ['B1', '设备编号'],
          ['C1', '监测日期'],
          ['D1', '平均值'],
          ['E1', '最小值'],
          ['F1', '最大值'],
          ['G1', '在线率'],
          ['H1', '有效率'],
          ['I1', '超标率']
        ];
        this.exportToExcel(data, tableColumns, excelColumns, '分析表.xlsx');
        this.exportButton = false
      });
    },
    // 功能:改变表格某个单元格的颜色
    tableCellClassName({ row, column, rowIndex, columnIndex }) {
    tableCellClassName({ row, columnIndex }) {
      // 平均值不满足标准时
      if (columnIndex == 4) {
        if (row.dayAvg >= 0.8) {
@@ -100,7 +114,6 @@
    // 页号改变时触发
    handleCurrentChange(val) {
      console.log('当前页为:', val);
      // 将当前页号给currentPage
      this.currentPage = val;
@@ -120,7 +133,6 @@
    // 点击统计按钮
    fetchData() {
      console.log(this.form.name);
      let params = {};
      params['page'] = this.currentPage;
      params['pageSize'] = this.pageSize;
@@ -134,12 +146,13 @@
        params['endTime'] = this.form.endTime;
      }
      this.loading = true;
      this.queryButton = true
      this.$http
        .get('/dust/analysistime', { params: params })
        .then((response) => {
          this.tableData = response.data.data.rows;
          console.log(this.tableData);
          this.loading = false;
          this.queryButton = false
          if (response.data.data.total == 0) {
            this.isNoData = true;
            return;
@@ -147,7 +160,6 @@
          // 移除空数据状态
          this.isNoData = false;
          this.total = response.data.data.total;
          this.loading = false;
        });
    }
  }
@@ -164,19 +176,19 @@
          </el-form-item>
 
          <el-form-item>
            <TimeSelectWithShortCuts
            <TimeShortCuts
            timeType="currentMonth"
              @submit-time="giveTime"
            ></TimeSelectWithShortCuts>
            ></TimeShortCuts>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="fetchData">统计分析</el-button>
            <el-button type="warning" @click="exportData">导出</el-button>
            <ButtonClick style="margin-right: 12px;" content="风险排名" type="primary" :loading="queryButton" @do-search="fetchData" ></ButtonClick>
            <ButtonExportExcel  content="导出数据" type="success" :loading="exportButton" @do-export="exportData"></ButtonExportExcel>
          </el-form-item>
        </el-form>
        <el-card>
          <el-empty v-show="isNoData" :image-size="200" />
        <el-card v-show="!isNoData">
        <el-table
          :data="tableData"
          height="600px"
@@ -192,7 +204,11 @@
            fixed
            show-overflow-tooltip
          />
          <el-table-column prop="name" label="站点名称" show-overflow-tooltip />
            <el-table-column
              prop="name"
              label="站点名称"
              show-overflow-tooltip
            />
          <el-table-column
            prop="mnCode"
@@ -258,7 +274,7 @@
          @update:page-size="handleSizeChange"
        />
      </el-card>
        <el-empty v-show="isNoData" :image-size="200" />
      </el-main>
    </el-container>
  </div>
@@ -272,7 +288,6 @@
  background-color: red;
}
.el-table {
  color: #000000;
  color: #333333;
}
</style>