Commit c103cc9a by Yang

附件点击下载进行查看,附件上传格式限制

parent e2f86dbe
......@@ -27,6 +27,7 @@
:data="manageList"
style="width: 100%"
height="550"
@selection-change="handleSelectionChange1"
>
<el-table-column type="selection" width="55"></el-table-column>
......@@ -147,7 +148,8 @@
</el-select>
<span class="ml-15">提示:在word文档中编辑好后,复制黏贴到编辑框</span>
</el-form-item>
<el-form-item label="所属栏目" v-show="isShowColumn">
<!-- old --- v-show="isShowColumn" -->
<el-form-item label="所属栏目">
<el-row>
<el-col :span="6">
<!-- 工作信息->最高人民法院简报 -->
......@@ -195,6 +197,7 @@
:file-list="fileList"
:auto-upload="false"
action="#"
accept=".doc, .docx, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, .pdf, image/*, audio/*, video/*, .xls, .xlsx, .xml, .txt"
name="fileList"
:show-file-list="true"
:on-change="uploadSuccess"
......@@ -395,8 +398,8 @@
<!-- 创建未提交审核为5,提交审核为4,审核不通过为3,通过已发布为1 -->
<el-button type="primary" size="mini" @click="sbBatch">批量打开</el-button>
<!-- 是否采用,3为采用,2为不采用即已阅 -->
<el-button type="primary" size="mini" @click="sbBatchUseOrNot(3)">批量采用</el-button>
<el-button type="primary" size="mini" @click="sbBatchUseOrNot(2)">批量不采用</el-button>
<el-button type="primary" size="mini" @click="sbBatchUseOrNot(3)" v-if="reportRadio == '1'">批量采用</el-button>
<el-button type="primary" size="mini" @click="sbBatchUseOrNot(2)" v-if="reportRadio == '1'">批量已阅</el-button>
</el-row>
<div style="margin-top: 10px">
<el-pagination
......@@ -608,6 +611,7 @@
:show-file-list="true"
:on-change="uploadSuccessEdit"
:on-remove="handleRemoveEdit"
:on-preview="handlePreviewEdit"
>
<el-button disabled class="area-btn">浏览文件</el-button>
</el-upload>
......@@ -703,8 +707,10 @@
action="#"
name="fileList"
:show-file-list="true"
accept=".doc, .docx, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, .pdf, image/*, audio/*, video/*, .xls, .xlsx, .xml, .txt"
:on-change="uploadSuccessEdit"
:on-remove="handleRemoveEdit"
:on-preview="handlePreviewEdit"
>
<el-button class="area-btn">浏览文件</el-button>
</el-upload>
......@@ -837,10 +843,12 @@
:file-list="fileListEdit"
:auto-upload="false"
action="#"
accept=".doc, .docx, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, .pdf, image/*, audio/*, video/*, .xls, .xlsx, .xml, .txt"
name="fileList"
:show-file-list="true"
:on-change="uploadSuccessEdit"
:on-remove="handleRemoveEdit"
:on-preview="handlePreviewEdit"
>
<el-button class="area-btn">浏览文件</el-button>
</el-upload>
......@@ -1780,7 +1788,24 @@ export default {
//上传附件
uploadSuccess(file, list) {
this.fileList = list;
let fileSize = Number(file.size / 1024 / 1024);
if (fileSize > 20) {
this.$msgbox({
title: "",
message: "文件大小不能超过20MB,请重新上传。",
type: "warning"
});
list.forEach((el,index)=> {
if(file.uid == el.uid){
list.splice(index,1)
}
})
this.fileList = list;
return list;
} else {
this.fileList = list;
}
console.log("fileList----", this.fileList);
},
......@@ -1790,9 +1815,26 @@ export default {
},
//上传附件--编辑
uploadSuccessEdit(file, list) {
this.fileListEdit = list;
let fileSize = Number(file.size / 1024 / 1024);
if (fileSize > 20) {
this.$msgbox({
title: "",
message: "文件大小不能超过20MB,请重新上传。",
type: "warning"
});
list.forEach((el,index)=> {
if(file.uid == el.uid){
list.splice(index,1)
}
})
this.fileListEdit = list;
return list;
} else {
this.fileListEdit = list;
}
// this.addFileListEdit=list;
console.log("编辑新增----", this.list);
console.log("编辑新增----", this.fileListEdit);
},
handleRemoveEdit(file, list) {
console.log("fileListHandleRemove----", list);
......@@ -1816,6 +1858,54 @@ export default {
}
}
},
saveAs(blob, filename) {
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, filename);
} else {
var link = document.createElement("a");
var body = document.querySelector("body");
link.href = window.URL.createObjectURL(blob);
link.download = filename; // fix Firefox
link.style.display = "none";
body.appendChild(link);
link.click();
body.removeChild(link);
window.URL.revokeObjectURL(link.href);
}
},
download(url, filename) {
this.getBlob(url, blob => {
this.saveAs(blob, filename);
});
},
downloadFiles(file) {
this.download(file.downloadPath, file.attachName);
},
getBlob(url, cb) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.responseType = "blob";
xhr.onload = function() {
if (xhr.status === 200) {
cb(xhr.response);
}
};
xhr.send();
},
// 点击已上传文件
handlePreviewEdit(file){
this.downloadFiles(file);
// // 创建a标签
// var link = document.createElement("a");
// // href链接
// link.setAttribute("download", file.attachName);
// // link.download = file.name; //下载后文件名
// link.setAttribute("href", file.downloadPath);
// link.setAttribute("target", "view_window");
// // 自执行点击事件
// link.click();
},
// 发布新闻
createNewsEvent(num) {
// params.publish=num;// 然后是publish ,点击发布的话是1,提交审核是4,保存是5
......@@ -1827,6 +1917,22 @@ export default {
return;
}
// 总文件大小不超过50M
var allFileSize = 0;
this.fileList.forEach(el => {
allFileSize += el.size;
})
let fileSize = Number(allFileSize / 1024 / 1024);
if (fileSize > 50) {
this.$msgbox({
title: "",
message: "总文件大小不能超过50MB,请重新选择。",
type: "warning"
});
return
}
// if(!this.newsForm.assUser){
// this.$message({
// message: "请选择审核人",
......@@ -1960,6 +2066,23 @@ export default {
// return;
// }
this.fileListEdit = [...new Set(this.fileListEdit)];
var allFileSize2 = 0;
this.fileListEdit.forEach(el => {
if(el.attachSize){
allFileSize2 += el.attachSize;
}else if(el.size){
allFileSize2 += el.size;
}
})
let fileSize = Number(allFileSize2 / 1024 / 1024);
if (fileSize > 50) {
this.$msgbox({
title: "",
message: "总文件大小不能超过50MB,请重新选择。",
type: "warning"
});
return
}
this.fileListEdit.forEach(item => {
if (item.raw) {
formData.append("fileList", item.raw);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment