feat: add content review flow
This commit is contained in:
@@ -86,3 +86,19 @@ func (c *contents) UpdateStatus(ctx fiber.Ctx, tenantID, contentID int64, form *
|
|||||||
func (c *contents) Review(ctx fiber.Ctx, user *models.User, id int64, form *dto.SuperContentReviewForm) error {
|
func (c *contents) Review(ctx fiber.Ctx, user *models.User, id int64, form *dto.SuperContentReviewForm) error {
|
||||||
return services.Super.ReviewContent(ctx, user.ID, id, form)
|
return services.Super.ReviewContent(ctx, user.ID, id, form)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Batch review contents
|
||||||
|
//
|
||||||
|
// @Router /super/v1/contents/review/batch [post]
|
||||||
|
// @Summary Batch review contents
|
||||||
|
// @Description Batch review contents
|
||||||
|
// @Tags Content
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param form body dto.SuperContentBatchReviewForm true "Batch review form"
|
||||||
|
// @Success 200 {string} string "Reviewed"
|
||||||
|
// @Bind user local key(__ctx_user)
|
||||||
|
// @Bind form body
|
||||||
|
func (c *contents) BatchReview(ctx fiber.Ctx, user *models.User, form *dto.SuperContentBatchReviewForm) error {
|
||||||
|
return services.Super.BatchReviewContents(ctx, user.ID, form)
|
||||||
|
}
|
||||||
|
|||||||
@@ -391,6 +391,15 @@ type SuperContentReviewForm struct {
|
|||||||
Reason string `json:"reason"`
|
Reason string `json:"reason"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SuperContentBatchReviewForm struct {
|
||||||
|
// ContentIDs 待审核内容ID列表。
|
||||||
|
ContentIDs []int64 `json:"content_ids" validate:"required,min=1,dive,gt=0"`
|
||||||
|
// Action 审核动作(approve/reject)。
|
||||||
|
Action string `json:"action" validate:"required,oneof=approve reject"`
|
||||||
|
// Reason 审核说明(驳回时填写,便于作者修正)。
|
||||||
|
Reason string `json:"reason"`
|
||||||
|
}
|
||||||
|
|
||||||
type SuperTenantUserItem struct {
|
type SuperTenantUserItem struct {
|
||||||
// User 用户信息。
|
// User 用户信息。
|
||||||
User *SuperUserLite `json:"user"`
|
User *SuperUserLite `json:"user"`
|
||||||
|
|||||||
@@ -75,6 +75,12 @@ func (r *Routes) Register(router fiber.Router) {
|
|||||||
PathParam[int64]("id"),
|
PathParam[int64]("id"),
|
||||||
Body[dto.SuperContentReviewForm]("form"),
|
Body[dto.SuperContentReviewForm]("form"),
|
||||||
))
|
))
|
||||||
|
r.log.Debugf("Registering route: Post /super/v1/contents/review/batch -> contents.BatchReview")
|
||||||
|
router.Post("/super/v1/contents/review/batch"[len(r.Path()):], Func2(
|
||||||
|
r.contents.BatchReview,
|
||||||
|
Local[*models.User]("__ctx_user"),
|
||||||
|
Body[dto.SuperContentBatchReviewForm]("form"),
|
||||||
|
))
|
||||||
// Register routes for controller: coupons
|
// Register routes for controller: coupons
|
||||||
r.log.Debugf("Registering route: Get /super/v1/coupons -> coupons.List")
|
r.log.Debugf("Registering route: Get /super/v1/coupons -> coupons.List")
|
||||||
router.Get("/super/v1/coupons"[len(r.Path()):], DataFunc1(
|
router.Get("/super/v1/coupons"[len(r.Path()):], DataFunc1(
|
||||||
|
|||||||
@@ -1061,6 +1061,97 @@ func (s *super) ReviewContent(ctx context.Context, operatorID, contentID int64,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *super) BatchReviewContents(ctx context.Context, operatorID int64, form *super_dto.SuperContentBatchReviewForm) error {
|
||||||
|
if operatorID == 0 {
|
||||||
|
return errorx.ErrUnauthorized.WithMsg("缺少操作者信息")
|
||||||
|
}
|
||||||
|
if form == nil {
|
||||||
|
return errorx.ErrBadRequest.WithMsg("审核参数不能为空")
|
||||||
|
}
|
||||||
|
|
||||||
|
action := strings.ToLower(strings.TrimSpace(form.Action))
|
||||||
|
if action != "approve" && action != "reject" {
|
||||||
|
return errorx.ErrBadRequest.WithMsg("审核动作非法")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去重并过滤非法ID,确保审核集合有效。
|
||||||
|
unique := make(map[int64]struct{})
|
||||||
|
contentIDs := make([]int64, 0, len(form.ContentIDs))
|
||||||
|
for _, id := range form.ContentIDs {
|
||||||
|
if id <= 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, ok := unique[id]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
unique[id] = struct{}{}
|
||||||
|
contentIDs = append(contentIDs, id)
|
||||||
|
}
|
||||||
|
if len(contentIDs) == 0 {
|
||||||
|
return errorx.ErrBadRequest.WithMsg("内容ID不能为空")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 审核动作映射为内容状态。
|
||||||
|
nextStatus := consts.ContentStatusBlocked
|
||||||
|
if action == "approve" {
|
||||||
|
nextStatus = consts.ContentStatusPublished
|
||||||
|
}
|
||||||
|
reason := strings.TrimSpace(form.Reason)
|
||||||
|
|
||||||
|
var contents []*models.Content
|
||||||
|
err := models.Q.Transaction(func(tx *models.Query) error {
|
||||||
|
tbl, q := tx.Content.QueryContext(ctx)
|
||||||
|
list, err := q.Where(tbl.ID.In(contentIDs...)).Find()
|
||||||
|
if err != nil {
|
||||||
|
return errorx.ErrDatabaseError.WithCause(err)
|
||||||
|
}
|
||||||
|
if len(list) != len(contentIDs) {
|
||||||
|
return errorx.ErrRecordNotFound.WithMsg("部分内容不存在")
|
||||||
|
}
|
||||||
|
for _, content := range list {
|
||||||
|
if content.Status != consts.ContentStatusReviewing {
|
||||||
|
return errorx.ErrStatusConflict.WithMsg("仅可审核待审核内容")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updates := &models.Content{
|
||||||
|
Status: nextStatus,
|
||||||
|
UpdatedAt: time.Now(),
|
||||||
|
}
|
||||||
|
if nextStatus == consts.ContentStatusPublished {
|
||||||
|
updates.PublishedAt = time.Now()
|
||||||
|
}
|
||||||
|
if _, err := q.Where(tbl.ID.In(contentIDs...)).Updates(updates); err != nil {
|
||||||
|
return errorx.ErrDatabaseError.WithCause(err)
|
||||||
|
}
|
||||||
|
contents = list
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 审核完成后通知作者并记录审计日志(批量逐条记录,便于追溯)。
|
||||||
|
title := "内容审核结果"
|
||||||
|
detail := "内容审核通过"
|
||||||
|
if action == "reject" {
|
||||||
|
detail = "内容审核驳回"
|
||||||
|
if reason != "" {
|
||||||
|
detail += ",原因:" + reason
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, content := range contents {
|
||||||
|
if Notification != nil {
|
||||||
|
_ = Notification.Send(ctx, content.TenantID, content.UserID, string(consts.NotificationTypeAudit), title, detail)
|
||||||
|
}
|
||||||
|
if Audit != nil {
|
||||||
|
Audit.Log(ctx, operatorID, "review_content", cast.ToString(content.ID), detail)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *super) ListOrders(ctx context.Context, filter *super_dto.SuperOrderListFilter) (*requests.Pager, error) {
|
func (s *super) ListOrders(ctx context.Context, filter *super_dto.SuperOrderListFilter) (*requests.Pager, error) {
|
||||||
tbl, q := models.OrderQuery.QueryContext(ctx)
|
tbl, q := models.OrderQuery.QueryContext(ctx)
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,40 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/super/v1/contents/review/batch": {
|
||||||
|
"post": {
|
||||||
|
"description": "Batch review contents",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Content"
|
||||||
|
],
|
||||||
|
"summary": "Batch review contents",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "Batch review form",
|
||||||
|
"name": "form",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.SuperContentBatchReviewForm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Reviewed",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/super/v1/contents/{id}/review": {
|
"/super/v1/contents/{id}/review": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Review content",
|
"description": "Review content",
|
||||||
@@ -5502,6 +5536,35 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dto.SuperContentBatchReviewForm": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"action",
|
||||||
|
"content_ids"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"action": {
|
||||||
|
"description": "Action 审核动作(approve/reject)。",
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"approve",
|
||||||
|
"reject"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"content_ids": {
|
||||||
|
"description": "ContentIDs 待审核内容ID列表。",
|
||||||
|
"type": "array",
|
||||||
|
"minItems": 1,
|
||||||
|
"items": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"reason": {
|
||||||
|
"description": "Reason 审核说明(驳回时填写,便于作者修正)。",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dto.SuperContentReviewForm": {
|
"dto.SuperContentReviewForm": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@@ -127,6 +127,40 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/super/v1/contents/review/batch": {
|
||||||
|
"post": {
|
||||||
|
"description": "Batch review contents",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"Content"
|
||||||
|
],
|
||||||
|
"summary": "Batch review contents",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"description": "Batch review form",
|
||||||
|
"name": "form",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/dto.SuperContentBatchReviewForm"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Reviewed",
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/super/v1/contents/{id}/review": {
|
"/super/v1/contents/{id}/review": {
|
||||||
"post": {
|
"post": {
|
||||||
"description": "Review content",
|
"description": "Review content",
|
||||||
@@ -5496,6 +5530,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"dto.SuperContentBatchReviewForm": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"action",
|
||||||
|
"content_ids"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"action": {
|
||||||
|
"description": "Action 审核动作(approve/reject)。",
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"approve",
|
||||||
|
"reject"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"content_ids": {
|
||||||
|
"description": "ContentIDs 待审核内容ID列表。",
|
||||||
|
"type": "array",
|
||||||
|
"minItems": 1,
|
||||||
|
"items": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"reason": {
|
||||||
|
"description": "Reason 审核说明(驳回时填写,便于作者修正)。",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dto.SuperContentReviewForm": {
|
"dto.SuperContentReviewForm": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|||||||
@@ -1003,6 +1003,27 @@ definitions:
|
|||||||
description: Likes 累计点赞数。
|
description: Likes 累计点赞数。
|
||||||
type: integer
|
type: integer
|
||||||
type: object
|
type: object
|
||||||
|
dto.SuperContentBatchReviewForm:
|
||||||
|
properties:
|
||||||
|
action:
|
||||||
|
description: Action 审核动作(approve/reject)。
|
||||||
|
enum:
|
||||||
|
- approve
|
||||||
|
- reject
|
||||||
|
type: string
|
||||||
|
content_ids:
|
||||||
|
description: ContentIDs 待审核内容ID列表。
|
||||||
|
items:
|
||||||
|
type: integer
|
||||||
|
minItems: 1
|
||||||
|
type: array
|
||||||
|
reason:
|
||||||
|
description: Reason 审核说明(驳回时填写,便于作者修正)。
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- action
|
||||||
|
- content_ids
|
||||||
|
type: object
|
||||||
dto.SuperContentReviewForm:
|
dto.SuperContentReviewForm:
|
||||||
properties:
|
properties:
|
||||||
action:
|
action:
|
||||||
@@ -2138,6 +2159,28 @@ paths:
|
|||||||
summary: Review content
|
summary: Review content
|
||||||
tags:
|
tags:
|
||||||
- Content
|
- Content
|
||||||
|
/super/v1/contents/review/batch:
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Batch review contents
|
||||||
|
parameters:
|
||||||
|
- description: Batch review form
|
||||||
|
in: body
|
||||||
|
name: form
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/dto.SuperContentBatchReviewForm'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Reviewed
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
summary: Batch review contents
|
||||||
|
tags:
|
||||||
|
- Content
|
||||||
/super/v1/coupons:
|
/super/v1/coupons:
|
||||||
get:
|
get:
|
||||||
consumes:
|
consumes:
|
||||||
|
|||||||
@@ -42,8 +42,8 @@
|
|||||||
|
|
||||||
### 2.7 内容治理 `/superadmin/contents`
|
### 2.7 内容治理 `/superadmin/contents`
|
||||||
- 状态:**部分完成**
|
- 状态:**部分完成**
|
||||||
- 已有:跨租户列表、下架。
|
- 已有:跨租户列表、下架、审核流(含批量审核)。
|
||||||
- 缺口:审核流(review)、评论治理/举报处理、批量处置。
|
- 缺口:评论治理、内容举报处理、批量处置扩展(如批量下架/封禁)。
|
||||||
|
|
||||||
### 2.8 订单与退款 `/superadmin/orders`
|
### 2.8 订单与退款 `/superadmin/orders`
|
||||||
- 状态:**已完成**
|
- 状态:**已完成**
|
||||||
|
|||||||
@@ -109,5 +109,26 @@ export const ContentService = {
|
|||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
body: { status }
|
body: { status }
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
async reviewContent(contentID, { action, reason } = {}) {
|
||||||
|
if (!contentID) throw new Error('contentID is required');
|
||||||
|
return requestJson(`/super/v1/contents/${contentID}/review`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: {
|
||||||
|
action,
|
||||||
|
reason
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async batchReviewContents({ content_ids, action, reason } = {}) {
|
||||||
|
if (!Array.isArray(content_ids) || content_ids.length === 0) throw new Error('content_ids is required');
|
||||||
|
return requestJson('/super/v1/contents/review/batch', {
|
||||||
|
method: 'POST',
|
||||||
|
body: {
|
||||||
|
content_ids,
|
||||||
|
action,
|
||||||
|
reason
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,6 +32,17 @@ const priceAmountMin = ref(null);
|
|||||||
const priceAmountMax = ref(null);
|
const priceAmountMax = ref(null);
|
||||||
const sortField = ref('id');
|
const sortField = ref('id');
|
||||||
const sortOrder = ref(-1);
|
const sortOrder = ref(-1);
|
||||||
|
const selectedContents = ref([]);
|
||||||
|
|
||||||
|
const reviewDialogVisible = ref(false);
|
||||||
|
const reviewSubmitting = ref(false);
|
||||||
|
const reviewAction = ref('approve');
|
||||||
|
const reviewReason = ref('');
|
||||||
|
const reviewTargetIDs = ref([]);
|
||||||
|
const reviewActionOptions = [
|
||||||
|
{ label: '通过', value: 'approve' },
|
||||||
|
{ label: '驳回', value: 'reject' }
|
||||||
|
];
|
||||||
|
|
||||||
const statusOptions = [
|
const statusOptions = [
|
||||||
{ label: '全部', value: '' },
|
{ label: '全部', value: '' },
|
||||||
@@ -67,6 +78,11 @@ function parseDate(value) {
|
|||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getContentID(row) {
|
||||||
|
const id = Number(row?.content?.id ?? row?.id ?? 0);
|
||||||
|
return Number.isFinite(id) ? id : 0;
|
||||||
|
}
|
||||||
|
|
||||||
function formatDate(value) {
|
function formatDate(value) {
|
||||||
if (!value) return '-';
|
if (!value) return '-';
|
||||||
if (String(value).startsWith('0001-01-01')) return '-';
|
if (String(value).startsWith('0001-01-01')) return '-';
|
||||||
@@ -159,6 +175,9 @@ function getContentVisibilitySeverity(value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectedCount = computed(() => selectedContents.value.length);
|
||||||
|
const reviewTargetCount = computed(() => reviewTargetIDs.value.length);
|
||||||
|
|
||||||
async function loadContents() {
|
async function loadContents() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
@@ -184,6 +203,7 @@ async function loadContents() {
|
|||||||
sortOrder: sortOrder.value
|
sortOrder: sortOrder.value
|
||||||
});
|
});
|
||||||
contents.value = (result.items || []).map((item) => ({ ...item, __key: item?.content?.id ?? undefined }));
|
contents.value = (result.items || []).map((item) => ({ ...item, __key: item?.content?.id ?? undefined }));
|
||||||
|
selectedContents.value = [];
|
||||||
totalRecords.value = result.total;
|
totalRecords.value = result.total;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.add({ severity: 'error', summary: '加载失败', detail: error?.message || '无法加载内容列表', life: 4000 });
|
toast.add({ severity: 'error', summary: '加载失败', detail: error?.message || '无法加载内容列表', life: 4000 });
|
||||||
@@ -192,6 +212,60 @@ async function loadContents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openReviewDialog(row) {
|
||||||
|
const id = getContentID(row);
|
||||||
|
if (!id) return;
|
||||||
|
reviewTargetIDs.value = [id];
|
||||||
|
reviewAction.value = 'approve';
|
||||||
|
reviewReason.value = '';
|
||||||
|
reviewDialogVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function openBatchReviewDialog(action) {
|
||||||
|
if (!selectedContents.value.length) {
|
||||||
|
toast.add({ severity: 'warn', summary: '请先选择内容', detail: '至少选择 1 条内容进行审核', life: 3000 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ids = selectedContents.value.map((row) => getContentID(row)).filter((id) => id > 0);
|
||||||
|
if (!ids.length) {
|
||||||
|
toast.add({ severity: 'warn', summary: '选择无效', detail: '未识别到可审核的内容', life: 3000 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reviewTargetIDs.value = ids;
|
||||||
|
reviewAction.value = action || 'approve';
|
||||||
|
reviewReason.value = '';
|
||||||
|
reviewDialogVisible.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function confirmReview() {
|
||||||
|
const action = reviewAction.value;
|
||||||
|
const reason = reviewReason.value.trim();
|
||||||
|
const ids = reviewTargetIDs.value.filter((id) => id > 0);
|
||||||
|
if (!ids.length) return;
|
||||||
|
if (action === 'reject' && !reason) {
|
||||||
|
toast.add({ severity: 'warn', summary: '请输入原因', detail: '驳回时需填写原因', life: 3000 });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
reviewSubmitting.value = true;
|
||||||
|
try {
|
||||||
|
if (ids.length === 1) {
|
||||||
|
await ContentService.reviewContent(ids[0], { action, reason });
|
||||||
|
} else {
|
||||||
|
await ContentService.batchReviewContents({ content_ids: ids, action, reason });
|
||||||
|
}
|
||||||
|
toast.add({ severity: 'success', summary: '审核成功', detail: `已处理 ${ids.length} 条内容`, life: 3000 });
|
||||||
|
reviewDialogVisible.value = false;
|
||||||
|
reviewTargetIDs.value = [];
|
||||||
|
selectedContents.value = [];
|
||||||
|
await loadContents();
|
||||||
|
} catch (error) {
|
||||||
|
toast.add({ severity: 'error', summary: '审核失败', detail: error?.message || '无法完成审核', life: 4000 });
|
||||||
|
} finally {
|
||||||
|
reviewSubmitting.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onSearch() {
|
function onSearch() {
|
||||||
page.value = 1;
|
page.value = 1;
|
||||||
loadContents();
|
loadContents();
|
||||||
@@ -265,8 +339,13 @@ watch(
|
|||||||
<h4 class="m-0">内容列表</h4>
|
<h4 class="m-0">内容列表</h4>
|
||||||
<span class="text-muted-color">平台侧汇总(跨租户)</span>
|
<span class="text-muted-color">平台侧汇总(跨租户)</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span class="text-sm text-muted-color">已选 {{ selectedCount }} 条</span>
|
||||||
|
<Button label="批量通过" icon="pi pi-check" severity="success" :disabled="selectedCount === 0" @click="openBatchReviewDialog('approve')" />
|
||||||
|
<Button label="批量驳回" icon="pi pi-times" severity="danger" :disabled="selectedCount === 0" @click="openBatchReviewDialog('reject')" />
|
||||||
<Button label="刷新" icon="pi pi-refresh" severity="secondary" @click="loadContents" :disabled="loading" />
|
<Button label="刷新" icon="pi pi-refresh" severity="secondary" @click="loadContents" :disabled="loading" />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<SearchPanel :loading="loading" @search="onSearch" @reset="onReset">
|
<SearchPanel :loading="loading" @search="onSearch" @reset="onReset">
|
||||||
@@ -320,6 +399,7 @@ watch(
|
|||||||
<DataTable
|
<DataTable
|
||||||
:value="contents"
|
:value="contents"
|
||||||
dataKey="__key"
|
dataKey="__key"
|
||||||
|
v-model:selection="selectedContents"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
lazy
|
lazy
|
||||||
:paginator="true"
|
:paginator="true"
|
||||||
@@ -338,6 +418,7 @@ watch(
|
|||||||
scrollHeight="640px"
|
scrollHeight="640px"
|
||||||
responsiveLayout="scroll"
|
responsiveLayout="scroll"
|
||||||
>
|
>
|
||||||
|
<Column selectionMode="multiple" headerStyle="width: 3rem" />
|
||||||
<Column header="ID" sortable sortField="id" style="min-width: 8rem">
|
<Column header="ID" sortable sortField="id" style="min-width: 8rem">
|
||||||
<template #body="{ data }">
|
<template #body="{ data }">
|
||||||
<span class="text-muted-color">{{ data?.content?.id ?? '-' }}</span>
|
<span class="text-muted-color">{{ data?.content?.id ?? '-' }}</span>
|
||||||
@@ -406,7 +487,8 @@ watch(
|
|||||||
</Column>
|
</Column>
|
||||||
<Column header="操作" style="min-width: 10rem">
|
<Column header="操作" style="min-width: 10rem">
|
||||||
<template #body="{ data }">
|
<template #body="{ data }">
|
||||||
<Button v-if="data?.content?.status === 'published'" label="下架" icon="pi pi-ban" severity="danger" text size="small" class="p-0" @click="openUnpublishDialog(data)" />
|
<Button v-if="data?.content?.status === 'reviewing'" label="审核" icon="pi pi-check-square" text size="small" class="p-0 mr-3" @click="openReviewDialog(data)" />
|
||||||
|
<Button v-else-if="data?.content?.status === 'published'" label="下架" icon="pi pi-ban" severity="danger" text size="small" class="p-0" @click="openUnpublishDialog(data)" />
|
||||||
<span v-else class="text-muted-color">-</span>
|
<span v-else class="text-muted-color">-</span>
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
@@ -431,4 +513,28 @@ watch(
|
|||||||
<Button label="确认下架" icon="pi pi-ban" severity="danger" @click="confirmUnpublish" :loading="unpublishLoading" />
|
<Button label="确认下架" icon="pi pi-ban" severity="danger" @click="confirmUnpublish" :loading="unpublishLoading" />
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
|
<Dialog v-model:visible="reviewDialogVisible" :modal="true" :style="{ width: '520px' }">
|
||||||
|
<template #header>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<span class="font-medium">内容审核</span>
|
||||||
|
<span class="text-muted-color">共 {{ reviewTargetCount }} 条</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div class="flex flex-col gap-4">
|
||||||
|
<div>
|
||||||
|
<label class="block font-medium mb-2">审核动作</label>
|
||||||
|
<Select v-model="reviewAction" :options="reviewActionOptions" optionLabel="label" optionValue="value" class="w-full" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block font-medium mb-2">审核说明</label>
|
||||||
|
<InputText v-model="reviewReason" placeholder="驳回时建议填写原因" class="w-full" />
|
||||||
|
</div>
|
||||||
|
<div class="text-sm text-muted-color">审核后会同步通知作者。</div>
|
||||||
|
</div>
|
||||||
|
<template #footer>
|
||||||
|
<Button label="取消" icon="pi pi-times" text @click="reviewDialogVisible = false" :disabled="reviewSubmitting" />
|
||||||
|
<Button label="确认审核" icon="pi pi-check" severity="success" @click="confirmReview" :loading="reviewSubmitting" :disabled="reviewSubmitting || (reviewAction === 'reject' && !reviewReason.trim())" />
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user