支持文件资源下载的使用控制
Showing
2 changed files
with
28 additions
and
10 deletions
| ... | @@ -60,6 +60,12 @@ export const downloadTableData = (params) => request({ | ... | @@ -60,6 +60,12 @@ export const downloadTableData = (params) => request({ |
| 60 | responseType: 'blob' | 60 | responseType: 'blob' |
| 61 | }); | 61 | }); |
| 62 | 62 | ||
| 63 | /** 下载文件前的检查 */ | ||
| 64 | export const downloadFileCheck = (params) => request({ | ||
| 65 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/contract-use/download-file?userGuid=${params.userGuid}&fileName=${params.fileName}`, | ||
| 66 | method: 'get' | ||
| 67 | }); | ||
| 68 | |||
| 63 | /** 下载数据前的检查 */ | 69 | /** 下载数据前的检查 */ |
| 64 | export const downloadTableDataCheck = (params) => request({ | 70 | export const downloadTableDataCheck = (params) => request({ |
| 65 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/contract-use/download-check?userGuid=${params.userGuid}&subjectGuid=${params.subjectGuid}`, | 71 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/contract-use/download-check?userGuid=${params.userGuid}&subjectGuid=${params.subjectGuid}`, | ... | ... |
| ... | @@ -32,7 +32,8 @@ import { TableColumnWidth } from '@/utils/enum'; | ... | @@ -32,7 +32,8 @@ import { TableColumnWidth } from '@/utils/enum'; |
| 32 | import { | 32 | import { |
| 33 | downloadTableData, | 33 | downloadTableData, |
| 34 | downloadTableDataCheck, | 34 | downloadTableDataCheck, |
| 35 | getContractStrategy | 35 | getContractStrategy, |
| 36 | downloadFileCheck | ||
| 36 | } from "@/api/modules/dataDelivery"; | 37 | } from "@/api/modules/dataDelivery"; |
| 37 | import StrategyTable from '../data_smart_contract/components/strategyTable.vue'; | 38 | import StrategyTable from '../data_smart_contract/components/strategyTable.vue'; |
| 38 | import { getDownFileSignByUrl, obsDownloadRequest, parseAndDecodeUrl } from '@/api/modules/obsService'; | 39 | import { getDownFileSignByUrl, obsDownloadRequest, parseAndDecodeUrl } from '@/api/modules/obsService'; |
| ... | @@ -477,6 +478,24 @@ const handleTableViewData = (scope) => { | ... | @@ -477,6 +478,24 @@ const handleTableViewData = (scope) => { |
| 477 | }); | 478 | }); |
| 478 | } | 479 | } |
| 479 | 480 | ||
| 481 | /** 下载文件资源 */ | ||
| 482 | const downloadFile = (productDetailItem) => { | ||
| 483 | if (foundMode.value == '1') { | ||
| 484 | onUploadFileDownload(productDetailItem); | ||
| 485 | } else {// 使用次数需要先调用 | ||
| 486 | downloadFileCheck({ | ||
| 487 | userGuid: route.query.useGuid, | ||
| 488 | fileName: productDetailItem | ||
| 489 | }).then((res: any) => { | ||
| 490 | if (res?.code == proxy.$passCode) { | ||
| 491 | onUploadFileDownload(productDetailItem); | ||
| 492 | } else { | ||
| 493 | ElMessage.error(res?.msg || '下载失败'); | ||
| 494 | } | ||
| 495 | }); | ||
| 496 | } | ||
| 497 | } | ||
| 498 | |||
| 480 | /** 下载数据 */ | 499 | /** 下载数据 */ |
| 481 | const handleTableViewDataDown = async (scope) => { | 500 | const handleTableViewDataDown = async (scope) => { |
| 482 | if (foundMode.value == 'download' || foundMode.value == 'readAndDown') { | 501 | if (foundMode.value == 'download' || foundMode.value == 'readAndDown') { |
| ... | @@ -1490,15 +1509,8 @@ const respParamsTableInfo = ref({ | ... | @@ -1490,15 +1509,8 @@ const respParamsTableInfo = ref({ |
| 1490 | </template> | 1509 | </template> |
| 1491 | <div class="file-name"><ellipsis-tooltip :content="productDetailItem.name ?? ''" class-name="w100f" | 1510 | <div class="file-name"><ellipsis-tooltip :content="productDetailItem.name ?? ''" class-name="w100f" |
| 1492 | refName="tooltipOver"></ellipsis-tooltip></div> | 1511 | refName="tooltipOver"></ellipsis-tooltip></div> |
| 1493 | <div | 1512 | <div :style="{ right: '0px' }" class="file-preview" v-if="foundMode == 'download' || foundMode == 'readAndDown' || (!detailInfo.nodeId && foundMode == '1')" |
| 1494 | v-if="['pdf', 'png', 'jpg', 'jpeg'].includes(productDetailItem.name?.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase())" | 1513 | @click="downloadFile">下载</div> |
| 1495 | :style="{ right: '36px' }" class="file-preview" @click="onUploadFilePreview(productDetailItem)"> | ||
| 1496 | 查看 | ||
| 1497 | </div> | ||
| 1498 | <div :style="{ right: '0px' }" class="file-preview" | ||
| 1499 | @click="onUploadFileDownload(productDetailItem)"> | ||
| 1500 | 下载 | ||
| 1501 | </div> | ||
| 1502 | </div> | 1514 | </div> |
| 1503 | </span> | 1515 | </span> |
| 1504 | </span> | 1516 | </span> | ... | ... |
-
Please register or sign in to post a comment