浏览代码

修改图片上传

liyg 2 年之前
父节点
当前提交
5130ed1ed7

+ 19 - 0
src/utils/base64ToBlob.js

@@ -22,6 +22,25 @@ function base64ToBlob(urlData, type) {
   })
 }
 
+/**
+ * 返回图片本地file
+ * @param {*} urlData 
+ * @returns 
+ */
+export  function creatImageFile(urlData,fileName){
+  //获得blob对象
+  let blob = base64ToBlob(urlData, "image") 
+  //获取类型
+  let type=urlData.split("data:").join('').split(";base64")[0];
+  //创建文件对象
+  return transToFile(blob,fileName,type);
+}
+
+
+async function transToFile(blob, fileName, fileType) {
+  return new window.File([blob], fileName, {type: fileType})
+}
+
 /**
  * desc: 下载导出文件
  * @param blob  :返回数据的blob对象或链接

+ 21 - 11
src/views/statisticalReport/components/salesLogisticsStatistics/saleSteelReports.vue

@@ -1165,9 +1165,10 @@
             action="/api/v1/otms/addtmstruckArrivalResult"
             :limit="12"
             :on-change="fileChange1"
+            :on-remove="fileChange1"
             :on-preview="handlePictureCardPreview"
             :on-exceed="exceed"
-            accept=".jpg,.jpeg,.png,.gif,.bmp,.pdf,.JPG,.JPEG,.PBG,.GIF,.BMP,.PDF"
+            accept=".jpg,.jpeg,.png,.gif,.bmp,.JPG,.JPEG,.PBG,.GIF,.BMP,.PDF"
             :auto-upload="false"
           >
             <i class="el-icon-plus"></i>
@@ -1181,9 +1182,10 @@
             action="null"
             :limit="11"
             :on-change="fileChange2"
+            :on-remove="fileChange2"
             :on-preview="handlePictureCardPreview"
             :on-exceed="exceed"
-            accept=".jpg,.jpeg,.png,.gif,.bmp,.pdf,.JPG,.JPEG,.PBG,.GIF,.BMP,.PDF"
+            accept=".jpg,.jpeg,.png,.gif,.bmp,.JPG,.JPEG,.PBG,.GIF,.BMP,.PDF"
             :auto-upload="false"
           >
             <i class="el-icon-plus"></i>
@@ -1575,7 +1577,7 @@ import { sjTime, isVehicleNumber } from '@/utils/sharedJsFile'
 import { getCookie } from '@/utils/util.js'
 import PathView from './mapTest.vue'
 import currentLocation from './currentLocation.vue'
-import { downloadFile } from '@/utils/base64ToBlob.js'
+import { downloadFile,creatImageFile } from '@/utils/base64ToBlob.js'
 export default {
   components: {
     PathView,
@@ -2651,10 +2653,13 @@ export default {
           if (res.data) {
             this.arriavlList = []
             res.data.forEach((e, index) => {
-              this.arriavlList.push({
-                name: 'file' + index,
-                url: e
-              })
+              creatImageFile(e,'file1-'+index).then((res)=>{
+                this.arriavlList.push({
+                  name: 'file' + index,
+                  raw: res,
+                  url: e
+                })
+              });
             })
             this.fileListArrival = this.arriavlList
           }
@@ -2667,10 +2672,13 @@ export default {
           if (res.data) {
             this.receiveList = []
             res.data.forEach((e, index) => {
-              this.receiveList.push({
-                name: 'file' + index,
-                url: e
-              })
+              creatImageFile(e,'file2-'+index).then((res)=>{
+                this.receiveList.push({
+                  name: 'file' + index,
+                  raw: res,
+                  url: e
+                })
+              });
             })
             this.fileListReceive = this.receiveList
           }
@@ -2730,7 +2738,9 @@ export default {
         this.axios(options).then(res => {
           console.log('receiveRes:', res)
           this.$message.success('上传成功!')
+          this.steelMap.arrivalAddress = this.location
           this.closeUpload()
+          this.refresh();
         })
       })
     },