kuaifan 5 年之前
父节点
当前提交
4bcd091c76

+ 10 - 2
app/Http/Controllers/Api/ReportController.php

@@ -113,7 +113,11 @@ class ReportController extends Controller
                 'status' => '已发送',
                 'ccuser' => Base::array2string($ccuser)
             ]);
-            return Base::retSuccess('发送成功!');
+            $reportDetail['ccuser'] = implode(',', $ccuser);
+            $reportDetail['ccuserArray'] = explode(',', $reportDetail['ccuser']);
+            return Base::retSuccess('发送成功!', array_merge($reportDetail, [
+                'ccuserAgain' => $reportDetail['status'] == '已发送'
+            ]));
         } elseif ($act == 'delete') {
             if (empty($reportDetail)) {
                 return Base::retError('没有相关的数据或已被删除!');
@@ -147,6 +151,7 @@ class ReportController extends Controller
             //
             $D['ccuser'] = explode(",", $D['ccuser']);
             $send = $reportDetail['status'] == '已发送' ? 1 : intval(Request::input('send'));
+            $ccuserAgain = $reportDetail['status'] == '已发送';
             if ($send) {
                 DB::table('report_ccuser')->where(['rid' => $reportDetail['id']])->update(['cc' => 0]);
                 foreach ($D['ccuser'] AS $ck => $cuser) {
@@ -167,6 +172,7 @@ class ReportController extends Controller
             DB::table('report_content')->updateOrInsert(['rid' => $reportDetail['id']], ['content' => $D['content']]);
             //
             $reportDetail = array_merge($reportDetail, [
+                'ccuserAgain' => $ccuserAgain,
                 'ccuser' => $D['ccuser'],
                 'title' => $D['title'],
                 'content' => $D['content'],
@@ -217,11 +223,13 @@ class ReportController extends Controller
             $reportDetail['content'] = '<h2>已完成工作</h2><ol>' . $completeContent . '</ol><h2>未完成的工作</h2><ol>' . $unfinishedContent . '</ol>';
             $reportDetail['status'] = '未保存';
         } else {
-            $reportDetail['ccuser'] = implode(',' ,Base::string2array($reportDetail['ccuser']));
+            $reportDetail['ccuser'] = implode(',', Base::string2array($reportDetail['ccuser']));
             if (!isset($reportDetail['content'])) {
                 $reportDetail['content'] = DB::table('report_content')->select(['content'])->where('rid', $reportDetail['id'])->value('content');
             }
         }
+        $reportDetail['ccuserAgain'] = isset($reportDetail['ccuserAgain']) ? $reportDetail['ccuserAgain'] : false;
+        $reportDetail['ccuserArray'] = explode(',', $reportDetail['ccuser']);
         return Base::retSuccess($act == 'submit' ? '保存成功' : 'success', $reportDetail);
     }
 

+ 4 - 1
app/Module/Chat.php

@@ -116,7 +116,10 @@ class Chat
                 $lastText = '[图片]';
                 break;
             case 'taskB':
-                $lastText = $message['detail'] . " [来自关注任务]";
+                $lastText = $message['text'] . " [来自关注任务]";
+                break;
+            case 'report':
+                $lastText = $message['text'] . " [来自工作报告]";
                 break;
             default:
                 $lastText = '[未知类型]';

+ 4 - 1
resources/assets/js/main/components/chat/Index.vue

@@ -683,7 +683,10 @@
                         lasttext = '[图片]';
                         break;
                     case 'taskB':
-                        lasttext = data.detail + " [来自关注任务]";
+                        lasttext = data.text + " [来自关注任务]";
+                        break;
+                    case 'report':
+                        lasttext = data.text + " [来自工作报告]";
                         break;
                     default:
                         lasttext = '[未知类型]';

+ 5 - 3
resources/assets/js/main/components/chat/message.vue

@@ -2,7 +2,7 @@
     <div :data-id="info.id">
 
         <!--文本、任务-->
-        <div v-if="info.type==='text' || info.type==='taskB'">
+        <div v-if="info.type==='text' || info.type==='taskB' || info.type==='report'">
             <div v-if="info.self===true" class="list-right">
                 <div v-if="info.error" class="item-error" @click="clickError(info.error)">
                     <Icon type="md-alert" />
@@ -13,12 +13,13 @@
                         <em v-if="info.indate" class="item-date">{{formatCDate(info.indate)}}</em>
                     </div>
                     <div class="item-text">
-                        <div class="item-text-view" v-html="textMsg(info[info.type==='text'?'text':'detail'])"></div>
+                        <div class="item-text-view" v-html="textMsg(info.text)"></div>
                     </div>
                     <template v-if="info.type==='taskB'">
                         <div v-if="info.other.type==='task'" class="item-link" @click="taskDetail(info.other.id)">来自关注任务:<a href="javascript:void(0)">{{info.other.title}}</a></div>
                         <div v-if="info.other.type==='file'" class="item-link">来自关注任务:<a target="_blank" :href="fileDownUrl(info.other.id)">{{info.other.name}}</a></div>
                     </template>
+                    <div v-else-if="info.type==='report'" class="item-link" @click="reportDetail(info.other.id, info.other.title)">来自工作报告:<a href="javascript:void(0)">{{info.other.title}}</a></div>
                 </div>
                 <img class="item-userimg" @click="clickUser" :src="info.userimg" onerror="this.src=window.location.origin+'/images/other/avatar.png'"/>
             </div>
@@ -31,12 +32,13 @@
                         <em v-if="info.indate" class="item-date">{{formatCDate(info.indate)}}</em>
                     </div>
                     <div class="item-text">
-                        <div class="item-text-view" v-html="textMsg(info[info.type==='text'?'text':'detail'])"></div>
+                        <div class="item-text-view" v-html="textMsg(info.text)"></div>
                     </div>
                     <template v-if="info.type==='taskB'">
                         <div v-if="info.other.type==='task'" class="item-link" @click="taskDetail(info.other.id)">来自关注任务:<a href="javascript:void(0)">{{info.other.title}}</a></div>
                         <div v-if="info.other.type==='file'" class="item-link">来自关注任务:<a target="_blank" :href="fileDownUrl(info.other.id)">{{info.other.name}}</a></div>
                     </template>
+                    <div v-else-if="info.type==='report'" class="item-link" @click="reportDetail(info.other.id, info.other.title)">来自工作报告:<a href="javascript:void(0)">{{info.other.title}}</a></div>
                 </div>
             </div>
         </div>

+ 21 - 0
resources/assets/js/main/components/report/add.vue

@@ -160,6 +160,27 @@
                             this.dataDetail = res.data;
                             this.$Message.success(res.msg);
                             this.$emit("on-success", res.data);
+                            //
+                            if (this.dataDetail.status === '已发送') {
+                                let userInfo = $A.getUserInfo();
+                                let msgData = {
+                                    type: 'report',
+                                    username: userInfo.username,
+                                    userimg: userInfo.userimg,
+                                    indate: Math.round(new Date().getTime() / 1000),
+                                    text: this.dataDetail.ccuserAgain ? '修改了工作报告' : '发送了工作报告',
+                                    other: {
+                                        id: this.dataDetail.id,
+                                        type: this.dataDetail.type,
+                                        title: this.dataDetail.title,
+                                    }
+                                };
+                                this.dataDetail.ccuserArray.forEach((username) => {
+                                    if (username != msgData.username) {
+                                        $A.WS.sendTo('user', username, msgData);
+                                    }
+                                });
+                            }
                         } else {
                             this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
                         }

+ 19 - 0
resources/assets/js/main/components/report/my.vue

@@ -275,6 +275,25 @@
                                         this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
                                     }
                                 }, 350);
+                                //
+                                let userInfo = $A.getUserInfo();
+                                let msgData = {
+                                    type: 'report',
+                                    username: userInfo.username,
+                                    userimg: userInfo.userimg,
+                                    indate: Math.round(new Date().getTime() / 1000),
+                                    text: res.data.ccuserAgain ? '修改了工作报告' : '发送了工作报告',
+                                    other: {
+                                        id: res.data.id,
+                                        type: res.data.type,
+                                        title: res.data.title,
+                                    }
+                                };
+                                res.data.ccuserArray.forEach((username) => {
+                                    if (username != msgData.username) {
+                                        $A.WS.sendTo('user', username, msgData);
+                                    }
+                                });
                             }
                         });
                     }

+ 1 - 1
resources/assets/js/main/main.js

@@ -298,7 +298,7 @@ import '../../sass/main.scss';
                                 username: item.username,
                                 userimg: item.userimg,
                                 indate: item.indate,
-                                detail: item.detail,
+                                text: item.detail,
                                 other: item.other
                             };
                             res.data.follower.forEach((username) => {