作者 朱兆平

优化页面传参,切换页面参数丢失后,对象为空的校验

@@ -145,12 +145,18 @@ @@ -145,12 +145,18 @@
145 submitForm(formName) { 145 submitForm(formName) {
146 this.$refs[formName].validate((valid) => { 146 this.$refs[formName].validate((valid) => {
147 if (valid) { 147 if (valid) {
148 - this.$router.push({path:'/origmaster',query:  
149 - {flightno:JSON.stringify(this.ruleForm.flightno),  
150 - flightdate:JSON.stringify(this.dateConversion(this.ruleForm.flightdate)),  
151 - originstation:JSON.stringify(this.ruleForm.originstation),  
152 - destinationstation:JSON.stringify(this.ruleForm.destinationstation),  
153 - awba:JSON.stringify("")}}); 148 + this.$router.push(
  149 + {
  150 + path:'/origmaster',
  151 + query:{
  152 + flightno: this.ruleForm.flightno,
  153 + flightdate: this.ruleForm.flightdate,
  154 + originstation: this.ruleForm.originstation,
  155 + destinationstation: this.ruleForm.destinationstation,
  156 + awba: ''
  157 + }
  158 + }
  159 + );
154 } else { 160 } else {
155 console.log('error submit!!'); 161 console.log('error submit!!');
156 return false; 162 return false;
@@ -1058,7 +1058,7 @@ @@ -1058,7 +1058,7 @@
1058 temprows:{}, 1058 temprows:{},
1059 dialogTableVisible:false, 1059 dialogTableVisible:false,
1060 gridData:[], 1060 gridData:[],
1061 - tableloading:true, 1061 + tableloading:false,
1062 htmlTitle:'', 1062 htmlTitle:'',
1063 batich:true, 1063 batich:true,
1064 batichboolean:false, 1064 batichboolean:false,
@@ -1405,23 +1405,28 @@ @@ -1405,23 +1405,28 @@
1405 && jsutil.checkNull(this.$route.query.originstation) 1405 && jsutil.checkNull(this.$route.query.originstation)
1406 && jsutil.checkNull(this.$route.query.destinationstation) 1406 && jsutil.checkNull(this.$route.query.destinationstation)
1407 ) { 1407 ) {
1408 - this.defaultQuery.flightno = JSON.parse(this.$route.query.flightno);  
1409 - this.defaultQuery.flightdate = JSON.parse(this.$route.query.flightdate);  
1410 - this.defaultQuery.originstation = JSON.parse(this.$route.query.originstation);  
1411 - this.defaultQuery.destinationstation = JSON.parse(this.$route.query.destinationstation);  
1412 - this.defaultQuery.awba = JSON.parse(this.$route.query.awba); 1408 + this.defaultQuery.flightno =this.$route.query.flightno;
  1409 + this.defaultQuery.flightdate = this.$route.query.flightdate;
  1410 + this.defaultQuery.originstation = this.$route.query.originstation;
  1411 + this.defaultQuery.destinationstation = this.$route.query.destinationstation;
  1412 + this.defaultQuery.awba = this.$route.query.awba;
  1413 + this.getList();
  1414 + }else {
  1415 + this.$router.push({
  1416 + path:'/enter'
  1417 + })
1413 } 1418 }
1414 1419
1415 }, 1420 },
1416 /*获取默认数据列表*/ 1421 /*获取默认数据列表*/
1417 getList(){ 1422 getList(){
  1423 + let _this = this;
1418 this.tableloading=true; 1424 this.tableloading=true;
1419 getMt1201List(this.defaultQuery).then(res =>{ 1425 getMt1201List(this.defaultQuery).then(res =>{
1420 this.sumNmmsCount=0; 1426 this.sumNmmsCount=0;
1421 this.sumNmmsPrice=0; 1427 this.sumNmmsPrice=0;
1422 this.sumNmmsWeight=0; 1428 this.sumNmmsWeight=0;
1423 let response=res.data.data; 1429 let response=res.data.data;
1424 - console.log(response)  
1425 this.tableData=response; 1430 this.tableData=response;
1426 this.tableloading=false; 1431 this.tableloading=false;
1427 response.forEach((item,i) => { 1432 response.forEach((item,i) => {
@@ -1430,6 +1435,13 @@ @@ -1430,6 +1435,13 @@
1430 this.sumNmmsPrice=Number(this.sumNmmsPrice)+Number(item.piece); 1435 this.sumNmmsPrice=Number(this.sumNmmsPrice)+Number(item.piece);
1431 this.sumNmmsWeight=Number(Number(this.sumNmmsWeight)+Number(item.weight)).toFixed(2); 1436 this.sumNmmsWeight=Number(Number(this.sumNmmsWeight)+Number(item.weight)).toFixed(2);
1432 }) 1437 })
  1438 + }).catch(error => {
  1439 + _this.tableloading=false;
  1440 + _this.$message({
  1441 + // 饿了么的消息弹窗组件
  1442 + message: error,
  1443 + type: "error"
  1444 + });
1433 }); 1445 });
1434 }, 1446 },
1435 /*获取国家代码*/ 1447 /*获取国家代码*/
@@ -1579,7 +1591,6 @@ @@ -1579,7 +1591,6 @@
1579 /*渲染方法*/ 1591 /*渲染方法*/
1580 activated(){ 1592 activated(){
1581 this.getDefaultData(); 1593 this.getDefaultData();
1582 - this.getList();  
1583 } 1594 }
1584 } 1595 }
1585 </script> 1596 </script>