| | |
| | | <div class="el-upload__tip" slot="tip">支持单个或批量上传,请选择PDF文件</div> |
| | | </el-upload> |
| | | </div> |
| | | |
| | | |
| | | <!-- 下载按钮区域 - 上传前禁用,上传后可用 --> |
| | | <div class="download-container" style="white-space: nowrap;"> |
| | | <el-button |
| | | type="primary" |
| | | icon="el-icon-download" |
| | | <el-button |
| | | type="primary" |
| | | icon="el-icon-download" |
| | | @click="downloadFile" |
| | | :disabled="!canDownload" |
| | | > |
| | |
| | | </a> |
| | | </div> |
| | | <div> |
| | | <el-button |
| | | type="text" |
| | | icon="el-icon-copy-document" |
| | | <el-button |
| | | type="text" |
| | | icon="el-icon-copy-document" |
| | | @click="copyLink" |
| | | size="small" |
| | | > |
| | |
| | | import { getToken } from '@/utils/auth' |
| | | import { getPdfFile } from '@/api/system/dpdf' |
| | | export default { |
| | | name: "DoublePdf", |
| | | name: "Pdf", |
| | | data() { |
| | | return { |
| | | fid: '', |
| | |
| | | getList() { |
| | | this.loading = true |
| | | }, |
| | | |
| | | |
| | | /** 上传前检查 */ |
| | | beforeUpload(file) { |
| | | const isPdf = file.type === 'application/pdf' |
| | | const isLt50M = file.size / 1024 / 1024 < 50 |
| | | |
| | | |
| | | if (!isPdf) { |
| | | this.$message.error('上传文件只能是 PDF 格式!') |
| | | } |
| | | if (!isLt50M) { |
| | | this.$message.error('上传文件大小不能超过 50MB!') |
| | | } |
| | | |
| | | |
| | | return isPdf && isLt50M |
| | | }, |
| | | |
| | | |
| | | /** 上传成功处理 */ |
| | | handleUploadSuccess(response) { |
| | | console.log(response) |
| | |
| | | this.$message.error(response.msg || '上传失败') |
| | | } |
| | | }, |
| | | |
| | | |
| | | /** 获取下载链接 */ |
| | | downloadFile() { |
| | | // 发起ajax请求获取下载链接 |
| | |
| | | this.$message.error('获取下载链接失败,请重试') |
| | | }) |
| | | }, |
| | | |
| | | |
| | | /** 复制链接到剪贴板 */ |
| | | copyLink() { |
| | | if (this.displayedDownloadLink) { |
| | |
| | | textarea.style.opacity = '0' |
| | | document.body.appendChild(textarea) |
| | | textarea.select() |
| | | |
| | | |
| | | try { |
| | | document.execCommand('copy') |
| | | this.$message.success('链接已复制到剪贴板') |
| | |
| | | } |
| | | } |
| | | }, |
| | | |
| | | |
| | | /** 上传失败处理 */ |
| | | handleUploadError(err) { |
| | | this.$message.error('上传失败,请重试') |