338f111e by lihua

添加数据产品下载源文件

1 parent 3bc59e4c
...@@ -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) {
...@@ -1287,9 +1346,9 @@ const handleImportSave = (val) => { ...@@ -1287,9 +1346,9 @@ const handleImportSave = (val) => {
1287 <ContentWrap id="id-baseInfo" title="资源基本信息" description="" :isExpand="baseInfoExpand" :expand-swicth="true" 1346 <ContentWrap id="id-baseInfo" title="资源基本信息" description="" :isExpand="baseInfoExpand" :expand-swicth="true"
1288 class="mb16" @expand="(v) => baseInfoExpand = v"> 1347 class="mb16" @expand="(v) => baseInfoExpand = v">
1289 <Form ref="baseInfoFormRef" :itemList="baseInfoFormItems" formId="base-info-form" :rules="baseInfoFormRules" 1348 <Form ref="baseInfoFormRef" :itemList="baseInfoFormItems" formId="base-info-form" :rules="baseInfoFormRules"
1290 @selectChange="baseSelectChange" @checkboxChange="handleBaseInfoCheckboxChange" col="col3" /> 1349 @selectChange="baseSelectChange" @checkboxChange="handleBaseInfoCheckboxChange" @radio-group-change="handleBaseInfoRadioChange" col="col3" />
1291 </ContentWrap> 1350 </ContentWrap>
1292 <ContentWrap v-if="baseInfoFormRef?.formInline?.damType == '2'" id="product-info" title="服务包信息" expandSwicth 1351 <ContentWrap v-if="baseInfoFormRef?.formInline?.damType == '2' && baseInfoFormRef?.formInline?.isFileResource != 'Y'" id="product-info" title="服务包信息" expandSwicth
1293 style="margin-top: 15px" :isExpand="expandServiceInfo" @expand="(v) => (expandServiceInfo = v)" description="" 1352 style="margin-top: 15px" :isExpand="expandServiceInfo" @expand="(v) => (expandServiceInfo = v)" description=""
1294 class="mb16"> 1353 class="mb16">
1295 <Table ref="productTableRef" :tableInfo="productTableInfo" class="fiveRow-table" 1354 <Table ref="productTableRef" :tableInfo="productTableInfo" class="fiveRow-table"
...@@ -1299,7 +1358,7 @@ const handleImportSave = (val) => { ...@@ -1299,7 +1358,7 @@ const handleImportSave = (val) => {
1299 v-preReClick>添加服务</el-button> 1358 v-preReClick>添加服务</el-button>
1300 </div> 1359 </div>
1301 </ContentWrap> 1360 </ContentWrap>
1302 <ContentWrap v-if="baseInfoFormRef?.formInline?.damType != '2'" id="id-tableInfo" title="资源表" description="" 1361 <ContentWrap v-if="baseInfoFormRef?.formInline?.damType != '2' && baseInfoFormRef?.formInline?.isFileResource != 'Y'" id="id-tableInfo" title="资源表" description=""
1303 :expand-swicth="true" :isExpand="assetTableInfoExpand" @expand="(v) => assetTableInfoExpand = v"> 1362 :expand-swicth="true" :isExpand="assetTableInfoExpand" @expand="(v) => assetTableInfoExpand = v">
1304 <div v-show="assetDataTableInfo.data.length" class="tools_btns"> 1363 <div v-show="assetDataTableInfo.data.length" class="tools_btns">
1305 <el-button type="primary" @click="handleCreateTable" v-preReClick>添加</el-button> 1364 <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(() => {
...@@ -1415,7 +1453,7 @@ const respParamsTableInfo = ref({ ...@@ -1415,7 +1453,7 @@ const respParamsTableInfo = ref({
1415 </div> 1453 </div>
1416 </div> 1454 </div>
1417 </ContentWrap> 1455 </ContentWrap>
1418 <ContentWrap v-if="productTableInfo.data?.length" id="product-info" title="服务包信息" style="margin: 16px 16px 16px"> 1456 <ContentWrap v-if="productTableInfo.data?.length && !detailInfo.attachments?.length" id="product-info" title="服务包信息" style="margin: 16px 16px 16px">
1419 <Table ref="productTableRef" :tableInfo="productTableInfo" /> 1457 <Table ref="productTableRef" :tableInfo="productTableInfo" />
1420 </ContentWrap> 1458 </ContentWrap>
1421 <ContentWrap v-if="isJSZQ" id="id-paramsInfo" title="入参出参信息" description="" style="margin: 16px 16px 16px"> 1459 <ContentWrap v-if="isJSZQ" id="id-paramsInfo" title="入参出参信息" description="" style="margin: 16px 16px 16px">
...@@ -1428,7 +1466,57 @@ const respParamsTableInfo = ref({ ...@@ -1428,7 +1466,57 @@ const respParamsTableInfo = ref({
1428 </el-tab-pane> 1466 </el-tab-pane>
1429 </el-tabs> 1467 </el-tabs>
1430 </ContentWrap> 1468 </ContentWrap>
1431 <ContentWrap id="id-table" title="资源表" v-if="detailInfo.damCatalogTableInfo?.length" description="" 1469 <ContentWrap id="id-table" title="文件资源" v-if="detailInfo.attachments?.length" description=""
1470 style="margin: 16px 16px 16px">
1471 <div class="list_panel">
1472 <div class="list_item is_block">
1473 <div class="file_item">
1474 <span class="item_label">上传文件:</span>
1475 <span class="item_value">
1476 <span v-for="productDetailItem in (detailInfo.attachments || [])"
1477 :style="{ 'padding-left': '0px', height: '32px', display: 'block' }">
1478 <div class="file-operate">
1479 <template
1480 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'">
1481 <img class="file-img" src="../../assets/images/excel.png" />
1482 </template>
1483 <template
1484 v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'doc' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'docx'">
1485 <img class="file-img" src="../../assets/images/word.png" />
1486 </template>
1487 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'zip'">
1488 <img class="file-img" src="../../assets/images/zip.png" />
1489 </template>
1490 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'rar'">
1491 <img class="file-img" src="../../assets/images/RAR.png" />
1492 </template>
1493 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'pdf'">
1494 <img class="file-img" src="../../assets/images/PDF.png" />
1495 </template>
1496 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'png'">
1497 <img class="file-img" src="../../assets/images/png.png" />
1498 </template>
1499 <template
1500 v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'jpg' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'jpeg'">
1501 <img class="file-img" src="../../assets/images/jpg.png" />
1502 </template>
1503 <div class="file-name"><ellipsis-tooltip :content="productDetailItem.name ?? ''" class-name="w100f"
1504 refName="tooltipOver"></ellipsis-tooltip></div>
1505 <!-- <div
1506 v-if="foundMode != 'download' && ['pdf', 'png', 'jpg', 'jpeg'].includes(productDetailItem.name?.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase())"
1507 :style="{ right: '36px' }" class="file-preview" @click="onUploadFilePreview(productDetailItem)">
1508 查看
1509 </div> -->
1510 <div :style="{ right: '0px' }" class="file-preview" v-if="foundMode == 'download' || foundMode == 'readAndDown' || foundMode == '1'"
1511 @click="downloadFile(productDetailItem)">下载</div>
1512 </div>
1513 </span>
1514 </span>
1515 </div>
1516 </div>
1517 </div>
1518 </ContentWrap>
1519 <ContentWrap id="id-table" title="资源表" v-if="detailInfo.damCatalogTableInfo?.length && !detailInfo.attachments?.length" description=""
1432 style="margin: 16px 16px 16px"> 1520 style="margin: 16px 16px 16px">
1433 <el-table v-show="!fullscreenLoading" ref="tableRef" :data="detailInfo.damCatalogTableInfo" 1521 <el-table v-show="!fullscreenLoading" ref="tableRef" :data="detailInfo.damCatalogTableInfo"
1434 :highlight-current-row="true" stripe border @expand-change="handleTableExpandChange" max-height="350" 1522 :highlight-current-row="true" stripe border @expand-change="handleTableExpandChange" max-height="350"
...@@ -1514,13 +1602,14 @@ const respParamsTableInfo = ref({ ...@@ -1514,13 +1602,14 @@ const respParamsTableInfo = ref({
1514 </template> 1602 </template>
1515 </el-table-column> 1603 </el-table-column>
1516 <el-table-column label="操作" v-if="!detailInfo.nodeId || foundMode == 'download' || foundMode == 'read' || foundMode == 'readAndDown'" 1604 <el-table-column label="操作" v-if="!detailInfo.nodeId || foundMode == 'download' || foundMode == 'read' || foundMode == 'readAndDown'"
1517 :width="foundMode == 'readAndDown' ? '220px' : '140px'" align="left" fixed="right" show-overflow-tooltip> 1605 :width="(foundMode == 'readAndDown' || foundMode == '1') ? '220px' : '140px'" align="left" fixed="right" show-overflow-tooltip>
1518 <template #default="scope"> 1606 <template #default="scope">
1519 <!-- 如果是下载,就只显示下载,如果是查看和下载就都显示,就两个按钮都显示。仅查看,就仅查看 --> 1607 <!-- 如果是下载,就只显示下载,如果是查看和下载就都显示,就两个按钮都显示。仅查看,就仅查看 -->
1520 <span v-show="foundMode != 'download'" class="text_btn" @click="handleTableViewData(scope)">查看样例数据</span> 1608 <span v-show="foundMode != 'download'" class="text_btn" @click="handleTableViewData(scope)">查看样例数据</span>
1521 <el-divider v-show="foundMode == 'readAndDown'" direction="vertical" /> 1609 <el-divider v-show="foundMode == 'readAndDown' || foundMode == '1'" direction="vertical" />
1522 <span v-show="foundMode == 'download' || foundMode == 'readAndDown'" class="text_btn" 1610 <span v-show="foundMode == 'download' || foundMode == 'readAndDown'" class="text_btn"
1523 @click="handleTableViewDataDown(scope)">下载数据</span> 1611 @click="handleTableViewDataDown(scope)">下载数据</span>
1612 <span v-show="foundMode == '1'" class="text_btn" @click="handleTableViewDataDown(scope)">下载</span>
1524 </template> 1613 </template>
1525 </el-table-column> 1614 </el-table-column>
1526 </el-table> 1615 </el-table>
...@@ -1565,8 +1654,7 @@ const respParamsTableInfo = ref({ ...@@ -1565,8 +1654,7 @@ const respParamsTableInfo = ref({
1565 <img class="file-img" src="../../assets/images/jpg.png" /> 1654 <img class="file-img" src="../../assets/images/jpg.png" />
1566 </template> 1655 </template>
1567 <div class="file-name">{{ item.name }}</div> 1656 <div class="file-name">{{ item.name }}</div>
1568 <div :style="{ right: '36px' }" 1657 <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'"
1569 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'"
1570 class="file-preview" @click="onUploadFilePreview(item)">查看</div> 1658 class="file-preview" @click="onUploadFilePreview(item)">查看</div>
1571 <div :style="{ right: '0px' }" class="file-preview" @click="onUploadFileDownload(item)">下载</div> 1659 <div :style="{ right: '0px' }" class="file-preview" @click="onUploadFileDownload(item)">下载</div>
1572 </div> 1660 </div>
...@@ -2121,6 +2209,10 @@ const respParamsTableInfo = ref({ ...@@ -2121,6 +2209,10 @@ const respParamsTableInfo = ref({
2121 } 2209 }
2122 } 2210 }
2123 2211
2212 .file_item {
2213 width: 70%;
2214 }
2215
2124 .file-operate { 2216 .file-operate {
2125 display: flex; 2217 display: flex;
2126 align-items: center; 2218 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!