Newer
Older
Nanping_sponge_GCYPG / src / views / dataAnalysis / dataCapability / repairdata / outcomeEvaluation.vue
@liyingjing liyingjing on 25 Oct 2023 10 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="请选择锐度"
          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 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="flex flex-r">
      <div class="flex" style="width: 800px; position: relative">
        <el-table
          v-loading="loading"
          :data="rtuSiteInfoList"
          border
          max-height="600px"
          @selection-change="handleSelectionChange"
        >
          <!-- <el-table-column type="selection" width="55"></el-table-column> -->
          <el-table-column
            prop="typeName"
            label="修复类型"
            align="center"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="st"
            label="站点编号"
            align="center"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="tt"
            label="观测时间"
            align="center"
            width="170"
          ></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"
            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="修复状态" 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="修复时间"
            align="center"
            width="170"
          ></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"
          >
            <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,
  listSiteSupportedProperty,
  originalRepairHistory,
} from "@/api/dataAnalysis/repairdata";

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 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,
    dateRange: ["2023-03-29 00:00:00", "2023-03-30 00:00:00"],
  },
  //修复前
  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 = proxy.formatAddDateRange(
    queryParams.value,
    queryParams.value.dateRange,
    "startDatetime",
    "endDatetime"
  );
  pageRepairRecord(params).then((response) => {
    rtuSiteInfoList.value = response.data;
    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) {
      echartData.value.xAxisData = res.data.map((item) => {
        return item.date;
      });
      echartData.value.seriesData1 = res.data.map((item) => {
        return item.originalData;
      });
      console.log(echartData.value.seriesData1);
      echartData.value.seriesData2 = res.data.map((item) => {
        return item.repairData;
      });
    } else {
      echartData.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
    : "";
  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;
}

/** 删除按钮操作 */
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();
  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: 20px;
}
</style>