From 17f9722fb23200c964d0c2d36d2025d552f2a3db Mon Sep 17 00:00:00 2001 From: whyczyk <525500596@qq.com> Date: 星期二, 25 五月 2021 10:55:59 +0800 Subject: [PATCH] 负载点列表组件优化 --- src/pages/test/dialog/LoadTestDialog.vue | 477 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 239 insertions(+), 238 deletions(-) diff --git a/src/pages/test/dialog/LoadTestDialog.vue b/src/pages/test/dialog/LoadTestDialog.vue index a094f0f..3a214a5 100644 --- a/src/pages/test/dialog/LoadTestDialog.vue +++ b/src/pages/test/dialog/LoadTestDialog.vue @@ -1,12 +1,9 @@ <template> <div class="el-dialog-wrapper"> - <el-dialog - :visible.sync="dialogVisible" class="position-absolute dialog-center dialog-no-header" width="840px" + <el-dialog :visible.sync="dialogVisible" class="position-absolute dialog-center dialog-no-header" width="840px" top="0" :modal="false" :destroy-on-close="true" :close-on-press-escape="false" :close-on-click-modal="false" - :modal-append-to-body="false" - v-loading="loading" element-loading-text="鎷煎懡鍔犺浇涓�" - element-loading-spinner="el-icon-loading" - element-loading-background="rgba(0, 0, 0, 0)"> + :modal-append-to-body="false" v-loading="loading" element-loading-text="鎷煎懡鍔犺浇涓�" + element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0)"> <mw-step v-model="step"></mw-step> <div class="step-list"> <div class="step-item" v-show="step == 0"> @@ -21,262 +18,266 @@ </div> </div> </el-dialog> - <el-dialog - :visible.sync="testStepCheck" class="position-absolute dialog-center dialog-no-header" - width="840px" top="0" - :modal="false" :destroy-on-close="true" - :close-on-press-escape="false" :close-on-click-modal="false" + <el-dialog :visible.sync="testStepCheck" class="position-absolute dialog-center dialog-no-header" width="840px" + top="0" :modal="false" :destroy-on-close="true" :close-on-press-escape="false" :close-on-click-modal="false" :modal-append-to-body="false"> <test-start :type="type" @startTest="startTest" v-if="testStepCheck"></test-start> </el-dialog> - <el-dialog - :visible.sync="startResult" class="position-absolute dialog-center dialog-no-header" - width="840px" top="0" - :modal="false" :destroy-on-close="true" - :close-on-press-escape="false" :close-on-click-modal="false" + <el-dialog :visible.sync="startResult" class="position-absolute dialog-center dialog-no-header" width="840px" + top="0" :modal="false" :destroy-on-close="true" :close-on-press-escape="false" :close-on-click-modal="false" :modal-append-to-body="false"> <heating-up-rs :list="heatingUpList" @updatePoint="updatePoint"></heating-up-rs> </el-dialog> - <test-step-dialog :type="type" :step="testStepKey" :list="list" :end="endStep" :progress="progressStep"></test-step-dialog> + <test-step-dialog :type="type" :step="testStepKey" :list="list" :end="endStep" :progress="progressStep"> + </test-step-dialog> </div> </template> <script> -import mwStep from "@/components/smallModule/mwStep"; -import newTest from "@/pages/test/dialog/newTest"; -import TestDataInput from "@/pages/test/dialog/testDataInput"; -import TestStepConfirm from "@/pages/test/dialog/testStepConfirm"; -import testStepConfirmKz from "@/pages/test/dialog/testStepConfirmKz"; -import TestStart from "@/pages/test/dialog/testStart"; -import {addKzFzTest, experimentPoint, getExitTest, testHeatingUp} from "@/pages/test/js/api"; -import HeatingUpRs from "@/pages/test/dialog/heatingUpRs"; -import {getLabel} from "@/assets/js/tools"; -import {constTestType} from "@/pages/test/js/const"; -import Timeout from "@/assets/js/tools/Timeout"; -import TestStepDialog from "@/pages/test/dialog/testStepDialog"; + import mwStep from "@/components/smallModule/mwStep"; + import newTest from "@/pages/test/dialog/newTest"; + import TestDataInput from "@/pages/test/dialog/testDataInput"; + import TestStepConfirm from "@/pages/test/dialog/testStepConfirm"; + import testStepConfirmKz from "@/pages/test/dialog/testStepConfirmKz"; + import TestStart from "@/pages/test/dialog/testStart"; + import { + addKzFzTest, + experimentPoint, + getExitTest, + testHeatingUp + } from "@/pages/test/js/api"; + import HeatingUpRs from "@/pages/test/dialog/heatingUpRs"; + import { + getLabel + } from "@/assets/js/tools"; + import { + constTestType + } from "@/pages/test/js/const"; + import Timeout from "@/assets/js/tools/Timeout"; + import TestStepDialog from "@/pages/test/dialog/testStepDialog"; -export default { - name: "LoadTestDialog", - props: { - visible: { - type: Boolean, - default: false, - }, - type: { - require: true, - type: String, - } - }, - components: { - TestStepDialog, - HeatingUpRs, - TestStepConfirm, - TestDataInput, - mwStep, - newTest, - testStepConfirmKz, - TestStart - }, - data() { - return { - loading: false, - timer: new Timeout(), - step: 0, - dialogVisible: false, - testStepCheck: false, - startResult: false, - experimentId: 0, - params: { - baseData: { - experimentId: "", // 璇曢獙缂栧彿 - gearSpeedRatio: "", // 榻胯疆杞�熸瘮 - ratedLateralSpeed: 0, // 楂橀�熶晶杞��,鍗曚綅:r/min - ratedPower: 0, // 棰濆畾鍔熺巼,鍗曚綅KW - ratedRotateSpeed: 0, // 棰濆畾杞��,鍗曚綅:r/min - ratedVol: 0 // 棰濆畾鐢靛帇,鍗曚綅V - }, - createTime: "", // 鍒涘缓鏃堕棿 - deviceId: "", // 琚祴璁惧id - deviceSn: "", // 琚祴璁惧SN - duration: "", // 璇曢獙鏃堕暱 - endTime: "", // 缁撴潫鏃堕棿 - id: "", // 璇曢獙缂栧彿 - name: "", // 璇曢獙鍚嶇О - point: [], - projectId: 0, // 瀵瑰簲鐨勯」鐩� - rz_link: 0, // 鍚勭浉缁曠粍杩炴帴鎯呭喌 0 寮曞嚭; 1 鍐呴儴杩炴帴 - startTime: "", // 鍚姩鏃堕棿 - status: 0, // 鐘舵��:-1-鍙栨秷,0-鏈紑濮�,1-杩涜涓�,2-瀹屾垚 - type: "", // 璇曢獙绫诲瀷:涔濆ぇ璇曢獙 - userId: sessionStorage.getItem('uid'), // 璐熻矗浜� - username: "" // 璐熻矗浜哄鍚� + export default { + name: "LoadTestDialog", + props: { + visible: { + type: Boolean, + default: false, }, - heatingUpList: [], - list: [], - testStepKey: -1, - endStep: false, - progressStep: false, - } - }, - watch: { - visible(value) { - this.dialogVisible = value; - }, - }, - methods: { - startTimer() { - this.timer.start(()=>{ - this.$axios.all([ - this.experimentPoint() - ]).then(res => { - this.timer.open(); - }).catch(error => { - this.timer.open(); - }); - }, 2000); - - }, - experimentPoint() { - let postData = { - experimentId: this.experimentId + type: { + require: true, + type: String, } - experimentPoint(postData).then((res) => { - let rs = res.data; - let data = []; - if (rs.code == 1) { - data = rs.data.map(item => { - let start = item.startTime?new Date(item.startTime).format("hh:ss"):''; - let end = item.endTime?new Date(item.endTime).format("hh:ss"):''; - item.start = item.startTime ? `寮�濮嬫椂闂碶n${start}`: ''; - item.end = item.endTime ? `瀹屾垚鏃堕棿\n${end}`: ''; - item.endText = item.averagePower ? `骞冲潎鍔熺巼\n${item.averagePower}kW` : ''; - return item; - }); - } - this.list = data; - this.$nextTick(()=>{ - // 璁剧疆testStepKey - let step = -1; - this.progressStep = false; - for(let i=0; i<data.length; i++) { - let status = data[i].status; - if(status == 0) { - step = i; - this.endStep = false; - break; - }else if(status == 1) { - step = i; - this.progressStep = true; - break; - } - step = i; - this.endStep = true; - } - // 璁剧疆鏈縺娲荤偣 - this.testStepKey = step; - }); - this.$emit('updateList', this.list); - }).catch((err) => { - console.log(err) - }); }, - checkIsTesting() { - getExitTest().then(res => { - let rs = res.data; - console.log(rs); - if (rs.code == 1) { - let data = rs.data; - if (data.type != this.type) { - let testType = getLabel(data.type, constTestType); - this.$alert("褰撳墠宸插紑鍚瘯楠岋細" + testType + "銆傚闇�瑕佽繘琛屽叾浠栬瘯楠岄渶鍏堝叧闂璇曢獙銆�", '绯荤粺鎻愮ず', { - callback: () => { - this.$router.push('/index/testManager/testing'); + components: { + TestStepDialog, + HeatingUpRs, + TestStepConfirm, + TestDataInput, + mwStep, + newTest, + testStepConfirmKz, + TestStart + }, + data() { + return { + loading: false, + timer: new Timeout(), + step: 0, + dialogVisible: false, + testStepCheck: false, + startResult: false, + experimentId: 0, + params: { + baseData: { + experimentId: "", // 璇曢獙缂栧彿 + gearSpeedRatio: "", // 榻胯疆杞�熸瘮 + ratedLateralSpeed: 0, // 楂橀�熶晶杞��,鍗曚綅:r/min + ratedPower: 0, // 棰濆畾鍔熺巼,鍗曚綅KW + ratedRotateSpeed: 0, // 棰濆畾杞��,鍗曚綅:r/min + ratedVol: 0 // 棰濆畾鐢靛帇,鍗曚綅V + }, + createTime: "", // 鍒涘缓鏃堕棿 + deviceId: "", // 琚祴璁惧id + deviceSn: "", // 琚祴璁惧SN + duration: "", // 璇曢獙鏃堕暱 + endTime: "", // 缁撴潫鏃堕棿 + id: "", // 璇曢獙缂栧彿 + name: "", // 璇曢獙鍚嶇О + point: [], + projectId: 0, // 瀵瑰簲鐨勯」鐩� + rz_link: 0, // 鍚勭浉缁曠粍杩炴帴鎯呭喌 0 寮曞嚭; 1 鍐呴儴杩炴帴 + startTime: "", // 鍚姩鏃堕棿 + status: 0, // 鐘舵��:-1-鍙栨秷,0-鏈紑濮�,1-杩涜涓�,2-瀹屾垚 + type: "", // 璇曢獙绫诲瀷:涔濆ぇ璇曢獙 + userId: sessionStorage.getItem('uid'), // 璐熻矗浜� + username: "" // 璐熻矗浜哄鍚� + }, + heatingUpList: [], + list: [], + testStepKey: -1, + endStep: false, + progressStep: false, + } + }, + watch: { + visible(value) { + this.dialogVisible = value; + }, + }, + methods: { + startTimer() { + this.timer.start(() => { + this.$axios.all([ + this.experimentPoint() + ]).then(res => { + this.timer.open(); + }).catch(error => { + this.timer.open(); + }); + }, 2000); + + }, + experimentPoint() { + let postData = { + experimentId: this.experimentId + } + experimentPoint(postData).then((res) => { + let rs = res.data; + let data = []; + if (rs.code == 1) { + data = rs.data.map(item => { + let start = item.startTime ? new Date(item.startTime).format("hh:ss") : ''; + let end = item.endTime ? new Date(item.endTime).format("hh:ss") : ''; + item.start = item.startTime ? `寮�濮嬫椂闂�&&${start}` : ''; + item.end = item.endTime ? `瀹屾垚鏃堕棿&&${end}` : ''; + item.endText = item.averagePower ? `骞冲潎鍔熺巼&&${item.averagePower}kW` : ''; + return item; + }); + } + this.list = data; + this.$nextTick(() => { + // 璁剧疆testStepKey + let step = -1; + this.progressStep = false; + for (let i = 0; i < data.length; i++) { + let status = data[i].status; + if (status == 0) { + step = i; + this.endStep = false; + break; + } else if (status == 1) { + step = i; + this.progressStep = true; + break; } + step = i; + this.endStep = true; + } + // 璁剧疆鏈縺娲荤偣 + this.testStepKey = step; + }); + this.$emit('updateList', this.list); + }).catch((err) => { + console.log(err) + }); + }, + checkIsTesting() { + getExitTest().then(res => { + let rs = res.data; + console.log(rs); + if (rs.code == 1) { + let data = rs.data; + if (data.type != this.type) { + let testType = getLabel(data.type, constTestType); + this.$alert("褰撳墠宸插紑鍚瘯楠岋細" + testType + "銆傚闇�瑕佽繘琛屽叾浠栬瘯楠岄渶鍏堝叧闂璇曢獙銆�", '绯荤粺鎻愮ず', { + callback: () => { + this.$router.push('/index/testManager/testing'); + } + }); + } else { + console.log('鏌ヨ璇曢獙姝ラ'); + this.experimentId = rs.data.id; + this.startTimer(); + } + } else { + this.dialogVisible = true; + } + }).catch(error => { + + }); + }, + newTest(data) { + this.params.name = data.name; + this.params.projectId = data.projectId; + this.step++; + }, + dataInput(data) { + this.params.baseData.experimentId = data.experimentId; + this.params.id = data.experimentId; + this.params.deviceSn = data.deviceSn; + this.params.deviceId = data.deviceId; + this.params.baseData.ratedPower = data.ratedPower; + this.params.baseData.ratedVol = data.ratedVol; + this.params.baseData.gearSpeedRatio = data.gearSpeedRatio; + this.params.baseData.ratedRotateSpeed = data.ratedRotateSpeed; + this.params.baseData.ratedLateralSpeed = data.ratedLateralSpeed; + this.step++; + }, + completeTest(data) { + let experimentId = this.params.baseData.experimentId; + this.params.point = data.point.map(item => { + item.experimentId = experimentId; + return item; + }); + this.loading = true; + addKzFzTest(this.params).then(res => { + let rs = res.data; + if (rs.code == 1) { + this.dialogVisible = false; + this.$nextTick(() => { + this.$layer.msg("鐢熸垚璇曢獙鎴愬姛"); + this.testStepCheck = true; }); } else { - console.log('鏌ヨ璇曢獙姝ラ'); - this.experimentId = rs.data.id; - this.startTimer(); + this.$layer.msg("鐢熸垚璇曢獙澶辫触"); } - } else { - this.dialogVisible = true; - } - }).catch(error => { + this.loading = false; + }).catch(error => { + this.$layer.msg("璇锋娴嬬綉缁�"); + this.loading = false; + }); + }, + startTest() { // 寮�濮嬭瘯楠�, 杩涜鍗囨俯 + this.testStepCheck = false; + testHeatingUp(this.params.id).then(res => { + let rs = res.data; + let data = []; + if (rs.code == 1) { + data = rs.data; + } + this.heatingUpList = data; + this.startResult = true; + }).catch(error => { - }); + }); + }, + updatePoint() { // 鏇存柊鑺傜偣鏁版嵁 + this.$emit('updatePoint'); + this.startResult = false; + this.experimentId = this.params.id; + this.startTimer(); + } }, - newTest(data) { - this.params.name = data.name; - this.params.projectId = data.projectId; - this.step++; - }, - dataInput(data) { - this.params.baseData.experimentId = data.experimentId; - this.params.id = data.experimentId; - this.params.deviceSn = data.deviceSn; - this.params.deviceId = data.deviceId; - this.params.baseData.ratedPower = data.ratedPower; - this.params.baseData.ratedVol = data.ratedVol; - this.params.baseData.gearSpeedRatio = data.gearSpeedRatio; - this.params.baseData.ratedRotateSpeed = data.ratedRotateSpeed; - this.params.baseData.ratedLateralSpeed = data.ratedLateralSpeed; - this.step++; - }, - completeTest(data) { - let experimentId = this.params.baseData.experimentId; - this.params.point = data.point.map(item => { - item.experimentId = experimentId; - return item; - }); - this.loading = true; - addKzFzTest(this.params).then(res => { - let rs = res.data; - if (rs.code == 1) { - this.dialogVisible = false; - this.$nextTick(() => { - this.$layer.msg("鐢熸垚璇曢獙鎴愬姛"); - this.testStepCheck = true; - }); - } else { - this.$layer.msg("鐢熸垚璇曢獙澶辫触"); - } - this.loading = false; - }).catch(error => { - this.$layer.msg("璇锋娴嬬綉缁�"); - this.loading = false; - }); - }, - startTest() { // 寮�濮嬭瘯楠�, 杩涜鍗囨俯 - this.testStepCheck = false; - testHeatingUp(this.params.id).then(res => { - let rs = res.data; - let data = []; - if (rs.code == 1) { - data = rs.data; - } - this.heatingUpList = data; - this.startResult = true; - }).catch(error => { + mounted() { + this.params.type = this.type; + this.dialogVisible = this.visible; - }); + this.checkIsTesting(); }, - updatePoint() { // 鏇存柊鑺傜偣鏁版嵁 - this.$emit('updatePoint'); - this.startResult = false; - this.experimentId = this.params.id; - this.startTimer(); + destroyed() { + this.timer.stop(); } - }, - mounted() { - this.params.type = this.type; - this.dialogVisible = this.visible; - - this.checkIsTesting(); - }, - destroyed() { - this.timer.stop(); } -} </script> <style scoped> -- Gitblit v1.9.1