[update] 文件导入 组件的修改1

This commit is contained in:
fengchenchen
2021-08-30 19:54:21 +08:00
parent e0819ed353
commit a8490aa2bf
2 changed files with 52 additions and 13 deletions
+6 -1
View File
@@ -96,6 +96,10 @@ const checkRuleByCode = (params) => getAction('/sys/checkRule/checkByCode', para
//加载我的通告信息 //加载我的通告信息
const getUserNoticeInfo= (params)=>getAction("/sys/sysAnnouncementSend/getMyAnnouncementSend",params); const getUserNoticeInfo= (params)=>getAction("/sys/sysAnnouncementSend/getMyAnnouncementSend",params);
const getTransitURL = url => `/sys/common/transitRESTful?url=${encodeURIComponent(url)}` const getTransitURL = url => `/sys/common/transitRESTful?url=${encodeURIComponent(url)}`
// 通过文件的id获取文件的相应信息
const getFileInfo = (params) => getAction('/sys/oss/file/queryById', params)
// 中转HTTP请求 // 中转HTTP请求
export const transitRESTful = { export const transitRESTful = {
get: (url, parameter) => getAction(getTransitURL(url), parameter), get: (url, parameter) => getAction(getTransitURL(url), parameter),
@@ -168,7 +172,8 @@ export {
resetUserPassword, resetUserPassword,
getContactsByCompany, getContactsByCompany,
queryallRoles, queryallRoles,
getContactsById getContactsById,
getFileInfo
} }
+46 -12
View File
@@ -33,6 +33,7 @@
import Vue from 'vue' import Vue from 'vue'
import { ACCESS_TOKEN } from "@/store/mutation-types" import { ACCESS_TOKEN } from "@/store/mutation-types"
import { getFileAccessHttpUrl } from '@/api/manage'; import { getFileAccessHttpUrl } from '@/api/manage';
import { getFileInfo } from '@/api/api';
const Base64 = require('js-base64').Base64 const Base64 = require('js-base64').Base64
const FILE_TYPE_ALL = "all" const FILE_TYPE_ALL = "all"
@@ -173,23 +174,39 @@
}) })
} }
}, },
initFileList(paths){ async initFileList(paths){
if(!paths || paths.length==0){ if(!paths || paths.length === 0){
this.fileList = []; this.fileList = [];
return; return;
} }
let arr = paths.split(",") let arr = paths.split(",")
if(this.returnId) { // 返回路径的时候,对路径进行操作,取出所属id
arr.map(item => item = getFileAccessHttpUrl(item)) if(!this.returnId && arr.length > 0) {
const newArr = []
arr.map(item => {
let itemArr = item.split('/')
newArr.push(itemArr[itemArr.length - 1])
})
arr = newArr
} }
for(var a=0;a<arr.length;a++){ const fileList = []
this.fileList.forEach((item)=>{ for (let a = 0; a < arr.length; a++) {
if (item.url === arr[a]){ // 获取每一个文件的信息,组成fileList
item.uid = uidGenerator() const fileObj = await this.getFileInfo(arr[a])
item.response.status = 'history' const url = getFileAccessHttpUrl(arr[a])
fileList.push({
uid: uidGenerator(),
name: fileObj.fileName,
status: 'done',
url: url,
response: {
status: 'history',
message: arr[a]
} }
}) })
} }
this.fileList = [...fileList]
}, },
handlePathChange(){ handlePathChange(){
let uploadFiles = this.fileList let uploadFiles = this.fileList
@@ -253,8 +270,8 @@
if(info.file.response.success){ if(info.file.response.success){
fileList = fileList.map((file) => { fileList = fileList.map((file) => {
if (file.response) { if (file.response) {
let reUrl = `${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.response.result.fileName}`; // let reUrl = `${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.response.result.fileName}`;
file.url = getFileAccessHttpUrl(reUrl); file.url = getFileAccessHttpUrl(file.response.result.id);
} }
return file; return file;
}); });
@@ -298,12 +315,29 @@
handlePreview(file) { handlePreview(file) {
if (file && file.url) { if (file && file.url) {
var fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/sys/common/download/${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.name}` var 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(Base64.encode(fileFullUrl))}`
let url = `${window._CONFIG['onlinePreviewDomainURL']}?url=${encodeURIComponent(fileFullUrl)}`
window.open(url) window.open(url)
} }
}, },
getFileUrl(fileId){ getFileUrl(fileId){
return `${window._CONFIG['domianURL']}/sys/common/download/${fileId}` return `${window._CONFIG['domianURL']}/sys/common/download/${fileId}`
},
/**
* 通过文件的id获取文件的相关信息
* @param id
*/
getFileInfo(id) {
return new Promise(resolve => {
let result = {}
getFileInfo({id: id}).then(res => {
if (res.success) {
result = res.result
}
}).finally(() => {
resolve(result)
})
})
} }
}, },
mounted(){}, mounted(){},