jinlin
2024-09-26 089b302259e03ce52fc102bcf168d1fa048fffe9
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<template>
  <div class="fa-card-a">
    <el-row :gutter="5">
      <el-form :inline="true" :model="dataForm" ref="dataForm" :disabled="dataForm.disabled">
        <zt-form-item label="产品节点" prop="productId" width="100px">
          <zt-select v-model="dataForm.productId" :datas="productList" @change="onProductSelected"/>
        </zt-form-item>
        <zt-form-item label="可靠性方案" prop="taskModelId" width="500px">
          <zt-select style="width: 400px" v-model="dataForm.taskModelId" :datas="schemeList"
                     @change="onTaskSelected" :multiple="true"/>
        </zt-form-item>
        <zt-form-item>
          <zt-button @click="compair()">方案对比</zt-button>
        </zt-form-item>
      </el-form>
      <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="position: relative;height: calc(100vh - 230px)">
          <div v-if="isShow">
            <el-button v-if="isZk" type="info" size="small" icon="el-icon-caret-bottom"
                       style="position: absolute;right: 10%;top: 9%;z-index: 1" @click="zk()"></el-button>
            <el-button v-if="!isZk" type="info" size="small" icon="el-icon-caret-right"
                       style="position: absolute;right: 10%;top: 9%;z-index: 1" @click="zk()"></el-button>
            <div v-if="isZk" style="position: absolute;right: 10%;top: 13%">
              <el-table :data="tableData" border style="width: 500px">
                <el-table-column
                  prop="name"
                  label="方案名称"
                >
                </el-table-column>
                <el-table-column
                  prop="mtbf"
                  label="MTBF"
                  width="100px"
                  align="right">
                  <template slot-scope="scope">
                    <span>{{  keepNumber(scope.row.mtbf) }}</span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="mttr"
                  label="MTTR"
                  width="100px"
                  align="right">
                  <template slot-scope="scope">
                    <span>{{  keepNumber(scope.row.mttr) }}</span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="msr"
                  label="MSR"
                  width="100px"
                  align="right">
                  <template slot-scope="scope">
                    <span>{{  keepNumber(scope.row.mttr) }}</span>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
          <div :disabled="isShow">
            <div class="echart" id="SchemeCompar" :style="myChartStyle"></div>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
 
<script>
  import ProductModelTree from "../basicInfo/ProductModelTree";
  import echart from "echarts";
 
 
  export default {
    data() {
      return {
        myChartStyle: {float: "left", width: "100%", height: "600px"}, //图表样式
        isSelect: false,
        isShow: false,
        isZk: true,
        productList: [],
        schemeList: [],
        dataForm: {
          id: '',
          taskModelId: [],
          productId: '',
          showProductId: '',
          dataType: 'fz',
        },
        xDataList: [],
        seriesList: [],
        tableData: [],
        taskList: [],
      }
    },
    mounted() {
      this.getProductList()
    },
    computed: {
      keepNumber() { //过滤器保留4为小数
        return function (val) {        // 对计算属性进行传参
          const numM = Number(val).toFixed(5);
          return numM.substring(0, numM.length - 1);
        }
      },
    },
    components: {
      ProductModelTree,
    },
 
    methods: {
      onTreeSelected(data) {
        if (this.dataForm.taskModelId.length > 0) {
          console.log(this.dataForm.taskModelId)
          console.log(data, 'onProductSelected')
          this.dataForm.showProductId = data.id
          this.$nextTick(() => {
            this.compair()
          })
        }
      },
      // 获取信息
      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, 'onTaskSelected(data)')
        for (let item of data) {
          this.taskList.push(item.name)
        }
      },
      zk() {
        this.isZk = !this.isZk;
      },
      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.schemeList = res.data
      },
      async compair() {
        let params = {
          taskList: this.dataForm.taskModelId,
          showProductId: this.dataForm.showProductId
        }
        console.log(this.dataForm.taskModelId, 'this.dataForm.taskModelId')
        let res = await this.$http.get('/taskReliability/SimulatAssess/SchemeCompar', {params: params})
        console.log(res.data, "res")
        this.xDataList = res.data.xdataList
        this.seriesList = res.data.curveList
        this.tableData = res.data.dataList
 
        this.isShow = true
        this.option = {
          xAxis: {
            data: this.xDataList,
            name: '仿真总时长',
            type: 'category',
            axisLabel: {
              formatter: function (value) {
                // 将 X 轴刻度值格式化为保留两位小数的字符串
                return parseFloat(value).toFixed(2);
              }
            }
          },
          yAxis: {
            type: 'value',
            name: '可靠度',
          },
          legend: {
            data: this.taskList
          },
          series: this.seriesList
        };
        this.myChart = echart.init(document.getElementById("SchemeCompar"));
        console.log(this.option, ' this.option ')
        this.myChart.setOption(this.option);
        //随着屏幕大小调节图表
        window.addEventListener("resize", () => {
          this.myChart.resize();
        });
      }
    }
  }
</script>
<style>
 
</style>