fix: bug
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="secret-container">
|
||||
<div class="search-form">
|
||||
<d-form layout='horizontal' :label-align="'end'">
|
||||
<d-form layout="horizontal" :label-align="'end'">
|
||||
<d-row :gutter="16">
|
||||
<d-col :span="8">
|
||||
<d-form-item field="name" label="软件名称">
|
||||
@@ -69,15 +69,31 @@
|
||||
<d-button variant="solid" color="secondary" @click="clear">清空</d-button>
|
||||
</div>
|
||||
<div class="left-btn">
|
||||
<d-button v-if="isLogin" class="output-btn" icon="icon-share" variant="text" @click="exportResult">导出</d-button>
|
||||
<d-button v-if="isLogin" class="output-btn" icon="icon-share" variant="text" @click="exportResult"
|
||||
>导出</d-button
|
||||
>
|
||||
<span v-if="isLogin" style="height: 14px" class="split"></span>
|
||||
<TableSetting :columns="columns" @setDefult="setDefult" :show-column-list="showColumnList" @update:show-column-list="updateShowColumnList"/>
|
||||
<TableSetting
|
||||
:columns="columns"
|
||||
@setDefult="setDefult"
|
||||
:show-column-list="showColumnList"
|
||||
@update:show-column-list="updateShowColumnList"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3 px-20">
|
||||
<d-table :key="tableKey" class="jyh-table" v-if="tableData.length" :striped="false" :data="tableData" table-layout="auto">
|
||||
<d-table
|
||||
:key="tableKey"
|
||||
ref="filterTableRef"
|
||||
class="jyh-table"
|
||||
v-if="tableData.length"
|
||||
:striped="false"
|
||||
:data="tableData"
|
||||
table-layout="auto"
|
||||
>
|
||||
<d-column type="checkable" width="40" reserve-check align="center"></d-column>
|
||||
<!-- 索引列 -->
|
||||
<d-column type="index" width="40"></d-column>
|
||||
<!-- <d-column type="index" width="40"></d-column> -->
|
||||
|
||||
<!-- 动态渲染列 -->
|
||||
<template v-for="column in columns" :key="column.key">
|
||||
@@ -136,24 +152,39 @@
|
||||
</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">
|
||||
<d-pagination size="md" :page-size-options="[10, 20, 50]" :total="pager.total"
|
||||
v-model:pageSize="pager.pageSize" v-model:pageIndex="pager.pageIndex" :max-items="5"
|
||||
:can-change-page-size="true" :can-view-total="true" total-item-text="总计"
|
||||
@page-index-change="getReleaseList()"
|
||||
@page-size-change="getReleaseList()" />
|
||||
<d-pagination
|
||||
size="md"
|
||||
:page-size-options="[10, 20, 50]"
|
||||
:total="pager.total"
|
||||
v-model:pageSize="pager.pageSize"
|
||||
v-model:pageIndex="pager.pageIndex"
|
||||
:max-items="5"
|
||||
:can-change-page-size="true"
|
||||
:can-view-total="true"
|
||||
total-item-text="总计"
|
||||
@page-index-change="getReleaseList()"
|
||||
@page-size-change="getReleaseList()"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 删除组件 -->
|
||||
<GModal v-model="deletevModels" ref="deleteModal" title="删除?" @confirm="confirmDelete" showWarnIcon
|
||||
confirmColor="danger">
|
||||
<span class="inline-block text-G900 text-sm font-normal leading-[20px] break-all">你确认删除此项:{{ item.cla_name }}
|
||||
?</span>
|
||||
<GModal
|
||||
v-model="deletevModels"
|
||||
ref="deleteModal"
|
||||
title="删除?"
|
||||
@confirm="confirmDelete"
|
||||
showWarnIcon
|
||||
confirmColor="danger"
|
||||
>
|
||||
<span class="inline-block text-G900 text-sm font-normal leading-[20px] break-all"
|
||||
>你确认删除此项:{{ item.cla_name }} ?</span
|
||||
>
|
||||
</GModal>
|
||||
|
||||
<!-- 引入子组件 -->
|
||||
@@ -165,7 +196,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import AdvanceSearch from '@/components/AdvanceSearch/index.vue'
|
||||
import AdvanceSearch from '@/components/AdvanceSearch/index.vue';
|
||||
import SettingTitle from '@/components/Setting/SettingTitle/index.vue';
|
||||
import SettingText from '@/components/Setting/SettingText/index.vue';
|
||||
import { ref, reactive, onMounted, watch, nextTick } from 'vue';
|
||||
@@ -177,20 +208,20 @@ import { reqCatch } from '@/utils/catch';
|
||||
import { getOrgInfo } from '@/views/Org/hooks/orgInfo';
|
||||
import { Message } from 'vue-devui';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import CountryModal from './CountryModal.vue'
|
||||
import OrgModal from './OrgModal.vue'
|
||||
import CountryModal from './CountryModal.vue';
|
||||
import OrgModal from './OrgModal.vue';
|
||||
import NoData from '@/components/NoData/NoData.vue';
|
||||
import { useAccountStore } from '@/stores/user';
|
||||
import * as XLSX from "xlsx"
|
||||
import * as XLSX from 'xlsx';
|
||||
const { formatTime } = useTimeFormat();
|
||||
import { releasePage, searchLanguageList } from '@/api/jyh';
|
||||
import { useTimeFormat } from '@/utils/hooks/useTimeFormat';
|
||||
import { useGlobalInfoStore } from '@/stores/Global';
|
||||
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const filterTableRef = ref();
|
||||
const { namespace } = getOrgInfo();
|
||||
const userInfo = useAccountStore();
|
||||
const { isLogin } = storeToRefs(userInfo);
|
||||
@@ -202,7 +233,7 @@ const allTableData = ref([]);
|
||||
const tableData = ref([]);
|
||||
const languageList = ref([]);
|
||||
const globalInfo = useGlobalInfoStore();
|
||||
const headerSearch = ref(globalInfo.headerSearch)
|
||||
const headerSearch = ref(globalInfo.headerSearch);
|
||||
const industryList = ref(globalInfo.industryList);
|
||||
const newFormData = ref({
|
||||
licenseName: '',
|
||||
@@ -214,7 +245,7 @@ const newFormData = ref({
|
||||
interestTag: '',
|
||||
industry: '',
|
||||
dateRange: ['', '']
|
||||
})
|
||||
});
|
||||
|
||||
// watch(() => globalInfo.headerSearch, (newVal: any) => {
|
||||
// headerSearch.value = newVal;
|
||||
@@ -258,10 +289,16 @@ const defultColumns = ref([
|
||||
{ key: 'contributorOrganizations', label: '贡献者组织/公司分布', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'communityHash', label: '社区hash值', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'copyright', label: 'Copyright', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'externalVulnerabilitySource', label: '外部漏洞源的软件名称', visible: false, filterable: true, sortable: false },
|
||||
{
|
||||
key: 'externalVulnerabilitySource',
|
||||
label: '外部漏洞源的软件名称',
|
||||
visible: false,
|
||||
filterable: true,
|
||||
sortable: false
|
||||
},
|
||||
{ key: 'versionDescription', label: '版本描述', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'compatibilityRisk', label: '兼容性风险描述', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'eolDate', label: '社区EOL时间', visible: false, filterable: true, sortable: true },
|
||||
{ key: 'eolDate', label: '社区EOL时间', visible: false, filterable: true, sortable: true }
|
||||
]);
|
||||
// 定义 columns 数据
|
||||
const columns = ref([
|
||||
@@ -282,10 +319,16 @@ const columns = ref([
|
||||
{ key: 'contributorOrganizations', label: '贡献者组织/公司分布', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'communityHash', label: '社区hash值', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'copyright', label: 'Copyright', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'externalVulnerabilitySource', label: '外部漏洞源的软件名称', visible: false, filterable: true, sortable: false },
|
||||
{
|
||||
key: 'externalVulnerabilitySource',
|
||||
label: '外部漏洞源的软件名称',
|
||||
visible: false,
|
||||
filterable: true,
|
||||
sortable: false
|
||||
},
|
||||
{ key: 'versionDescription', label: '版本描述', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'compatibilityRisk', label: '兼容性风险描述', visible: false, filterable: false, sortable: false },
|
||||
{ key: 'eolDate', label: '社区EOL时间', visible: false, filterable: true, sortable: true },
|
||||
{ key: 'eolDate', label: '社区EOL时间', visible: false, filterable: true, sortable: true }
|
||||
]);
|
||||
|
||||
// 定义 showColumnList 状态
|
||||
@@ -295,7 +338,7 @@ const countryModalRef = ref(null);
|
||||
const orgModalRef = ref(null);
|
||||
|
||||
const getIndustryName = (value) => {
|
||||
const industry = industryList.value.find(item => item.value === value);
|
||||
const industry = industryList.value.find((item) => item.value === value);
|
||||
return industry ? industry.name : '未知行业'; // 如果找不到,返回默认值
|
||||
};
|
||||
|
||||
@@ -311,13 +354,13 @@ const clear = () => {
|
||||
interestTag: '',
|
||||
industry: '',
|
||||
dateRange: ['', '']
|
||||
}
|
||||
};
|
||||
getReleaseList();
|
||||
}
|
||||
};
|
||||
|
||||
// 打开模态框的方法
|
||||
const setDefult = () => {
|
||||
columns.value = defultColumns.value
|
||||
columns.value = defultColumns.value;
|
||||
};
|
||||
// 打开模态框的方法
|
||||
const openCountryModal = () => {
|
||||
@@ -415,7 +458,7 @@ const signCla = (row: any) => {
|
||||
router.push('/cla/' + row.object_id);
|
||||
};
|
||||
|
||||
const getReleaseList = async() => {
|
||||
const getReleaseList = async () => {
|
||||
const { data, error } = await releasePage({
|
||||
softwareName: newFormData.value.softwareName || '',
|
||||
searchType: newFormData.value.searchType || '',
|
||||
@@ -425,21 +468,22 @@ const getReleaseList = async() => {
|
||||
industry: newFormData.value.industry || '',
|
||||
licenseName: newFormData.value.licenseName || '',
|
||||
dependentSoftware: newFormData.value.dependentSoftware || '',
|
||||
releaseDateStart: newFormData.value.dateRange&&newFormData.value.dateRange.length>0?newFormData.value.dateRange[0]:'',
|
||||
releaseDateEnd: newFormData.value.dateRange&&newFormData.value.dateRange.length>0?newFormData.value.dateRange[1]:'',
|
||||
releaseDateStart:
|
||||
newFormData.value.dateRange && newFormData.value.dateRange.length > 0 ? newFormData.value.dateRange[0] : '',
|
||||
releaseDateEnd:
|
||||
newFormData.value.dateRange && newFormData.value.dateRange.length > 0 ? newFormData.value.dateRange[1] : '',
|
||||
current: pager.value.pageIndex,
|
||||
size: pager.value.pageSize
|
||||
});
|
||||
if (!error && data) {
|
||||
allTableData.value = data.data.records
|
||||
allTableData.value = data.data.records;
|
||||
tableData.value = data.data.records;
|
||||
pager.value.total = data.data.total;
|
||||
|
||||
console.log(tableData.value)
|
||||
console.log(tableData.value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const getLanguageList = async () => {
|
||||
const res: any = await searchLanguageList();
|
||||
if (!res.error) {
|
||||
@@ -447,20 +491,20 @@ const getLanguageList = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async() => {
|
||||
onMounted(async () => {
|
||||
await getLanguageList();
|
||||
newFormData.value.softwareName = route.query.softwareName || '';
|
||||
newFormData.value.searchType = route.query.searchType || '';
|
||||
newFormData.value.softwareVersion = route.query.softwareVersion || '';
|
||||
newFormData.value.programmingLanguage = route.query.programmingLanguage || '';
|
||||
newFormData.value.interestTag = route.query.interestTag || '';
|
||||
newFormData.value.industry = route.query.searchType || '';
|
||||
newFormData.value.licenseName = route.query.licenseName || '';
|
||||
newFormData.value.dependentSoftware = route.query.dependentSoftware || '';
|
||||
newFormData.value.dateRange = [route.query.releaseDateStart || '',route.query.releaseDateEnd || '']
|
||||
newFormData.value.softwareName = route.query.softwareName || '';
|
||||
newFormData.value.searchType = route.query.searchType || '';
|
||||
newFormData.value.softwareVersion = route.query.softwareVersion || '';
|
||||
newFormData.value.programmingLanguage = route.query.programmingLanguage || '';
|
||||
newFormData.value.interestTag = route.query.interestTag || '';
|
||||
newFormData.value.industry = route.query.searchType || '';
|
||||
newFormData.value.licenseName = route.query.licenseName || '';
|
||||
newFormData.value.dependentSoftware = route.query.dependentSoftware || '';
|
||||
newFormData.value.dateRange = [route.query.releaseDateStart || '', route.query.releaseDateEnd || ''];
|
||||
nextTick(() => {
|
||||
getReleaseList();
|
||||
})
|
||||
});
|
||||
// getReleaseList();
|
||||
});
|
||||
|
||||
@@ -472,29 +516,32 @@ onMounted(async() => {
|
||||
// });
|
||||
|
||||
const exportResult = () => {
|
||||
|
||||
if (!allTableData.value.length) {
|
||||
Message.info('暂无结果');
|
||||
const selectDatas = filterTableRef.value.store.getCheckedRows().map((d) => d.id);
|
||||
if (!allTableData.value.length || selectDatas.length <= 0) {
|
||||
Message.info('未选择任何数据');
|
||||
return;
|
||||
}
|
||||
|
||||
const exportData = allTableData.value.map(item => {
|
||||
let res = {}
|
||||
columns.value.forEach(col => {
|
||||
|
||||
if (col.key === 'validStatus') {
|
||||
res[col.label] = validStatusMap[item[col.key]] ? validStatusMap[item[col.key]] : '';
|
||||
} else {
|
||||
res[col.label] = item[col.key] ? item[col.key] : '';
|
||||
}
|
||||
const exportData = allTableData.value
|
||||
.filter((d) => {
|
||||
return selectDatas.includes(d.id);
|
||||
})
|
||||
return res
|
||||
})
|
||||
.map((item) => {
|
||||
let res = {};
|
||||
columns.value.forEach((col) => {
|
||||
if (col.key === 'validStatus') {
|
||||
res[col.label] = validStatusMap[item[col.key]] ? validStatusMap[item[col.key]] : '';
|
||||
} else {
|
||||
res[col.label] = item[col.key] ? item[col.key] : '';
|
||||
}
|
||||
});
|
||||
return res;
|
||||
});
|
||||
|
||||
try {
|
||||
const workSheet = XLSX.utils.json_to_sheet(exportData);
|
||||
const workBook: any = { Sheets: { '校验结果': workSheet}, SheetNames: ['校验结果']};
|
||||
const excelBuffer = XLSX.write(workBook, { bookType: 'xlsx', type: 'array'});
|
||||
const workBook: any = { Sheets: { 校验结果: workSheet }, SheetNames: ['校验结果'] };
|
||||
const excelBuffer = XLSX.write(workBook, { bookType: 'xlsx', type: 'array' });
|
||||
|
||||
const link = document.createElement('a');
|
||||
const blob = new Blob([excelBuffer]);
|
||||
@@ -504,12 +551,11 @@ const exportResult = () => {
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
Message.success('导出成功')
|
||||
Message.success('导出成功');
|
||||
} catch {
|
||||
Message.error('导出失败')
|
||||
Message.error('导出失败');
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -524,7 +570,6 @@ const exportResult = () => {
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.error {
|
||||
@@ -543,7 +588,7 @@ const exportResult = () => {
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
margin-right: 8px;
|
||||
border: 1px solid #E3E3EE;
|
||||
border: 1px solid #e3e3ee;
|
||||
}
|
||||
|
||||
.one-line {
|
||||
|
||||
Reference in New Issue
Block a user