update preview pdf

This commit is contained in:
lb 2023-05-25 14:15:27 +08:00
parent 03661f63b5
commit 66efe8c476
6 changed files with 62 additions and 16 deletions

View File

@ -38,10 +38,10 @@
<% if (process.env.VUE_APP_NODE_ENV === 'dev') { %> <% if (process.env.VUE_APP_NODE_ENV === 'dev') { %>
<script> <script>
// window.SITE_CONFIG['apiURL'] = 'http://192.168.1.103:8080/pms-am'; // window.SITE_CONFIG['apiURL'] = 'http://192.168.1.103:8080/pms-am';
window.SITE_CONFIG['apiURL'] = 'http://192.168.1.49:8080/pms-am'; // tengyun // window.SITE_CONFIG['apiURL'] = 'http://192.168.1.49:8080/pms-am'; // tengyun
// window.SITE_CONFIG['apiURL'] = 'http://192.168.1.62:8080/pms-am'; // tao window.SITE_CONFIG['apiURL'] = 'http://192.168.1.62:8080/pms-am'; // tao
// window.SITE_CONFIG['apiURL'] = 'http://192.168.1.21:8080/pms-am'; // xv // window.SITE_CONFIG['apiURL'] = 'http://192.168.1.21:8080/pms-am'; // xv
// window.SITE_CONFIG['apiURL'] = 'http://localhost:3000/pms-am'; // xv // window.SITE_CONFIG['apiURL'] = 'http://localhost:3000/p//////ms-am'; // xv
</script> </script>
<% } %> <% } %>
<!-- 集成测试环境 --> <!-- 集成测试环境 -->

View File

@ -519,9 +519,18 @@ export default {
// //
this.currentImgUrl = URL.createObjectURL(res); this.currentImgUrl = URL.createObjectURL(res);
this.imgPreviewDialogVisible = true; this.imgPreviewDialogVisible = true;
} else if (/pdf/i.test(res.type)) {
// pdf
let a = document.createElement('a')
a.setAttribute('target', '_blank')
a.href = URL.createObjectURL(res)
a.click()
console.log('before remove a ', a)
a.remove()
console.log('removed a ', a)
} else { } else {
this.$message({ this.$message({
message: "非图片文件请下载后预览", message: "非图片和PDF文件请下载后预览",
type: "error", type: "error",
duration: 1500, duration: 1500,
}); });

View File

@ -7,6 +7,7 @@
{{ file.name }} {{ file.name }}
</span> </span>
<div class="h-4 space-x-2"> <div class="h-4 space-x-2">
<button class="el-icon-view color-blue" @click="hanlePreview(file)" title="点击预览"></button>
<button class="el-icon-download color-blue" @click="handleDownload(file)" title="点击下载"></button> <button class="el-icon-download color-blue" @click="handleDownload(file)" title="点击下载"></button>
<button class="el-icon-delete color-red" v-if="!detailMode" @click="handleDelete(file)" title="点击删除"></button> <button class="el-icon-delete color-red" v-if="!detailMode" @click="handleDelete(file)" title="点击删除"></button>
</div> </div>
@ -17,15 +18,8 @@
<div class="top-search"> <div class="top-search">
<transition name="fade" mode="out-in"> <transition name="fade" mode="out-in">
<button v-if="!showSearchInput" class="el-icon-search search-btn" @click="handleSearchClick"></button> <button v-if="!showSearchInput" class="el-icon-search search-btn" @click="handleSearchClick"></button>
<el-input <el-input v-else size="mini" placeholder="请输入关键字" clearable @keydown.enter.native="showSearchInput = false"
v-else @keydown.esc.stop.native="showSearchInput = false" v-model="searchCondition" />
size="mini"
placeholder="请输入关键字"
clearable
@keydown.enter.native="showSearchInput = false"
@keydown.esc.stop.native="showSearchInput = false"
v-model="searchCondition"
/>
</transition> </transition>
</div> </div>
@ -77,6 +71,34 @@ export default {
}, },
}, },
methods: { methods: {
hanlePreview(file) {
//
this.$http
.get("/pms/attachment/downloadFile", {
params: {
attachmentId: file.id,
type: 0, // 0 1
},
responseType: "blob",
})
.then(({ data: res }) => {
console.log("preivew", res);
if (/image/i.test(res.type) || /pdf/i.test(res.type)) {
let a = document.createElement('a')
a.setAttribute('target', '_blank')
a.href = URL.createObjectURL(res)
a.click()
a.remove()
} else {
this.$message({
message: "非图片和PDF文件请下载后预览",
type: "error",
duration: 1500,
});
}
});
},
handleDownload(file) { handleDownload(file) {
console.log("[FileList] handleDownload", file); console.log("[FileList] handleDownload", file);
this.$http this.$http
@ -178,12 +200,15 @@ li {
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 8px; width: 8px;
} }
::-webkit-scrollbar-track { ::-webkit-scrollbar-track {
width: 8px; width: 8px;
} }
::-webkit-scrollbar-button { ::-webkit-scrollbar-button {
display: none; display: none;
} }
::-webkit-scrollbar-thumb { ::-webkit-scrollbar-thumb {
background: rgb(175, 175, 175); background: rgb(175, 175, 175);
border-radius: 4px; border-radius: 4px;
@ -193,6 +218,7 @@ li {
color: #0b58ff; color: #0b58ff;
cursor: pointer; cursor: pointer;
} }
.color-red { .color-red {
color: rgba(222, 15, 15, 0.89); color: rgba(222, 15, 15, 0.89);
cursor: pointer; cursor: pointer;

View File

@ -338,6 +338,10 @@ export default {
this.openDialog(data, false, { key: "attachment" }); this.openDialog(data, false, { key: "attachment" });
break; break;
} }
case "view-attachment-justform-version": {
console.log(data)
break;
}
case "view-recipe": { case "view-recipe": {
this.openDialog(data, true, { key: "attr" }); this.openDialog(data, true, { key: "attr" });
break; break;

View File

@ -1,5 +1,5 @@
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent"; import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
// import switchBtn from "@/components/noTemplateComponents/switchBtn"; import TableTextComponent from "@/components/noTemplateComponents/detailComponent";
import request from "@/utils/request"; import request from "@/utils/request";
import { timeFilter, dictFilter } from "@/utils/filters"; import { timeFilter, dictFilter } from "@/utils/filters";
@ -108,6 +108,13 @@ export default function () {
{ input: true, label: "短描述", prop: "shortDesc", elparams: { placeholder: "短描述" } }, { input: true, label: "短描述", prop: "shortDesc", elparams: { placeholder: "短描述" } },
], ],
[{ textarea: true, label: "描述", prop: "description", elparams: { placeholder: "描述" } }], [{ textarea: true, label: "描述", prop: "description", elparams: { placeholder: "描述" } }],
[{
upload: true,
actionUrl: window.SITE_CONFIG['apiURL'] + '/pms/attachment/uploadFileFormData?typeCode=shape',
label: "上传资料",
prop: "files",
elparams: null
}],
[{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }], [{ input: true, label: "备注", prop: "remark", elparams: { placeholder: "备注" } }],
], ],
operations: [ operations: [

View File

@ -21,7 +21,7 @@ module.exports = {
productionSourceMap: false, productionSourceMap: false,
devServer: { devServer: {
open: true, open: true,
port: 8001, port: 9000,
overlay: { overlay: {
errors: true, errors: true,
warnings: true warnings: true