Authored by zhangtianqi

禅道:漏洞上传文件

... ... @@ -106,11 +106,11 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions
<form class="layui-form" style="margin-top: 15px;" lay-filter="vulnerabilityForm">
<div class="layui-form-item">
<label class="layui-form-label">漏洞名称:</label>
<div class="layui-input-block">${d.name}</div>
<div class="layui-input-block" style="line-height: 36px;">${d.name}</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">漏洞详情:</label>
<div class="layui-input-block">${d.remark}</div>
<div class="layui-input-block" style="line-height: 36px;">${d.remark}</div>
</div>
<div class="layui-form-item">
... ... @@ -129,7 +129,9 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions
<div><input type="hidden" id="vulnerabilitiesId" name="vulnerabilitiesId" value="${d.id}"></div>
</div>
<div class="layui-form-item">
<button type="button" class="download">下载附件</button>
<label class="layui-form-label">
<button type="button" data-filePath="${d.filePath}" data-fileName="${d.fileName}" class="download layui-btn layui-btn-normal layui-btn-normal searchButton">下载附件</button>
</label>
</div>
</form>
`
... ... @@ -146,50 +148,15 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions
move: false,
success:()=>{
form.render();
if(d.filePath){
let docMime = d.fileName.slice(d.fileName.lastIndexOf('.') + 1); // 获取文件的后缀
console.log(docMime,"-------");
// 判断下载的文件类型
let mineType = "";
switch (docMime) {
case "xls":
mineType = "application/vnd.ms-excel";
break;
case "xlsx":
mineType = "application/vnd.ms-excel";
break;
case "docx":
mineType = "application/msword";
break;
case "doc":
mineType = "application/msword";
break;
case "zip":
mineType = "application/zip";
break;
case "html":
mineType = "text/html";
break;
case "markdown":
mineType = "text/markdown";
break;
default:
break;
$('button.download').unbind("click").on('click',function (){
var filePath = $(this).data("filepath");
var fileName = $(this).data("filename");
if(filePath){
window.open(common.domainName+'/api-web/vulnerabilities/download?name='+fileName+'&access_token='+access_token)
}else{
layer.msg("无附件信息", {offset: '15px', icon: 7, time: 1000});
}
let url = window.URL.createObjectURL(new Blob([d.filePath], { type: mineType }));
console.log(url);
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", d.fileName);
document.body.appendChild(link);
link.click();
// 销毁超连接
window.URL.revokeObjectURL(url);
}else{
layer.msg("无附件信息", {offset: '15px', icon: 7, time: 1000});
}
})
},
yes:(index)=>{
var formData = form.val('vulnerabilityForm');
... ...
... ... @@ -40,7 +40,7 @@
:total="queryParams.count"
@loaddata="getVulnerabilityList">
<template #default="{row,prop,column}">
<el-popover placement="right" :width="700" trigger="click" :offset="prop=='remark'?-600:0">
<el-popover v-if="prop=='remark' || prop == 'name'" placement="right" :width="700" trigger="click" :offset="prop=='remark'?-600:0">
<template #reference>
<div v-if="prop=='remark' || prop == 'name'" style="
overflow: hidden;
... ... @@ -56,6 +56,7 @@
</div>
</template>
</el-popover>
<div v-else>{{row[prop]}}</div>
</template>
<template #tools="{scope}">
<div class="list-handle">
... ...
... ... @@ -232,52 +232,8 @@ export default {
// 下载文件
const handleDownload = (row)=>{
if(row.filePath){
let docMime = row.fileName.slice(row.fileName.lastIndexOf('.') + 1); // 获取文件的后缀
console.log(docMime,"-------");
// 判断下载的文件类型
let mineType = "";
switch (docMime) {
case "xls":
mineType = "application/vnd.ms-excel";
break;
case "xlsx":
mineType = "application/vnd.ms-excel";
break;
case "docx":
mineType = "application/msword";
break;
case "doc":
mineType = "application/msword";
break;
case "zip":
mineType = "application/zip";
break;
case "html":
mineType = "text/html";
break;
case "markdown":
mineType = "text/markdown";
break;
default:
break;
}
let url = window.URL.createObjectURL(new Blob([row.filePath], { type: mineType }));
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", row.fileName);
document.body.appendChild(link);
link.click();
// 销毁超连接
window.URL.revokeObjectURL(url);
// proxy.$http.get('/api-web/vulnerabilities/download',{
// path: row.filePath,name:row.fileName
// }, function (res) {
// handleForm.value.manufacturerName = res.str;
// })
if(row.fileName){
window.open(proxy.$http.getGateWay()+'/api-web/vulnerabilities/download?name='+row.fileName+'&access_token='+localStorage.getItem('access_token'))
}else{
proxy.$global.showMsg("无附件信息", 'warning');
}
... ...