From bcd950216084a6208de0c636f9430e47601acc01 Mon Sep 17 00:00:00 2001 From: jinlin <jinlin> Date: 星期五, 26 七月 2024 08:30:23 +0800 Subject: [PATCH] 修改 --- web/src/views/modules/taskReliability/SimulatCurve.vue | 103 +++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 79 insertions(+), 24 deletions(-) diff --git a/web/src/views/modules/taskReliability/SimulatCurve.vue b/web/src/views/modules/taskReliability/SimulatCurve.vue index b56b0ec..d688c1b 100644 --- a/web/src/views/modules/taskReliability/SimulatCurve.vue +++ b/web/src/views/modules/taskReliability/SimulatCurve.vue @@ -1,11 +1,11 @@ <template> <div class="mod-taskReliability-taskPhase"> - <div class="echart" id="mychart" :style="myChartStyle"></div> + <div class="echart" id="myChart" :style="myChartStyle"></div> </div> </template> <script> - import * as echarts from "echarts"; + import echart from "echarts"; export default { name: 'SimulatCurve', @@ -13,6 +13,8 @@ return { xDataList: [], yDataList: [], + mttr: '', + mtbf: '', myChart: {}, myChartStyle: {float: "left", width: "100%", height: "600px"}, //鍥捐〃鏍峰紡 option: {} @@ -20,48 +22,101 @@ }, components: {}, methods: { - initEcharts(id,taskId, samplPeriod) { + async initEcharts(Param) { + let res = await this.$http.post(`/taskReliability/SimulatAssess/getResultXML`, Param) + console.log(res.data) + if (res.data) { + this.yDataList = res.data.curveParam.ydata + this.xDataList = res.data.curveParam.xdata + this.mttr = res.data.mttr.toFixed(4) + this.mtbf = res.data.mtbf.toFixed(4) + } this.option = { title: { - text: '', + text: "mttr:" + this.mttr + " mtbf:" + this.mtbf, textStyle: { // 涓绘爣棰樻枃鏈牱寮弡"fontSize": 18,"fontWeight": "bolder","color": "#333"} fontFamily: 'Arial', - fontSize: 20, + fontSize: 30, fontStyle: 'normal', fontWeight: 'normal', - } + }, + textAlign:'auto',//鏁翠綋锛堝寘鎷� text 鍜� subtext锛夌殑姘村钩瀵归綈 + textVerticalAlign:'auto',//鏁翠綋锛堝寘鎷� text 鍜� subtext锛夌殑鍨傜洿瀵归綈 + padding:0,//[5,10] | [ 5,6, 7, 8] ,鏍囬鍐呰竟璺� + left:'center',//'5' | '5%'锛宼itle 缁勪欢绂诲鍣ㄥ乏渚х殑璺濈 + right:'auto',//'title 缁勪欢绂诲鍣ㄥ彸渚х殑璺濈 + top:'auto',//title 缁勪欢绂诲鍣ㄤ笂渚х殑璺濈 + bottom:'auto',//title 缁勪欢绂诲鍣ㄤ笅渚х殑璺濈 }, xAxis: { - data: [], + data: this.xDataList, name: '浠跨湡娆℃暟' }, - yAxis: {}, + yAxis: { + + name: '', + }, series: [ { - data: [], + data: this.yDataList, type: 'line', smooth: true } ] }; - this.getEchart(id,taskId, samplPeriod) + this.myChart = echart.init(document.getElementById("myChart")); + console.log(this.option, ' this.option ') + this.myChart.setOption(this.option); + //闅忕潃灞忓箷澶у皬璋冭妭鍥捐〃 + window.addEventListener("resize", () => { + this.myChart.resize(); + }); }, - async getEchart(id,taskId, samplPeriod) { - let task = await this.$http.get(`/taskReliability/Task/${taskId}`) - samplPeriod = samplPeriod / 60 - let i = 0 - for (i = 0; i + samplPeriod <= task.taskDuration; i += samplPeriod) { - this.series[0].data.push(i); + async getProductEcharts(Param) { + let res = await this.$http.post(`/taskReliability/SimulatAssess/getResultData`, Param) + console.log(res.data) + if (res.data) { + this.yDataList = res.data.curveParam.ydata + this.xDataList = res.data.curveParam.xdata + this.mttr = res.data.mttr.toFixed(4) + this.mtbf = res.data.mtbf.toFixed(4) } - if (i !== task.taskDuration) { - this.series[0].data.push(task.taskDuration); - } + this.option = { + title: { + text: "mttr:" + this.mttr + " mtbf:" + this.mtbf, + textStyle: { // 涓绘爣棰樻枃鏈牱寮弡"fontSize": 18,"fontWeight": "bolder","color": "#333"} + fontFamily: 'Arial', + fontSize: 30, + fontStyle: 'normal', + fontWeight: 'normal', + }, + textAlign: 'auto',//鏁翠綋锛堝寘鎷� text 鍜� subtext锛夌殑姘村钩瀵归綈 + textVerticalAlign: 'auto',//鏁翠綋锛堝寘鎷� text 鍜� subtext锛夌殑鍨傜洿瀵归綈 + padding: 0,//[5,10] | [ 5,6, 7, 8] ,鏍囬鍐呰竟璺� + left: 'center',//'5' | '5%'锛宼itle 缁勪欢绂诲鍣ㄥ乏渚х殑璺濈 + right: 'auto',//'title 缁勪欢绂诲鍣ㄥ彸渚х殑璺濈 + top: 'auto',//title 缁勪欢绂诲鍣ㄤ笂渚х殑璺濈 + bottom: 'auto',//title 缁勪欢绂诲鍣ㄤ笅渚х殑璺濈 + }, + xAxis: { + data: this.xDataList, + name: '浠跨湡鎬绘椂闀�', + splitNumber: 10 + }, + yAxis: { - let res = await this.$http.get(`/taskReliability/SimulatAssess/${id}`) - - - - this.myChart = echarts.init(document.getElementById("mychart")); + name: '', + }, + series: [ + { + data: this.yDataList, + type: 'line', + smooth: true + } + ] + }; + this.myChart = echart.init(document.getElementById("myChart")); + console.log(this.option, ' this.option ') this.myChart.setOption(this.option); //闅忕潃灞忓箷澶у皬璋冭妭鍥捐〃 window.addEventListener("resize", () => { -- Gitblit v1.9.1