|
|
|
@ -25,10 +25,15 @@
|
|
|
|
|
<el-upload
|
|
|
|
|
class="upload-xml"
|
|
|
|
|
:action="action"
|
|
|
|
|
accept=".xml"
|
|
|
|
|
:on-preview="handlePreview"
|
|
|
|
|
:on-remove="handleRemove"
|
|
|
|
|
:before-remove="beforeRemove"
|
|
|
|
|
:limit="3"
|
|
|
|
|
:on-success="handleSuccess"
|
|
|
|
|
:on-progress="handleProgress"
|
|
|
|
|
:on-error="handleError"
|
|
|
|
|
:before-upload="beforeUpload"
|
|
|
|
|
:limit="5"
|
|
|
|
|
:on-exceed="handleExceed"
|
|
|
|
|
:file-list="fileList"
|
|
|
|
|
:data="extraData">
|
|
|
|
@ -94,7 +99,8 @@ export default {
|
|
|
|
|
list:[],
|
|
|
|
|
formData:null,
|
|
|
|
|
total:0,
|
|
|
|
|
extraData:{"prefix": "user"},
|
|
|
|
|
extraData:{"uuid": "upload-xml"},
|
|
|
|
|
uploadLoading: false,
|
|
|
|
|
action: process.env.VUE_APP_BASE_API + "/udiwms/relCode/batch/xmlUpload",
|
|
|
|
|
fileList: []
|
|
|
|
|
};
|
|
|
|
@ -159,16 +165,49 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleRemove(file, fileList) {
|
|
|
|
|
console.log(file, fileList);
|
|
|
|
|
console.log(file, fileList);
|
|
|
|
|
},
|
|
|
|
|
handlePreview(file) {
|
|
|
|
|
console.log(file);
|
|
|
|
|
},
|
|
|
|
|
handleExceed(files, fileList) {
|
|
|
|
|
this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
|
|
|
|
|
this.$message.warning(`当前限制选择 5 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
|
|
|
|
|
},
|
|
|
|
|
beforeRemove(file, fileList) {
|
|
|
|
|
return this.$confirm(`确定移除 ${ file.name }?`);
|
|
|
|
|
},
|
|
|
|
|
handleSuccess(res, file, fileList) {
|
|
|
|
|
fileList = fileList.filter(item => item.response.code === 20000);
|
|
|
|
|
this.fileList = fileList;
|
|
|
|
|
if (res.code === 20000) {
|
|
|
|
|
this.$message.success(res.message);
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(res.message);
|
|
|
|
|
}
|
|
|
|
|
this.uploadLoading.close();
|
|
|
|
|
},
|
|
|
|
|
beforeUpload(file) {
|
|
|
|
|
const isXML = file.type === 'text/xml';
|
|
|
|
|
const isLt5M = file.size / 1024 / 1024 < 5;
|
|
|
|
|
if (!isXML) {
|
|
|
|
|
this.$message.error('上传文件只能是 XML 格式!');
|
|
|
|
|
}
|
|
|
|
|
if (!isLt5M) {
|
|
|
|
|
this.$message.error('上传文件大小不能超过 5MB!');
|
|
|
|
|
}
|
|
|
|
|
return isXML && isLt5M;
|
|
|
|
|
},
|
|
|
|
|
handleProgress() {
|
|
|
|
|
this.uploadLoading = this.$loading({
|
|
|
|
|
lock: true,
|
|
|
|
|
text: '文件上传中…',
|
|
|
|
|
spinner: 'el-icon-loading',
|
|
|
|
|
background: 'rgba(0, 0, 0, 0.5)'
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
handleError() {
|
|
|
|
|
this.uploadLoading.close();
|
|
|
|
|
this.$message.error('文件上传失败,请检查文件大小或文件格式');
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
components: {},
|
|
|
|
|