xyc
2024-08-02 7abc95a191d2c1a9bb9ff8fd7fb05470a0d4e86b
web/src/views/modules/taskReliability/SimulatAssess.vue
@@ -26,16 +26,13 @@
        <el-progress v-if="isShow" :percentage="percentage"></el-progress>
        <div>
          <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(88vh - 100px)" 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>
                <SimulatCurve ref="SimulatCurve"></SimulatCurve>
              </div>
@@ -49,7 +46,6 @@
<script>
  import SimulatCurve from "./SimulatCurve";
  import SimulatData from "./SimulatData";
  import ProductModelTree from "../basicInfo/ProductModelTree";
@@ -68,10 +64,9 @@
          id: '',
          pid: '',
          productId: '',
          taskId: '',
          showProductId: '',
          taskModelId: '',
          dataType: '',
          isRepair: '',
          dataType: 'fz',
          samplPeriod: '',
          simulatFrequency: '',
          simulatTime: ''
@@ -84,30 +79,39 @@
    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
      },
      async getTaskList() {
@@ -122,45 +126,27 @@
        //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)
              // console.log(res.data, 'res.data')
              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)
        }
      }
    }
  }