jinlin
2024-07-17 3c15e684416e06a7351eeb2d756e5be778a893fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<template>
  <div>
    <el-row :gutter="5">
      <el-col :span="5">
        <div class="fa-card-a" style="margin-right: 5px;height: calc(100vh - 123px)">
          <product-model-tree ref="modelTree" @on-selected="onProductSelected" @on-default="onDefault" showXdy="false"
                              basic="3" :isShow="false"/>
        </div>
      </el-col>
      <el-col :span="19">
        <div class="mod-baseReliability-paramDataBasic fa-card-a" style="margin-left: 5px;">
          <zt-table-wraper :defaultNotQuery='true' ref="tableObj" query-url="/baseReliability/ParamDataBasic/page"
                           delete-url="/baseReliability/ParamDataBasic"
                           v-slot="{ table }" :paging='false'>
            <el-form :inline="true" :model="dataForm" @keyup.enter.native="table.query()">
              <el-form-item>
                <!--<zt-button type="query" @click="table.query()"/>
                <zt-button type="add" perm="baseReliability:add" @click="table.editHandle()"/>
                <zt-button type="delete" perm="baseReliability:delete" @click="table.deleteHandle()"/>-->
                <zt-button type="primary" @click="recalculate()">重新计算</zt-button>
              </el-form-item>
            </el-form>
            <el-table v-loading="table.dataLoading" :data="table.dataList" height="100px" v-adaptive="{bottomOffset:70}"
                      row-key="id"
                      :expand-row-keys="defultKey"
                      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                      border @selection-change="table.selectionChangeHandle">
              <!--<el-table-column type="selection" width="40"/>-->
              <el-table-column prop="name" label="名称"/>
              <el-table-column prop="basicMtbfRegulate" label="MTBF" align="right">
                <template slot-scope="scope">
                  <span>{{ scope.row.basicMtbfRegulate | keepNumber }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="repairMttcr" label="MTTR" align="right">
                <template slot-scope="scope">
                  <span>{{ scope.row.repairMttcr | keepNumber }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="basicMtbfOperatingRatio" label="运行比" align="right">
                <template slot-scope="scope">
                  <span>{{ scope.row.basicMtbfOperatingRatio | keepNumber }}</span>
                </template>
              </el-table-column>
              <el-table-column prop="ai" label="可用度" align="right">
                <template slot-scope="scope">
                  <span>{{ scope.row.ai | keepNumber }}</span>
                </template>
              </el-table-column>
            </el-table>
          </zt-table-wraper>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import ProductModelTree from "../basicInfo/ProductModelTree";
 
  export default {
    data() {
      return {
        dataForm: {
          shipId: '',
          isRecal: 0,
          basicMtbfRegulate: '',
          repairMttcr: '',
          basicMtbfOperatingRatio: '',
          ai: ''
        },
        defultKey: []
      }
    },
    components: {
      ProductModelTree,
    },
    filters: {
      keepNumber(value) { //过滤器保留4为小数
        const numM = Number(value).toFixed(5);
        if (numM === "NaN") {
          return "0.0000";
        }
        if (numM === '0.0000' && value > 0) {
 
        }
        const realVal = numM.substring(0, numM.length - 1);
        return realVal;
      },
    },
    methods: {
      onProductSelected(data) {
        this.defultKey = []
        this.dataForm.shipId = data.id
        this.dataForm.productType = data.productType
        console.log(data, 'onProductSelected(data)')
        this.$nextTick(() => {
          this.$refs.tableObj.query()
          this.setDefultKey()
        })
      },
      setDefultKey() {
        this.defultKey.push(this.dataForm.shipId + "")
      },
      onDefault(defaultId) {
        this.dataForm.shipId = defaultId
        this.$nextTick(() => {
          this.$refs.tableObj.query()
          this.setDefultKey()
        })
      },
      async recalculate() {
        this.dataForm.isRecal = 1
        this.$nextTick(() => {
          this.$refs.tableObj.query()
        })
      },
    }
  }
</script>