评论问题
This commit is contained in:
parent
8f0a66338b
commit
01598aaac1
@ -30,6 +30,25 @@ export const userCommentClinicalArticleApi = {
|
|||||||
return postRequest('/userCommentClinicalArticle/update', param);
|
return postRequest('/userCommentClinicalArticle/update', param);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改评论状态 @author xing
|
||||||
|
*/
|
||||||
|
updateStatus: (commentId, status) => {
|
||||||
|
return postRequest('/userCommentClinicalArticle/updateStatus', {
|
||||||
|
commentId: commentId,
|
||||||
|
status: status
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改置顶状态 @author xing
|
||||||
|
*/
|
||||||
|
updateTopStatus: (commentId, isTop) => {
|
||||||
|
return postRequest('/userCommentClinicalArticle/updateTopStatus', {
|
||||||
|
commentId: commentId,
|
||||||
|
isTop: isTop
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除 @author xing
|
* 删除 @author xing
|
||||||
|
|||||||
@ -30,6 +30,25 @@ export const userCommentClinicalVideoApi = {
|
|||||||
return postRequest('/userCommentClinicalVideo/update', param);
|
return postRequest('/userCommentClinicalVideo/update', param);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改评论状态 @author xing
|
||||||
|
*/
|
||||||
|
updateStatus: (commentId, status) => {
|
||||||
|
return postRequest('/userCommentClinicalVideo/updateStatus', {
|
||||||
|
commentId: commentId,
|
||||||
|
status: status
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改置顶状态 @author xing
|
||||||
|
*/
|
||||||
|
updateTopStatus: (commentId, isTop) => {
|
||||||
|
return postRequest('/userCommentClinicalVideo/updateTopStatus', {
|
||||||
|
commentId: commentId,
|
||||||
|
isTop: isTop
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除 @author xing
|
* 删除 @author xing
|
||||||
|
|||||||
@ -30,6 +30,25 @@ export const userCommentExchangeApi = {
|
|||||||
return postRequest('/userCommentExchange/update', param);
|
return postRequest('/userCommentExchange/update', param);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改评论状态 @author xing
|
||||||
|
*/
|
||||||
|
updateStatus: (commentId, status) => {
|
||||||
|
return postRequest('/userCommentExchange/updateStatus', {
|
||||||
|
commentId: commentId,
|
||||||
|
status: status
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改置顶状态 @author xing
|
||||||
|
*/
|
||||||
|
updateTopStatus: (commentId, isTop) => {
|
||||||
|
return postRequest('/userCommentExchange/updateTopStatus', {
|
||||||
|
commentId: commentId,
|
||||||
|
isTop: isTop
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除 @author xing
|
* 删除 @author xing
|
||||||
|
|||||||
@ -38,8 +38,20 @@ export const SELECTED_ENUM = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const AUDIT_STATUS_ENUM = {
|
||||||
|
PENDING: {
|
||||||
|
value: 0,
|
||||||
|
desc: '待审核',
|
||||||
|
},
|
||||||
|
APPROVED: {
|
||||||
|
value: 1,
|
||||||
|
desc: '已审核',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
STATUS_ENUM,
|
STATUS_ENUM,
|
||||||
DELETE_STATUS_ENUM,
|
DELETE_STATUS_ENUM,
|
||||||
SELECTED_ENUM,
|
SELECTED_ENUM,
|
||||||
|
AUDIT_STATUS_ENUM,
|
||||||
};
|
};
|
||||||
@ -15,15 +15,31 @@
|
|||||||
:destroyOnClose="true"
|
:destroyOnClose="true"
|
||||||
>
|
>
|
||||||
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }" >
|
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }" >
|
||||||
<a-form-item label="主键id" name="commentId">
|
<a-form-item label="评论状态" name="status">
|
||||||
<a-input-number style="width: 100%" v-model:value="form.commentId" placeholder="主键id" />
|
<a-select style="width: 100%" v-model:value="form.status" placeholder="请选择评论状态">
|
||||||
|
<a-select-option :value="0">禁用</a-select-option>
|
||||||
|
<a-select-option :value="1">正常</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="评论状态(0:禁用 1:正常)" name="status">
|
<a-form-item label="是否置顶" name="isTop">
|
||||||
<a-input-number style="width: 100%" v-model:value="form.status" placeholder="评论状态(0:禁用 1:正常)" />
|
<a-select style="width: 100%" v-model:value="form.isTop" placeholder="请选择是否置顶">
|
||||||
|
<a-select-option :value="0">否</a-select-option>
|
||||||
|
<a-select-option :value="1">是</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="评论内容" name="content">
|
<a-form-item label="评论内容" name="content">
|
||||||
<a-input style="width: 100%" v-model:value="form.content" placeholder="评论内容" />
|
<a-input style="width: 100%" v-model:value="form.content" placeholder="评论内容" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
<a-form-item label="评论图片" name="commentImage">
|
||||||
|
<div v-if="form.commentImage && form.commentImage.trim() !== ''">
|
||||||
|
<div style="display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px;">
|
||||||
|
<div v-for="(img, index) in form.commentImage.split(',').filter(img => img.trim())" :key="index" style="position: relative;">
|
||||||
|
<img :src="img.trim()" style="width: 100px; height: 100px; object-fit: cover; border-radius: 4px;" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a-input style="width: 100%" v-model:value="form.commentImage" placeholder="评论图片,多个图片用逗号分隔" />
|
||||||
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@ -77,13 +93,17 @@
|
|||||||
|
|
||||||
const formDefault = {
|
const formDefault = {
|
||||||
commentId: undefined, //主键id
|
commentId: undefined, //主键id
|
||||||
status: undefined, //评论状态(0:禁用 1:正常)
|
status: 1, //评论状态(0:禁用 1:正常)
|
||||||
|
isTop: 0, //是否置顶(0:否 1:是)
|
||||||
content: undefined, //评论内容
|
content: undefined, //评论内容
|
||||||
|
commentImage: undefined, //评论图片
|
||||||
};
|
};
|
||||||
|
|
||||||
let form = reactive({ ...formDefault });
|
let form = reactive({ ...formDefault });
|
||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
|
status: [{ required: true, message: '请选择评论状态' }],
|
||||||
|
isTop: [{ required: true, message: '请选择是否置顶' }],
|
||||||
};
|
};
|
||||||
|
|
||||||
// 点击确定,验证表单
|
// 点击确定,验证表单
|
||||||
|
|||||||
@ -9,8 +9,20 @@
|
|||||||
<!---------- 查询表单form begin ----------->
|
<!---------- 查询表单form begin ----------->
|
||||||
<a-form class="smart-query-form">
|
<a-form class="smart-query-form">
|
||||||
<a-row class="smart-query-form-row">
|
<a-row class="smart-query-form-row">
|
||||||
<a-form-item label="内容" class="smart-query-form-item">
|
<a-form-item label="关键词" class="smart-query-form-item">
|
||||||
<a-input style="width: 200px" v-model:value="queryForm.keywords" placeholder="内容" />
|
<a-input style="width: 200px" v-model:value="queryForm.keywords" placeholder="评论内容、文章标题" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="是否置顶" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 120px" v-model:value="queryForm.isTop" placeholder="请选择" allowClear>
|
||||||
|
<a-select-option :value="0">否</a-select-option>
|
||||||
|
<a-select-option :value="1">是</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="是否敏感词" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 120px" v-model:value="queryForm.isSensitive" placeholder="请选择" allowClear>
|
||||||
|
<a-select-option :value="0">否</a-select-option>
|
||||||
|
<a-select-option :value="1">是</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item class="smart-query-form-item">
|
<a-form-item class="smart-query-form-item">
|
||||||
<a-button type="primary" @click="onSearch">
|
<a-button type="primary" @click="onSearch">
|
||||||
@ -34,12 +46,6 @@
|
|||||||
<!---------- 表格操作行 begin ----------->
|
<!---------- 表格操作行 begin ----------->
|
||||||
<a-row class="smart-table-btn-block">
|
<a-row class="smart-table-btn-block">
|
||||||
<div class="smart-table-operate-block">
|
<div class="smart-table-operate-block">
|
||||||
<a-button @click="showForm" type="primary" size="small">
|
|
||||||
<template #icon>
|
|
||||||
<PlusOutlined />
|
|
||||||
</template>
|
|
||||||
新建
|
|
||||||
</a-button>
|
|
||||||
<a-button @click="confirmBatchDelete" type="primary" danger size="small" :disabled="selectedRowKeyList.length == 0">
|
<a-button @click="confirmBatchDelete" type="primary" danger size="small" :disabled="selectedRowKeyList.length == 0">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<DeleteOutlined />
|
<DeleteOutlined />
|
||||||
@ -48,29 +54,31 @@
|
|||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="smart-table-setting-block">
|
<div class="smart-table-setting-block">
|
||||||
<TableOperator v-model="columns" :tableId="null" :refresh="queryData" />
|
<!-- 移除TableOperator组件 -->
|
||||||
</div>
|
</div>
|
||||||
</a-row>
|
</a-row>
|
||||||
<!---------- 表格操作行 end ----------->
|
<!---------- 表格操作行 end ----------->
|
||||||
|
|
||||||
<!---------- 表格 begin ----------->
|
<!---------- 表格 begin ----------->
|
||||||
<a-table
|
<a-table
|
||||||
size="small"
|
|
||||||
:scroll="{ y: 800 }"
|
|
||||||
:dataSource="tableData"
|
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
rowKey="commentId"
|
:data-source="tableData"
|
||||||
bordered
|
|
||||||
:loading="tableLoading"
|
:loading="tableLoading"
|
||||||
:pagination="false"
|
:pagination="false"
|
||||||
|
:scroll="{ x: 1500 }"
|
||||||
|
size="small"
|
||||||
|
bordered
|
||||||
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
|
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
|
||||||
>
|
>
|
||||||
<template #bodyCell="{ text, record, column }">
|
<template #bodyCell="{ text, record, column }">
|
||||||
|
|
||||||
|
|
||||||
<template v-if="column.dataIndex === 'action'">
|
<template v-if="column.dataIndex === 'action'">
|
||||||
<div class="smart-table-operate">
|
<div class="smart-table-operate">
|
||||||
<a-button @click="showForm(record)" type="link">编辑</a-button>
|
<a-button @click="updateStatus(record.commentId, record.status === 1 ? 0 : 1)" type="link">
|
||||||
|
{{ record.status === 1 ? '禁用' : '启用' }}
|
||||||
|
</a-button>
|
||||||
|
<a-button @click="updateTopStatus(record.commentId, record.isTop === 1 ? 0 : 1)" type="link">
|
||||||
|
{{ record.isTop === 1 ? '取消置顶' : '置顶' }}
|
||||||
|
</a-button>
|
||||||
<a-button @click="onDelete(record)" danger type="link">删除</a-button>
|
<a-button @click="onDelete(record)" danger type="link">删除</a-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -94,110 +102,77 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UserCommentClinicalArticleForm ref="formRef" @reloadList="queryData"/>
|
<!-- 图片预览Modal -->
|
||||||
|
<a-modal
|
||||||
|
v-model:open="imageModalVisible"
|
||||||
|
:footer="null"
|
||||||
|
:width="800"
|
||||||
|
:title="'图片预览'"
|
||||||
|
centered
|
||||||
|
>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<img
|
||||||
|
:src="currentImageUrl"
|
||||||
|
style="max-width: 100%; max-height: 600px; object-fit: contain;"
|
||||||
|
alt="图片预览"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</a-modal>
|
||||||
</a-card>
|
</a-card>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref, onMounted } from 'vue';
|
import { reactive, ref, onMounted, h } from 'vue';
|
||||||
import { message, Modal } from 'ant-design-vue';
|
import { message, Modal } from 'ant-design-vue';
|
||||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||||
import { userCommentClinicalArticleApi } from '/@/api/business/user-comment-clinical-article/user-comment-clinical-article-api';
|
import { userCommentClinicalArticleApi } from '/@/api/business/user-comment-clinical-article/user-comment-clinical-article-api';
|
||||||
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||||
import { smartSentry } from '/@/lib/smart-sentry';
|
import { smartSentry } from '/@/lib/smart-sentry';
|
||||||
import TableOperator from '/@/components/support/table-operator/index.vue';
|
|
||||||
import UserCommentClinicalArticleForm from './user-comment-clinical-article-form.vue';
|
|
||||||
|
|
||||||
// ---------------------------- 表格列 ----------------------------
|
// ---------------------------- 表格列 ----------------------------
|
||||||
|
|
||||||
const columns = ref([
|
const columns = ref([
|
||||||
{
|
{ title: '用户名称', dataIndex: 'userName', ellipsis: true, width: 120 },
|
||||||
title: '主键id',
|
{ title: '文章标题', dataIndex: 'articleTitle', ellipsis: false, width: 200, customRender: ({ text }) => h('div', { style: { 'white-space': 'pre-wrap', 'word-break': 'break-all', 'line-height': '1.4' } }, text || '-') },
|
||||||
dataIndex: 'commentId',
|
{ title: '评论状态', dataIndex: 'status', ellipsis: true, width: 80, customRender: ({ text }) => h('a-tag', {
|
||||||
ellipsis: true,
|
color: text === 1 ? 'success' : 'error'
|
||||||
},
|
}, text === 1 ? '正常' : '禁用') },
|
||||||
{
|
{ title: '是否敏感词', dataIndex: 'isSensitive', ellipsis: true, width: 80, customRender: ({ text }) => h('a-tag', {
|
||||||
title: '用户id',
|
color: text === 1 ? 'error' : 'success'
|
||||||
dataIndex: 'userId',
|
}, text === 1 ? '是' : '否') },
|
||||||
ellipsis: true,
|
{ title: '是否置顶', dataIndex: 'isTop', ellipsis: true, width: 80, customRender: ({ text }) => h('a-tag', {
|
||||||
},
|
color: text === 1 ? 'processing' : 'default'
|
||||||
{
|
}, text === 1 ? '是' : '否') },
|
||||||
title: '临床文章id',
|
{ title: '点赞数量', dataIndex: 'likeNum', ellipsis: true, width: 80 },
|
||||||
dataIndex: 'articleId',
|
{ title: '是否作者评论', dataIndex: 'isAuthor', ellipsis: true, width: 100, customRender: ({ text }) => h('a-tag', {
|
||||||
ellipsis: true,
|
color: text === 1 ? 'magenta' : 'default'
|
||||||
},
|
}, text === 1 ? '是' : '否') },
|
||||||
{
|
{ title: '评论内容', dataIndex: 'content', ellipsis: false, width: 200, customRender: ({ text }) => h('div', { style: { 'white-space': 'pre-wrap', 'word-break': 'break-all', 'line-height': '1.4' } }, text || '-') },
|
||||||
title: '父级id,一级评论为null',
|
{ title: '评论内容(原版)', dataIndex: 'contentWord', ellipsis: false, width: 200, customRender: ({ text }) => h('div', { style: { 'white-space': 'pre-wrap', 'word-break': 'break-all', 'line-height': '1.4' } }, text || '-') },
|
||||||
dataIndex: 'parentId',
|
{ title: '评论图片', dataIndex: 'commentImage', ellipsis: false, width: 150, customRender: ({ text }) => {
|
||||||
ellipsis: true,
|
if (!text) return h('span', '-');
|
||||||
},
|
const images = text.split(',').filter(img => img.trim());
|
||||||
{
|
if (images.length === 0) return h('span', '-');
|
||||||
title: '根评论id,一级评论时为null。其余为一级评论id',
|
|
||||||
dataIndex: 'rootId',
|
return h('div', { style: { display: 'flex', gap: '5px', flexWrap: 'wrap' } },
|
||||||
ellipsis: true,
|
images.map((img, index) =>
|
||||||
},
|
h('img', {
|
||||||
{
|
src: img.trim(),
|
||||||
title: '评论状态(0:禁用 1:正常)',
|
style: { width: '50px', height: '50px', objectFit: 'cover', cursor: 'pointer' },
|
||||||
dataIndex: 'status',
|
onClick: () => showImageModal(img.trim())
|
||||||
ellipsis: true,
|
})
|
||||||
},
|
)
|
||||||
{
|
);
|
||||||
title: '是否存在敏感词(0:否 1:是)',
|
}},
|
||||||
dataIndex: 'isSensitive',
|
{ title: '创建时间', dataIndex: 'createdAt', ellipsis: true, width: 120 },
|
||||||
ellipsis: true,
|
{ title: '操作', dataIndex: 'action', fixed: 'right', width: 200 },
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '是否置顶(0:否 1:是)',
|
|
||||||
dataIndex: 'isTop',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '点赞数量',
|
|
||||||
dataIndex: 'likeNum',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '是否作者评论(0:否 1:是)',
|
|
||||||
dataIndex: 'isAuthor',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '评论内容',
|
|
||||||
dataIndex: 'content',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '评论内容(原版)',
|
|
||||||
dataIndex: 'contentWord',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '评论图片',
|
|
||||||
dataIndex: 'commentImage',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '创建时间',
|
|
||||||
dataIndex: 'createdAt',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '修改时间',
|
|
||||||
dataIndex: 'updatedAt',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '操作',
|
|
||||||
dataIndex: 'action',
|
|
||||||
fixed: 'right',
|
|
||||||
width: 90,
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// ---------------------------- 查询数据表单和方法 ----------------------------
|
// ---------------------------- 查询数据表单和方法 ----------------------------
|
||||||
|
|
||||||
const queryFormState = {
|
const queryFormState = {
|
||||||
keywords: undefined, //内容
|
keywords: undefined, //关键词
|
||||||
|
isTop: undefined, //是否置顶
|
||||||
|
isSensitive: undefined, //是否存在敏感词
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
};
|
};
|
||||||
@ -209,6 +184,8 @@
|
|||||||
const tableData = ref([]);
|
const tableData = ref([]);
|
||||||
// 总数
|
// 总数
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
|
// 选中的行
|
||||||
|
const selectedRowKeyList = ref([]);
|
||||||
|
|
||||||
// 重置查询条件
|
// 重置查询条件
|
||||||
function resetQuery() {
|
function resetQuery() {
|
||||||
@ -238,41 +215,30 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onMounted(queryData);
|
onMounted(queryData);
|
||||||
|
|
||||||
// ---------------------------- 添加/修改 ----------------------------
|
// ---------------------------- 添加/修改 ----------------------------
|
||||||
const formRef = ref();
|
// 修改状态
|
||||||
|
async function updateStatus(commentId, status) {
|
||||||
|
const statusText = status === 1 ? '启用' : '禁用';
|
||||||
|
|
||||||
function showForm(data) {
|
|
||||||
formRef.value.show(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------- 单个删除 ----------------------------
|
|
||||||
//确认删除
|
|
||||||
function onDelete(data){
|
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '确定要删除选吗?',
|
content: `确定要${statusText}这条评论吗?`,
|
||||||
okText: '删除',
|
okText: '确定',
|
||||||
okType: 'danger',
|
|
||||||
onOk() {
|
onOk() {
|
||||||
requestDelete(data);
|
requestUpdateStatus(commentId, status);
|
||||||
},
|
},
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onCancel() {},
|
onCancel() {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//请求删除
|
async function requestUpdateStatus(commentId, status) {
|
||||||
async function requestDelete(data){
|
|
||||||
SmartLoading.show();
|
SmartLoading.show();
|
||||||
try {
|
try {
|
||||||
let deleteForm = {
|
await userCommentClinicalArticleApi.updateStatus(commentId, status);
|
||||||
goodsIdList: selectedRowKeyList.value,
|
message.success('操作成功');
|
||||||
};
|
|
||||||
await userCommentClinicalArticleApi.delete(data.commentId);
|
|
||||||
message.success('删除成功');
|
|
||||||
queryData();
|
queryData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
smartSentry.captureError(e);
|
smartSentry.captureError(e);
|
||||||
@ -281,11 +247,87 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------- 修改置顶状态 ----------------------------
|
||||||
|
async function updateTopStatus(commentId, isTop) {
|
||||||
|
const topText = isTop === 1 ? '取消置顶' : '置顶';
|
||||||
|
|
||||||
|
Modal.confirm({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要${topText}这条评论吗?`,
|
||||||
|
okText: '确定',
|
||||||
|
onOk() {
|
||||||
|
requestUpdateTopStatus(commentId, isTop);
|
||||||
|
},
|
||||||
|
cancelText: '取消',
|
||||||
|
onCancel() {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function requestUpdateTopStatus(commentId, isTop) {
|
||||||
|
SmartLoading.show();
|
||||||
|
try {
|
||||||
|
await userCommentClinicalArticleApi.updateTopStatus(commentId, isTop);
|
||||||
|
message.success('操作成功');
|
||||||
|
queryData();
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
} finally {
|
||||||
|
SmartLoading.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------- 单个删除 ----------------------------
|
||||||
|
// 批量删除
|
||||||
|
function batchDelete() {
|
||||||
|
if (selectedRowKeyList.value.length === 0) {
|
||||||
|
message.warning('请选择要删除的评论');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Modal.confirm({
|
||||||
|
title: '批量删除',
|
||||||
|
content: `确定要删除选中的 ${selectedRowKeyList.value.length} 条评论吗?`,
|
||||||
|
okText: '确定',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk() {
|
||||||
|
// 这里可以调用批量删除API
|
||||||
|
message.success('批量删除功能待实现');
|
||||||
|
selectedRowKeyList.value = [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除单条评论
|
||||||
|
function onDelete(record) {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '删除评论',
|
||||||
|
content: `确定要删除这条评论吗?`,
|
||||||
|
okText: '确定',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk() {
|
||||||
|
requestDelete(record.commentId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 请求删除评论
|
||||||
|
async function requestDelete(commentId) {
|
||||||
|
try {
|
||||||
|
SmartLoading.show();
|
||||||
|
await userCommentClinicalArticleApi.delete(commentId);
|
||||||
|
message.success('删除成功');
|
||||||
|
queryData();
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
message.error('删除失败');
|
||||||
|
} finally {
|
||||||
|
SmartLoading.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------- 批量删除 ----------------------------
|
// ---------------------------- 批量删除 ----------------------------
|
||||||
|
|
||||||
// 选择表格行
|
// 选择表格行
|
||||||
const selectedRowKeyList = ref([]);
|
|
||||||
|
|
||||||
function onSelectChange(selectedRowKeys) {
|
function onSelectChange(selectedRowKeys) {
|
||||||
selectedRowKeyList.value = selectedRowKeys;
|
selectedRowKeyList.value = selectedRowKeys;
|
||||||
}
|
}
|
||||||
@ -318,4 +360,13 @@
|
|||||||
SmartLoading.hide();
|
SmartLoading.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------- 图片预览 ----------------------------
|
||||||
|
const imageModalVisible = ref(false);
|
||||||
|
const currentImageUrl = ref('');
|
||||||
|
|
||||||
|
function showImageModal(url) {
|
||||||
|
currentImageUrl.value = url;
|
||||||
|
imageModalVisible.value = true;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -15,15 +15,31 @@
|
|||||||
:destroyOnClose="true"
|
:destroyOnClose="true"
|
||||||
>
|
>
|
||||||
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }" >
|
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }" >
|
||||||
<a-form-item label="主键id" name="commentId">
|
<a-form-item label="评论状态" name="status">
|
||||||
<a-input-number style="width: 100%" v-model:value="form.commentId" placeholder="主键id" />
|
<a-select style="width: 100%" v-model:value="form.status" placeholder="请选择评论状态">
|
||||||
|
<a-select-option :value="0">禁用</a-select-option>
|
||||||
|
<a-select-option :value="1">正常</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="评论状态(0:禁用 1:正常)" name="status">
|
<a-form-item label="是否置顶" name="isTop">
|
||||||
<a-input-number style="width: 100%" v-model:value="form.status" placeholder="评论状态(0:禁用 1:正常)" />
|
<a-select style="width: 100%" v-model:value="form.isTop" placeholder="请选择是否置顶">
|
||||||
|
<a-select-option :value="0">否</a-select-option>
|
||||||
|
<a-select-option :value="1">是</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="评论内容" name="content">
|
<a-form-item label="评论内容" name="content">
|
||||||
<a-input style="width: 100%" v-model:value="form.content" placeholder="评论内容" />
|
<a-input style="width: 100%" v-model:value="form.content" placeholder="评论内容" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
<a-form-item label="评论图片" name="commentImage">
|
||||||
|
<div v-if="form.commentImage && form.commentImage.trim() !== ''">
|
||||||
|
<div style="display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px;">
|
||||||
|
<div v-for="(img, index) in form.commentImage.split(',').filter(img => img.trim())" :key="index" style="position: relative;">
|
||||||
|
<img :src="img.trim()" style="width: 100px; height: 100px; object-fit: cover; border-radius: 4px;" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a-input style="width: 100%" v-model:value="form.commentImage" placeholder="评论图片,多个图片用逗号分隔" />
|
||||||
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@ -77,13 +93,17 @@
|
|||||||
|
|
||||||
const formDefault = {
|
const formDefault = {
|
||||||
commentId: undefined, //主键id
|
commentId: undefined, //主键id
|
||||||
status: undefined, //评论状态(0:禁用 1:正常)
|
status: 1, //评论状态(0:禁用 1:正常)
|
||||||
|
isTop: 0, //是否置顶(0:否 1:是)
|
||||||
content: undefined, //评论内容
|
content: undefined, //评论内容
|
||||||
|
commentImage: undefined, //评论图片
|
||||||
};
|
};
|
||||||
|
|
||||||
let form = reactive({ ...formDefault });
|
let form = reactive({ ...formDefault });
|
||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
|
status: [{ required: true, message: '请选择评论状态' }],
|
||||||
|
isTop: [{ required: true, message: '请选择是否置顶' }],
|
||||||
};
|
};
|
||||||
|
|
||||||
// 点击确定,验证表单
|
// 点击确定,验证表单
|
||||||
|
|||||||
@ -9,8 +9,20 @@
|
|||||||
<!---------- 查询表单form begin ----------->
|
<!---------- 查询表单form begin ----------->
|
||||||
<a-form class="smart-query-form">
|
<a-form class="smart-query-form">
|
||||||
<a-row class="smart-query-form-row">
|
<a-row class="smart-query-form-row">
|
||||||
<a-form-item label="内容" class="smart-query-form-item">
|
<a-form-item label="关键词" class="smart-query-form-item">
|
||||||
<a-input style="width: 200px" v-model:value="queryForm.keywords" placeholder="内容" />
|
<a-input style="width: 200px" v-model:value="queryForm.keywords" placeholder="评论内容、视频标题" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="是否置顶" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 120px" v-model:value="queryForm.isTop" placeholder="请选择" allowClear>
|
||||||
|
<a-select-option :value="0">否</a-select-option>
|
||||||
|
<a-select-option :value="1">是</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="是否敏感词" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 120px" v-model:value="queryForm.isSensitive" placeholder="请选择" allowClear>
|
||||||
|
<a-select-option :value="0">否</a-select-option>
|
||||||
|
<a-select-option :value="1">是</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item class="smart-query-form-item">
|
<a-form-item class="smart-query-form-item">
|
||||||
<a-button type="primary" @click="onSearch">
|
<a-button type="primary" @click="onSearch">
|
||||||
@ -34,12 +46,6 @@
|
|||||||
<!---------- 表格操作行 begin ----------->
|
<!---------- 表格操作行 begin ----------->
|
||||||
<a-row class="smart-table-btn-block">
|
<a-row class="smart-table-btn-block">
|
||||||
<div class="smart-table-operate-block">
|
<div class="smart-table-operate-block">
|
||||||
<a-button @click="showForm" type="primary" size="small">
|
|
||||||
<template #icon>
|
|
||||||
<PlusOutlined />
|
|
||||||
</template>
|
|
||||||
新建
|
|
||||||
</a-button>
|
|
||||||
<a-button @click="confirmBatchDelete" type="primary" danger size="small" :disabled="selectedRowKeyList.length == 0">
|
<a-button @click="confirmBatchDelete" type="primary" danger size="small" :disabled="selectedRowKeyList.length == 0">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<DeleteOutlined />
|
<DeleteOutlined />
|
||||||
@ -48,29 +54,31 @@
|
|||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="smart-table-setting-block">
|
<div class="smart-table-setting-block">
|
||||||
<TableOperator v-model="columns" :tableId="null" :refresh="queryData" />
|
<!-- 移除TableOperator组件 -->
|
||||||
</div>
|
</div>
|
||||||
</a-row>
|
</a-row>
|
||||||
<!---------- 表格操作行 end ----------->
|
<!---------- 表格操作行 end ----------->
|
||||||
|
|
||||||
<!---------- 表格 begin ----------->
|
<!---------- 表格 begin ----------->
|
||||||
<a-table
|
<a-table
|
||||||
size="small"
|
|
||||||
:scroll="{ y: 800 }"
|
|
||||||
:dataSource="tableData"
|
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
rowKey="commentId"
|
:data-source="tableData"
|
||||||
bordered
|
|
||||||
:loading="tableLoading"
|
:loading="tableLoading"
|
||||||
:pagination="false"
|
:pagination="false"
|
||||||
|
:scroll="{ x: 1500 }"
|
||||||
|
size="small"
|
||||||
|
bordered
|
||||||
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
|
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
|
||||||
>
|
>
|
||||||
<template #bodyCell="{ text, record, column }">
|
<template #bodyCell="{ text, record, column }">
|
||||||
|
|
||||||
|
|
||||||
<template v-if="column.dataIndex === 'action'">
|
<template v-if="column.dataIndex === 'action'">
|
||||||
<div class="smart-table-operate">
|
<div class="smart-table-operate">
|
||||||
<a-button @click="showForm(record)" type="link">编辑</a-button>
|
<a-button @click="updateStatus(record.commentId, record.status === 1 ? 0 : 1)" type="link">
|
||||||
|
{{ record.status === 1 ? '禁用' : '启用' }}
|
||||||
|
</a-button>
|
||||||
|
<a-button @click="updateTopStatus(record.commentId, record.isTop === 1 ? 0 : 1)" type="link">
|
||||||
|
{{ record.isTop === 1 ? '取消置顶' : '置顶' }}
|
||||||
|
</a-button>
|
||||||
<a-button @click="onDelete(record)" danger type="link">删除</a-button>
|
<a-button @click="onDelete(record)" danger type="link">删除</a-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -94,110 +102,77 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UserCommentClinicalVideoForm ref="formRef" @reloadList="queryData"/>
|
<!-- 图片预览Modal -->
|
||||||
|
<a-modal
|
||||||
|
v-model:open="imageModalVisible"
|
||||||
|
:footer="null"
|
||||||
|
:width="800"
|
||||||
|
:title="'图片预览'"
|
||||||
|
centered
|
||||||
|
>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<img
|
||||||
|
:src="currentImageUrl"
|
||||||
|
style="max-width: 100%; max-height: 600px; object-fit: contain;"
|
||||||
|
alt="图片预览"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</a-modal>
|
||||||
</a-card>
|
</a-card>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref, onMounted } from 'vue';
|
import { reactive, ref, onMounted, h } from 'vue';
|
||||||
import { message, Modal } from 'ant-design-vue';
|
import { message, Modal } from 'ant-design-vue';
|
||||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||||
import { userCommentClinicalVideoApi } from '/@/api/business/user-comment-clinical-video/user-comment-clinical-video-api';
|
import { userCommentClinicalVideoApi } from '/@/api/business/user-comment-clinical-video/user-comment-clinical-video-api';
|
||||||
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||||
import { smartSentry } from '/@/lib/smart-sentry';
|
import { smartSentry } from '/@/lib/smart-sentry';
|
||||||
import TableOperator from '/@/components/support/table-operator/index.vue';
|
|
||||||
import UserCommentClinicalVideoForm from './user-comment-clinical-video-form.vue';
|
|
||||||
|
|
||||||
// ---------------------------- 表格列 ----------------------------
|
// ---------------------------- 表格列 ----------------------------
|
||||||
|
|
||||||
const columns = ref([
|
const columns = ref([
|
||||||
{
|
{ title: '用户名称', dataIndex: 'userName', ellipsis: true, width: 120 },
|
||||||
title: '主键id',
|
{ title: '视频标题', dataIndex: 'videoTitle', ellipsis: false, width: 200, customRender: ({ text }) => h('div', { style: { 'white-space': 'pre-wrap', 'word-break': 'break-all', 'line-height': '1.4' } }, text || '-') },
|
||||||
dataIndex: 'commentId',
|
{ title: '评论状态', dataIndex: 'status', ellipsis: true, width: 80, customRender: ({ text }) => h('a-tag', {
|
||||||
ellipsis: true,
|
color: text === 1 ? 'success' : 'error'
|
||||||
},
|
}, text === 1 ? '正常' : '禁用') },
|
||||||
{
|
{ title: '是否敏感词', dataIndex: 'isSensitive', ellipsis: true, width: 80, customRender: ({ text }) => h('a-tag', {
|
||||||
title: '用户id',
|
color: text === 1 ? 'error' : 'success'
|
||||||
dataIndex: 'userId',
|
}, text === 1 ? '是' : '否') },
|
||||||
ellipsis: true,
|
{ title: '是否置顶', dataIndex: 'isTop', ellipsis: true, width: 80, customRender: ({ text }) => h('a-tag', {
|
||||||
},
|
color: text === 1 ? 'processing' : 'default'
|
||||||
{
|
}, text === 1 ? '是' : '否') },
|
||||||
title: '临床视频id',
|
{ title: '点赞数量', dataIndex: 'likeNum', ellipsis: true, width: 80 },
|
||||||
dataIndex: 'videoId',
|
{ title: '是否作者评论', dataIndex: 'isAuthor', ellipsis: true, width: 100, customRender: ({ text }) => h('a-tag', {
|
||||||
ellipsis: true,
|
color: text === 1 ? 'magenta' : 'default'
|
||||||
},
|
}, text === 1 ? '是' : '否') },
|
||||||
{
|
{ title: '评论内容', dataIndex: 'content', ellipsis: false, width: 200, customRender: ({ text }) => h('div', { style: { 'white-space': 'pre-wrap', 'word-break': 'break-all', 'line-height': '1.4' } }, text || '-') },
|
||||||
title: '父级id,一级评论为null',
|
{ title: '评论内容(原版)', dataIndex: 'contentWord', ellipsis: false, width: 200, customRender: ({ text }) => h('div', { style: { 'white-space': 'pre-wrap', 'word-break': 'break-all', 'line-height': '1.4' } }, text || '-') },
|
||||||
dataIndex: 'parentId',
|
{ title: '评论图片', dataIndex: 'commentImage', ellipsis: false, width: 150, customRender: ({ text }) => {
|
||||||
ellipsis: true,
|
if (!text) return h('span', '-');
|
||||||
},
|
const images = text.split(',').filter(img => img.trim());
|
||||||
{
|
if (images.length === 0) return h('span', '-');
|
||||||
title: '根评论id,一级评论时为null。其余为一级评论id',
|
|
||||||
dataIndex: 'rootId',
|
return h('div', { style: { display: 'flex', gap: '5px', flexWrap: 'wrap' } },
|
||||||
ellipsis: true,
|
images.map((img, index) =>
|
||||||
},
|
h('img', {
|
||||||
{
|
src: img.trim(),
|
||||||
title: '评论状态(0:禁用 1:正常)',
|
style: { width: '50px', height: '50px', objectFit: 'cover', cursor: 'pointer' },
|
||||||
dataIndex: 'status',
|
onClick: () => showImageModal(img.trim())
|
||||||
ellipsis: true,
|
})
|
||||||
},
|
)
|
||||||
{
|
);
|
||||||
title: '是否存在敏感词(0:否 1:是)',
|
}},
|
||||||
dataIndex: 'isSensitive',
|
{ title: '创建时间', dataIndex: 'createdAt', ellipsis: true, width: 120 },
|
||||||
ellipsis: true,
|
{ title: '操作', dataIndex: 'action', fixed: 'right', width: 200 },
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '是否置顶(0:否 1:是)',
|
|
||||||
dataIndex: 'isTop',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '点赞数量',
|
|
||||||
dataIndex: 'likeNum',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '是否作者评论(0:否 1:是)',
|
|
||||||
dataIndex: 'isAuthor',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '评论内容',
|
|
||||||
dataIndex: 'content',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '评论内容(原版)',
|
|
||||||
dataIndex: 'contentWord',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '评论图片',
|
|
||||||
dataIndex: 'commentImage',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '创建时间',
|
|
||||||
dataIndex: 'createdAt',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '修改时间',
|
|
||||||
dataIndex: 'updatedAt',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '操作',
|
|
||||||
dataIndex: 'action',
|
|
||||||
fixed: 'right',
|
|
||||||
width: 90,
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// ---------------------------- 查询数据表单和方法 ----------------------------
|
// ---------------------------- 查询数据表单和方法 ----------------------------
|
||||||
|
|
||||||
const queryFormState = {
|
const queryFormState = {
|
||||||
keywords: undefined, //内容
|
keywords: undefined, //关键词
|
||||||
|
isTop: undefined, //是否置顶
|
||||||
|
isSensitive: undefined, //是否存在敏感词
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
};
|
};
|
||||||
@ -209,6 +184,8 @@
|
|||||||
const tableData = ref([]);
|
const tableData = ref([]);
|
||||||
// 总数
|
// 总数
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
|
// 选中的行
|
||||||
|
const selectedRowKeyList = ref([]);
|
||||||
|
|
||||||
// 重置查询条件
|
// 重置查询条件
|
||||||
function resetQuery() {
|
function resetQuery() {
|
||||||
@ -238,41 +215,59 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onMounted(queryData);
|
onMounted(queryData);
|
||||||
|
|
||||||
// ---------------------------- 添加/修改 ----------------------------
|
// ---------------------------- 添加/修改 ----------------------------
|
||||||
const formRef = ref();
|
// 修改状态
|
||||||
|
async function updateStatus(commentId, status) {
|
||||||
|
const statusText = status === 1 ? '启用' : '禁用';
|
||||||
|
|
||||||
function showForm(data) {
|
|
||||||
formRef.value.show(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------- 单个删除 ----------------------------
|
|
||||||
//确认删除
|
|
||||||
function onDelete(data){
|
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '确定要删除选吗?',
|
content: `确定要${statusText}这条评论吗?`,
|
||||||
okText: '删除',
|
okText: '确定',
|
||||||
okType: 'danger',
|
|
||||||
onOk() {
|
onOk() {
|
||||||
requestDelete(data);
|
requestUpdateStatus(commentId, status);
|
||||||
},
|
},
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onCancel() {},
|
onCancel() {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//请求删除
|
async function requestUpdateStatus(commentId, status) {
|
||||||
async function requestDelete(data){
|
|
||||||
SmartLoading.show();
|
SmartLoading.show();
|
||||||
try {
|
try {
|
||||||
let deleteForm = {
|
await userCommentClinicalVideoApi.updateStatus(commentId, status);
|
||||||
goodsIdList: selectedRowKeyList.value,
|
message.success('操作成功');
|
||||||
};
|
queryData();
|
||||||
await userCommentClinicalVideoApi.delete(data.commentId);
|
} catch (e) {
|
||||||
message.success('删除成功');
|
smartSentry.captureError(e);
|
||||||
|
} finally {
|
||||||
|
SmartLoading.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------- 修改置顶状态 ----------------------------
|
||||||
|
async function updateTopStatus(commentId, isTop) {
|
||||||
|
const topText = isTop === 1 ? '取消置顶' : '置顶';
|
||||||
|
|
||||||
|
Modal.confirm({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要${topText}这条评论吗?`,
|
||||||
|
okText: '确定',
|
||||||
|
onOk() {
|
||||||
|
requestUpdateTopStatus(commentId, isTop);
|
||||||
|
},
|
||||||
|
cancelText: '取消',
|
||||||
|
onCancel() {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function requestUpdateTopStatus(commentId, isTop) {
|
||||||
|
SmartLoading.show();
|
||||||
|
try {
|
||||||
|
await userCommentClinicalVideoApi.updateTopStatus(commentId, isTop);
|
||||||
|
message.success('操作成功');
|
||||||
queryData();
|
queryData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
smartSentry.captureError(e);
|
smartSentry.captureError(e);
|
||||||
@ -284,8 +279,6 @@
|
|||||||
// ---------------------------- 批量删除 ----------------------------
|
// ---------------------------- 批量删除 ----------------------------
|
||||||
|
|
||||||
// 选择表格行
|
// 选择表格行
|
||||||
const selectedRowKeyList = ref([]);
|
|
||||||
|
|
||||||
function onSelectChange(selectedRowKeys) {
|
function onSelectChange(selectedRowKeys) {
|
||||||
selectedRowKeyList.value = selectedRowKeys;
|
selectedRowKeyList.value = selectedRowKeys;
|
||||||
}
|
}
|
||||||
@ -318,4 +311,61 @@
|
|||||||
SmartLoading.hide();
|
SmartLoading.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 批量删除
|
||||||
|
function batchDelete() {
|
||||||
|
if (selectedRowKeyList.value.length === 0) {
|
||||||
|
message.warning('请选择要删除的评论');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Modal.confirm({
|
||||||
|
title: '批量删除',
|
||||||
|
content: `确定要删除选中的 ${selectedRowKeyList.value.length} 条评论吗?`,
|
||||||
|
okText: '确定',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk() {
|
||||||
|
// 这里可以调用批量删除API
|
||||||
|
message.success('批量删除功能待实现');
|
||||||
|
selectedRowKeyList.value = [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除单条评论
|
||||||
|
function onDelete(record) {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '删除评论',
|
||||||
|
content: `确定要删除这条评论吗?`,
|
||||||
|
okText: '确定',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk() {
|
||||||
|
requestDelete(record.commentId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 请求删除评论
|
||||||
|
async function requestDelete(commentId) {
|
||||||
|
try {
|
||||||
|
SmartLoading.show();
|
||||||
|
await userCommentClinicalVideoApi.delete(commentId);
|
||||||
|
message.success('删除成功');
|
||||||
|
queryData();
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
message.error('删除失败');
|
||||||
|
} finally {
|
||||||
|
SmartLoading.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------- 图片预览 ----------------------------
|
||||||
|
const imageModalVisible = ref(false);
|
||||||
|
const currentImageUrl = ref('');
|
||||||
|
|
||||||
|
function showImageModal(imageUrl) {
|
||||||
|
currentImageUrl.value = imageUrl;
|
||||||
|
imageModalVisible.value = true;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -15,15 +15,31 @@
|
|||||||
:destroyOnClose="true"
|
:destroyOnClose="true"
|
||||||
>
|
>
|
||||||
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }" >
|
<a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }" >
|
||||||
<a-form-item label="主键id" name="commentId">
|
<a-form-item label="评论状态" name="status">
|
||||||
<a-input-number style="width: 100%" v-model:value="form.commentId" placeholder="主键id" />
|
<a-select style="width: 100%" v-model:value="form.status" placeholder="请选择评论状态">
|
||||||
|
<a-select-option :value="0">禁用</a-select-option>
|
||||||
|
<a-select-option :value="1">正常</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="评论状态(0:禁用 1:正常)" name="status">
|
<a-form-item label="是否置顶" name="isTop">
|
||||||
<a-input-number style="width: 100%" v-model:value="form.status" placeholder="评论状态(0:禁用 1:正常)" />
|
<a-select style="width: 100%" v-model:value="form.isTop" placeholder="请选择是否置顶">
|
||||||
|
<a-select-option :value="0">否</a-select-option>
|
||||||
|
<a-select-option :value="1">是</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item label="评论内容" name="content">
|
<a-form-item label="评论内容" name="content">
|
||||||
<a-input style="width: 100%" v-model:value="form.content" placeholder="评论内容" />
|
<a-input style="width: 100%" v-model:value="form.content" placeholder="评论内容" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
<a-form-item label="评论图片" name="commentImage">
|
||||||
|
<div v-if="form.commentImage && form.commentImage.trim() !== ''">
|
||||||
|
<div style="display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px;">
|
||||||
|
<div v-for="(img, index) in form.commentImage.split(',').filter(img => img.trim())" :key="index" style="position: relative;">
|
||||||
|
<img :src="img.trim()" style="width: 100px; height: 100px; object-fit: cover; border-radius: 4px;" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a-input style="width: 100%" v-model:value="form.commentImage" placeholder="评论图片,多个图片用逗号分隔" />
|
||||||
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@ -77,13 +93,17 @@
|
|||||||
|
|
||||||
const formDefault = {
|
const formDefault = {
|
||||||
commentId: undefined, //主键id
|
commentId: undefined, //主键id
|
||||||
status: undefined, //评论状态(0:禁用 1:正常)
|
status: 1, //评论状态(0:禁用 1:正常)
|
||||||
|
isTop: 0, //是否置顶(0:否 1:是)
|
||||||
content: undefined, //评论内容
|
content: undefined, //评论内容
|
||||||
|
commentImage: undefined, //评论图片
|
||||||
};
|
};
|
||||||
|
|
||||||
let form = reactive({ ...formDefault });
|
let form = reactive({ ...formDefault });
|
||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
|
status: [{ required: true, message: '请选择评论状态' }],
|
||||||
|
isTop: [{ required: true, message: '请选择是否置顶' }],
|
||||||
};
|
};
|
||||||
|
|
||||||
// 点击确定,验证表单
|
// 点击确定,验证表单
|
||||||
|
|||||||
@ -9,8 +9,20 @@
|
|||||||
<!---------- 查询表单form begin ----------->
|
<!---------- 查询表单form begin ----------->
|
||||||
<a-form class="smart-query-form">
|
<a-form class="smart-query-form">
|
||||||
<a-row class="smart-query-form-row">
|
<a-row class="smart-query-form-row">
|
||||||
<a-form-item label="内容" class="smart-query-form-item">
|
<a-form-item label="关键词" class="smart-query-form-item">
|
||||||
<a-input style="width: 200px" v-model:value="queryForm.keywords" placeholder="内容" />
|
<a-input style="width: 200px" v-model:value="queryForm.keywords" placeholder="评论内容、交流标题" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="是否置顶" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 120px" v-model:value="queryForm.isTop" placeholder="请选择" allowClear>
|
||||||
|
<a-select-option :value="0">否</a-select-option>
|
||||||
|
<a-select-option :value="1">是</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="是否敏感词" class="smart-query-form-item">
|
||||||
|
<a-select style="width: 120px" v-model:value="queryForm.isSensitive" placeholder="请选择" allowClear>
|
||||||
|
<a-select-option :value="0">否</a-select-option>
|
||||||
|
<a-select-option :value="1">是</a-select-option>
|
||||||
|
</a-select>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item class="smart-query-form-item">
|
<a-form-item class="smart-query-form-item">
|
||||||
<a-button type="primary" @click="onSearch">
|
<a-button type="primary" @click="onSearch">
|
||||||
@ -34,12 +46,6 @@
|
|||||||
<!---------- 表格操作行 begin ----------->
|
<!---------- 表格操作行 begin ----------->
|
||||||
<a-row class="smart-table-btn-block">
|
<a-row class="smart-table-btn-block">
|
||||||
<div class="smart-table-operate-block">
|
<div class="smart-table-operate-block">
|
||||||
<a-button @click="showForm" type="primary" size="small">
|
|
||||||
<template #icon>
|
|
||||||
<PlusOutlined />
|
|
||||||
</template>
|
|
||||||
新建
|
|
||||||
</a-button>
|
|
||||||
<a-button @click="confirmBatchDelete" type="primary" danger size="small" :disabled="selectedRowKeyList.length == 0">
|
<a-button @click="confirmBatchDelete" type="primary" danger size="small" :disabled="selectedRowKeyList.length == 0">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<DeleteOutlined />
|
<DeleteOutlined />
|
||||||
@ -48,29 +54,31 @@
|
|||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="smart-table-setting-block">
|
<div class="smart-table-setting-block">
|
||||||
<TableOperator v-model="columns" :tableId="null" :refresh="queryData" />
|
<!-- 移除TableOperator组件 -->
|
||||||
</div>
|
</div>
|
||||||
</a-row>
|
</a-row>
|
||||||
<!---------- 表格操作行 end ----------->
|
<!---------- 表格操作行 end ----------->
|
||||||
|
|
||||||
<!---------- 表格 begin ----------->
|
<!---------- 表格 begin ----------->
|
||||||
<a-table
|
<a-table
|
||||||
size="small"
|
|
||||||
:scroll="{ y: 800 }"
|
|
||||||
:dataSource="tableData"
|
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
rowKey="commentId"
|
:data-source="tableData"
|
||||||
bordered
|
|
||||||
:loading="tableLoading"
|
:loading="tableLoading"
|
||||||
:pagination="false"
|
:pagination="false"
|
||||||
|
:scroll="{ x: 1500 }"
|
||||||
|
size="small"
|
||||||
|
bordered
|
||||||
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
|
:row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
|
||||||
>
|
>
|
||||||
<template #bodyCell="{ text, record, column }">
|
<template #bodyCell="{ text, record, column }">
|
||||||
|
|
||||||
|
|
||||||
<template v-if="column.dataIndex === 'action'">
|
<template v-if="column.dataIndex === 'action'">
|
||||||
<div class="smart-table-operate">
|
<div class="smart-table-operate">
|
||||||
<a-button @click="showForm(record)" type="link">编辑</a-button>
|
<a-button @click="updateStatus(record.commentId, record.status === 1 ? 0 : 1)" type="link">
|
||||||
|
{{ record.status === 1 ? '禁用' : '启用' }}
|
||||||
|
</a-button>
|
||||||
|
<a-button @click="updateTopStatus(record.commentId, record.isTop === 1 ? 0 : 1)" type="link">
|
||||||
|
{{ record.isTop === 1 ? '取消置顶' : '置顶' }}
|
||||||
|
</a-button>
|
||||||
<a-button @click="onDelete(record)" danger type="link">删除</a-button>
|
<a-button @click="onDelete(record)" danger type="link">删除</a-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -94,110 +102,77 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UserCommentExchangeForm ref="formRef" @reloadList="queryData"/>
|
<!-- 图片预览Modal -->
|
||||||
|
<a-modal
|
||||||
|
v-model:open="imageModalVisible"
|
||||||
|
:footer="null"
|
||||||
|
:width="800"
|
||||||
|
:title="'图片预览'"
|
||||||
|
centered
|
||||||
|
>
|
||||||
|
<div style="text-align: center;">
|
||||||
|
<img
|
||||||
|
:src="currentImageUrl"
|
||||||
|
style="max-width: 100%; max-height: 600px; object-fit: contain;"
|
||||||
|
alt="图片预览"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</a-modal>
|
||||||
</a-card>
|
</a-card>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref, onMounted } from 'vue';
|
import { reactive, ref, onMounted, h } from 'vue';
|
||||||
import { message, Modal } from 'ant-design-vue';
|
import { message, Modal } from 'ant-design-vue';
|
||||||
import { SmartLoading } from '/@/components/framework/smart-loading';
|
import { SmartLoading } from '/@/components/framework/smart-loading';
|
||||||
import { userCommentExchangeApi } from '/@/api/business/user-comment-exchange/user-comment-exchange-api';
|
import { userCommentExchangeApi } from '/@/api/business/user-comment-exchange/user-comment-exchange-api';
|
||||||
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
import { PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
|
||||||
import { smartSentry } from '/@/lib/smart-sentry';
|
import { smartSentry } from '/@/lib/smart-sentry';
|
||||||
import TableOperator from '/@/components/support/table-operator/index.vue';
|
|
||||||
import UserCommentExchangeForm from './user-comment-exchange-form.vue';
|
|
||||||
|
|
||||||
// ---------------------------- 表格列 ----------------------------
|
// ---------------------------- 表格列 ----------------------------
|
||||||
|
|
||||||
const columns = ref([
|
const columns = ref([
|
||||||
{
|
{ title: '用户名称', dataIndex: 'userName', ellipsis: true, width: 120 },
|
||||||
title: '主键id',
|
{ title: '交流标题', dataIndex: 'exchangeTitle', ellipsis: false, width: 200, customRender: ({ text }) => h('div', { style: { 'white-space': 'pre-wrap', 'word-break': 'break-all', 'line-height': '1.4' } }, text || '-') },
|
||||||
dataIndex: 'commentId',
|
{ title: '评论状态', dataIndex: 'status', ellipsis: true, width: 80, customRender: ({ text }) => h('a-tag', {
|
||||||
ellipsis: true,
|
color: text === 1 ? 'success' : 'error'
|
||||||
},
|
}, text === 1 ? '正常' : '禁用') },
|
||||||
{
|
{ title: '是否敏感词', dataIndex: 'isSensitive', ellipsis: true, width: 80, customRender: ({ text }) => h('a-tag', {
|
||||||
title: '用户id',
|
color: text === 1 ? 'error' : 'success'
|
||||||
dataIndex: 'userId',
|
}, text === 1 ? '是' : '否') },
|
||||||
ellipsis: true,
|
{ title: '是否置顶', dataIndex: 'isTop', ellipsis: true, width: 80, customRender: ({ text }) => h('a-tag', {
|
||||||
},
|
color: text === 1 ? 'processing' : 'default'
|
||||||
{
|
}, text === 1 ? '是' : '否') },
|
||||||
title: '病例交流id',
|
{ title: '点赞数量', dataIndex: 'likeNum', ellipsis: true, width: 80 },
|
||||||
dataIndex: 'exchangeId',
|
{ title: '是否作者评论', dataIndex: 'isAuthor', ellipsis: true, width: 100, customRender: ({ text }) => h('a-tag', {
|
||||||
ellipsis: true,
|
color: text === 1 ? 'magenta' : 'default'
|
||||||
},
|
}, text === 1 ? '是' : '否') },
|
||||||
{
|
{ title: '评论内容', dataIndex: 'content', ellipsis: false, width: 200, customRender: ({ text }) => h('div', { style: { 'white-space': 'pre-wrap', 'word-break': 'break-all', 'line-height': '1.4' } }, text || '-') },
|
||||||
title: '父级id,一级评论为null',
|
{ title: '评论内容(原版)', dataIndex: 'contentWord', ellipsis: false, width: 200, customRender: ({ text }) => h('div', { style: { 'white-space': 'pre-wrap', 'word-break': 'break-all', 'line-height': '1.4' } }, text || '-') },
|
||||||
dataIndex: 'parentId',
|
{ title: '评论图片', dataIndex: 'commentImage', ellipsis: false, width: 150, customRender: ({ text }) => {
|
||||||
ellipsis: true,
|
if (!text) return h('span', '-');
|
||||||
},
|
const images = text.split(',').filter(img => img.trim());
|
||||||
{
|
if (images.length === 0) return h('span', '-');
|
||||||
title: '根评论id,一级评论时为null。其余为一级评论id',
|
|
||||||
dataIndex: 'rootId',
|
return h('div', { style: { display: 'flex', gap: '5px', flexWrap: 'wrap' } },
|
||||||
ellipsis: true,
|
images.map((img, index) =>
|
||||||
},
|
h('img', {
|
||||||
{
|
src: img.trim(),
|
||||||
title: '评论状态(0:禁用 1:正常)',
|
style: { width: '50px', height: '50px', objectFit: 'cover', cursor: 'pointer' },
|
||||||
dataIndex: 'status',
|
onClick: () => showImageModal(img.trim())
|
||||||
ellipsis: true,
|
})
|
||||||
},
|
)
|
||||||
{
|
);
|
||||||
title: '是否存在敏感词(0:否 1:是)',
|
}},
|
||||||
dataIndex: 'isSensitive',
|
{ title: '创建时间', dataIndex: 'createdAt', ellipsis: true, width: 120 },
|
||||||
ellipsis: true,
|
{ title: '操作', dataIndex: 'action', fixed: 'right', width: 200 },
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '是否置顶(0:否 1:是)',
|
|
||||||
dataIndex: 'isTop',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '点赞数量',
|
|
||||||
dataIndex: 'likeNum',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '是否作者评论(0:否 1:是)',
|
|
||||||
dataIndex: 'isAuthor',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '评论内容',
|
|
||||||
dataIndex: 'content',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '评论内容(原版)',
|
|
||||||
dataIndex: 'contentWord',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '评论图片',
|
|
||||||
dataIndex: 'commentImage',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '创建时间',
|
|
||||||
dataIndex: 'createdAt',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '修改时间',
|
|
||||||
dataIndex: 'updatedAt',
|
|
||||||
ellipsis: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '操作',
|
|
||||||
dataIndex: 'action',
|
|
||||||
fixed: 'right',
|
|
||||||
width: 90,
|
|
||||||
},
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// ---------------------------- 查询数据表单和方法 ----------------------------
|
// ---------------------------- 查询数据表单和方法 ----------------------------
|
||||||
|
|
||||||
const queryFormState = {
|
const queryFormState = {
|
||||||
keywords: undefined, //内容
|
keywords: undefined, //关键词
|
||||||
|
isTop: undefined, //是否置顶
|
||||||
|
isSensitive: undefined, //是否存在敏感词
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
};
|
};
|
||||||
@ -209,11 +184,12 @@
|
|||||||
const tableData = ref([]);
|
const tableData = ref([]);
|
||||||
// 总数
|
// 总数
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
|
// 选中的行
|
||||||
|
const selectedRowKeyList = ref([]);
|
||||||
|
|
||||||
// 重置查询条件
|
// 重置查询条件
|
||||||
function resetQuery() {
|
function resetQuery() {
|
||||||
let pageSize = queryForm.pageSize;
|
let pageSize = queryForm.pageSize;
|
||||||
Object.assign(queryForm, queryFormState);
|
|
||||||
queryForm.pageSize = pageSize;
|
queryForm.pageSize = pageSize;
|
||||||
queryData();
|
queryData();
|
||||||
}
|
}
|
||||||
@ -238,41 +214,30 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onMounted(queryData);
|
onMounted(queryData);
|
||||||
|
|
||||||
// ---------------------------- 添加/修改 ----------------------------
|
// ---------------------------- 添加/修改 ----------------------------
|
||||||
const formRef = ref();
|
// 修改状态
|
||||||
|
async function updateStatus(commentId, status) {
|
||||||
|
const statusText = status === 1 ? '禁用' : '启用';
|
||||||
|
|
||||||
function showForm(data) {
|
|
||||||
formRef.value.show(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------- 单个删除 ----------------------------
|
|
||||||
//确认删除
|
|
||||||
function onDelete(data){
|
|
||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '提示',
|
title: '提示',
|
||||||
content: '确定要删除选吗?',
|
content: `确定要${statusText}这条评论吗?`,
|
||||||
okText: '删除',
|
okText: '确定',
|
||||||
okType: 'danger',
|
|
||||||
onOk() {
|
onOk() {
|
||||||
requestDelete(data);
|
requestUpdateStatus(commentId, status);
|
||||||
},
|
},
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onCancel() {},
|
onCancel() {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//请求删除
|
async function requestUpdateStatus(commentId, status) {
|
||||||
async function requestDelete(data){
|
|
||||||
SmartLoading.show();
|
SmartLoading.show();
|
||||||
try {
|
try {
|
||||||
let deleteForm = {
|
await userCommentExchangeApi.updateStatus(commentId, status);
|
||||||
goodsIdList: selectedRowKeyList.value,
|
message.success('操作成功');
|
||||||
};
|
|
||||||
await userCommentExchangeApi.delete(data.commentId);
|
|
||||||
message.success('删除成功');
|
|
||||||
queryData();
|
queryData();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
smartSentry.captureError(e);
|
smartSentry.captureError(e);
|
||||||
@ -281,11 +246,87 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------- 修改置顶状态 ----------------------------
|
||||||
|
async function updateTopStatus(commentId, isTop) {
|
||||||
|
const topText = isTop === 1 ? '取消置顶' : '置顶';
|
||||||
|
|
||||||
|
Modal.confirm({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要${topText}这条评论吗?`,
|
||||||
|
okText: '确定',
|
||||||
|
onOk() {
|
||||||
|
requestUpdateTopStatus(commentId, isTop);
|
||||||
|
},
|
||||||
|
cancelText: '取消',
|
||||||
|
onCancel() {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function requestUpdateTopStatus(commentId, isTop) {
|
||||||
|
SmartLoading.show();
|
||||||
|
try {
|
||||||
|
await userCommentExchangeApi.updateTopStatus(commentId, isTop);
|
||||||
|
message.success('操作成功');
|
||||||
|
queryData();
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
} finally {
|
||||||
|
SmartLoading.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------- 单个删除 ----------------------------
|
||||||
|
// 批量删除
|
||||||
|
function batchDelete() {
|
||||||
|
if (selectedRowKeyList.value.length === 0) {
|
||||||
|
message.warning('请选择要删除的评论');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Modal.confirm({
|
||||||
|
title: '批量删除',
|
||||||
|
content: `确定要删除选中的 ${selectedRowKeyList.value.length} 条评论吗?`,
|
||||||
|
okText: '确定',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk() {
|
||||||
|
// 这里可以调用批量删除API
|
||||||
|
message.success('批量删除功能待实现');
|
||||||
|
selectedRowKeyList.value = [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除单条评论
|
||||||
|
function onDelete(record) {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '删除评论',
|
||||||
|
content: `确定要删除这条评论吗?`,
|
||||||
|
okText: '确定',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk() {
|
||||||
|
requestDelete(record.commentId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 请求删除评论
|
||||||
|
async function requestDelete(commentId) {
|
||||||
|
try {
|
||||||
|
SmartLoading.show();
|
||||||
|
await userCommentExchangeApi.delete(commentId);
|
||||||
|
message.success('删除成功');
|
||||||
|
queryData();
|
||||||
|
} catch (e) {
|
||||||
|
smartSentry.captureError(e);
|
||||||
|
message.error('删除失败');
|
||||||
|
} finally {
|
||||||
|
SmartLoading.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------- 批量删除 ----------------------------
|
// ---------------------------- 批量删除 ----------------------------
|
||||||
|
|
||||||
// 选择表格行
|
// 选择表格行
|
||||||
const selectedRowKeyList = ref([]);
|
|
||||||
|
|
||||||
function onSelectChange(selectedRowKeys) {
|
function onSelectChange(selectedRowKeys) {
|
||||||
selectedRowKeyList.value = selectedRowKeys;
|
selectedRowKeyList.value = selectedRowKeys;
|
||||||
}
|
}
|
||||||
@ -318,4 +359,13 @@
|
|||||||
SmartLoading.hide();
|
SmartLoading.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------- 图片预览 ----------------------------
|
||||||
|
const imageModalVisible = ref(false);
|
||||||
|
const currentImageUrl = ref('');
|
||||||
|
|
||||||
|
function showImageModal(url) {
|
||||||
|
currentImageUrl.value = url;
|
||||||
|
imageModalVisible.value = true;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user