diff --git a/src/views/xm/core/xmIteration/index.vue b/src/views/xm/core/xmIteration/index.vue index a35f1bc0..8a97b2c9 100644 --- a/src/views/xm/core/xmIteration/index.vue +++ b/src/views/xm/core/xmIteration/index.vue @@ -34,7 +34,7 @@ export default { if(!this.$route.query.iterationId){ this.$message.error("地址不合规") - this.$route.back(-1) + this.$router.back(-1) } if(!this.xmIteration||this.xmIteration.id!=this.$route.query.iterationId){ listXmIterationWithState({id:this.$route.query.iterationId}).then(res=>{ diff --git a/src/views/xm/core/xmProduct/index.vue b/src/views/xm/core/xmProduct/index.vue index abde2ccb..32ecf8a9 100644 --- a/src/views/xm/core/xmProduct/index.vue +++ b/src/views/xm/core/xmProduct/index.vue @@ -34,7 +34,7 @@ export default { if(!this.$route.query.productId){ this.$message.error("地址不合规") - this.$route.back(-1) + this.$router.back(-1) } if(!this.xmProduct||this.xmProduct.id!=this.$route.query.productId){ listXmProductWithState({id:this.$route.query.productId}).then(res=>{ diff --git a/src/views/xm/core/xmProject/index.vue b/src/views/xm/core/xmProject/index.vue index 9da2c3df..976a0b45 100644 --- a/src/views/xm/core/xmProject/index.vue +++ b/src/views/xm/core/xmProject/index.vue @@ -33,7 +33,7 @@ export default { mounted() { if(!this.$route.query.projectId){ this.$message.error("地址不合规") - this.$route.back(-1) + this.$router.back(-1) } if(!this.projectInfo||this.projectInfo.id!=this.$route.query.projectId){ listXmProject({id:this.$route.query.projectId}).then(res=>{ diff --git a/src/views/xm/core/xmTestCasedb/index.vue b/src/views/xm/core/xmTestCasedb/index.vue index bb38c289..e83fa6ab 100644 --- a/src/views/xm/core/xmTestCasedb/index.vue +++ b/src/views/xm/core/xmTestCasedb/index.vue @@ -34,7 +34,7 @@ export default { if(!this.$route.query.casedbId){ this.$message.error("地址不合规") - this.$route.back(-1) + this.$router.back(-1) } if(!this.testCasedb||this.testCasedb.id!=this.$route.query.casedbId){ listXmTestCasedb({id:this.$route.query.casedbId}).then(res=>{ @@ -44,16 +44,12 @@ export default { store.dispatch('setTestCasedb',res.data.data[0]) }else{ this.$message.error("测试用例库不存在,请确保测试用例库编号正确") - this.$router.push({ - path:'/xm/core/casedb/mng' - }) + this.$router.back(-1) } }else{ this.$message.error(tips.msg) - this.$router.push({ - path:'/xm/core/casedb/mng' - }) + this.$router.back(-1) } }) } diff --git a/src/views/xm/core/xmTestPlanCase/XmTestPlanCaseMng.vue b/src/views/xm/core/xmTestPlanCase/XmTestPlanCaseMng.vue index 1df775d9..48c86dd5 100644 --- a/src/views/xm/core/xmTestPlanCase/XmTestPlanCaseMng.vue +++ b/src/views/xm/core/xmTestPlanCase/XmTestPlanCaseMng.vue @@ -94,6 +94,18 @@ + + + + + + + + + + @@ -110,7 +122,8 @@ import MdpSelectUserXm from '@/views/xm/core/components/MdpSelectUserXm';//修 import {autoStepToAxios,initEnvVars} from '@/api/xm/core/XmTestAutoStep.js';//全局公共库 import { mapGetters } from 'vuex' -import axios from 'axios'//免登录访问 +import axios from 'axios'//免登录访问 + export default { name:'xmTestPlanCaseMng', components: { @@ -152,6 +165,11 @@ export default { caseStatus:'', execStatus:'' }, + batchProgress:0, + okCasesNum:0, + errCasesNum:0, + igCasesNum:0, + xmTestPlanCases: [],//查询结果 pageInfo:{//分页数据 total:0,//服务器端收到0时,会自动计算总记录数,如果上传>0的不自动计算。 @@ -161,7 +179,7 @@ export default { orderFields:[],//排序列 如 ['sex','student_id'],必须为数据库字段 orderDirs:[]//升序 asc,降序desc 如 性别 升序、学生编号降序 ['asc','desc'] }, - load:{ list: false, edit: false, del: false, add: false },//查询中... + load:{ list: false, edit: false, del: false, add: false,doBatch:false },//查询中... sels: [],//列表选中数据 dicts:{ testCaseStatus:[], @@ -177,6 +195,7 @@ export default { bugs:'',execUserid:'',caseId:'',ltime:'',ctime:'',execStatus:'',execUsername:'',planId:'',caseName:'',priority:'',remark:'',testStep:'' }, maxTableHeight:300, + doBatchExecVisible:false, } },//end data methods: { @@ -365,7 +384,10 @@ export default { } }).catch((e)=>Object.assign(this.editForm,this.editFormBak)) }, - + doBatchBack(){ + this.doBatchExecVisible=false; + this.searchXmTestPlanCases(); + }, editSomeFieldsForExec(sels,fieldName,$event){ let params={}; params['pkList']=sels.map(i=>{ return { caseId:i.caseId, planId:i.planId}}) @@ -416,60 +438,71 @@ export default { } this.doBatchExec(this.sels) }, - doBatchExec(planCases){ + async doBatchExec(planCases){ this.doBatchExecVisible=true; + this.load.doBatch=true; var igCases=planCases.filter(k=> !k.autoStep || k.testType!='1') + if(igCases.length>0){ + this.editSomeFieldsForExec(igCases,"execStatus",'1') + } + this.igCasesNum=igCases.length; + this.batchProgress=Math.round(igCases.length/planCases.length) var cases=planCases.filter(k=>k.autoStep && k.testType=='1') var execAll=[] var env=initEnvVars(this.xmTestCasedb?this.xmTestCasedb.envJson:null,this.xmTestPlan ?this.xmTestPlan.envJson:null); - cases.forEach(k=>{ - this.sendMsgForTestSetting(k,env,execAll) - }) + for( let k of cases ){ + var data= await this.sendMsgForTestSetting(k,env) + execAll.push(data) + this.batchProgress=Math.round((igCases.length+execAll.length)/planCases.length) + + } var okCases=execAll.filter(k=>k.execStatus=='2') + this.okCasesNum=okCases.length if(okCases.length>0){ - this.editSomeFieldsForExec(okCases,"execStatus",'2') + this.editSomeFieldsForExec(okCases,"execStatus",'2') } var errCases=execAll.filter(k=>k.execStatus=='4') + this.errCasesNum=errCases.length; if(errCases.length>0){ this.editSomeFieldsForExec(errCases,"execStatus",'4') } - + this.load.doBatch=false; }, - sendMsgForTestSetting(planCase,env,execAll){ - - var autoStepObj=JSON.parse(planCase.autoStep) - if(!autoStepObj.url){ - planCase.execStatus='1' - execAll.push(planCase) - }else{ - var axiosObj=autoStepToAxios(autoStepObj,env) - //axiosObj.headers['Access-Control-Allow-Origin']='*' - //axios.defaults.withCredentials = true // 若跨域请求需要带 cookie 身份识别 - //axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded' - axios(axiosObj).then(res=>{ - if(autoStepObj.expectResult){ - var func=new Function('res','env',autoStepObj.expectResult) - var result=func(res,env) - planCase.execStatus=result==true?"2":"4" - }else{ - planCase.execStatus=res.status==200?"2":"4" + sendMsgForTestSetting:function(planCase,env){ + return new Promise((resolve,reject)=>{ + var autoStepObj=JSON.parse(planCase.autoStep) + if(!autoStepObj.url){ + planCase.execStatus='1' + resolve(planCase) + }else{ + var axiosObj=autoStepToAxios(autoStepObj,env) + //axiosObj.headers['Access-Control-Allow-Origin']='*' + //axios.defaults.withCredentials = true // 若跨域请求需要带 cookie 身份识别 + //axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded' + axios(axiosObj).then(res=>{ + if(autoStepObj.expectResult){ + var func=new Function('res','env',autoStepObj.expectResult) + var result=func(res,env) + planCase.execStatus=result==true?"2":"4" + }else{ + planCase.execStatus=res.status==200?"2":"4" - } - execAll.push(planCase) - }).catch(res=>{ - var func=new Function('res','env',autoStepObj.expectResult) - var result=func(res,env) - if(result==true){ - planCase.execStatus="2" - }else{ - planCase.execStatus="4" - } - execAll.push(planCase) - - }) - } - + } + resolve(planCase) + }).catch(res=>{ + var func=new Function('res','env',autoStepObj.expectResult) + var result=func(res,env) + if(result==true){ + planCase.execStatus="2" + }else{ + planCase.execStatus="4" + } + resolve(planCase) + }) + } + }) + }, onXmFuncRowClick(row){