瀏覽代碼

update preview pdf

docs_0727
lb 1 年之前
父節點
當前提交
66efe8c476
共有 6 個檔案被更改,包括 62 行新增16 行删除
  1. +3
    -3
      public/index.html
  2. +10
    -1
      src/components/DialogWithMenu.vue
  3. +36
    -10
      src/components/uploadBtn/components/FileList.vue
  4. +4
    -0
      src/views/atomViews/ListViewWithHead.vue
  5. +8
    -1
      src/views/modules/pms/shape/config.js
  6. +1
    -1
      vue.config.js

+ 3
- 3
public/index.html 查看文件

@@ -38,10 +38,10 @@
<% if (process.env.VUE_APP_NODE_ENV === 'dev') { %>
<script>
// 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.62:8080/pms-am'; // tao
// 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.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>
<% } %>
<!-- 集成测试环境 -->


+ 10
- 1
src/components/DialogWithMenu.vue 查看文件

@@ -519,9 +519,18 @@ export default {
// 显示图片
this.currentImgUrl = URL.createObjectURL(res);
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 {
this.$message({
message: "非图片文件请下载后预览",
message: "非图片和PDF文件请下载后预览",
type: "error",
duration: 1500,
});


+ 36
- 10
src/components/uploadBtn/components/FileList.vue 查看文件

@@ -7,6 +7,7 @@
{{ file.name }}
</span>
<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-delete color-red" v-if="!detailMode" @click="handleDelete(file)" title="点击删除"></button>
</div>
@@ -17,15 +18,8 @@
<div class="top-search">
<transition name="fade" mode="out-in">
<button v-if="!showSearchInput" class="el-icon-search search-btn" @click="handleSearchClick"></button>
<el-input
v-else
size="mini"
placeholder="请输入关键字"
clearable
@keydown.enter.native="showSearchInput = false"
@keydown.esc.stop.native="showSearchInput = false"
v-model="searchCondition"
/>
<el-input v-else size="mini" placeholder="请输入关键字" clearable @keydown.enter.native="showSearchInput = false"
@keydown.esc.stop.native="showSearchInput = false" v-model="searchCondition" />
</transition>
</div>

@@ -77,6 +71,34 @@ export default {
},
},
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) {
console.log("[FileList] handleDownload", file);
this.$http
@@ -153,7 +175,7 @@ li {
list-style: none;
}

.filelist > li {
.filelist>li {
display: flex;
justify-content: space-between;
align-items: center;
@@ -178,12 +200,15 @@ li {
::-webkit-scrollbar {
width: 8px;
}

::-webkit-scrollbar-track {
width: 8px;
}

::-webkit-scrollbar-button {
display: none;
}

::-webkit-scrollbar-thumb {
background: rgb(175, 175, 175);
border-radius: 4px;
@@ -193,6 +218,7 @@ li {
color: #0b58ff;
cursor: pointer;
}

.color-red {
color: rgba(222, 15, 15, 0.89);
cursor: pointer;


+ 4
- 0
src/views/atomViews/ListViewWithHead.vue 查看文件

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


+ 8
- 1
src/views/modules/pms/shape/config.js 查看文件

@@ -1,5 +1,5 @@
import TableOperaionComponent from "@/components/noTemplateComponents/operationComponent";
// import switchBtn from "@/components/noTemplateComponents/switchBtn";
import TableTextComponent from "@/components/noTemplateComponents/detailComponent";
import request from "@/utils/request";
import { timeFilter, dictFilter } from "@/utils/filters";

@@ -108,6 +108,13 @@ export default function () {
{ input: true, label: "短描述", prop: "shortDesc", 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: "备注" } }],
],
operations: [


+ 1
- 1
vue.config.js 查看文件

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


Loading…
取消
儲存