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,7 +104,7 @@ | ||
104 | </tr> | 104 | </tr> |
105 | </tbody> | 105 | </tbody> |
106 | </table> | 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 | mockData.invoiceName | 108 | mockData.invoiceName |
109 | }}</a> | 109 | }}</a> |
110 | <template #appendFooter> | 110 | <template #appendFooter> |
@@ -134,6 +134,7 @@ | @@ -134,6 +134,7 @@ | ||
134 | import BaseInfo from './BaseInfo.vue'; | 134 | import BaseInfo from './BaseInfo.vue'; |
135 | import { createImgPreview } from '/@/components/Preview'; | 135 | import { createImgPreview } from '/@/components/Preview'; |
136 | import { getFormConfig } from './data'; | 136 | import { getFormConfig } from './data'; |
137 | + import { view } from '/@/utils/pdfShow'; | ||
137 | import { Description, DescItem, useDescription } from '@/components/Description'; | 138 | import { Description, DescItem, useDescription } from '@/components/Description'; |
138 | 139 | ||
139 | const userStore = useUserStoreWithOut(); | 140 | const userStore = useUserStoreWithOut(); |
@@ -327,7 +328,7 @@ | @@ -327,7 +328,7 @@ | ||
327 | function handleProfitModal() {} | 328 | function handleProfitModal() {} |
328 | // 打开图片或 PDF | 329 | // 打开图片或 PDF |
329 | function openPic(url: string) { | 330 | function openPic(url: string) { |
330 | - const baseUrl = url.split('?')[0]; // 获取问号前的部分 | 331 | + const baseUrl = url.split('?')[0]; |
331 | if (isImageUrl(baseUrl)) { | 332 | if (isImageUrl(baseUrl)) { |
332 | window.open('', '', '').document.write(`<!DOCTYPE html> | 333 | window.open('', '', '').document.write(`<!DOCTYPE html> |
333 | <html> | 334 | <html> |
@@ -457,6 +458,16 @@ | @@ -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 | return { | 471 | return { |
461 | handleProfitModal, | 472 | handleProfitModal, |
462 | registerTable, | 473 | registerTable, |
src/views/project/order/FormDetail/BaseFormPanel.vue
@@ -57,6 +57,8 @@ | @@ -57,6 +57,8 @@ | ||
57 | let fields = ref({}); | 57 | let fields = ref({}); |
58 | const picUrl = ref(''); | 58 | const picUrl = ref(''); |
59 | const smallPicUrl = ref(''); | 59 | const smallPicUrl = ref(''); |
60 | + const fileName = ref(''); | ||
61 | + const smallfileName = ref(''); | ||
60 | const userStore = useUserStoreWithOut(); | 62 | const userStore = useUserStoreWithOut(); |
61 | const role = computed(() => { | 63 | const role = computed(() => { |
62 | return userStore.getUserInfo?.roleSmallVO?.code; | 64 | return userStore.getUserInfo?.roleSmallVO?.code; |
@@ -175,6 +177,8 @@ | @@ -175,6 +177,8 @@ | ||
175 | if (res.file?.response?.data) { | 177 | if (res.file?.response?.data) { |
176 | picUrl.value = res.file?.response?.data?.picUrl; | 178 | picUrl.value = res.file?.response?.data?.picUrl; |
177 | smallPicUrl.value = res.file?.response?.data?.smallPicUrl; | 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 | setFieldsValue({ picUrl: picUrl.value }); | 183 | setFieldsValue({ picUrl: picUrl.value }); |
180 | clearValidate('picUrl'); | 184 | clearValidate('picUrl'); |
@@ -318,6 +322,8 @@ | @@ -318,6 +322,8 @@ | ||
318 | validate, | 322 | validate, |
319 | picUrl, | 323 | picUrl, |
320 | smallPicUrl, | 324 | smallPicUrl, |
325 | + fileName, | ||
326 | + smallfileName, | ||
321 | isInnerNoRepeat, | 327 | isInnerNoRepeat, |
322 | role, | 328 | role, |
323 | }; | 329 | }; |
src/views/project/order/FormDetail/index.vue
@@ -245,6 +245,8 @@ | @@ -245,6 +245,8 @@ | ||
245 | }); | 245 | }); |
246 | baseFormPanelRef.value.picUrl = data.picUrl; | 246 | baseFormPanelRef.value.picUrl = data.picUrl; |
247 | baseFormPanelRef.value.smallPicUrl = data.smallPicUrl; | 247 | baseFormPanelRef.value.smallPicUrl = data.smallPicUrl; |
248 | + baseFormPanelRef.value.fileName = data.fileName; | ||
249 | + baseFormPanelRef.value.smallfileName = data.smallfileName; | ||
248 | } | 250 | } |
249 | // 复制,只能更新基本信息 | 251 | // 复制,只能更新基本信息 |
250 | if (data.isCopy) return; | 252 | if (data.isCopy) return; |
@@ -360,6 +362,8 @@ | @@ -360,6 +362,8 @@ | ||
360 | ...forms.baseInfo, | 362 | ...forms.baseInfo, |
361 | picUrl: baseFormPanelRef?.value?.picUrl || '', | 363 | picUrl: baseFormPanelRef?.value?.picUrl || '', |
362 | smallPicUrl: baseFormPanelRef?.value?.smallPicUrl || '', | 364 | smallPicUrl: baseFormPanelRef?.value?.smallPicUrl || '', |
365 | + fileName:baseFormPanelRef?.value?.fileName || '', | ||
366 | + smallfileName:baseFormPanelRef?.value?.smallfileName || '', | ||
363 | }; | 367 | }; |
364 | await orderUpdate(forms); | 368 | await orderUpdate(forms); |
365 | closeDrawer(); | 369 | closeDrawer(); |
@@ -446,12 +450,13 @@ | @@ -446,12 +450,13 @@ | ||
446 | 450 | ||
447 | // 新建只有基本信息 | 451 | // 新建只有基本信息 |
448 | const values = baseFormPanelRef?.value?.getFieldsValue() || {}; | 452 | const values = baseFormPanelRef?.value?.getFieldsValue() || {}; |
449 | - | ||
450 | const forms = { | 453 | const forms = { |
451 | baseInfo: { | 454 | baseInfo: { |
452 | ...values, | 455 | ...values, |
453 | picUrl: baseFormPanelRef?.value?.picUrl || '', | 456 | picUrl: baseFormPanelRef?.value?.picUrl || '', |
454 | smallPicUrl: baseFormPanelRef?.value?.smallPicUrl || '', | 457 | smallPicUrl: baseFormPanelRef?.value?.smallPicUrl || '', |
458 | + fileName:baseFormPanelRef?.value?.fileName || '', | ||
459 | + smallfileName:baseFormPanelRef?.value?.smallfileName || '', | ||
455 | }, | 460 | }, |
456 | }; | 461 | }; |
457 | await orderCreate(forms); | 462 | await orderCreate(forms); |