Commit 3c773bac by liangzhen

回到上个版本

1 parent b31a94d2
Showing with 29 additions and 173 deletions
...@@ -24,36 +24,11 @@ ...@@ -24,36 +24,11 @@
:name="item.typeCode" :name="item.typeCode"
> >
<!-- <p style="height:600px"> {{ item.typeText }}</p> --> <!-- <p style="height:600px"> {{ item.typeText }}</p> -->
<!-- <iframe <iframe
:src="iframeUrl" :src="iframeUrl"
frameborder="0" frameborder="0"
style="width: 80%; height: 60vh; margin: auto; display: block" style="width: 80%; height: 60vh; margin: auto; display: block"
></iframe> --> ></iframe>
<div v-if="noFile" class="nofileimg">
<img src="../../assets/nopdf.png" alt="">
</div>
<pdf
v-else
ref="morePDF"
:src="pdfFile"
:page="currentPage"
@num-pages="pageCount = $event"
@page-loaded="currentPage = $event"
@loaded="loadPdf"
class="setpdf"
></pdf>
<div class="pageButton" v-if="!noFile">
<el-button type="primary" @click="changePage(0)"
>上一页</el-button
>
<el-button type="primary" @click="changePage(1)"
>下一页</el-button
>
<span> {{ currentPage }} / {{ pageCount }} </span>
</div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</div> </div>
...@@ -222,14 +197,9 @@ import { ...@@ -222,14 +197,9 @@ import {
presignedUrl, presignedUrl,
} from "@/api/index"; } from "@/api/index";
import { MaterialsListKY } from "@/utils/cache"; import { MaterialsListKY } from "@/utils/cache";
import pdf from "vue-pdf";
export default { export default {
components: {
pdf,
},
data() { data() {
return { return {
pdfFile: "",
dialogImageUrl: "", dialogImageUrl: "",
fileList: [], fileList: [],
evalList: [ evalList: [
...@@ -260,50 +230,14 @@ export default { ...@@ -260,50 +230,14 @@ export default {
limitNum: 1, limitNum: 1,
disabled: false, disabled: false,
oldQuestionList: [], //对比列表 oldQuestionList: [], //对比列表
numPages: "",
pdfFile: "", //pdf文件地址
currentPage: 1, // 页码
pageCount: 0, // 总页数
noFile:true,
}; };
}, },
watch: {},
mounted() { mounted() {
console.log(MaterialsListKY(1), "wwwww"); console.log(MaterialsListKY(1), "wwwww");
this.clqparams = JSON.parse(this.$route.query.clqparams); this.clqparams = JSON.parse(this.$route.query.clqparams);
this.init(this.clqparams); this.init(this.clqparams);
}, },
methods: { methods: {
// 翻页
changePage(val) {
if (val === 0 && this.currentPage > 1) {
this.currentPage--;
}
if (val === 1 && this.currentPage < this.pageCount) {
this.currentPage++;
}
},
// pdf加载时
loadPdf() {
this.currentPage = 1; // 加载的时候先加载第一页
},
getPDFnums(url) {
this.loading = true;
let loadURL = pdf.createLoadingTask({
url: url, //你的pdf地址
});
loadURL.promise
.then((pdf) => {
console.log(pdf, this.src, "pdfffff");
this.pageCount = pdf.numPages;
this.loading = false;
})
.catch((err) => {
this.loading = false;
this.loadingError = true;
});
},
// 放大图片 // 放大图片
handlePictureCardPreview(file) { handlePictureCardPreview(file) {
console.log("点击放大"); console.log("点击放大");
...@@ -370,7 +304,7 @@ export default { ...@@ -370,7 +304,7 @@ export default {
async init(type) { async init(type) {
let params = { let params = {
projectStage: this.active * 1 + 1, projectStage: this.active * 1 + 1,
hgx: "hgx", hgx:"hgx",
...type, ...type,
}; };
Promise.all([selFile(params), selWtqdFZ(params)]).then(async (res) => { Promise.all([selFile(params), selWtqdFZ(params)]).then(async (res) => {
...@@ -393,7 +327,7 @@ export default { ...@@ -393,7 +327,7 @@ export default {
projectStage: item.questionId, projectStage: item.questionId,
}; };
let responfx = await selZnfx(paramsFX); let responfx = await selZnfx(paramsFX);
counterNum++; counterNum++
if (respon.data.records && respon.data.records.length > 0) { if (respon.data.records && respon.data.records.length > 0) {
respon.data.records.forEach(async (itemImg) => { respon.data.records.forEach(async (itemImg) => {
if (itemImg.url) { if (itemImg.url) {
...@@ -439,15 +373,13 @@ export default { ...@@ -439,15 +373,13 @@ export default {
this.$set(item, "znfxList", []); this.$set(item, "znfxList", []);
this.$set(item, "fzfxList", []); this.$set(item, "fzfxList", []);
} }
if (counterNum == this.questionList.length) { if(counterNum==this.questionList.length){
setTimeout(() => { setTimeout(() => {
this.oldQuestionList = JSON.parse( this.oldQuestionList = JSON.parse(JSON.stringify(this.questionList));
JSON.stringify(this.questionList)
);
console.log(this.questionList, this.oldQuestionList, "总列表"); console.log(this.questionList, this.oldQuestionList, "总列表");
}, 300); }, 300);
} }
}); })
} }
if (this.urlList.length <= 0) { if (this.urlList.length <= 0) {
...@@ -460,60 +392,30 @@ export default { ...@@ -460,60 +392,30 @@ export default {
let resUrl = await presignedUrl(paramsUrl); let resUrl = await presignedUrl(paramsUrl);
// this.iframeUrl = "/pdf/web/viewer.html?file=" + resUrl.msg; this.iframeUrl = "/pdf/web/viewer.html?file=" + resUrl.msg;
this.iframeUrl = resUrl.msg;
} }
setTimeout(() => { // setTimeout(() => {
if(this.iframeUrl){ // this.oldQuestionList = JSON.parse(JSON.stringify(this.questionList));
this.noFile=false // console.log(this.questionList, this.oldQuestionList, "总列表");
this.pdfFile = this.iframeUrl; // }, 1000);
this.getPDFnums(this.iframeUrl);
}else{
console.log('空的')
this.noFile=true
}
this.oldQuestionList = JSON.parse(JSON.stringify(this.questionList));
console.log(this.questionList, this.oldQuestionList, "总列表");
}, 1000);
}); });
}, },
async handleClick(tab) { async handleClick(tab) {
console.log("切换", tab.name, this.urlList); console.log("切换", tab.name, this.urlList);
this.noFile=true
this.iframeUrl=""
this.urlList.forEach(async (item) => { this.urlList.forEach(async (item) => {
if (item.typeCode == tab.name) { if (item.typeCode == tab.name) {
let paramsUrl = { let paramsUrl = {
fileId: item.id, fileId: item.id,
url: item.url, url: item.url,
}; };
console.log(this.noFile, "333");
let resUrl = await presignedUrl(paramsUrl); let resUrl = await presignedUrl(paramsUrl);
this.iframeUrl=resUrl.msg this.iframeUrl = "/pdf/web/viewer.html?file=" + resUrl.msg;
// this.iframeUrl = "/pdf/web/viewer.html?file=" + resUrl.msg;
} else { } else {
console.log('为什么会走这里')
// this.iframeUrl ="" // this.iframeUrl =""
// this.iframeUrl = "/nopdf.png"; this.iframeUrl = "/nopdf.png";
// this.noFile=true
} }
}); });
console.log(this.iframeUrl, "this.iframeUrl");
setTimeout(() => {
if(this.iframeUrl){
this.noFile=false
this.pdfFile = this.iframeUrl;
this.getPDFnums(this.iframeUrl);
}else{
console.log('空的')
this.noFile=true
}
}, 1000);
console.log(this.noFile, "this.iframeUrl");
}, },
change(id) { change(id) {
console.log(this.questionList, this.oldQuestionList, "相同么"); console.log(this.questionList, this.oldQuestionList, "相同么");
...@@ -681,42 +583,35 @@ export default { ...@@ -681,42 +583,35 @@ export default {
// console.log("来了么222222", this.fileList); // console.log("来了么222222", this.fileList);
// }, // },
}, },
beforeRouteLeave(to, from, next) { beforeRouteLeave(to,from,next){
if ( if(JSON.stringify(this.questionList) ==JSON.stringify(this.oldQuestionList)){
JSON.stringify(this.questionList) == JSON.stringify(this.oldQuestionList) console.log('相同么')
) { next({replace: true,redirect: '/mainLayout/auxiliaryInspection'})
console.log("相同么");
next({ replace: true, redirect: "/mainLayout/auxiliaryInspection" }); }else{
} else { console.log('不同么')
console.log("不同么");
setTimeout(() => { setTimeout(() => {
this.$confirm("是否保存?", "提示", { this.$confirm("是否保存?", "提示", {
confirmButtonText: "是", confirmButtonText: "是",
cancelButtonText: "否", cancelButtonText: "否",
distinguishCancelAndClose: true, distinguishCancelAndClose: true,
type: "warning", type: "warning",
}) }).then(() => {
.then(() => { this.save('leave');
this.save("leave"); next({replace: true,redirect: '/mainLayout/auxiliaryInspection'})
next({
replace: true,
redirect: "/mainLayout/auxiliaryInspection",
});
}) })
.catch((action) => { .catch((action) => {
console.log(action, "actionaction"); console.log(action, "actionaction");
if (action === "cancel") { if (action === "cancel") {
next({ next({replace: true,redirect: '/mainLayout/auxiliaryInspection'})
replace: true,
redirect: "/mainLayout/auxiliaryInspection",
});
} else { } else {
// next() // next()
} }
}); });
}, 16); },16)
}
} }
},
}; };
</script> </script>
...@@ -929,42 +824,4 @@ export default { ...@@ -929,42 +824,4 @@ export default {
margin-left: 10px; margin-left: 10px;
border: none; border: none;
} }
.setpdf {
width: 37vw;
height: 53vw;
}
.pageButton {
height: 50px;
position: absolute;
top: 0;
right: 50px;
line-height: 50px;
// background-color: #c0d8f3;
// border: 1px solid #5caaf8;
// border-radius: 6px;
display: flex;
padding: 0px 24px;
.page {
color: #636a70;
flex-grow: 1;
// border: 1px solid #909;
span {
margin-right: 20px;
}
}
.scale {
// border: 1px solid #909;
text-align: right;
}
}
.nofileimg{
width: 500px;
height:500px;
margin: 50px auto;
img{
width: 100%;
height: 100%;
}
}
</style> </style>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!