| | |
| | | class="upload-demo" |
| | | drag |
| | | action="#" |
| | | :on-remove="handleRemove" |
| | | :http-request="httpRequest" |
| | | :file-list="form.fileList" |
| | | :on-exceed="handleExceed" |
| | | :limit="1" |
| | | :accept="'.jpg,.jpeg,.png'" |
| | | multiple> |
| | | <i class="el-icon-upload"></i> |
| | | <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | |
| | | import fileDownload from '../../../../util/file' |
| | | export default { |
| | | data() { |
| | | return { |
| | |
| | | downLoadPost() { |
| | | this.$axios.get(this.$api.facilitiesAndEnvironment.exportOfLightningProtectionDetection,{responseType: "blob"}).then(res => { |
| | | this.outLoading = false |
| | | this.$message.success('导出成功') |
| | | const blob = new Blob([res],{ type: 'application/msword' }); |
| | | const url = URL.createObjectURL(blob); |
| | | const link = document.createElement('a'); |
| | | link.href = url; |
| | | link.download = '防雷检测导出' + '.xlsx'; |
| | | link.click(); |
| | | //将Blob 对象转换成字符串 |
| | | let reader = new FileReader(); |
| | | reader.readAsText(blob, 'utf-8'); |
| | | reader.onload = () => { |
| | | try { |
| | | let result = JSON.parse(reader.result); |
| | | if (result.message) { |
| | | this.$message.error(result.message); |
| | | } else { |
| | | const url = URL.createObjectURL(blob); |
| | | const link = document.createElement('a'); |
| | | link.href = url; |
| | | link.download = '防雷检测导出' + '.xlsx'; |
| | | link.click(); |
| | | this.$message.success('导出成功') |
| | | } |
| | | } catch (err) { |
| | | console.log(err); |
| | | const url = URL.createObjectURL(blob); |
| | | const link = document.createElement('a'); |
| | | link.href = url; |
| | | link.download = '防雷检测导出' + '.xlsx'; |
| | | link.click(); |
| | | this.$message.success('导出成功') |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | initData() { |
| | |
| | | }, |
| | | // 覆盖默认的上传行为,可以自定义上传的实现,将上传的文件依次添加到fileList数组中,支持多个文件 |
| | | httpRequest(option) { |
| | | this.form.fileData = [] |
| | | this.form.fileData.push(option) |
| | | }, |
| | | addImport() { |
| | |
| | | }) |
| | | }) |
| | | }, |
| | | handleRemove(file) { |
| | | this.$axios.delete(this.$api.personnel.deleteCNASFile + "?fileName=" + file.name).then(res => { |
| | | if (res.code === 201) return; |
| | | this.$message.success('删除成功!') |
| | | let index = this.form.fileList.indexOf(fileName) |
| | | if (index != -1) { |
| | | this.successFileList.splice(index, 1) |
| | | } |
| | | }) |
| | | }, |
| | | download(row) { |
| | | let url = ''; |
| | | |
| | | // fileDownload.downloadIamge(url, row.fileName) |
| | | url = this.javaApi + 'img/' + row.systemFileName |
| | | const link = document.createElement('a'); |
| | | link.href = url; |
| | | link.download = row.fileName; |
| | | link.click(); |
| | | url = this.javaApi + '/img/' + row.systemFileName |
| | | fileDownload.downloadIamge(url, row.fileName) |
| | | } |
| | | } |
| | | } |