gjy 2 years ago
parent
commit
5845d97082

+ 69 - 2
src/components/WsUpload/index.vue

@@ -29,6 +29,15 @@
         格式的文件,单个文件大小不能超过10M
         格式的文件,单个文件大小不能超过10M
       </div>
       </div>
     </div>
     </div>
+    <div>
+      <el-button
+       v-if="batchDown"
+        class="batchdown-btn"
+        size="small"
+        type="default"
+        @click="_handleDownClick"
+        >批量下载</el-button>
+    </div>
     <el-upload
     <el-upload
       action="#"
       action="#"
       list-type="picture-card"
       list-type="picture-card"
@@ -44,7 +53,7 @@
       </template>
       </template>
       <template v-slot:file="{ file }">
       <template v-slot:file="{ file }">
         <div class="thumbnail-group">
         <div class="thumbnail-group">
-          <el-image  v-if='getFileClass(file)=="ext png"||getFileClass(file)=="ext jpg"||getFileClass(file)=="ext jpeg"||getFileClass(file)=="ext JPG"'
+          <el-image  v-if='getFileClass(file)=="ext png"||getFileClass(file)=="ext jpg"||getFileClass(file)=="ext jpeg"||getFileClass(file)=="ext JPG"||getFileClass(file)=="ext PNG"'
           :src='file.url'
           :src='file.url'
   class="el-upload-list__item-thumbnail"
   class="el-upload-list__item-thumbnail"
             :class="getFileClass(file)"
             :class="getFileClass(file)"
@@ -123,6 +132,8 @@ import downloadNow from '../WsDownload/download'
 import { EventBus } from 'base-core-lib'
 import { EventBus } from 'base-core-lib'
 import pdf from '@/components/pdf/pdf'
 import pdf from '@/components/pdf/pdf'
 import { mapActions } from 'vuex'
 import { mapActions } from 'vuex'
+import JSZip from 'jszip';
+import FileSaver from 'file-saver';
 export default {
 export default {
   name: 'WsUpload',
   name: 'WsUpload',
   components: {
   components: {
@@ -191,6 +202,11 @@ export default {
       type: String,
       type: String,
       required: false,
       required: false,
     },
     },
+    batchDown: {
+      // 要保存的表的名字
+      type: String,
+      required: false,
+    },
     onlineEdit: false,
     onlineEdit: false,
     disabled: false,
     disabled: false,
     buttonName: {
     buttonName: {
@@ -316,7 +332,55 @@ export default {
         }
         }
       }
       }
     },
     },
-
+    _handleDownClick(){
+      console.log(this.fileList,111)
+      var arr=[]
+      for (let i = 0; i < this.fileList.length; i++) {
+        arr.push(this.fileList[i].url+'?s=' + Math.random().toString())
+      }
+      let urls = arr
+          let promises = [];
+          urls.map((item) => {
+            promises.push(this.getBase64Image(item));
+          });
+
+          Promise.all(promises)
+            .then((result) => {
+              let zip = new JSZip();// 创建压缩包
+              let img = zip.folder("image"); // 创建文件夹
+              let number = 0;
+              result.map((p) => {
+                let i = number++;
+                img.file(`${i}.png`, p, {
+                  base64: true,
+                });
+              });
+              zip.generateAsync({ type: "blob" }).then(function (content) {
+                // see FileSaver.js
+                FileSaver.saveAs(content, "image.zip");
+              });
+            })
+            .catch((err) => {});
+    },
+    getBase64Image(src) {
+      return new Promise(function (resolve, reject) {
+        var canvas = document.createElement("canvas"),
+          ctx = canvas.getContext("2d"),
+          img = new Image();
+        img.crossOrigin = "Access-Control-Allow-Origin";
+        img.onload = function () {
+          canvas.height = img.height;
+          canvas.width = img.width;
+          ctx.drawImage(img, 0, 0);
+          var dataURL = canvas.toDataURL("image/png");
+          let deleDataHeader = dataURL.split(",")[1];
+          resolve(deleDataHeader);
+          canvas = null;
+        };
+        //这个很重要
+        img.src =src;
+      });
+    },
     // 处理上传按钮点击
     // 处理上传按钮点击
     _handleUploadClick() {
     _handleUploadClick() {
       this.$refs.triggerDiv.click()
       this.$refs.triggerDiv.click()
@@ -793,4 +857,7 @@ $ctrl-margin-left: 10px;
 .operate-bg:hover {
 .operate-bg:hover {
   opacity: 0;
   opacity: 0;
 }
 }
+.batchdown-btn{
+  margin-bottom:10px;
+}
 </style>
 </style>

+ 1 - 1
src/views/universalityAudit/audit.vue

@@ -151,7 +151,7 @@
     </el-dialog>
     </el-dialog>
     <WinseaContentModal v-model="accessoryTFs" :title="$t('system.noticeCircular.information')"
     <WinseaContentModal v-model="accessoryTFs" :title="$t('system.noticeCircular.information')"
       @on-cancel="handleClose">
       @on-cancel="handleClose">
-      <ws-upload ref="upload" :comp-id="compId" :appendix-ids="appendixIdss" :editable="false"
+      <ws-upload ref="upload" :comp-id="compId" :appendix-ids="appendixIdss" :batch-down="true" :editable="false"
         accept=".jpg, .jpeg, .png, .pdf, .doc, .zip, .rar" />
         accept=".jpg, .jpeg, .png, .pdf, .doc, .zip, .rar" />
     </WinseaContentModal>
     </WinseaContentModal>
     <el-dialog width="50%" :visible.sync="dialogVisible1" title="审核记录">
     <el-dialog width="50%" :visible.sync="dialogVisible1" title="审核记录">

+ 1 - 2
src/views/warehousenew/dryWarehousing.vue

@@ -795,7 +795,6 @@ export default {
         },
         },
         tabClick(val) {
         tabClick(val) {
             this.weighingList = {}
             this.weighingList = {}
-            
             for (let i = 0; i < this.warehouseList.length; i++) {
             for (let i = 0; i < this.warehouseList.length; i++) {
                 if (this.warehouseList[i].warehouseName == this.warehouseName) {
                 if (this.warehouseList[i].warehouseName == this.warehouseName) {
                     this.warehouseId = this.warehouseList[i].id
                     this.warehouseId = this.warehouseList[i].id
@@ -811,7 +810,7 @@ export default {
                 this.cartips = '手动输入'//用来点称皮重时显示皮重输入框
                 this.cartips = '手动输入'//用来点称皮重时显示皮重输入框
             } else {
             } else {
               this.weighingList.goodsName = this.goodsNameList[0].constValue
               this.weighingList.goodsName = this.goodsNameList[0].constValue
-            this.weighingList.goodsNameKey = this.goodsNameList[0].constKey
+              this.weighingList.goodsNameKey = this.goodsNameList[0].constKey
                 this.tpyeNo = '2'
                 this.tpyeNo = '2'
                 this.information = '毛重'
                 this.information = '毛重'
             }
             }