Przeglądaj źródła

1、上传图片前先进行压缩
2、意外险框内清除按钮的方法

lihongxiao 2 lat temu
rodzic
commit
8d9889081c
2 zmienionych plików z 252 dodań i 100 usunięć
  1. 249 100
      src/views/Letter/Letter.vue
  2. 3 0
      src/views/Letter/Orderlist.vue

+ 249 - 100
src/views/Letter/Letter.vue

@@ -825,7 +825,7 @@
                 <h3>意外险信息</h3>
                 <div class="dis a-c " style="margin-bottom:15px">
                   <span style="margin-right:15px;color:#606266;">选择意外险:</span>
-                  <el-select style="width: 250px;" filterable  size="small" clearable v-model="insuranceHB" placeholder="选择类型" @clear="clearAccidentForm"
+                  <el-select style="width: 250px;" filterable  size="small" clearable v-model="insuranceHB" placeholder="选择类型" @clear="clearAccidentFormHB"
                       @change="hengbangInsuranceChange">
                       <el-option v-for="(item, index) in hengbangInsuranceData" :key="index" :label="item.programname"
                         :value="item.programcode"></el-option>
@@ -856,7 +856,7 @@
                 <h3>意外险信息</h3>
                 <div class="dis a-c " style="margin-bottom:15px">
                   <span style="margin-right:15px;color:#606266;">意外险类型:</span>
-                  <el-select style="width: 250px;" size="small" clearable v-model="anshengInsurancetype" placeholder="选择类型" @clear="clearAccidentForm"
+                  <el-select style="width: 250px;" size="small" clearable v-model="anshengInsurancetype" placeholder="选择类型" @clear="clearAccidentFormAS"
                       @change="anshengInsuranceChange">
                       <el-option v-for="(item, index) in anshengInsuranceData" :key="index" :label="item.planChineseName"
                         :value="item.planCode"></el-option>
@@ -916,7 +916,7 @@
                 <h3>意外险信息</h3>
                 <div class="dis a-c " style="margin-bottom:15px">
                   <span style="margin-right:15px;color:#606266;">选择意外险:</span>
-                  <el-select style="width: 250px;" filterable  size="small" clearable v-model="insuranceZA" placeholder="选择类型" @clear="clearAccidentFormRS"
+                  <el-select style="width: 250px;" filterable  size="small" clearable v-model="insuranceZA" placeholder="选择类型" @clear="clearAccidentFormZA"
                       @change="zhonganInsuranceChange">
                       <el-option v-for="(item, index) in zhonganInsuranceData" :key="index" :label="item.name"
                         :value="item.combination"></el-option>
@@ -944,7 +944,7 @@
                 <h3>意外险信息</h3>
                 <div class="dis a-c " style="margin-bottom:15px">
                   <span style="margin-right:15px;color:#606266;">选择意外险:</span>
-                  <el-select style="width: 250px;" filterable  size="small" clearable v-model="insuranceZJ" placeholder="选择类型" @clear="clearAccidentForm"
+                  <el-select style="width: 250px;" filterable  size="small" clearable v-model="insuranceZJ" placeholder="选择类型" @clear="clearAccidentFormZJ"
                       @change="zijinInsuranceChange">
                       <el-option v-for="(item, index) in ziJinInsuranceData" :key="index" :label="item.projectName"
                         :value="item.projectCode"></el-option>
@@ -1022,7 +1022,7 @@
                 <h3>意外险信息</h3>
                 <div class="dis a-c " style="margin-bottom:15px">
                   <span style="margin-right:15px;color:#606266;">意外险类型:</span>
-                  <el-select style="width: 250px;" size="small" clearable v-model="zhongmeiInsurancetype" placeholder="选择类型" @clear="clearAccidentForm"
+                  <el-select style="width: 250px;" size="small" clearable v-model="zhongmeiInsurancetype" placeholder="选择类型" @clear="clearAccidentFormZM"
                              @change="zhongmeiInsuranceChange" >
                     <el-option v-for="(item, index) in zhongmeiInsuranceData" :key="index" :label="item.productName"
                                :value="item.productCode"></el-option>
@@ -4023,6 +4023,24 @@ export default {
         premium:0
       };
     },
+    clearAccidentFormHB(){
+      this.hengbangaccidentalDrivingVo={};
+    },
+    clearAccidentFormZM(){
+      this.zhongmeiaccidentalDrivingVo={};
+    },
+    clearAccidentFormZJ(){
+      this.accidentalDrivingVo=[]
+    },
+    clearAccidentFormZA(){
+      this.zhonganaccidentalDrivingVo={};
+    },
+    clearAccidentFormRS(){
+      this.renshouaccidentalDrivingVo={};
+    },
+    clearAccidentFormAS(){
+      this.anshengaccidentalDrivingVo={};
+    },
     //身份证有效期长期
     insureLongterm(e) {
       this[e].identifyValidEndDate = "9999-12-31";
@@ -4777,7 +4795,7 @@ export default {
             this.guoRen(num, id);
           });
         } else if (res.code == "200") {
-          if (res.data.warnMessageList.length > 0) {
+          if (res.data.warnMessageList && res.data.warnMessageList.length > 0) {
             this.totalCompanyList[num].lastYearMsg = "";
             let dat = res.data.warnMessageList;
             dat.map(ele => {
@@ -5809,6 +5827,7 @@ export default {
    
     //影像上传
     drivingupload(file, imageIdList, imgurl, type) {
+      let that=this
       let size=file.size / 1024 / 1024 < 5;
       const isJPG = file.raw.type === 'image/jpeg'||file.raw.type === 'image/png';
       if(!size){
@@ -5817,31 +5836,58 @@ export default {
        return false
       }
       if(!isJPG){
-       this.$message.error('上传头像图片只能是 JPG、PNG 格式!')
+       this.$message.error('上传图片只能是 JPG、PNG 格式!')
        this[imgurl]=[]
        return false
       }
       this[imgurl].push(file)
-      var file = file.raw;
-      const params = new FormData(); // 声明formData数据类型
-      params.append("multipartFile", file);
-      params.append("type", "image");
-      this.$api.letter.uploadFile(params).then(res => {
+      let name=file.raw.name
+      var image = new Image();
+      image.src = window.URL.createObjectURL(file.raw);
+      that.carfrontImg =  image.src 
+      image.onload = function(){
+        let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
+      const params = new FormData()
+       params.append("multipartFile", aaa);
+       params.append("type", "image");
+
+      that.$api.letter.uploadFile(params).then(res => {
         if (res.code == "200") {
-          if (this[imageIdList].some(v => v.imageType == type)) {
-            this[imageIdList].map(val => {
+          if (that[imageIdList].some(v => v.imageType == type)) {
+            that[imageIdList].map(val => {
               if (val.imageType == type) {
                 val.imageId = res.data.id;
               }
             })
           } else {
-            this[imageIdList].push({
+            that[imageIdList].push({
               imageId: res.data.id,
               imageType: type,
             })
           }
         }
       });
+    }
+      // var file = file.raw;
+      // const params = new FormData(); // 声明formData数据类型
+      // params.append("multipartFile", file);
+      // params.append("type", "image");
+      // this.$api.letter.uploadFile(params).then(res => {
+      //   if (res.code == "200") {
+      //     if (this[imageIdList].some(v => v.imageType == type)) {
+      //       this[imageIdList].map(val => {
+      //         if (val.imageType == type) {
+      //           val.imageId = res.data.id;
+      //         }
+      //       })
+      //     } else {
+      //       this[imageIdList].push({
+      //         imageId: res.data.id,
+      //         imageType: type,
+      //       })
+      //     }
+      //   }
+      // });
 
     },
     handleRemove1(file, imageIdList, imgList) {
@@ -5894,7 +5940,7 @@ export default {
         return file;
     },
     carfrontChange(file) {
-      //选择行驶证正面
+    //选择行驶证正面
       let that =this
       let size=file.size / 1024 / 1024 < 5;
       const isJPG = file.raw.type === 'image/jpeg'||file.raw.type === 'image/png';
@@ -5903,108 +5949,135 @@ export default {
        return false
       }
       if(!isJPG){
-       this.$message.error('上传头像图片只能是 JPG、PNG 格式!')
+       this.$message.error('上传图片只能是 JPG、PNG 格式!')
        return false
       }
-//       let name=file.raw.name
-//       var image = new Image();
-//       image.src = window.URL.createObjectURL(file.raw);
-//       that.carfrontImg =  image.src 
-//       image.onload = function(){
-//         let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
+      let name=file.raw.name
+      var image = new Image();
+      image.src = window.URL.createObjectURL(file.raw);
+      that.carfrontImg =  image.src 
+      image.onload = function(){
+        let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
+      that.carfrontImg = image.src;
+      const params = new FormData(); // 声明formData数据类型
+      params.append("multipartFile", aaa);
+      params.append("type", "image");
+      that.$api.letter.uploadFile(params).then(res => {
+        if (res.code == "200") {
+          that.CarFrontFile = aaa;//文件流
+          if (that.imageList1.some(v => v.imageType == 'C01')) {
+            that.imageList1.map(val => {
+              if (val.imageType == 'C01') {
+                val.imageId = res.data.id;
+              }
+            })
+          } else {
+            that.imageList1.push({
+              imageId: res.data.id,
+              imageType: "C01",
+            })
+          }
+        } else {
+          that.$message({ message: res.msg, type: "warning" });
+        }
+      });
+    }
       // var file = file.raw;
       // let files = window.URL.createObjectURL(file); //转临时路径
-      // that.carfrontImg = image.src;
+      // this.carfrontImg = files;
       // const params = new FormData(); // 声明formData数据类型
-      // params.append("multipartFile", aaa);
+      // params.append("multipartFile", file);
       // params.append("type", "image");
-
-      // that.$api.letter.uploadFile(params).then(res => {
+      // this.$api.letter.uploadFile(params).then(res => {
       //   if (res.code == "200") {
-      //     that.CarFrontFile = aaa;//文件流
-
-      //     if (that.imageList1.some(v => v.imageType == 'C01')) {
-      //       that.imageList1.map(val => {
+      //     this.CarFrontFile = file;//文件流
+      //     if (this.imageList1.some(v => v.imageType == 'C01')) {
+      //       this.imageList1.map(val => {
       //         if (val.imageType == 'C01') {
       //           val.imageId = res.data.id;
       //         }
       //       })
       //     } else {
-      //       that.imageList1.push({
+      //       this.imageList1.push({
       //         imageId: res.data.id,
       //         imageType: "C01",
       //       })
       //     }
       //   } else {
-      //     that.$message({ message: res.msg, type: "warning" });
+      //     this.$message({ message: res.msg, type: "warning" });
       //   }
       // });
-    // }
-      var file = file.raw;
-      let files = window.URL.createObjectURL(file); //转临时路径
-      this.carfrontImg = files;
-      const params = new FormData(); // 声明formData数据类型
-      params.append("multipartFile", file);
-      params.append("type", "image");
-      this.$api.letter.uploadFile(params).then(res => {
-        if (res.code == "200") {
-          this.CarFrontFile = file;//文件流
-          if (this.imageList1.some(v => v.imageType == 'C01')) {
-            this.imageList1.map(val => {
-              if (val.imageType == 'C01') {
-                val.imageId = res.data.id;
-              }
-            })
-          } else {
-            this.imageList1.push({
-              imageId: res.data.id,
-              imageType: "C01",
-            })
-          }
-        } else {
-          this.$message({ message: res.msg, type: "warning" });
-        }
-      });
     },
     carbackChange(file) {
-      let size=file.size / 1024 / 1024 < 5;
+      let that=this
+      let size=file.size / 1024 / 1024 < 2;
       const isJPG = file.raw.type === 'image/jpeg'||file.raw.type === 'image/png';
       if(!size){
        this.$message.error('上传图片大小不能超过 5MB!')
        return false
       }
       if(!isJPG){
-       this.$message.error('上传头像图片只能是 JPG、PNG 格式!')
+       this.$message.error('上传图片只能是 JPG、PNG 格式!')
        return false
       }
-      //选择行驶证反面
-      var file = file.raw;
-      let files = window.URL.createObjectURL(file); //转临时路径
-      this.carbackImg = files;
+      let name=file.raw.name
+      var image = new Image();
+      image.src = window.URL.createObjectURL(file.raw);
+      image.onload = function(){
+        let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
+      that.carbackImg = image.src;
       const params = new FormData(); // 声明formData数据类型
-      params.append("multipartFile", file);
+      params.append("multipartFile", aaa);
       params.append("type", "image");
-      this.$api.letter.uploadFile(params).then(res => {
+      that.$api.letter.uploadFile(params).then(res => {
         if (res.code == "200") {
-          this.CarBackFile = file;
-          if (this.imageList1.some(v => v.imageType == 'D01')) {
-            this.imageList1.map(val => {
+          that.CarBackFile = aaa;//文件流
+          if (that.imageList1.some(v => v.imageType == 'D01')) {
+            that.imageList1.map(val => {
               if (val.imageType == 'D01') {
                 val.imageId = res.data.id;
               }
             })
           } else {
-            this.imageList1.push({
+            that.imageList1.push({
               imageId: res.data.id,
               imageType: "D01",
             })
           }
         } else {
-          this.$message({ message: res.msg, type: "warning" });
+          that.$message({ message: res.msg, type: "warning" });
         }
       });
+    }
+      //选择行驶证反面
+      // var file = file.raw;
+      // let files = window.URL.createObjectURL(file); //转临时路径
+      // this.carbackImg = files;
+      // const params = new FormData(); // 声明formData数据类型
+      // params.append("multipartFile", file);
+      // params.append("type", "image");
+      // this.$api.letter.uploadFile(params).then(res => {
+      //   if (res.code == "200") {
+      //     this.CarBackFile = file;
+      //     if (this.imageList1.some(v => v.imageType == 'D01')) {
+      //       this.imageList1.map(val => {
+      //         if (val.imageType == 'D01') {
+      //           val.imageId = res.data.id;
+      //         }
+      //       })
+      //     } else {
+      //       this.imageList1.push({
+      //         imageId: res.data.id,
+      //         imageType: "D01",
+      //       })
+      //     }
+      //   } else {
+      //     this.$message({ message: res.msg, type: "warning" });
+      //   }
+      // });
     },
     userfrontChange(file) {
+      let that =this
       let size=file.size / 1024 / 1024 < 5;
       const isJPG = file.raw.type === 'image/jpeg'||file.raw.type === 'image/png';
       if(!size){
@@ -6012,39 +6085,70 @@ export default {
        return false
       }
       if(!isJPG){
-       this.$message.error('上传头像图片只能是 JPG、PNG 格式!')
+       this.$message.error('上传图片只能是 JPG、PNG 格式!')
        return false
       }
-      //选择身份证正面
-      var file = file.raw;
-      let files = window.URL.createObjectURL(file); //转链接
-      this.userfrontImg = files;
+      let name=file.raw.name
+      var image = new Image();
+      image.src = window.URL.createObjectURL(file.raw);
+      image.onload = function(){
+        let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
+      that.userfrontImg = image.src;
       const params = new FormData(); // 声明formData数据类型
-      params.append("multipartFile", file);
+      params.append("multipartFile", aaa);
       params.append("type", "image");
-      this.$api.letter.uploadFile(params).then(res => {
+      that.$api.letter.uploadFile(params).then(res => {
         if (res.code == "200") {
-          let type = 'C0' + this.userIndex;
-          if (this['imageList' + this.userIndex].some(v => v.imageType == type)) {
-            this['imageList' + this.userIndex].map(val => {
+          let type = 'C0' + that.userIndex;
+          if (that['imageList' + that.userIndex].some(v => v.imageType == type)) {
+            that['imageList' + that.userIndex].map(val => {
               if (val.imageType == type) {
                 val.imageId = res.data.id;
               }
             })
           } else {
-            this['imageList' + this.userIndex].push({
+            that['imageList' + that.userIndex].push({
               imageId: res.data.id,
               imageType: type,
             })
           }
-          this[type + 'File'] = file;
-
+          that[type + 'File'] = file;
         } else {
-          this.$message({ message: res.msg, type: "warning" });
+          that.$message({ message: res.msg, type: "warning" });
         }
       });
+    }
+      //选择身份证正面
+      // var file = file.raw;
+      // let files = window.URL.createObjectURL(file); //转链接
+      // this.userfrontImg = files;
+      // const params = new FormData(); // 声明formData数据类型
+      // params.append("multipartFile", file);
+      // params.append("type", "image");
+      // this.$api.letter.uploadFile(params).then(res => {
+      //   if (res.code == "200") {
+      //     let type = 'C0' + this.userIndex;
+      //     if (this['imageList' + this.userIndex].some(v => v.imageType == type)) {
+      //       this['imageList' + this.userIndex].map(val => {
+      //         if (val.imageType == type) {
+      //           val.imageId = res.data.id;
+      //         }
+      //       })
+      //     } else {
+      //       this['imageList' + this.userIndex].push({
+      //         imageId: res.data.id,
+      //         imageType: type,
+      //       })
+      //     }
+      //     this[type + 'File'] = file;
+
+      //   } else {
+      //     this.$message({ message: res.msg, type: "warning" });
+      //   }
+      // });
     },
     userbackChange(file) {
+      let that =this
       let size=file.size / 1024 / 1024 < 5;
       const isJPG = file.raw.type === 'image/jpeg'||file.raw.type === 'image/png';
       if(!size){
@@ -6052,37 +6156,67 @@ export default {
        return false
       }
       if(!isJPG){
-       this.$message.error('上传头像图片只能是 JPG、PNG 格式!')
+       this.$message.error('上传图片只能是 JPG、PNG 格式!')
        return false
       }
-      //选择身份证背面
-      var file = file.raw;
-      let files = window.URL.createObjectURL(file); //转链接
-      this.userbackImg = files;
+      let name=file.raw.name
+      var image = new Image();
+      image.src = window.URL.createObjectURL(file.raw);
+      image.onload = function(){
+        let aaa= that.base64ToFile(that.compress(image, 500, 400, 0.7),name)
+      that.userbackImg = image.src;
       const params = new FormData(); // 声明formData数据类型
-      params.append("multipartFile", file);
+      params.append("multipartFile", aaa);
       params.append("type", "image");
-      this.$api.letter.uploadFile(params).then(res => {
+      that.$api.letter.uploadFile(params).then(res => {
         if (res.code == "200") {
-          let type = 'D0' + this.userIndex;
-          if (this['imageList' + this.userIndex].some(v => v.imageType == type)) {
-            this['imageList' + this.userIndex].map(val => {
+          let type = 'C0' + that.userIndex;
+          if (that['imageList' + that.userIndex].some(v => v.imageType == type)) {
+            that['imageList' + that.userIndex].map(val => {
               if (val.imageType == type) {
                 val.imageId = res.data.id;
               }
             })
-
           } else {
-            this['imageList' + this.userIndex].push({
+            that['imageList' + that.userIndex].push({
               imageId: res.data.id,
               imageType: type,
             })
           }
-          this[type + 'File'] = file;
+          that[type + 'File'] = file;
         } else {
-          this.$message({ message: res.msg, type: "warning" });
+          that.$message({ message: res.msg, type: "warning" });
         }
       });
+    }
+      //选择身份证背面
+      // var file = file.raw;
+      // let files = window.URL.createObjectURL(file); //转链接
+      // this.userbackImg = files;
+      // const params = new FormData(); // 声明formData数据类型
+      // params.append("multipartFile", file);
+      // params.append("type", "image");
+      // this.$api.letter.uploadFile(params).then(res => {
+      //   if (res.code == "200") {
+      //     let type = 'D0' + this.userIndex;
+      //     if (this['imageList' + this.userIndex].some(v => v.imageType == type)) {
+      //       this['imageList' + this.userIndex].map(val => {
+      //         if (val.imageType == type) {
+      //           val.imageId = res.data.id;
+      //         }
+      //       })
+
+      //     } else {
+      //       this['imageList' + this.userIndex].push({
+      //         imageId: res.data.id,
+      //         imageType: type,
+      //       })
+      //     }
+      //     this[type + 'File'] = file;
+      //   } else {
+      //     this.$message({ message: res.msg, type: "warning" });
+      //   }
+      // });
     },
     CarOCRdiscern() {
       //car识别
@@ -6462,6 +6596,21 @@ export default {
       this.imgList7 = [];
       this.imgList8 = [];
 
+      // 清空保险公司选中的意外险
+      this.insuranceZJ=''
+      this.insuranceZA=''
+      this.insuranceHB=''
+      this.insuranceRS=''
+      this.accidentForm = {
+        fen: "1",
+        premium:0
+      };
+      this.hengbangaccidentalDrivingVo={};
+      this.zhongmeiaccidentalDrivingVo={};
+      this.accidentalDrivingVo=[]
+      this.zhonganaccidentalDrivingVo={};
+      this.renshouaccidentalDrivingVo={};
+      this.anshengaccidentalDrivingVo={};
       // this.selectedOptions1 = [];
       // this.selectedOptions2 = [];
       // this.selectedOptions3 = [];

+ 3 - 0
src/views/Letter/Orderlist.vue

@@ -1872,6 +1872,9 @@ export default {
               }
             })
         }
+        else{
+          this.$message({ message:res.msg, type: "error" })
+        }
       })
     },
     //查询缴费状态