Commit 2578ee809c958dfa487ec73198891ef473dc5cd6

Authored by BSTH
1 parent e319593a

更新

src/main/java/com/bsth/controller/DownloadController.java
@@ -28,11 +28,10 @@ public class DownloadController @@ -28,11 +28,10 @@ public class DownloadController
28 { 28 {
29 29
30 @RequestMapping("download") 30 @RequestMapping("download")
31 - public ResponseEntity<byte[]> download(String jName,String lpName) throws IOException {  
32 - String moudelPath = this.getClass().getResource("/").getPath()+ "static\\pages\\forms\\export\\"+jName+".xls";  
33 -// System.out.println(moudelPath);  
34 - String fileName = jName+lpName+".xls";  
35 -// String path="D:\\export\\target\\"+jName+".xls"; 31 + public ResponseEntity<byte[]> download(String fileName) throws IOException {
  32 + fileName = fileName+".xls";
  33 + String moudelPath = this.getClass().getResource("/").getPath()+ "static\\pages\\forms\\export\\"+fileName;
  34 +// String path="D:\\export\\target\\"+jName+".xls";
36 File file=new File(moudelPath); 35 File file=new File(moudelPath);
37 HttpHeaders headers = new HttpHeaders(); 36 HttpHeaders headers = new HttpHeaders();
38 String realFileName=new String(fileName.getBytes("UTF-8"),"iso-8859-1");//为了解决中文名称乱码问题 37 String realFileName=new String(fileName.getBytes("UTF-8"),"iso-8859-1");//为了解决中文名称乱码问题
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
@@ -300,8 +300,8 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -300,8 +300,8 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
300 } 300 }
301 301
302 @RequestMapping(value = "/dailyInfo") 302 @RequestMapping(value = "/dailyInfo")
303 - public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date) {  
304 - return scheduleRealInfoService.dailyInfo(line, date); 303 + public List<Map<String, Object>> dailyInfo(@RequestParam String line, @RequestParam String date,@RequestParam String type) {
  304 + return scheduleRealInfoService.dailyInfo(line, date, type);
305 } 305 }
306 306
307 @RequestMapping(value = "/historyMessage") 307 @RequestMapping(value = "/historyMessage")
@@ -336,9 +336,33 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -336,9 +336,33 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
336 @RequestParam String endDate,@RequestParam String lpName,@RequestParam String code) { 336 @RequestParam String endDate,@RequestParam String lpName,@RequestParam String code) {
337 return scheduleRealInfoService.correctForm(line, startDate, endDate, lpName, code); 337 return scheduleRealInfoService.correctForm(line, startDate, endDate, lpName, code);
338 } 338 }
339 - 339 + /**
  340 + * @Title queryListWaybill
  341 + * @Description 查询行车路单列表
  342 + * @param jName 驾驶员名字
  343 + * @param clZbh 车辆自编号(内部编号)
  344 + * @param lpName 路牌
  345 + * @return
  346 + */
340 @RequestMapping(value="/queryListWaybill") 347 @RequestMapping(value="/queryListWaybill")
341 public List<ScheduleRealInfo> queryListWaybill(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName){ 348 public List<ScheduleRealInfo> queryListWaybill(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName){
342 return scheduleRealInfoService.queryListWaybill(jName, clZbh,lpName); 349 return scheduleRealInfoService.queryListWaybill(jName, clZbh,lpName);
343 } 350 }
  351 +
  352 + @RequestMapping(value="/statisticsDaily")
  353 + public List<Map<String,Object>> statisticsDaily(@RequestParam String line,@RequestParam String date,@RequestParam String xlName){
  354 + return scheduleRealInfoService.statisticsDaily(line, date,xlName);
  355 + }
  356 +
  357 + /**
  358 + * @Title: scheduleDaily
  359 + * @Description: TODO(调度日报表)
  360 + * @param line 线路
  361 + * @param date 时间
  362 + * @return
  363 + */
  364 + @RequestMapping(value="/scheduleDaily")
  365 + public List<Object> scheduleDaily(@RequestParam String line,@RequestParam String date){
  366 + return scheduleRealInfoService.scheduleDaily(line,date);
  367 + }
344 } 368 }
src/main/java/com/bsth/controller/sys/UserController.java
@@ -4,23 +4,30 @@ import javax.servlet.http.HttpServletRequest; @@ -4,23 +4,30 @@ import javax.servlet.http.HttpServletRequest;
4 import javax.servlet.http.HttpServletResponse; 4 import javax.servlet.http.HttpServletResponse;
5 import javax.servlet.http.HttpSession; 5 import javax.servlet.http.HttpSession;
6 6
  7 +import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.security.authentication.BadCredentialsException; 8 import org.springframework.security.authentication.BadCredentialsException;
8 import org.springframework.security.core.Authentication; 9 import org.springframework.security.core.Authentication;
9 import org.springframework.security.core.context.SecurityContextHolder; 10 import org.springframework.security.core.context.SecurityContextHolder;
  11 +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
10 import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; 12 import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
11 import org.springframework.security.web.authentication.session.SessionAuthenticationException; 13 import org.springframework.security.web.authentication.session.SessionAuthenticationException;
12 import org.springframework.web.bind.annotation.RequestMapping; 14 import org.springframework.web.bind.annotation.RequestMapping;
  15 +import org.springframework.web.bind.annotation.RequestParam;
13 import org.springframework.web.bind.annotation.RestController; 16 import org.springframework.web.bind.annotation.RestController;
14 import org.springframework.web.servlet.ModelAndView; 17 import org.springframework.web.servlet.ModelAndView;
15 18
16 import com.bsth.controller.BaseController; 19 import com.bsth.controller.BaseController;
17 import com.bsth.entity.sys.SysUser; 20 import com.bsth.entity.sys.SysUser;
18 import com.bsth.security.util.SecurityUtils; 21 import com.bsth.security.util.SecurityUtils;
  22 +import com.bsth.service.sys.SysUserService;
19 23
20 @RestController 24 @RestController
21 @RequestMapping("user") 25 @RequestMapping("user")
22 public class UserController extends BaseController<SysUser, Integer>{ 26 public class UserController extends BaseController<SysUser, Integer>{
23 27
  28 + @Autowired
  29 + SysUserService sysUserService;
  30 +
24 /** 31 /**
25 * 32 *
26 * @Title: loginFailure 33 * @Title: loginFailure
@@ -65,4 +72,45 @@ public class UserController extends BaseController&lt;SysUser, Integer&gt;{ @@ -65,4 +72,45 @@ public class UserController extends BaseController&lt;SysUser, Integer&gt;{
65 public SysUser currentUser(){ 72 public SysUser currentUser(){
66 return SecurityUtils.getCurrentUser(); 73 return SecurityUtils.getCurrentUser();
67 } 74 }
  75 +
  76 + /**
  77 + * @Title changeEnabled
  78 + * @Description: TODO(改变用户状态)
  79 + * @param id 用户ID
  80 + * @param enabled 状态
  81 + * @return
  82 + */
  83 + @RequestMapping("/changeEnabled")
  84 + public int changeEnabled(@RequestParam int id,@RequestParam int enabled){
  85 + return sysUserService.changeEnabled(id,enabled);
  86 + }
  87 +
  88 + /**
  89 + * @Title changePWD
  90 + * @Description: TODO(修改密码)
  91 + * @param oldPWD 原始密码
  92 + * @param newwPWD 新密码
  93 + * @param cnewPWD 确认新密码
  94 + * @return
  95 + */
  96 + @RequestMapping("/changePWD")
  97 + public String changePWD(@RequestParam String oldPWD,@RequestParam String newPWD,@RequestParam String cnewPWD){
  98 + SysUser sysUser = SecurityUtils.getCurrentUser();
  99 + String msg = "";
  100 + if(new BCryptPasswordEncoder(4).matches(oldPWD, sysUser.getPassword())){
  101 + if(oldPWD.equals(newPWD)){
  102 + msg = "新密码不能跟原始密码一样!";
  103 + }else{
  104 + if(newPWD.equals(cnewPWD)){
  105 + sysUserService.changePWD(sysUser.getId(),newPWD);
  106 + msg = "修改成功!";
  107 + }else{
  108 + msg= "新密码两次输入不一致!";
  109 + }
  110 + }
  111 + }else{
  112 + msg = "原始密码错误!";
  113 + }
  114 + return msg;
  115 + }
68 } 116 }
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
@@ -54,4 +54,10 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI @@ -54,4 +54,10 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
54 54
55 @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by fcsj") 55 @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by fcsj")
56 List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName); 56 List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName);
  57 +
  58 + @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2")
  59 + List<ScheduleRealInfo> statisticsDaily(String line,String date);
  60 +
  61 + @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2")
  62 + List<ScheduleRealInfo> scheduleDaily(String line,String date);
57 } 63 }
src/main/java/com/bsth/repository/sys/SysUserRepository.java
1 package com.bsth.repository.sys; 1 package com.bsth.repository.sys;
2 2
  3 +import org.springframework.data.jpa.repository.Modifying;
  4 +import org.springframework.data.jpa.repository.Query;
3 import org.springframework.stereotype.Repository; 5 import org.springframework.stereotype.Repository;
  6 +import org.springframework.transaction.annotation.Transactional;
4 7
5 import com.bsth.entity.sys.SysUser; 8 import com.bsth.entity.sys.SysUser;
6 import com.bsth.repository.BaseRepository; 9 import com.bsth.repository.BaseRepository;
@@ -10,4 +13,13 @@ public interface SysUserRepository extends BaseRepository&lt;SysUser, Integer&gt;{ @@ -10,4 +13,13 @@ public interface SysUserRepository extends BaseRepository&lt;SysUser, Integer&gt;{
10 13
11 SysUser findByUserName(String userName); 14 SysUser findByUserName(String userName);
12 15
  16 + @Transactional
  17 + @Modifying
  18 + @Query(value="update bsth_c_sys_user set enabled=?2 where id=?1",nativeQuery=true)
  19 + int changeEnabled(int id,int enabled);
  20 +
  21 + @Transactional
  22 + @Modifying
  23 + @Query(value="update bsth_c_sys_user set password=?2 where id=?1",nativeQuery=true)
  24 + int changePWD(int id,String newPWD);
13 } 25 }
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
@@ -62,7 +62,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L @@ -62,7 +62,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
62 62
63 List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName); 63 List<ScheduleRealInfo> exportWaybill(String jName,String clZbh,String lpName);
64 64
65 - List<Map<String,Object>> dailyInfo(String line,String date); 65 + List<Map<String,Object>> dailyInfo(String line,String date,String type);
66 66
67 List<Object[]> historyMessage(String line,String date,String code); 67 List<Object[]> historyMessage(String line,String date,String code);
68 68
@@ -95,4 +95,8 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L @@ -95,4 +95,8 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
95 List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName); 95 List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName);
96 96
97 Map<String, Object> removeChildTask(Long taskId); 97 Map<String, Object> removeChildTask(Long taskId);
  98 +
  99 + List<Map<String,Object>> statisticsDaily(String line,String date,String xlName);
  100 +
  101 + List<Object> scheduleDaily(String line,String date);
98 } 102 }
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -42,7 +42,9 @@ import com.bsth.service.SectionRouteService; @@ -42,7 +42,9 @@ import com.bsth.service.SectionRouteService;
42 import com.bsth.service.impl.BaseServiceImpl; 42 import com.bsth.service.impl.BaseServiceImpl;
43 import com.bsth.service.realcontrol.ScheduleRealInfoService; 43 import com.bsth.service.realcontrol.ScheduleRealInfoService;
44 import com.bsth.service.realcontrol.buffer.ScheduleBuffer; 44 import com.bsth.service.realcontrol.buffer.ScheduleBuffer;
  45 +import com.bsth.util.ReportRelatedUtils;
45 import com.bsth.util.ReportUtils; 46 import com.bsth.util.ReportUtils;
  47 +import com.bsth.util.TimeUtils;
46 import com.bsth.util.TransGPS; 48 import com.bsth.util.TransGPS;
47 import com.bsth.util.TransGPS.Location; 49 import com.bsth.util.TransGPS.Location;
48 import com.bsth.vehicle.BorrowCenter; 50 import com.bsth.vehicle.BorrowCenter;
@@ -87,7 +89,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -87,7 +89,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
87 Logger logger = LoggerFactory.getLogger(this.getClass()); 89 Logger logger = LoggerFactory.getLogger(this.getClass());
88 90
89 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), 91 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
90 - sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm"), sdfShort = new SimpleDateFormat("HH:mm"); 92 + sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm"), sdfShort = new SimpleDateFormat("HH:mm"),
  93 + sdfSimple = new SimpleDateFormat("yyyyMMdd");
91 94
92 @Override 95 @Override
93 public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) { 96 public Map<String, Collection<ScheduleRealInfo>> findByLines(String lines) {
@@ -426,13 +429,16 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -426,13 +429,16 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
426 public List<ScheduleRealInfo> queryUserInfo(String line, String date) { 429 public List<ScheduleRealInfo> queryUserInfo(String line, String date) {
427 return scheduleRealInfoRepository.queryUserInfo(line, date); 430 return scheduleRealInfoRepository.queryUserInfo(line, date);
428 } 431 }
429 - 432 + /**
  433 + *
  434 + */
430 @Override 435 @Override
431 public List<ScheduleRealInfo> exportWaybill(String jName, String clZbh, String lpName) { 436 public List<ScheduleRealInfo> exportWaybill(String jName, String clZbh, String lpName) {
432 ReportUtils ee = new ReportUtils(); 437 ReportUtils ee = new ReportUtils();
  438 + ReportRelatedUtils rru = new ReportRelatedUtils();
433 List<Iterator<?>> list = new ArrayList<Iterator<?>>(); 439 List<Iterator<?>> list = new ArrayList<Iterator<?>>();
434 List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.exportWaybill(jName, clZbh, lpName); 440 List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.exportWaybill(jName, clZbh, lpName);
435 - ScheduleRealInfo scheduleReal = scheduleRealInfoRepository.findOne(scheduleRealInfos.get(0).getId()); 441 + List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
436 442
437 DecimalFormat format = new DecimalFormat("0.00"); 443 DecimalFormat format = new DecimalFormat("0.00");
438 int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); 444 int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
@@ -440,7 +446,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -440,7 +446,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
440 int jhbc = 0; 446 int jhbc = 0;
441 double jhlc = 0; 447 double jhlc = 0;
442 float realMileage = 0l,addMileage = 0l,remMileage = 0l; 448 float realMileage = 0l,addMileage = 0l,remMileage = 0l;
443 - Map<String,Object> map = new HashMap<String, Object>(); 449 +
  450 + Map<String,Object> map;
444 for(ScheduleRealInfo scheduleRealInfo : scheduleRealInfos){ 451 for(ScheduleRealInfo scheduleRealInfo : scheduleRealInfos){
445 if(scheduleRealInfo != null){ 452 if(scheduleRealInfo != null){
446 jhlc += scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc(); 453 jhlc += scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
@@ -448,8 +455,34 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -448,8 +455,34 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
448 addMileage += scheduleRealInfo.getAddMileage()==null?0:scheduleRealInfo.getAddMileage(); 455 addMileage += scheduleRealInfo.getAddMileage()==null?0:scheduleRealInfo.getAddMileage();
449 remMileage += scheduleRealInfo.getRemMileage()==null?0:scheduleRealInfo.getRemMileage(); 456 remMileage += scheduleRealInfo.getRemMileage()==null?0:scheduleRealInfo.getRemMileage();
450 jhbc++; 457 jhbc++;
  458 +
  459 + map = new HashMap<String, Object>();
  460 + try {
  461 + map = rru.getMapValue(scheduleRealInfo);
  462 + String zdsj = scheduleRealInfo.getZdsj();
  463 + String zdsjActual = scheduleRealInfo.getZdsjActual();
  464 + if(zdsj != null && zdsjActual != null &&
  465 + !zdsj.equals(zdsjActual)){
  466 + if(zdsj.compareTo(zdsjActual) > 0){
  467 + map.put("fast", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  468 + map.put("slow", "");
  469 + } else {
  470 + map.put("fast", "");
  471 + map.put("slow", TimeUtils.getTimeDifference(zdsj, zdsjActual));
  472 + }
  473 + } else {
  474 + map.put("fast", "");
  475 + map.put("slow", "");
  476 + }
  477 + listMap.add(map);
  478 + } catch (Exception e) {
  479 + e.printStackTrace();
  480 + }
451 } 481 }
452 } 482 }
  483 +
  484 + //计算里程和班次数,并放入Map里
  485 + map = new HashMap<String, Object>();
453 map.put("jhlc", format.format(jhlc)); 486 map.put("jhlc", format.format(jhlc));
454 map.put("remMileage", format.format(remMileage)); 487 map.put("remMileage", format.format(remMileage));
455 map.put("addMileage", format.format(addMileage)); 488 map.put("addMileage", format.format(addMileage));
@@ -463,19 +496,50 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -463,19 +496,50 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
463 496
464 String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\"; 497 String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
465 498
466 - list.add(scheduleRealInfos.iterator());  
467 - ee.excelReplace(list, new Object[] { scheduleReal,map }, path+"mould\\waybill.xls", 499 + list.add(listMap.iterator());
  500 + ee.excelReplace(list, new Object[] { scheduleRealInfos.get(0),map }, path+"mould\\waybill.xls",
468 path+"export\\" + jName + ".xls"); 501 path+"export\\" + jName + ".xls");
469 return scheduleRealInfos; 502 return scheduleRealInfos;
470 } 503 }
471 504
472 @Override 505 @Override
473 - public List<Map<String, Object>> dailyInfo(String line, String date) { 506 + public List<Map<String, Object>> dailyInfo(String line, String date,String type) {
474 DecimalFormat format = new DecimalFormat("0.00"); 507 DecimalFormat format = new DecimalFormat("0.00");
  508 + ReportUtils ee = new ReportUtils();
  509 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
475 List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date); 510 List<Map<String, Object>> list = scheduleRealInfoRepository.dailyInfo(line, date);
  511 +
  512 + double totalZGL = 0,totalKSGL=0,totalYH=0;
  513 + int totalBCS=0;
476 for(int i = 0;i < list.size();i++){ 514 for(int i = 0;i < list.size();i++){
477 - list.get(i).put("zgl", format.format(Double.parseDouble(list.get(i).get("zgl")==null?"0":list.get(i).get("zgl").toString())));  
478 - list.get(i).put("ksgl", format.format(Double.parseDouble(list.get(i).get("ksgl")==null?"0":list.get(i).get("ksgl").toString()))); 515 + String zgl = format.format(Double.parseDouble(list.get(i).get("zgl")==null?"0":list.get(i).get("zgl").toString()));
  516 + String ksgl = format.format(Double.parseDouble(list.get(i).get("ksgl")==null?"0":list.get(i).get("ksgl").toString()));
  517 + if(type.equals("export")){
  518 + totalZGL += Double.parseDouble(zgl);
  519 + totalKSGL += Double.parseDouble(ksgl);
  520 + totalBCS += Integer.parseInt(list.get(i).get("bcs").toString());
  521 + }
  522 + list.get(i).put("zgl", zgl);
  523 + list.get(i).put("ksgl", ksgl);
  524 + }
  525 + if(type.equals("export")){
  526 + Map<String,Object> map = new HashMap<String, Object>();
  527 + map.put("line", line);
  528 + map.put("date", date);
  529 + map.put("totalZGL", totalZGL);
  530 + map.put("totalKSGL", totalKSGL);
  531 + map.put("totalYH", totalYH);
  532 + map.put("totalBCS", totalBCS);
  533 +
  534 + String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
  535 +
  536 + listI.add(list.iterator());
  537 + try {
  538 + ee.excelReplace(listI, new Object[] { map }, path+"mould\\daily.xls",
  539 + path+"export\\班次日报" + sdfSimple.format(sdfMonth.parse(date)) + ".xls");
  540 + } catch (ParseException e) {
  541 + e.printStackTrace();
  542 + }
479 } 543 }
480 return list; 544 return list;
481 } 545 }
@@ -907,9 +971,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -907,9 +971,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
907 map.put("jhlc", format.format(jhlc)); 971 map.put("jhlc", format.format(jhlc));
908 map.put("remMileage", format.format(remMileage)); 972 map.put("remMileage", format.format(remMileage));
909 map.put("addMileage", format.format(addMileage)); 973 map.put("addMileage", format.format(addMileage));
910 - map.put("yygl", format.format(realMileage-addMileage)); 974 + map.put("yygl", format.format(jhlc));
911 map.put("ksgl", format.format(realMileage-addMileage)); 975 map.put("ksgl", format.format(realMileage-addMileage));
912 - map.put("realMileage", format.format(realMileage)); 976 + map.put("realMileage", format.format(jhlc));
913 map.put("jhbc", jhbc); 977 map.put("jhbc", jhbc);
914 map.put("cjbc", cjbc); 978 map.put("cjbc", cjbc);
915 map.put("ljbc", ljbc); 979 map.put("ljbc", ljbc);
@@ -967,4 +1031,40 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -967,4 +1031,40 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
967 } 1031 }
968 return rs; 1032 return rs;
969 } 1033 }
  1034 +
  1035 + @Override
  1036 + public List<Map<String, Object>> statisticsDaily(String line, String date,
  1037 + String xlName) {
  1038 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.statisticsDaily(line, date);
  1039 + double jhlc = 0.00;
  1040 + float realMileage = 0l;
  1041 + for(ScheduleRealInfo scheduleRealInfo: list){
  1042 + if(scheduleRealInfo != null){
  1043 + jhlc += scheduleRealInfo.getJhlc();
  1044 + if(scheduleRealInfo.getsName().equals("1")){
  1045 + realMileage += scheduleRealInfo.getRealMileage();
  1046 + }
  1047 + }
  1048 + }
  1049 + return null;
  1050 + }
  1051 +
  1052 + @Override
  1053 + public List<Object> scheduleDaily(String line, String date) {
  1054 + Map<String,String> tempMap = null;
  1055 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleDaily(line, date);
  1056 + Map<String, Object> map = new HashMap<String, Object>();
  1057 + Double jhlc = 0.00;
  1058 + for(ScheduleRealInfo scheduleRealInfo:scheduleRealInfos){
  1059 + if(scheduleRealInfo != null){
  1060 + jhlc += scheduleRealInfo.getJhlc();
  1061 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1062 + if(childTaskPlans.isEmpty()){
  1063 +
  1064 + }
  1065 + }
  1066 + }
  1067 + map.put("jhlc", jhlc);
  1068 + return null;
  1069 + }
970 } 1070 }
src/main/java/com/bsth/service/sys/SysUserService.java
@@ -6,4 +6,8 @@ import com.bsth.service.BaseService; @@ -6,4 +6,8 @@ import com.bsth.service.BaseService;
6 public interface SysUserService extends BaseService<SysUser, Integer>{ 6 public interface SysUserService extends BaseService<SysUser, Integer>{
7 7
8 SysUser findByUserName(String name); 8 SysUser findByUserName(String name);
  9 +
  10 + int changeEnabled(int id,int enabled);
  11 +
  12 + int changePWD(int id,String newPWD);
9 } 13 }
src/main/java/com/bsth/service/sys/impl/SysUserServiceImpl.java
1 package com.bsth.service.sys.impl; 1 package com.bsth.service.sys.impl;
2 2
  3 +import java.util.Map;
  4 +
3 import org.springframework.beans.factory.annotation.Autowired; 5 import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
4 import org.springframework.stereotype.Service; 7 import org.springframework.stereotype.Service;
5 8
6 import com.bsth.entity.sys.SysUser; 9 import com.bsth.entity.sys.SysUser;
@@ -18,4 +21,22 @@ public class SysUserServiceImpl extends BaseServiceImpl&lt;SysUser, Integer&gt; implem @@ -18,4 +21,22 @@ public class SysUserServiceImpl extends BaseServiceImpl&lt;SysUser, Integer&gt; implem
18 public SysUser findByUserName(String name) { 21 public SysUser findByUserName(String name) {
19 return sysUserRepository.findByUserName(name); 22 return sysUserRepository.findByUserName(name);
20 } 23 }
  24 +
  25 + @Override
  26 + public Map<String, Object> save(SysUser t) {
  27 + //
  28 + t.setPassword(new BCryptPasswordEncoder(4).encode(t.getPassword()));
  29 + return super.save(t);
  30 + }
  31 +
  32 + @Override
  33 + public int changeEnabled(int id, int enabled) {
  34 + sysUserRepository.changeEnabled(id,enabled);
  35 + return 0;
  36 + }
  37 +
  38 + @Override
  39 + public int changePWD(int id,String newPWD) {
  40 + return sysUserRepository.changePWD(id,new BCryptPasswordEncoder(4).encode(newPWD));
  41 + }
21 } 42 }
src/main/java/com/bsth/util/ReportRelatedUtils.java
1 package com.bsth.util; 1 package com.bsth.util;
2 2
  3 +import java.lang.reflect.Field;
3 import java.lang.reflect.InvocationTargetException; 4 import java.lang.reflect.InvocationTargetException;
4 import java.lang.reflect.Method; 5 import java.lang.reflect.Method;
  6 +import java.util.HashMap;
  7 +import java.util.Map;
  8 +
  9 +import org.apache.poi.ss.formula.functions.T;
5 10
6 import com.bsth.entity.Line; 11 import com.bsth.entity.Line;
7 12
@@ -52,6 +57,42 @@ public class ReportRelatedUtils { @@ -52,6 +57,42 @@ public class ReportRelatedUtils {
52 } 57 }
53 return value; 58 return value;
54 } 59 }
  60 +
  61 + /**
  62 + * 通过字段名取到对象中该字段的相应值
  63 + *
  64 + * @param t
  65 + * 对象
  66 + * @param fieldName
  67 + * 字段名
  68 + * @return
  69 + * @throws ClassNotFoundException
  70 + * @throws IllegalAccessException
  71 + * @throws InvocationTargetException
  72 + * @throws NoSuchMethodException
  73 + * @throws NoSuchFieldException
  74 + */
  75 + public Map<String,Object> getMapValue(Object t)
  76 + throws ClassNotFoundException, IllegalAccessException,
  77 + InvocationTargetException, NoSuchMethodException,
  78 + NoSuchFieldException {
  79 + Map<String,Object> map = new HashMap<String, Object>();
  80 + Object value = "";
  81 + Field[] fields = t.getClass().getDeclaredFields();
  82 + for(Field field:fields){
  83 + String fieldName = field.getName();
  84 + String tmpFieldName = firstCharToUpperCase(fieldName);
  85 + Method method = null;
  86 + try {
  87 + method = t.getClass().getMethod("get" + tmpFieldName);
  88 + value = method.invoke(t)==null?"":method.invoke(t);
  89 + } catch (NoSuchMethodException e) {
  90 + value = "";
  91 + }
  92 + map.put(fieldName, value);
  93 + }
  94 + return map;
  95 + }
55 96
56 /** 97 /**
57 * 首字母大写 98 * 首字母大写
src/main/java/com/bsth/util/ReportUtils.java
@@ -279,6 +279,9 @@ public class ReportUtils { @@ -279,6 +279,9 @@ public class ReportUtils {
279 } 279 }
280 } else if (obj.getClass().getName().equals(classWholeName)) { 280 } else if (obj.getClass().getName().equals(classWholeName)) {
281 cellValue = cellValue.replace("$" + tmpKey + "$",getKeyValue(obj, fieldName) + ""); 281 cellValue = cellValue.replace("$" + tmpKey + "$",getKeyValue(obj, fieldName) + "");
  282 + } else if (obj.getClass().getName().equals("java.util.HashMap")){
  283 + Map<String,Object> map = (HashMap<String,Object>)obj;
  284 + cellValue = cellValue.replace("$" + tmpKey + "$",map.get(fieldName)+"");
282 } 285 }
283 } 286 }
284 } 287 }
src/main/resources/static/index.html
@@ -166,6 +166,10 @@ tr.row-active td { @@ -166,6 +166,10 @@ tr.row-active td {
166 <a href="javascript:;"> 166 <a href="javascript:;">
167 <i class="fa fa-user"></i> 我的信息 </a> 167 <i class="fa fa-user"></i> 我的信息 </a>
168 </li> 168 </li>
  169 + <li>
  170 + <a href="javascript:;" id="changePWD">
  171 + <i class="fa fa-unlock-alt"></i> 修改密码</a>
  172 + </li>
169 <li class="divider"> </li> 173 <li class="divider"> </li>
170 <li> 174 <li>
171 <a href="javascript:;"> 175 <a href="javascript:;">
@@ -391,6 +395,22 @@ $(function(){ @@ -391,6 +395,22 @@ $(function(){
391 loadPage('/pages/home.html'); 395 loadPage('/pages/home.html');
392 } 396 }
393 }); 397 });
  398 +
  399 + //修改密码
  400 + $('#changePWD').on('click', function(){
  401 + $.get('/pages/permission/user/changePWD.html', function(content){
  402 + layer.open({
  403 + type: 1,
  404 + area: ['600px','360px'],
  405 + content: content,
  406 + title : '修改密码',
  407 + shift: 5,
  408 + scrollbar: false,
  409 + success: function(){
  410 + }
  411 + });
  412 + });
  413 + });
394 }); 414 });
395 415
396 //modal关闭时销毁dom 416 //modal关闭时销毁dom
src/main/resources/static/pages/forms/mould/waybill.xls
No preview for this file type
src/main/resources/static/pages/forms/statement/daily.html
@@ -130,10 +130,12 @@ @@ -130,10 +130,12 @@
130 } 130 }
131 }); 131 });
132 132
  133 + var line;
  134 + var date;
133 $("#query").on("click",function(){ 135 $("#query").on("click",function(){
134 - var line = $("#line").val();  
135 - var date = $("#date").val();  
136 - $get('/realSchedule/dailyInfo',{line:line,date:date},function(result){ 136 + line = $("#line").val();
  137 + date = $("#date").val();
  138 + $get('/realSchedule/dailyInfo',{line:line,date:date,type:'query'},function(result){
137 $("#form_line").text(line); 139 $("#form_line").text(line);
138 $("#form_date").text(date); 140 $("#form_date").text(date);
139 var total_zgl = 0,total_ksgl = 0,total_yh = 0,total_bcs = 0; 141 var total_zgl = 0,total_ksgl = 0,total_yh = 0,total_bcs = 0;
@@ -153,6 +155,11 @@ @@ -153,6 +155,11 @@
153 // 把渲染好的模版html文本追加到表格中 155 // 把渲染好的模版html文本追加到表格中
154 $('#forms .dailyInfo').html(tbodyHtml); 156 $('#forms .dailyInfo').html(tbodyHtml);
155 }); 157 });
  158 + });
  159 + $("#export").on("click",function(){
  160 + $get('/realSchedule/dailyInfo',{line:line,date:date,type:'export'},function(result){
  161 + window.open("/downloadFile/download?fileName=班次日报"+moment(date).format("YYYYMMDD"));
  162 + });
156 }); 163 });
157 }); 164 });
158 </script> 165 </script>
src/main/resources/static/pages/forms/statement/historyMessage.html
@@ -168,8 +168,8 @@ @@ -168,8 +168,8 @@
168 $('#forms tbody').html(tbodyHtml); 168 $('#forms tbody').html(tbodyHtml);
169 }); 169 });
170 }); 170 });
171 - $("#export").click(function(){  
172 - $('#forms').tableExport({ type: 'excel', escape: 'false' }); 171 + $("#export").on("click",function(){
  172 + $('#forms').tableExport({ type: 'excel', escape: 'false',filename:'(2016-02-29_2016-03-06)'});
173 }); 173 });
174 174
175 }); 175 });
@@ -191,7 +191,4 @@ @@ -191,7 +191,4 @@
191 <td colspan="7"><h6 class="muted">没有找到相关数据</h6></td> 191 <td colspan="7"><h6 class="muted">没有找到相关数据</h6></td>
192 </tr> 192 </tr>
193 {{/if}} 193 {{/if}}
194 -</script>  
195 -  
196 -<script src="/pages/forms/statement/js/tableExport.js"></script>  
197 -<script src="/pages/forms/statement/js/jquery.base64.js"></script>  
198 \ No newline at end of file 194 \ No newline at end of file
  195 +</script>
199 \ No newline at end of file 196 \ No newline at end of file
src/main/resources/static/pages/forms/statement/js/tableExport.js
1 -/*The MIT License (MIT)  
2 -  
3 -Copyright (c) 2014 https://github.com/kayalshri/  
4 -  
5 -Permission is hereby granted, free of charge, to any person obtaining a copy  
6 -of this software and associated documentation files (the "Software"), to deal  
7 -in the Software without restriction, including without limitation the rights  
8 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell  
9 -copies of the Software, and to permit persons to whom the Software is  
10 -furnished to do so, subject to the following conditions:  
11 -  
12 -The above copyright notice and this permission notice shall be included in  
13 -all copies or substantial portions of the Software.  
14 -  
15 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  
16 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  
17 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE  
18 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
19 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  
20 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN  
21 -THE SOFTWARE.*/  
22 - 1 +// 此函数引用自: http://www.alloyteam.com/2014/01/use-js-file-download/
  2 +function downloadFile(fileName, content){
  3 + var aLink = document.createElement('a');
  4 + var blob = new Blob([content]);
  5 + var evt = document.createEvent("HTMLEvents");
  6 + evt.initEvent("click", false, false);//initEvent 不加后两个参数在FF下会报错, 感谢 Barret Lee 的反馈
  7 + aLink.download = fileName;
  8 + aLink.href = URL.createObjectURL(blob);
  9 + aLink.dispatchEvent(evt);
  10 +}
  11 +
  12 +
23 (function($){ 13 (function($){
24 - $.fn.extend({  
25 - tableExport: function(options) {  
26 - var defaults = {  
27 - separator: ',',  
28 - ignoreColumn: [],  
29 - tableName:'yourTableName',  
30 - type:'csv',  
31 - pdfFontSize:14,  
32 - pdfLeftMargin:20,  
33 - escape:'true',  
34 - htmlContent:'false',  
35 - consoleLog:'false'  
36 - };  
37 -  
38 - var options = $.extend(defaults, options);  
39 - var el = this;  
40 -  
41 - if(defaults.type == 'csv' || defaults.type == 'txt'){  
42 -  
43 - // Header  
44 - var tdData ="";  
45 - $(el).find('thead').find('tr').each(function() {  
46 - tdData += "\n";  
47 - $(this).filter(':visible').find('th').each(function(index,data) {  
48 - if ($(this).css('display') != 'none'){  
49 - if(defaults.ignoreColumn.indexOf(index) == -1){  
50 - tdData += '"' + parseString($(this)) + '"' + defaults.separator;  
51 - }  
52 - }  
53 -  
54 - });  
55 - tdData = $.trim(tdData);  
56 - tdData = $.trim(tdData).substring(0, tdData.length -1);  
57 - });  
58 -  
59 - // Row vs Column  
60 - $(el).find('tbody').find('tr').each(function() {  
61 - tdData += "\n";  
62 - $(this).filter(':visible').find('td').each(function(index,data) {  
63 - if ($(this).css('display') != 'none'){  
64 - if(defaults.ignoreColumn.indexOf(index) == -1){  
65 - tdData += '"'+ parseString($(this)) + '"'+ defaults.separator;  
66 - }  
67 - }  
68 - });  
69 - //tdData = $.trim(tdData);  
70 - tdData = $.trim(tdData).substring(0, tdData.length -1);  
71 - });  
72 -  
73 - //output  
74 - if(defaults.consoleLog == 'true'){  
75 - console.log(tdData);  
76 - }  
77 - var base64data = "base64," + $.base64.encode(tdData);  
78 - window.open('data:application/'+defaults.type+';filename=exportData;' + base64data);  
79 - }else if(defaults.type == 'sql'){  
80 -  
81 - // Header  
82 - var tdData ="INSERT INTO `"+defaults.tableName+"` (";  
83 - $(el).find('thead').find('tr').each(function() {  
84 -  
85 - $(this).filter(':visible').find('th').each(function(index,data) {  
86 - if ($(this).css('display') != 'none'){  
87 - if(defaults.ignoreColumn.indexOf(index) == -1){  
88 - tdData += '`' + parseString($(this)) + '`,' ;  
89 - }  
90 - }  
91 -  
92 - });  
93 - tdData = $.trim(tdData);  
94 - tdData = $.trim(tdData).substring(0, tdData.length -1);  
95 - });  
96 - tdData += ") VALUES ";  
97 - // Row vs Column  
98 - $(el).find('tbody').find('tr').each(function() {  
99 - tdData += "(";  
100 - $(this).filter(':visible').find('td').each(function(index,data) {  
101 - if ($(this).css('display') != 'none'){  
102 - if(defaults.ignoreColumn.indexOf(index) == -1){  
103 - tdData += '"'+ parseString($(this)) + '",';  
104 - }  
105 - }  
106 - });  
107 -  
108 - tdData = $.trim(tdData).substring(0, tdData.length -1);  
109 - tdData += "),";  
110 - });  
111 - tdData = $.trim(tdData).substring(0, tdData.length -1);  
112 - tdData += ";";  
113 -  
114 - //output  
115 - //console.log(tdData);  
116 -  
117 - if(defaults.consoleLog == 'true'){  
118 - console.log(tdData);  
119 - }  
120 -  
121 - var base64data = "base64," + $.base64.encode(tdData);  
122 - window.open('data:application/sql;filename=exportData;' + base64data);  
123 -  
124 -  
125 - }else if(defaults.type == 'json'){  
126 -  
127 - var jsonHeaderArray = [];  
128 - $(el).find('thead').find('tr').each(function() {  
129 - var tdData ="";  
130 - var jsonArrayTd = [];  
131 -  
132 - $(this).filter(':visible').find('th').each(function(index,data) {  
133 - if ($(this).css('display') != 'none'){  
134 - if(defaults.ignoreColumn.indexOf(index) == -1){  
135 - jsonArrayTd.push(parseString($(this)));  
136 - }  
137 - }  
138 - });  
139 - jsonHeaderArray.push(jsonArrayTd);  
140 -  
141 - });  
142 -  
143 - var jsonArray = [];  
144 - $(el).find('tbody').find('tr').each(function() {  
145 - var tdData ="";  
146 - var jsonArrayTd = [];  
147 -  
148 - $(this).filter(':visible').find('td').each(function(index,data) {  
149 - if ($(this).css('display') != 'none'){  
150 - if(defaults.ignoreColumn.indexOf(index) == -1){  
151 - jsonArrayTd.push(parseString($(this)));  
152 - }  
153 - }  
154 - });  
155 - jsonArray.push(jsonArrayTd);  
156 -  
157 - });  
158 -  
159 - var jsonExportArray =[];  
160 - jsonExportArray.push({header:jsonHeaderArray,data:jsonArray});  
161 -  
162 - //Return as JSON  
163 - //console.log(JSON.stringify(jsonExportArray));  
164 -  
165 - //Return as Array  
166 - //console.log(jsonExportArray);  
167 - if(defaults.consoleLog == 'true'){  
168 - console.log(JSON.stringify(jsonExportArray));  
169 - }  
170 - var base64data = "base64," + $.base64.encode(JSON.stringify(jsonExportArray));  
171 - window.open('data:application/json;filename=exportData;' + base64data);  
172 - }else if(defaults.type == 'xml'){  
173 -  
174 - var xml = '<?xml version="1.0" encoding="utf-8"?>';  
175 - xml += '<tabledata><fields>';  
176 - // Header  
177 - $(el).find('thead').find('tr').each(function() {  
178 - $(this).filter(':visible').find('th').each(function(index,data) {  
179 - if ($(this).css('display') != 'none'){  
180 - if(defaults.ignoreColumn.indexOf(index) == -1){  
181 - xml += "<field>" + parseString($(this)) + "</field>";  
182 - }  
183 - }  
184 - });  
185 - });  
186 - xml += '</fields><data>';  
187 -  
188 - // Row Vs Column  
189 - var rowCount=1;  
190 - $(el).find('tbody').find('tr').each(function() {  
191 - xml += '<row id="'+rowCount+'">';  
192 - var colCount=0;  
193 - $(this).filter(':visible').find('td').each(function(index,data) {  
194 - if ($(this).css('display') != 'none'){  
195 - if(defaults.ignoreColumn.indexOf(index) == -1){  
196 - xml += "<column-"+colCount+">"+parseString($(this))+"</column-"+colCount+">";  
197 - }  
198 - }  
199 - colCount++;  
200 - });  
201 - rowCount++;  
202 - xml += '</row>';  
203 - });  
204 - xml += '</data></tabledata>'  
205 -  
206 - if(defaults.consoleLog == 'true'){  
207 - console.log(xml);  
208 - }  
209 -  
210 - var base64data = "base64," + $.base64.encode(xml);  
211 - window.open('data:application/xml;filename=exportData;' + base64data);  
212 - }else if(defaults.type == 'excel' || defaults.type == 'doc'|| defaults.type == 'powerpoint' ){  
213 - //console.log($(this).html());  
214 - var excel="<table>";  
215 - // Header  
216 - $(el).find('thead').find('tr').each(function() {  
217 - excel += "<tr>";  
218 - $(this).filter(':visible').find('th').each(function(index,data) {  
219 - if ($(this).css('display') != 'none'){  
220 - if(defaults.ignoreColumn.indexOf(index) == -1){  
221 - excel += "<td>" + parseString($(this))+ "</td>";  
222 - }  
223 - }  
224 - });  
225 - excel += '</tr>';  
226 -  
227 - });  
228 -  
229 -  
230 - // Row Vs Column  
231 - var rowCount=1;  
232 - $(el).find('tbody').find('tr').each(function() {  
233 - excel += "<tr>";  
234 - var colCount=0;  
235 - $(this).filter(':visible').find('td').each(function(index,data) {  
236 - if ($(this).css('display') != 'none'){  
237 - if(defaults.ignoreColumn.indexOf(index) == -1){  
238 - excel += "<td>"+parseString($(this))+"</td>";  
239 - }  
240 - }  
241 - colCount++;  
242 - });  
243 - rowCount++;  
244 - excel += '</tr>';  
245 - });  
246 - excel += '</table>'  
247 -  
248 - if(defaults.consoleLog == 'true'){  
249 - console.log(excel);  
250 - }  
251 -  
252 - var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:"+defaults.type+"' xmlns='http://www.w3.org/TR/REC-html40'>";  
253 - excelFile += "<head>";  
254 - excelFile += "<!--[if gte mso 9]>";  
255 - excelFile += "<xml>";  
256 - excelFile += "<x:ExcelWorkbook>";  
257 - excelFile += "<x:ExcelWorksheets>";  
258 - excelFile += "<x:ExcelWorksheet>";  
259 - excelFile += "<x:Name>";  
260 - excelFile += "{worksheet}";  
261 - excelFile += "</x:Name>";  
262 - excelFile += "<x:WorksheetOptions>";  
263 - excelFile += "<x:DisplayGridlines/>";  
264 - excelFile += "</x:WorksheetOptions>";  
265 - excelFile += "</x:ExcelWorksheet>";  
266 - excelFile += "</x:ExcelWorksheets>";  
267 - excelFile += "</x:ExcelWorkbook>";  
268 - excelFile += "</xml>";  
269 - excelFile += "<![endif]-->";  
270 - excelFile += "</head>";  
271 - excelFile += "<body>";  
272 - excelFile += excel;  
273 - excelFile += "</body>";  
274 - excelFile += "</html>";  
275 - var base64data = "base64," + $.base64({ data: excelFile, type: 0 });  
276 - window.open('data:application/vnd.ms-'+defaults.type+';filename=exportData.doc;' + base64data);  
277 -  
278 - }else if(defaults.type == 'png'){  
279 - html2canvas($(el), {  
280 - onrendered: function(canvas) {  
281 - var img = canvas.toDataURL("image/png");  
282 - window.open(img);  
283 -  
284 -  
285 - }  
286 - });  
287 - }else if(defaults.type == 'pdf'){  
288 -  
289 - var doc = new jsPDF('p','pt', 'a4', true);  
290 - doc.setFontSize(defaults.pdfFontSize);  
291 -  
292 - // Header  
293 - var startColPosition=defaults.pdfLeftMargin;  
294 - $(el).find('thead').find('tr').each(function() {  
295 - $(this).filter(':visible').find('th').each(function(index,data) {  
296 - if ($(this).css('display') != 'none'){  
297 - if(defaults.ignoreColumn.indexOf(index) == -1){  
298 - var colPosition = startColPosition+ (index * 50);  
299 - doc.text(colPosition,20, parseString($(this)));  
300 - }  
301 - }  
302 - });  
303 - });  
304 -  
305 -  
306 - // Row Vs Column  
307 - var startRowPosition = 20; var page =1;var rowPosition=0;  
308 - $(el).find('tbody').find('tr').each(function(index,data) {  
309 - rowCalc = index+1;  
310 -  
311 - if (rowCalc % 26 == 0){  
312 - doc.addPage();  
313 - page++;  
314 - startRowPosition=startRowPosition+10;  
315 - }  
316 - rowPosition=(startRowPosition + (rowCalc * 10)) - ((page -1) * 280);  
317 -  
318 - $(this).filter(':visible').find('td').each(function(index,data) {  
319 - if ($(this).css('display') != 'none'){  
320 - if(defaults.ignoreColumn.indexOf(index) == -1){  
321 - var colPosition = startColPosition+ (index * 50);  
322 - doc.text(colPosition,rowPosition, parseString($(this))); 14 + $.fn.extend({
  15 + tableExport: function(options) {
  16 + var defaults = {
  17 + separator: ',',
  18 + ignoreColumn: [],
  19 + tableName:'yourTableName',
  20 + type:'csv',
  21 + pdfFontSize:14,
  22 + pdfLeftMargin:20,
  23 + escape:'true',
  24 + htmlContent:'false',
  25 + consoleLog:'false'
  26 + };
  27 +
  28 + var options = $.extend(defaults, options);
  29 + var el = this;
  30 +
  31 + if(defaults.type == 'csv' || defaults.type == 'txt'){
  32 +
  33 + // Header
  34 + var tdData ="";
  35 + $(el).find('thead').find('tr').each(function() {
  36 + tdData += "\n";
  37 + $(this).filter(':visible').find('th').each(function(index,data) {
  38 + if ($(this).css('display') != 'none'){
  39 + if(defaults.ignoreColumn.indexOf(index) == -1){
  40 + tdData += '"' + parseString($(this)) + '"' + defaults.separator;
  41 + }
  42 + }
  43 +
  44 + });
  45 + tdData = $.trim(tdData);
  46 + tdData = $.trim(tdData).substring(0, tdData.length -1);
  47 + });
  48 +
  49 + // Row vs Column
  50 + $(el).find('tbody').find('tr').each(function() {
  51 + tdData += "\n";
  52 + $(this).filter(':visible').find('td').each(function(index,data) {
  53 + if ($(this).css('display') != 'none'){
  54 + if(defaults.ignoreColumn.indexOf(index) == -1){
  55 + tdData += '"'+ parseString($(this)) + '"'+ defaults.separator;
  56 + }
  57 + }
  58 + });
  59 + //tdData = $.trim(tdData);
  60 + tdData = $.trim(tdData).substring(0, tdData.length -1);
  61 + });
  62 +
  63 + //output
  64 + if(defaults.consoleLog == 'true'){
  65 + console.log(tdData);
  66 + }
  67 + var base64data = "base64," + $.base64({ data: tdData, type: 0 });
  68 + //window.open('data:application/'+defaults.type+';filename=exportData;' + base64data);
  69 + downloadFile(defaults.filename + '.' + defaults.type, tdData);
  70 + }else if(defaults.type == 'sql'){
  71 +
  72 + // Header
  73 + var tdData ="INSERT INTO `"+defaults.tableName+"` (";
  74 + $(el).find('thead').find('tr').each(function() {
  75 +
  76 + $(this).filter(':visible').find('th').each(function(index,data) {
  77 + if ($(this).css('display') != 'none'){
  78 + if(defaults.ignoreColumn.indexOf(index) == -1){
  79 + tdData += '`' + parseString($(this)) + '`,' ;
  80 + }
  81 + }
  82 +
  83 + });
  84 + tdData = $.trim(tdData);
  85 + tdData = $.trim(tdData).substring(0, tdData.length -1);
  86 + });
  87 + tdData += ") VALUES ";
  88 + // Row vs Column
  89 + $(el).find('tbody').find('tr').each(function() {
  90 + tdData += "(";
  91 + $(this).filter(':visible').find('td').each(function(index,data) {
  92 + if ($(this).css('display') != 'none'){
  93 + if(defaults.ignoreColumn.indexOf(index) == -1){
  94 + tdData += '"'+ parseString($(this)) + '",';
  95 + }
  96 + }
  97 + });
  98 +
  99 + tdData = $.trim(tdData).substring(0, tdData.length -1);
  100 + tdData += "),";
  101 + });
  102 + tdData = $.trim(tdData).substring(0, tdData.length -1);
  103 + tdData += ";";
  104 +
  105 + //output
  106 + //console.log(tdData);
  107 +
  108 + if(defaults.consoleLog == 'true'){
  109 + console.log(tdData);
  110 + }
  111 +
  112 + var base64data = "base64," + $.base64.encode(tdData);
  113 + window.open('data:application/sql;filename=exportData;' + base64data);
  114 +
  115 +
  116 + }else if(defaults.type == 'json'){
  117 +
  118 + var jsonHeaderArray = [];
  119 + $(el).find('thead').find('tr').each(function() {
  120 + var tdData ="";
  121 + var jsonArrayTd = [];
  122 +
  123 + $(this).filter(':visible').find('th').each(function(index,data) {
  124 + if ($(this).css('display') != 'none'){
  125 + if(defaults.ignoreColumn.indexOf(index) == -1){
  126 + jsonArrayTd.push(parseString($(this)));
  127 + }
  128 + }
  129 + });
  130 + jsonHeaderArray.push(jsonArrayTd);
  131 +
  132 + });
  133 +
  134 + var jsonArray = [];
  135 + $(el).find('tbody').find('tr').each(function() {
  136 + var tdData ="";
  137 + var jsonArrayTd = [];
  138 +
  139 + $(this).filter(':visible').find('td').each(function(index,data) {
  140 + if ($(this).css('display') != 'none'){
  141 + if(defaults.ignoreColumn.indexOf(index) == -1){
  142 + jsonArrayTd.push(parseString($(this)));
  143 + }
  144 + }
  145 + });
  146 + jsonArray.push(jsonArrayTd);
  147 +
  148 + });
  149 +
  150 + var jsonExportArray =[];
  151 + jsonExportArray.push({header:jsonHeaderArray,data:jsonArray});
  152 +
  153 + //Return as JSON
  154 + //console.log(JSON.stringify(jsonExportArray));
  155 +
  156 + //Return as Array
  157 + //console.log(jsonExportArray);
  158 + if(defaults.consoleLog == 'true'){
  159 + console.log(JSON.stringify(jsonExportArray));
  160 + }
  161 + var base64data = "base64," + $.base64.encode(JSON.stringify(jsonExportArray));
  162 + window.open('data:application/json;filename=exportData;' + base64data);
  163 + }else if(defaults.type == 'xml'){
  164 +
  165 + var xml = '<?xml version="1.0" encoding="utf-8"?>';
  166 + xml += '<tabledata><fields>';
  167 + // Header
  168 + $(el).find('thead').find('tr').each(function() {
  169 + $(this).filter(':visible').find('th').each(function(index,data) {
  170 + if ($(this).css('display') != 'none'){
  171 + if(defaults.ignoreColumn.indexOf(index) == -1){
  172 + xml += "<field>" + parseString($(this)) + "</field>";
  173 + }
  174 + }
  175 + });
  176 + });
  177 + xml += '</fields><data>';
  178 +
  179 + // Row Vs Column
  180 + var rowCount=1;
  181 + $(el).find('tbody').find('tr').each(function() {
  182 + xml += '<row id="'+rowCount+'">';
  183 + var colCount=0;
  184 + $(this).filter(':visible').find('td').each(function(index,data) {
  185 + if ($(this).css('display') != 'none'){
  186 + if(defaults.ignoreColumn.indexOf(index) == -1){
  187 + xml += "<column-"+colCount+">"+parseString($(this))+"</column-"+colCount+">";
  188 + }
  189 + }
  190 + colCount++;
  191 + });
  192 + rowCount++;
  193 + xml += '</row>';
  194 + });
  195 + xml += '</data></tabledata>'
  196 +
  197 + if(defaults.consoleLog == 'true'){
  198 + console.log(xml);
  199 + }
  200 +
  201 + var base64data = "base64," + $.base64.encode(xml);
  202 + window.open('data:application/xml;filename=exportData;' + base64data);
  203 + }else if(defaults.type == 'excel' || defaults.type == 'doc'|| defaults.type == 'powerpoint' ){
  204 + //console.log($(this).html());
  205 + var excel="<table>";
  206 + // Header
  207 + $(el).find('thead').find('tr').each(function() {
  208 + excel += "<tr>";
  209 + $(this).filter(':visible').find('th').each(function(index,data) {
  210 + if ($(this).css('display') != 'none'){
  211 + if(defaults.ignoreColumn.indexOf(index) == -1){
  212 + excel += "<td>" + parseString($(this))+ "</td>";
  213 + }
  214 + }
  215 + });
  216 + excel += '</tr>';
  217 +
  218 + });
  219 +
  220 +
  221 + // Row Vs Column
  222 + var rowCount=1;
  223 + $(el).find('tbody').find('tr').each(function() {
  224 + excel += "<tr>";
  225 + var colCount=0;
  226 + $(this).filter(':visible').find('td').each(function(index,data) {
  227 + if ($(this).css('display') != 'none'){
  228 + if(defaults.ignoreColumn.indexOf(index) == -1){
  229 + excel += "<td>"+parseString($(this))+"</td>";
  230 + }
  231 + }
  232 + colCount++;
  233 + });
  234 + rowCount++;
  235 + excel += '</tr>';
  236 + });
  237 + excel += '</table>'
  238 +
  239 + if(defaults.consoleLog == 'true'){
  240 + console.log(excel);
  241 + }
  242 +
  243 + var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:"+defaults.type+"' xmlns='http://www.w3.org/TR/REC-html40'>";
  244 + excelFile += "<head>";
  245 + excelFile += "<!--[if gte mso 9]>";
  246 + excelFile += "<xml>";
  247 + excelFile += "<x:ExcelWorkbook>";
  248 + excelFile += "<x:ExcelWorksheets>";
  249 + excelFile += "<x:ExcelWorksheet>";
  250 + excelFile += "<x:Name>";
  251 + excelFile += "{worksheet}";
  252 + excelFile += "</x:Name>";
  253 + excelFile += "<x:WorksheetOptions>";
  254 + excelFile += "<x:DisplayGridlines/>";
  255 + excelFile += "</x:WorksheetOptions>";
  256 + excelFile += "</x:ExcelWorksheet>";
  257 + excelFile += "</x:ExcelWorksheets>";
  258 + excelFile += "</x:ExcelWorkbook>";
  259 + excelFile += "</xml>";
  260 + excelFile += "<![endif]-->";
  261 + excelFile += "</head>";
  262 + excelFile += "<body>";
  263 + excelFile += excel;
  264 + excelFile += "</body>";
  265 + excelFile += "</html>";
  266 + var base64data = "base64," + $.base64({ data: excelFile, type: 0 });
  267 +
  268 + if(defaults.type == "doc") {
  269 + window.open('data:application/msword;filename=exportData.'+defaults.type+';' + base64data);
  270 + }
  271 + else {
  272 + window.open('data:application/vnd.ms-'+defaults.type+';filename=exportData.'+defaults.type+';' + base64data);
  273 + }
  274 + }else if(defaults.type == 'png'){
  275 + html2canvas($(el), {
  276 + onrendered: function(canvas) {
  277 + var img = canvas.toDataURL("image/png");
  278 + window.open(img);
  279 +
  280 +
  281 + }
  282 + });
  283 + }else if(defaults.type == 'pdf'){
  284 +
  285 + var doc = new jsPDF('p','pt', 'a4', true);
  286 + doc.setFontSize(defaults.pdfFontSize);
  287 +
  288 + // Header
  289 + var startColPosition=defaults.pdfLeftMargin;
  290 + $(el).find('thead').find('tr').each(function() {
  291 + $(this).filter(':visible').find('th').each(function(index,data) {
  292 + if ($(this).css('display') != 'none'){
  293 + if(defaults.ignoreColumn.indexOf(index) == -1){
  294 + var colPosition = startColPosition+ (index * 50);
  295 + doc.text(colPosition,20, parseString($(this)));
  296 + }
  297 + }
  298 + });
  299 + });
  300 +
  301 +
  302 + // Row Vs Column
  303 + var startRowPosition = 20; var page =1;var rowPosition=0;
  304 + $(el).find('tbody').find('tr').each(function(index,data) {
  305 + rowCalc = index+1;
  306 +
  307 + if (rowCalc % 26 == 0){
  308 + doc.addPage();
  309 + page++;
  310 + startRowPosition=startRowPosition+10;
  311 + }
  312 + rowPosition=(startRowPosition + (rowCalc * 10)) - ((page -1) * 280);
  313 +
  314 + $(this).filter(':visible').find('td').each(function(index,data) {
  315 + if ($(this).css('display') != 'none'){
  316 + if(defaults.ignoreColumn.indexOf(index) == -1){
  317 + var colPosition = startColPosition+ (index * 50);
  318 + doc.text(colPosition,rowPosition, parseString($(this)));
  319 + }
  320 + }
  321 +
  322 + });
  323 +
  324 + });
  325 +
  326 + // Output as Data URI
  327 + doc.output('datauri');
  328 +
  329 + }
  330 +
  331 +
  332 + function parseString(data){
  333 +
  334 + if(defaults.htmlContent == 'true'){
  335 + content_data = data.html().trim();
  336 + }else{
  337 + content_data = data.text().trim();
  338 + }
  339 +
  340 + if(defaults.escape == 'true'){
  341 + content_data = escape(content_data);
  342 + }
  343 +
  344 +
  345 +
  346 + return content_data;
  347 + }
  348 +
323 } 349 }
324 - }  
325 -  
326 - });  
327 -  
328 - });  
329 -  
330 - // Output as Data URI  
331 - doc.output('datauri');  
332 -  
333 - }  
334 -  
335 -  
336 - function parseString(data){  
337 -  
338 - if(defaults.htmlContent == 'true'){  
339 - content_data = data.html().trim();  
340 - }else{  
341 - content_data = data.text().trim();  
342 - }  
343 -  
344 - if(defaults.escape == 'true'){  
345 - content_data = escape(content_data);  
346 - }  
347 -  
348 -  
349 -  
350 - return content_data;  
351 - }  
352 -  
353 - }  
354 - });  
355 - })(jQuery);  
356 - 350 + });
  351 +})(jQuery);
357 \ No newline at end of file 352 \ No newline at end of file
src/main/resources/static/pages/forms/statement/statisticsDaily .html
@@ -200,7 +200,18 @@ @@ -200,7 +200,18 @@
200 return '<span style="color:gray;font-size: 12px;"> 正在搜索线路...</span>'; 200 return '<span style="color:gray;font-size: 12px;"> 正在搜索线路...</span>';
201 } 201 }
202 } 202 }
203 - }); 203 + });
  204 + $("#query").on("click",function(){
  205 + var line = $("#line").val();
  206 + var xlName = $("#line").text();
  207 + var date = $("#date").val();
  208 + $get('/realSchedule/statisticsDaily',{line:line,date:date,xlName:xlName},function(result){
  209 + // 把数据填充到模版中
  210 + var tbodyHtml = template('list_account',{list:result});
  211 + // 把渲染好的模版html文本追加到表格中
  212 + $('#forms tbody').html(tbodyHtml);
  213 + });
  214 + });
204 }); 215 });
205 </script> 216 </script>
206 <script type="text/html" id="list_forms"> 217 <script type="text/html" id="list_forms">
src/main/resources/static/pages/forms/statement/waybill.html
@@ -165,10 +165,10 @@ @@ -165,10 +165,10 @@
165 $get('/realSchedule/'+id,null,function(result){ 165 $get('/realSchedule/'+id,null,function(result){
166 result.scheduleDate = moment(result.scheduleDate).format("YYYY/MM/DD"); 166 result.scheduleDate = moment(result.scheduleDate).format("YYYY/MM/DD");
167 var ludan_1 = template('ludan_1',result); 167 var ludan_1 = template('ludan_1',result);
168 - var ludan_4 = template('ludan_4',result); 168 + //var ludan_4 = template('ludan_4',result);
169 // 把渲染好的模版html文本追加到表格中 169 // 把渲染好的模版html文本追加到表格中
170 $('#forms .ludan_1').append(ludan_1); 170 $('#forms .ludan_1').append(ludan_1);
171 - $('#forms .ludan_4').append(ludan_4); 171 + //$('#forms .ludan_4').append(ludan_4);
172 }); 172 });
173 $get('/realSchedule/queryListWaybill',{jName:jName,clZbh:params[1],lpName:params[2]},function(result){ 173 $get('/realSchedule/queryListWaybill',{jName:jName,clZbh:params[1],lpName:params[2]},function(result){
174 getTime(result); 174 getTime(result);
@@ -185,7 +185,7 @@ @@ -185,7 +185,7 @@
185 185
186 $("#export").on("click",function(){ 186 $("#export").on("click",function(){
187 $get('/realSchedule/exportWaybill',{jName:jName,clZbh:params[1],lpName:params[2]},function(result){ 187 $get('/realSchedule/exportWaybill',{jName:jName,clZbh:params[1],lpName:params[2]},function(result){
188 - window.open("/downloadFile/download?jName="+jName+"&lpName="+params[2]); 188 + window.open("/downloadFile/download?fileName="+jName);
189 }); 189 });
190 }); 190 });
191 191
@@ -198,11 +198,11 @@ @@ -198,11 +198,11 @@
198 if(obj.zdsj != null && obj.zdsjActual != null ){ 198 if(obj.zdsj != null && obj.zdsjActual != null ){
199 var zdsjActual = (obj.zdsjActual).split(":"); 199 var zdsjActual = (obj.zdsjActual).split(":");
200 var zdsj = (obj.zdsj).split(":"); 200 var zdsj = (obj.zdsj).split(":");
201 - if(zdsjActual[0]*60+zdsjActual[1] > zdsj[0]*60+zdsj[1]){  
202 - obj["slow"] = (zdsjActual[0]*60+zdsjActual[1]) - (zdsj[0]*60+zdsj[1]); 201 + if(zdsjActual[0]*60+Number(zdsjActual[1]) > zdsj[0]*60+Number(zdsj[1])){
  202 + obj["slow"] = (zdsjActual[0]*60+Number(zdsjActual[1])) - (zdsj[0]*60+Number(zdsj[1]));
203 } 203 }
204 - else{  
205 - obj["fast"] = (zdsj[0]*60+zdsj[1]) - (zdsjActual[0]*60+zdsjActual[1]); 204 + else if(zdsjActual[0]*60+Number(zdsjActual[1]) < zdsj[0]*60+Number(zdsj[1])){
  205 + obj["fast"] = (zdsj[0]*60+Number(zdsj[1])) - (zdsjActual[0]*60+Number(zdsjActual[1]));
206 } 206 }
207 } 207 }
208 }); 208 });
@@ -228,7 +228,7 @@ @@ -228,7 +228,7 @@
228 <td colspan="14">行车路单</td> 228 <td colspan="14">行车路单</td>
229 </tr> 229 </tr>
230 <tr> 230 <tr>
231 - <td colspan="14">路别:{{xlName}} 路牌:{{lpName}} 车号:{{clZbh}} 出场时间:{{ccTime}} 到达站名:{{zdzName}} 当班调派:&nbsp; 日期:{{scheduleDate}}</td> 231 + <td colspan="14">路别:{{xlName}} 路牌:{{lpName}} 车号:{{clZbh}} 出场时间:{{fcsjActual}} 到达站名:{{zdzName}} 当班调派:&nbsp; 日期:{{scheduleDate}}</td>
232 </tr> 232 </tr>
233 <tr> 233 <tr>
234 <td colspan="2">出场存油 &nbsp;升</td> 234 <td colspan="2">出场存油 &nbsp;升</td>
src/main/resources/static/pages/permission/user/add.html
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 </div> 19 </div>
20 </div> 20 </div>
21 <div class="portlet-body form"> 21 <div class="portlet-body form">
22 - <form action="/resource" class="form-horizontal" id="resource_add_form" > 22 + <form action="/addUser" class="form-horizontal" id="user_add_form" >
23 <div class="alert alert-danger display-hide"> 23 <div class="alert alert-danger display-hide">
24 <button class="close" data-close="alert"></button> 24 <button class="close" data-close="alert"></button>
25 您的输入有误,请检查下面的输入项 25 您的输入有误,请检查下面的输入项
@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
41 <div class="form-group"> 41 <div class="form-group">
42 <label class="col-md-3 control-label">密码</label> 42 <label class="col-md-3 control-label">密码</label>
43 <div class="col-md-4"> 43 <div class="col-md-4">
44 - <input type="password" class="form-control" name="password" > 44 + <input type="password" class="form-control" id="password" name="password" >
45 <span class="help-block"> 请输入6位以上密码</span> 45 <span class="help-block"> 请输入6位以上密码</span>
46 </div> 46 </div>
47 </div> 47 </div>
@@ -62,8 +62,8 @@ @@ -62,8 +62,8 @@
62 <div class="form-group"> 62 <div class="form-group">
63 <label class="col-md-3 control-label">角色</label> 63 <label class="col-md-3 control-label">角色</label>
64 <div class="col-md-4"> 64 <div class="col-md-4">
65 - <select class="form-control" name="role[]" style="width: 160px;" multiple="multiple">  
66 - <option>请选择...</option> 65 + <select class="form-control" id="role" name="roles[]" style="width: 160px;" multiple="multiple">
  66 +
67 </select> 67 </select>
68 </div> 68 </div>
69 </div> 69 </div>
@@ -72,7 +72,7 @@ @@ -72,7 +72,7 @@
72 <label class="col-md-3 control-label">是否启用</label> 72 <label class="col-md-3 control-label">是否启用</label>
73 <div class="col-md-4"> 73 <div class="col-md-4">
74 <div class="input-group"> 74 <div class="input-group">
75 - <select class="form-control" name="enable" style="width: 160px;"> 75 + <select class="form-control" name="enabled" style="width: 160px;">
76 <option value="1">可用</option> 76 <option value="1">可用</option>
77 <option value="0">禁用</option> 77 <option value="0">禁用</option>
78 </select> 78 </select>
@@ -93,5 +93,88 @@ @@ -93,5 +93,88 @@
93 </div> 93 </div>
94 </div> 94 </div>
95 <script> 95 <script>
96 - 96 + $(function(){
  97 + $get('/role/all',null,function(result){
  98 + $.each(result,function(i,obj){
  99 + $("#role").append("<option value='"+obj.id+"'>"+obj.roleName+"</option>");
  100 + });
  101 + });
  102 +
  103 + var form = $('#user_add_form');
  104 + var error = $('.alert-danger', form);
  105 +
  106 + //表单 validate
  107 + form.validate({
  108 + errorElement : 'span',
  109 + errorClass : 'help-block help-block-error',
  110 + focusInvalid : false,
  111 + rules : {
  112 + 'userName' : {
  113 + required : true,
  114 + maxlength: 25
  115 + },
  116 + 'name' : {
  117 + required : true,
  118 + maxlength: 25
  119 + },
  120 + 'password' : {
  121 + required : true,
  122 + minlength: 6,
  123 + maxlength: 25
  124 + },
  125 + 'cfmPassword' : {
  126 + equalTo: '#password'
  127 + },
  128 + 'role' : {
  129 + required : true,
  130 + minlength: 1
  131 + }
  132 + },
  133 + invalidHandler : function(event, validator) {
  134 + error.show();
  135 + App.scrollTo(error, -200);
  136 + },
  137 +
  138 + highlight : function(element) {
  139 + $(element).closest('.form-group').addClass('has-error');
  140 + },
  141 +
  142 + unhighlight : function(element) {
  143 + $(element).closest('.form-group').removeClass('has-error');
  144 + },
  145 +
  146 + success : function(label) {
  147 + label.closest('.form-group').removeClass('has-error');
  148 + },
  149 +
  150 + submitHandler : function(f) {
  151 + var params = form.serializeJSON();
  152 + error.hide();
  153 + console.log(params);
  154 +
  155 + //检查一下用户是否存在
  156 + $get('/user/all', {userName_eq: params.userName}, function(list){
  157 + if(!list || list.length == 0){
  158 + console.log(params);
  159 + $.ajax({
  160 + url: '/user',
  161 + type: 'POST',
  162 + traditional: true,
  163 + data: params,
  164 + success: function(res){
  165 + layer.msg('添加用户成功.');
  166 + loadPage('list.html');
  167 + }
  168 + });
  169 + /* $post('/user', params, function(res){
  170 + layer.msg('添加用户成功.');
  171 + loadPage('list.html');
  172 + }); */
  173 + }
  174 + else
  175 + layer.alert('用户【' + params.userName + '】已存在', {icon: 2, title: '提交被拒绝'});
  176 + });
  177 + }
  178 + });
  179 + });
97 </script> 180 </script>
98 \ No newline at end of file 181 \ No newline at end of file
src/main/resources/static/pages/permission/user/list.html
@@ -75,7 +75,7 @@ @@ -75,7 +75,7 @@
75 </td> 75 </td>
76 <td></td> 76 <td></td>
77 <td> 77 <td>
78 - <select class="form-control form-filter " name="enable_eq"> 78 + <select class="form-control form-filter " name="enabled_eq">
79 <option value="">请选择...</option> 79 <option value="">请选择...</option>
80 <option value="1">可用</option> 80 <option value="1">可用</option>
81 <option value="0">禁用</option> 81 <option value="0">禁用</option>
@@ -132,7 +132,13 @@ @@ -132,7 +132,13 @@
132 <td> 132 <td>
133 {{obj.lastLoginDate}} 133 {{obj.lastLoginDate}}
134 </td> 134 </td>
135 - <td><a href="edit.html?no={{obj.id}}" class="btn default blue-stripe btn-sm" data-pjax> 详细 </a></td> 135 + <td>
  136 + {{if obj.enabled}}
  137 + <button type="button" onclick="changeEnabled({{obj.id}},0)" class="btn btn-warning btn-sm">禁用</button>
  138 + {{else}}
  139 + <button type="button" onclick="changeEnabled({{obj.id}},1)" class="btn btn-success btn-sm">启用</button>
  140 + {{/if}}
  141 + </td>
136 </tr> 142 </tr>
137 {{/each}} 143 {{/each}}
138 {{if list.length == 0}} 144 {{if list.length == 0}}
@@ -252,4 +258,11 @@ $(function(){ @@ -252,4 +258,11 @@ $(function(){
252 }); 258 });
253 }); 259 });
254 }); 260 });
  261 +//改变状态
  262 +function changeEnabled(id,enabled){
  263 + debugger
  264 + $get('/user/changeEnabled',{id:id,enabled:enabled},function(result){
  265 + jsDoQuery(null, true);
  266 + })
  267 +}
255 </script> 268 </script>
256 \ No newline at end of file 269 \ No newline at end of file