9b123ce8 by lihua

添加数据产品下载源文件

1 parent 4cee3cc6
......@@ -35,6 +35,7 @@ import {
getContractStrategy
} from "@/api/modules/dataDelivery";
import StrategyTable from '../data_smart_contract/components/strategyTable.vue';
import { getDownFileSignByUrl, obsDownloadRequest, parseAndDecodeUrl } from '@/api/modules/obsService';
const router = useRouter();
const route = useRoute();
......@@ -477,26 +478,44 @@ const handleTableViewData = (scope) => {
}
/** 下载数据 */
const handleTableViewDataDown = (scope) => {
downloadTableDataCheck({
userGuid: route.query.useGuid,
subjectGuid: scope.row.guid
}).then((res: any) => {
if (res?.code == proxy.$passCode) {
downloadTableData({
userGuid: route.query.useGuid,
subjectGuid: scope.row.guid
}).then((res: any) => {
if (res && !res.msg) {
download(res, `${scope.row.tableChName}.xlsx`, 'excel');
} else {
res?.msg && ElMessage.error(res?.msg);
}
})
} else {
ElMessage.error(res?.msg || '下载失败');
const handleTableViewDataDown = async (scope) => {
if (foundMode.value == 'download' || foundMode.value == 'readAndDown') {
downloadTableDataCheck({
userGuid: route.query.useGuid,
subjectGuid: scope.row.guid
}).then((res: any) => {
if (res?.code == proxy.$passCode) {
downloadTableData({
userGuid: route.query.useGuid,
subjectGuid: scope.row.guid
}).then((res: any) => {
if (res && !res.msg) {
download(res, `${scope.row.tableChName}.xlsx`, 'excel');
} else {
res?.msg && ElMessage.error(res?.msg);
}
})
} else {
ElMessage.error(res?.msg || '下载失败');
}
})
} else if (foundMode.value == '1') { //下载源文件
let fileUrl = scope.row.fileUrl;
const refSignInfo: any = await getDownFileSignByUrl(parseAndDecodeUrl(fileUrl).fileName);
if (!refSignInfo?.data) {
refSignInfo?.msg && ElMessage.error(refSignInfo?.msg);
return;
}
})
obsDownloadRequest(refSignInfo?.data).then((res: any) => {
if (res && !res.msg) {
let name = scope.row.fileName;
var fileSuffix = name ? name.substring(name.lastIndexOf('.') + 1) : '';
download(res, name, fileSuffix);
} else {
res?.msg && ElMessage.error(res?.msg);
}
})
}
}
const toolBtns: any = computed(() => {
......@@ -1528,9 +1547,10 @@ const respParamsTableInfo = ref({
<template #default="scope">
<!-- 如果是下载,就只显示下载,如果是查看和下载就都显示,就两个按钮都显示。仅查看,就仅查看 -->
<span v-show="foundMode != 'download'" class="text_btn" @click="handleTableViewData(scope)">查看样例数据</span>
<el-divider v-show="foundMode == 'readAndDown'" direction="vertical" />
<el-divider v-show="foundMode == 'readAndDown' || foundMode == '1'" direction="vertical" />
<span v-show="foundMode == 'download' || foundMode == 'readAndDown'" class="text_btn"
@click="handleTableViewDataDown(scope)">下载数据</span>
<span v-show="foundMode == '1'" class="text_btn" @click="handleTableViewDataDown(scope)">下载</span>
</template>
</el-table-column>
</el-table>
......@@ -1575,10 +1595,9 @@ const respParamsTableInfo = ref({
<img class="file-img" src="../../assets/images/jpg.png" />
</template>
<div class="file-name">{{ item.name }}</div>
<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'"
<div :style="{ right: '36px' }" v-if="foundMode != 'download' && 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'"
class="file-preview" @click="onUploadFilePreview(item)">查看</div>
<div :style="{ right: '0px' }" class="file-preview" @click="onUploadFileDownload(item)">下载</div>
<div v-if="foundMode == 'download' || foundMode == 'readAndDown' || foundMode == '1'" :style="{ right: '0px' }" class="file-preview" @click="onUploadFileDownload(item)">下载</div>
</div>
</span>
</div>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!