9fbe3018 by lihua

添加数据产品下载源文件

1 parent e8f7d2ee
...@@ -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(() => {
...@@ -1429,7 +1467,7 @@ const respParamsTableInfo = ref({ ...@@ -1429,7 +1467,7 @@ const respParamsTableInfo = ref({
1429 </div> 1467 </div>
1430 </div> 1468 </div>
1431 </ContentWrap> 1469 </ContentWrap>
1432 <ContentWrap v-if="productTableInfo.data?.length" id="product-info" title="服务包信息" style="margin: 16px 16px 16px"> 1470 <ContentWrap v-if="productTableInfo.data?.length && !detailInfo.attachments?.length" id="product-info" title="服务包信息" style="margin: 16px 16px 16px">
1433 <Table ref="productTableRef" :tableInfo="productTableInfo" /> 1471 <Table ref="productTableRef" :tableInfo="productTableInfo" />
1434 </ContentWrap> 1472 </ContentWrap>
1435 <ContentWrap v-if="isJSZQ" id="id-paramsInfo" title="入参出参信息" description="" style="margin: 16px 16px 16px"> 1473 <ContentWrap v-if="isJSZQ" id="id-paramsInfo" title="入参出参信息" description="" style="margin: 16px 16px 16px">
...@@ -1442,7 +1480,57 @@ const respParamsTableInfo = ref({ ...@@ -1442,7 +1480,57 @@ const respParamsTableInfo = ref({
1442 </el-tab-pane> 1480 </el-tab-pane>
1443 </el-tabs> 1481 </el-tabs>
1444 </ContentWrap> 1482 </ContentWrap>
1445 <ContentWrap id="id-table" title="资源表" v-if="detailInfo.damCatalogTableInfo?.length" description="" 1483 <ContentWrap id="id-table" title="文件资源" v-if="detailInfo.attachments?.length" description=""
1484 style="margin: 16px 16px 16px">
1485 <div class="list_panel">
1486 <div class="list_item is_block">
1487 <div class="file_item">
1488 <span class="item_label">上传文件:</span>
1489 <span class="item_value">
1490 <span v-for="productDetailItem in (detailInfo.attachments || [])"
1491 :style="{ 'padding-left': '0px', height: '32px', display: 'block' }">
1492 <div class="file-operate">
1493 <template
1494 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'">
1495 <img class="file-img" src="../../assets/images/excel.png" />
1496 </template>
1497 <template
1498 v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'doc' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'docx'">
1499 <img class="file-img" src="../../assets/images/word.png" />
1500 </template>
1501 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'zip'">
1502 <img class="file-img" src="../../assets/images/zip.png" />
1503 </template>
1504 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'rar'">
1505 <img class="file-img" src="../../assets/images/RAR.png" />
1506 </template>
1507 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'pdf'">
1508 <img class="file-img" src="../../assets/images/PDF.png" />
1509 </template>
1510 <template v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'png'">
1511 <img class="file-img" src="../../assets/images/png.png" />
1512 </template>
1513 <template
1514 v-else-if="productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'jpg' || productDetailItem.name.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase() == 'jpeg'">
1515 <img class="file-img" src="../../assets/images/jpg.png" />
1516 </template>
1517 <div class="file-name"><ellipsis-tooltip :content="productDetailItem.name ?? ''" class-name="w100f"
1518 refName="tooltipOver"></ellipsis-tooltip></div>
1519 <!-- <div
1520 v-if="foundMode != 'download' && ['pdf', 'png', 'jpg', 'jpeg'].includes(productDetailItem.name?.substring(productDetailItem.name.lastIndexOf('.') + 1).toLowerCase())"
1521 :style="{ right: '36px' }" class="file-preview" @click="onUploadFilePreview(productDetailItem)">
1522 查看
1523 </div> -->
1524 <div :style="{ right: '0px' }" class="file-preview" v-if="foundMode == 'download' || foundMode == 'readAndDown' || foundMode == '1'"
1525 @click="downloadFile(productDetailItem)">下载</div>
1526 </div>
1527 </span>
1528 </span>
1529 </div>
1530 </div>
1531 </div>
1532 </ContentWrap>
1533 <ContentWrap id="id-table" title="资源表" v-if="detailInfo.damCatalogTableInfo?.length && !detailInfo.attachments?.length" description=""
1446 style="margin: 16px 16px 16px"> 1534 style="margin: 16px 16px 16px">
1447 <el-table v-show="!fullscreenLoading" ref="tableRef" :data="detailInfo.damCatalogTableInfo" 1535 <el-table v-show="!fullscreenLoading" ref="tableRef" :data="detailInfo.damCatalogTableInfo"
1448 :highlight-current-row="true" stripe border @expand-change="handleTableExpandChange" max-height="350" 1536 :highlight-current-row="true" stripe border @expand-change="handleTableExpandChange" max-height="350"
...@@ -1528,13 +1616,14 @@ const respParamsTableInfo = ref({ ...@@ -1528,13 +1616,14 @@ const respParamsTableInfo = ref({
1528 </template> 1616 </template>
1529 </el-table-column> 1617 </el-table-column>
1530 <el-table-column label="操作" v-if="!detailInfo.nodeId || foundMode == 'download' || foundMode == 'read' || foundMode == 'readAndDown'" 1618 <el-table-column label="操作" v-if="!detailInfo.nodeId || foundMode == 'download' || foundMode == 'read' || foundMode == 'readAndDown'"
1531 :width="foundMode == 'readAndDown' ? '220px' : '140px'" align="left" fixed="right" show-overflow-tooltip> 1619 :width="(foundMode == 'readAndDown' || foundMode == '1') ? '220px' : '140px'" align="left" fixed="right" show-overflow-tooltip>
1532 <template #default="scope"> 1620 <template #default="scope">
1533 <!-- 如果是下载,就只显示下载,如果是查看和下载就都显示,就两个按钮都显示。仅查看,就仅查看 --> 1621 <!-- 如果是下载,就只显示下载,如果是查看和下载就都显示,就两个按钮都显示。仅查看,就仅查看 -->
1534 <span v-show="foundMode != 'download'" class="text_btn" @click="handleTableViewData(scope)">查看样例数据</span> 1622 <span v-show="foundMode != 'download'" class="text_btn" @click="handleTableViewData(scope)">查看样例数据</span>
1535 <el-divider v-show="foundMode == 'readAndDown'" direction="vertical" /> 1623 <el-divider v-show="foundMode == 'readAndDown' || foundMode == '1'" direction="vertical" />
1536 <span v-show="foundMode == 'download' || foundMode == 'readAndDown'" class="text_btn" 1624 <span v-show="foundMode == 'download' || foundMode == 'readAndDown'" class="text_btn"
1537 @click="handleTableViewDataDown(scope)">下载数据</span> 1625 @click="handleTableViewDataDown(scope)">下载数据</span>
1626 <span v-show="foundMode == '1'" class="text_btn" @click="handleTableViewDataDown(scope)">下载</span>
1538 </template> 1627 </template>
1539 </el-table-column> 1628 </el-table-column>
1540 </el-table> 1629 </el-table>
...@@ -1579,8 +1668,7 @@ const respParamsTableInfo = ref({ ...@@ -1579,8 +1668,7 @@ const respParamsTableInfo = ref({
1579 <img class="file-img" src="../../assets/images/jpg.png" /> 1668 <img class="file-img" src="../../assets/images/jpg.png" />
1580 </template> 1669 </template>
1581 <div class="file-name">{{ item.name }}</div> 1670 <div class="file-name">{{ item.name }}</div>
1582 <div :style="{ right: '36px' }" 1671 <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'"
1583 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'"
1584 class="file-preview" @click="onUploadFilePreview(item)">查看</div> 1672 class="file-preview" @click="onUploadFilePreview(item)">查看</div>
1585 <div :style="{ right: '0px' }" class="file-preview" @click="onUploadFileDownload(item)">下载</div> 1673 <div :style="{ right: '0px' }" class="file-preview" @click="onUploadFileDownload(item)">下载</div>
1586 </div> 1674 </div>
...@@ -2135,6 +2223,10 @@ const respParamsTableInfo = ref({ ...@@ -2135,6 +2223,10 @@ const respParamsTableInfo = ref({
2135 } 2223 }
2136 } 2224 }
2137 2225
2226 .file_item {
2227 width: 70%;
2228 }
2229
2138 .file-operate { 2230 .file-operate {
2139 display: flex; 2231 display: flex;
2140 align-items: center; 2232 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!