项目导出
parent
412dd5de76
commit
b49786ef4f
|
|
@ -61,7 +61,7 @@ public class BaseController {
|
|||
* @param response HttpServletResponse
|
||||
* @param fileName 文件名
|
||||
*/
|
||||
protected void downloadHearder(HttpServletResponse response, String fileName, String contentType) {
|
||||
protected void downloadHeader(HttpServletResponse response, String fileName, String contentType) {
|
||||
response.setContentType(contentType);
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
try {
|
||||
|
|
@ -72,10 +72,10 @@ public class BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see BaseController {@link #downloadHearder(HttpServletResponse, String, String)}
|
||||
* @see BaseController {@link #downloadHeader(HttpServletResponse, String, String)}
|
||||
*/
|
||||
protected void downloadHearder(HttpServletResponse response, String fileName) {
|
||||
downloadHearder(response, fileName, "application/octet-stream");
|
||||
downloadHeader(response, fileName, "application/octet-stream");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import cn.palmte.work.model.DeptRepository;
|
|||
import cn.palmte.work.model.Project;
|
||||
import cn.palmte.work.service.ProjectService;
|
||||
import cn.palmte.work.utils.InterfaceUtil;
|
||||
import cn.palmte.work.utils.Utils;
|
||||
import cn.palmte.work.utils.excel.ExportUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -16,6 +18,8 @@ import org.springframework.web.bind.annotation.InitBinder;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
|
@ -33,6 +37,9 @@ public class ProjectController extends BaseController{
|
|||
@Autowired
|
||||
private DeptRepository deptRepository;
|
||||
|
||||
/**
|
||||
* 项目列表
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
public String list(@RequestParam(value = "keywords",required = false) String keywords,
|
||||
@RequestParam(value = PAGE_NUMBER, defaultValue = DEFAULT_PAGE_NUMBER) int pageNumber,
|
||||
|
|
@ -46,6 +53,19 @@ public class ProjectController extends BaseController{
|
|||
return "admin/project_list";
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目导出
|
||||
*/
|
||||
@RequestMapping("/export")
|
||||
public void export(@RequestParam(value = "keywords",required = false) String keywords, HttpServletResponse httpServletResponse) throws IOException {
|
||||
Map<String, String> searchInfo = getSearchInfo(keywords);
|
||||
downloadHeader(httpServletResponse , Utils.generateExcelName("项目报表"), "application/octet-stream");
|
||||
String[] headers = {"项目名称","项目类型","项目状态","审核状态","当前审核人","项目创建者","部门名称","项目开始时间","项目结束时间"};
|
||||
String[] exportColumns = {"name","typeDesc","statusDesc","approveStatusDesc","approveName","creatorName","deptName","startDate","endDate"};
|
||||
ExportUtils.exportToExcel(headers, exportColumns, 1, 10000,
|
||||
httpServletResponse.getOutputStream(), (pN, pS) -> projectService.list(searchInfo, pN, pS).getList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增,至项目概算
|
||||
|
|
|
|||
|
|
@ -215,9 +215,22 @@
|
|||
<script type="text/javascript">
|
||||
$(function () {
|
||||
|
||||
var keywordsObj = {};
|
||||
$("#submit-btn").on("click", function () {
|
||||
$("#pageNumber").val(1);
|
||||
setKeywords();
|
||||
$("#listForm").attr("action","${base}/project/list");
|
||||
$("#listForm").submit();
|
||||
});
|
||||
|
||||
$("#submit-btn-export").on("click", function () {
|
||||
setKeywords();
|
||||
$("#listForm").attr("action","${base}/project/export");
|
||||
$("#listForm").submit();
|
||||
});
|
||||
|
||||
|
||||
function setKeywords() {
|
||||
var keywordsObj = {};
|
||||
if ($("#name").val())
|
||||
keywordsObj.name = $("#name").val();
|
||||
if ($("#creatorName").val())
|
||||
|
|
@ -241,8 +254,7 @@
|
|||
console.log("keywords = " + keywords);
|
||||
|
||||
$("#keywords").val(keywords);
|
||||
$("#listForm").submit();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue