Commit 12df354290778fa279f780fab3ca495cd4c72817
1 parent
edd43a19
PSM-14
Showing
13 changed files
with
779 additions
and
179 deletions
src/main/java/com/bsth/controller/BaseController2.java
0 → 100644
| 1 | +package com.bsth.controller; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import com.bsth.common.ResponseCode; | ||
| 5 | +import com.bsth.service.BaseService; | ||
| 6 | +import com.bsth.service.schedule.utils.DataImportExportService; | ||
| 7 | +import com.google.common.base.Splitter; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.data.domain.Page; | ||
| 10 | +import org.springframework.data.domain.PageRequest; | ||
| 11 | +import org.springframework.data.domain.Sort; | ||
| 12 | +import org.springframework.web.bind.annotation.*; | ||
| 13 | +import org.springframework.web.multipart.MultipartFile; | ||
| 14 | + | ||
| 15 | +import javax.servlet.http.HttpServletResponse; | ||
| 16 | +import java.io.*; | ||
| 17 | +import java.util.ArrayList; | ||
| 18 | +import java.util.HashMap; | ||
| 19 | +import java.util.List; | ||
| 20 | +import java.util.Map; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * Created by xu on 16/11/3. | ||
| 24 | + */ | ||
| 25 | +public class BaseController2<T, ID extends Serializable> { | ||
| 26 | + | ||
| 27 | + @Autowired | ||
| 28 | + protected BaseService<T, ID> baseService; | ||
| 29 | + @Autowired | ||
| 30 | + DataImportExportService dataImportExportService; | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * | ||
| 34 | + * @Title: list | ||
| 35 | + * @Description: TODO(多条件分页查询) | ||
| 36 | + * @param @param map 查询条件 | ||
| 37 | + * @param @param page 页码 | ||
| 38 | + * @param @param size 每页显示数量 | ||
| 39 | + * @throws | ||
| 40 | + */ | ||
| 41 | + @RequestMapping(method = RequestMethod.GET) | ||
| 42 | + public Page<T> list(@RequestParam Map<String, Object> map, | ||
| 43 | + @RequestParam(defaultValue = "0") int page, | ||
| 44 | + @RequestParam(defaultValue = "10") int size, | ||
| 45 | + @RequestParam(defaultValue = "id") String order, | ||
| 46 | + @RequestParam(defaultValue = "DESC") String direction){ | ||
| 47 | + | ||
| 48 | + // 允许多个字段排序,order可以写单个字段,也可以写多个字段 | ||
| 49 | + // 多个字段格式:{col1},{col2},{col3},....,{coln} | ||
| 50 | + List<String> order_columns = Splitter.on(",").trimResults().splitToList(order); | ||
| 51 | + // 多字段排序:DESC,ASC... | ||
| 52 | + List<String> order_dirs = Splitter.on(",").trimResults().splitToList(direction); | ||
| 53 | + | ||
| 54 | + if (order_dirs.size() == 1) { // 所有字段采用一种排序 | ||
| 55 | + if (null != order_dirs.get(0) && order_dirs.get(0).equals("ASC")) { | ||
| 56 | + return baseService.list(map, new PageRequest(page, size, new Sort(Sort.Direction.ASC, order_columns))); | ||
| 57 | + } else { | ||
| 58 | + return baseService.list(map, new PageRequest(page, size, new Sort(Sort.Direction.DESC, order_columns))); | ||
| 59 | + } | ||
| 60 | + } else if (order_columns.size() == order_dirs.size()) { | ||
| 61 | + List<Sort.Order> orderList = new ArrayList<>(); | ||
| 62 | + for (int i = 0; i < order_columns.size(); i++) { | ||
| 63 | + if (null != order_dirs.get(i) && order_dirs.get(i).equals("ASC")) { | ||
| 64 | + orderList.add(new Sort.Order(Sort.Direction.ASC, order_columns.get(i))); | ||
| 65 | + } else { | ||
| 66 | + orderList.add(new Sort.Order(Sort.Direction.DESC, order_columns.get(i))); | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + return baseService.list(map, new PageRequest(page, size, new Sort(orderList))); | ||
| 70 | + } else { | ||
| 71 | + throw new RuntimeException("多字段排序参数格式问题,排序顺序和字段数不一致"); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * | ||
| 77 | + * @Title: list | ||
| 78 | + * @Description: TODO(多条件查询) | ||
| 79 | + * @param @param map | ||
| 80 | + * @throws | ||
| 81 | + */ | ||
| 82 | + @RequestMapping(value = "/all", method = RequestMethod.GET) | ||
| 83 | + public Iterable<T> list(@RequestParam Map<String, Object> map){ | ||
| 84 | + return baseService.list(map); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + /** | ||
| 88 | + * 这里保存直接返回保存后的对象,不自己定义Map返回了,和前端angularjs配合。 | ||
| 89 | + * form也可以提交,但是页面参数可能不全, | ||
| 90 | + * json的化比较灵活,但是貌似有多余属性也会报错,或者碰到lazy属性值,也有问题 | ||
| 91 | + * 不论form,还是json提交都能解决问题,就看哪个方便哪个来 | ||
| 92 | + * | ||
| 93 | + * @param t 参数需要使用@RequestBody转换json成对象 | ||
| 94 | + * @return | ||
| 95 | + */ | ||
| 96 | + @RequestMapping(method = RequestMethod.POST) | ||
| 97 | + public T save(@RequestBody T t) { | ||
| 98 | + baseService.save(t); | ||
| 99 | + return t; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + /** | ||
| 103 | + * | ||
| 104 | + * @Title: findById | ||
| 105 | + * @Description: TODO(根据主键获取单个对象) | ||
| 106 | + * @param @param id | ||
| 107 | + * @throws | ||
| 108 | + */ | ||
| 109 | + @RequestMapping(value="/{id}",method = RequestMethod.GET) | ||
| 110 | + public T findById(@PathVariable("id") ID id){ | ||
| 111 | + return baseService.findById(id); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + /** | ||
| 115 | + * | ||
| 116 | + * @Title: delete | ||
| 117 | + * @Description: TODO(根据主键删除对象) | ||
| 118 | + * @param @param id | ||
| 119 | + * @throws | ||
| 120 | + */ | ||
| 121 | + @RequestMapping(value="/{id}",method = RequestMethod.DELETE) | ||
| 122 | + public Map<String, Object> delete(@PathVariable("id") ID id){ | ||
| 123 | + return baseService.delete(id); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + /** | ||
| 127 | + * 上传数据文件,并使用ktr转换文件导入数据。 | ||
| 128 | + * @param file | ||
| 129 | + * @return | ||
| 130 | + * @throws Exception | ||
| 131 | + */ | ||
| 132 | + @RequestMapping(value = "/dataImport", method = RequestMethod.POST) | ||
| 133 | + public Map<String, Object> uploadDataAndImport(MultipartFile file) throws Exception { | ||
| 134 | + Map<String, Object> resultMap = new HashMap<>(); | ||
| 135 | + | ||
| 136 | + try { | ||
| 137 | + // 获取ktr转换文件绝对路径 | ||
| 138 | + File ktrfile = new File(this.getClass().getResource(getDataImportKtrClasspath()).toURI()); | ||
| 139 | + System.out.println(ktrfile.getAbsolutePath()); | ||
| 140 | + // 导入数据 | ||
| 141 | + dataImportExportService.fileDataImport(file, ktrfile); | ||
| 142 | + | ||
| 143 | + resultMap.put("status", ResponseCode.SUCCESS); | ||
| 144 | + resultMap.put("msg", "导入成功"); | ||
| 145 | + } catch (Exception exp) { | ||
| 146 | + exp.printStackTrace(); | ||
| 147 | + resultMap.put("status", ResponseCode.ERROR); | ||
| 148 | + resultMap.put("msg", exp.getLocalizedMessage()); | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + return resultMap; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + /** | ||
| 155 | + * 使用ktr导出数据。 | ||
| 156 | + * @param response | ||
| 157 | + * @throws Exception | ||
| 158 | + */ | ||
| 159 | + @RequestMapping(value = "/dataExport", method = RequestMethod.GET) | ||
| 160 | + public void dataExport(HttpServletResponse response) throws Exception { | ||
| 161 | + // 1、使用ktr转换获取输出文件 | ||
| 162 | + File ktrfile = new File(this.getClass().getResource(getDataExportKtrClasspath()).toURI()); | ||
| 163 | + File outputfile = dataImportExportService.fileDataOutput( | ||
| 164 | + getDataExportFilename(), | ||
| 165 | + ktrfile); | ||
| 166 | + | ||
| 167 | + System.out.println(outputfile.getName()); | ||
| 168 | + String filePath = outputfile.getAbsolutePath(); | ||
| 169 | + String fp[] = filePath.split(File.separator); | ||
| 170 | + String fileName = fp[fp.length - 1]; | ||
| 171 | + | ||
| 172 | + // TODO:使用ktr获取导出数据 | ||
| 173 | + | ||
| 174 | + response.setHeader("conent-type", "application/octet-stream"); | ||
| 175 | + response.setContentType("application/octet-stream"); | ||
| 176 | + response.setHeader("Content-Disposition", "attachment; filename=" + "东东"); | ||
| 177 | + | ||
| 178 | + OutputStream os = response.getOutputStream(); | ||
| 179 | + BufferedOutputStream bos = new BufferedOutputStream(os); | ||
| 180 | + | ||
| 181 | + InputStream is = null; | ||
| 182 | + | ||
| 183 | + is = new FileInputStream(filePath); | ||
| 184 | + BufferedInputStream bis = new BufferedInputStream(is); | ||
| 185 | + | ||
| 186 | + int length = 0; | ||
| 187 | + byte[] temp = new byte[1 * 1024 * 10]; | ||
| 188 | + | ||
| 189 | + while ((length = bis.read(temp)) != -1) { | ||
| 190 | + bos.write(temp, 0, length); | ||
| 191 | + } | ||
| 192 | + bos.flush(); | ||
| 193 | + bis.close(); | ||
| 194 | + bos.close(); | ||
| 195 | + is.close(); | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + /** | ||
| 199 | + * @return 数据导出的ktr转换文件类路径。 | ||
| 200 | + */ | ||
| 201 | + protected String getDataExportKtrClasspath() { | ||
| 202 | + // 默认返回异常,子类如果要使用导出功能,必须覆写此方法,指定ktr文件类路径 | ||
| 203 | + throw new RuntimeException("必须override,并指定ktr classpath"); | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + /** | ||
| 207 | + * @return 导出文件名。 | ||
| 208 | + */ | ||
| 209 | + protected String getDataExportFilename() { | ||
| 210 | + // 默认返回异常,子类如果要使用导出功能,必须覆写此方法,指定导出的文件路径名 | ||
| 211 | + throw new RuntimeException("必须override,并指定导出文件名"); | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + /** | ||
| 215 | + * @return 数据导入的ktr转换文件类路径。 | ||
| 216 | + */ | ||
| 217 | + protected String getDataImportKtrClasspath() { | ||
| 218 | + // 默认返回异常,子类如果要使用导入功能,必须覆写此方法,指定ktr文件类路径 | ||
| 219 | + throw new RuntimeException("必须override,并指定ktr classpath"); | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | +} |
src/main/java/com/bsth/controller/schedule/TTInfoController.java
| 1 | package com.bsth.controller.schedule; | 1 | package com.bsth.controller.schedule; |
| 2 | 2 | ||
| 3 | -import com.bsth.controller.BaseController; | 3 | +import com.bsth.controller.BaseController2; |
| 4 | import com.bsth.entity.schedule.TTInfo; | 4 | import com.bsth.entity.schedule.TTInfo; |
| 5 | import com.bsth.repository.schedule.TTInfoDetailRepository; | 5 | import com.bsth.repository.schedule.TTInfoDetailRepository; |
| 6 | import com.bsth.repository.schedule.TTInfoRepository; | 6 | import com.bsth.repository.schedule.TTInfoRepository; |
| @@ -18,7 +18,7 @@ import java.util.Map; | @@ -18,7 +18,7 @@ import java.util.Map; | ||
| 18 | @RestController | 18 | @RestController |
| 19 | @RequestMapping("tic") | 19 | @RequestMapping("tic") |
| 20 | @EnableConfigurationProperties(DataToolsProperties.class) | 20 | @EnableConfigurationProperties(DataToolsProperties.class) |
| 21 | -public class TTInfoController extends BaseController<TTInfo, Long> { | 21 | +public class TTInfoController extends BaseController2<TTInfo, Long> { |
| 22 | @Autowired | 22 | @Autowired |
| 23 | private DataToolsProperties dataToolsProperties; | 23 | private DataToolsProperties dataToolsProperties; |
| 24 | @Autowired | 24 | @Autowired |
| @@ -31,20 +31,6 @@ public class TTInfoController extends BaseController<TTInfo, Long> { | @@ -31,20 +31,6 @@ public class TTInfoController extends BaseController<TTInfo, Long> { | ||
| 31 | return dataToolsProperties.getTtinfoDatainputktr(); | 31 | return dataToolsProperties.getTtinfoDatainputktr(); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | - /** | ||
| 35 | - * 覆写方法,因为form提交的方式参数不全,改用 json形式提交 @RequestBody | ||
| 36 | - * @Title: save | ||
| 37 | - * @Description: TODO(持久化对象) | ||
| 38 | - * @param @param t | ||
| 39 | - * @param @return 设定文件 | ||
| 40 | - * @return Map<String,Object> {status: 1(成功),-1(失败)} | ||
| 41 | - * @throws | ||
| 42 | - */ | ||
| 43 | - @RequestMapping(method = RequestMethod.POST) | ||
| 44 | - public Map<String, Object> save(@RequestBody TTInfo t){ | ||
| 45 | - return baseService.save(t); | ||
| 46 | - } | ||
| 47 | - | ||
| 48 | @Override | 34 | @Override |
| 49 | public TTInfo findById(@PathVariable("id") Long aLong) { | 35 | public TTInfo findById(@PathVariable("id") Long aLong) { |
| 50 | return ttInfoRepository.findOneExtend(aLong); | 36 | return ttInfoRepository.findOneExtend(aLong); |
src/main/java/com/bsth/service/impl/BaseServiceImpl.java
| @@ -45,14 +45,9 @@ public class BaseServiceImpl<T, ID extends Serializable> implements BaseService< | @@ -45,14 +45,9 @@ public class BaseServiceImpl<T, ID extends Serializable> implements BaseService< | ||
| 45 | @Override | 45 | @Override |
| 46 | public Map<String, Object> save(T t) { | 46 | public Map<String, Object> save(T t) { |
| 47 | Map<String, Object> map = new HashMap<>(); | 47 | Map<String, Object> map = new HashMap<>(); |
| 48 | - try{ | ||
| 49 | - baseRepository.save(t); | ||
| 50 | - map.put("status", ResponseCode.SUCCESS); | ||
| 51 | - map.put("t", t); | ||
| 52 | - }catch(Exception e){ | ||
| 53 | - map.put("status", ResponseCode.ERROR); | ||
| 54 | - logger.error("save erro.", e); | ||
| 55 | - } | 48 | + baseRepository.save(t); |
| 49 | + map.put("status", ResponseCode.SUCCESS); | ||
| 50 | + map.put("t", t); | ||
| 56 | return map; | 51 | return map; |
| 57 | } | 52 | } |
| 58 | 53 |
src/main/java/com/bsth/service/schedule/TTInfoServiceImpl.java
| @@ -5,7 +5,6 @@ import com.bsth.entity.schedule.TTInfo; | @@ -5,7 +5,6 @@ import com.bsth.entity.schedule.TTInfo; | ||
| 5 | import com.bsth.repository.schedule.TTInfoRepository; | 5 | import com.bsth.repository.schedule.TTInfoRepository; |
| 6 | import com.bsth.service.impl.BaseServiceImpl; | 6 | import com.bsth.service.impl.BaseServiceImpl; |
| 7 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| 8 | -import org.springframework.dao.DataIntegrityViolationException; | ||
| 9 | import org.springframework.stereotype.Service; | 8 | import org.springframework.stereotype.Service; |
| 10 | 9 | ||
| 11 | import javax.transaction.Transactional; | 10 | import javax.transaction.Transactional; |
| @@ -21,19 +20,28 @@ public class TTInfoServiceImpl extends BaseServiceImpl<TTInfo, Long> implements | @@ -21,19 +20,28 @@ public class TTInfoServiceImpl extends BaseServiceImpl<TTInfo, Long> implements | ||
| 21 | @Autowired | 20 | @Autowired |
| 22 | private TTInfoRepository ttInfoRepository; | 21 | private TTInfoRepository ttInfoRepository; |
| 23 | 22 | ||
| 23 | + @Transactional | ||
| 24 | @Override | 24 | @Override |
| 25 | public Map<String, Object> delete(Long aLong) { | 25 | public Map<String, Object> delete(Long aLong) { |
| 26 | + // 获取待作废的数据 | ||
| 26 | TTInfo ttInfo = ttInfoRepository.findOne(aLong); | 27 | TTInfo ttInfo = ttInfoRepository.findOne(aLong); |
| 27 | - ttInfo.setIsCancel(true); | 28 | + |
| 29 | + toogleIsCancel(ttInfo); | ||
| 28 | 30 | ||
| 29 | Map<String, Object> map = new HashMap<>(); | 31 | Map<String, Object> map = new HashMap<>(); |
| 30 | - try{ | ||
| 31 | - ttInfoRepository.save(ttInfo); | ||
| 32 | - map.put("status", ResponseCode.SUCCESS); | ||
| 33 | - }catch(DataIntegrityViolationException de){ | ||
| 34 | - map.put("status", ResponseCode.ERROR); | ||
| 35 | - map.put("msg", "“完整性约束”校验失败,请检查要删除的对象是否存在外键约束"); | ||
| 36 | - } | 32 | + map.put("status", ResponseCode.SUCCESS); |
| 33 | + | ||
| 37 | return map; | 34 | return map; |
| 38 | } | 35 | } |
| 36 | + | ||
| 37 | + | ||
| 38 | + | ||
| 39 | + private void toogleIsCancel(TTInfo ttInfo) { | ||
| 40 | + boolean isCancel = ttInfo.getIsCancel(); | ||
| 41 | + if (isCancel) { | ||
| 42 | + ttInfo.setIsCancel(false); | ||
| 43 | + } else { | ||
| 44 | + ttInfo.setIsCancel(true); | ||
| 45 | + } | ||
| 46 | + } | ||
| 39 | } | 47 | } |
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
| @@ -339,32 +339,13 @@ angular.module('ScheduleApp').factory('TimeTableManageService_g', ['$resource', | @@ -339,32 +339,13 @@ angular.module('ScheduleApp').factory('TimeTableManageService_g', ['$resource', | ||
| 339 | return { | 339 | return { |
| 340 | rest: $resource( | 340 | rest: $resource( |
| 341 | '/tic/:id', | 341 | '/tic/:id', |
| 342 | - {order: 'createDate', direction: 'DESC', id: '@id_route'}, | 342 | + {order: 'xl,isCancel,isEnableDisTemplate,qyrq', direction: 'DESC,ASC,DESC,DESC', id: '@id_route'}, |
| 343 | { | 343 | { |
| 344 | list: { | 344 | list: { |
| 345 | method: 'GET', | 345 | method: 'GET', |
| 346 | params: { | 346 | params: { |
| 347 | - page: 0, | ||
| 348 | - isCancel_eq: 'false' | 347 | + page: 0 |
| 349 | } | 348 | } |
| 350 | - }, | ||
| 351 | - get: { | ||
| 352 | - method: 'GET' | ||
| 353 | - }, | ||
| 354 | - save: { | ||
| 355 | - method: 'POST' | ||
| 356 | - }, | ||
| 357 | - delete: { | ||
| 358 | - method: 'DELETE' | ||
| 359 | - } | ||
| 360 | - } | ||
| 361 | - ), | ||
| 362 | - validate: $resource( | ||
| 363 | - '/tic/validate/:type', | ||
| 364 | - {}, | ||
| 365 | - { | ||
| 366 | - ttinfoname: { | ||
| 367 | - method: 'GET' | ||
| 368 | } | 349 | } |
| 369 | } | 350 | } |
| 370 | ) | 351 | ) |
| @@ -696,6 +677,18 @@ angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', fun | @@ -696,6 +677,18 @@ angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', fun | ||
| 696 | } | 677 | } |
| 697 | } | 678 | } |
| 698 | ) | 679 | ) |
| 680 | + }, | ||
| 681 | + ttc1: { // 时刻表名字验证 | ||
| 682 | + template: {'xl.id_eq': -1, 'name_eq': 'ddd'}, | ||
| 683 | + remote: $resource( // $resource封装对象 | ||
| 684 | + '/tic/validate/equale', | ||
| 685 | + {}, | ||
| 686 | + { | ||
| 687 | + do: { | ||
| 688 | + method: 'GET' | ||
| 689 | + } | ||
| 690 | + } | ||
| 691 | + ) | ||
| 699 | } | 692 | } |
| 700 | } | 693 | } |
| 701 | 694 |
src/main/resources/static/pages/scheduleApp/module/common/prj-common-ui-route-state.js
| @@ -484,6 +484,8 @@ ScheduleApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvi | @@ -484,6 +484,8 @@ ScheduleApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvi | ||
| 484 | name: 'timeTableManage_module', | 484 | name: 'timeTableManage_module', |
| 485 | insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置 | 485 | insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置 |
| 486 | files: [ | 486 | files: [ |
| 487 | + "assets/bower_components/angular-ui-select/dist/select.min.css", | ||
| 488 | + "assets/bower_components/angular-ui-select/dist/select.min.js", | ||
| 487 | "assets/bower_components/angular-file-upload/dist/angular-file-upload.min.js", | 489 | "assets/bower_components/angular-file-upload/dist/angular-file-upload.min.js", |
| 488 | "pages/scheduleApp/module/core/timeTableManage/timeTableManage.js" | 490 | "pages/scheduleApp/module/core/timeTableManage/timeTableManage.js" |
| 489 | ] | 491 | ] |
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/edit.html
| 1 | <div class="page-head"> | 1 | <div class="page-head"> |
| 2 | <div class="page-title"> | 2 | <div class="page-title"> |
| 3 | - <h1>修改时刻表基础信息</h1> | 3 | + <h1>添加时刻表基础信息</h1> |
| 4 | </div> | 4 | </div> |
| 5 | </div> | 5 | </div> |
| 6 | 6 | ||
| @@ -43,17 +43,18 @@ | @@ -43,17 +43,18 @@ | ||
| 43 | <div class="form-group has-success has-feedback"> | 43 | <div class="form-group has-success has-feedback"> |
| 44 | <label class="col-md-2 control-label">线路*:</label> | 44 | <label class="col-md-2 control-label">线路*:</label> |
| 45 | <div class="col-md-3"> | 45 | <div class="col-md-3"> |
| 46 | - <sa-Select3 model="ctrl.timeTableManageForForm" | ||
| 47 | - name="xl" | ||
| 48 | - placeholder="请输拼音..." | ||
| 49 | - dcvalue="{{ctrl.timeTableManageForForm.xl.id}}" | 46 | + <sa-Select5 name="xl" |
| 47 | + model="ctrl.timeTableManageForForm" | ||
| 48 | + cmaps="{'xl.id' : 'id'}" | ||
| 50 | dcname="xl.id" | 49 | dcname="xl.id" |
| 51 | icname="id" | 50 | icname="id" |
| 52 | - icnames="name" | ||
| 53 | - datatype="xl" | ||
| 54 | - mlp="true" | 51 | + dsparams="{{ {type: 'ajax', param:{type: 'all'}, atype:'xl' } | json }}" |
| 52 | + iterobjname="item" | ||
| 53 | + iterobjexp="item.name" | ||
| 54 | + searchph="请输拼音..." | ||
| 55 | + searchexp="this.name" | ||
| 55 | required > | 56 | required > |
| 56 | - </sa-Select3> | 57 | + </sa-Select5> |
| 57 | </div> | 58 | </div> |
| 58 | <!-- 隐藏块,显示验证信息 --> | 59 | <!-- 隐藏块,显示验证信息 --> |
| 59 | <div class="alert alert-danger well-sm" ng-show="myForm.xl.$error.required"> | 60 | <div class="alert alert-danger well-sm" ng-show="myForm.xl.$error.required"> |
| @@ -76,8 +77,10 @@ | @@ -76,8 +77,10 @@ | ||
| 76 | <label class="col-md-2 control-label">时刻表名字*:</label> | 77 | <label class="col-md-2 control-label">时刻表名字*:</label> |
| 77 | <div class="col-md-3"> | 78 | <div class="col-md-3"> |
| 78 | <input type="text" class="form-control" ng-model="ctrl.timeTableManageForForm.name" | 79 | <input type="text" class="form-control" ng-model="ctrl.timeTableManageForForm.name" |
| 79 | - name="name" placeholder="请输入时刻表名字" required | ||
| 80 | - remote-Validaton rvtype="ttinfoname" rv1="{{ctrl.timeTableManageForForm.xl.id}}" | 80 | + name="name" placeholder="请输入时刻表名字..." required |
| 81 | + remote-Validation | ||
| 82 | + remotevtype="ttc1" | ||
| 83 | + remotevparam="{{ {'xl.id_eq': ctrl.timeTableManageForForm.xl.id, 'name_eq': ctrl.timeTableManageForForm.name} | json}}" | ||
| 81 | /> | 84 | /> |
| 82 | </div> | 85 | </div> |
| 83 | 86 | ||
| @@ -86,7 +89,7 @@ | @@ -86,7 +89,7 @@ | ||
| 86 | 时刻表名字必须填写 | 89 | 时刻表名字必须填写 |
| 87 | </div> | 90 | </div> |
| 88 | <div class="alert alert-danger well-sm" ng-show="myForm.name.$error.remote"> | 91 | <div class="alert alert-danger well-sm" ng-show="myForm.name.$error.remote"> |
| 89 | - 选择线路并且相同相同线路时刻表名字不能重复 | 92 | + 相同线路下的时刻表不能同名 |
| 90 | </div> | 93 | </div> |
| 91 | </div> | 94 | </div> |
| 92 | 95 | ||
| @@ -130,7 +133,7 @@ | @@ -130,7 +133,7 @@ | ||
| 130 | <label class="col-md-2 control-label">路牌数量:</label> | 133 | <label class="col-md-2 control-label">路牌数量:</label> |
| 131 | <div class="col-md-3"> | 134 | <div class="col-md-3"> |
| 132 | <input type="number" class="form-control" ng-model="ctrl.timeTableManageForForm.lpCount" | 135 | <input type="number" class="form-control" ng-model="ctrl.timeTableManageForForm.lpCount" |
| 133 | - name="lpCount" placeholder="请输入路牌数" min="1"/> | 136 | + name="lpCount" placeholder="请输入路牌数..." min="1"/> |
| 134 | </div> | 137 | </div> |
| 135 | <div class="alert alert-danger well-sm" ng-show="myForm.lpCount.$error.number"> | 138 | <div class="alert alert-danger well-sm" ng-show="myForm.lpCount.$error.number"> |
| 136 | 必须输入数字 | 139 | 必须输入数字 |
| @@ -144,7 +147,7 @@ | @@ -144,7 +147,7 @@ | ||
| 144 | <label class="col-md-2 control-label">营运圈数:</label> | 147 | <label class="col-md-2 control-label">营运圈数:</label> |
| 145 | <div class="col-md-3"> | 148 | <div class="col-md-3"> |
| 146 | <input type="number" class="form-control" ng-model="ctrl.timeTableManageForForm.loopCount" | 149 | <input type="number" class="form-control" ng-model="ctrl.timeTableManageForForm.loopCount" |
| 147 | - name="loopCount" placeholder="请输入圈数" min="1"/> | 150 | + name="loopCount" placeholder="请输入圈数..." min="1"/> |
| 148 | </div> | 151 | </div> |
| 149 | <div class="alert alert-danger well-sm" ng-show="myForm.loopCount.$error.number"> | 152 | <div class="alert alert-danger well-sm" ng-show="myForm.loopCount.$error.number"> |
| 150 | 必须输入数字 | 153 | 必须输入数字 |
| @@ -158,10 +161,10 @@ | @@ -158,10 +161,10 @@ | ||
| 158 | <label class="col-md-2 control-label">常规有效日:</label> | 161 | <label class="col-md-2 control-label">常规有效日:</label> |
| 159 | <div class="col-md-6"> | 162 | <div class="col-md-6"> |
| 160 | <sa-Checkboxgroup model="ctrl.timeTableManageForForm" | 163 | <sa-Checkboxgroup model="ctrl.timeTableManageForForm" |
| 161 | - name="rule_days" | ||
| 162 | - dcvalue="{{ctrl.timeTableManageForForm.rule_days}}" | ||
| 163 | - dcname="rule_days" | ||
| 164 | - required > | 164 | + name="rule_days" |
| 165 | + dcvalue="{{ctrl.timeTableManageForForm.rule_days}}" | ||
| 166 | + dcname="rule_days" | ||
| 167 | + required > | ||
| 165 | </sa-Checkboxgroup> | 168 | </sa-Checkboxgroup> |
| 166 | </div> | 169 | </div> |
| 167 | <div class="alert alert-danger well-sm" ng-show="myForm.rule_days.$error.required"> | 170 | <div class="alert alert-danger well-sm" ng-show="myForm.rule_days.$error.required"> |
| @@ -173,10 +176,10 @@ | @@ -173,10 +176,10 @@ | ||
| 173 | <label class="col-md-2 control-label">特殊有效日:</label> | 176 | <label class="col-md-2 control-label">特殊有效日:</label> |
| 174 | <div class="col-md-6"> | 177 | <div class="col-md-6"> |
| 175 | <sa-Dategroup model="ctrl.timeTableManageForForm" | 178 | <sa-Dategroup model="ctrl.timeTableManageForForm" |
| 176 | - name="special_days" | ||
| 177 | - dcvalue="{{ctrl.timeTableManageForForm.special_days}}" | ||
| 178 | - dcname="special_days" | ||
| 179 | - > | 179 | + name="special_days" |
| 180 | + dcvalue="{{ctrl.timeTableManageForForm.special_days}}" | ||
| 181 | + dcname="special_days" | ||
| 182 | + > | ||
| 180 | </sa-Dategroup> | 183 | </sa-Dategroup> |
| 181 | </div> | 184 | </div> |
| 182 | <div class="alert alert-danger well-sm" ng-show="myForm.special_days.$error.required"> | 185 | <div class="alert alert-danger well-sm" ng-show="myForm.special_days.$error.required"> |
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/form.html
| @@ -43,17 +43,18 @@ | @@ -43,17 +43,18 @@ | ||
| 43 | <div class="form-group has-success has-feedback"> | 43 | <div class="form-group has-success has-feedback"> |
| 44 | <label class="col-md-2 control-label">线路*:</label> | 44 | <label class="col-md-2 control-label">线路*:</label> |
| 45 | <div class="col-md-3"> | 45 | <div class="col-md-3"> |
| 46 | - <sa-Select3 model="ctrl.timeTableManageForForm" | ||
| 47 | - name="xl" | ||
| 48 | - placeholder="请输拼音..." | ||
| 49 | - dcvalue="{{ctrl.timeTableManageForForm.xl.id}}" | 46 | + <sa-Select5 name="xl" |
| 47 | + model="ctrl.timeTableManageForForm" | ||
| 48 | + cmaps="{'xl.id' : 'id'}" | ||
| 50 | dcname="xl.id" | 49 | dcname="xl.id" |
| 51 | icname="id" | 50 | icname="id" |
| 52 | - icnames="name" | ||
| 53 | - datatype="xl" | ||
| 54 | - mlp="true" | 51 | + dsparams="{{ {type: 'ajax', param:{type: 'all'}, atype:'xl' } | json }}" |
| 52 | + iterobjname="item" | ||
| 53 | + iterobjexp="item.name" | ||
| 54 | + searchph="请输拼音..." | ||
| 55 | + searchexp="this.name" | ||
| 55 | required > | 56 | required > |
| 56 | - </sa-Select3> | 57 | + </sa-Select5> |
| 57 | </div> | 58 | </div> |
| 58 | <!-- 隐藏块,显示验证信息 --> | 59 | <!-- 隐藏块,显示验证信息 --> |
| 59 | <div class="alert alert-danger well-sm" ng-show="myForm.xl.$error.required"> | 60 | <div class="alert alert-danger well-sm" ng-show="myForm.xl.$error.required"> |
| @@ -76,8 +77,10 @@ | @@ -76,8 +77,10 @@ | ||
| 76 | <label class="col-md-2 control-label">时刻表名字*:</label> | 77 | <label class="col-md-2 control-label">时刻表名字*:</label> |
| 77 | <div class="col-md-3"> | 78 | <div class="col-md-3"> |
| 78 | <input type="text" class="form-control" ng-model="ctrl.timeTableManageForForm.name" | 79 | <input type="text" class="form-control" ng-model="ctrl.timeTableManageForForm.name" |
| 79 | - name="name" placeholder="请输入时刻表名字" required | ||
| 80 | - remote-Validaton rvtype="ttinfoname" rv1="{{ctrl.timeTableManageForForm.xl.id}}" | 80 | + name="name" placeholder="请输入时刻表名字..." required |
| 81 | + remote-Validation | ||
| 82 | + remotevtype="ttc1" | ||
| 83 | + remotevparam="{{ {'xl.id_eq': ctrl.timeTableManageForForm.xl.id, 'name_eq': ctrl.timeTableManageForForm.name} | json}}" | ||
| 81 | /> | 84 | /> |
| 82 | </div> | 85 | </div> |
| 83 | 86 | ||
| @@ -86,7 +89,7 @@ | @@ -86,7 +89,7 @@ | ||
| 86 | 时刻表名字必须填写 | 89 | 时刻表名字必须填写 |
| 87 | </div> | 90 | </div> |
| 88 | <div class="alert alert-danger well-sm" ng-show="myForm.name.$error.remote"> | 91 | <div class="alert alert-danger well-sm" ng-show="myForm.name.$error.remote"> |
| 89 | - 选择线路并且相同相同线路时刻表名字不能重复 | 92 | + 相同线路下的时刻表不能同名 |
| 90 | </div> | 93 | </div> |
| 91 | </div> | 94 | </div> |
| 92 | 95 | ||
| @@ -130,7 +133,7 @@ | @@ -130,7 +133,7 @@ | ||
| 130 | <label class="col-md-2 control-label">路牌数量:</label> | 133 | <label class="col-md-2 control-label">路牌数量:</label> |
| 131 | <div class="col-md-3"> | 134 | <div class="col-md-3"> |
| 132 | <input type="number" class="form-control" ng-model="ctrl.timeTableManageForForm.lpCount" | 135 | <input type="number" class="form-control" ng-model="ctrl.timeTableManageForForm.lpCount" |
| 133 | - name="lpCount" placeholder="请输入路牌数" min="1"/> | 136 | + name="lpCount" placeholder="请输入路牌数..." min="1"/> |
| 134 | </div> | 137 | </div> |
| 135 | <div class="alert alert-danger well-sm" ng-show="myForm.lpCount.$error.number"> | 138 | <div class="alert alert-danger well-sm" ng-show="myForm.lpCount.$error.number"> |
| 136 | 必须输入数字 | 139 | 必须输入数字 |
| @@ -144,7 +147,7 @@ | @@ -144,7 +147,7 @@ | ||
| 144 | <label class="col-md-2 control-label">营运圈数:</label> | 147 | <label class="col-md-2 control-label">营运圈数:</label> |
| 145 | <div class="col-md-3"> | 148 | <div class="col-md-3"> |
| 146 | <input type="number" class="form-control" ng-model="ctrl.timeTableManageForForm.loopCount" | 149 | <input type="number" class="form-control" ng-model="ctrl.timeTableManageForForm.loopCount" |
| 147 | - name="loopCount" placeholder="请输入圈数" min="1"/> | 150 | + name="loopCount" placeholder="请输入圈数..." min="1"/> |
| 148 | </div> | 151 | </div> |
| 149 | <div class="alert alert-danger well-sm" ng-show="myForm.loopCount.$error.number"> | 152 | <div class="alert alert-danger well-sm" ng-show="myForm.loopCount.$error.number"> |
| 150 | 必须输入数字 | 153 | 必须输入数字 |
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/index.html
| @@ -39,18 +39,6 @@ | @@ -39,18 +39,6 @@ | ||
| 39 | <i class="fa fa-angle-down"></i> | 39 | <i class="fa fa-angle-down"></i> |
| 40 | </a> | 40 | </a> |
| 41 | <ul class="dropdown-menu pull-right"> | 41 | <ul class="dropdown-menu pull-right"> |
| 42 | - <li> | ||
| 43 | - <a href="javascript:" class="tool-action" ng-click="ctrl.importData()"> | ||
| 44 | - <i class="fa fa-file-excel-o"></i> | ||
| 45 | - 导入excel | ||
| 46 | - </a> | ||
| 47 | - </li> | ||
| 48 | - <li> | ||
| 49 | - <a href="javascript:" class="tool-action"> | ||
| 50 | - <i class="fa fa-file-excel-o"></i> | ||
| 51 | - 导出excel | ||
| 52 | - </a> | ||
| 53 | - </li> | ||
| 54 | <li class="divider"></li> | 42 | <li class="divider"></li> |
| 55 | <li> | 43 | <li> |
| 56 | <a href="javascript:" class="tool-action"> | 44 | <a href="javascript:" class="tool-action"> |
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/list.html
| @@ -4,24 +4,32 @@ | @@ -4,24 +4,32 @@ | ||
| 4 | <table class="fixTable table table-striped table-bordered table-hover table-checkable order-column"> | 4 | <table class="fixTable table table-striped table-bordered table-hover table-checkable order-column"> |
| 5 | <thead> | 5 | <thead> |
| 6 | <tr role="row" class="heading"> | 6 | <tr role="row" class="heading"> |
| 7 | - <th style="width: 5%;">序号</th> | ||
| 8 | - <th style="width: 8%;">线路</th> | ||
| 9 | - <th >名称</th> | ||
| 10 | - <th>路牌数</th> | ||
| 11 | - <th>圈数</th> | ||
| 12 | - <th>上下行</th> | ||
| 13 | - <th>启用</th> | ||
| 14 | - <th style="width: 10%">启用日期</th> | ||
| 15 | - <th style="width: 25%">时刻表明细</th> | ||
| 16 | - <th style="width: 21%">操作</th> | 7 | + <th style="width: 50px;">序号</th> |
| 8 | + <th style="width: 150px;">线路</th> | ||
| 9 | + <th style="width: 180px;">时刻表名称</th> | ||
| 10 | + <th style="width: 100px">路牌数/圈数</th> | ||
| 11 | + <th style="width: 80px">上下行</th> | ||
| 12 | + <th style="width: 50px;">启用</th> | ||
| 13 | + <th style="width: 120px">启用日期</th> | ||
| 14 | + <th style="width: 50%">时刻表明细</th> | ||
| 15 | + <th style="width: 50%">操作</th> | ||
| 17 | </tr> | 16 | </tr> |
| 18 | <tr role="row" class="filter"> | 17 | <tr role="row" class="filter"> |
| 19 | <td></td> | 18 | <td></td> |
| 20 | - <td></td> | ||
| 21 | <td> | 19 | <td> |
| 22 | - <input type="text" class="form-control form-filter input-sm" ng-model="ctrl.searchCondition().name_like"/> | 20 | + <sa-Select3 model="ctrl.searchCondition()" |
| 21 | + name="xl" | ||
| 22 | + placeholder="请输拼音..." | ||
| 23 | + dcvalue="{{ctrl.searchCondition()['xl.id_eq']}}" | ||
| 24 | + dcname="xl.id_eq" | ||
| 25 | + icname="id" | ||
| 26 | + icnames="name" | ||
| 27 | + datatype="xl"> | ||
| 28 | + </sa-Select3> | ||
| 29 | + </td> | ||
| 30 | + <td> | ||
| 31 | + <input type="text" class="form-control form-filter input-sm" ng-model="ctrl.searchCondition().name_like" placeholder="输入时刻表名称..."/> | ||
| 23 | </td> | 32 | </td> |
| 24 | - <td></td> | ||
| 25 | <td></td> | 33 | <td></td> |
| 26 | <td></td> | 34 | <td></td> |
| 27 | <td></td> | 35 | <td></td> |
| @@ -40,7 +48,7 @@ | @@ -40,7 +48,7 @@ | ||
| 40 | 48 | ||
| 41 | </thead> | 49 | </thead> |
| 42 | <tbody> | 50 | <tbody> |
| 43 | - <tr ng-repeat="info in ctrl.pageInfo.infos" class="odd gradeX"> | 51 | + <tr ng-repeat="info in ctrl.pageInfo.infos" ng-class="{odd: true, gradeX: true, danger: info.isCancel}"> |
| 44 | <td> | 52 | <td> |
| 45 | <span ng-bind="$index + 1"></span> | 53 | <span ng-bind="$index + 1"></span> |
| 46 | </td> | 54 | </td> |
| @@ -48,12 +56,11 @@ | @@ -48,12 +56,11 @@ | ||
| 48 | <span ng-bind="info.xl.name"></span> | 56 | <span ng-bind="info.xl.name"></span> |
| 49 | </td> | 57 | </td> |
| 50 | <td> | 58 | <td> |
| 51 | - <span ng-bind="info.name"></span> | 59 | + <span ng-bind="info.name" title="{{info.name}}"></span> |
| 52 | </td> | 60 | </td> |
| 53 | <td> | 61 | <td> |
| 54 | <span ng-bind="info.lpCount"></span> | 62 | <span ng-bind="info.lpCount"></span> |
| 55 | - </td> | ||
| 56 | - <td> | 63 | + / |
| 57 | <span ng-bind="info.loopCount"></span> | 64 | <span ng-bind="info.loopCount"></span> |
| 58 | </td> | 65 | </td> |
| 59 | <td> | 66 | <td> |
| @@ -67,17 +74,17 @@ | @@ -67,17 +74,17 @@ | ||
| 67 | </td> | 74 | </td> |
| 68 | <td> | 75 | <td> |
| 69 | <a ui-sref="timeTableDetailInfoManage({xlid: info.xl.id, ttid : info.id, xlname: info.xl.name, ttname : info.name})" | 76 | <a ui-sref="timeTableDetailInfoManage({xlid: info.xl.id, ttid : info.id, xlname: info.xl.name, ttname : info.name})" |
| 70 | - class="btn default blue-stripe btn-sm"> 编辑 </a> | ||
| 71 | - <a ng-click="ctrl.importData($index)" class="btn default blue-stripe btn-sm"> 导入 </a> | 77 | + class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 编辑 </a> |
| 78 | + <a ng-click="ctrl.importData($index)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 导入 </a> | ||
| 72 | <a href="javascript:" class="btn default blue-stripe btn-sm"> 导出 </a> | 79 | <a href="javascript:" class="btn default blue-stripe btn-sm"> 导出 </a> |
| 73 | - <a href="javascript:" class="btn default blue-stripe btn-sm"> 清空 </a> | ||
| 74 | </td> | 80 | </td> |
| 75 | <td> | 81 | <td> |
| 76 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> | 82 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 77 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> | 83 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 78 | <a ui-sref="timeTableManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | 84 | <a ui-sref="timeTableManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> |
| 79 | - <a ui-sref="timeTableManage_edit({id: info.id})" class="btn default blue-stripe btn-sm"> 修改 </a> | ||
| 80 | - <a ng-click="ctrl.deleteTTinfo(info.id)" class="btn default blue-stripe btn-sm"> 作废 </a> | 85 | + <a ui-sref="timeTableManage_edit({id: info.id})" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> |
| 86 | + <a ng-click="ctrl.toggleTtinfo(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | ||
| 87 | + <a ng-click="ctrl.toggleTtinfo(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | ||
| 81 | </td> | 88 | </td> |
| 82 | </tr> | 89 | </tr> |
| 83 | </tbody> | 90 | </tbody> |
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/timeTableManage.js
| @@ -187,30 +187,37 @@ angular.module('ScheduleApp').controller('TimeTableManageListCtrl', ['TimeTableM | @@ -187,30 +187,37 @@ angular.module('ScheduleApp').controller('TimeTableManageListCtrl', ['TimeTableM | ||
| 187 | }; | 187 | }; |
| 188 | // 重置查询条件 | 188 | // 重置查询条件 |
| 189 | self.resetSearchCondition = function() { | 189 | self.resetSearchCondition = function() { |
| 190 | - return timeTableManageService.resetSearchCondition(); | 190 | + timeTableManageService.resetSearchCondition(); |
| 191 | + self.pageInfo.currentPage = 1; | ||
| 192 | + self.pageChanaged(); | ||
| 191 | }; | 193 | }; |
| 192 | 194 | ||
| 193 | - // 删除时刻表 | ||
| 194 | - self.deleteTTinfo = function(id) { | 195 | + // 作废/撤销 |
| 196 | + self.toggleTtinfo = function(id) { | ||
| 195 | // TODO: | 197 | // TODO: |
| 196 | timeTableManageService.deleteDetail(id).then( | 198 | timeTableManageService.deleteDetail(id).then( |
| 197 | function(result) { | 199 | function(result) { |
| 198 | - alert("作废成功!"); | ||
| 199 | - | ||
| 200 | - timeTableManageService.getPage().then( | ||
| 201 | - function(result) { | ||
| 202 | - self.pageInfo.totalItems = result.totalElements; | ||
| 203 | - self.pageInfo.currentPage = result.number + 1; | ||
| 204 | - self.pageInfo.infos = result.content; | ||
| 205 | - timeTableManageService.setCurrentPageNo(result.number + 1); | ||
| 206 | - }, | ||
| 207 | - function(result) { | ||
| 208 | - alert("出错啦!"); | ||
| 209 | - } | ||
| 210 | - ); | 200 | + if (result.message) { // 暂时这样做,之后全局拦截 |
| 201 | + alert("失败:" + result.message); | ||
| 202 | + } else { | ||
| 203 | + alert("成功!"); | ||
| 204 | + | ||
| 205 | + timeTableManageService.getPage().then( | ||
| 206 | + function(result) { | ||
| 207 | + self.pageInfo.totalItems = result.totalElements; | ||
| 208 | + self.pageInfo.currentPage = result.number + 1; | ||
| 209 | + self.pageInfo.infos = result.content; | ||
| 210 | + timeTableManageService.setCurrentPageNo(result.number + 1); | ||
| 211 | + }, | ||
| 212 | + function(result) { | ||
| 213 | + alert("出错啦!"); | ||
| 214 | + } | ||
| 215 | + ); | ||
| 216 | + } | ||
| 217 | + | ||
| 211 | }, | 218 | }, |
| 212 | function(result) { | 219 | function(result) { |
| 213 | - alert("出错啦!"); | 220 | + alert("出错啦!" + result); |
| 214 | } | 221 | } |
| 215 | ); | 222 | ); |
| 216 | }; | 223 | }; |
| @@ -289,51 +296,49 @@ angular.module('ScheduleApp').controller('TimeTableDetailManageToolsCtrl', ['$mo | @@ -289,51 +296,49 @@ angular.module('ScheduleApp').controller('TimeTableDetailManageToolsCtrl', ['$mo | ||
| 289 | 296 | ||
| 290 | }]); | 297 | }]); |
| 291 | 298 | ||
| 292 | -angular.module('ScheduleApp').controller('TimeTableManageFormCtrl', ['TimeTableManageService', '$stateParams', '$state', function(timeTableManageService, $stateParams, $state) { | 299 | +angular.module('ScheduleApp').controller('TimeTableManageFormCtrl', [ |
| 300 | + 'TimeTableManageService', | ||
| 301 | + '$stateParams', | ||
| 302 | + '$state', function(timeTableManageService, $stateParams, $state) { | ||
| 293 | var self = this; | 303 | var self = this; |
| 294 | 304 | ||
| 295 | - // 启用日期 日期控件开关 | ||
| 296 | - self.qyrqOpen = false; | ||
| 297 | - self.qyrq_open = function() { | ||
| 298 | - self.qyrqOpen = true; | ||
| 299 | - }; | ||
| 300 | - | ||
| 301 | - // 欲保存的表单信息,双向绑定 | ||
| 302 | - self.timeTableManageForForm= {xl : {}}; | ||
| 303 | - | ||
| 304 | - // 如果是修改,获取传过来的id,从后台获取一份数据,用于绑定页面form值 | ||
| 305 | - var id = $stateParams.id; | ||
| 306 | - if (id) { | ||
| 307 | - self.timeTableManageForForm.id = id; | ||
| 308 | - timeTableManageService.getDetail(id).then( | ||
| 309 | - function(result) { | ||
| 310 | - var key; | ||
| 311 | - for (key in result) { | ||
| 312 | - self.timeTableManageForForm[key] = result[key]; | 305 | + // 启用日期 日期控件开关 |
| 306 | + self.qyrqOpen = false; | ||
| 307 | + self.qyrq_open = function() { | ||
| 308 | + self.qyrqOpen = true; | ||
| 309 | + }; | ||
| 310 | + | ||
| 311 | + // 欲保存的表单信息,双向绑定 | ||
| 312 | + self.timeTableManageForForm= {xl : {}}; | ||
| 313 | + | ||
| 314 | + // 如果是修改,获取传过来的id,从后台获取一份数据,用于绑定页面form值 | ||
| 315 | + var id = $stateParams.id; | ||
| 316 | + if (id) { | ||
| 317 | + self.timeTableManageForForm.id = id; | ||
| 318 | + timeTableManageService.getDetail(id).then( | ||
| 319 | + function(result) { | ||
| 320 | + var key; | ||
| 321 | + for (key in result) { | ||
| 322 | + self.timeTableManageForForm[key] = result[key]; | ||
| 323 | + } | ||
| 324 | + }, | ||
| 325 | + function(result) { | ||
| 326 | + alert("出错啦!"); | ||
| 313 | } | 327 | } |
| 314 | - }, | ||
| 315 | - function(result) { | ||
| 316 | - alert("出错啦!"); | ||
| 317 | - } | ||
| 318 | - ); | ||
| 319 | - } | 328 | + ); |
| 329 | + } | ||
| 320 | 330 | ||
| 321 | - // form提交方法 | ||
| 322 | - self.submit = function() { | ||
| 323 | - timeTableManageService.saveDetail(self.timeTableManageForForm).then( | ||
| 324 | - function(result) { | ||
| 325 | - if (result.status == 'SUCCESS') { | ||
| 326 | - alert("保存成功!"); | 331 | + // form提交方法 |
| 332 | + self.submit = function() { | ||
| 333 | + timeTableManageService.saveDetail(self.timeTableManageForForm).then( | ||
| 334 | + function(result) { | ||
| 327 | $state.go("timeTableManage"); | 335 | $state.go("timeTableManage"); |
| 328 | - } else { | ||
| 329 | - alert("保存异常!"); | 336 | + }, |
| 337 | + function(result) { | ||
| 338 | + alert("出错啦!"); | ||
| 330 | } | 339 | } |
| 331 | - }, | ||
| 332 | - function(result) { | ||
| 333 | - alert("出错啦!"); | ||
| 334 | - } | ||
| 335 | - ); | ||
| 336 | - }; | 340 | + ); |
| 341 | + }; | ||
| 337 | 342 | ||
| 338 | 343 | ||
| 339 | }]); | 344 | }]); |
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/timeTableManage2.js
0 → 100644
| 1 | +// 时刻表管理 service controller 等写在一起 | ||
| 2 | +angular.module('ScheduleApp').factory('TimeTableManageService', ['TimeTableManageService_g', function(service) { | ||
| 3 | + /** 当前的查询条件信息 */ | ||
| 4 | + var currentSearchCondition = {}; | ||
| 5 | + | ||
| 6 | + /** 当前第几页 */ | ||
| 7 | + var currentPageNo = 1; | ||
| 8 | + | ||
| 9 | + return { | ||
| 10 | + /** | ||
| 11 | + * 获取查询条件信息, | ||
| 12 | + * 用于给controller用来和页面数据绑定。 | ||
| 13 | + */ | ||
| 14 | + getSearchCondition: function() { | ||
| 15 | + return currentSearchCondition; | ||
| 16 | + }, | ||
| 17 | + /** | ||
| 18 | + * 重置查询条件信息。 | ||
| 19 | + */ | ||
| 20 | + resetSearchCondition: function() { | ||
| 21 | + var key; | ||
| 22 | + for (key in currentSearchCondition) { | ||
| 23 | + currentSearchCondition[key] = undefined; | ||
| 24 | + } | ||
| 25 | + }, | ||
| 26 | + /** | ||
| 27 | + * 设置当前页码。 | ||
| 28 | + * @param cpn 从1开始,后台是从0开始的 | ||
| 29 | + */ | ||
| 30 | + setCurrentPageNo: function(cpn) { | ||
| 31 | + currentPageNo = cpn; | ||
| 32 | + }, | ||
| 33 | + /** | ||
| 34 | + * 组装查询参数,返回一个promise查询结果。 | ||
| 35 | + * @param params 查询参数 | ||
| 36 | + * @return 返回一个 promise | ||
| 37 | + */ | ||
| 38 | + getPage: function() { | ||
| 39 | + var params = currentSearchCondition; // 查询条件 | ||
| 40 | + params.page = currentPageNo - 1; // 服务端页码从0开始 | ||
| 41 | + return service.rest.list(params).$promise; | ||
| 42 | + }, | ||
| 43 | + /** | ||
| 44 | + * 获取明细信息。 | ||
| 45 | + * @param id 车辆id | ||
| 46 | + * @return 返回一个 promise | ||
| 47 | + */ | ||
| 48 | + getDetail: function(id) { | ||
| 49 | + var params = {id: id}; | ||
| 50 | + return service.rest.get(params).$promise; | ||
| 51 | + }, | ||
| 52 | + /** | ||
| 53 | + * 保存信息。 | ||
| 54 | + * @param obj 车辆详细信息 | ||
| 55 | + * @return 返回一个 promise | ||
| 56 | + */ | ||
| 57 | + saveDetail: function(obj) { | ||
| 58 | + return service.rest.save(obj).$promise; | ||
| 59 | + }, | ||
| 60 | + /** | ||
| 61 | + * 删除信息。 | ||
| 62 | + * @param id 主键id | ||
| 63 | + * @returns {*|Function|promise|n} | ||
| 64 | + */ | ||
| 65 | + deleteDetail: function(id) { | ||
| 66 | + return service.rest.delete({id: id}).$promise; | ||
| 67 | + } | ||
| 68 | + }; | ||
| 69 | + | ||
| 70 | +}]); | ||
| 71 | + | ||
| 72 | +angular.module('ScheduleApp').controller('TimeTableManageCtrl', ['TimeTableManageService', '$state', '$uibModal', function(timeTableManageService, $state, $uibModal) { | ||
| 73 | + var self = this; | ||
| 74 | + | ||
| 75 | + // 切换到form状态 | ||
| 76 | + self.goForm = function() { | ||
| 77 | + //alert("切换"); | ||
| 78 | + $state.go("timeTableManage_form"); | ||
| 79 | + }; | ||
| 80 | + | ||
| 81 | + // 导入excel | ||
| 82 | + self.importData = function() { | ||
| 83 | + // large方式弹出模态对话框 | ||
| 84 | + var modalInstance = $uibModal.open({ | ||
| 85 | + templateUrl: '/pages/scheduleApp/module/core/timeTableManage/dataImport.html', | ||
| 86 | + size: "lg", | ||
| 87 | + animation: true, | ||
| 88 | + backdrop: 'static', | ||
| 89 | + resolve: { | ||
| 90 | + // 可以传值给controller | ||
| 91 | + }, | ||
| 92 | + windowClass: 'center-modal', | ||
| 93 | + controller: "TimeTableManageToolsCtrl", | ||
| 94 | + controllerAs: "ctrl", | ||
| 95 | + bindToController: true | ||
| 96 | + }); | ||
| 97 | + modalInstance.result.then( | ||
| 98 | + function() { | ||
| 99 | + console.log("dataImport.html打开"); | ||
| 100 | + }, | ||
| 101 | + function() { | ||
| 102 | + console.log("dataImport.html消失"); | ||
| 103 | + } | ||
| 104 | + ); | ||
| 105 | + }; | ||
| 106 | +}]); | ||
| 107 | + | ||
| 108 | +angular.module('ScheduleApp').controller('TimeTableManageToolsCtrl', ['$modalInstance', 'FileUploader', function($modalInstance, FileUploader) { | ||
| 109 | + var self = this; | ||
| 110 | + self.data = "TODO"; | ||
| 111 | + | ||
| 112 | + // 关闭窗口 | ||
| 113 | + self.close = function() { | ||
| 114 | + $modalInstance.dismiss("cancel"); | ||
| 115 | + }; | ||
| 116 | + | ||
| 117 | + self.clearInputFile = function() { | ||
| 118 | + angular.element("input[type='file']").val(null); | ||
| 119 | + }; | ||
| 120 | + | ||
| 121 | + // 上传文件组件 | ||
| 122 | + self.uploader = new FileUploader({ | ||
| 123 | + url: "/tic/dataImport", | ||
| 124 | + filters: [] // 用于过滤文件,比如只允许导入excel | ||
| 125 | + }); | ||
| 126 | + self.uploader.onAfterAddingFile = function(fileItem) | ||
| 127 | + { | ||
| 128 | + console.info('onAfterAddingFile', fileItem); | ||
| 129 | + console.log(self.uploader.queue.length); | ||
| 130 | + if (self.uploader.queue.length > 1) | ||
| 131 | + self.uploader.removeFromQueue(0); | ||
| 132 | + }; | ||
| 133 | + self.uploader.onSuccessItem = function(fileItem, response, status, headers) | ||
| 134 | + { | ||
| 135 | + console.info('onSuccessItem', fileItem, response, status, headers); | ||
| 136 | + }; | ||
| 137 | + self.uploader.onErrorItem = function(fileItem, response, status, headers) | ||
| 138 | + { | ||
| 139 | + console.info('onErrorItem', fileItem, response, status, headers); | ||
| 140 | + }; | ||
| 141 | + | ||
| 142 | +}]); | ||
| 143 | + | ||
| 144 | +angular.module('ScheduleApp').controller('TimeTableManageListCtrl', ['TimeTableManageService', '$uibModal', function(timeTableManageService, $uibModal) { | ||
| 145 | + var self = this; | ||
| 146 | + self.pageInfo = { | ||
| 147 | + totalItems : 0, | ||
| 148 | + currentPage : 1, | ||
| 149 | + infos: [] | ||
| 150 | + }; | ||
| 151 | + | ||
| 152 | + // 初始创建的时候,获取一次列表数据 | ||
| 153 | + timeTableManageService.getPage().then( | ||
| 154 | + function(result) { | ||
| 155 | + self.pageInfo.totalItems = result.totalElements; | ||
| 156 | + self.pageInfo.currentPage = result.number + 1; | ||
| 157 | + self.pageInfo.infos = result.content; | ||
| 158 | + timeTableManageService.setCurrentPageNo(result.number + 1); | ||
| 159 | + }, | ||
| 160 | + function(result) { | ||
| 161 | + alert("出错啦!"); | ||
| 162 | + } | ||
| 163 | + ); | ||
| 164 | + | ||
| 165 | + //$scope.$watch("ctrl.pageInfo.currentPage", function() { | ||
| 166 | + // alert("dfdfdf"); | ||
| 167 | + //}); | ||
| 168 | + | ||
| 169 | + // 翻页的时候调用 | ||
| 170 | + self.pageChanaged = function() { | ||
| 171 | + timeTableManageService.setCurrentPageNo(self.pageInfo.currentPage); | ||
| 172 | + timeTableManageService.getPage().then( | ||
| 173 | + function(result) { | ||
| 174 | + self.pageInfo.totalItems = result.totalElements; | ||
| 175 | + self.pageInfo.currentPage = result.number + 1; | ||
| 176 | + self.pageInfo.infos = result.content; | ||
| 177 | + timeTableManageService.setCurrentPageNo(result.number + 1); | ||
| 178 | + }, | ||
| 179 | + function(result) { | ||
| 180 | + alert("出错啦!"); | ||
| 181 | + } | ||
| 182 | + ); | ||
| 183 | + }; | ||
| 184 | + // 获取查询条件数据 | ||
| 185 | + self.searchCondition = function() { | ||
| 186 | + return timeTableManageService.getSearchCondition(); | ||
| 187 | + }; | ||
| 188 | + // 重置查询条件 | ||
| 189 | + self.resetSearchCondition = function() { | ||
| 190 | + timeTableManageService.resetSearchCondition(); | ||
| 191 | + self.pageInfo.currentPage = 1; | ||
| 192 | + self.pageChanaged(); | ||
| 193 | + }; | ||
| 194 | + | ||
| 195 | + // 作废/撤销 | ||
| 196 | + self.toggleTtinfo = function(id) { | ||
| 197 | + // TODO: | ||
| 198 | + timeTableManageService.deleteDetail(id).then( | ||
| 199 | + function(result) { | ||
| 200 | + if (result.message) { // 暂时这样做,之后全局拦截 | ||
| 201 | + alert("失败:" + result.message); | ||
| 202 | + } else { | ||
| 203 | + alert("成功!"); | ||
| 204 | + | ||
| 205 | + timeTableManageService.getPage().then( | ||
| 206 | + function(result) { | ||
| 207 | + self.pageInfo.totalItems = result.totalElements; | ||
| 208 | + self.pageInfo.currentPage = result.number + 1; | ||
| 209 | + self.pageInfo.infos = result.content; | ||
| 210 | + timeTableManageService.setCurrentPageNo(result.number + 1); | ||
| 211 | + }, | ||
| 212 | + function(result) { | ||
| 213 | + alert("出错啦!"); | ||
| 214 | + } | ||
| 215 | + ); | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + }, | ||
| 219 | + function(result) { | ||
| 220 | + alert("出错啦!" + result); | ||
| 221 | + } | ||
| 222 | + ); | ||
| 223 | + }; | ||
| 224 | + | ||
| 225 | + // 导入excel | ||
| 226 | + self.importData = function($index) { | ||
| 227 | + // 线路名称 | ||
| 228 | + var xlmc = self.pageInfo.infos[$index]["xl"]["name"]; | ||
| 229 | + // 时刻表名称 | ||
| 230 | + var ttinfoname = self.pageInfo.infos[$index]["name"]; | ||
| 231 | + | ||
| 232 | + // large方式弹出模态对话框 | ||
| 233 | + var modalInstance = $uibModal.open({ | ||
| 234 | + templateUrl: '/pages/scheduleApp/module/core/timeTableManage/detailDataImport.html', | ||
| 235 | + size: "lg", | ||
| 236 | + animation: true, | ||
| 237 | + backdrop: 'static', | ||
| 238 | + resolve: { | ||
| 239 | + // 可以传值给controller | ||
| 240 | + r_xlmc : function() {return xlmc}, | ||
| 241 | + r_ttinfoname : function() {return ttinfoname;} | ||
| 242 | + }, | ||
| 243 | + windowClass: 'center-modal', | ||
| 244 | + controller: "TimeTableDetailManageToolsCtrl", | ||
| 245 | + controllerAs: "ctrl", | ||
| 246 | + bindToController: true | ||
| 247 | + }); | ||
| 248 | + modalInstance.result.then( | ||
| 249 | + function() { | ||
| 250 | + console.log("dataImport.html打开"); | ||
| 251 | + }, | ||
| 252 | + function() { | ||
| 253 | + console.log("dataImport.html消失"); | ||
| 254 | + } | ||
| 255 | + ); | ||
| 256 | + }; | ||
| 257 | + | ||
| 258 | +}]); | ||
| 259 | + | ||
| 260 | +angular.module('ScheduleApp').controller('TimeTableDetailManageToolsCtrl', ['$modalInstance', 'FileUploader', 'r_xlmc', 'r_ttinfoname', function($modalInstance, FileUploader, r_xlmc, r_ttinfoname) { | ||
| 261 | + var self = this; | ||
| 262 | + | ||
| 263 | + self.xlmc = r_xlmc; | ||
| 264 | + self.ttinfoname = r_ttinfoname; | ||
| 265 | + | ||
| 266 | + // 关闭窗口 | ||
| 267 | + self.close = function() { | ||
| 268 | + $modalInstance.dismiss("cancel"); | ||
| 269 | + }; | ||
| 270 | + | ||
| 271 | + self.clearInputFile = function() { | ||
| 272 | + angular.element("input[type='file']").val(null); | ||
| 273 | + }; | ||
| 274 | + | ||
| 275 | + // 上传文件组件 | ||
| 276 | + self.uploader = new FileUploader({ | ||
| 277 | + url: "/tidc/dataImportExtend", | ||
| 278 | + filters: [], // 用于过滤文件,比如只允许导入excel, | ||
| 279 | + formData: [{xlmc: self.xlmc, ttinfoname: self.ttinfoname}] | ||
| 280 | + }); | ||
| 281 | + self.uploader.onAfterAddingFile = function(fileItem) | ||
| 282 | + { | ||
| 283 | + console.info('onAfterAddingFile', fileItem); | ||
| 284 | + console.log(self.uploader.queue.length); | ||
| 285 | + if (self.uploader.queue.length > 1) | ||
| 286 | + self.uploader.removeFromQueue(0); | ||
| 287 | + }; | ||
| 288 | + self.uploader.onSuccessItem = function(fileItem, response, status, headers) | ||
| 289 | + { | ||
| 290 | + console.info('onSuccessItem', fileItem, response, status, headers); | ||
| 291 | + }; | ||
| 292 | + self.uploader.onErrorItem = function(fileItem, response, status, headers) | ||
| 293 | + { | ||
| 294 | + console.info('onErrorItem', fileItem, response, status, headers); | ||
| 295 | + }; | ||
| 296 | + | ||
| 297 | +}]); | ||
| 298 | + | ||
| 299 | +angular.module('ScheduleApp').controller('TimeTableManageFormCtrl', [ | ||
| 300 | + 'TimeTableManageService', | ||
| 301 | + 'TimeTableManageService_g', | ||
| 302 | + '$stateParams', | ||
| 303 | + '$state', function(timeTableManageService, timeTableManageService_g, $stateParams, $state) { | ||
| 304 | + var self = this; | ||
| 305 | + | ||
| 306 | + // 启用日期 日期控件开关 | ||
| 307 | + self.qyrqOpen = false; | ||
| 308 | + self.qyrq_open = function() { | ||
| 309 | + self.qyrqOpen = true; | ||
| 310 | + }; | ||
| 311 | + | ||
| 312 | + // 测试 | ||
| 313 | + self.timeTableManageForForm = new timeTableManageService_g.rest(); | ||
| 314 | + self.timeTableManageForForm.xl = {}; | ||
| 315 | + self.submit = function() { | ||
| 316 | + self.timeTableManageForForm.$save(function() { | ||
| 317 | + $state.go("timeTableManage"); | ||
| 318 | + }); | ||
| 319 | + }; | ||
| 320 | + | ||
| 321 | + | ||
| 322 | + | ||
| 323 | + //// 欲保存的表单信息,双向绑定 | ||
| 324 | + //self.timeTableManageForForm= {xl : {}}; | ||
| 325 | + // | ||
| 326 | + //// 如果是修改,获取传过来的id,从后台获取一份数据,用于绑定页面form值 | ||
| 327 | + //var id = $stateParams.id; | ||
| 328 | + //if (id) { | ||
| 329 | + // self.timeTableManageForForm.id = id; | ||
| 330 | + // timeTableManageService.getDetail(id).then( | ||
| 331 | + // function(result) { | ||
| 332 | + // var key; | ||
| 333 | + // for (key in result) { | ||
| 334 | + // self.timeTableManageForForm[key] = result[key]; | ||
| 335 | + // } | ||
| 336 | + // }, | ||
| 337 | + // function(result) { | ||
| 338 | + // alert("出错啦!"); | ||
| 339 | + // } | ||
| 340 | + // ); | ||
| 341 | + //} | ||
| 342 | + // | ||
| 343 | + //// form提交方法 | ||
| 344 | + //self.submit = function() { | ||
| 345 | + // timeTableManageService.saveDetail(self.timeTableManageForForm).then( | ||
| 346 | + // function(result) { | ||
| 347 | + // if (result.status == 'SUCCESS') { | ||
| 348 | + // alert("保存成功!"); | ||
| 349 | + // $state.go("timeTableManage"); | ||
| 350 | + // } else { | ||
| 351 | + // alert("保存异常!"); | ||
| 352 | + // } | ||
| 353 | + // }, | ||
| 354 | + // function(result) { | ||
| 355 | + // alert("出错啦!"); | ||
| 356 | + // } | ||
| 357 | + // ); | ||
| 358 | + //}; | ||
| 359 | + | ||
| 360 | + | ||
| 361 | + }]); | ||
| 362 | + | ||
| 363 | +angular.module('ScheduleApp').controller('TimeTableManageDetailCtrl', ['TimeTableManageService', '$stateParams', function(timeTableManageService, $stateParams) { | ||
| 364 | + var self = this; | ||
| 365 | + self.title = ""; | ||
| 366 | + self.timeTableManageForDetail = {}; | ||
| 367 | + | ||
| 368 | + timeTableManageService.getDetail($stateParams.id).then( | ||
| 369 | + function(result) { | ||
| 370 | + angular.copy(result, self.timeTableManageForDetail); | ||
| 371 | + | ||
| 372 | + self.title = self.timeTableManageForDetail.xl.name + | ||
| 373 | + "(" + | ||
| 374 | + self.timeTableManageForDetail.name + | ||
| 375 | + ")" + | ||
| 376 | + "时刻表基础信息"; | ||
| 377 | + }, | ||
| 378 | + function(result) { | ||
| 379 | + alert("出错啦!"); | ||
| 380 | + } | ||
| 381 | + ); | ||
| 382 | + | ||
| 383 | + | ||
| 384 | +}]); | ||
| 385 | + | ||
| 386 | + | ||
| 387 | + |
src/main/resources/static/pages/scheduleApp/module/main.css
| @@ -39,6 +39,7 @@ form input.ng-valid.ng-dirty.ng-valid-required { | @@ -39,6 +39,7 @@ form input.ng-valid.ng-dirty.ng-valid-required { | ||
| 39 | white-space: nowrap; | 39 | white-space: nowrap; |
| 40 | overflow: hidden; | 40 | overflow: hidden; |
| 41 | text-overflow: ellipsis; | 41 | text-overflow: ellipsis; |
| 42 | + text-ov | ||
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | /** 内容不换行,多余的用...表示 */ | 45 | /** 内容不换行,多余的用...表示 */ |