123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- import { downLoad2 } from '@/utils'
- export const File = {
- methods: {
- downLoad(item){
- if(item.originalName){
- var href = `http://${this.$c.hostname}:8801/fileManager/downloadSystemFile?fileId=${item.id}`
- const anchor = document.createElement('a');
- const fileName = 'download';
- if ('download' in anchor) {
- anchor.href = href;
- anchor.setAttribute("download", fileName);
- anchor.className = "download-js-link";
- anchor.innerHTML = "downloading...";
- anchor.style.display = "none";
- document.body.appendChild(anchor);
- setTimeout(function () {
- anchor.click();
- document.body.removeChild(anchor);
- }, 66);
- return true;
- }
- }else{
- downLoad2(item.url)
- }
-
- },
- preview(row){
- var item = JSON.parse(JSON.stringify(row))
- if(item.originalName){
- item.url = `http://${this.$c.hostname}:8801/fileManager/downloadSystemFile?fileId=${item.id}`
- var arr = ['png','jpeg','bmp','jpg']
- if(arr.includes(item.suffix)){
- var FileUrl = item.url
- var isPicture = 1
- }else if(item.suffix == 'pdf'){
- var FileUrl = item.url
- var isPicture = 0
- }else{
- var FileUrl = `http://${this.$c.hostname}:8012/onlinePreview?url=`+ btoa(encodeURIComponent(item.url))
- var isPicture = 0
- }
- const router = this.$router.resolve({
- path: '/checkFile',
- query: {
- row: JSON.stringify(item),
- FileUrl: FileUrl,
- isPicture:isPicture
- }
- })
- window.open(router.href, '_blank');
- return false
- }
- var arr = ['png','jpeg','bmp','jpg']
- if(arr.includes(item.suffix)){
- var FileUrl = this.$p + item.url
- var isPicture = 1
- }else if(item.suffix == 'pdf'){
- var FileUrl = this.$p + item.url
- var isPicture = 0
- }else{
- var FileUrl = `http://${this.$c.hostname}:8012/onlinePreview?url=`+ btoa(encodeURIComponent(this.$p + item.url))
- var isPicture = 0
- }
- const router = this.$router.resolve({
- path: '/checkFile',
- query: {
- row: JSON.stringify(item),
- FileUrl: FileUrl,
- isPicture:isPicture
- }
- })
- window.open(router.href, '_blank');
- },
- delFile(item){
- this.$emit('delFile',item.id)
- }
- },
- }
|