|
@@ -144,12 +144,12 @@ export async function httpRequest (file, name, type) { // 阿里云OSS上传
|
|
const fileName = filePath + name + '.' + exname
|
|
const fileName = filePath + name + '.' + exname
|
|
console.log(fileName, '文件名')
|
|
console.log(fileName, '文件名')
|
|
|
|
|
|
- client.multipartUpload(fileName, file.file, {
|
|
|
|
- progress: function (p, checkpoint) {
|
|
|
|
|
|
+ await client.multipartUpload(fileName, file.file, {
|
|
|
|
+ progress: await function (p, checkpoint) {
|
|
file.onProgress({percent: Math.floor(p * 100)}) // 触发el-upload组件的onProgress方法
|
|
file.onProgress({percent: Math.floor(p * 100)}) // 触发el-upload组件的onProgress方法
|
|
}
|
|
}
|
|
// mime: type,
|
|
// mime: type,
|
|
- }).then(function (result) {
|
|
|
|
|
|
+ }).then(await function (result) {
|
|
console.log(result)
|
|
console.log(result)
|
|
if (result.res.status === 200) {
|
|
if (result.res.status === 200) {
|
|
// file.onSuccess(result) // 触发el-upload组件的onSuccess方法
|
|
// file.onSuccess(result) // 触发el-upload组件的onSuccess方法
|
|
@@ -171,62 +171,39 @@ function getTemporaryByUrl (url) {
|
|
}
|
|
}
|
|
|
|
|
|
export async function openWindowOnUrl (row) {
|
|
export async function openWindowOnUrl (row) {
|
|
- var rowurl = ''
|
|
|
|
|
|
+ if (row.url === undefined || row.url === null || row.url === '') {
|
|
|
|
+ // Message.error('没有获取到文件的url')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ let rowUrl = ''
|
|
let suffix = row.name.substring(row.name.lastIndexOf('.') + 1)
|
|
let suffix = row.name.substring(row.name.lastIndexOf('.') + 1)
|
|
if (suffix === 'jpg' || suffix === 'png' || suffix === 'gif' || suffix === 'bmp' || suffix === 'jpeg') {
|
|
if (suffix === 'jpg' || suffix === 'png' || suffix === 'gif' || suffix === 'bmp' || suffix === 'jpeg') {
|
|
- if (row.url !== null && row.url !== undefined && row.url !== '') {
|
|
|
|
|
|
+ await getTemporaryByUrl(row.url).then((data) => {
|
|
// eslint-disable-next-line no-undef
|
|
// eslint-disable-next-line no-undef
|
|
- onPreview(row.temporaryUrl)
|
|
|
|
- return
|
|
|
|
- } else {
|
|
|
|
- await getTemporaryByUrl(row.raw.url).then((data) => {
|
|
|
|
- // eslint-disable-next-line no-undef
|
|
|
|
- onPreview(data.data)
|
|
|
|
- })
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (row.url !== null && row.url !== undefined && row.url !== '') {
|
|
|
|
- if (suffix === 'pdf') {
|
|
|
|
- window.open('https://view.xdocin.com/xdoc?_xdoc=' + encodeURIComponent(row.temporaryUrl), '_blank')
|
|
|
|
- } else if (suffix === 'rar' || suffix === 'zip' || suffix === 'jar' || suffix === '7z') {
|
|
|
|
- window.open('http://ow365.cn/?i=30045&furl=' + encodeURIComponent(row.temporaryUrl), '_blank')
|
|
|
|
- } else {
|
|
|
|
- window.open('https://view.officeapps.live.com/op/view.aspx?src=' + encodeURIComponent(row.temporaryUrl), '_blank')
|
|
|
|
- }
|
|
|
|
- } else if (row.raw.url !== null && row.raw.url !== undefined && row.raw.url !== '') {
|
|
|
|
- await getTemporaryByUrl(row.raw.url).then((data) => {
|
|
|
|
- rowurl = data.data
|
|
|
|
|
|
+ onPreview(data.data)
|
|
})
|
|
})
|
|
- if (suffix === 'pdf') {
|
|
|
|
- window.open('https://view.xdocin.com/xdoc?_xdoc=' + encodeURIComponent(rowurl), '_blank')
|
|
|
|
- } else if (suffix === 'rar' || suffix === 'zip' || suffix === 'jar' || suffix === '7z') {
|
|
|
|
- window.open('http://ow365.cn/?i=30045&furl=' + encodeURIComponent(rowurl), '_blank')
|
|
|
|
- } else {
|
|
|
|
- window.open('https://view.officeapps.live.com/op/view.aspx?src=' + encodeURIComponent(rowurl), '_blank')
|
|
|
|
- }
|
|
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ await getTemporaryByUrl(row.url).then((data) => {
|
|
|
|
+ rowUrl = data.data
|
|
|
|
+ })
|
|
|
|
+ if (suffix === 'pdf') {
|
|
|
|
+ window.open('https://view.xdocin.com/xdoc?_xdoc=' + encodeURIComponent(rowUrl), '_blank')
|
|
|
|
+ } else if (suffix === 'rar' || suffix === 'zip' || suffix === 'jar' || suffix === '7z') {
|
|
|
|
+ window.open('http://ow365.cn/?i=30045&furl=' + encodeURIComponent(rowUrl), '_blank')
|
|
|
|
+ } else {
|
|
|
|
+ window.open('https://view.officeapps.live.com/op/view.aspx?src=' + encodeURIComponent(rowUrl), '_blank')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
export async function toHref (row) {
|
|
export async function toHref (row) {
|
|
|
|
+ if (row.url === null || row.url === undefined || row.url === '') {
|
|
|
|
+ // Message.error('没有获取到文件的url')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
const link = document.createElement('a')
|
|
const link = document.createElement('a')
|
|
- if (row.id === null || row.id === undefined || row.id === '') {
|
|
|
|
- await getTemporaryByUrl(row.raw.url).then((data) => {
|
|
|
|
- const url = data.data // 完整的url则直接使用
|
|
|
|
- // 这里是将url转成blob地址,
|
|
|
|
- fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
|
|
|
|
- link.href = URL.createObjectURL(blob)
|
|
|
|
- link.download = row.name || '' // 下载文件的名字
|
|
|
|
- // a.download = url.split('/')[url.split('/').length -1] // // 下载文件的名字
|
|
|
|
- document.body.appendChild(link)
|
|
|
|
- link.click()
|
|
|
|
- // 在资源下载完成后 清除 占用的缓存资源
|
|
|
|
- window.URL.revokeObjectURL(link.href)
|
|
|
|
- document.body.removeChild(link)
|
|
|
|
- })
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- const url = row.temporaryUrl // 完整的url则直接使用
|
|
|
|
|
|
+ await getTemporaryByUrl(row.url).then((data) => {
|
|
|
|
+ const url = data.data // 完整的url则直接使用
|
|
// 这里是将url转成blob地址,
|
|
// 这里是将url转成blob地址,
|
|
fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
|
|
fetch(url).then(res => res.blob()).then(blob => { // 将链接地址字符内容转变成blob地址
|
|
link.href = URL.createObjectURL(blob)
|
|
link.href = URL.createObjectURL(blob)
|
|
@@ -238,5 +215,5 @@ export async function toHref (row) {
|
|
window.URL.revokeObjectURL(link.href)
|
|
window.URL.revokeObjectURL(link.href)
|
|
document.body.removeChild(link)
|
|
document.body.removeChild(link)
|
|
})
|
|
})
|
|
- }
|
|
|
|
|
|
+ })
|
|
}
|
|
}
|