From 7339b8a9ccf09e6262cb71ac6c9b724cdfa6fe22 Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期五, 15 八月 2025 16:43:32 +0800 Subject: [PATCH] 'pdf预览'’’ --- src/views/system/dept/uploadform.vue | 27 +++++++++++-- src/views/system/dept/utils/hook.tsx | 20 ++++++++- src/views/system/dept/index.vue | 12 +++--- src/views/system/component/四川招标投标交易服务平台用户操作手册(代理机构).pdf | 0 src/api/upload/index.ts | 7 ++- src/views/system/component/pdfPreview.vue | 31 +++++++++++++++ src/api/types.ts | 19 +++++++++ 7 files changed, 100 insertions(+), 16 deletions(-) diff --git a/src/api/types.ts b/src/api/types.ts index 2e3491e..884a951 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -24,6 +24,25 @@ id: string; }; +type getUploadToken = { + policy: string; + message: string; + DirPath: string; + id: string; + x_oss_signature_version: string; + x_oss_credential: string; + x_oss_date: string; + signature: string; + security_token: string; + url: string; +}; + +export type getUploadTokenResult = { + success: boolean; + result: getUploadToken; + code: string | number; +}; + export type CaptchaResult = { success: boolean; result: captchaImg; diff --git a/src/api/upload/index.ts b/src/api/upload/index.ts index 727dbe8..0855e0e 100644 --- a/src/api/upload/index.ts +++ b/src/api/upload/index.ts @@ -6,11 +6,14 @@ import { http } from "@/utils/http"; import { baseUrlApi, uploadUrlApi } from "../util"; -import type { Result } from "../types"; +import type { Result, getUploadTokenResult } from "../types"; // 鑾峰彇涓婁紶Token export const getUploadToken = () => { - return http.request<Result>("get", baseUrlApi("/api/upFile/token")); + return http.request<getUploadTokenResult>( + "get", + baseUrlApi("/api/upFile/token") + ); }; export const uploadFileAli11 = (data, key) => { diff --git a/src/views/system/component/pdfPreview.vue b/src/views/system/component/pdfPreview.vue new file mode 100644 index 0000000..48748a0 --- /dev/null +++ b/src/views/system/component/pdfPreview.vue @@ -0,0 +1,31 @@ +<template> + <div + v-loading="isLoading" + class="pdf-container" + element-loading-text="鍔犺浇涓�..." + > + <iframe + id="printIframe" + :src="pdfSrc" + frameborder="0" + style="width: 100%; height: 100%" + @load="iframeLoaded" + /> + </div> +</template> + +<script setup lang="ts"> +import { ref } from "vue"; +import pdfSrc from "./鍥涘窛鎷涙爣鎶曟爣浜ゆ槗鏈嶅姟骞冲彴鐢ㄦ埛鎿嶄綔鎵嬪唽锛堜唬鐞嗘満鏋勶級.pdf"; +let isLoading = ref(true); +const iframeLoaded = () => { + console.log("jjjjjj"); + + isLoading.value = false; +}; +</script> +<style> +.pdf-container { + height: 600px; +} +</style> diff --git "a/src/views/system/component/\345\233\233\345\267\235\346\213\233\346\240\207\346\212\225\346\240\207\344\272\244\346\230\223\346\234\215\345\212\241\345\271\263\345\217\260\347\224\250\346\210\267\346\223\215\344\275\234\346\211\213\345\206\214\357\274\210\344\273\243\347\220\206\346\234\272\346\236\204\357\274\211.pdf" "b/src/views/system/component/\345\233\233\345\267\235\346\213\233\346\240\207\346\212\225\346\240\207\344\272\244\346\230\223\346\234\215\345\212\241\345\271\263\345\217\260\347\224\250\346\210\267\346\223\215\344\275\234\346\211\213\345\206\214\357\274\210\344\273\243\347\220\206\346\234\272\346\236\204\357\274\211.pdf" new file mode 100644 index 0000000..786d820 --- /dev/null +++ "b/src/views/system/component/\345\233\233\345\267\235\346\213\233\346\240\207\346\212\225\346\240\207\344\272\244\346\230\223\346\234\215\345\212\241\345\271\263\345\217\260\347\224\250\346\210\267\346\223\215\344\275\234\346\211\213\345\206\214\357\274\210\344\273\243\347\220\206\346\234\272\346\236\204\357\274\211.pdf" Binary files differ diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue index f1f1a6e..c4b1105 100644 --- a/src/views/system/dept/index.vue +++ b/src/views/system/dept/index.vue @@ -230,12 +230,12 @@ <el-button type="primary" :loading="loading" @click="onSearch"> 鎼滅储 </el-button> - <!-- <el-button - :icon="useRenderIcon(Refresh)" - @click="resetForm(formRef)" - > - 閲嶇疆 - </el-button> --> + <el-button + :icon="useRenderIcon(Refresh)" + @click="resetForm(formRef)" + > + 閲嶇疆 + </el-button> <el-button type="primary" @click="openDialog()"> 鏂板 </el-button> diff --git a/src/views/system/dept/uploadform.vue b/src/views/system/dept/uploadform.vue index 4dddd4f..ad52997 100644 --- a/src/views/system/dept/uploadform.vue +++ b/src/views/system/dept/uploadform.vue @@ -30,8 +30,25 @@ }), isChange: null }); - -const gonggaoRules = reactive({ +interface FormInlineType { + // 椤圭洰鏍囬 + projectName: string | null | undefined; + // 鎶曟爣鎶ュ悕寮�濮嬫椂闂达紙閫氬父涓篒SO鏃ユ湡瀛楃涓叉牸寮忥級 + toubiaoStartDate: string | null | undefined; + // 鎶曟爣鎶ュ悕缁撴潫鏃堕棿 + toubiaoEndDate: string | null | undefined; + // 寮�鏍囨椂闂� + kaibiaoDate: string | null | undefined; + // 鎷涙爣鏂囦欢锛堝彲鑳芥槸鏂囦欢璺緞銆両D鎴栨枃浠跺璞★級 + zhaobiaowenjian: string | null | undefined; + // 鍙樻洿鏂囦欢 + biangengwenjian: string | null | undefined; + // 闄勪欢锛堟枃鏈弿杩版垨璺緞锛� + fujian: string | null | undefined; + // 寮�鏍囧湴鐐� + kaibiaodidian: string | null | undefined; +} +const gonggaoRules = reactive<FormRules<FormInlineType>>({ projectName: [{ required: true, message: "璇疯緭鍏ユ爣棰�", trigger: "change" }], toubiaoStartDate: [ { required: true, message: "璇烽�夋嫨鎶曟爣鎶ュ悕寮�濮嬫椂闂�", trigger: "change" } @@ -150,6 +167,8 @@ let res = await getUploadToken(); if (res.code == 200) { let keyVal = generateTimestampWithRandom(res.result.DirPath, file.name); + let upUrl = res.result.url; + let upPath = res.result.DirPath; let formData = new FormData(); formData.append("policy", res.result.policy); formData.append( @@ -166,9 +185,7 @@ formData.append("key", keyVal); // 鏂囦欢鍚� formData.append("file", file.raw); // file 蹇呴』涓烘渶鍚庝竴涓〃鍗曞煙 uploadFileAli(formData, res.result.url).then(res => { - let path = res.result.url + "/" + res.result.DirPath + keyVal; - console.log(path); - + let path = `${upUrl}"/"${upPath}${upPath};`; if (props.isChange) { newFormInline.value.biangengwenjian = path; } else { diff --git a/src/views/system/dept/utils/hook.tsx b/src/views/system/dept/utils/hook.tsx index 6e41864..7e7a9d7 100644 --- a/src/views/system/dept/utils/hook.tsx +++ b/src/views/system/dept/utils/hook.tsx @@ -23,6 +23,7 @@ // import { useUserStoreHook } from "@/store/modules/user"; import type { PaginationProps } from "@pureadmin/table"; +import pdfPreview from "../../component/pdfPreview.vue"; // const nowRole = computed(() => { // return useUserStoreHook().nowRole; // }); @@ -286,9 +287,22 @@ } function resetForm(formEl) { - if (!formEl) return; - formEl.resetFields(); - onSearch(); + // if (!formEl) return; + // formEl.resetFields(); + // onSearch(); + + addDialog({ + title: `棰勮pdf`, + props: {}, + width: "60%", + draggable: true, + fullscreen: deviceDetection(), + fullscreenIcon: true, + sureBtnLoading: true, + closeOnClickModal: false, + contentRenderer: () => h(pdfPreview, { ref: formRef, formInline: null }) + // jsx 璇硶 锛堟敞鎰忓湪.vue鏂囦欢鍚敤jsx璇硶锛岄渶瑕佸湪script寮�鍚痩ang="tsx"锛� + }); } const checkboxAsRadio = data => { if (data.length > 1) { -- Gitblit v1.9.1