feat: 整合知识库管理页面
This commit is contained in:
@@ -1,93 +1,73 @@
|
||||
import { request } from '@/api/request'
|
||||
import type { KbReply } from './faq'
|
||||
|
||||
/** 分类类型 */
|
||||
/** 公共分类状态。 */
|
||||
export type CategoryStatus = 'active' | 'inactive'
|
||||
|
||||
/** 公共分类。 */
|
||||
export interface Category {
|
||||
id: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
name: string
|
||||
description: string
|
||||
type: string
|
||||
type: 'general'
|
||||
icon: string
|
||||
color: string
|
||||
parent_id: number
|
||||
level: number
|
||||
level: 1 | 2 | 3
|
||||
path: string
|
||||
sort_order: number
|
||||
status: string
|
||||
status: CategoryStatus
|
||||
creator_id: number
|
||||
creator_name: string
|
||||
doc_count: number
|
||||
faq_count: number
|
||||
metadata: string | null
|
||||
metadata: string
|
||||
remarks: string
|
||||
}
|
||||
|
||||
/** API响应包装类型 */
|
||||
export interface ApiResponse<T = any> {
|
||||
code: number
|
||||
message: string
|
||||
data: T
|
||||
/** 公共分类树节点。 */
|
||||
export interface CategoryTreeNode extends Category {
|
||||
children: CategoryTreeNode[]
|
||||
}
|
||||
|
||||
/** 创建分类请求参数 */
|
||||
/** 创建分类参数。 */
|
||||
export interface CreateCategoryParams {
|
||||
name: string
|
||||
description?: string
|
||||
type?: string
|
||||
icon?: string
|
||||
color?: string
|
||||
parent_id?: number
|
||||
sort_order?: number
|
||||
remarks?: string
|
||||
description: string
|
||||
icon: string
|
||||
color: string
|
||||
parent_id: number
|
||||
sort_order: number
|
||||
status: CategoryStatus
|
||||
remarks: string
|
||||
}
|
||||
|
||||
/** 更新分类请求参数 */
|
||||
export interface UpdateCategoryParams {
|
||||
/** 更新分类参数。 */
|
||||
export interface UpdateCategoryParams extends CreateCategoryParams {
|
||||
id: number
|
||||
name?: string
|
||||
description?: string
|
||||
icon?: string
|
||||
color?: string
|
||||
sort_order?: number
|
||||
status?: string
|
||||
remarks?: string
|
||||
}
|
||||
|
||||
/** 获取分类列表参数 */
|
||||
/** 分类列表参数。 */
|
||||
export interface FetchCategoryListParams {
|
||||
type?: string
|
||||
parent_id?: number
|
||||
}
|
||||
|
||||
/** 创建分类 */
|
||||
export const createCategory = (data: CreateCategoryParams) => {
|
||||
return request.post<ApiResponse<Category>>('/Kb/v1/category/create', data)
|
||||
}
|
||||
/** 创建公共分类。 */
|
||||
export const createCategory = (data: CreateCategoryParams) => request.post<KbReply<Category>>('/Kb/v1/category/create', data)
|
||||
|
||||
/** 更新分类 */
|
||||
export const updateCategory = (data: UpdateCategoryParams) => {
|
||||
return request.post<ApiResponse<Category>>('/Kb/v1/category/update', data)
|
||||
}
|
||||
/** 更新公共分类。 */
|
||||
export const updateCategory = (data: UpdateCategoryParams) => request.post<KbReply<Category>>('/Kb/v1/category/update', data)
|
||||
|
||||
/** 删除分类 */
|
||||
export const deleteCategory = (id: number) => {
|
||||
return request.delete<ApiResponse<string>>(`/Kb/v1/category/${id}`)
|
||||
}
|
||||
/** 删除公共分类。 */
|
||||
export const deleteCategory = (id: number) => request.delete<KbReply<string>>(`/Kb/v1/category/${id}`)
|
||||
|
||||
/** 获取分类详情 */
|
||||
export const fetchCategoryDetail = (id: number) => {
|
||||
return request.get<ApiResponse<Category>>(`/Kb/v1/category/${id}`)
|
||||
}
|
||||
/** 获取公共分类详情。 */
|
||||
export const fetchCategoryDetail = (id: number) => request.get<KbReply<Category>>(`/Kb/v1/category/${id}`)
|
||||
|
||||
/** 获取分类列表 */
|
||||
export const fetchCategoryList = (params?: FetchCategoryListParams) => {
|
||||
return request.get<ApiResponse<Category[]>>('/Kb/v1/category/list', { params })
|
||||
}
|
||||
/** 获取公共分类列表。 */
|
||||
export const fetchCategoryList = (params?: FetchCategoryListParams) => request.get<KbReply<Category[]>>('/Kb/v1/category/list', { params })
|
||||
|
||||
/** 获取分类树 */
|
||||
export const fetchCategoryTree = (type?: string) => {
|
||||
return request.get<ApiResponse<Category[]>>('/Kb/v1/category/tree', {
|
||||
params: type ? { type } : undefined,
|
||||
})
|
||||
}
|
||||
/** 获取完整公共分类树,包含停用节点。 */
|
||||
export const fetchCategoryTree = () => request.get<KbReply<CategoryTreeNode[]>>('/Kb/v1/category/tree')
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { request } from '@/api/request'
|
||||
import type { KbReply } from './faq'
|
||||
|
||||
/** 文档状态 */
|
||||
/** 文档状态。 */
|
||||
export type DocumentStatus = 'draft' | 'published' | 'reviewed' | 'rejected'
|
||||
|
||||
/** 文档类型 */
|
||||
/** 文档类型。 */
|
||||
export type DocumentType = 'common' | 'guide' | 'solution' | 'troubleshoot' | 'process' | 'technical'
|
||||
/** 文档列表范围。 */
|
||||
export type DocumentScope = 'my' | 'all'
|
||||
|
||||
/** 文档接口类型 */
|
||||
/** 文档资源。 */
|
||||
export interface Document {
|
||||
id: number
|
||||
created_at: string
|
||||
@@ -33,71 +35,54 @@ export interface Document {
|
||||
version: string
|
||||
version_notes: string
|
||||
tags: string
|
||||
attachments: string | null
|
||||
related_docs: string | null
|
||||
detection_point_ids: string | null
|
||||
metadata: string | null
|
||||
attachments: string
|
||||
related_docs: string
|
||||
detection_point_ids: string
|
||||
metadata: string
|
||||
keywords: string
|
||||
remarks: string
|
||||
is_favorited?: boolean
|
||||
is_favorited: boolean
|
||||
}
|
||||
|
||||
/** API响应包装类型 */
|
||||
export interface ApiResponse<T = any> {
|
||||
code: number
|
||||
message: string
|
||||
data: T
|
||||
}
|
||||
|
||||
/** 分页响应类型 */
|
||||
export interface PaginatedResponse<T> {
|
||||
/** 文档分页结果。 */
|
||||
export interface DocumentPage {
|
||||
total: number
|
||||
page: number
|
||||
page_size: number
|
||||
data: T[]
|
||||
data: Document[]
|
||||
}
|
||||
|
||||
/** 创建文档请求参数 */
|
||||
/** 文档创建字段。 */
|
||||
export interface CreateDocumentParams {
|
||||
title: string
|
||||
description?: string
|
||||
description: string
|
||||
content: string
|
||||
type?: DocumentType
|
||||
category_id?: number
|
||||
sub_category?: string
|
||||
keywords?: string
|
||||
tags?: string
|
||||
detection_point_ids?: string
|
||||
remarks?: string
|
||||
type: DocumentType
|
||||
category_id: number
|
||||
sub_category: string
|
||||
keywords: string
|
||||
tags: string
|
||||
detection_point_ids: string
|
||||
remarks: string
|
||||
}
|
||||
|
||||
/** 更新文档请求参数 */
|
||||
export interface UpdateDocumentParams {
|
||||
/** 文档编辑字段。 */
|
||||
export interface UpdateDocumentParams extends CreateDocumentParams {
|
||||
id: number
|
||||
title?: string
|
||||
description?: string
|
||||
content?: string
|
||||
type?: DocumentType
|
||||
category_id?: number
|
||||
sub_category?: string
|
||||
keywords?: string
|
||||
tags?: string
|
||||
detection_point_ids?: string
|
||||
remarks?: string
|
||||
}
|
||||
|
||||
/** 获取文档列表参数 */
|
||||
/** 文档列表参数。 */
|
||||
export interface FetchDocumentListParams {
|
||||
page?: number
|
||||
page_size?: number
|
||||
scope?: DocumentScope
|
||||
keyword?: string
|
||||
type?: DocumentType
|
||||
status?: DocumentStatus
|
||||
category_id?: number
|
||||
}
|
||||
|
||||
/** 文档类型选项 */
|
||||
export const documentTypeOptions = [
|
||||
export const documentTypeOptions: Array<{ label: string; value: DocumentType }> = [
|
||||
{ label: '通用文档', value: 'common' },
|
||||
{ label: '操作指南', value: 'guide' },
|
||||
{ label: '解决方案', value: 'solution' },
|
||||
@@ -106,115 +91,28 @@ export const documentTypeOptions = [
|
||||
{ label: '技术文档', value: 'technical' },
|
||||
]
|
||||
|
||||
/** 文档状态选项 */
|
||||
export const documentStatusOptions = [
|
||||
{ label: '草稿', value: 'draft' },
|
||||
{ label: '已发布', value: 'published' },
|
||||
{ label: '已审核', value: 'reviewed' },
|
||||
{ label: '未通过审核', value: 'rejected' },
|
||||
]
|
||||
/** 创建文档草稿。 */
|
||||
export const createDocument = (data: CreateDocumentParams) => request.post<KbReply<Document>>('/Kb/v1/document/create', data)
|
||||
|
||||
/** 获取文档状态文本 */
|
||||
export const getDocumentStatusText = (status: DocumentStatus): string => {
|
||||
const statusMap: Record<DocumentStatus, string> = {
|
||||
draft: '草稿',
|
||||
published: '已发布',
|
||||
reviewed: '已审核',
|
||||
rejected: '未通过审核',
|
||||
}
|
||||
return statusMap[status] || status
|
||||
}
|
||||
/** 更新文档。 */
|
||||
export const updateDocument = (data: UpdateDocumentParams) => request.post<KbReply<Document>>('/Kb/v1/document/update', data)
|
||||
|
||||
/** 获取文档状态颜色 */
|
||||
export const getDocumentStatusColor = (status: DocumentStatus): string => {
|
||||
const colorMap: Record<DocumentStatus, string> = {
|
||||
draft: 'gray',
|
||||
published: 'blue',
|
||||
reviewed: 'green',
|
||||
rejected: 'red',
|
||||
}
|
||||
return colorMap[status] || 'gray'
|
||||
}
|
||||
/** 删除文档并移入回收站。 */
|
||||
export const deleteDocument = (id: number) => request.delete<KbReply<string>>(`/Kb/v1/document/${id}`)
|
||||
|
||||
/** 获取文档类型文本 */
|
||||
export const getDocumentTypeText = (type: DocumentType): string => {
|
||||
const typeMap: Record<DocumentType, string> = {
|
||||
common: '通用文档',
|
||||
guide: '操作指南',
|
||||
solution: '解决方案',
|
||||
troubleshoot: '故障排查',
|
||||
process: '流程规范',
|
||||
technical: '技术文档',
|
||||
}
|
||||
return typeMap[type] || type
|
||||
}
|
||||
/** 获取文档详情。 */
|
||||
export const fetchDocumentDetail = (id: number) => request.get<KbReply<Document>>(`/Kb/v1/document/${id}`)
|
||||
|
||||
/** 创建文档 */
|
||||
export const createDocument = (data: CreateDocumentParams) => {
|
||||
return request.post<ApiResponse<Document>>('/Kb/v1/document/create', data)
|
||||
}
|
||||
/** 获取指定可见范围的文档列表。 */
|
||||
export const fetchDocumentList = (params: FetchDocumentListParams) => request.get<KbReply<DocumentPage>>('/Kb/v1/document/list', { params })
|
||||
|
||||
/** 更新文档 */
|
||||
export const updateDocument = (data: UpdateDocumentParams) => {
|
||||
return request.post<ApiResponse<Document>>('/Kb/v1/document/update', data)
|
||||
}
|
||||
/** 提交文档审核。 */
|
||||
export const publishDocument = (id: number) => request.post<KbReply<string>>('/Kb/v1/document/publish', { id })
|
||||
|
||||
/** 删除文档(移入回收站) */
|
||||
export const deleteDocument = (id: number) => {
|
||||
return request.delete<ApiResponse<string>>(`/Kb/v1/document/${id}`)
|
||||
}
|
||||
/** 收藏文档。 */
|
||||
export const favoriteDocument = (id: number) =>
|
||||
request.post<KbReply<unknown>>('/Kb/v1/favorite/collect', { resource_type: 'document', resource_id: id })
|
||||
|
||||
/** 获取文档详情 */
|
||||
export const fetchDocumentDetail = (id: number) => {
|
||||
return request.get<ApiResponse<Document>>(`/Kb/v1/document/${id}`)
|
||||
}
|
||||
|
||||
/** 获取文档列表 */
|
||||
export const fetchDocumentList = (params?: FetchDocumentListParams) => {
|
||||
return request.get<ApiResponse<PaginatedResponse<Document>>>('/Kb/v1/document/list', { params })
|
||||
}
|
||||
|
||||
/** 发布文档 */
|
||||
export const publishDocument = (id: number) => {
|
||||
return request.post<ApiResponse<string>>('/Kb/v1/document/publish', { id })
|
||||
}
|
||||
|
||||
/** 移入回收站 */
|
||||
export const moveToTrash = (resourceId: number, resourceType: string) => {
|
||||
return request.post<ApiResponse<string>>('/Kb/v1/trash/move', {
|
||||
resource_id: resourceId,
|
||||
resource_type: resourceType,
|
||||
})
|
||||
}
|
||||
|
||||
/** 获取我的文档列表(由我创建的所有文档) */
|
||||
export const fetchMyDocumentList = (params?: FetchDocumentListParams) => {
|
||||
return request.get<ApiResponse<PaginatedResponse<Document>>>('/Kb/v1/review/publish/list', { params })
|
||||
}
|
||||
|
||||
/** 获取已审核通过的文档列表 */
|
||||
export const fetchApprovedDocumentList = (params?: FetchDocumentListParams) => {
|
||||
return request.get<ApiResponse<PaginatedResponse<Document>>>('/Kb/v1/review/approved/list', { params })
|
||||
}
|
||||
|
||||
/** 收藏文档 */
|
||||
export const favoriteDocument = (id: number, remarks?: string) => {
|
||||
return request.post<ApiResponse<string>>('/Kb/v1/favorite/collect', {
|
||||
resource_type: 'document',
|
||||
resource_id: id,
|
||||
remarks,
|
||||
})
|
||||
}
|
||||
|
||||
/** 取消收藏文档 */
|
||||
export const unfavoriteDocument = (id: number) => {
|
||||
return request.post<ApiResponse<string>>('/Kb/v1/favorite/uncollect', {
|
||||
resource_type: 'document',
|
||||
resource_id: id,
|
||||
})
|
||||
}
|
||||
|
||||
/** 下载文档 */
|
||||
export const downloadDocument = (id: number) => {
|
||||
return request.get<Blob>(`/Kb/v1/document/${id}/download`, { responseType: 'blob' })
|
||||
}
|
||||
/** 取消收藏文档。 */
|
||||
export const unfavoriteDocument = (id: number) =>
|
||||
request.post<KbReply<string>>('/Kb/v1/favorite/uncollect', { resource_type: 'document', resource_id: id })
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { request } from '@/api/request'
|
||||
import type { Document } from './document'
|
||||
import type { Faq, KbReply } from './faq'
|
||||
|
||||
/** 资源类型 */
|
||||
export type ResourceType = 'document' | 'faq'
|
||||
|
||||
/** 收藏记录接口 */
|
||||
/** 收藏记录。 */
|
||||
export interface Favorite {
|
||||
id: number
|
||||
created_at: string
|
||||
@@ -12,69 +13,36 @@ export interface Favorite {
|
||||
resource_name: string
|
||||
remarks: string
|
||||
is_deleted: boolean
|
||||
resource_data?: any
|
||||
resource_data?: Document | Faq
|
||||
}
|
||||
|
||||
/** 收藏列表响应 */
|
||||
export interface FavoriteListResponse {
|
||||
export interface FavoritePage {
|
||||
total: number
|
||||
page: number
|
||||
page_size: number
|
||||
data: Favorite[]
|
||||
}
|
||||
|
||||
/** 获取收藏列表参数 */
|
||||
export interface FetchFavoriteListParams {
|
||||
page?: number
|
||||
page_size?: number
|
||||
resource_type?: ResourceType
|
||||
}
|
||||
|
||||
/** 收藏请求参数 */
|
||||
export interface CollectParams {
|
||||
resource_type: ResourceType
|
||||
resource_id: number
|
||||
remarks?: string
|
||||
}
|
||||
|
||||
/** 取消收藏参数 */
|
||||
export interface UncollectParams {
|
||||
resource_type: ResourceType
|
||||
resource_id: number
|
||||
}
|
||||
export type UncollectParams = Omit<CollectParams, 'remarks'>
|
||||
|
||||
/** API响应包装类型 */
|
||||
export interface ApiResponse<T = any> {
|
||||
code: number
|
||||
message: string
|
||||
data: T
|
||||
}
|
||||
/** 获取收藏列表。 */
|
||||
export const fetchFavoriteList = (params: FetchFavoriteListParams = {}) =>
|
||||
request.get<KbReply<FavoritePage>>('/Kb/v1/favorite/list', { params })
|
||||
|
||||
/**
|
||||
* 获取收藏列表
|
||||
*/
|
||||
export async function fetchFavoriteList(params: FetchFavoriteListParams = {}): Promise<ApiResponse<FavoriteListResponse>> {
|
||||
return request.get<ApiResponse<FavoriteListResponse>>('/Kb/v1/favorite/list', {
|
||||
params,
|
||||
})
|
||||
}
|
||||
/** 收藏资源。 */
|
||||
export const collectResource = (data: CollectParams) => request.post<KbReply<Favorite>>('/Kb/v1/favorite/collect', data)
|
||||
|
||||
/**
|
||||
* 收藏资源
|
||||
*/
|
||||
export async function collectResource(data: CollectParams): Promise<ApiResponse<Favorite>> {
|
||||
return request.post<ApiResponse<Favorite>>('/Kb/v1/favorite/collect', data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消收藏
|
||||
*/
|
||||
export async function uncollectResource(data: UncollectParams): Promise<ApiResponse<string>> {
|
||||
return request.post<ApiResponse<string>>('/Kb/v1/favorite/uncollect', data)
|
||||
}
|
||||
|
||||
/** 资源类型选项 */
|
||||
export const resourceTypeOptions = [
|
||||
{ label: '文档', value: 'document' },
|
||||
{ label: 'FAQ', value: 'faq' },
|
||||
]
|
||||
/** 取消收藏。 */
|
||||
export const uncollectResource = (data: UncollectParams) => request.post<KbReply<string>>('/Kb/v1/favorite/uncollect', data)
|
||||
|
||||
@@ -1,169 +1,70 @@
|
||||
import { request } from '@/api/request'
|
||||
import type { Document } from './document'
|
||||
import type { Faq, KbReply } from './faq'
|
||||
|
||||
export type ReviewStatsResourceType = 'all' | 'document' | 'faq'
|
||||
export type ReviewResourceType = 'all' | 'document' | 'faq'
|
||||
|
||||
/** 审核统计接口返回的 data 字段 */
|
||||
export interface ReviewStatsPayload {
|
||||
need_my_review_document?: number
|
||||
need_my_review_faq?: number
|
||||
need_my_review_total?: number
|
||||
need_my_review_unreviewed_document?: number
|
||||
need_my_review_unreviewed_faq?: number
|
||||
need_my_review_unreviewed_total?: number
|
||||
}
|
||||
|
||||
/** 文档资源类型 */
|
||||
export interface DocumentResource {
|
||||
id: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
doc_no: string
|
||||
title: string
|
||||
description: string
|
||||
content: string
|
||||
type: string
|
||||
status: string
|
||||
category_id: number
|
||||
sub_category: string
|
||||
author_id: number
|
||||
author_name: string
|
||||
reviewer_id: number
|
||||
reviewer_name: string
|
||||
reviewed_at: string | null
|
||||
published_at: string | null
|
||||
publisher_id: number
|
||||
view_count: number
|
||||
like_count: number
|
||||
comment_count: number
|
||||
download_count: number
|
||||
version: string
|
||||
version_notes: string
|
||||
tags: string
|
||||
attachments: string | null
|
||||
related_docs: string | null
|
||||
metadata: string | null
|
||||
keywords: string
|
||||
remarks: string
|
||||
}
|
||||
|
||||
/** FAQ资源类型 */
|
||||
export interface FaqResource {
|
||||
id: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
faq_no: string
|
||||
question: string
|
||||
answer: string
|
||||
status: string
|
||||
priority: string
|
||||
category_id: number
|
||||
sub_category: string
|
||||
problem_type: string
|
||||
solution: string
|
||||
process_steps: string
|
||||
prerequisites: string
|
||||
author_id: number
|
||||
author_name: string
|
||||
reviewer_id: number
|
||||
reviewer_name: string
|
||||
reviewed_at: string | null
|
||||
published_at: string | null
|
||||
view_count: number
|
||||
use_count: number
|
||||
helpful_count: number
|
||||
useless_count: number
|
||||
tags: string
|
||||
related_faqs: string | null
|
||||
related_docs: string | null
|
||||
related_links: string | null
|
||||
attachments: string | null
|
||||
keywords: string
|
||||
applicable_scope: string
|
||||
remarks: string
|
||||
}
|
||||
|
||||
/** 审核列表项(resource_type 为 all 时) */
|
||||
/** 统一审核列表项。 */
|
||||
export interface ReviewListItem {
|
||||
type: 'document' | 'faq'
|
||||
resource: DocumentResource | FaqResource
|
||||
resource: Document | Faq
|
||||
}
|
||||
|
||||
/** 分页响应类型 */
|
||||
export interface PaginatedResponse<T> {
|
||||
/** 审核分页结果。 */
|
||||
export interface ReviewPage {
|
||||
total: number
|
||||
page: number
|
||||
page_size: number
|
||||
data: T[]
|
||||
data: ReviewListItem[]
|
||||
}
|
||||
|
||||
/** API响应包装类型 */
|
||||
export interface ApiResponse<T = any> {
|
||||
code: number
|
||||
message: string
|
||||
data: T
|
||||
/** 当前审核人的待审数量。 */
|
||||
export interface ReviewStats {
|
||||
need_my_review_document: number
|
||||
need_my_review_faq: number
|
||||
need_my_review_total: number
|
||||
need_my_review_unreviewed_document: number
|
||||
need_my_review_unreviewed_faq: number
|
||||
need_my_review_unreviewed_total: number
|
||||
}
|
||||
|
||||
/** 获取审核列表参数 */
|
||||
/** 审核列表参数。 */
|
||||
export interface FetchReviewListParams {
|
||||
page?: number
|
||||
page_size?: number
|
||||
resource_type?: ReviewStatsResourceType
|
||||
resource_type?: ReviewResourceType
|
||||
}
|
||||
|
||||
/** 审核通过参数 */
|
||||
export interface ApproveParams {
|
||||
resource_type: 'document' | 'faq'
|
||||
id: number
|
||||
}
|
||||
|
||||
/** 审核拒绝参数 */
|
||||
export interface RejectParams {
|
||||
resource_type: 'document' | 'faq'
|
||||
id: number
|
||||
reason?: string
|
||||
export interface RejectParams extends ApproveParams {
|
||||
reason: string
|
||||
}
|
||||
|
||||
/** 按当前登录用户统计需要本人审核的数量(不含本人为作者的稿件) */
|
||||
export const fetchReviewStats = (params?: { resource_type?: ReviewStatsResourceType }) =>
|
||||
request.get('/Kb/v1/review/stats', params ? { params } : undefined)
|
||||
/** 获取当前用户可审核的待审资源。 */
|
||||
export const fetchReviewList = (params: FetchReviewListParams) => request.get<KbReply<ReviewPage>>('/Kb/v1/review/list', { params })
|
||||
|
||||
/** 获取待审核列表 */
|
||||
export const fetchReviewList = (params?: FetchReviewListParams) =>
|
||||
request.get<ApiResponse<PaginatedResponse<ReviewListItem | DocumentResource | FaqResource>>>('/Kb/v1/review/list', { params })
|
||||
/** 获取当前审核人的待审统计。 */
|
||||
export const fetchReviewStats = (params: { resource_type?: ReviewResourceType } = {}) =>
|
||||
request.get<KbReply<ReviewStats>>('/Kb/v1/review/stats', { params })
|
||||
|
||||
/** 审核通过 */
|
||||
export const approveReview = (data: ApproveParams) => request.post<ApiResponse<string>>('/Kb/v1/review/approve', data)
|
||||
/** 审核通过。 */
|
||||
export const approveReview = (data: ApproveParams) => request.post<KbReply<string>>('/Kb/v1/review/approve', data)
|
||||
|
||||
/** 审核拒绝 */
|
||||
export const rejectReview = (data: RejectParams) => request.post<ApiResponse<string>>('/Kb/v1/review/reject', data)
|
||||
/** 审核拒绝。 */
|
||||
export const rejectReview = (data: RejectParams) => request.post<KbReply<string>>('/Kb/v1/review/reject', data)
|
||||
|
||||
/** 获取文档详情 */
|
||||
export const fetchDocumentDetail = (id: number) => request.get<ApiResponse<DocumentResource>>(`/Kb/v1/document/${id}`)
|
||||
|
||||
/** 获取FAQ详情 */
|
||||
export const fetchFaqDetail = (id: number) => request.get<ApiResponse<FaqResource>>(`/Kb/v1/faq/${id}`)
|
||||
|
||||
/** 资源类型选项 */
|
||||
export const resourceTypeOptions = [
|
||||
export const resourceTypeOptions: Array<{ label: string; value: ReviewResourceType }> = [
|
||||
{ label: '全部', value: 'all' },
|
||||
{ label: '文档', value: 'document' },
|
||||
{ label: 'FAQ', value: 'faq' },
|
||||
]
|
||||
|
||||
/** 获取资源类型文本 */
|
||||
export const getResourceTypeText = (type: string): string => {
|
||||
const typeMap: Record<string, string> = {
|
||||
document: '文档',
|
||||
faq: 'FAQ',
|
||||
}
|
||||
return typeMap[type] || type
|
||||
}
|
||||
/** 获取审核资源类型文案。 */
|
||||
export const getResourceTypeText = (type: string) => ({ document: '文档', faq: 'FAQ' })[type] || type
|
||||
|
||||
/** 获取资源类型颜色 */
|
||||
export const getResourceTypeColor = (type: string): string => {
|
||||
const colorMap: Record<string, string> = {
|
||||
document: 'arcoblue',
|
||||
faq: 'green',
|
||||
}
|
||||
return colorMap[type] || 'gray'
|
||||
}
|
||||
/** 获取审核资源类型颜色。 */
|
||||
export const getResourceTypeColor = (type: string) => ({ document: 'arcoblue', faq: 'green' })[type] || 'gray'
|
||||
|
||||
@@ -1,26 +1,14 @@
|
||||
import { request } from '@/api/request'
|
||||
import type { KbReply } from './faq'
|
||||
|
||||
/** API响应包装类型 */
|
||||
export interface ApiResponse<T = any> {
|
||||
code: number
|
||||
message: string
|
||||
data: T
|
||||
}
|
||||
export type TrashResourceType = 'document' | 'faq'
|
||||
|
||||
/** 分页响应类型 */
|
||||
export interface PaginatedResponse<T> {
|
||||
total: number
|
||||
page: number
|
||||
page_size: number
|
||||
data: T[]
|
||||
}
|
||||
|
||||
/** 回收站记录 */
|
||||
/** 回收站记录。 */
|
||||
export interface TrashRecord {
|
||||
id: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
resource_type: 'document' | 'faq'
|
||||
resource_type: TrashResourceType
|
||||
resource_id: number
|
||||
resource_name: string
|
||||
deleted_by: number
|
||||
@@ -31,58 +19,35 @@ export interface TrashRecord {
|
||||
remarks: string
|
||||
}
|
||||
|
||||
/** 获取回收站列表参数 */
|
||||
export interface TrashPage {
|
||||
total: number
|
||||
page: number
|
||||
page_size: number
|
||||
data: TrashRecord[]
|
||||
}
|
||||
|
||||
export interface FetchTrashListParams {
|
||||
page?: number
|
||||
page_size?: number
|
||||
resource_type?: 'document' | 'faq'
|
||||
resource_type?: TrashResourceType
|
||||
}
|
||||
|
||||
/** 恢复资源请求参数 */
|
||||
export interface RestoreTrashParams {
|
||||
id: number
|
||||
}
|
||||
|
||||
/** 彻底删除请求参数 */
|
||||
export interface DeleteTrashParams {
|
||||
id: number
|
||||
}
|
||||
|
||||
/** 资源类型选项 */
|
||||
export const resourceTypeOptions = [
|
||||
export const resourceTypeOptions: Array<{ label: string; value: TrashResourceType }> = [
|
||||
{ label: '文档', value: 'document' },
|
||||
{ label: '常见问题', value: 'faq' },
|
||||
{ label: 'FAQ', value: 'faq' },
|
||||
]
|
||||
|
||||
/** 获取资源类型文本 */
|
||||
export const getResourceTypeText = (type: string): string => {
|
||||
const typeMap: Record<string, string> = {
|
||||
document: '文档',
|
||||
faq: '常见问题',
|
||||
}
|
||||
return typeMap[type] || type
|
||||
}
|
||||
/** 获取回收站资源类型文案。 */
|
||||
export const getResourceTypeText = (type: string) => ({ document: '文档', faq: 'FAQ' })[type] || type
|
||||
|
||||
/** 获取资源类型颜色 */
|
||||
export const getResourceTypeColor = (type: string): string => {
|
||||
const colorMap: Record<string, string> = {
|
||||
document: 'blue',
|
||||
faq: 'green',
|
||||
}
|
||||
return colorMap[type] || 'gray'
|
||||
}
|
||||
/** 获取回收站资源类型颜色。 */
|
||||
export const getResourceTypeColor = (type: string) => ({ document: 'blue', faq: 'green' })[type] || 'gray'
|
||||
|
||||
/** 获取回收站列表 */
|
||||
export const fetchTrashList = (params?: FetchTrashListParams) => {
|
||||
return request.get<ApiResponse<PaginatedResponse<TrashRecord>>>('/Kb/v1/trash/list', { params })
|
||||
}
|
||||
/** 获取回收站列表。 */
|
||||
export const fetchTrashList = (params: FetchTrashListParams) => request.get<KbReply<TrashPage>>('/Kb/v1/trash/list', { params })
|
||||
|
||||
/** 恢复资源 */
|
||||
export const restoreTrash = (data: RestoreTrashParams) => {
|
||||
return request.post<ApiResponse<string>>('/Kb/v1/trash/restore', data)
|
||||
}
|
||||
/** 恢复资源。 */
|
||||
export const restoreTrash = (id: number) => request.post<KbReply<string>>('/Kb/v1/trash/restore', { id })
|
||||
|
||||
/** 彻底删除 */
|
||||
export const deleteTrash = (data: DeleteTrashParams) => {
|
||||
return request.post<ApiResponse<string>>('/Kb/v1/trash/delete', data)
|
||||
}
|
||||
/** 彻底删除资源。 */
|
||||
export const deleteTrash = (id: number) => request.post<KbReply<string>>('/Kb/v1/trash/delete', { id })
|
||||
|
||||
Reference in New Issue
Block a user