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