Commit 8b6413ac5ebad5fff12825a5dd66da44763243d8
1 parent
522f7be0
fix: 后端采用实时链接文件之后,部分文件打不开的情况。
Showing
3 changed files
with
25 additions
and
3 deletions
src/views/project/approve/ReceivePanel.vue
... | ... | @@ -104,7 +104,7 @@ |
104 | 104 | </tr> |
105 | 105 | </tbody> |
106 | 106 | </table> |
107 | - <a v-if="showInvoice" @click="openPic(mockData.invoiceUrl)" rel="noopener noreferrer">{{ | |
107 | + <a v-if="showInvoice" @click="openPic(mockData.deductUrl)" rel="noopener noreferrer">{{ | |
108 | 108 | mockData.invoiceName |
109 | 109 | }}</a> |
110 | 110 | <template #appendFooter> |
... | ... | @@ -134,6 +134,7 @@ |
134 | 134 | import BaseInfo from './BaseInfo.vue'; |
135 | 135 | import { createImgPreview } from '/@/components/Preview'; |
136 | 136 | import { getFormConfig } from './data'; |
137 | + import { view } from '/@/utils/pdfShow'; | |
137 | 138 | import { Description, DescItem, useDescription } from '@/components/Description'; |
138 | 139 | |
139 | 140 | const userStore = useUserStoreWithOut(); |
... | ... | @@ -327,7 +328,7 @@ |
327 | 328 | function handleProfitModal() {} |
328 | 329 | // 打开图片或 PDF |
329 | 330 | function openPic(url: string) { |
330 | - const baseUrl = url.split('?')[0]; // 获取问号前的部分 | |
331 | + const baseUrl = url.split('?')[0]; | |
331 | 332 | if (isImageUrl(baseUrl)) { |
332 | 333 | window.open('', '', '').document.write(`<!DOCTYPE html> |
333 | 334 | <html> |
... | ... | @@ -457,6 +458,16 @@ |
457 | 458 | } |
458 | 459 | }; |
459 | 460 | |
461 | + function isImageUrl(url: string): boolean { | |
462 | + const imageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'svg']; | |
463 | + const baseUrl = url.split('?')[0]; | |
464 | + return imageExtensions.some((ext) => baseUrl.toLowerCase().endsWith(ext)); | |
465 | + } | |
466 | + // 检查 URL 是否为 PDF 格式 | |
467 | + function isPdfUrl(url: string): boolean { | |
468 | + return url.toLowerCase().endsWith('.pdf'); | |
469 | + } | |
470 | + | |
460 | 471 | return { |
461 | 472 | handleProfitModal, |
462 | 473 | registerTable, | ... | ... |
src/views/project/order/FormDetail/BaseFormPanel.vue
... | ... | @@ -57,6 +57,8 @@ |
57 | 57 | let fields = ref({}); |
58 | 58 | const picUrl = ref(''); |
59 | 59 | const smallPicUrl = ref(''); |
60 | + const fileName = ref(''); | |
61 | + const smallfileName = ref(''); | |
60 | 62 | const userStore = useUserStoreWithOut(); |
61 | 63 | const role = computed(() => { |
62 | 64 | return userStore.getUserInfo?.roleSmallVO?.code; |
... | ... | @@ -175,6 +177,8 @@ |
175 | 177 | if (res.file?.response?.data) { |
176 | 178 | picUrl.value = res.file?.response?.data?.picUrl; |
177 | 179 | smallPicUrl.value = res.file?.response?.data?.smallPicUrl; |
180 | + fileName.value = res.file?.response?.data?.fileName; | |
181 | + smallfileName.value = res.file?.response?.data?.smallfileName; | |
178 | 182 | |
179 | 183 | setFieldsValue({ picUrl: picUrl.value }); |
180 | 184 | clearValidate('picUrl'); |
... | ... | @@ -318,6 +322,8 @@ |
318 | 322 | validate, |
319 | 323 | picUrl, |
320 | 324 | smallPicUrl, |
325 | + fileName, | |
326 | + smallfileName, | |
321 | 327 | isInnerNoRepeat, |
322 | 328 | role, |
323 | 329 | }; | ... | ... |
src/views/project/order/FormDetail/index.vue
... | ... | @@ -245,6 +245,8 @@ |
245 | 245 | }); |
246 | 246 | baseFormPanelRef.value.picUrl = data.picUrl; |
247 | 247 | baseFormPanelRef.value.smallPicUrl = data.smallPicUrl; |
248 | + baseFormPanelRef.value.fileName = data.fileName; | |
249 | + baseFormPanelRef.value.smallfileName = data.smallfileName; | |
248 | 250 | } |
249 | 251 | // 复制,只能更新基本信息 |
250 | 252 | if (data.isCopy) return; |
... | ... | @@ -360,6 +362,8 @@ |
360 | 362 | ...forms.baseInfo, |
361 | 363 | picUrl: baseFormPanelRef?.value?.picUrl || '', |
362 | 364 | smallPicUrl: baseFormPanelRef?.value?.smallPicUrl || '', |
365 | + fileName:baseFormPanelRef?.value?.fileName || '', | |
366 | + smallfileName:baseFormPanelRef?.value?.smallfileName || '', | |
363 | 367 | }; |
364 | 368 | await orderUpdate(forms); |
365 | 369 | closeDrawer(); |
... | ... | @@ -446,12 +450,13 @@ |
446 | 450 | |
447 | 451 | // 新建只有基本信息 |
448 | 452 | const values = baseFormPanelRef?.value?.getFieldsValue() || {}; |
449 | - | |
450 | 453 | const forms = { |
451 | 454 | baseInfo: { |
452 | 455 | ...values, |
453 | 456 | picUrl: baseFormPanelRef?.value?.picUrl || '', |
454 | 457 | smallPicUrl: baseFormPanelRef?.value?.smallPicUrl || '', |
458 | + fileName:baseFormPanelRef?.value?.fileName || '', | |
459 | + smallfileName:baseFormPanelRef?.value?.smallfileName || '', | |
455 | 460 | }, |
456 | 461 | }; |
457 | 462 | await orderCreate(forms); | ... | ... |