jinlin
2024-09-06 3ecb68c427a627ad8e90d8c555655e7724be2d96
web/src/views/modules/taskReliability/SimulatAssess.vue
@@ -1,55 +1,45 @@
<template>
  <div class="fa-card-a">
    <el-row :gutter="5">
      <div class="mod-taskReliability-simulatAssess">
        <el-form :inline="true" :model="dataForm" ref="dataForm" :disabled="dataForm.disabled" label-width="80px">
          <zt-form-item label="产品节点" prop="productId">
            <zt-select v-model="dataForm.productId" :datas="productList" @change="onProductSelected"/>
          </zt-form-item>
          <zt-form-item label="总体任务" prop="taskModelId">
            <zt-select v-model="dataForm.taskModelId" :datas="taskList" @change="onTaskSelected"/>
          </zt-form-item>
          <zt-form-item label="采样周期" prop="samplPeriod">
            <el-input type="number" :min="1" v-model="dataForm.samplPeriod">
              <template slot="append">分钟</template>
            </el-input>
          </zt-form-item>
          <zt-form-item label="仿真次数" prop="simulatFrequency">
            <el-input type="number" :min="1" v-model="dataForm.simulatFrequency">
              <template slot="append">次数</template>
            </el-input>
          </zt-form-item>
          <zt-form-item>
            <zt-button @click="analyze()">仿真分析</zt-button>
          </zt-form-item>
        </el-form>
        <el-progress v-if="isShow" :percentage="percentage"></el-progress>
        <div>
      <el-form :inline="true" :model="dataForm" ref="dataForm" :disabled="dataForm.disabled" label-width="80px">
        <zt-form-item label="产品节点" prop="productId">
          <zt-select v-model="dataForm.productId" :datas="productList" @change="onProductSelected"/>
        </zt-form-item>
        <zt-form-item label="总体任务" prop="taskModelId">
          <zt-select v-model="dataForm.taskModelId" :datas="taskList" @change="onTaskSelected"/>
        </zt-form-item>
        <zt-form-item label="时间分片" prop="samplPeriod">
          <el-input type="number" :min="1" v-model="dataForm.samplPeriod">
            <template slot="append">分钟</template>
          </el-input>
        </zt-form-item>
        <zt-form-item label="仿真次数" prop="simulatFrequency">
          <el-input type="number" :min="1" v-model="dataForm.simulatFrequency">
            <template slot="append">次数</template>
          </el-input>
        </zt-form-item>
        <zt-form-item>
          <zt-button @click="analyze()">仿真分析</zt-button>
        </zt-form-item>
      </el-form>
      <el-progress v-if="isShow" :percentage="percentage"></el-progress>
          <el-col :span="4">
            <div style="margin-right: 5px;height: calc(88vh - 100px)"  v-if="isSelect">
              <product-model-tree :isShow="false" ></product-model-tree>
            <div style="margin-right: 5px;height: calc(100vh - 230px)" v-if="isSelect">
              <product-model-tree @on-selected="onTreeSelected" showXdy="false"
                                  ref="ProductModelTree" :isShow="false" basic="4" :productId="dataForm.productId"/>
            </div>
          </el-col>
          <el-col :span="20">
            <div style="margin-top: 20px">
              <div style="margin-left: 400px" v-if="isShow">
                <el-tag type="info" effect="dark" style="font-size: 20px">MTBF:{{MTBF}}</el-tag>
                <el-tag type="info" effect="dark" style="margin-left: 50px;font-size: 20px">MTTR:{{MTTR}}</el-tag>
              </div>
              <div>
            <div  class="fa-card-a" style="height: calc(100vh - 230px)">
                <SimulatCurve ref="SimulatCurve"></SimulatCurve>
              </div>
            </div>
          </el-col>
        </div>
      </div>
    </el-row>
  </div>
</template>
<script>
  import SimulatCurve from "./SimulatCurve";
  import SimulatData from "./SimulatData";
  import ProductModelTree from "../basicInfo/ProductModelTree";
@@ -68,12 +58,11 @@
          id: '',
          pid: '',
          productId: '',
          taskId: '',
          showProductId: '',
          taskModelId: '',
          dataType: '',
          isRepair: '',
          samplPeriod: '',
          simulatFrequency: '',
          dataType: 'fz',
          samplPeriod: '10',
          simulatFrequency: 500,
          simulatTime: ''
        }
      }
@@ -84,31 +73,41 @@
    watch: {
      percentage() {
        if (this.percentage === 100) {
          this.$refs.SimulatCurve.initEcharts(this.dataForm.taskId,this.dataForm.samplPeriod);
          this.$refs.SimulatCurve.initEcharts(this.dataForm);
        }
      }
    },
    components: {
      ProductModelTree,
      SimulatCurve,
      SimulatData
    },
    methods: {
      onTreeSelected(data) {
        if (this.dataForm.id){
          console.log(data, 'onProductSelected')
          this.dataForm.showProductId = data.id
          this.$refs.SimulatCurve.getProductEcharts(this.dataForm);
        }
      },
      // 获取信息
      onProductSelected(data) {
        this.isSelect = true
        console.log(data, ' onProductSelected(data)')
        this.dataForm.productId = data.id
        this.getTaskList()
        this.$nextTick(() => {
          this.$refs.ProductModelTree.getProductList()
        })
      },
      onTaskSelected(data) {
        console.log(data, ' onProductSelected(data)')
        this.dataForm.taskModelId = data.id
      },
      async getProductList() {
        let res = await this.$http.get('/taskReliability/Task/getTaskProductList')
        let res = await this.$http.get('/basicInfo/XhProductModel/getTaskProductList')
        this.productList = res.data
        this.onProductSelected(this.productList[0])
      },
      async getTaskList() {
        let params = {
@@ -119,48 +118,27 @@
        this.taskList = res.data
      },
      getStroke() {
        //console.log('getStroke:',this.progress.start,",",this.progress.speed)
        if (this.percentage < 100) {
          //console.log('getStroke2')
         /* this.$http.get(`sys/common/stroke?progressId=${this.progress.id}`).then(
          this.$http.get(`/taskReliability/SimulatAssess/getCalcProgress?taskId=${this.dataForm.id}`).then(
            res => {
              if (res.success) {
                this.percentage = parseFloat(res.data.percentage)
              if (res.data) {
                this.percentage = parseFloat(res.data)
              }
            }
          )*/
          )
        } else {
          clearInterval(this.timers)
          this.percentage = 0
        }
      },
      async analyze() {
        this.isShow = true
        this.timers = window.setInterval(this.getStroke, 1000)
        /* let res = await this.$http.post('/taskReliability/SimulatAssess/analyze', this.dataForm)
         if (res.success) {
           let stopPolling = false
           if (!stopPolling) {
             let timer = setInterval(async () => {
               let res2 = await this.$http.get(`/taskReliability/SimulatAssess/${res.data}`)
               if (res2.data) {
                 if (res2.data.code === '0' || res2.data.errorMsg === '0') {
                   stopPolling = true
                   // 中止轮询
                   clearInterval(timer)
                   alert('已获取')*/
        //this.$refs.SimulatCurve.initEcharts();
        // 清除定时器
        /*        } else {
                  stopPolling = true
                  // 中止轮询
                  clearInterval(timer)
                  alert('数据有误,重新输入')
                }
              }
            }, 400)
          }
        }*/
        let result = await this.$http.get(`/basicInfo/TyProductModel/getUuid`)
        this.dataForm.id = result.data
        let res = await this.$http.post('/taskReliability/SimulatAssess/analyze', this.dataForm)
        if (res.success) {
          this.timers = window.setInterval(this.getStroke, 1000)
        }
      }
    }
  }