|
@@ -5,12 +5,11 @@
|
|
|
v-model:docType="docType"
|
|
v-model:docType="docType"
|
|
|
v-model:department="department"
|
|
v-model:department="department"
|
|
|
v-model:dateRange="dateRange"
|
|
v-model:dateRange="dateRange"
|
|
|
- v-model:keyword="filterKeyword"
|
|
|
|
|
@change="handleFilterChange"
|
|
@change="handleFilterChange"
|
|
|
/>
|
|
/>
|
|
|
<div class="result-area">
|
|
<div class="result-area">
|
|
|
<div class="result-header">
|
|
<div class="result-header">
|
|
|
- <StatsOverview :total="total" />
|
|
|
|
|
|
|
+ <StatsOverview :count="totalCount" />
|
|
|
<SortDropdown @change="handleSort" />
|
|
<SortDropdown @change="handleSort" />
|
|
|
</div>
|
|
</div>
|
|
|
<div class="result-list" v-loading="loading">
|
|
<div class="result-list" v-loading="loading">
|
|
@@ -27,14 +26,13 @@
|
|
|
<el-empty description="暂无搜索结果" />
|
|
<el-empty description="暂无搜索结果" />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
- <div v-if="total > 0" class="pagination-wrapper">
|
|
|
|
|
- <Pagination
|
|
|
|
|
- :total="total"
|
|
|
|
|
- :current-page="page"
|
|
|
|
|
- :page-size="pageSize"
|
|
|
|
|
- @change="handlePageChange"
|
|
|
|
|
- />
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <Pagination
|
|
|
|
|
+ v-if="searched"
|
|
|
|
|
+ :current-page="page"
|
|
|
|
|
+ :page-size="pageSize"
|
|
|
|
|
+ :total="totalCount"
|
|
|
|
|
+ @change="handlePageChange"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<!-- 文档预览弹窗 -->
|
|
<!-- 文档预览弹窗 -->
|
|
@@ -98,19 +96,20 @@ const searchParams = reactive({
|
|
|
const docType = ref('全部')
|
|
const docType = ref('全部')
|
|
|
const department = ref('全部')
|
|
const department = ref('全部')
|
|
|
const dateRange = ref<[string, string] | null>(null)
|
|
const dateRange = ref<[string, string] | null>(null)
|
|
|
-const filterKeyword = ref('')
|
|
|
|
|
|
|
|
|
|
// ============================================================
|
|
// ============================================================
|
|
|
// 搜索结果状态
|
|
// 搜索结果状态
|
|
|
// ============================================================
|
|
// ============================================================
|
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
|
const results = ref<any[]>([])
|
|
const results = ref<any[]>([])
|
|
|
-const total = ref(0)
|
|
|
|
|
const page = ref(1)
|
|
const page = ref(1)
|
|
|
const pageSize = ref(10)
|
|
const pageSize = ref(10)
|
|
|
const searched = ref(false)
|
|
const searched = ref(false)
|
|
|
const hasRestored = ref(false) // 防止重复恢复
|
|
const hasRestored = ref(false) // 防止重复恢复
|
|
|
|
|
|
|
|
|
|
+// 搜索结果总数(外部 API total_count)
|
|
|
|
|
+const totalCount = ref(0)
|
|
|
|
|
+
|
|
|
// 本地浏览量增量(解决 mapResultToItem 每次创建新对象导致更新丢失的问题)
|
|
// 本地浏览量增量(解决 mapResultToItem 每次创建新对象导致更新丢失的问题)
|
|
|
const browseCountDelta = reactive<Record<string, number>>({})
|
|
const browseCountDelta = reactive<Record<string, number>>({})
|
|
|
|
|
|
|
@@ -130,11 +129,10 @@ interface StoredState {
|
|
|
docType: string
|
|
docType: string
|
|
|
department: string
|
|
department: string
|
|
|
dateRange: [string, string] | null
|
|
dateRange: [string, string] | null
|
|
|
- filterKeyword: string
|
|
|
|
|
results: any[]
|
|
results: any[]
|
|
|
- total: number
|
|
|
|
|
page: number
|
|
page: number
|
|
|
pageSize: number
|
|
pageSize: number
|
|
|
|
|
+ totalCount: number
|
|
|
searched: boolean
|
|
searched: boolean
|
|
|
browseCountDelta: Record<string, number>
|
|
browseCountDelta: Record<string, number>
|
|
|
}
|
|
}
|
|
@@ -147,11 +145,10 @@ function saveState() {
|
|
|
docType: docType.value,
|
|
docType: docType.value,
|
|
|
department: department.value,
|
|
department: department.value,
|
|
|
dateRange: dateRange.value,
|
|
dateRange: dateRange.value,
|
|
|
- filterKeyword: filterKeyword.value,
|
|
|
|
|
results: results.value,
|
|
results: results.value,
|
|
|
- total: total.value,
|
|
|
|
|
page: page.value,
|
|
page: page.value,
|
|
|
pageSize: pageSize.value,
|
|
pageSize: pageSize.value,
|
|
|
|
|
+ totalCount: totalCount.value,
|
|
|
searched: searched.value,
|
|
searched: searched.value,
|
|
|
browseCountDelta: { ...browseCountDelta },
|
|
browseCountDelta: { ...browseCountDelta },
|
|
|
}
|
|
}
|
|
@@ -181,11 +178,10 @@ function restoreState(): boolean {
|
|
|
docType.value = state.docType
|
|
docType.value = state.docType
|
|
|
department.value = state.department
|
|
department.value = state.department
|
|
|
dateRange.value = state.dateRange
|
|
dateRange.value = state.dateRange
|
|
|
- filterKeyword.value = state.filterKeyword
|
|
|
|
|
results.value = state.results || []
|
|
results.value = state.results || []
|
|
|
- total.value = state.total ?? 0
|
|
|
|
|
page.value = state.page ?? 1
|
|
page.value = state.page ?? 1
|
|
|
pageSize.value = state.pageSize ?? 10
|
|
pageSize.value = state.pageSize ?? 10
|
|
|
|
|
+ totalCount.value = state.totalCount ?? 0
|
|
|
searched.value = true
|
|
searched.value = true
|
|
|
hasRestored.value = true
|
|
hasRestored.value = true
|
|
|
|
|
|
|
@@ -268,6 +264,7 @@ onDeactivated(() => {
|
|
|
function handleSearch(kw: string) {
|
|
function handleSearch(kw: string) {
|
|
|
searchParams.query = kw
|
|
searchParams.query = kw
|
|
|
page.value = 1
|
|
page.value = 1
|
|
|
|
|
+ totalCount.value = 0
|
|
|
doSearch()
|
|
doSearch()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -279,20 +276,17 @@ function handleFilterChange(params: any) {
|
|
|
if (params.department !== undefined) {
|
|
if (params.department !== undefined) {
|
|
|
searchParams.issuing_authority = params.department === '全部' ? '' : params.department
|
|
searchParams.issuing_authority = params.department === '全部' ? '' : params.department
|
|
|
}
|
|
}
|
|
|
- // keyword 仅在明确传入时更新,避免空字符串覆盖已有搜索词
|
|
|
|
|
- if (params.keyword && params.keyword !== '') {
|
|
|
|
|
- filterKeyword.value = params.keyword
|
|
|
|
|
- searchParams.query = params.keyword
|
|
|
|
|
- }
|
|
|
|
|
if (params.publishDateFrom) searchParams.start_time = params.publishDateFrom
|
|
if (params.publishDateFrom) searchParams.start_time = params.publishDateFrom
|
|
|
if (params.publishDateTo) searchParams.end_time = params.publishDateTo
|
|
if (params.publishDateTo) searchParams.end_time = params.publishDateTo
|
|
|
page.value = 1
|
|
page.value = 1
|
|
|
|
|
+ totalCount.value = 0
|
|
|
doSearch()
|
|
doSearch()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function handleSort(sortBy: string) {
|
|
function handleSort(sortBy: string) {
|
|
|
searchParams.sort_mode = sortBy
|
|
searchParams.sort_mode = sortBy
|
|
|
page.value = 1
|
|
page.value = 1
|
|
|
|
|
+ totalCount.value = 0
|
|
|
doSearch()
|
|
doSearch()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -463,16 +457,15 @@ async function doSearch() {
|
|
|
if (res.code !== undefined && String(res.code) !== '1' && String(res.code) !== '000000') {
|
|
if (res.code !== undefined && String(res.code) !== '1' && String(res.code) !== '000000') {
|
|
|
ElMessage.error(res.message || '检索失败')
|
|
ElMessage.error(res.message || '检索失败')
|
|
|
results.value = []
|
|
results.value = []
|
|
|
- total.value = 0
|
|
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
const data = res.data
|
|
const data = res.data
|
|
|
if (data) {
|
|
if (data) {
|
|
|
results.value = data.objs || []
|
|
results.value = data.objs || []
|
|
|
- total.value = data.total_count ?? data.objs?.length ?? 0
|
|
|
|
|
|
|
+ // 使用外部 API 返回的 total_count
|
|
|
|
|
+ totalCount.value = data.total_count || 0
|
|
|
} else {
|
|
} else {
|
|
|
results.value = []
|
|
results.value = []
|
|
|
- total.value = 0
|
|
|
|
|
}
|
|
}
|
|
|
} catch (e: any) {
|
|
} catch (e: any) {
|
|
|
ElMessage.error(e.message || '检索失败')
|
|
ElMessage.error(e.message || '检索失败')
|
|
@@ -504,12 +497,6 @@ async function doSearch() {
|
|
|
.empty-result {
|
|
.empty-result {
|
|
|
padding: 40px 0;
|
|
padding: 40px 0;
|
|
|
}
|
|
}
|
|
|
-.pagination-wrapper {
|
|
|
|
|
- display: flex;
|
|
|
|
|
- justify-content: center;
|
|
|
|
|
- margin-top: 24px;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
.preview-container {
|
|
.preview-container {
|
|
|
height: 75vh;
|
|
height: 75vh;
|
|
|
min-height: 500px;
|
|
min-height: 500px;
|