Skip to content

Commit

Permalink
更新用户编辑的一个bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lenve committed Jan 18, 2018
1 parent cf628da commit 8df22fb
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 20 deletions.
4 changes: 4 additions & 0 deletions hrserver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
90 changes: 90 additions & 0 deletions hrserver/src/main/java/org/sang/common/EmailUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package org.sang.common;

import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.*;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.MimeUtility;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.Properties;

/**
* Created by sang on 2017/9/20.
*/
public class EmailUtils {
public static void sendEmail(String a, String b, String c) {
try {
Properties properties = new Properties();
properties.setProperty("mail.host", "smtp.qq.com");
properties.setProperty("mail.transport.protocol", "smtp");
properties.setProperty("mail.smtp.auth", "true");
properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.setProperty("mail.smtp.port", "465");
Session session = Session.getDefaultInstance(properties);
session.setDebug(true);
Transport transport = session.getTransport();
transport.connect("smtp.qq.com", "[email protected]", "ofuyyplaqaqpiefi");
//创建一封邮件
MimeMessage mimeMessage = new MimeMessage(session);
mimeMessage.addRecipients(Message.RecipientType.TO, "[email protected]");//设置收信人
mimeMessage.addRecipients(Message.RecipientType.CC, "[email protected]");//抄送
mimeMessage.setFrom("[email protected]");//邮件发送人
mimeMessage.setSubject("测试邮件主题");//邮件主题

MimeMultipart mixed = new MimeMultipart("mixed");
mimeMessage.setContent(mixed);//设置整封邮件的MIME消息体为混合的组合关系

MimeBodyPart attach1 = new MimeBodyPart();//创建附件1
MimeBodyPart attach2 = new MimeBodyPart();//创建附件2
MimeBodyPart content = new MimeBodyPart();//创建邮件正文

mixed.addBodyPart(attach1);//将附件一添加到MIME消息体中
mixed.addBodyPart(attach2);//将附件二添加到MIME消息体中
mixed.addBodyPart(content);//将正文添加到消息体中

FileDataSource fds1 = new FileDataSource(new File("C:\\Users\\sang\\Desktop\\1.png"));//构造附件一的数据源
DataHandler dh1 = new DataHandler(fds1);//数据处理
attach1.setDataHandler(dh1);//设置附件一的数据源
attach1.setFileName("1.png");//设置附件一的文件名

//附件二的操作与附件一类似,这里就不一一注释了
FileDataSource fds2 = new FileDataSource(new File("C:\\Users\\sang\\Desktop\\博客笔记.xlsx"));
DataHandler dh2 = new DataHandler(fds2);
attach2.setDataHandler(dh2);
attach2.setFileName(MimeUtility.encodeText("博客笔记.xlsx"));//设置文件名时,如果有中文,可以通过MimeUtility类中的encodeText方法进行编码,避免乱码

MimeMultipart bodyMimeMultipart = new MimeMultipart("related");//设置正文的MIME类型
content.setContent(bodyMimeMultipart);//将bodyMimeMultipart添加到正文消息体中

MimeBodyPart bodyPart = new MimeBodyPart();//正文的HTML部分
bodyPart.setContent("<h1>Hello大家好,这是一封测试邮件<img src='cid:2.png'/></h1>","text/html;charset=utf-8");

MimeBodyPart picPart = new MimeBodyPart();//正文的图片部分
DataHandler dataHandler = new DataHandler(new FileDataSource("C:\\Users\\sang\\Desktop\\2.png"));
picPart.setDataHandler(dataHandler);
picPart.setContentID("2.png");

//将正文的HTML和图片部分分别添加到bodyMimeMultipart中
bodyMimeMultipart.addBodyPart(bodyPart);
bodyMimeMultipart.addBodyPart(picPart);

mimeMessage.saveChanges();

transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());//发送邮件,第二个参数为收件人
transport.close();
} catch (NoSuchProviderException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
sendEmail(null, null, null);
}
}
2 changes: 1 addition & 1 deletion hrserver/src/main/resources/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>微人事</title><link href=/static/css/app.f2615d5e193d755da4ecf8e1fb3dab07.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.be68f676a39fdca2f847.js></script><script type=text/javascript src=/static/js/vendor.59f7a0d2e440c37c0dac.js></script><script type=text/javascript src=/static/js/app.c9854a01d31fe48e8754.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>微人事</title><link href=/static/css/app.f2615d5e193d755da4ecf8e1fb3dab07.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=/static/js/manifest.88d3cb88712c4c25b743.js></script><script type=text/javascript src=/static/js/vendor.59f7a0d2e440c37c0dac.js></script><script type=text/javascript src=/static/js/app.c9854a01d31fe48e8754.js></script></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

31 changes: 21 additions & 10 deletions vuehr/src/components/emp/EmpBasic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@
<el-col :span="5">
所属部门:
<el-popover
v-model="showOrHidePop"
v-model="showOrHidePop2"
placement="right"
title="请选择部门"
trigger="manual">
<el-tree :data="deps" :default-expand-all="true" :props="defaultProps" :expand-on-click-node="false"
@node-click="handleNodeClick"></el-tree>
@node-click="handleNodeClick2"></el-tree>
<div slot="reference"
style="width: 130px;height: 26px;display: inline-flex;font-size:13px;border: 1px;border-radius: 5px;border-style: solid;padding-left: 13px;box-sizing:border-box;border-color: #dcdfe6;cursor: pointer;align-items: center"
@click.left="showDepTree" v-bind:style="{color: depTextColor}">{{emp.departmentName}}
@click="showDepTree2" v-bind:style="{color: depTextColor}">{{emp.departmentName}}
</div>
</el-popover>
</el-col>
Expand Down Expand Up @@ -629,6 +629,7 @@
tableLoading: false,
advanceSearchViewVisible: false,
showOrHidePop: false,
showOrHidePop2: false,
emp: {
name: '',
gender: '',
Expand Down Expand Up @@ -820,8 +821,8 @@
var data = resp.data;
_this.$message({type: data.status, message: data.msg});
_this.dialogVisible = false;
_this.loadEmps();
_this.emptyEmpData();
_this.loadEmps();
}
})
} else {
Expand All @@ -833,8 +834,8 @@
var data = resp.data;
_this.$message({type: data.status, message: data.msg});
_this.dialogVisible = false;
_this.emptyEmpData();
_this.loadEmps();
_this.emptyEmpData();
}
})
}
Expand All @@ -850,12 +851,21 @@
showDepTree(){
this.showOrHidePop = !this.showOrHidePop;
},
showDepTree2(){
this.showOrHidePop2 = !this.showOrHidePop2;
},
handleNodeClick(data) {
this.emp.departmentName = data.name;
this.emp.departmentId = data.id;
this.showOrHidePop = false;
this.depTextColor = '#606266';
},
handleNodeClick2(data) {
this.emp.departmentName = data.name;
this.emp.departmentId = data.id;
this.showOrHidePop2 = false;
this.depTextColor = '#606266';
},
initData(){
var _this = this;
this.getRequest("/emp/basic/basicdata").then(resp=> {
Expand All @@ -871,6 +881,7 @@
})
},
showEditEmpView(row){
console.log(row)
this.dialogTitle = "编辑员工";
this.emp = row;
this.emp.birthday = this.formatDate(row.birthday);
Expand All @@ -884,11 +895,11 @@
this.emp.departmentName = row.department.name;
this.emp.jobLevelId = row.jobLevel.id;
this.emp.posId = row.position.id;
delete this.emp.department;
delete this.emp.jobLevel;
delete this.emp.position;
delete this.emp.nation;
delete this.emp.politicsStatus;
// delete this.emp.department;
// delete this.emp.jobLevel;
// delete this.emp.position;
// delete this.emp.nation;
// delete this.emp.politicsStatus;
delete this.emp.workAge;
delete this.emp.notWorkDate;
this.dialogVisible = true;
Expand Down

0 comments on commit 8df22fb

Please sign in to comment.