|
854 | 854 | </div> |
855 | 855 | </vue-scroll> |
856 | 856 | </div> |
857 | | - <div class="footer"> |
858 | | - <a-textarea v-model="comment" :rows="1" placeholder="按 Ctrl+Enter 快速发表评论" |
859 | | - style="margin-right: 24px;"/> |
| 857 | + <div class="footer" id="footer"> |
| 858 | + <a-popover trigger="click" placement="top" :visible="showMentions" arrowPointAtCenter :getPopupContainer="getPopup"> |
| 859 | + <template slot="content"> |
| 860 | + <div class="mentions-content" style="width: 200px;"> |
| 861 | + <div class="mentions-wrapper" v-for="member in taskMemberList" :key="member.id" @click="selectMentionMember(member)"> |
| 862 | + <a-avatar :src="member.avatar" icon="user" :size="28"/> |
| 863 | + <span class="muted name m-l-xs">{{member.name}}</span> |
| 864 | + </div> |
| 865 | + </div> |
| 866 | + </template> |
| 867 | +<!-- <span slot="title">Title</span>--> |
| 868 | + <a-textarea ref="commentText" v-model="comment" :rows="1" placeholder="支持@提及任务成员,Ctrl+Enter发表评论" |
| 869 | + style="margin-right: 24px;"/> |
| 870 | + </a-popover> |
860 | 871 | <a-button class="middle-btn" type="primary" @click="createComment">评论</a-button> |
861 | 872 | </div> |
862 | 873 | </div> |
|
1126 | 1137 | modalTitle: '设置预估工时', |
1127 | 1138 | modalStatus: false, |
1128 | 1139 | confirmLoading: false, |
1129 | | - } |
| 1140 | + }, |
| 1141 | + //显示评论提及 |
| 1142 | + showMentions: false, |
| 1143 | + mentionsList: [] |
1130 | 1144 | } |
1131 | 1145 | }, |
1132 | 1146 | computed: { |
|
1210 | 1224 | })() |
1211 | 1225 | }; |
1212 | 1226 | document.onkeydown = (event) => { |
| 1227 | + console.log(event); |
1213 | 1228 | var e = event || window.event || arguments.callee.caller.arguments[0]; |
1214 | 1229 | if (13 == e.keyCode && e.ctrlKey) { |
1215 | 1230 | //处理的部分 |
1216 | 1231 | this.createComment(); |
1217 | 1232 | } |
| 1233 | + if ('Digit2' == e.code) { |
| 1234 | + this.showMentions = true; |
| 1235 | + }else{ |
| 1236 | + this.showMentions = false; |
| 1237 | + } |
1218 | 1238 | }; |
1219 | 1239 | setTimeout(() => { |
1220 | 1240 | this.uploader.assignBrowse(document.getElementById('upload-file')); |
|
1578 | 1598 | }); |
1579 | 1599 | }, |
1580 | 1600 | createComment() { |
1581 | | - if (!this.comment.trim()) { |
| 1601 | + let comment = this.comment.trim(); |
| 1602 | + if (!comment) { |
1582 | 1603 | return false; |
1583 | 1604 | } |
1584 | | - createComment(this.code, this.comment).then(() => { |
| 1605 | + comment += ' '; |
| 1606 | + const regx = /(@[^@]+) /g; |
| 1607 | + comment.match(regx).forEach((v) => { |
| 1608 | + let str = v.substring(1, v.length - 1); |
| 1609 | + if (this.mentionsList.findIndex(item => item == str) === -1) { |
| 1610 | + this.mentionsList.push(str); |
| 1611 | + } |
| 1612 | + }); |
| 1613 | + createComment(this.code, this.comment, JSON.stringify(this.mentionsList)).then(() => { |
1585 | 1614 | this.comment = ''; |
| 1615 | + this.mentionsList = []; |
1586 | 1616 | this.getTaskLog(); |
1587 | 1617 | }); |
1588 | 1618 | }, |
|
1764 | 1794 | this.visibleChildTaskMemberMenu = false; |
1765 | 1795 | this.childExecutor = member; |
1766 | 1796 | }, |
| 1797 | + getPopup() { |
| 1798 | + return document.getElementById('footer'); |
| 1799 | + }, |
| 1800 | + selectMentionMember(member) { |
| 1801 | + this.showMentions = false; |
| 1802 | + this.comment += member.name + ' '; |
| 1803 | + this.$nextTick(() => { |
| 1804 | + this.$refs.commentText.focus(); |
| 1805 | + }); |
| 1806 | + }, |
1767 | 1807 | changeModalHeight() { |
1768 | 1808 | const defaultWidth = this.width; |
1769 | 1809 | let width = $(window).width() - 100; |
|
2240 | 2280 | } |
2241 | 2281 | } |
2242 | 2282 | } |
| 2283 | + .footer{ |
| 2284 | + .ant-popover-inner-content{ |
| 2285 | + padding: 0; |
| 2286 | + .mentions-content { |
| 2287 | + width: 200px; |
| 2288 | + padding: 12px 0; |
| 2289 | + .mentions-wrapper { |
| 2290 | + width: 100%; |
| 2291 | + display: flex; |
| 2292 | + align-items: center; |
| 2293 | + padding: 6px 12px; |
| 2294 | + &:hover{ |
| 2295 | + cursor: pointer; |
| 2296 | + background: rgba(51, 143, 229, 0.1); |
| 2297 | + } |
| 2298 | + } |
| 2299 | + } |
| 2300 | + } |
| 2301 | + } |
2243 | 2302 | </style> |
0 commit comments