评论管理

This commit is contained in:
ChenXinXin committed 2024-05-21 13:40:42 +08:00
1 parent 1f99dcd134
commit 6aadef58bf
5 files changed
+283 -1

No files matched your search

+1
View File
@@ -0,0 +1 @@
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):r.dayjs_plugin_relativeTime=t()}(this,function(){"use strict";return function(r,t,e){var n=t.prototype;e.en.relativeTime={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};var o=function(r,t,n,o){for(var d,i,u=n.$locale().relativeTime,a=[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],f=a.length,s=0;s<f;s+=1){var l=a[s];l.d&&(d=o?e(r).diff(n,l.d,!0):n.diff(r,l.d,!0));var h=Math.round(Math.abs(d));if(h<=l.r||!l.r){1===h&&s>0&&(l=a[s-1]),i=u[l.l].replace("%d",h);break}}return t?i:(d>0?u.future:u.past).replace("%s",i)};n.to=function(r,t){return o(r,t,this,!0)},n.from=function(r,t){return o(r,t,this)};var d=function(r){return r.$u?e.utc():e()};n.toNow=function(r){return this.to(d(this),r)},n.fromNow=function(r){return this.from(d(this),r)}}});
+30
View File
@@ -599,6 +599,36 @@ class TaskService extends Service {
throw new Error("审批信息已更新,请重新刷新页面!") throw new Error("审批信息已更新,请重新刷新页面!")
} }
} }
async updateComment() {
const { jianghuKnex } = this.app;
const { userId, username } = this.ctx.userInfo;
const { actionData, where } = this.ctx.request.body.appData;
const { taskCommentList, taskInitUser, taskEditUserList } = actionData;
const noticeInsertData = []
var noticeUser = taskEditUserList && taskEditUserList.split(',') || []
// 如果是审批单申请人添加的备注,就只给当前审批人发送(已经通过审批人的不会收到提醒);
// 如果是已经审批了的审批人添加的备注,就给其他当前节点未审批的审批人和申请人发送消息提醒。
if (userId !== taskInitUser) {
noticeUser.push(taskInitUser)
}
noticeInsertData.push({
noticeId: await idGenerateUtil.uuid(),
noticeName: "通知-审批-" + where.taskId,
noticeContent: _.uniq(noticeUser).join(','),
pushContent: '{}',
pushStatus: "success",
pushAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
})
await jianghuKnex.transaction(async trx => {
await trx("task", this.ctx).where(where).jhUpdate({ taskCommentList: JSON.stringify(taskCommentList) });
if (noticeInsertData.length > 0) await trx("notice_push", this.ctx).jhInsert(noticeInsertData);
})
}
} }
module.exports = TaskService; module.exports = TaskService;
+155
View File
@@ -0,0 +1,155 @@
<template id="task-comment-list">
<div class="pa-4">
<!-- 评论框 -->
<div class="d-flex" v-if="!readonly">
<v-avatar color="primary" size="25" class="mr-2">
<span class="white--text font-weight-bold">{{username[0]}}</span>
</v-avatar>
<div class="flex-grow-1 right-content px-4 py-2 text-right">
<textarea v-model="newComment" style="width: 100%; outline: none;" :counter="2000" @focus="expandInput"></textarea>
<v-btn color="primary" small v-if="isInputExpanded" @click="postComment">评论</v-btn>
<v-btn small v-if="isInputExpanded" @click="cancelComment">取消</v-btn>
</div>
</div>
<!-- 评论列表 -->
<div class="comment-list mt-4">
<div class="comment-list-item d-flex" v-for="comment in reversedComments" :key="comment.id">
<v-avatar color="primary" size="25" class="mr-2">
<span class="white--text font-weight-bold">{{comment.username[0]}}</span>
</v-avatar>
<div class="right-content pa-4">
<div class="content font-weight-bold">{{ comment.content }}</div>
<div class="bottom-content">
<div class="user-info">
<span>{{comment.username}}</span>
<span class="time">{{ comment.time | timeAgo}}</span>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script src="/<$ ctx.app.config.appId $>/public/lib/dayjs/relativeTime.js"></script>
<script type="module">
Vue.component("task-comment-list", {
template: '#task-comment-list',
props: {
comments: {
type: Array,
default: () => [],
},
// 是否只读
readonly: {
type: Boolean,
default: false,
},
},
data: () => ({
newComment: '',
isInputExpanded: false,
username: userInfo.username
}),
created() {
dayjs.extend(dayjs_plugin_relativeTime);
},
filters: {
timeAgo: (time) => time ? dayjs(time).fromNow() : '',
},
computed: {
// 倒序评论列表
reversedComments() {
return this.comments.slice().reverse();
},
},
methods: {
expandInput() {
this.isInputExpanded = true;
},
postComment() {
// 添加评论逻辑
this.comments.push({
id: this.comments.length + 1,
username: userInfo.username,
userId: userInfo.userId,
content: this.newComment,
time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
})
this.newComment = null
this.$emit('update:comments', this.comments)
this.$emit('confirm')
this.isInputExpanded = false;
},
cancelComment() {
this.newComment = '';
this.isInputExpanded = false;
},
},
})
</script>
<style scoped>
.comment-list .comment-list-item {
color: #42526e
}
.comment-list .comment-list-item {
margin-top: 32px
}
.right-content {
position: relative;
width: 100%;
padding-top: 8px;
margin-left: 10px;
border: 1px solid #dfe1e6;
border-radius: 3px
}
.right-content:before {
position: absolute;
top: 5px;
left: -12px;
width: 0;
height: 0;
content: "";
border: 6px solid #dfe1e6;
border-color: transparent #dfe1e6 transparent transparent
}
.right-content:after {
position: absolute;
top: 5px;
left: -10px;
width: 0;
height: 0;
content: "";
border: 6px solid transparent;
border-color: transparent #fff transparent transparent
}
.comment-list .comment-list-item .right-content .bottom-content {
display: -webkit-box;
display: -ms-flexbox;
display: flex
}
.comment-list .comment-list-item .time {
margin-left: 8px;
color: #42526e;
}
.comment-list .comment-list-item .content {
line-height: 1.5;
color: #42526e;
word-break: break-all;
word-wrap: break-word;
white-space: pre-wrap
}
</style>
+49 -1
View File
@@ -159,6 +159,31 @@
</v-col> </v-col>
</v-row> </v-row>
<!-- 评论列表 -->
<v-row class="mt-4" v-if="isSubmitDrawerShown" >
<v-col cols="12" sm="12" md="12">
<div class="text-subtitle-2 mb-2 mx-4 font-weight-bold">
评论列表
<v-tooltip bottom>
<template v-slot:activator="{ on, attrs }">
<v-icon
color="grey"
dark
v-bind="attrs"
v-on="on"
small
>
mdi-alert-circle-outline
</v-icon>
</template>
<span>如果是审批单申请人添加的备注,就只给当前审批人发送(已经通过审批人的不会收到提醒);
如果是已经审批了的审批人添加的备注,就给其他当前节点未审批的审批人和申请人发送消息提醒。</span>
</v-tooltip>
</div>
<task-comment-list :comments.sync="updateItem.taskCommentList" @confirm="doUiAction('postComment')" />
</v-col>
</v-row>
<!--抽屉关闭按钮--> <!--抽屉关闭按钮-->
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" <v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn"
@click="isSubmitDrawerShown = false"> @click="isSubmitDrawerShown = false">
@@ -201,6 +226,8 @@
{% include 'component/tpl/formComponentList.html' %} {% include 'component/tpl/formComponentList.html' %}
{% include 'component/taskHistory.html' %} {% include 'component/taskHistory.html' %}
{% include 'common/jianghuJs/fixedTableHeightV4.html' %} {% include 'common/jianghuJs/fixedTableHeightV4.html' %}
{% include 'component/taskCommentList.html' %}
<!-- <<<<<<<<<<<<< 加载页面组件 --> <!-- <<<<<<<<<<<<< 加载页面组件 -->
<script type="module"> <script type="module">
@@ -299,6 +326,11 @@
this.getTableData(); this.getTableData();
this.getTaskHistoryData(); this.getTaskHistoryData();
break; break;
case 'postComment':
await this.doPostComment();
this.getTableData();
this.getTaskHistoryData();
break;
default: default:
console.error("[doUiAction] uiActionId not find", { uiActionId }); console.error("[doUiAction] uiActionId not find", { uiActionId });
break; break;
@@ -351,7 +383,7 @@
this.updateItem.taskInfo = JSON.parse(funObj.taskInfo); this.updateItem.taskInfo = JSON.parse(funObj.taskInfo);
this.updateItem.taskWorkflow = JSON.parse(funObj.taskWorkflow); this.updateItem.taskWorkflow = JSON.parse(funObj.taskWorkflow);
this.updateItem.taskFormInput = JSON.parse(funObj.taskFormInput); this.updateItem.taskFormInput = JSON.parse(funObj.taskFormInput);
this.updateItem.taskComment = ''; // 备注 this.updateItem.taskCommentList = funObj.taskCommentList && JSON.parse(funObj.taskCommentList) || [];
}, },
async getTaskWorkflow({ taskId }){ async getTaskWorkflow({ taskId }){
@@ -408,6 +440,22 @@
this.updateItemId = null; this.updateItemId = null;
}, },
// ---------- <<<<<<<<<<< 审核、查看 uiAction -------- // ---------- <<<<<<<<<<< 审核、查看 uiAction --------
// ---------- 保存评论 uiAction >>>>>>>>>>>> --------
async doPostComment() {
const { taskId, taskCommentList, taskInitUser, taskEditUserList,...data } = this.updateItem
await window.jianghuAxios({
data: {
appData: {
pageId: 'approvalManagement',
actionId: 'updateComment',
actionData: { taskCommentList, taskInitUser, taskEditUserList },
where: { taskId },
}
}
})
},
// ---------- 保存评论 uiAction >>>>>>>>>>>> --------
} }
}) })
</script> </script>
+48
View File
@@ -122,6 +122,31 @@
</v-col> </v-col>
</v-row> </v-row>
<!-- 评论列表 -->
<v-row class="mt-4" v-if="isViewDrawerShown" >
<v-col cols="12" sm="12" md="12">
<div class="text-subtitle-2 mb-2 mx-4 font-weight-bold">
评论列表
<v-tooltip bottom>
<template v-slot:activator="{ on, attrs }">
<v-icon
color="grey"
dark
v-bind="attrs"
v-on="on"
small
>
mdi-alert-circle-outline
</v-icon>
</template>
<span>如果是审批单申请人添加的备注,就只给当前审批人发送(已经通过审批人的不会收到提醒);
如果是已经审批了的审批人添加的备注,就给其他当前节点未审批的审批人和申请人发送消息提醒。</span>
</v-tooltip>
</div>
<task-comment-list :comments.sync="viewItem.taskCommentList" @confirm="doUiAction('postComment')" />
</v-col>
</v-row>
<!--抽屉关闭按钮--> <!--抽屉关闭按钮-->
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" <v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn"
@click="isViewDrawerShown = false"> @click="isViewDrawerShown = false">
@@ -163,6 +188,8 @@
{% include 'component/tpl/formComponentList.html' %} {% include 'component/tpl/formComponentList.html' %}
{% include 'component/taskHistory.html' %} {% include 'component/taskHistory.html' %}
{% include 'common/jianghuJs/fixedTableHeightV4.html' %} {% include 'common/jianghuJs/fixedTableHeightV4.html' %}
{% include 'component/taskCommentList.html' %}
<!-- <<<<<<<<<<<<< 加载页面组件 --> <!-- <<<<<<<<<<<<< 加载页面组件 -->
<script type="module"> <script type="module">
@@ -239,6 +266,10 @@
await this.doAmendTask(uiActionData); await this.doAmendTask(uiActionData);
await this.getTableData(); await this.getTableData();
break; break;
case 'postComment':
await this.doPostComment();
await this.getTableData();
break;
default: default:
console.error("[doUiAction] uiActionId not find", { uiActionId }); console.error("[doUiAction] uiActionId not find", { uiActionId });
break; break;
@@ -282,6 +313,7 @@
// ---------- 查看 uiAction >>>>>>>>>>>> -------- // ---------- 查看 uiAction >>>>>>>>>>>> --------
async prepareViewItemData(funObj) { async prepareViewItemData(funObj) {
this.viewItem = _.cloneDeep(funObj); this.viewItem = _.cloneDeep(funObj);
this.viewItem.taskCommentList = this.viewItem.taskCommentList && JSON.parse(this.viewItem.taskCommentList) || []
}, },
async getTaskWorkflow({ taskId }){ async getTaskWorkflow({ taskId }){
@@ -348,6 +380,22 @@
await window.vtoast.success("修改数据成功"); await window.vtoast.success("修改数据成功");
}, },
// ---------- 修正 uiAction >>>>>>>>>>>> -------- // ---------- 修正 uiAction >>>>>>>>>>>> --------
// ---------- 保存评论 uiAction >>>>>>>>>>>> --------
async doPostComment() {
const { taskId, taskCommentList, taskInitUser, taskEditUserList,...data } = this.viewItem
await window.jianghuAxios({
data: {
appData: {
pageId: 'taskManagement',
actionId: 'updateComment',
actionData: { taskCommentList, taskInitUser, taskEditUserList },
where: { taskId },
}
}
})
},
// ---------- 保存评论 uiAction >>>>>>>>>>>> --------
} }
}) })
</script> </script>