6f51b92f by lihua

添加数据产品下载源文件

1 parent 10558aff
...@@ -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}`,
......
...@@ -444,6 +444,34 @@ const baseInfoFormItems = ref([ ...@@ -444,6 +444,34 @@ const baseInfoFormItems = ref([
444 filterable: true, 444 filterable: true,
445 required: false, //非必填,只能选择跟领域匹配的逻辑空间 445 required: false, //非必填,只能选择跟领域匹配的逻辑空间
446 clearable: true, 446 clearable: true,
447 }, {
448 label: '是否文件资源',
449 type: 'radio-group',
450 placeholder: '',
451 field: 'isFileResource',
452 block: false,
453 disabled: false,
454 default: 'N',
455 options: [{
456 value: 'Y',
457 label: '是'
458 }, {
459 value: 'N',
460 label: '否'
461 }],
462 required: true,
463 },
464 {
465 label: '选择文件上传',
466 tip: '',
467 type: 'upload-file',
468 accept: '',
469 required: true,
470 default: [],
471 block: false,
472 field: 'attachments',
473 col: 'col2',
474 visible: false,
447 }, 475 },
448 { 476 {
449 label: '资源描述', 477 label: '资源描述',
...@@ -516,7 +544,16 @@ const baseInfoFormRules = ref({ ...@@ -516,7 +544,16 @@ const baseInfoFormRules = ref({
516 domain: [required('请选择领域')], 544 domain: [required('请选择领域')],
517 scenario: [required('请选择应用场景')], 545 scenario: [required('请选择应用场景')],
518 medDepartmentCode: [required('请选择所属科室')], 546 medDepartmentCode: [required('请选择所属科室')],
519 updateFrequency: [required('请选择更新频率')] 547 updateFrequency: [required('请选择更新频率')],
548 attachments: [{
549 validator: (rule: any, value: any, callback: any) => {
550 if (!value?.length) {
551 callback(new Error('请上传文件'))
552 } else {
553 callback();
554 }
555 }, trigger: 'change'
556 }]
520 }); 557 });
521 558
522 const getTableFieldPromise: any = ref({}); 559 const getTableFieldPromise: any = ref({});
...@@ -685,6 +722,9 @@ const setFormItems = (val) => { ...@@ -685,6 +722,9 @@ const setFormItems = (val) => {
685 item.visible = val['domain'] == '003' 722 item.visible = val['domain'] == '003'
686 } else if (item.field == 'subjectDomain') { 723 } else if (item.field == 'subjectDomain') {
687 item.visible = val['domain'] == '004'; 724 item.visible = val['domain'] == '004';
725 } else if (item.field == 'attachments') {
726 item.visible = val['isFileResource'] == 'Y';
727 item.default = val[item.field] || [];
688 } 728 }
689 }); 729 });
690 } 730 }
...@@ -716,6 +756,12 @@ const handleBaseInfoCheckboxChange = (val, info) => { ...@@ -716,6 +756,12 @@ const handleBaseInfoCheckboxChange = (val, info) => {
716 setFormItems(info); 756 setFormItems(info);
717 } 757 }
718 758
759 const handleBaseInfoRadioChange = (val, info, item) => {
760 if (item.field == 'isFileResource') {
761 setFormItems(info);
762 }
763 }
764
719 /** ------------------- 添加选择数据服务API表格,多选 ---------------------------- */ 765 /** ------------------- 添加选择数据服务API表格,多选 ---------------------------- */
720 const productTableRef = ref(); 766 const productTableRef = ref();
721 const productData: any = ref([]); 767 const productData: any = ref([]);
...@@ -922,6 +968,11 @@ onBeforeMount(() => { ...@@ -922,6 +968,11 @@ onBeforeMount(() => {
922 item.options = domainDictList.value.find(s => s.value == detailInfo.value['domain'])?.childDictList || [] 968 item.options = domainDictList.value.find(s => s.value == detailInfo.value['domain'])?.childDictList || []
923 } else if (item.field == 'medDepartmentCode') { 969 } else if (item.field == 'medDepartmentCode') {
924 item.visible = detailInfo.value['domain'] == '003' 970 item.visible = detailInfo.value['domain'] == '003'
971 } else if (item.field == 'isFileResource') {
972 item.default = detailInfo.value.attachments?.length ? 'Y' : 'N';
973 } else if (item.field == 'attachments') {
974 item.default = detailInfo.value.attachments || [];
975 item.visible = item.default.length > 0;
925 } 976 }
926 if (item.field == 'isCache' || item.field == 'isEncrypField') { 977 if (item.field == 'isCache' || item.field == 'isEncrypField') {
927 item.disabled = true; 978 item.disabled = true;
...@@ -1081,6 +1132,7 @@ const save = () => { ...@@ -1081,6 +1132,7 @@ const save = () => {
1081 baseInfoFormRef.value?.ruleFormRef?.validate((valid, errorItem) => { 1132 baseInfoFormRef.value?.ruleFormRef?.validate((valid, errorItem) => {
1082 if (valid) { 1133 if (valid) {
1083 let params = { ...baseInfoFormRef.value.formInline }; 1134 let params = { ...baseInfoFormRef.value.formInline };
1135 if (params.isFileResource != 'Y') {
1084 let associationApiList: string[] = []; 1136 let associationApiList: string[] = [];
1085 for (const api of productData.value) { 1137 for (const api of productData.value) {
1086 if (!api.apiGuid) { 1138 if (!api.apiGuid) {
...@@ -1115,6 +1167,13 @@ const save = () => { ...@@ -1115,6 +1167,13 @@ const save = () => {
1115 return; 1167 return;
1116 } 1168 }
1117 } 1169 }
1170 }
1171 params.attachments = params.attachments?.map(item => {
1172 return {
1173 name: item.name,
1174 url: item.url
1175 }
1176 }) || [];
1118 if (params.coverageArea == 'all') { 1177 if (params.coverageArea == 'all') {
1119 params.coverageArea = [['all']]; 1178 params.coverageArea = [['all']];
1120 } else if (!params.coverageArea) { 1179 } else if (!params.coverageArea) {
...@@ -1290,9 +1349,9 @@ const handleImportSave = (val) => { ...@@ -1290,9 +1349,9 @@ const handleImportSave = (val) => {
1290 <ContentWrap id="id-baseInfo" title="资源基本信息" description="" :isExpand="baseInfoExpand" :expand-swicth="true" 1349 <ContentWrap id="id-baseInfo" title="资源基本信息" description="" :isExpand="baseInfoExpand" :expand-swicth="true"
1291 class="mb16" @expand="(v) => baseInfoExpand = v"> 1350 class="mb16" @expand="(v) => baseInfoExpand = v">
1292 <Form ref="baseInfoFormRef" :itemList="baseInfoFormItems" formId="base-info-form" :rules="baseInfoFormRules" 1351 <Form ref="baseInfoFormRef" :itemList="baseInfoFormItems" formId="base-info-form" :rules="baseInfoFormRules"
1293 @selectChange="baseSelectChange" @checkboxChange="handleBaseInfoCheckboxChange" col="col3" /> 1352 @selectChange="baseSelectChange" @checkboxChange="handleBaseInfoCheckboxChange" @radio-group-change="handleBaseInfoRadioChange" col="col3" />
1294 </ContentWrap> 1353 </ContentWrap>
1295 <ContentWrap v-if="baseInfoFormRef?.formInline?.damType == '2'" id="product-info" title="服务包信息" expandSwicth 1354 <ContentWrap v-if="baseInfoFormRef?.formInline?.damType == '2' && baseInfoFormRef?.formInline?.isFileResource != 'Y'" id="product-info" title="服务包信息" expandSwicth
1296 style="margin-top: 15px" :isExpand="expandServiceInfo" @expand="(v) => (expandServiceInfo = v)" description="" 1355 style="margin-top: 15px" :isExpand="expandServiceInfo" @expand="(v) => (expandServiceInfo = v)" description=""
1297 class="mb16"> 1356 class="mb16">
1298 <Table ref="productTableRef" :tableInfo="productTableInfo" class="fiveRow-table" 1357 <Table ref="productTableRef" :tableInfo="productTableInfo" class="fiveRow-table"
...@@ -1302,7 +1361,7 @@ const handleImportSave = (val) => { ...@@ -1302,7 +1361,7 @@ const handleImportSave = (val) => {
1302 v-preReClick>添加服务</el-button> 1361 v-preReClick>添加服务</el-button>
1303 </div> 1362 </div>
1304 </ContentWrap> 1363 </ContentWrap>
1305 <ContentWrap v-if="baseInfoFormRef?.formInline?.damType != '2'" id="id-tableInfo" title="资源表" description="" 1364 <ContentWrap v-if="baseInfoFormRef?.formInline?.damType != '2' && baseInfoFormRef?.formInline?.isFileResource != 'Y'" id="id-tableInfo" title="资源表" description=""
1306 :expand-swicth="true" :isExpand="assetTableInfoExpand" @expand="(v) => assetTableInfoExpand = v"> 1365 :expand-swicth="true" :isExpand="assetTableInfoExpand" @expand="(v) => assetTableInfoExpand = v">
1307 <div v-show="assetDataTableInfo.data.length" class="tools_btns"> 1366 <div v-show="assetDataTableInfo.data.length" class="tools_btns">
1308 <el-button type="primary" @click="handleCreateTable" v-preReClick>添加</el-button> 1367 <el-button type="primary" @click="handleCreateTable" v-preReClick>添加</el-button>
......
...@@ -32,9 +32,11 @@ import { TableColumnWidth } from '@/utils/enum'; ...@@ -32,9 +32,11 @@ 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';
39 import { getDownFileSignByUrl, obsDownloadRequest, parseAndDecodeUrl } from '@/api/modules/obsService';
38 40
39 const router = useRouter(); 41 const router = useRouter();
40 const route = useRoute(); 42 const route = useRoute();
...@@ -476,8 +478,27 @@ const handleTableViewData = (scope) => { ...@@ -476,8 +478,27 @@ const handleTableViewData = (scope) => {
476 }); 478 });
477 } 479 }
478 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.name
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
479 /** 下载数据 */ 499 /** 下载数据 */
480 const handleTableViewDataDown = (scope) => { 500 const handleTableViewDataDown = async (scope) => {
501 if (foundMode.value == 'download' || foundMode.value == 'readAndDown') {
481 downloadTableDataCheck({ 502 downloadTableDataCheck({
482 userGuid: route.query.useGuid, 503 userGuid: route.query.useGuid,
483 subjectGuid: scope.row.guid 504 subjectGuid: scope.row.guid
...@@ -497,6 +518,23 @@ const handleTableViewDataDown = (scope) => { ...@@ -497,6 +518,23 @@ const handleTableViewDataDown = (scope) => {
497 ElMessage.error(res?.msg || '下载失败'); 518 ElMessage.error(res?.msg || '下载失败');
498 } 519 }
499 }) 520 })
521 } else if (foundMode.value == '1') { //下载源文件
522 let fileUrl = scope.row.fileUrl;
523 const refSignInfo: any = await getDownFileSignByUrl(parseAndDecodeUrl(fileUrl).fileName);
524 if (!refSignInfo?.data) {
525 refSignInfo?.msg && ElMessage.error(refSignInfo?.msg);
526 return;
527 }
528 obsDownloadRequest(refSignInfo?.data).then((res: any) => {
529 if (res && !res.msg) {
530 let name = scope.row.fileName;
531 var fileSuffix = name ? name.substring(name.lastIndexOf('.') + 1) : '';
532 download(res, name, fileSuffix);
533 } else {
534 res?.msg && ElMessage.error(res?.msg);
535 }
536 })
537 }
500 } 538 }
501 539
502 const toolBtns: any = computed(() => { 540 const toolBtns: any = computed(() => {
...@@ -1426,7 +1464,7 @@ const respParamsTableInfo = ref({ ...@@ -1426,7 +1464,7 @@ const respParamsTableInfo = ref({
1426 </div> 1464 </div>
1427 </div> 1465 </div>
1428 </ContentWrap> 1466 </ContentWrap>
1429 <ContentWrap v-if="productTableInfo.data?.length" id="product-info" title="服务包信息" style="margin: 16px 16px 16px"> 1467 <ContentWrap v-if="productTableInfo.data?.length && !detailInfo.attachments?.length" id="product-info" title="服务包信息" style="margin: 16px 16px 16px">
1430 <Table ref="productTableRef" :tableInfo="productTableInfo" /> 1468 <Table ref="productTableRef" :tableInfo="productTableInfo" />
1431 </ContentWrap> 1469 </ContentWrap>
1432 <ContentWrap v-if="isJSZQ" id="id-paramsInfo" title="入参出参信息" description="" style="margin: 16px 16px 16px"> 1470 <ContentWrap v-if="isJSZQ" id="id-paramsInfo" title="入参出参信息" description="" style="margin: 16px 16px 16px">
...@@ -1439,7 +1477,57 @@ const respParamsTableInfo = ref({ ...@@ -1439,7 +1477,57 @@ const respParamsTableInfo = ref({
1439 </el-tab-pane> 1477 </el-tab-pane>
1440 </el-tabs> 1478 </el-tabs>
1441 </ContentWrap> 1479 </ContentWrap>
1442 <ContentWrap id="id-table" title="资源表" v-if="detailInfo.damCatalogTableInfo?.length" description="" 1480 <ContentWrap id="id-table" title="文件资源" v-if="detailInfo.attachments?.length" description=""
1481 style="margin: 16px 16px 16px">
1482 <div class="list_panel">
1483 <div class="list_item is_block">
1484 <div class="file_item">
1485 <span class="item_label">上传文件:</span>
1486 <span class="item_value">
1487 <span v-for="productDetailItem in (detailInfo.attachments || [])"
1488 :style="{ 'padding-left': '0px', height: '32px', display: 'block' }">
1489 <div class="file-operate">
1490 <template
1491 v-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'xls' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'xlsx' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'csv'">
1492 <img class="file-img" src="../../assets/images/excel.png" />
1493 </template>
1494 <template
1495 v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'doc' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'docx'">
1496 <img class="file-img" src="../../assets/images/word.png" />
1497 </template>
1498 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'zip'">
1499 <img class="file-img" src="../../assets/images/zip.png" />
1500 </template>
1501 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'rar'">
1502 <img class="file-img" src="../../assets/images/RAR.png" />
1503 </template>
1504 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'pdf'">
1505 <img class="file-img" src="../../assets/images/PDF.png" />
1506 </template>
1507 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'png'">
1508 <img class="file-img" src="../../assets/images/png.png" />
1509 </template>
1510 <template
1511 v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'jpg' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'jpeg'">
1512 <img class="file-img" src="../../assets/images/jpg.png" />
1513 </template>
1514 <div class="file-name"><ellipsis-tooltip :content="productDetailItem.name ?? ''" class-name="w100f"
1515 refName="tooltipOver"></ellipsis-tooltip></div>
1516 <!-- <div
1517 v-if="foundMode != 'download' && ['pdf', 'png', 'jpg', 'jpeg'].includes(productDetailItem.name?.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase())"
1518 :style="{ right: '36px' }" class="file-preview" @click="onUploadFilePreview(productDetailItem)">
1519 查看
1520 </div> -->
1521 <div :style="{ right: '0px' }" class="file-preview" v-if="foundMode == 'download' || foundMode == 'readAndDown' || foundMode == '1'"
1522 @click="downloadFile(productDetailItem)">下载</div>
1523 </div>
1524 </span>
1525 </span>
1526 </div>
1527 </div>
1528 </div>
1529 </ContentWrap>
1530 <ContentWrap id="id-table" title="资源表" v-if="detailInfo.damCatalogTableInfo?.length && !detailInfo.attachments?.length" description=""
1443 style="margin: 16px 16px 16px"> 1531 style="margin: 16px 16px 16px">
1444 <el-table v-show="!fullscreenLoading" ref="tableRef" :data="detailInfo.damCatalogTableInfo" 1532 <el-table v-show="!fullscreenLoading" ref="tableRef" :data="detailInfo.damCatalogTableInfo"
1445 :highlight-current-row="true" stripe border @expand-change="handleTableExpandChange" max-height="350" 1533 :highlight-current-row="true" stripe border @expand-change="handleTableExpandChange" max-height="350"
...@@ -1532,6 +1620,7 @@ const respParamsTableInfo = ref({ ...@@ -1532,6 +1620,7 @@ const respParamsTableInfo = ref({
1532 <el-divider v-show="foundMode == 'readAndDown' || (!detailInfo.nodeId && foundMode == '1' && userData.superTubeFlag == 'Y')" direction="vertical" /> 1620 <el-divider v-show="foundMode == 'readAndDown' || (!detailInfo.nodeId && foundMode == '1' && userData.superTubeFlag == 'Y')" direction="vertical" />
1533 <span v-show="foundMode == 'download' || foundMode == 'readAndDown' || (!detailInfo.nodeId && foundMode == '1' && userData.superTubeFlag == 'Y')" class="text_btn" 1621 <span v-show="foundMode == 'download' || foundMode == 'readAndDown' || (!detailInfo.nodeId && foundMode == '1' && userData.superTubeFlag == 'Y')" class="text_btn"
1534 @click="handleTableViewDataDown(scope)">下载数据</span> 1622 @click="handleTableViewDataDown(scope)">下载数据</span>
1623 <span v-show="foundMode == '1'" class="text_btn" @click="handleTableViewDataDown(scope)">下载</span>
1535 </template> 1624 </template>
1536 </el-table-column> 1625 </el-table-column>
1537 </el-table> 1626 </el-table>
...@@ -1576,8 +1665,7 @@ const respParamsTableInfo = ref({ ...@@ -1576,8 +1665,7 @@ const respParamsTableInfo = ref({
1576 <img class="file-img" src="../../assets/images/jpg.png" /> 1665 <img class="file-img" src="../../assets/images/jpg.png" />
1577 </template> 1666 </template>
1578 <div class="file-name">{{ item.name }}</div> 1667 <div class="file-name">{{ item.name }}</div>
1579 <div :style="{ right: '36px' }" 1668 <div :style="{ right: '36px' }" v-if="item.name.substring(item.name.lastIndexOf('.') + 1) == 'pdf' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'png' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'jpg' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'jpeg'"
1580 v-if="item.name.substring(item.name.lastIndexOf('.') + 1) == 'pdf' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'png' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'jpg' || item.name.substring(item.name.lastIndexOf('.') + 1) == 'jpeg'"
1581 class="file-preview" @click="onUploadFilePreview(item)">查看</div> 1669 class="file-preview" @click="onUploadFilePreview(item)">查看</div>
1582 <div :style="{ right: '0px' }" class="file-preview" @click="onUploadFileDownload(item)">下载</div> 1670 <div :style="{ right: '0px' }" class="file-preview" @click="onUploadFileDownload(item)">下载</div>
1583 </div> 1671 </div>
...@@ -2132,6 +2220,10 @@ const respParamsTableInfo = ref({ ...@@ -2132,6 +2220,10 @@ const respParamsTableInfo = ref({
2132 } 2220 }
2133 } 2221 }
2134 2222
2223 .file_item {
2224 width: 70%;
2225 }
2226
2135 .file-operate { 2227 .file-operate {
2136 display: flex; 2228 display: flex;
2137 align-items: center; 2229 align-items: center;
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!