设备图纸查看修改

This commit is contained in:
xusd 2024-07-09 11:29:43 +08:00
parent 68bd5ff1b5
commit b783cb87af

View File

@ -10,11 +10,8 @@
<u-collapse style="margin-top: 40px;">
<u-collapse-item :title="item.fileName" :isLink="isLink" :disabled="disabled"
v-for="(item,index) in itemDrawingList">
<text v-if="!item.localHave" style="color: #1771f7;" slot="value"
class="u-page__item__title__slot-title"
@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>
<text style="color: #1771f7;" slot="value" class="u-page__item__title__slot-title"
@click="lookDrawing(item.fileName,item.url,index)">查看</text>
</u-collapse-item>
</u-collapse>
</u-popup>
@ -132,60 +129,27 @@
}
},
methods: {
//
openDrawing(fileName) {
// App
if (this.$scope.$mp && this.$scope.$mp.runtime && this.$scope.$mp.runtime === 'app-plus') {
// Appplus.io.getRoot()
plus.io.getRoot((root) => {
console.log('App根目录' + root);
lookDrawing(fileName,url,index){
uni.showLoading({
title: '正在加载……'
});
} else {
console.log('当前不是App环境无法获取根目录');
}
console.log(fileName)
let fileType = fileName.substring(fileName.lastIndexOf(".") + 1);
console.log(fileType)
uni.openDocument({
showMenu: true,
fileType: fileType,
filePath: 'file://storage/emulated/0/Android/data/com.inspur.ipcApp/apps/__UNI__B298C37/downloads/storage/ipcApp/' +
fileName,
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.downloadFile({
url: url,
success: function (res) {
uni.hideLoading();
if (status == 200) {
uni.$u.toast('下载成功')
let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
console.log(fileSaveUrl)
that.itemDrawingList[index].localHave = true;
} else {
uni.$u.toast('下载失败')
plus.downloader.clear();
var filePath = res.tempFilePath;
uni.openDocument({
filePath: filePath,
fileType: fileType,
showMenu: true,
success: function (res) {
console.log('打开文档成功');
}
});
}
});
dtask.start();
},
clickDownload(paths) {
this.itemDrawingList = [];
@ -193,52 +157,11 @@
let list = paths.split(",");
list.forEach((item, index) => {
let fileName = item.substring(item.lastIndexOf("/") + 1)
const self = this;
// // _local://hello.txt_
// let filePath = 'file://storage/ipcApp/' + fileName;
// // 使plus.ioresolveLocalFileSystemURL
// 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 = {
url: baseUrl + item,
fileName: fileName,
localHave: true
fileName: fileName
}
self.itemDrawingList.push(drawing)
},
fail(err) {
let drawing = {
url: baseUrl + item,
fileName: fileName,
localHave: false
}
self.itemDrawingList.push(drawing)
}
})
this.itemDrawingList.push(drawing)
})
}
this.showDrawing = true;