diff --git a/src/components/jero/JUpload.vue b/src/components/jero/JUpload.vue index 186818b..99932d4 100644 --- a/src/components/jero/JUpload.vue +++ b/src/components/jero/JUpload.vue @@ -26,6 +26,25 @@ + + + @@ -33,9 +52,10 @@ import Vue from 'vue' import {ACCESS_TOKEN} from '@/store/mutation-types' -import {getFileAccessHttpUrl} from '@/api/manage' +import {getFileAccessHttpUrl, downloadFile} from '@/api/manage' import {getFileInfo} from '@/api/api' +// eslint-disable-next-line no-undef const Base64 = require('js-base64').Base64 const FILE_TYPE_ALL = 'all' @@ -120,6 +140,14 @@ export default { required: false, default: true }, + /** + * 是否显示下载和查看按钮 + **/ + showOtherIcon: { + type: Boolean, + required: false, + default: true + } }, watch: { value: { @@ -197,7 +225,7 @@ export default { // 获取每一个文件的信息,组成fileList // 突然想判断现在的fileList 中是否是历史的信息,如果是的话则先进行匹配 let isHistory = this.fileList.find(file => file.response.status === 'history' && (file.response.result || {}).id === arr[a]) - console.log("isHistory===", isHistory) + console.log('isHistory===', isHistory) if (isHistory) { fileList.push(isHistory) } else { @@ -217,6 +245,7 @@ export default { } } this.fileList = [...fileList] + this.showOtherIcon && this.actionsClass() }, handlePathChange() { let uploadFiles = this.fileList @@ -345,7 +374,10 @@ export default { console.log(file) }, handlePreview(file) { - console.log(file) + if (this.showOtherIcon) { + return + } + // eslint-disable-next-line no-unreachable if (file && file.url) { const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}` let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}` @@ -371,6 +403,41 @@ export default { resolve(result) }) }) + }, + // 修改删除按钮的样式,增加文字说明 + actionsClass(){ + this.$nextTick(()=>{ + let content = document.getElementsByClassName('ant-upload-list-item-card-actions') + for (let i = 0; i < content.length; i++) { + if ( content[i].childNodes.length > 0){ + // content[i].innerHTML = '' + content[i].childNodes[0].childNodes[0].innerHTML = ' \n' + + ' \n' + + ' 删除' + } + } + }) + }, + /** + * 单个文件的下载功能 + * @param file + */ + myDownload(file) { + downloadFile(`sys/common/download/${file.response.result.id}`, file.name) + }, + /** + * 单个文件的预览功能 + * @param file + */ + myPreview(file) { + if (file && file.url) { + const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}` + let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(Base64.encode(fileFullUrl))}` + // let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(fileFullUrl)}` + window.open(url) + } } }, mounted() { @@ -382,9 +449,9 @@ export default { } -