设备图纸查看修改

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 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') { });
// Appplus.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, success: function (res) {
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.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; let drawing = {
// // _local://hello.txt_ url: baseUrl + item,
// let filePath = 'file://storage/ipcApp/' + fileName; fileName: fileName
// // 使plus.ioresolveLocalFileSystemURL }
// plus.io.resolveLocalFileSystemURL(filePath, this.itemDrawingList.push(drawing)
// 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
}
self.itemDrawingList.push(drawing)
},
fail(err) {
let drawing = {
url: baseUrl + item,
fileName: fileName,
localHave: false
}
self.itemDrawingList.push(drawing)
}
})
}) })
} }
this.showDrawing = true; this.showDrawing = true;