Authored by zhangtianqi

禅道:漏洞上传文件

@@ -106,11 +106,11 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions @@ -106,11 +106,11 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions
106 <form class="layui-form" style="margin-top: 15px;" lay-filter="vulnerabilityForm"> 106 <form class="layui-form" style="margin-top: 15px;" lay-filter="vulnerabilityForm">
107 <div class="layui-form-item"> 107 <div class="layui-form-item">
108 <label class="layui-form-label">漏洞名称:</label> 108 <label class="layui-form-label">漏洞名称:</label>
109 - <div class="layui-input-block">${d.name}</div> 109 + <div class="layui-input-block" style="line-height: 36px;">${d.name}</div>
110 </div> 110 </div>
111 <div class="layui-form-item"> 111 <div class="layui-form-item">
112 <label class="layui-form-label">漏洞详情:</label> 112 <label class="layui-form-label">漏洞详情:</label>
113 - <div class="layui-input-block">${d.remark}</div> 113 + <div class="layui-input-block" style="line-height: 36px;">${d.remark}</div>
114 </div> 114 </div>
115 115
116 <div class="layui-form-item"> 116 <div class="layui-form-item">
@@ -129,7 +129,9 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions @@ -129,7 +129,9 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions
129 <div><input type="hidden" id="vulnerabilitiesId" name="vulnerabilitiesId" value="${d.id}"></div> 129 <div><input type="hidden" id="vulnerabilitiesId" name="vulnerabilitiesId" value="${d.id}"></div>
130 </div> 130 </div>
131 <div class="layui-form-item"> 131 <div class="layui-form-item">
132 - <button type="button" class="download">下载附件</button> 132 + <label class="layui-form-label">
  133 + <button type="button" data-filePath="${d.filePath}" data-fileName="${d.fileName}" class="download layui-btn layui-btn-normal layui-btn-normal searchButton">下载附件</button>
  134 + </label>
133 </div> 135 </div>
134 </form> 136 </form>
135 ` 137 `
@@ -146,50 +148,15 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions @@ -146,50 +148,15 @@ layui.define(['common', 'swiper', 'admin', 'commonDetail', 'mxClient', 'sessions
146 move: false, 148 move: false,
147 success:()=>{ 149 success:()=>{
148 form.render(); 150 form.render();
149 - if(d.filePath){  
150 -  
151 - let docMime = d.fileName.slice(d.fileName.lastIndexOf('.') + 1); // 获取文件的后缀  
152 - console.log(docMime,"-------");  
153 - // 判断下载的文件类型  
154 - let mineType = "";  
155 - switch (docMime) {  
156 - case "xls":  
157 - mineType = "application/vnd.ms-excel";  
158 - break;  
159 - case "xlsx":  
160 - mineType = "application/vnd.ms-excel";  
161 - break;  
162 - case "docx":  
163 - mineType = "application/msword";  
164 - break;  
165 - case "doc":  
166 - mineType = "application/msword";  
167 - break;  
168 - case "zip":  
169 - mineType = "application/zip";  
170 - break;  
171 - case "html":  
172 - mineType = "text/html";  
173 - break;  
174 - case "markdown":  
175 - mineType = "text/markdown";  
176 - break;  
177 - default:  
178 - break; 151 + $('button.download').unbind("click").on('click',function (){
  152 + var filePath = $(this).data("filepath");
  153 + var fileName = $(this).data("filename");
  154 + if(filePath){
  155 + window.open(common.domainName+'/api-web/vulnerabilities/download?name='+fileName+'&access_token='+access_token)
  156 + }else{
  157 + layer.msg("无附件信息", {offset: '15px', icon: 7, time: 1000});
179 } 158 }
180 - let url = window.URL.createObjectURL(new Blob([d.filePath], { type: mineType }));  
181 - console.log(url);  
182 - let link = document.createElement("a");  
183 - link.style.display = "none";  
184 - link.href = url;  
185 - link.setAttribute("download", d.fileName);  
186 - document.body.appendChild(link);  
187 - link.click();  
188 - // 销毁超连接  
189 - window.URL.revokeObjectURL(url);  
190 - }else{  
191 - layer.msg("无附件信息", {offset: '15px', icon: 7, time: 1000});  
192 - } 159 + })
193 }, 160 },
194 yes:(index)=>{ 161 yes:(index)=>{
195 var formData = form.val('vulnerabilityForm'); 162 var formData = form.val('vulnerabilityForm');
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 :total="queryParams.count" 40 :total="queryParams.count"
41 @loaddata="getVulnerabilityList"> 41 @loaddata="getVulnerabilityList">
42 <template #default="{row,prop,column}"> 42 <template #default="{row,prop,column}">
43 - <el-popover placement="right" :width="700" trigger="click" :offset="prop=='remark'?-600:0"> 43 + <el-popover v-if="prop=='remark' || prop == 'name'" placement="right" :width="700" trigger="click" :offset="prop=='remark'?-600:0">
44 <template #reference> 44 <template #reference>
45 <div v-if="prop=='remark' || prop == 'name'" style=" 45 <div v-if="prop=='remark' || prop == 'name'" style="
46 overflow: hidden; 46 overflow: hidden;
@@ -56,6 +56,7 @@ @@ -56,6 +56,7 @@
56 </div> 56 </div>
57 </template> 57 </template>
58 </el-popover> 58 </el-popover>
  59 + <div v-else>{{row[prop]}}</div>
59 </template> 60 </template>
60 <template #tools="{scope}"> 61 <template #tools="{scope}">
61 <div class="list-handle"> 62 <div class="list-handle">
@@ -232,52 +232,8 @@ export default { @@ -232,52 +232,8 @@ export default {
232 232
233 // 下载文件 233 // 下载文件
234 const handleDownload = (row)=>{ 234 const handleDownload = (row)=>{
235 - if(row.filePath){  
236 -  
237 - let docMime = row.fileName.slice(row.fileName.lastIndexOf('.') + 1); // 获取文件的后缀  
238 - console.log(docMime,"-------");  
239 - // 判断下载的文件类型  
240 - let mineType = "";  
241 - switch (docMime) {  
242 - case "xls":  
243 - mineType = "application/vnd.ms-excel";  
244 - break;  
245 - case "xlsx":  
246 - mineType = "application/vnd.ms-excel";  
247 - break;  
248 - case "docx":  
249 - mineType = "application/msword";  
250 - break;  
251 - case "doc":  
252 - mineType = "application/msword";  
253 - break;  
254 - case "zip":  
255 - mineType = "application/zip";  
256 - break;  
257 - case "html":  
258 - mineType = "text/html";  
259 - break;  
260 - case "markdown":  
261 - mineType = "text/markdown";  
262 - break;  
263 - default:  
264 - break;  
265 - }  
266 - let url = window.URL.createObjectURL(new Blob([row.filePath], { type: mineType }));  
267 - let link = document.createElement("a");  
268 - link.style.display = "none";  
269 - link.href = url;  
270 - link.setAttribute("download", row.fileName);  
271 - document.body.appendChild(link);  
272 - link.click();  
273 - // 销毁超连接  
274 - window.URL.revokeObjectURL(url);  
275 -  
276 - // proxy.$http.get('/api-web/vulnerabilities/download',{  
277 - // path: row.filePath,name:row.fileName  
278 - // }, function (res) {  
279 - // handleForm.value.manufacturerName = res.str;  
280 - // }) 235 + if(row.fileName){
  236 + window.open(proxy.$http.getGateWay()+'/api-web/vulnerabilities/download?name='+row.fileName+'&access_token='+localStorage.getItem('access_token'))
281 }else{ 237 }else{
282 proxy.$global.showMsg("无附件信息", 'warning'); 238 proxy.$global.showMsg("无附件信息", 'warning');
283 } 239 }