Commit 83f4732b by liangzhen

限制大小

1 parent a4101706
...@@ -88,6 +88,10 @@ axios.interceptors.response.use(response => { ...@@ -88,6 +88,10 @@ axios.interceptors.response.use(response => {
return response; return response;
} }
}, err => { }, err => {
if (loadingInstance) {
loadingInstance.close();
Message.error('上传失败')
}
if (err && err.response) { if (err && err.response) {
console.log('连接到服务器失败'); console.log('连接到服务器失败');
} else { } else {
......
...@@ -245,6 +245,7 @@ ...@@ -245,6 +245,7 @@
return fileupdate(scope.row, res); return fileupdate(scope.row, res);
} }
" "
:before-upload="beforeUpload"
:on-change="uploadChange" :on-change="uploadChange"
:with-credentials="true" :with-credentials="true"
:auto-upload="true" :auto-upload="true"
...@@ -512,6 +513,14 @@ export default { ...@@ -512,6 +513,14 @@ export default {
}, },
methods: { methods: {
beforeUpload(file) {
console.log( file.size / 1024 / 1024,'多大')
const isLt500M = file.size / 1024 / 1024 < 500;
if (!isLt500M) {
this.$message.error('上传的文件不能超过500MB!');
}
return isLt500M;
},
numberVal(val) { numberVal(val) {
this.$forceUpdate(); this.$forceUpdate();
}, },
...@@ -767,7 +776,6 @@ export default { ...@@ -767,7 +776,6 @@ export default {
// 移除附件 // 移除附件
// 监控上传文件列表 // 监控上传文件列表
uploadChange(file, fileList) { uploadChange(file, fileList) {
// console.log(fileList, "this.fileList");
// let existFile = fileList // let existFile = fileList
// .slice(0, fileList.length - 1) // .slice(0, fileList.length - 1)
// .find((f) => f.name === file.name); // .find((f) => f.name === file.name);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!