Commit 3cff23f0741720ccda30ac4770b4ae804ca75816

Authored by BSTH
1 parent 93b4ad27

update

src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
... ... @@ -362,7 +362,13 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo,
362 362 * @return
363 363 */
364 364 @RequestMapping(value="/scheduleDaily")
365   - public List<Object> scheduleDaily(@RequestParam String line,@RequestParam String date){
  365 + public Map<String,Object> scheduleDaily(@RequestParam String line,@RequestParam String date){
366 366 return scheduleRealInfoService.scheduleDaily(line,date);
367 367 }
  368 +
  369 + @RequestMapping(value="/realScheduleList")
  370 + public List<ScheduleRealInfo> realScheduleList(@RequestParam String line,@RequestParam String date){
  371 + return scheduleRealInfoService.realScheduleList(line,date);
  372 + }
  373 +
368 374 }
... ...
src/main/java/com/bsth/controller/sys/RoleController.java
... ... @@ -32,4 +32,16 @@ public class RoleController extends BaseController&lt;Role, Integer&gt;{
32 32 public Map<String, Object> settRoleModules(@RequestParam Integer roleId,@RequestParam String mIds){
33 33 return roleService.settRoleModules(roleId, mIds);
34 34 }
  35 +
  36 + /**
  37 + *
  38 + * @Title: roleInfo
  39 + * @Description: TODO(角色信息)
  40 + * @param @param id 角色ID
  41 + * @throws
  42 + */
  43 + @RequestMapping(value = "/roleInfo")
  44 + public Map<String, Object> roleInfo(@RequestParam Integer id){
  45 + return roleService.roleInfo(id);
  46 + }
35 47 }
... ...
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -54,10 +54,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
54 54  
55 55 @Query(value="select s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 order by fcsj")
56 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   -
  57 +
61 58 @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);
  59 + List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date);
63 60 }
... ...
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
... ... @@ -98,5 +98,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
98 98  
99 99 List<Map<String,Object>> statisticsDaily(String line,String date,String xlName);
100 100  
101   - List<Object> scheduleDaily(String line,String date);
  101 + Map<String,Object> scheduleDaily(String line,String date);
  102 +
  103 + List<ScheduleRealInfo> realScheduleList(String line,String date);
102 104 }
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -1035,7 +1035,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1035 1035 @Override
1036 1036 public List<Map<String, Object>> statisticsDaily(String line, String date,
1037 1037 String xlName) {
1038   - List<ScheduleRealInfo> list = scheduleRealInfoRepository.statisticsDaily(line, date);
  1038 + List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1039 1039 double jhlc = 0.00;
1040 1040 float realMileage = 0l;
1041 1041 for(ScheduleRealInfo scheduleRealInfo: list){
... ... @@ -1050,21 +1050,85 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1050 1050 }
1051 1051  
1052 1052 @Override
1053   - public List<Object> scheduleDaily(String line, String date) {
  1053 + public Map<String,Object> scheduleDaily(String line, String date) {
1054 1054 Map<String,String> tempMap = null;
1055   - List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleDaily(line, date);
  1055 + List<ScheduleRealInfo> scheduleRealInfos = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
1056 1056 Map<String, Object> map = new HashMap<String, Object>();
1057 1057 Double jhlc = 0.00;
  1058 + Float sjgl = 0f,ssgl = 0f,ssgl_lz = 0f,ssgl_dm = 0f,ssgl_gz = 0f,ssgl_jf = 0f,ssgl_zs = 0f,ssgl_qr = 0f
  1059 + ,ssgl_qc = 0f,ssgl_kx = 0f,ssgl_qh = 0f,ssgl_yw = 0f,ssgl_other = 0f,ljgl = 0f;
  1060 + int jhbc = 0;
1058 1061 for(ScheduleRealInfo scheduleRealInfo:scheduleRealInfos){
1059 1062 if(scheduleRealInfo != null){
  1063 + //计算里程(包括子任务)
1060 1064 jhlc += scheduleRealInfo.getJhlc();
1061 1065 Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
1062   - if(childTaskPlans.isEmpty()){
1063   -
  1066 + if(!childTaskPlans.isEmpty()){
  1067 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1068 + while(it.hasNext()){
  1069 + ChildTaskPlan childTaskPlan = it.next();
  1070 + //是否烂班,烂班就是少驶
  1071 + if(!childTaskPlan.isDestroy()){
  1072 + sjgl += childTaskPlan.getMileage();
  1073 + }else{
  1074 + ssgl += childTaskPlan.getMileage();
  1075 + if(childTaskPlan.getDestroyReason().equals("路阻")){
  1076 + ssgl_lz += childTaskPlan.getMileage();
  1077 + }else if(childTaskPlan.getDestroyReason().equals("吊慢")){
  1078 + ssgl_dm += childTaskPlan.getMileage();
  1079 + }else if(childTaskPlan.getDestroyReason().equals("故障")){
  1080 + ssgl_gz += childTaskPlan.getMileage();
  1081 + }else if(childTaskPlan.getDestroyReason().equals("纠纷")){
  1082 + ssgl_jf += childTaskPlan.getMileage();
  1083 + }else if(childTaskPlan.getDestroyReason().equals("肇事")){
  1084 + ssgl_zs += childTaskPlan.getMileage();
  1085 + }else if(childTaskPlan.getDestroyReason().equals("缺人")){
  1086 + ssgl_qr += childTaskPlan.getMileage();
  1087 + }else if(childTaskPlan.getDestroyReason().equals("缺车")){
  1088 + ssgl_qc += childTaskPlan.getMileage();
  1089 + }else if(childTaskPlan.getDestroyReason().equals("客稀")){
  1090 + ssgl_kx += childTaskPlan.getMileage();
  1091 + }else if(childTaskPlan.getDestroyReason().equals("气候")){
  1092 + ssgl_qh += childTaskPlan.getMileage();
  1093 + }else if(childTaskPlan.getDestroyReason().equals("援外")){
  1094 + ssgl_yw += childTaskPlan.getMileage();
  1095 + }else{
  1096 + ssgl_other += childTaskPlan.getMileage();
  1097 + }
  1098 + }
  1099 + //临加公里
  1100 + if(childTaskPlan.getType1().equals("临加")){
  1101 + ljgl += childTaskPlan.getMileage();
  1102 + }
  1103 + }
1064 1104 }
  1105 + //班次
  1106 + scheduleRealInfo.getFcsjT();
  1107 + scheduleRealInfo.getFcsjActualTime();
1065 1108 }
1066 1109 }
1067 1110 map.put("jhlc", jhlc);
  1111 + map.put("sjgl", sjgl);
  1112 + map.put("ssgl", ssgl);
  1113 + map.put("ssgl_lz", ssgl_lz);
  1114 + map.put("ssgl_dm", ssgl_dm);
  1115 + map.put("ssgl_gz", ssgl_gz);
  1116 + map.put("ssgl_jf", ssgl_jf);
  1117 + map.put("ssgl_zs", ssgl_zs);
  1118 + map.put("ssgl_qr", ssgl_qr);
  1119 + map.put("ssgl_qc", ssgl_qc);
  1120 + map.put("ssgl_kx", ssgl_kx);
  1121 + map.put("ssgl_qh", ssgl_qh);
  1122 + map.put("ssgl_yw", ssgl_yw);
  1123 + map.put("ssgl_other", ssgl_other);
  1124 + map.put("ljgl", ljgl);
  1125 +
  1126 + map.put("jhbc", scheduleRealInfos.size());
1068 1127 return null;
1069 1128 }
  1129 +
  1130 + @Override
  1131 + public List<ScheduleRealInfo> realScheduleList(String line, String date) {
  1132 + return scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1133 + }
1070 1134 }
... ...
src/main/java/com/bsth/service/sys/RoleService.java
... ... @@ -9,4 +9,5 @@ public interface RoleService extends BaseService&lt;Role, Integer&gt;{
9 9  
10 10 Map<String, Object> settRoleModules(Integer roleId, String mIds);
11 11  
  12 + Map<String, Object> roleInfo(Integer id);
12 13 }
... ...
src/main/java/com/bsth/service/sys/impl/RoleServiceImpl.java
1 1 package com.bsth.service.sys.impl;
2 2  
  3 +import java.text.SimpleDateFormat;
3 4 import java.util.ArrayList;
4 5 import java.util.HashMap;
  6 +import java.util.Iterator;
5 7 import java.util.List;
6 8 import java.util.Map;
7 9 import java.util.Set;
... ... @@ -14,6 +16,7 @@ import org.springframework.stereotype.Service;
14 16 import com.bsth.common.ResponseCode;
15 17 import com.bsth.entity.sys.Module;
16 18 import com.bsth.entity.sys.Role;
  19 +import com.bsth.entity.sys.SysUser;
17 20 import com.bsth.repository.sys.ModuleRepository;
18 21 import com.bsth.repository.sys.RoleRepository;
19 22 import com.bsth.service.impl.BaseServiceImpl;
... ... @@ -30,6 +33,8 @@ public class RoleServiceImpl extends BaseServiceImpl&lt;Role, Integer&gt; implements
30 33  
31 34 @Autowired
32 35 ModuleRepository moduleRepository;
  36 +
  37 + SimpleDateFormat sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
33 38  
34 39 @Override
35 40 public Map<String, Object> save(Role t) {
... ... @@ -73,4 +78,29 @@ public class RoleServiceImpl extends BaseServiceImpl&lt;Role, Integer&gt; implements
73 78 }
74 79 return map;
75 80 }
  81 +
  82 + @Override
  83 + public Map<String, Object> roleInfo(Integer id) {
  84 + Map<String, Object> map = new HashMap<>();
  85 + Role role = roleRepository.findOne(id);
  86 + map.put("codeName", role.getCodeName());
  87 + map.put("roleName", role.getRoleName());
  88 + map.put("createDate", sdfMinute.format(role.getCreateDate()));
  89 + map.put("updateDate", sdfMinute.format(role.getUpdateDate()));
  90 + map.put("enable", role.isEnable()==true?1:0);
  91 + map.put("descriptions", role.getDescriptions());
  92 + map.put("modules", role.getModules().size());
  93 + map.put("resources", role.getResources().size());
  94 + String userNames = "";
  95 + Set<SysUser> users = role.getUsers();
  96 + if(!users.isEmpty()){
  97 + Iterator<SysUser> it = users.iterator();
  98 + while(it.hasNext()){
  99 + SysUser user = it.next();
  100 + userNames = user.getUserName()+"...";
  101 + }
  102 + }
  103 + map.put("userNames", userNames);
  104 + return map;
  105 + }
76 106 }
... ...
src/main/java/com/bsth/service/sys/impl/SysUserServiceImpl.java
... ... @@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
8 8  
9 9 import com.bsth.entity.sys.SysUser;
10 10 import com.bsth.repository.sys.SysUserRepository;
  11 +import com.bsth.security.util.SecurityUtils;
11 12 import com.bsth.service.impl.BaseServiceImpl;
12 13 import com.bsth.service.sys.SysUserService;
13 14  
... ... @@ -25,7 +26,12 @@ public class SysUserServiceImpl extends BaseServiceImpl&lt;SysUser, Integer&gt; implem
25 26 @Override
26 27 public Map<String, Object> save(SysUser t) {
27 28 //
28   - t.setPassword(new BCryptPasswordEncoder(4).encode(t.getPassword()));
  29 + if(t.getPassword() == null || t.getPassword().trim().equals("")){
  30 + SysUser user = sysUserRepository.findOne(t.getId());
  31 + t.setPassword(user.getPassword());
  32 + }else{
  33 + t.setPassword(new BCryptPasswordEncoder(4).encode(t.getPassword()));
  34 + }
29 35 return super.save(t);
30 36 }
31 37  
... ...
src/main/resources/static/pages/forms/statement/scheduleDaily_minhang.html
... ... @@ -82,23 +82,23 @@
82 82 <td>援外</td>
83 83 <td>其他</td>
84 84 <td>全日</td>
85   - <td>6:31~8:30</td>
86   - <td>16:01~18:00</td>
  85 + <td>6:31~<br>8:30</td>
  86 + <td>16:01~<br>18:00</td>
87 87 <td>全日</td>
88   - <td>6:31~8:30</td>
89   - <td>16:01~18:00</td>
  88 + <td>6:31~<br>8:30</td>
  89 + <td>16:01~<br>18:00</td>
90 90 <td>全日</td>
91   - <td>6:31~8:30</td>
92   - <td>16:01~18:00</td>
  91 + <td>6:31~<br>8:30</td>
  92 + <td>16:01~<br>18:00</td>
93 93 <td>全日</td>
94   - <td>6:31~8:30</td>
95   - <td>16:01~18:00</td>
  94 + <td>6:31~<br>8:30</td>
  95 + <td>16:01~<br>18:00</td>
96 96 <td>全日</td>
97   - <td>6:31~8:30</td>
98   - <td>16:01~18:00</td>
  97 + <td>6:31~<br>8:30</td>
  98 + <td>16:01~<br>18:00</td>
99 99 <td>全日</td>
100   - <td>6:31~8:30</td>
101   - <td>16:01~18:00</td>
  100 + <td>6:31~<br>8:30</td>
  101 + <td>16:01~<br>18:00</td>
102 102 </tr>
103 103 </thead>
104 104 <tr>
... ... @@ -111,37 +111,40 @@
111 111 <td colspan="40">&nbsp;</td>
112 112 </tr>
113 113 <tr>
114   - <td colspan="2">班</td>
  114 + <td colspan="2">班</td>
115 115 <td colspan="2">车号</td>
116 116 <td>司早</td>
117 117 <td>售早</td>
118 118 <td>司晚</td>
119 119 <td>售晚</td>
120   - <td colspan="2">班</td>
  120 + <td colspan="2">班</td>
121 121 <td colspan="2">车号</td>
122 122 <td>司早</td>
123 123 <td>售早</td>
124 124 <td>司晚</td>
125 125 <td>售晚</td>
126   - <td colspan="2">班</td>
  126 + <td colspan="2">班</td>
127 127 <td colspan="2">车号</td>
128 128 <td>司早</td>
129 129 <td>售早</td>
130 130 <td>司晚</td>
131 131 <td>售晚</td>
132   - <td colspan="2">班</td>
  132 + <td colspan="2">班</td>
133 133 <td colspan="2">车号</td>
134 134 <td>司早</td>
135 135 <td>售早</td>
136 136 <td>司晚</td>
137 137 <td>售晚</td>
138   - <td colspan="2">班</td>
  138 + <td colspan="2">班</td>
139 139 <td colspan="2">车号</td>
140 140 <td>司早</td>
141 141 <td>售早</td>
142 142 <td>司晚</td>
143 143 <td>售晚</td>
144 144 </tr>
  145 + <tbody class="scheduleDaily_2">
  146 +
  147 + </tbody>
145 148 <tr>
146 149 <td colspan="40">&nbsp;</td>
147 150 </tr>
... ... @@ -190,7 +193,7 @@
190 193 <td>慢</td>
191 194 <td>&nbsp;</td>
192 195 </tr>
193   - <tbody>
  196 + <tbody class="scheduleDaily_3">
194 197  
195 198 </tbody>
196 199 </table>
... ... @@ -253,21 +256,63 @@
253 256 $("#query").on('click',function(){
254 257 var line = $("#line").val();
255 258 var date = $("#date").val();
256   - $.get('/realSchedule/scheduleDaily',{line:line,date:date},function(result){
257   -
  259 + $.get('/realSchedule/queryUserInfo',{line:line,date:date},function(result){
  260 + var scheduleDaily_2 = template('scheduleDaily_2',{list:result});
  261 + $('#forms .scheduleDaily_2').html(scheduleDaily_2);
  262 + });
  263 + $.get('/realSchedule/realScheduleList',{line:line,date:date},function(result){
  264 + var scheduleDaily_3 = template('scheduleDaily_3',{list:result});
  265 + $('#forms .scheduleDaily_3').html(scheduleDaily_3);
258 266 });
  267 +
259 268 });
260 269 });
261 270 </script>
262   -<script type="text/html" id="list_forms">
  271 +<script type="text/html" id="scheduleDaily_2">
263 272 {{each list as obj i}}
  273 + {{if i%5 == 0}}
  274 + <tr>
  275 + {{/if}}
  276 + <td colspan="2">{{obj.lpName}}</td>
  277 + <td colspan="2">{{obj.clZbh}}</td>
  278 + <td>{{obj.jGh}}</td>
  279 + <td>{{obj.sGh}}</td>
  280 + <td>&nbsp;</td>
  281 + <td>&nbsp;</td>
  282 + {{if (i+1)%5 == 0}}
  283 + </tr>
  284 + {{/if}}
  285 + {{/each}}
  286 + {{if list.length == 0}}
264 287 <tr>
265   -
  288 + <td colspan="40"><h6 class="muted">没有找到相关数据</h6></td>
266 289 </tr>
  290 + {{/if}}
  291 +</script>
  292 +<script type="text/html" id="scheduleDaily_3">
  293 + {{each list as obj i}}
  294 + {{if i%3 == 0}}
  295 + <tr>
  296 + {{/if}}
  297 + <td>{{obj.lpName}}</td>
  298 + <td colspan="2">{{obj.qdzName}}</td>
  299 + <td>{{obj.zdsj}}</td>
  300 + <td>{{obj.zdsjActual}}</td>
  301 + <td>&nbsp;</td>
  302 + <td>&nbsp;</td>
  303 + <td>{{obj.fcsj}}</td>
  304 + <td>{{obj.fcsjActual}}</td>
  305 + <td>&nbsp;</td>
  306 + <td>&nbsp;</td>
  307 + <td colspan="2">{{obj.remarks}}</td>
  308 + {{if (i+1)%3 == 0}}
  309 + <td>&nbsp;</td>
  310 + </tr>
  311 + {{/if}}
267 312 {{/each}}
268 313 {{if list.length == 0}}
269 314 <tr>
270   - <td colspan="6"><h6 class="muted">没有找到相关数据</h6></td>
  315 + <td colspan="40"><h6 class="muted">没有找到相关数据</h6></td>
271 316 </tr>
272 317 {{/if}}
273 318 </script>
274 319 \ No newline at end of file
... ...
src/main/resources/static/pages/forms/statement/waybill_minhang.html
... ... @@ -99,6 +99,7 @@
99 99 $('#line').select2({
100 100 ajax: {
101 101 url: '/realSchedule/findLine',
  102 + type: 'post',
102 103 dataType: 'json',
103 104 delay: 150,
104 105 data: function(params){
... ... @@ -170,13 +171,13 @@
170 171 $('#forms .ludan_1').append(ludan_1);
171 172 //$('#forms .ludan_4').append(ludan_4);
172 173 });
173   - $get('/realSchedule/queryListWaybill',{jName:jName,clZbh:params[1],lpName:params[2]},function(result){
  174 + $post('/realSchedule/queryListWaybill',{jName:jName,clZbh:params[1],lpName:params[2]},function(result){
174 175 getTime(result);
175 176 var ludan_2 = template('ludan_2',{list:result});
176 177 // 把渲染好的模版html文本追加到表格中
177 178 $('#forms .ludan_2').append(ludan_2);
178 179 });
179   - $get('/realSchedule/findKMBC',{jName:jName,clZbh:params[1],lpName:params[2]},function(result){
  180 + $post('/realSchedule/findKMBC',{jName:jName,clZbh:params[1],lpName:params[2]},function(result){
180 181 var ludan_3 = template('ludan_3',result);
181 182 $('#forms .ludan_3').append(ludan_3);
182 183 });
... ... @@ -184,7 +185,7 @@
184 185 });
185 186  
186 187 $("#export").on("click",function(){
187   - $get('/realSchedule/exportWaybill',{jName:jName,clZbh:params[1],lpName:params[2]},function(result){
  188 + $post('/realSchedule/exportWaybill',{jName:jName,clZbh:params[1],lpName:params[2]},function(result){
188 189 window.open("/downloadFile/download?fileName="+jName);
189 190 });
190 191 });
... ...
src/main/resources/static/pages/permission/role/settings.html
... ... @@ -71,21 +71,21 @@
71 71 <li class="mt-list-item" style="border-bottom:none;">
72 72 <div class="list-item-content">
73 73 <h5 class="uppercase">
74   - <span><i class="fa fa-columns"></i> 模块数:...</span>
  74 + <span><i class="fa fa-columns"></i> 模块数:{{modules}}</span>
75 75 </h5>
76 76 </div>
77 77 </li>
78 78 <li class="mt-list-item" style="border-bottom:none;">
79 79 <div class="list-item-content">
80 80 <h5 class="uppercase">
81   - <span><i class="fa fa-users"></i> 用户:张三,李四,王五,刘六</span>
  81 + <span><i class="fa fa-users"></i> 用户:{{userNames}}</span>
82 82 </h5>
83 83 </div>
84 84 </li>
85 85 <li class="mt-list-item" style="border-bottom:none;">
86 86 <div class="list-item-content">
87 87 <h5 class="uppercase">
88   - <span><i class="fa fa-ambulance"></i> 资源数:...</span>
  88 + <span><i class="fa fa-ambulance"></i> 资源数:{{resources}}</span>
89 89 </h5>
90 90 </div>
91 91 </li>
... ... @@ -132,11 +132,14 @@ $(function(){
132 132 alert('缺少主键');
133 133 }
134 134 else{
135   - $get('/role/' + id ,null, function(obj){
136   - roleObj = obj;
  135 + $get('/role/roleInfo' ,{id:id}, function(obj){
  136 + $('.caption-helper').text(obj.updateDate);
137 137 var htmlStr = template('role_detail_temp', obj);
138 138 $('.mt-list-container').html(htmlStr);
139 139 });
  140 + $get('/role/' + id ,null, function(obj){
  141 + roleObj = obj;
  142 + });
140 143 }
141 144  
142 145 $('#saveModuleSett').on('click', function(){
... ...
src/main/resources/static/pages/permission/user/edit.html
1   -我是详细
2 1 \ No newline at end of file
  2 +<div class="page-head">
  3 + <div class="page-title">
  4 + <h1>编辑用户</h1>
  5 + </div>
  6 +</div>
  7 +
  8 +<ul class="page-breadcrumb breadcrumb">
  9 + <li><a href="/pages/home.html" data-pjax>首页</a> <i class="fa fa-circle"></i></li>
  10 + <li><span class="active">权限管理</span> <i class="fa fa-circle"></i></li>
  11 + <li><a href="list.html" data-pjax>用户管理</a> <i class="fa fa-circle"></i></li>
  12 + <li><span class="active">编辑用户</span></li>
  13 +</ul>
  14 +
  15 +<div class="portlet light bordered">
  16 + <div class="portlet-title">
  17 + <div class="caption">
  18 + <i class="icon-equalizer font-red-sunglo"></i> <span
  19 + class="caption-subject font-red-sunglo bold uppercase">表单</span>
  20 + </div>
  21 + </div>
  22 + <div class="portlet-body form">
  23 + <form action="/addUser" class="form-horizontal" id="user_edit_form" >
  24 + <div class="alert alert-danger display-hide">
  25 + <button class="close" data-close="alert"></button>
  26 + 您的输入有误,请检查下面的输入项
  27 + </div>
  28 + <div class="form-body">
  29 + <div class="form-group">
  30 + <label class="col-md-3 control-label">登录名</label>
  31 + <div class="col-md-4">
  32 + <input type="hidden" id="id" name="id">
  33 + <input type="text" class="form-control" id="userName" name="userName" readonly="readonly">
  34 + <span class="help-block"> 登录时的帐号</span>
  35 + </div>
  36 + </div>
  37 + <div class="form-group">
  38 + <label class="col-md-3 control-label">姓名</label>
  39 + <div class="col-md-4">
  40 + <input type="text" class="form-control" id="name" name="name" readonly="readonly">
  41 + </div>
  42 + </div>
  43 + <div class="form-group">
  44 + <label class="col-md-3 control-label">所属机构</label>
  45 + <div class="col-md-4">
  46 + <input type="text" class="form-control" id="agencies" name="agencies" >
  47 + </div>
  48 + </div>
  49 +
  50 + <div class="form-group">
  51 + <label class="col-md-3 control-label">角色</label>
  52 + <div class="col-md-4">
  53 + <select class="form-control" id="role" name="roles[]" style="width: 160px;" multiple="multiple">
  54 +
  55 + </select>
  56 + </div>
  57 + </div>
  58 +
  59 + <div class="form-group">
  60 + <label class="col-md-3 control-label">是否启用</label>
  61 + <div class="col-md-4">
  62 + <div class="input-group">
  63 + <select class="form-control" id="enabled" name="enabled" style="width: 160px;">
  64 + <option value="1">可用</option>
  65 + <option value="0">禁用</option>
  66 + </select>
  67 + </div>
  68 + </div>
  69 + </div>
  70 + </div>
  71 + <div class="form-actions">
  72 + <div class="row">
  73 + <div class="col-md-offset-3 col-md-4">
  74 + <button type="submit" class="btn green" ><i class="fa fa-check"></i> 提交</button>
  75 + <a type="button" class="btn default" href="list.html" data-pjax><i class="fa fa-times"></i> 取消</a>
  76 + </div>
  77 + </div>
  78 + </div>
  79 + </form>
  80 + <!-- END FORM-->
  81 + </div>
  82 +</div>
  83 +<script>
  84 + $(function(){
  85 + var id = $.url().param('no');
  86 + if(id){
  87 + $get('/user/'+id,null,function(obj){
  88 + $("#id").attr('value',obj.id);
  89 + $("#userName").attr('value',obj.userName);
  90 + $("#name").attr('value',obj.name);
  91 + $("#agencies").attr('value',obj.agencies);
  92 + $get('/role/all',null,function(result){
  93 + $.each(result,function(i,r){
  94 + $("#role").append("<option value='"+r.id+"'>"+r.roleName+"</option>");
  95 + });
  96 + $.each(obj.roles,function(i,obt){
  97 + $("#role option[value="+obt.id+"]").attr("selected",true);
  98 + });
  99 + });
  100 + if(obj.enabled){
  101 + $("#enabled option[value=1]").attr("selected",true);
  102 + }else{
  103 + $("#enabled option[value=0]").attr("selected",true);
  104 + }
  105 + });
  106 +
  107 + }else {
  108 +
  109 + // 缺少ID
  110 + layer.confirm('【ID缺失,请点击返回,重新进行修改操作】', {btn : [ '返回' ],icon: 3, title:'提示'}, function(index){
  111 +
  112 + // 关闭弹出层
  113 + layer.close(index);
  114 +
  115 + // 跳转到list页面
  116 + loadPage('list.html');
  117 +
  118 + });
  119 + }
  120 +
  121 + var form = $('#user_edit_form');
  122 + var error = $('.alert-danger', form);
  123 +
  124 + //表单 validate
  125 + form.validate({
  126 + errorElement : 'span',
  127 + errorClass : 'help-block help-block-error',
  128 + focusInvalid : false,
  129 + rules : {
  130 + 'userName' : {
  131 + required : true,
  132 + maxlength: 25
  133 + },
  134 + 'name' : {
  135 + required : true,
  136 + maxlength: 25
  137 + },
  138 + 'role' : {
  139 + required : true,
  140 + minlength: 1
  141 + }
  142 + },
  143 + invalidHandler : function(event, validator) {
  144 + error.show();
  145 + App.scrollTo(error, -200);
  146 + },
  147 +
  148 + highlight : function(element) {
  149 + $(element).closest('.form-group').addClass('has-error');
  150 + },
  151 +
  152 + unhighlight : function(element) {
  153 + $(element).closest('.form-group').removeClass('has-error');
  154 + },
  155 +
  156 + success : function(label) {
  157 + label.closest('.form-group').removeClass('has-error');
  158 + },
  159 +
  160 + submitHandler : function(f) {
  161 + debugger
  162 + var params = form.serializeJSON();
  163 + error.hide();
  164 + console.log(params);
  165 +
  166 + //检查一下用户是否存在
  167 + $.ajax({
  168 + url: '/user',
  169 + type: 'POST',
  170 + traditional: true,
  171 + data: params,
  172 + success: function(res){
  173 + layer.msg('修改用户信息成功.');
  174 + loadPage('list.html');
  175 + }
  176 + });
  177 + }
  178 + });
  179 + });
  180 +</script>
3 181 \ No newline at end of file
... ...
src/main/resources/static/pages/permission/user/list.html
... ... @@ -133,11 +133,7 @@
133 133 {{obj.lastLoginDate}}
134 134 </td>
135 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}}
  136 + <a class="btn btn-sm blue btn-outline" href="edit.html?no={{obj.id}}"><i class="fa fa-edit"></i> 编辑</a>
141 137 </td>
142 138 </tr>
143 139 {{/each}}
... ... @@ -194,6 +190,9 @@ $(function(){
194 190 params['page'] = page;
195 191 var i = layer.load(2);
196 192 $get('/user' ,params, function(data){
  193 + $.each(data.content, function(i, obj) {
  194 + obj.lastLoginDate = moment(obj.lastLoginDate).format("YYYY-MM-DD HH:mm:ss");
  195 + });
197 196 var bodyHtm = template('user_list_temp', {list: data.content});
198 197  
199 198 $('#datatable_user tbody').html(bodyHtm)
... ...