设备图纸查看修改
This commit is contained in:
parent
68bd5ff1b5
commit
b783cb87af
@ -10,11 +10,8 @@
|
|||||||
<u-collapse style="margin-top: 40px;">
|
<u-collapse style="margin-top: 40px;">
|
||||||
<u-collapse-item :title="item.fileName" :isLink="isLink" :disabled="disabled"
|
<u-collapse-item :title="item.fileName" :isLink="isLink" :disabled="disabled"
|
||||||
v-for="(item,index) in itemDrawingList">
|
v-for="(item,index) in itemDrawingList">
|
||||||
<text v-if="!item.localHave" style="color: #1771f7;" slot="value"
|
<text style="color: #1771f7;" slot="value" class="u-page__item__title__slot-title"
|
||||||
class="u-page__item__title__slot-title"
|
@click="lookDrawing(item.fileName,item.url,index)">查看</text>
|
||||||
@click="downloadDrawing(item.fileName,item.url,index)">下载</text>
|
|
||||||
<text v-if="item.localHave" style="color: #1771f7;" slot="value" @click="openDrawing(item.fileName)"
|
|
||||||
class="u-page__item__title__slot-title">打开</text>
|
|
||||||
</u-collapse-item>
|
</u-collapse-item>
|
||||||
</u-collapse>
|
</u-collapse>
|
||||||
</u-popup>
|
</u-popup>
|
||||||
@ -132,60 +129,27 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
//打开文件
|
lookDrawing(fileName,url,index){
|
||||||
openDrawing(fileName) {
|
uni.showLoading({
|
||||||
// 判断当前环境是否为App环境
|
title: '正在加载……'
|
||||||
if (this.$scope.$mp && this.$scope.$mp.runtime && this.$scope.$mp.runtime === 'app-plus') {
|
|
||||||
// 在App环境中调用plus.io.getRoot()获取根目录
|
|
||||||
plus.io.getRoot((root) => {
|
|
||||||
console.log('App根目录:' + root);
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
console.log('当前不是App环境,无法获取根目录');
|
|
||||||
}
|
|
||||||
console.log(fileName)
|
|
||||||
let fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
|
let fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||||
console.log(fileType)
|
console.log(fileType)
|
||||||
uni.openDocument({
|
uni.downloadFile({
|
||||||
showMenu: true,
|
url: url,
|
||||||
fileType: fileType,
|
|
||||||
filePath: 'file://storage/emulated/0/Android/data/com.inspur.ipcApp/apps/__UNI__B298C37/downloads/storage/ipcApp/' +
|
|
||||||
fileName,
|
|
||||||
success: function (res) {
|
success: function (res) {
|
||||||
console.log(res, "打开文件成功");
|
|
||||||
},
|
|
||||||
fail: function(res) {
|
|
||||||
console.log(res)
|
|
||||||
uni.showToast({
|
|
||||||
title: "打开文件失败请重试",
|
|
||||||
icon: "none",
|
|
||||||
});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
//本地无文件--下载并打开文件
|
|
||||||
downloadDrawing(name, url, index) {
|
|
||||||
let progressVal = 0;
|
|
||||||
let that = this
|
|
||||||
uni.showLoading({
|
|
||||||
title: '正在下载……'
|
|
||||||
});
|
|
||||||
let dtask = plus.downloader.createDownload(url, {
|
|
||||||
// filename: 'file://storage/ipcApp/' + name
|
|
||||||
filename: 'file://storage/ipcApp/' + name
|
|
||||||
}, function(d, status) {
|
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
if (status == 200) {
|
var filePath = res.tempFilePath;
|
||||||
uni.$u.toast('下载成功')
|
uni.openDocument({
|
||||||
let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
|
filePath: filePath,
|
||||||
console.log(fileSaveUrl)
|
fileType: fileType,
|
||||||
that.itemDrawingList[index].localHave = true;
|
showMenu: true,
|
||||||
} else {
|
success: function (res) {
|
||||||
uni.$u.toast('下载失败')
|
console.log('打开文档成功');
|
||||||
plus.downloader.clear();
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dtask.start();
|
|
||||||
},
|
},
|
||||||
clickDownload(paths) {
|
clickDownload(paths) {
|
||||||
this.itemDrawingList = [];
|
this.itemDrawingList = [];
|
||||||
@ -193,52 +157,11 @@
|
|||||||
let list = paths.split(",");
|
let list = paths.split(",");
|
||||||
list.forEach((item, index) => {
|
list.forEach((item, index) => {
|
||||||
let fileName = item.substring(item.lastIndexOf("/") + 1)
|
let fileName = item.substring(item.lastIndexOf("/") + 1)
|
||||||
const self = this;
|
|
||||||
// // 假设你想检查的文件路径是_local://hello.txt_
|
|
||||||
// let filePath = 'file://storage/ipcApp/' + fileName;
|
|
||||||
// // 使用plus.io的resolveLocalFileSystemURL方法
|
|
||||||
// plus.io.resolveLocalFileSystemURL(filePath,
|
|
||||||
// function(entry) {
|
|
||||||
// // 文件存在的回调
|
|
||||||
// console.log("文件存在: " + entry.fullPath);
|
|
||||||
// let drawing = {
|
|
||||||
// url: baseUrl + item,
|
|
||||||
// fileName: fileName,
|
|
||||||
// localHave: true
|
|
||||||
// }
|
|
||||||
// self.itemDrawingList.push(drawing)
|
|
||||||
// },
|
|
||||||
// function(error) {
|
|
||||||
// // 文件不存在的回调
|
|
||||||
// console.log("文件不存在: " + filePath);
|
|
||||||
// let drawing = {
|
|
||||||
// url: baseUrl + item,
|
|
||||||
// fileName: fileName,
|
|
||||||
// localHave: false
|
|
||||||
// }
|
|
||||||
// self.itemDrawingList.push(drawing)
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
uni.getFileInfo({
|
|
||||||
filePath: 'file://storage/emulated/0/Android/data/com.inspur.ipcApp/apps/__UNI__B298C37/downloads/storage/ipcApp/' +
|
|
||||||
fileName,
|
|
||||||
success(res) {
|
|
||||||
let drawing = {
|
let drawing = {
|
||||||
url: baseUrl + item,
|
url: baseUrl + item,
|
||||||
fileName: fileName,
|
fileName: fileName
|
||||||
localHave: true
|
|
||||||
}
|
}
|
||||||
self.itemDrawingList.push(drawing)
|
this.itemDrawingList.push(drawing)
|
||||||
},
|
|
||||||
fail(err) {
|
|
||||||
let drawing = {
|
|
||||||
url: baseUrl + item,
|
|
||||||
fileName: fileName,
|
|
||||||
localHave: false
|
|
||||||
}
|
|
||||||
self.itemDrawingList.push(drawing)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.showDrawing = true;
|
this.showDrawing = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user