Commit 1243d2a0 authored by liuchao's avatar liuchao

no message

parent 489f6648
...@@ -265,6 +265,12 @@ ...@@ -265,6 +265,12 @@
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.15-beta2</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
......
package com.qiankun.controller.rainbowplan; package com.qiankun.controller.rainbowplan;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List; import java.util.List;
import java.util.ResourceBundle; import java.util.ResourceBundle;
...@@ -9,6 +13,18 @@ import javax.servlet.http.HttpServletResponse; ...@@ -9,6 +13,18 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.PaperSize;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFPrintSetup;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -183,4 +199,188 @@ public class RainbowPlanWebController extends BaseController<Object>{ ...@@ -183,4 +199,188 @@ public class RainbowPlanWebController extends BaseController<Object>{
return view; return view;
} }
@RequestMapping("/rainbow/wish/export")
public void export(WishVo wishVo, HttpServletResponse response, HttpServletRequest request) throws Exception {
try {
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
response.setContentType("application/x-download");
String fileName = "wish.xlsx";
fileName = URLEncoder.encode(fileName, "UTF-8");
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("心愿");
sheet.setMargin(HSSFSheet.TopMargin,( double ) 0.5 ); // 上边距
sheet.setMargin(HSSFSheet.BottomMargin,( double ) 0.5 ); // 下边距
sheet.setMargin(HSSFSheet.LeftMargin,( double ) 0.4 ); // 左边距
sheet.setMargin(HSSFSheet.RightMargin,( double ) 0.2 ); // 右边距
XSSFPrintSetup print = sheet.getPrintSetup();
print.setLandscape(true);
print.setPaperSize(PaperSize.A4_PAPER);
sheet.setDefaultRowHeight((short) (2 * 256));//设置行高
sheet.setColumnWidth(0,2500);//设置列宽
sheet.setColumnWidth(1,2500);
sheet.setColumnWidth(2,3500);
sheet.setColumnWidth(3,1500);
sheet.setColumnWidth(4,4000);
sheet.setColumnWidth(5,4000);
sheet.setColumnWidth(6,6000);
sheet.setColumnWidth(7,3000);
sheet.setColumnWidth(8,3000);
sheet.setColumnWidth(9,6000);
XSSFFont font = wb.createFont();
font.setFontName("宋体");
font.setFontHeightInPoints((short) 12);
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
XSSFCellStyle cellTopStyle=wb.createCellStyle();
cellTopStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellTopStyle.setBorderBottom(BorderStyle.THIN); //setBorderBottom(CellStyle.BORDER_THIN);
cellTopStyle.setBorderLeft(BorderStyle.THIN);//setBorderLeft(CellStyle.BORDER_THIN);
cellTopStyle.setBorderRight(BorderStyle.THIN);//setBorderRight(CellStyle.BORDER_THIN);
cellTopStyle.setBorderTop(BorderStyle.THIN);//setBorderTop(CellStyle.BORDER_THIN);
cellTopStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellTopStyle.setFont(font);
XSSFRow row = sheet.createRow(0);
row.setHeightInPoints(30);
XSSFCell cell = row.createCell(0);
cell.setCellValue("编号 ");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(1);
cell.setCellValue("宝宝昵称 ");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(2);
cell.setCellValue("宝宝真实姓名");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(3);
cell.setCellValue("性别");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(4);
cell.setCellValue("年龄");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(5);
cell.setCellValue("楼层床号");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(6);
cell.setCellValue("心愿礼物");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(7);
cell.setCellValue("收件人姓名");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(8);
cell.setCellValue("联系方式");
cell.setCellStyle(cellTopStyle);
cell = row.createCell(9);
cell.setCellValue("邮寄地址");
cell.setCellStyle(cellTopStyle);
XSSFCellStyle cellStyle=wb.createCellStyle();
cellStyle.setWrapText(true);
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
cellStyle.setBorderBottom(BorderStyle.THIN); //setBorderBottom(CellStyle.BORDER_THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);//setBorderLeft(CellStyle.BORDER_THIN);
cellStyle.setBorderRight(BorderStyle.THIN);//setBorderRight(CellStyle.BORDER_THIN);
cellStyle.setBorderTop(BorderStyle.THIN);//setBorderTop(CellStyle.BORDER_THIN);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
IPageList<Wish> wishPage = wishDao.findPages(wishVo.getSearchStr(), wishVo.getActivityId(), wishVo.getStatus(),
wishVo.getOrder(), wishVo.getSort(), new Hints(getStartRow(request), getPageCount(request)));
List<Wish> wish = wishPage.getRecords();
XSSFRow rows;
XSSFCell cells;
for (int i = 0; i < wish.size(); i++) {
// 第三步:在这个sheet页里创建一行
rows = sheet.createRow(i+1);
// 第四步:在该行创建一个单元格
Wish data = wish.get(i);
cells = rows.createCell(0);
cells.setCellValue(data.getCode());
cells.setCellStyle(cellStyle);
// 第五步:在该单元格里设置值
cells = rows.createCell(1);
cells.setCellValue(data.getChildren().getNickName());
cells.setCellStyle(cellStyle);
cells = rows.createCell(2);
cells.setCellValue(data.getChildren().getName());
cells.setCellStyle(cellStyle);
cells = rows.createCell(3);
String gender = "男";
if ("2".equals(data.getChildren().getGender()))
gender = "女";
cells.setCellValue(gender);
cells.setCellStyle(cellStyle);
cells = rows.createCell(4);
cells.setCellValue(data.getChildren().getBirthday());
cells.setCellStyle(cellStyle);
cells = rows.createCell(5);
cells.setCellValue(data.getChildren().getBedNum());
cells.setCellStyle(cellStyle);
cells = rows.createCell(6);
cells.setCellValue(data.getContent());
cells.setCellStyle(cellStyle);
cells = rows.createCell(7);
cells.setCellValue(data.getChildren().getReceiveName());
cells.setCellStyle(cellStyle);
cells = rows.createCell(8);
cells.setCellValue(data.getChildren().getConnectTel());
cells.setCellStyle(cellStyle);
cells = rows.createCell(9);
cells.setCellValue(data.getChildren().getReceiveAddress());
cells.setCellStyle(cellStyle);
}
OutputStream out = response.getOutputStream();
wb.write(out);
out.close();
wb.close();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
...@@ -44,6 +44,11 @@ ...@@ -44,6 +44,11 @@
修改状态 修改状态
</button> </button>
<button class="btn btn-sm btn-success" onclick="wish.exportExcel()">
<i class="icon-share bigger-110"></i>
导出
</button>
</div> </div>
<div class="pull-right"> <div class="pull-right">
......
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font> 姓名 </label> <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <!--font color="red">*</font--> 姓名 </label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" id="name" name="name" value="${user.name}" class="col-xs-10 col-sm-10" /> <input type="text" id="name" name="name" value="${user.name}" class="col-xs-10 col-sm-10" />
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> <font color="red">*</font> 出生日期 </label> <label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> <!--font color="red">*</font--> 出生日期 </label>
<div class="col-sm-9"> <div class="col-sm-9">
<input class="col-xs-10 col-sm-10" id="birthday" name="birthday" type="text" autocomplete="off" data-date-format="yyyy-mm-dd" value="${user.birthday}"/> <input class="col-xs-10 col-sm-10" id="birthday" name="birthday" type="text" autocomplete="off" data-date-format="yyyy-mm-dd" value="${user.birthday}"/>
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> <font color="red">*</font> 证件类型 </label> <label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> <!--font color="red">*</font--> 证件类型 </label>
<div class="col-sm-9"> <div class="col-sm-9">
<select class="col-xs-10 col-sm-10" id="paperType" name="paperType"> <select class="col-xs-10 col-sm-10" id="paperType" name="paperType">
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> <font color="red">*</font> 证件号码 </label> <label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> <!--font color="red">*</font--> 证件号码 </label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" id="paperId" name="paperId" value="${user.paperId}" class="col-xs-10 col-sm-10" /> <input type="text" id="paperId" name="paperId" value="${user.paperId}" class="col-xs-10 col-sm-10" />
...@@ -165,7 +165,7 @@ ...@@ -165,7 +165,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> <font color="red">*</font> 籍贯 </label> <label class="col-sm-3 control-label no-padding-right" for="form-input-readonly"> <!--font color="red">*</font--> 籍贯 </label>
<div class="col-sm-9"> <div class="col-sm-9">
<select class="col-xs-10 col-sm-10" id="nativePlace" name="nativePlace"> <select class="col-xs-10 col-sm-10" id="nativePlace" name="nativePlace">
...@@ -194,7 +194,7 @@ ...@@ -194,7 +194,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font> 经常居住地</label> <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <!--font color="red">*</font--> 经常居住地</label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" id="addr" name="addr" value="${user.addr}" class="col-xs-10 col-sm-10" /> <input type="text" id="addr" name="addr" value="${user.addr}" class="col-xs-10 col-sm-10" />
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font> 本人手机 </label> <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <!--font color="red">*</font--> 本人手机 </label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" id="mobile" name="mobile" value="${user.mobile}" class="col-xs-10 col-sm-10" /> <input type="text" id="mobile" name="mobile" value="${user.mobile}" class="col-xs-10 col-sm-10" />
...@@ -292,7 +292,7 @@ ...@@ -292,7 +292,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font>QQ号码 </label> <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <!--font color="red">*</font-->QQ号码 </label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" id="qq" name="qq" value="${user.qq}" class="col-xs-10 col-sm-10" /> <input type="text" id="qq" name="qq" value="${user.qq}" class="col-xs-10 col-sm-10" />
...@@ -378,7 +378,7 @@ ...@@ -378,7 +378,7 @@
<div class="col-xs-4"> <div class="col-xs-4">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font>姓名 </label> <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <!--font color="red">*</font-->姓名 </label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" id="contactsName1" name="contactsName1" value="${user.contactsName1}" class="col-xs-10 col-sm-10" /> <input type="text" id="contactsName1" name="contactsName1" value="${user.contactsName1}" class="col-xs-10 col-sm-10" />
...@@ -422,7 +422,7 @@ ...@@ -422,7 +422,7 @@
<div class="col-xs-4"> <div class="col-xs-4">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font>手机</label> <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <!--font color="red">*</font-->手机</label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" id="contactsMobile1" name="contactsMobile1" value="${user.contactsMobile1}" class="col-xs-10 col-sm-10" /> <input type="text" id="contactsMobile1" name="contactsMobile1" value="${user.contactsMobile1}" class="col-xs-10 col-sm-10" />
...@@ -449,7 +449,7 @@ ...@@ -449,7 +449,7 @@
<div class="col-xs-4"> <div class="col-xs-4">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font>姓名 </label> <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <!--font color="red">*</font-->姓名 </label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" id="contactsName2" name="contactsName2" value="${user.contactsName2}" class="col-xs-10 col-sm-10" /> <input type="text" id="contactsName2" name="contactsName2" value="${user.contactsName2}" class="col-xs-10 col-sm-10" />
...@@ -492,7 +492,7 @@ ...@@ -492,7 +492,7 @@
<div class="col-xs-4"> <div class="col-xs-4">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <font color="red">*</font>手机</label> <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> <!--font color="red">*</font-->手机</label>
<div class="col-sm-9"> <div class="col-sm-9">
<input type="text" id="contactsMobile2" name="contactsMobile2" value="${user.contactsMobile2}" class="col-xs-10 col-sm-10" /> <input type="text" id="contactsMobile2" name="contactsMobile2" value="${user.contactsMobile2}" class="col-xs-10 col-sm-10" />
......
...@@ -51,7 +51,37 @@ $(document).ready(function(){ ...@@ -51,7 +51,37 @@ $(document).ready(function(){
var wish = { var wish = {
exportExcel : function(){
var activityId = $("#activity").val();
var searchStr = $("#searchStr").val();
var status = $("#status").val();
var url = webPath + "/rainbow/wish/export";
if(activityId != "" || searchStr != "" || status != ""){
var param = "?"
if (activityId != ""){
param = param + "activityId=" + activityId ;
}
if (status != ""){
if (param == "?"){
param = param + "status=" + status;
} else {
param = param + "&status=" + status;
}
}
if (searchStr != ""){
if (param == "?"){
param = param + "searchStr=" + searchStr;
} else {
param = param + "&searchStr=" + searchStr;
}
}
url = url + param;
}
window.open(url);
},
search : function(){ search : function(){
var activityId = $("#activity").val(); var activityId = $("#activity").val();
var searchStr = $("#searchStr").val(); var searchStr = $("#searchStr").val();
......
...@@ -12,16 +12,37 @@ $(document).ready(function(){ ...@@ -12,16 +12,37 @@ $(document).ready(function(){
required : true required : true
}, },
"birthday" : { "birthday" : {
required : true required : function(){
var role = $("#role").val();
if ( role == 1){
return false;
}else {
return true;
}
}
}, },
"paperId" : { "paperId" : {
required : true required : true
}, },
"nativePlace" : { "nativePlace" : {
required : true required : function(){
var role = $("#role").val();
if ( role == 1){
return false;
}else {
return true;
}
}
}, },
"addr" : { "addr" : {
required : true required : function(){
var role = $("#role").val();
if ( role == 1){
return false;
}else {
return true;
}
}
}, },
"mobile" : { "mobile" : {
required : true, required : true,
...@@ -30,23 +51,58 @@ $(document).ready(function(){ ...@@ -30,23 +51,58 @@ $(document).ready(function(){
minlength:11 minlength:11
}, },
"qq": { "qq": {
required : true required : function(){
var role = $("#role").val();
if ( role == 1){
return false;
}else {
return true;
}
}
}, },
"contactsName1" : { "contactsName1" : {
required : true required : function(){
var role = $("#role").val();
if ( role == 1){
return false;
}else {
return true;
}
}
}, },
"contactsMobile1" : { "contactsMobile1" : {
required : true, required : function(){
var role = $("#role").val();
if ( role == 1){
return false;
}else {
return true;
}
},
isMobile: true, isMobile: true,
maxlength:11, maxlength:11,
minlength:11 minlength:11
}, },
"contactsName2" : { "contactsName2" : {
required : true required : function(){
var role = $("#role").val();
if ( role == 1){
return false;
}else {
return true;
}
}
}, },
"contactsMobile2" : { "contactsMobile2" : {
required : true, required : function(){
var role = $("#role").val();
if ( role == 1){
return false;
}else {
return true;
}
},
isMobile: true, isMobile: true,
maxlength:11, maxlength:11,
minlength:11 minlength:11
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment