From 5159d19ed210ec3e14d157f9ae6221299bd46e34 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期二, 29 八月 2023 17:04:47 +0800 Subject: [PATCH] 供应商文件预览、下载、删除 --- src/views/supplierManage/supplier/AddSupplier.vue | 69 +++++++++++++++++++++++++--------- 1 files changed, 50 insertions(+), 19 deletions(-) diff --git a/src/views/supplierManage/supplier/AddSupplier.vue b/src/views/supplierManage/supplier/AddSupplier.vue index 52038bd..2fb6519 100644 --- a/src/views/supplierManage/supplier/AddSupplier.vue +++ b/src/views/supplierManage/supplier/AddSupplier.vue @@ -160,7 +160,7 @@ <span style="margin-left: 5px">鍚堝悓闄勪欢</span> </div> </template> - <div class="annex-view"> + <div v-if="file_id === 0" class="annex-view"> <div @click="addAnnexClick"> <el-upload class="upload-demo" @@ -178,13 +178,15 @@ </el-upload> </div> </div> - <div v-if="file_name && file_name.length > 0" class="file-content"> + <!-- v-if="file_name && file_name.length > 0" --> + <div v-else class="file-content"> <div>{{ file_name }}</div> <div> - <el-button type="text">棰勮</el-button> - <el-button type="text">涓嬭浇</el-button> - <el-button type="text">鍒犻櫎</el-button> + <el-button type="text" @click="previewClick" style="margin-left: 10px">棰勮</el-button> + <el-button type="text" @click="downloadClick">涓嬭浇</el-button> + <el-button type="text" @click="delContractClick">鍒犻櫎</el-button> </div> + <div ref="file"></div> </div> </el-form-item> </el-col> @@ -208,11 +210,15 @@ createContract, updateSupplier, getIndustryList, - previewContract + getSupplierTypeList, + deleteContract + // previewContract } from "@/api/supplierManage/supplier" import EditDropdownDialog from "@/views/other/commonDialog/EditDropdownDialog" -import { getSupplierTypeList } from "@/api/supplierManage/supplier" import { getMemberListFromGrpc } from "@/api/common/other" +import download from "downloadjs" +// import { renderAsync } from "docx-preview" +// import axios from "axios" export default { name: "AddSupplierDialog", props: { @@ -263,8 +269,10 @@ infomation: {} }, fileList: [], - file_name: "", - file_id: this.addCommonConfig.infomation.fileId + file_name: this.addCommonConfig.infomation.file_name, + file_id: this.addCommonConfig.infomation.fileId, + previewUrl: "", + loading: false } }, created() { @@ -272,7 +280,7 @@ this.getIndustryList() this.getMemberList() if (this.editConfig.title === "淇敼") { - this.previewContract() + // this.previewContract() } }, methods: { @@ -302,14 +310,6 @@ pageSize: 100 }).then((res) => { this.industryOptions = res.data.data.list - }) - }, - // 鍚堝悓闄勪欢淇℃伅 - async previewContract() { - await previewContract({ - id: 1 - }).then((res) => { - console.log(res.data) }) }, handleClose() { @@ -364,7 +364,7 @@ name: data.name || "", number: data.number || "", phone: data.phone || "", - responsiblePersonId: data.responsiblePersonId || 0, + responsiblePersonName: data.responsiblePersonName || "", status: data.status || 0, supplierType: data.supplierType || "", url: data.url || "" @@ -416,6 +416,37 @@ handleExceed(files, fileList) { console.log(fileList) this.$message.warning(`褰撳墠闄愬埗閫夋嫨 1 涓枃浠讹紝鏈閫夋嫨浜� ${files.length} 涓枃浠禶) + }, + // 涓嬭浇鍚堝悓 + downloadClick() { + let url = "/api/con/downloadContract?id=" + this.file_id + download(url, "", "") + }, + // 鍒犻櫎鍚堝悓 + delContractClick() { + deleteContract({ + id: this.file_id + }).then((res) => { + console.log(res) + this.$message.success(res.msg) + this.file_id = 0 + }) + }, + // 棰勮鍚堝悓 + async previewClick() { + this.previewUrl = "/api/con/previewContract?id=" + this.file_id + if (this.file_name.includes("pdf")) { + window.open(this.previewUrl, "_blank") + } else { + let routeUrl = this.$router.resolve({ + path: "/PreviewFile", + query: { + //瑕佷紶鐨勫弬鏁� + previewUrl: this.previewUrl + } + }) + window.open(routeUrl.href, "_blank") + } } } } -- Gitblit v1.8.0