@@ -210,22 +224,19 @@
style="margin: 10px 10px 0 10px; border-radius: 4px"
label="评论"
>
-
-
武大郎:
+
+ {{ subComment.creatorName }}:
- 大官人,你要脆饼不要,卖完最后一个我要回家了,我家婆娘熬了鸡汤给我补身子
+ {{ subComment.content }}
-
- 潘金莲:
- 西门大官人,我要给你生猴子❥(^_-)
-
-
- 武二郎:
- 如同天上降魔主,真乃人间太岁
-
-
+ /> -->
+
+
+
+ {{ item.name }}
+ {{ item.dept }}
+
+
+
发布
@@ -277,8 +306,16 @@ import { formatDate } from '@/utils/formatTime'
import OkrTable from './OkrTable.vue'
import { getOkrNodeDetail, getOkrNodeHistory } from '@/api/okr/okr'
-import { getCommentTypeOptions, createComment, getCommentPage } from '@/api/okr/comment'
+import {
+ getCommentTypeOptions,
+ createComment,
+ getCommentPage,
+ likeComment
+} from '@/api/okr/comment'
+import { listToTree } from '@/utils/tree'
+import { getEmployeeSimpleList } from '@/api/pers/employee'
+const message = useMessage()
const emit = defineEmits(['edit'])
const show = ref(false)
@@ -319,6 +356,8 @@ async function open(curNode) {
show.value = true
}
+const employeeOptions = ref([])
+
function searchInfo(curNode) {
try {
getOkrNodeDetail(curNode.nodeId).then((resp) => {
@@ -339,6 +378,13 @@ function searchInfo(curNode) {
getOkrNodeHistory(curNode.nodeId).then((resp) => {
nodeRecords.value = resp
})
+ getEmployeeSimpleList({ status: 0 }).then((resp) => {
+ employeeOptions.value = resp.map((item) => ({
+ ...item,
+ label: item.name,
+ value: item.name
+ }))
+ })
getCommentTypeOptions().then((resp) => {
commentTypeOptions.value = resp
})
@@ -353,6 +399,10 @@ function close() {
defineExpose({ open, close })
+function handleMention(item) {
+ form.value.mentionedUserIdList.push(item.id)
+}
+
function handleSaveProcess() {
okrTableRef.value.updateProcess(nodeInfo.value.nodeId).then(() => {
message.success('更新成功')
@@ -367,7 +417,8 @@ function handleChildItem() {
const addNewComment = ref(false)
const form = ref({
commentValue: '',
- commentType: undefined
+ commentType: undefined,
+ mentionedUserIdList: []
})
function handleInsertComment() {
addNewComment.value = true
@@ -401,10 +452,14 @@ function handleSaveComment() {
content: form.value.commentValue,
mentionedUserIdList: form.value.mentionedUserIdList
}
- createComment(data).then(() => {
- message.success('评论成功')
- searchCommentList()
- })
+ createComment(data)
+ .then(() => {
+ message.success('评论成功')
+ searchCommentList()
+ })
+ .finally(() => {
+ form.value.commentValue = ''
+ })
} catch (error) {
message.error('评论失败')
}
@@ -416,14 +471,21 @@ function searchCommentList() {
businessType: 1,
businessId: nodeInfo.value.nodeId,
pageNum: 1,
- pageSize: 100
+ pageSize: -1
}).then((resp) => {
- commentList.value = resp.list
+ commentList.value = listToTree(resp.list, {
+ id: 'commentId',
+ pid: 'parentId',
+ children: 'children'
+ })
})
}
-function good(index) {
- console.log(index)
+function good(item) {
+ likeComment(item.commentId).then(() => {
+ message.success('点赞成功')
+ searchCommentList()
+ })
}
const showCommentIndex = ref(-1)
@@ -431,8 +493,37 @@ function showComment(index) {
showCommentIndex.value = showCommentIndex.value == index ? -1 : index
}
-function handleSendCommnet() {
- console.log(form.value.commentValue)
+function handleSendCommnet(idx) {
+ try {
+ // 过滤掉删除的用户,方式为遍历mentionedUserIdList,查找评论中是否有对应的用户名
+ const userList = [...form.value.mentionedUserIdList]
+ const arr = []
+ userList.map((item) => {
+ if (form.value.commentValue.indexOf(`@${item.name}`) != -1) {
+ arr.push(item.id)
+ // 然后移除对应的用户名,防止有多个
+ form.value.commentValue = form.value.commentValue.replace(`@${item.name}`, '')
+ }
+ })
+ const data = {
+ businessType: 1,
+ businessId: nodeInfo.value.nodeId,
+ contentType: 1,
+ content: form.value.commentValue,
+ mentionedUserIdList: arr,
+ parentId: commentList.value[idx].commentId
+ }
+ createComment(data)
+ .then(() => {
+ message.success('评论成功')
+ searchCommentList()
+ })
+ .finally(() => {
+ form.value.commentValue = ''
+ })
+ } catch (error) {
+ message.error('评论失败')
+ }
}