Newer
Older
operation_web / src / components / Engineering / Nowfault.vue
<template>
  <div id="Nowfault">
    <div id="NFTopSearchBox">
      <span class="SelectTitle">请选择项目:</span>
      <el-select
        class="widthinput"
        v-model="Project"
        filterable
        clearable
        placeholder="请选择"
        @change="loadProjectUser(Project)"
      >
        <el-option
          v-for="item in ProjectOptions"
          :key="item.index"
          :label="item.platformName"
          :value="item.platformCode"
        ></el-option>
      </el-select>
      <span class="SelectTitle">请选择站点:</span>
      <el-select
        clearable
        v-model="Site"
        filterable
        placeholder="请选择"
        class="widthinput"
      >
        <el-option
          v-for="item in SiteOptions"
          :key="item.index"
          :label="item.siteName"
          :value="item.siteNo"
        ></el-option>
      </el-select>
      <!-- <span class="SelectTitle">站点查询:</span> -->
      <!-- <el-input
        v-model="condition"
        placeholder="请输入站点名称/编号"
      ></el-input> -->
      <el-button
        type="primary"
        icon="el-icon-search"
        @click="searcher"
        v-has="'Search'"
        >搜索</el-button
      >
    </div>
    <div id="NFCertent">
      <el-table
        :data="HistoryTableData"
        style="width: 100%;height:calc(100% - 45px)"
        v-loading="loading"
        element-loading-text="拼命加载中"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.3)"
      >
        <el-table-column prop="siteNo" label="站点编号"></el-table-column>
        <el-table-column prop="siteName" label="站点名称"></el-table-column>
        <el-table-column prop="fromType" label="上报类型"></el-table-column>
        <el-table-column prop="faultTime" label="上报时间"></el-table-column>
        <el-table-column
          prop="faultValueName"
          label="故障因子"
        ></el-table-column>
      </el-table>
      <el-pagination
        @size-change="SizeChange"
        @current-change="CurrentChange"
        :current-page="Page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="Size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="DataLength"
        style="margin-top:10px;"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  name: "Nowfault",
  data: function() {
    return {
      condition: "",
      HistoryTableData: [], //历史数据表格数据
      Page: 1, //分页默认显示页
      DataLength: 0, //分页上显示的数据总条数
      Size: 10, //分页上显示的每页的条数
      loading: false,
      Project: "", //平台
      userNo: "",
      platCode: "",
      // searchnum: 1,
      ProjectOptions: [
        {
          platformName: "全部",
          platformCode: "",
          dropSiteList: ""
        }
      ],
      Site: "", //平台

      SiteOptions: [
        // {
        //   siteName: "全部",
        //   siteNo: ""
        // }
      ] //平台的数据源
    };
  },
  methods: {
    SizeChange(val) {
      // 改变每页的条数
      this.Size = val;
      this.loadDataGridData();
    },
    CurrentChange(val) {
      //改变页数
      this.Page = val;
      this.loadDataGridData();
    },
    // 获取平台的站点
    loadProjectUser(CODE) {
      this.platCode = CODE;
      this.SiteOptions = [
        {
          siteName: "请先选择项目",
          siteNo: ""
        }
      ];
      this.Site = "";
      for (var i = 0; i < this.ProjectOptions.length; i++) {
        if (this.ProjectOptions[i].platformCode == CODE) {
          this.SiteOptions = this.SiteOptions.concat(
            this.ProjectOptions[i].dropSiteList
          );
          return;
        }
      }
    },
    // 获取所有平台
    loadAllProject() {
      this.$http
        .get(this.nozzle.StationBaseControllerGetPlatFormSiteTree)
        .then(response => {
          if (response.data.data.length > 0) {
            this.ProjectOptions = this.ProjectOptions.concat(
              response.data.data
            );
            this.Project = this.ProjectOptions[0].platformCode;
            this.loadProjectUser(this.ProjectOptions[0].dropSiteList);
          } else {
            this.$message({
              showClose: true,
              message: "无项目",
              type: "warning"
            });
          }
          // this.loadDataGridData();
        })
        .catch(response => {
          this.$message({
            showClose: true,
            message: "请求平台失败",
            type: "warning"
          });
        });
    },
    // 搜索的请求方法
    searcher() {
      this.Page = 1;
      this.loadDataGridData();
    },

    loadDataGridData() {
      this.loading = true;
      this.$http
        .post(this.nozzle.faultInfoGetTempInfo, {
          siteNo: this.Site,
          pageNo: this.Page,
          pageSize: this.Size,
          platCode: this.platCode,
          userNo: this.userNo
        })
        .then(response => {
          this.loading = false;
          this.HistoryTableData = response.data.data;
          this.DataLength = response.data.total;
        })
        .catch(response => {
          this.loading = false;
          this.$message({
            showClose: true,
            message: "请求日志失败",
            type: "warning"
          });
        });
    }
  },
  mounted: function() {
    this.userNo = window.localStorage.getItem("USERNO");
    this.loadAllProject();
    this.loadDataGridData();
  }
};
</script>

<style scoped>
#Nowfault {
  width: 100%;
  height: 100%;
}
/* 顶部搜索 */
#NFTopSearchBox {
  width: 100%;
  height: 60px;
  line-height: 60px;
  text-align: left;
  color: var(--white);
}
#NFTopSearchBox .el-input {
  width: 200px;
  margin: 0 10px;
}
.SelectTitle {
  display: inline-block;
  margin-left: 5px;
  text-align: center;
  height: 60px;

  line-height: 60px;
}
/* 主体内容 */
#NFCertent {
  width: 100%;
  height: calc(100% - 70px);
  margin-top: 10px;
  /* background: rgba(53, 53, 53, 0.5); */
}
</style>