Browse Source

请假信息修改

lrf402788946 4 years ago
parent
commit
6a5c80c7a7
1 changed files with 8 additions and 4 deletions
  1. 8 4
      app/service/leave.js

+ 8 - 4
app/service/leave.js

@@ -34,7 +34,7 @@ class LeaveService extends CrudService {
 
   async update({ id }, data) {
     const leave = await this.model.findById(id);
-    const { studentid, starttime, endtime, reason, status, refcause, batchid, termid, classid, planid, stuname } = data;
+    const { studentid, starttime, endtime, reason, status, refcause, batchid, termid, classid, planid, stuname, type } = data;
     if (studentid) {
       leave.studentid = studentid;
     }
@@ -71,10 +71,14 @@ class LeaveService extends CrudService {
         // 通知中心管理员学生请假通过
         let detail = student.name + '的请假申请已通过,请及时查收!';
         const users = await this.umodel.find({ type: '0' });
+        let toOtherMsg = `${student.name}的${type === '1' ? '退出' : '请假'}申请已通过,请及时查收!`;
+        if (starttime) toOtherMsg = `${toOtherMsg}\n 时间:${starttime} 至 ${endtime}`;
+        if (reason) toOtherMsg = `${toOtherMsg}\n ${type === '1' ? '退出' : '请假'}原因:${reason}`;
+        if (refcause) toOtherMsg = `${toOtherMsg}\n 学校反馈:${refcause}`;
         for (const user of users) {
           const openid = user.openid;
           const date = await this.ctx.service.util.updatedate();
-          this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
+          this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', toOtherMsg, date, remark);
         }
         const _class = await this.cmodel.findById(student.classid);
         // 通知班主任学生请假通过
@@ -83,7 +87,7 @@ class LeaveService extends CrudService {
         if (headuser) {
           const openid = headuser.openid;
           const date = await this.ctx.service.util.updatedate();
-          this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
+          this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', toOtherMsg, date, remark);
         }
         const leadstu = await this.smodel.findOne({ classid: student.classid, job: '班长' });
         if (leadstu) {
@@ -91,7 +95,7 @@ class LeaveService extends CrudService {
           if (leaduser) {
             const openid = leaduser.openid;
             const date = await this.ctx.service.util.updatedate();
-            this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', detail, date, remark);
+            this.ctx.service.weixin.sendTemplateMsg(this.ctx.app.config.REVIEW_TEMPLATE_ID, openid, '您有一个新的通知', toOtherMsg, date, remark);
           }
         }
         const stuopenid = stuuser.openid;