[update] 文件导入 组件的修改1
This commit is contained in:
+6
-1
@@ -96,6 +96,10 @@ const checkRuleByCode = (params) => getAction('/sys/checkRule/checkByCode', para
|
||||
//加载我的通告信息
|
||||
const getUserNoticeInfo= (params)=>getAction("/sys/sysAnnouncementSend/getMyAnnouncementSend",params);
|
||||
const getTransitURL = url => `/sys/common/transitRESTful?url=${encodeURIComponent(url)}`
|
||||
|
||||
// 通过文件的id获取文件的相应信息
|
||||
const getFileInfo = (params) => getAction('/sys/oss/file/queryById', params)
|
||||
|
||||
// 中转HTTP请求
|
||||
export const transitRESTful = {
|
||||
get: (url, parameter) => getAction(getTransitURL(url), parameter),
|
||||
@@ -168,7 +172,8 @@ export {
|
||||
resetUserPassword,
|
||||
getContactsByCompany,
|
||||
queryallRoles,
|
||||
getContactsById
|
||||
getContactsById,
|
||||
getFileInfo
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
import Vue from 'vue'
|
||||
import { ACCESS_TOKEN } from "@/store/mutation-types"
|
||||
import { getFileAccessHttpUrl } from '@/api/manage';
|
||||
import { getFileInfo } from '@/api/api';
|
||||
const Base64 = require('js-base64').Base64
|
||||
|
||||
const FILE_TYPE_ALL = "all"
|
||||
@@ -173,23 +174,39 @@
|
||||
})
|
||||
}
|
||||
},
|
||||
initFileList(paths){
|
||||
if(!paths || paths.length==0){
|
||||
async initFileList(paths){
|
||||
if(!paths || paths.length === 0){
|
||||
this.fileList = [];
|
||||
return;
|
||||
}
|
||||
let arr = paths.split(",")
|
||||
if(this.returnId) {
|
||||
arr.map(item => item = getFileAccessHttpUrl(item))
|
||||
// 返回路径的时候,对路径进行操作,取出所属id
|
||||
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++){
|
||||
this.fileList.forEach((item)=>{
|
||||
if (item.url === arr[a]){
|
||||
item.uid = uidGenerator()
|
||||
item.response.status = 'history'
|
||||
const fileList = []
|
||||
for (let a = 0; a < arr.length; a++) {
|
||||
// 获取每一个文件的信息,组成fileList
|
||||
const fileObj = await this.getFileInfo(arr[a])
|
||||
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(){
|
||||
let uploadFiles = this.fileList
|
||||
@@ -253,8 +270,8 @@
|
||||
if(info.file.response.success){
|
||||
fileList = fileList.map((file) => {
|
||||
if (file.response) {
|
||||
let reUrl = `${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.response.result.fileName}`;
|
||||
file.url = getFileAccessHttpUrl(reUrl);
|
||||
// let reUrl = `${file.response.result.id}?token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${file.response.result.fileName}`;
|
||||
file.url = getFileAccessHttpUrl(file.response.result.id);
|
||||
}
|
||||
return file;
|
||||
});
|
||||
@@ -298,12 +315,29 @@
|
||||
handlePreview(file) {
|
||||
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}`
|
||||
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)
|
||||
}
|
||||
},
|
||||
getFileUrl(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(){},
|
||||
|
||||
Reference in New Issue
Block a user