Browse Source

Signed-off-by: Caner <5658514@qq.com>

Caner 4 years ago
parent
commit
62244c683a
1 changed files with 8 additions and 6 deletions
  1. 8 6
      web/src/pages/index/views/index.vue

+ 8 - 6
web/src/pages/index/views/index.vue

@@ -49,7 +49,7 @@ export default {
     // 选择多张图片
     selectImg(event) {
       const file = event.target.files;
-      const size = 2097152; //2M
+      const size = 10485760; //10M
       const newArr = [];
       if (file.length > 1) {
         Notice.warning({
@@ -61,12 +61,12 @@ export default {
         const el = file[j];
         if (el.size >= size) {
           Notice.warning({
-            desc: el.name + "大小超过2M限制请重新上传",
+            desc: el.name + "大小超过10M限制请重新上传",
           });
           break;
-        } else if (el.size >= size * 0.5) {
+        } else if (el.size >= size * 0.2) {
           Notice.warning({
-            desc: el.name + "大小超过限制将被压缩",
+            desc: el.name + "大小超过2M限制将被压缩",
           });
           // 压缩
           new ImageCompressor({
@@ -74,6 +74,7 @@ export default {
             quality: 0.3,
             mimeType: "image/jpeg",
             success: (result) => {
+              console.log('压缩后',result);
               newArr.push({
                 url: this.getObjectURL(result),
                 data: result,
@@ -209,8 +210,9 @@ export default {
     async reGetData(url,start) {
       const res = await axios.get(url);
       if (res.success) {
-        if(!res.data || !res.data.invoice_data.words_result  || !res.data.invoice_data.words_result.length) throw new Error("识别错误");
-        this.table = this.setData(res.data.invoice_data.words_result[0].result);
+        if(res.data && res.data.invoice_data.words_result  && res.data.invoice_data.words_result.length){
+          this.table = this.setData(res.data.invoice_data.words_result[0].result);
+        }
         const end = Date.now();
         Message.info({
           content: "识别总用时:" + Math.abs((start - end) / 1000) + "s",