Newer
Older
Nanping_sponge_GCYPG / src / views / dataAnalysis / dataCapability / repairdata / outcomeEvaluation copy.vue
@liyingjing liyingjing on 25 Oct 2023 11 KB 工程预评估
<template>
  <!-- 能力效果对比 -->
  <div class="app-container">
    <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"
          placeholder="请选择站点"
          @change="changeSite"
        >
          <el-option
            v-for="dict in searchSiteList"
            :key="dict.stCode"
            :label="dict.stName"
            :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="请选择锐度">
          <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 HH:mm:ss"
          type="datetimerange"
          range-separator="-"
          start-placeholder="开始周期"
          end-placeholder="结束周期"
        ></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="fex flex-r">
      <div class="flex flex-1"></div>
    </div> -->
    <el-table
      v-loading="loading"
      :data="rtuSiteInfoList"
      border
      :height="250"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column
        prop="typeName"
        label="修复类型"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="st"
        label="站点编号"
        align="center"
      ></el-table-column>
      <el-table-column
        prop="tt"
        label="观测时间"
        align="center"
      ></el-table-column>
      <!-- <el-table-column
        prop="propertyName"
        label="因子"
        min-width="150px"
      ></el-table-column> -->

      <el-table-column
        prop="originalValue"
        label="原始数据"
        align="center"
      ></el-table-column>
      <el-table-column prop="resultNote" label="修复值" align="center">
        <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="修复状态" align="center">
        <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="修复时间"
        min-width="150px"
        align="center"
      ></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 class="back-empty"></div>
    <div class="bottomcontent flex flex-r">
      <div class="flex flex-1 flex-v" style="height: 100%; background: #ffffff">
        <div
          class="bottomcontent-title"
          v-if="echartOriginalData.xAxisData.length == 0"
        >
          {{ echartOriginalData.title }}
        </div>
        <lineChart
          v-if="echartOriginalData.xAxisData.length"
          :refresh="refresh"
          :title="echartOriginalData.title"
          :echartData="echartOriginalData"
        ></lineChart>

        <empty v-else emptyText="暂无数据" :width="100" :height="100"></empty>
      </div>
      <div
        class="flex flex-1 flex-v"
        style="height: 100%; background: #ffffff; margin-left: 10px"
      >
        <div
          class="bottomcontent-title"
          v-if="echartRepairData.xAxisData.length == 0"
        >
          {{ echartRepairData.title }}
        </div>
        <lineChart
          v-if="echartRepairData.xAxisData.length"
          :refresh="refresh"
          :title="echartRepairData.title"
          :echartData="echartRepairData"
        ></lineChart>
        <empty
          v-else
          :emptyText="`暂无数据`"
          :width="100"
          :height="100"
        ></empty>
      </div>
    </div>
  </div>
</template>

<script setup name="RtuSiteInfo">
import {
  pageRepairRecord,
  listRepairAllSite,
  listSiteSupportedProperty,
  originalRepairHistory,
} from "@/api/dataAnalysis/repairdata";
import { listrtuSiteInfo } from "@/api/dataAnalysis/rtuSiteInfo";
import lineChart from "@/components/Echarts/lineChart";
import { findDictObj } from "@/utils/ruoyi.js";
const { proxy } = getCurrentInstance();
const siteTypes = proxy.fixDict["siteTypes"]; //站点类型
const repairGrades = proxy.fixDict["repairGrades"]; //锐度
const activeName = ref("first");
const rtuSiteInfoList = ref([]);
const open = ref(false);
const loading = ref(false);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const currentRow = ref({});
const searchSiteList = ref([]); //站点搜索列表
const propertyList = ref([]); //因子列表
const refresh = ref(1);
const data = reactive({
  queryParams: {
    pageNo: 1,
    pageSize: 10,
    st: null,
    repairGrade: "Middle",
    property: null,
    dateRange: ["2023-03-29 00:00:00", "2023-03-30 00:00:00"],
  },
  //修复前
  echartOriginalData: {
    xAxisData: [],
    seriesData: [],
    seriesName: "",
    title: "",
  },
  //修复后
  echartRepairData: {
    xAxisData: [],
    seriesData: [],
    seriesName: "",
    title: "",
  },
});

const { queryParams, echartOriginalData, echartRepairData } = toRefs(data);

//获取站点列表
function getSearchSiteList() {
  listRepairAllSite({ platformCode: 111211 }).then((res) => {
    searchSiteList.value = res.data;
    queryParams.value.st = searchSiteList.value.length
      ? searchSiteList.value[0].stCode
      : "";
    changeSite();
    // propertyList.value = searchSiteList.value.length
    //   ? searchSiteList.value[0].siteRepairPropertyConfigList
    //   : [];
    // queryParams.value.property = propertyList.value.length
    //   ? propertyList.value[0].property
    //   : "";
    // echartOriginalData.value.seriesName = echartRepairData.value.seriesName =
    //   propertyList.value.length ? propertyList.value[0].propertyName : "";
    // echartOriginalData.value.title = propertyList.value.length
    //   ? propertyList.value[0].propertyName + "修复前"
    //   : "";
    // echartRepairData.value.title = propertyList.value.length
    //   ? propertyList.value[0].propertyName + "修复后(修复结果有1-2小时延迟)"
    //   : "";
    if (queryParams.value.st && queryParams.value.property) {
      getList();
      getOriginalRepairHistory();
    } else {
      rtuSiteInfoList.value = [];
      total.value = 0;
      echartRepairData.value.xAxisData = echartOriginalData.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
  );
  echartOriginalData.value.seriesName = echartRepairData.value.seriesName =
    obj.propertyName;
  echartOriginalData.value.title = obj.propertyName + "修复前";
  echartRepairData.value.title =
    obj.propertyName + "修复后(修复结果有1-2小时延迟)";
}

/** 列表查询原始/修复后历史数据 */
function getList() {
  loading.value = true;
  let params = proxy.formatAddDateRange(
    queryParams.value,
    queryParams.value.dateRange,
    "startDatetime",
    "endDatetime"
  );
  pageRepairRecord(params).then((response) => {
    rtuSiteInfoList.value = response.data;
    echartOriginalData.value.seriesName = echartRepairData.value.seriesName =
      rtuSiteInfoList.value.length ? rtuSiteInfoList.value[0].propertyName : "";

    total.value = response.total;
    loading.value = false;
  });
}

//分页查站点修复记录
function getOriginalRepairHistory() {
  let params = proxy.formatAddDateRange(
    queryParams.value,
    queryParams.value.dateRange,
    "startDate",
    "endDate"
  );
  params.queryRepairDataFlag = "1";

  originalRepairHistory(params).then((res) => {
    if (res.data.length) {
      echartRepairData.value.xAxisData = echartOriginalData.value.xAxisData =
        res.data.map((item) => {
          return item.date;
        });
      echartOriginalData.value.seriesData = res.data.map((item) => {
        return item.originalData;
      });
      echartRepairData.value.seriesData = res.data.map((item) => {
        return item.repairData;
      });
    } else {
      echartRepairData.value.xAxisData = echartOriginalData.value.xAxisData =
        [];
    }
    refresh.value = Math.random();
  });
}

/** 搜索按钮操作 */
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
    : "";
  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;
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value;
  proxy.$modal
    .confirm("是否确认删除?")
    .then(function () {
      return delrtuSiteInfo(_ids);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => {});
}
onMounted(() => {
  //refresh.value = Math.random();
});
getSearchSiteList();
</script>
<style lang="scss" scoped>
.bottomcontent {
  width: 100%;
  height: calc(100vh - 580px);
  background: #f8f8f9;
}
.bottomcontent-title {
  font-size: 16px;
  font-weight: bold;
  color: #545e75;
  margin-top: 20px;
  padding-left: 20px;
  padding-bottom: 100px;
}
.back-empty {
  width: 100%;
  height: 10px;
  background: #f8f8f9;
}
</style>