feat: allow editing community post content
This commit is contained in:
@@ -129,12 +129,16 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="发布时间" prop="create_time" min-width="150" />
|
||||
<el-table-column label="操作" width="230" fixed="right">
|
||||
<el-table-column label="操作" width="280" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button v-perms="['community.communityPost/detail']" type="primary" link
|
||||
@click="handleDetail(row.id)">
|
||||
详情
|
||||
</el-button>
|
||||
<el-button v-perms="['community.communityPost/editContent']" type="primary" link
|
||||
@click="handleEdit(row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button v-if="row.status === 0" v-perms="['community.communityPost/updateStatus']"
|
||||
type="success" link @click="handleAudit(row.id, 1)">
|
||||
通过
|
||||
@@ -199,12 +203,27 @@
|
||||
<el-button @click="showDetail = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="showEdit" title="编辑帖子内容" width="700px" destroy-on-close>
|
||||
<el-form label-position="top">
|
||||
<el-form-item label="帖子内容">
|
||||
<el-input v-model="editData.content" type="textarea" :rows="14" :maxlength="16000"
|
||||
show-word-limit resize="vertical" placeholder="请输入帖子内容" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="showEdit = false">取消</el-button>
|
||||
<el-button type="primary" :loading="editSubmitLoading" @click="handleSubmitEdit">
|
||||
保存
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup name="communityPost">
|
||||
import {
|
||||
communityPostLists,
|
||||
communityPostDetail,
|
||||
communityPostEditContent,
|
||||
communityPostStatus,
|
||||
communityPostSetTop,
|
||||
communityPostSetHot,
|
||||
@@ -315,6 +334,40 @@ const handleDetail = async (id: number) => {
|
||||
}
|
||||
}
|
||||
|
||||
const showEdit = ref(false)
|
||||
const editSubmitLoading = ref(false)
|
||||
const editData = reactive({
|
||||
id: 0,
|
||||
content: ''
|
||||
})
|
||||
|
||||
const handleEdit = (post: any) => {
|
||||
showEdit.value = true
|
||||
editData.id = post.id
|
||||
editData.content = post.content || ''
|
||||
}
|
||||
|
||||
const handleSubmitEdit = async () => {
|
||||
if (!editData.content.trim()) {
|
||||
feedback.msgError('请输入帖子内容')
|
||||
return
|
||||
}
|
||||
editSubmitLoading.value = true
|
||||
try {
|
||||
await communityPostEditContent({
|
||||
id: editData.id,
|
||||
content: editData.content
|
||||
})
|
||||
showEdit.value = false
|
||||
if (detailData.value.id === editData.id) {
|
||||
detailData.value.content = editData.content
|
||||
}
|
||||
getLists()
|
||||
} finally {
|
||||
editSubmitLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const loadCategories = async () => {
|
||||
try {
|
||||
const categories = await communityCategoryAll()
|
||||
|
||||
Reference in New Issue
Block a user