提交 73b4be4c 编写于 作者: Q qq_38870145

Fri Jan 5 21:53:00 CST 2024 inscode

上级 dfeb4e36
...@@ -4,7 +4,7 @@ import ExportBtn from './ExportBtn.vue'; ...@@ -4,7 +4,7 @@ import ExportBtn from './ExportBtn.vue';
import EchartBar from './EchartBar.vue'; import EchartBar from './EchartBar.vue';
import { tableColumns } from './const'; import { tableColumns } from './const';
import { getRemoteCsdnGrade } from '../service/csdnApi'; import { getRemoteCsdnGrade } from '../service/csdnApi';
import { onMounted, reactive, onUnmounted } from 'vue'; import { onMounted, reactive, onUnmounted, computed } from 'vue';
const state = reactive({ const state = reactive({
title: 'csdn用户根据id快速查分数改文章', title: 'csdn用户根据id快速查分数改文章',
...@@ -24,7 +24,8 @@ const state = reactive({ ...@@ -24,7 +24,8 @@ const state = reactive({
}, },
onShowSizeChange: changePageSize, // 改变每页数量时更新显示 onShowSizeChange: changePageSize, // 改变每页数量时更新显示
onChange: changePage,//点击页码事件 onChange: changePage,//点击页码事件
} },
selectedRows: []
}) })
// storage // storage
...@@ -47,7 +48,7 @@ const getCsdnData = (uId) => { ...@@ -47,7 +48,7 @@ const getCsdnData = (uId) => {
state.pagination.total = state.dataSource.length state.pagination.total = state.dataSource.length
state.loading = false state.loading = false
saveStorege(state.dataSource) saveStorege(state.dataSource)
}).catch((r) => { }).catch((r) => {
state.pagination.total = 0 state.pagination.total = 0
console.log(r) console.log(r)
...@@ -57,8 +58,8 @@ const getCsdnData = (uId) => { ...@@ -57,8 +58,8 @@ const getCsdnData = (uId) => {
}) })
} }
async function saveStorege(val){ async function saveStorege(val) {
return new Promise(resolve=>{ return new Promise(resolve => {
window.localStorage.setItem('csdnUidData', JSON.stringify(val)) window.localStorage.setItem('csdnUidData', JSON.stringify(val))
resolve(true) resolve(true)
}) })
...@@ -72,6 +73,24 @@ const onSearch = () => { ...@@ -72,6 +73,24 @@ const onSearch = () => {
getCsdnData(state.searchValue) getCsdnData(state.searchValue)
} }
const rowSelection = {
onChange: (selectedRowKeys, selectedRows) => {
console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
state.selectedRows = selectedRows
},
getCheckboxProps: (record) => ({
disabled: record.name === 'Disabled User', // Column configuration not to be checked
name: record.name,
})
}
const exportTableData = computed(() => {
if (state.selectedRows?.length) {
return state.selectedRows
}
return state.dataSource
})
...@@ -109,7 +128,7 @@ onUnmounted(() => { ...@@ -109,7 +128,7 @@ onUnmounted(() => {
<a style="font-size: 24px;font-weight:bolder;">{{ state.title }}</a> <a style="font-size: 24px;font-weight:bolder;">{{ state.title }}</a>
</div> </div>
<div> <div>
</div> </div>
<br> <br>
<div style="display:flex"> <div style="display:flex">
...@@ -118,9 +137,10 @@ onUnmounted(() => { ...@@ -118,9 +137,10 @@ onUnmounted(() => {
</div> </div>
<div> <div>
<ExportBtn :table-data="state.dataSource" :user-id="state.searchValue" /> <ExportBtn :table-data="exportTableData" :user-id="state.searchValue" />
<a-table :scroll="{ x: 800, y: 600 }" :columns="state.columns" :data-source="state.dataSource" <a-table :scroll="{ x: 800, y: 600 }" :columns="state.columns" :row-selection="rowSelection"
:loading="state.loading" :pagination="state.pagination" bordered style="border-bottom:1px solid #f0f0f0;"> :data-source="state.dataSource" :loading="state.loading" :pagination="state.pagination" bordered
style="border-bottom:1px solid #f0f0f0;">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'url'"> <template v-if="column.key === 'url'">
<a :href="record.url" target="_blank"> <a :href="record.url" target="_blank">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册