软件校验接口对接
This commit is contained in:
BIN
public/static/软件存在及可信校验模版.xlsx
Normal file
BIN
public/static/软件存在及可信校验模版.xlsx
Normal file
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
import { reqCatchV2, type catchRt } from '@/utils/catch';
|
||||
import request from '@/utils/request';
|
||||
import * as types from '@/api/repo/types';
|
||||
|
||||
// 详情-获取版本信息
|
||||
export function releaseInfo(params: { softwareId: string }): Promise<any> {
|
||||
@@ -134,3 +135,17 @@ export function getVulnerabilityList() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 迁移批量导入
|
||||
export function repoImport(data: types.commonRepoReqType){
|
||||
return reqCatchV2(() =>
|
||||
request({
|
||||
url: `/api/v1/home/software/valid`,
|
||||
method: 'post',
|
||||
data,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data', // 设置请求头
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ const handleFileUpload = async (event) => {
|
||||
const file = event.target.files[0]; // 获取选择的文件
|
||||
if (file) {
|
||||
// 检查文件类型
|
||||
if (file.type === 'text/xml' || file.name.endsWith('.xml')) {
|
||||
if (file.type === 'text/xml' || file.name.endsWith('.xml') || file.name.endsWith('.xlsx')) {
|
||||
loading.value = true; // 显示加载状态
|
||||
try {
|
||||
await props.onFileUpload(file); // 调用父组件传递的上传方法
|
||||
|
||||
@@ -24,7 +24,7 @@ const getCounts = () => {
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getCounts();
|
||||
// getCounts();
|
||||
addEventListener('updateNotice', debounce((count: number) => {
|
||||
counts.value = count;
|
||||
}, 500));
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="search-form">
|
||||
<FileUploadButton
|
||||
buttonText="批量导入"
|
||||
accept=".xml"
|
||||
accept=".xlsx"
|
||||
:onFileUpload="handleFileUpload"
|
||||
/>
|
||||
<d-input
|
||||
@@ -20,16 +20,16 @@
|
||||
<div class="tjsj">
|
||||
<span style="height: 14px" class="split"></span>
|
||||
<span>可使用:</span>
|
||||
<span class="green" @click="filterVerifyResult(1)">3</span>
|
||||
<span class="green" @click="filterVerifyResult(1)">{{useNum}}</span>
|
||||
<span style="height: 14px" class="split"></span>
|
||||
<span>有风险:</span>
|
||||
<span class="red" @click="filterVerifyResult(2)">3</span>
|
||||
<span class="red" @click="filterVerifyResult(2)">{{riskNum}}</span>
|
||||
<span style="height: 14px" class="split"></span>
|
||||
<span>未治理:</span>
|
||||
<span class="yellow" @click="filterVerifyResult(0)">3</span>
|
||||
<span class="yellow" @click="filterVerifyResult(0)">{{noNum}}</span>
|
||||
</div>
|
||||
<div class="left-btn">
|
||||
<a v-if="isLogin" class="cursor-pointer" href="/static/template.xlsx" download><i class="icon icon-download-2"></i>下载excel模板</a>
|
||||
<a v-if="isLogin" class="cursor-pointer" href="/static/软件存在及可信校验模版.xlsx" download><i class="icon icon-download-2"></i>下载excel模板</a>
|
||||
<span v-if="isLogin" style="height: 14px" class="split"></span>
|
||||
<d-button v-if="isLogin" class="output-btn" icon="icon-share" variant="text">导出</d-button>
|
||||
<span v-if="isLogin" style="height: 14px" class="split"></span>
|
||||
@@ -55,18 +55,18 @@
|
||||
>
|
||||
<!-- 自定义列内容 -->
|
||||
<template #default="scope">
|
||||
<template v-if="column.key === 'result'">
|
||||
<div v-if="scope.row.result == 1" style="display: flex; align-items: center">
|
||||
<template v-if="column.key === 'validStatus'">
|
||||
<div v-if="scope.row.validStatus == 1" style="display: flex; align-items: center">
|
||||
<d-icon class="mr-1" name="icon-right-o" style="font-size: 14px; color: rgb(80, 212, 171)"></d-icon>
|
||||
<span>可使用</span>
|
||||
</div>
|
||||
<div v-else-if="scope.row.result == 2" style="display: flex; align-items: center">
|
||||
<div v-else-if="scope.row.validStatus == 2" style="display: flex; align-items: center">
|
||||
<d-icon class="mr-1" name="icon-warning-o" style="font-size: 14px; color: rgb(250, 194, 10)"></d-icon>
|
||||
<span>未治理</span>
|
||||
<span>有风险</span>
|
||||
</div>
|
||||
<div v-else style="display: flex; align-items: center">
|
||||
<d-icon class="mr-1" name="icon-error-o" style="font-size: 14px; color: rgb(246, 111, 106)"></d-icon>
|
||||
<span>有风险</span>
|
||||
<span>未治理</span>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'versionName'">
|
||||
@@ -105,7 +105,7 @@
|
||||
<template #default="scope">
|
||||
<d-button
|
||||
variant="text"
|
||||
disabled
|
||||
:disabled="scope.row.validStatus !== 0"
|
||||
>
|
||||
申请入库
|
||||
</d-button>
|
||||
@@ -113,8 +113,10 @@
|
||||
</d-column>
|
||||
</d-table>
|
||||
|
||||
<DataPanel v-else skeleton :card="false" :empty="true">
|
||||
</DataPanel>
|
||||
<!-- <DataPanel v-else skeleton :card="false" :empty="true">-->
|
||||
<!-- </DataPanel>-->
|
||||
|
||||
<NoData v-else :small="false"></NoData>
|
||||
</div>
|
||||
|
||||
<div class="mt-20 mb-20 flex justify-end">
|
||||
@@ -136,7 +138,7 @@
|
||||
<script setup lang="ts">
|
||||
import SettingTitle from '@/components/Setting/SettingTitle/index.vue';
|
||||
import SettingText from '@/components/Setting/SettingText/index.vue';
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { getGroupClaList, setGroupClaStatus, deleteGroupCla } from '@/api/cla';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { GModal } from '@/components/Setting/index';
|
||||
@@ -147,12 +149,43 @@ import { useAccountStore } from '@/stores/user';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import TableSetting from '@/components/TableSetting/index.vue';
|
||||
import FileUploadButton from '@/components/FileUploadButton/index.vue';
|
||||
import { releasePage } from '@/api/jyh';
|
||||
import { releasePage, repoImport } from '@/api/jyh';
|
||||
import NoData from "@/components/NoData/NoData.vue";
|
||||
|
||||
const useNum = computed(() => {
|
||||
if (tableData.value.length>0) {
|
||||
return tableData.value.filter(item => item.validStatus === 1).length;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
const riskNum = computed(() => {
|
||||
if (tableData.value.length>0) {
|
||||
return tableData.value.filter(item => item.validStatus === 2).length;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
const noNum = computed(() => {
|
||||
if (tableData.value.length>0) {
|
||||
return tableData.value.filter(item => item.validStatus === 0).length;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
// 处理文件上传
|
||||
const handleFileUpload = async (file) => {
|
||||
console.log('选择的文件:', file.name);
|
||||
|
||||
const { data, error } = await repoImport({file});
|
||||
if (!error && data) {
|
||||
tableData.value = data.data.data;
|
||||
pager.value.total = data.data.data.length;
|
||||
}
|
||||
|
||||
// 模拟文件上传逻辑
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
@@ -168,7 +201,7 @@ const { namespace } = getOrgInfo();
|
||||
const allTableData = ref([]);
|
||||
const tableData = ref([]);
|
||||
const columns = ref([
|
||||
{ key: 'result', label: '校验结果', visible: true, filterable: true, sortable: false },
|
||||
{ key: 'validStatus', label: '校验结果', visible: true, filterable: true, sortable: false },
|
||||
{ key: 'softwareName', label: '软件名称', visible: true, filterable: true, sortable: false },
|
||||
{ key: 'softwareVersion', label: '软件版本', visible: true, filterable: true, sortable: false },
|
||||
{ key: 'securityScore', label: '软件评分', visible: true, filterable: false, sortable: true },
|
||||
@@ -215,7 +248,7 @@ const getReleaseList = async() => {
|
||||
};
|
||||
|
||||
onMounted(async() => {
|
||||
getReleaseList();
|
||||
// getReleaseList();
|
||||
});
|
||||
|
||||
const filterVerifyResult = (type) => {
|
||||
@@ -252,9 +285,11 @@ const handleBatchImport = async() => { // 多个项目导入
|
||||
const gotoDetail = (row) => {
|
||||
/*TODO:如果是可使用、有风险的,点击软件版本,可跳转到软件详情页面;如果是未治理的,无法跳转*/
|
||||
// 后续请换成params,暂时params传参没传过去
|
||||
router.push({
|
||||
path: 'repoDetail/' + row.version
|
||||
});
|
||||
if(row.validStatus == 1 || row.validStatus == 2) {
|
||||
router.push({
|
||||
path: 'repoDetail/' + row.softwareVersion
|
||||
});
|
||||
}
|
||||
};
|
||||
// 分页
|
||||
const changeIndex = () => {
|
||||
|
||||
@@ -76,8 +76,9 @@
|
||||
</template>
|
||||
</d-table>
|
||||
|
||||
<DataPanel v-else skeleton :card="false" :empty="true">
|
||||
</DataPanel>
|
||||
<!-- <DataPanel v-else skeleton :card="false" :empty="true">-->
|
||||
<!-- </DataPanel>-->
|
||||
<NoData v-else :small="false"></NoData>
|
||||
</div>
|
||||
|
||||
<div class="mt-20 mb-20 flex justify-end">
|
||||
|
||||
Reference in New Issue
Block a user