web/src/views/modules/taskReliability/SimulatAssess.vue
@@ -8,37 +8,50 @@
        <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" style="width: 150px;vertical-align: baseline;">
        <zt-form-item label="时间分片" prop="samplPeriod">
          <el-input type="number" :min="1" v-model="dataForm.samplPeriod"
                    style="width: 150px;vertical-align: baseline;">
            <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" style="width: 150px;vertical-align: baseline;">
        <zt-form-item label="仿真次数" prop="simulatFrequency">
          <el-input type="number" :min="1" v-model="dataForm.simulatFrequency"
                    style="width: 150px;vertical-align: baseline;">
            <template slot="append">次数</template>
          </el-input>
        </zt-form-item>
        <el-form-item prop="repairDiracFlag" label-width="150px" style="margin-left: 20px">
          <el-checkbox v-model="dataForm.repairDiracFlag">可修设备可靠度为1</el-checkbox>
        </el-form-item>
        <zt-form-item style="margin-left: 20px">
        <zt-form-item style="margin-left: 10px">
          <zt-button @click="analyze()">仿真分析</zt-button>
          <zt-button @click="displayProcess()">算法库进程</zt-button>
          <el-dropdown style="margin-left: 10px" @command="download">
            <el-button type="primary">
              下载xml<i class="el-icon-arrow-down el-icon--right"></i>
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="1">输入xml</el-dropdown-item>
              <el-dropdown-item command="2">输出xml</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </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(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  class="fa-card-a" style="height: calc(100vh - 230px)">
                <SimulatCurve ref="SimulatCurve"></SimulatCurve>
            </div>
          </el-col>
      <el-col :span="4">
        <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 class="fa-card-a" style="height: calc(100vh - 230px)">
          <SimulatCurve ref="SimulatCurve"></SimulatCurve>
        </div>
      </el-col>
    </el-row>
    <el-dialog v-dialogDrag :close-on-click-modal="false" top="8vh" :visible.sync="dialogVisible" title="模型检查" width="60%" @close="dialogVisible = false">
    <el-dialog v-dialogDrag :close-on-click-modal="false" top="8vh" :visible.sync="dialogVisible" title="模型检查"
               width="60%" @close="dialogVisible = false">
      <el-tag type="danger" style="margin-bottom: 10px">模型定义/参数配置里存在以下问题:</el-tag>
      <el-table :data="modelCheckResult" height="350"
                :header-cell-style="{'text-align':'center'}">
@@ -55,18 +68,22 @@
        <el-button type="primary" @click="dialogVisible = false">关 闭</el-button>
      </div>
    </el-dialog>
    <Process ref="process"></Process>
  </div>
</template>
<script>
  import SimulatCurve from "./SimulatCurve";
  import ProductModelTree from "../basicInfo/ProductModelTree";
  import Process from "./Process";
  import qs from "qs";
  import Cookies from "js-cookie";
  export default {
    data() {
      return {
        timers: '',
        timers: null,
        isSelect: false,
        isShow: false,
        percentage: 0,
@@ -94,20 +111,21 @@
      this.getProductList()
    },
    watch: {
      percentage() {
        if (this.percentage === 100) {
          this.$refs.SimulatCurve.initEcharts(this.dataForm);
        }
      }
      // percentage() {
      //   if (this.percentage === 100) {
      //     this.$refs.SimulatCurve.initEcharts(this.dataForm);
      //   }
      // }
    },
    components: {
      ProductModelTree,
      SimulatCurve,
      Process,
    },
    methods: {
      onTreeSelected(data) {
        if (this.dataForm.id){
        if (this.dataForm.id) {
          console.log(data, 'onProductSelected')
          this.dataForm.showProductId = data.id
          this.$refs.SimulatCurve.getProductEcharts(this.dataForm);
@@ -141,18 +159,20 @@
        console.log(res.data)
        this.taskList = res.data
      },
      getStroke() {
        if (this.percentage < 100) {
          let param = {
            taskList: [this.dataForm.id]
          }
          this.$http.get(`/taskReliability/SimulatAssess/getCalcProgress`, {params: param}).then(
            res => {
              if (res.data) {
                this.percentage = parseFloat(res.data)
              }
      async getStroke() {
        let param = {
          taskList: [this.dataForm.id]
        }
        let res = await this.$http.get(`/taskReliability/SimulatAssess/getCalcProgress`, {params: param})
        if (res.success) {
          if (res.data) {
            this.percentage = parseFloat(res.data)
            if (this.percentage >= 100) {
              clearInterval(this.timers)
              this.percentage = 0
              this.$refs.SimulatCurve.initEcharts(this.dataForm);
            }
          )
          }
        } else {
          clearInterval(this.timers)
          this.percentage = 0
@@ -164,9 +184,10 @@
        this.isShow = true
        let result = await this.$http.get(`/basicInfo/TyProductModel/getUuid`)
        this.dataForm.id = result.data
        this.percentage = 0
        let res = await this.$http.post('/taskReliability/SimulatAssess/analyze', this.dataForm)
        if (res.success) {
          console.log(res.data)
          console.log(res.data, 'res.data')
          if (res.data && res.data.length > 0) {
            this.modelCheckResult = res.data
            this.dialogVisible = true
@@ -174,6 +195,24 @@
            this.timers = window.setInterval(this.getStroke, 1000)
          }
        }
      },
      async download(selsect) {
        if(this.dataForm.id){
          let param = qs.stringify({
            'token': Cookies.get('token'),
            type: 'fz',
            xml:selsect,
            id: this.dataForm.id
          })
          let apiURL = `/taskReliability/SimulatAssess/downloadXml`
          window.location.href = `${window.SITE_CONFIG['apiURL']}${apiURL}?${param}`
        }else{
          this.$alert('还未进行仿真操作')
        }
      },
      displayProcess() {
        this.$refs.process.$refs.dialog.init()
      }
    }
  }