Authored by 王凤

Merge branch 'wangfeng-500-dev' into 'master-500-dev'

上传下载功能



See merge request !1241
@@ -113,10 +113,12 @@ @@ -113,10 +113,12 @@
113 <!--<el-form-item label="修复建议" prop="repairSuggestions">--> 113 <!--<el-form-item label="修复建议" prop="repairSuggestions">-->
114 <!-- <el-input type="textarea" v-model="docForm.repairSuggestions"></el-input>--> 114 <!-- <el-input type="textarea" v-model="docForm.repairSuggestions"></el-input>-->
115 <!--</el-form-item>--> 115 <!--</el-form-item>-->
116 - <el-form-item label="" prop="remark"> 116 + <el-form-item label="" prop="">
117 <el-upload 117 <el-upload
118 ref="upload" 118 ref="upload"
119 action="#" 119 action="#"
  120 + style="display: inline"
  121 + :auto-upload="false"
120 :limit="1" 122 :limit="1"
121 :on-exceed="handleExceed" 123 :on-exceed="handleExceed"
122 :auto-upload="false" 124 :auto-upload="false"
@@ -124,9 +126,10 @@ @@ -124,9 +126,10 @@
124 :on-change="handleUploadChange" 126 :on-change="handleUploadChange"
125 > 127 >
126 <template #trigger> 128 <template #trigger>
127 - <el-button type="primary">上 传 附 </el-button> 129 + <el-button type="primary">选择附</el-button>
128 </template> 130 </template>
129 </el-upload> 131 </el-upload>
  132 +
130 </el-form-item> 133 </el-form-item>
131 134
132 <el-form-item> 135 <el-form-item>
@@ -64,41 +64,10 @@ export default { @@ -64,41 +64,10 @@ export default {
64 remark:'', 64 remark:'',
65 impactSite:'', 65 impactSite:'',
66 repairSuggestions:'', 66 repairSuggestions:'',
67 - file:''  
68 } 67 }
69 } 68 }
70 - // 保存漏洞  
71 - const addFolder = ()=>{  
72 - // console.log(docForm.value);  
73 - ruleForm.value.validate((validate)=>{  
74 - if (validate){  
75 - proxy.$http.post('/api-web/vulnerabilities/save', docForm.value, function (res) {  
76 - addDialogVisible.value = false;  
77 - getVulnerabilityList();  
78 - docForm.value.name = '';  
79 - docForm.value.level = '';  
80 - docForm.value.remark = '';  
81 - docForm.value.impactSite = '';  
82 - docForm.value.repairSuggestions = '';  
83 - docForm.value.file = "";  
84 - })  
85 - }  
86 - })  
87 - }  
88 -  
89 - let upload = Vue.ref();  
90 - //文件选中时自动替换上一个文件  
91 - const handleExceed = (files)=>{  
92 - upload.value.clearFiles()  
93 - const file = files[0]  
94 - upload.value.handleStart(file)  
95 - }  
96 - const handleUploadChange = (uploadFile)=>{  
97 - let formData = new FormData();  
98 - formData.append('file',uploadFile)  
99 - docForm.value.file = formData;  
100 - }  
101 69
  70 + let vlunfile = Vue.ref();
102 let docForm = Vue.ref({ 71 let docForm = Vue.ref({
103 name:'', 72 name:'',
104 level:'', 73 level:'',
@@ -106,7 +75,6 @@ export default { @@ -106,7 +75,6 @@ export default {
106 remark:'', 75 remark:'',
107 impactSite:'', 76 impactSite:'',
108 repairSuggestions:'', 77 repairSuggestions:'',
109 - file:''  
110 }) 78 })
111 let docRulesForm = Vue.ref({ 79 let docRulesForm = Vue.ref({
112 name:[ 80 name:[
@@ -130,6 +98,50 @@ export default { @@ -130,6 +98,50 @@ export default {
130 98
131 let viewDrawer = Vue.ref(false) 99 let viewDrawer = Vue.ref(false)
132 100
  101 + // 保存漏洞
  102 + const addFolder = ()=>{
  103 + let formData = new FormData();
  104 + console.log(docForm.value,"docForm.value",vlunfile.value.raw)
  105 + formData.append("data", JSON.stringify(docForm.value));
  106 + formData.append("files",vlunfile.value.raw);
  107 + formData.append("access_token",localStorage.getItem('access_token'))
  108 + ruleForm.value.validate((validate)=>{
  109 + if (validate){
  110 + $.ajax({
  111 + url: sessionStorage.getItem('domainName') + '/api-web/vulnerabilities/save',
  112 + type: 'POST',
  113 + processData: false,
  114 + mimeType: "multipart/form-data",
  115 + contentType: false,
  116 + async: false,
  117 + data: formData,
  118 + success(res) {
  119 + proxy.$global.showMsg('添加成功');
  120 + addDialogVisible.value = false;
  121 + getVulnerabilityList();
  122 + docForm.value.name = '';
  123 + docForm.value.level = '';
  124 + docForm.value.remark = '';
  125 + docForm.value.impactSite = '';
  126 + docForm.value.repairSuggestions = '';
  127 + }
  128 + });
  129 + }
  130 + })
  131 + }
  132 +
  133 + let upload = Vue.ref();
  134 + //文件选中时自动替换上一个文件
  135 + const handleExceed = (files)=>{
  136 + upload.value.clearFiles()
  137 + const file = files[0]
  138 + upload.value.handleStart(file)
  139 + }
  140 + const handleUploadChange = (f)=>{
  141 + vlunfile.value = f;
  142 + }
  143 +
  144 +
133 // 查看详细 145 // 查看详细
134 const handleDetail = (obj) =>{ 146 const handleDetail = (obj) =>{
135 proxy.$http.get('/api-web/vulnerabilities/detail', {id:obj.id}, function (res) { 147 proxy.$http.get('/api-web/vulnerabilities/detail', {id:obj.id}, function (res) {
@@ -139,6 +151,7 @@ export default { @@ -139,6 +151,7 @@ export default {
139 } 151 }
140 }) 152 })
141 } 153 }
  154 +
142 // 处理按钮 155 // 处理按钮
143 let handleFun = (v)=>{ 156 let handleFun = (v)=>{
144 handleVisible.value = true; 157 handleVisible.value = true;
@@ -219,13 +232,15 @@ export default { @@ -219,13 +232,15 @@ export default {
219 232
220 // 下载文件 233 // 下载文件
221 const handleDownload = (row)=>{ 234 const handleDownload = (row)=>{
  235 + if(row.filePath){
222 proxy.$http.get('/api-web/vulnerabilities/download',{ 236 proxy.$http.get('/api-web/vulnerabilities/download',{
223 - path:row.filePath,  
224 - name:row.fileName, 237 + path: row.filePath,name:row.fileName
225 }, function (res) { 238 }, function (res) {
226 - console.log(res);  
227 - 239 + handleForm.value.manufacturerName = res.str;
228 }) 240 })
  241 + }else{
  242 + proxy.$global.showMsg("无附件信息", 'warning');
  243 + }
229 } 244 }
230 245
231 // 获取当前登陆人所属厂商 246 // 获取当前登陆人所属厂商