xyc
2024-08-16 33246bb56e05b273944ec1cc03a58dc112e48848
web/src/views/modules/taskReliability/ReliabilityWeakness.vue
New file
@@ -0,0 +1,147 @@
<template>
  <div>
    <div class="mod-baseReliability-paramDataBasic fa-card-a" style="margin-left: 5px;">
      <zt-table-wraper :defaultNotQuery='true' ref="tableObj" v-slot="{ table }" :paging='false'>
        <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="simulatHis">
            <zt-select v-model="dataForm.fzId" :datas="simulatList" @change="onSimulatSelected"/>
          </zt-form-item>
        </el-form>
        <el-table v-loading="table.dataLoading" :data="dataList" height="100px" v-adaptive="{bottomOffset:70}"
                  row-key="id"
                  :expand-row-keys="defultKey"
                  :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                  :header-cell-style="{'text-align':'center'}"
                  :row-style="rowStyle"
                  border @selection-change="table.selectionChangeHandle">
          <el-table-column prop="name" label="名称"/>
          <el-table-column prop="mtbf" label="MTBF" align="right">
            <template slot-scope="scope">
              <span>{{  keepNumber(scope.row.mtbf) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="mttr" label="MTTR" align="right">
            <template slot-scope="scope">
              <span>{{  keepNumber(scope.row.mttr) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="msr" label="任务成功度" align="right">
            <template slot-scope="scope">
              <span>{{keepNumber(scope.row.msr) }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="timeRate" label="任务时间比" align="right">
            <template slot-scope="scope">
              <span>{{  keepNumber(scope.row.timeRate) }}</span>
            </template>
          </el-table-column>
        </el-table>
      </zt-table-wraper>
    </div>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        productList: [],
        simulatList: [],
        dataList: [],
        taskList: [],
        dataForm: {
          name: '',
          fzId: '',
          shipId: '',
          mtbf: '',
          mttr: '',
          msr: '',
          timeRate: ''
        },
        defultKey: []
      }
    },
    computed: {
      keepNumber() { //过滤器保留4为小数
        return function (val) {      // 对计算属性进行传参
          const numM = Number(val).toFixed(5);
          return numM.substring(0, numM.length - 1);
        }
      },
    },
    mounted() {
      this.getProductList()
    },
    methods: {
      async getProductList() {
        let res = await this.$http.get('/basicInfo/XhProductModel/getTaskProductList')
        this.productList = res.data
        this.onProductSelected(this.productList[0])
      },
      async getTaskList() {
        let params = {
          productId: this.dataForm.productId
        }
        let res = await this.$http.get('/taskReliability/Task/getTaskList', {params: params})
        console.log(res.data)
        this.taskList = res.data
        this.onTaskSelected(this.taskList[0])
      },
      async getSimulatList() {
        let params = {
          productId: this.dataForm.productId,
          taskModelId: this.dataForm.taskModelId
        }
        let res = await this.$http.get('/taskReliability/SimulatAssess/getSimulatList', {params: params})
        console.log(res.data)
        this.simulatList = res.data
        this.$nextTick(() => {
          this.onSimulatSelected(this.simulatList[0])
        })
      },
      // 获取信息
      onProductSelected(data) {
        this.isSelect = true
        console.log(data, ' onProductSelected(data)')
        this.dataForm.productId = data.id
        this.getTaskList()
        this.dataForm.taskModelId = ''
      },
      onTaskSelected(data) {
        console.log(data, ' onProductSelected(data)')
        this.dataForm.taskModelId = data.id
        this.getSimulatList()
        this.dataForm.fzId = ''
      },
      setDefultKey() {
        this.defultKey.push(this.dataForm.productId + "")
      },
      async onSimulatSelected(data) {
        this.dataForm.fzId = data.id
        this.dataForm.samplPeriod = data.samplPeriod
        let params = {
          fzId: this.dataForm.fzId,
          taskId:this.dataForm.taskModelId,
          productId:this.dataForm.productId
        }
        let res = await this.$http.get('/taskReliability/SimulatAssess/ReliabilityWeakness', {params: params})
        this.dataList = res.data
        this.setDefultKey()
        console.log(this.dataList)
      },
      rowStyle({row,rowIndex}) {
        console.log(row)
        if (row.isWeak===1){
          console.log(row.isWeak,"console.log(row)")
          return {color: 'red'}
        }
      },
    }
  }
</script>