Newer
Older
Nanping_sponge_SJJC / src / views / dataAnalysis / dataCapability / repairdata / outcomeEvaluation.vue
@liyingjing liyingjing on 25 Oct 2023 9 KB 数据检测
<template>
  <!-- 能力效果对比 -->
  <div class="outComEvaluation">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="" prop="st">
        <el-select v-model="queryParams.st" filterable placeholder="请选择站点" @change="changeSite" style="width: 380px">
          <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="property">
        <el-select v-model="queryParams.property" placeholder="请选择因子" @change="changeProperty">
          <el-option
            v-for="item in propertyList"
            :key="item.property"
            :label="item.propertyName"
            :value="item.property"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="repairGrade">
        <el-select v-model="queryParams.repairGrade" placeholder="请选择锐度" style="width: 90px">
          <el-option v-for="dict in repairGrades" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="" prop="dateRange">
        <el-date-picker
          v-model="queryParams.dateRange"
          value-format="YYYY-MM-DD"
          type="daterange"
          range-separator="-"
          start-placeholder="开始周期"
          end-placeholder="结束周期"
          :clearable="false"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <div class="flex flex-r">
      <div class="flex" style="width: 900px; position: relative">
        <el-table v-loading="loading" :data="rtuSiteInfoList" border max-height="600px" @selection-change="handleSelectionChange">
          <el-table-column prop="typeName" label="修复类型" show-overflow-tooltip></el-table-column>
          <el-table-column prop="st" label="站点编号" show-overflow-tooltip width="110"></el-table-column>
          <el-table-column prop="tt" label="观测时间" width="180"></el-table-column>
          <el-table-column prop="originalValue" label="原始数据" width="90"></el-table-column>
          <el-table-column prop="resultNote" label="修复值" show-overflow-tooltip>
            <template #default="scope">
              <span v-if="scope.row.repairResult == 'SUCCESS'">{{ scope.row.repairValue }}</span>
              <span v-if="scope.row.repairResult == 'FAIL'">{{ scope.row.resultNote }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="repairResult" label="修复状态" width="90">
            <template #default="scope">
              <span v-if="scope.row.repairResult == 'SUCCESS'">成功</span>
              <span v-if="scope.row.repairResult == 'FAIL'" style="color: red">失败</span>
            </template>
          </el-table-column>
          <el-table-column prop="createDatetime" label="修复时间" width="180"></el-table-column>
        </el-table>
        <pagination
          v-show="total > 0"
          :total="total"
          v-model:page="queryParams.pageNo"
          v-model:limit="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
      <div class="flex flex-1">
        <div class="back-empty"></div>
        <div class="bottomcontent flex flex-v">
          <div class="flex flex-1 flex-v" style="height: 100%; background: #ffffff" v-loading="echartLoading">
            <lineChart
              v-if="echartData.xAxisData.length"
              :refresh="refresh"
              :title="echartData.title"
              :echartData="echartData"
            ></lineChart>
            <empty v-else emptyText="暂无数据" :width="100" :height="100" style="margin-top: 50px"></empty>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { pageRepairRecord, listRepairAllSite, originalRepairHistory } from '@/api/dataAnalysis/repairdata';

import lineChart from '@/components/Echarts/lineChart';
import { findDictObj } from '@/utils/ruoyi.js';
const { proxy } = getCurrentInstance();
const repairGrades = proxy.fixDict['repairGrades']; //锐度
const rtuSiteInfoList = ref([]);
const loading = ref(false);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const searchSiteList = ref([]); //站点搜索列表
const propertyList = ref([]); //因子列表
const refresh = ref(1);
const echartLoading = ref(false);
const props = defineProps({
  //站点code
  stCode: {
    type: [Number, String],
    default: '',
  },
  //当前行数据
  rowData: {
    type: Object,
    default: {},
  },
  //刷新标识
  refresh: {
    type: Number,
    default: 1,
  },
});

const data = reactive({
  queryParams: {
    pageNo: 1,
    pageSize: 10,
    st: null,
    repairGrade: 'Middle',
    property: null,
    platformCode: 111211,
    dateRange: [proxy.moment(new Date()).subtract(1, 'days').format('YYYY-MM-DD'), proxy.moment().format('YYYY-MM-DD')],
  },
  //修复前
  echartData: {
    xAxisData: [],
    seriesData1: [], //修复前
    seriesData2: [], //修复后
    seriesName: '',
    title: '',
  },
});

const { queryParams, echartData } = toRefs(data);
watch(
  () => props.refresh,
  value => {
    if (props.refresh != 1) {
      queryParams.value.dateRange = [props.rowData.startDatetime, props.rowData.endDatetime];
      getSearchSiteList();
    }
  },
  {
    immediate: true,
  }
);

//获取站点列表
function getSearchSiteList() {
  listRepairAllSite({ platformCode: 111211 }).then(res => {
    searchSiteList.value = res.data;
    queryParams.value.st = props.stCode ? props.stCode : searchSiteList.value.length ? searchSiteList.value[0].stCode : '';
    changeSite();
    if (queryParams.value.st && queryParams.value.property) {
      getList();
      getOriginalRepairHistory();
    } else {
      rtuSiteInfoList.value = [];
      total.value = 0;
      echartData.value.xAxisData = [];
      refresh.value = Math.random();
    }
  });
}

//切换站点
function changeSite() {
  propertyList.value = findDictObj(queryParams.value.st, 'stCode', searchSiteList.value).siteRepairPropertyConfigList;
  queryParams.value.property = propertyList.value.length ? propertyList.value[0].property : '';
  changeProperty();
}

//切换因子
function changeProperty() {
  let obj = findDictObj(queryParams.value.property, 'property', propertyList.value);
  echartData.value.seriesName = obj.propertyName;
  echartData.value.yAxisName1 = obj.propertyName + '修复前';
  echartData.value.yAxisName2 = obj.propertyName + '修复后(修复结果有1-2小时延迟)';
}

/** 列表查询原始/修复后历史数据 */
function getList() {
  loading.value = true;
  let params = { ...queryParams.value };
  params.startDatetime = queryParams.value.dateRange[0] + ' 00:00:00';
  params.endDatetime = queryParams.value.dateRange[1] + ' 23:59:59';
  pageRepairRecord(params).then(response => {
    rtuSiteInfoList.value = response.data;
    total.value = response.total;
    loading.value = false;
  });
}

//分页查站点修复记录
function getOriginalRepairHistory() {
  echartLoading.value = true;
  let params = { ...queryParams.value };
  params.startDate = queryParams.value.dateRange[0] + ' 00:00:00';
  params.endDate = queryParams.value.dateRange[1] + ' 23:59:59';
  params.queryRepairDataFlag = '1';

  originalRepairHistory(params).then(res => {
    if (res.data.length) {
      echartData.value.xAxisData = res.data.map(item => {
        return item.date;
      });
      echartData.value.seriesData1 = res.data.map(item => {
        return item.originalData;
      });
      echartData.value.seriesData2 = res.data.map(item => {
        return item.repairData;
      });
    } else {
      echartData.value.xAxisData = [];
    }
    refresh.value = Math.random();
    echartLoading.value = false;
  });
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNo = 1;
  if (queryParams.value.repairGrade && queryParams.value.st && queryParams.value.property) {
    getList();
    getOriginalRepairHistory();
  }
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  queryParams.value.repairGrade = 'Middle';
  queryParams.value.st = searchSiteList.value.length ? searchSiteList.value[0].stCode : '';
  changeSite();
  //   queryParams.value.property = propertyList.value.length
  //     ? propertyList.value[0].code
  //     : "";
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

onMounted(() => {
  //refresh.value = Math.random();
  if (props.refresh == 1) {
    getSearchSiteList();
  }
});
</script>
<style lang="scss" scoped>
.bottomcontent {
  width: 100%;
  height: calc(100vh - 230px);
  background: #f8f8f9;
}
.bottomcontent-title {
  font-size: 16px;
  font-weight: bold;
  color: #545e75;
  margin-top: 20px;
  padding-left: 20px;
  padding-bottom: 100px;
}
.back-empty {
  width: 10px;
  height: 100%;
  background: #f8f8f9;
}
::v-deep(.pagination-container .el-pagination) {
  bottom: 30px;
}
</style>