style:文件上传功能的完善
Showing
2 changed files
with
24 additions
and
5 deletions
| 1 | /* | 1 | /* |
| 2 | * @Description: 材料信息 | 2 | * @Description: 材料信息 |
| 3 | * @Autor: renchao | 3 | * @Autor: renchao |
| 4 | * @LastEditTime: 2023-05-16 14:04:42 | 4 | * @LastEditTime: 2023-07-28 14:31:00 |
| 5 | */ | 5 | */ |
| 6 | import request from '@/utils/request' | 6 | import request from '@/utils/request' |
| 7 | let SERVER = window.config ? window.config : JSON.parse(localStorage.getItem('ApiUrl')) | 7 | let SERVER = window.config ? window.config : JSON.parse(localStorage.getItem('ApiUrl')) |
| ... | @@ -75,6 +75,22 @@ export function uploadSjClmx (data) { | ... | @@ -75,6 +75,22 @@ export function uploadSjClmx (data) { |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | /** | 77 | /** |
| 78 | * @description: 上传duo个文件 | ||
| 79 | * @param {*} data | ||
| 80 | * @author: renchao | ||
| 81 | */ | ||
| 82 | export function uploadBatch (data) { | ||
| 83 | return request({ | ||
| 84 | url: SERVER.SERVERAPI + '/rest/ywbl/clxx/uploadBatch', | ||
| 85 | method: 'post', | ||
| 86 | headers: { | ||
| 87 | 'Content-Type': 'multipart/form-data' | ||
| 88 | }, | ||
| 89 | data | ||
| 90 | }) | ||
| 91 | } | ||
| 92 | |||
| 93 | /** | ||
| 78 | * @description: 删除上传文件 | 94 | * @description: 删除上传文件 |
| 79 | * @param {*} bsmClmx | 95 | * @param {*} bsmClmx |
| 80 | * @author: renchao | 96 | * @author: renchao | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Description: | 2 | * @Description: |
| 3 | * @Autor: renchao | 3 | * @Autor: renchao |
| 4 | * @LastEditTime: 2023-07-28 14:20:07 | 4 | * @LastEditTime: 2023-07-28 14:59:55 |
| 5 | --> | 5 | --> |
| 6 | <template> | 6 | <template> |
| 7 | <div class="rlPopup"> | 7 | <div class="rlPopup"> |
| ... | @@ -50,7 +50,7 @@ | ... | @@ -50,7 +50,7 @@ |
| 50 | <script> | 50 | <script> |
| 51 | import PhotoZoom from '@/components/PhotoZoom' | 51 | import PhotoZoom from '@/components/PhotoZoom' |
| 52 | import { getAltimeterInfo, getUuid } from '@/utils/operation.js' | 52 | import { getAltimeterInfo, getUuid } from '@/utils/operation.js' |
| 53 | import { uploadSjClmx, deleteClmx } from "@/api/clxx.js"; | 53 | import { uploadBatch, deleteClmx } from "@/api/clxx.js"; |
| 54 | import publicPicture from '@/components/publicPicture/index.vue' | 54 | import publicPicture from '@/components/publicPicture/index.vue' |
| 55 | export default { | 55 | export default { |
| 56 | name: 'PreviewImage', | 56 | name: 'PreviewImage', |
| ... | @@ -255,8 +255,9 @@ | ... | @@ -255,8 +255,9 @@ |
| 255 | async handleChange (file, fileList) { | 255 | async handleChange (file, fileList) { |
| 256 | let length = fileList.length; | 256 | let length = fileList.length; |
| 257 | this.maxFileLength = Math.max(length, this.maxFileLength) | 257 | this.maxFileLength = Math.max(length, this.maxFileLength) |
| 258 | console.log(fileList, this.maxFileLength, 'this.maxFileLength'); | ||
| 259 | var formData = new FormData(); | ||
| 258 | setTimeout(() => { | 260 | setTimeout(() => { |
| 259 | var formData = new FormData(); | ||
| 260 | if (this.maxFileLength !== length) { | 261 | if (this.maxFileLength !== length) { |
| 261 | return | 262 | return |
| 262 | } | 263 | } |
| ... | @@ -265,13 +266,15 @@ | ... | @@ -265,13 +266,15 @@ |
| 265 | }) | 266 | }) |
| 266 | formData.append("bsmSj", this.previewImg.bsmSj); | 267 | formData.append("bsmSj", this.previewImg.bsmSj); |
| 267 | formData.append("bsmSlsq", this.previewImg.bsmSlsq); | 268 | formData.append("bsmSlsq", this.previewImg.bsmSlsq); |
| 268 | uploadSjClmx(formData).then((res) => { | 269 | uploadBatch(formData).then((res) => { |
| 269 | if (res.code == 200) { | 270 | if (res.code == 200) { |
| 270 | this.$emit('updateList', res.result) | 271 | this.$emit('updateList', res.result) |
| 271 | this.$message({ | 272 | this.$message({ |
| 272 | message: '上传成功!', | 273 | message: '上传成功!', |
| 273 | type: 'success' | 274 | type: 'success' |
| 274 | }) | 275 | }) |
| 276 | this.$refs.upload.clearFiles(); | ||
| 277 | this.maxFileLength = 0 | ||
| 275 | } | 278 | } |
| 276 | }) | 279 | }) |
| 277 | }, 0) | 280 | }, 0) | ... | ... |
-
Please register or sign in to post a comment