Commit 1130cdeb9017bbf470ae9d17e843f9773cea2f2e

Authored by 王通
1 parent faca0f50

1.大邑站点、路由维护优化

src/main/java/com/bsth/controller/LsStationRouteController.java
... ... @@ -131,6 +131,36 @@ public class LsStationRouteController extends BaseController<LsStationRoute, Int
131 131 }
132 132  
133 133 /**
  134 + * 保存线路某个版本下的站点路由
  135 + * 常规使用在选择已有站点生成线路路由的情况
  136 + * @param map
  137 + * @return
  138 + */
  139 + @RequestMapping(value="addStationRoutes" , method = RequestMethod.POST)
  140 + public Map<String, Object> addStationRoutes(@RequestBody Map<String, Object> map) {
  141 + Map<String, Object> result = new HashMap<>();
  142 + try {
  143 + if (map.get("lineId") == null || map.get("versions") == null || map.get("directions") == null) {
  144 + throw new IllegalArgumentException("需正确传入线路、方向、版本参数");
  145 + }
  146 + Integer versions = Integer.parseInt(map.get("versions").toString()), directions = Integer.parseInt(map.get("directions").toString()), lineId = Integer.parseInt(map.get("lineId").toString());
  147 + String stationIdsStr = map.get("stationIds").toString();
  148 + List<Integer> stationIds = new ArrayList<>();
  149 + for (String stationId : stationIdsStr.split(",")) {
  150 + stationIds.add(Integer.parseInt(stationId));
  151 + }
  152 +
  153 + result.putAll(lsStationRouteService.addStationRoutes(lineId, versions, directions, stationIds));
  154 + result.put("status", ResponseCode.SUCCESS);
  155 + } catch (Exception e) {
  156 + result.put("status", ResponseCode.ERROR);
  157 + log.error("", e);
  158 + }
  159 +
  160 + return result;
  161 + }
  162 +
  163 + /**
134 164 * 保存线路某个版本下单行的站点和路段路由
135 165 * 常规使用在根据百度地图生成数据或者模板导入的批量保存
136 166 * @param map
... ...
src/main/java/com/bsth/controller/StationController.java
... ... @@ -42,6 +42,8 @@ public class StationController extends BaseController&lt;Station, Integer&gt; {
42 42 @Autowired
43 43 private ObjectMapper mapper;
44 44  
  45 + private boolean executing = false;
  46 +
45 47 /** 日志记录器 */
46 48 private static final Logger log = LoggerFactory.getLogger(StationController.class);
47 49  
... ... @@ -121,4 +123,31 @@ public class StationController extends BaseController&lt;Station, Integer&gt; {
121 123 public List<Station> findStationByName(String stationName) {
122 124 return stationService.findStationByName(stationName);
123 125 }
  126 +
  127 + /**
  128 + * 更新站点、站点路由信息
  129 + * @return
  130 + */
  131 + @RequestMapping(value="generate-pass-line" , method = RequestMethod.POST)
  132 + public Map<String, Object> generatePassLine() {
  133 + Map<String, Object> result = new HashMap<>();
  134 + if (executing) {
  135 + result.put("status", ResponseCode.ERROR);
  136 + result.put("msg", "计算正在执行中,请勿重复操作");
  137 +
  138 + return result;
  139 + }
  140 + executing = true;
  141 + try {
  142 + stationService.generatePassLine();
  143 + result.put("status", ResponseCode.SUCCESS);
  144 + } catch (Exception e) {
  145 + result.put("status", ResponseCode.ERROR);
  146 + throw new RuntimeException(e);
  147 + } finally {
  148 + executing = false;
  149 + }
  150 +
  151 + return result;
  152 + }
124 153 }
... ...
src/main/java/com/bsth/entity/search/PredicatesBuilder.java
... ... @@ -82,6 +82,16 @@ public class PredicatesBuilder {
82 82  
83 83 return in;
84 84 }
  85 +
  86 + public static Predicate ids(CriteriaBuilder cb, Path<?> expression, Object obj) {
  87 + CriteriaBuilder.In<Object> in = cb.in(expression);
  88 + List<Integer> list = (List<Integer>) obj;
  89 + for(int i = 0; i < list.size(); i++){
  90 + in.value(list.get(i));
  91 + }
  92 +
  93 + return in;
  94 + }
85 95  
86 96 public static Predicate gt(CriteriaBuilder cb,Path<Number> expression, Object object){
87 97 try {
... ...
src/main/java/com/bsth/entity/search/SearchOperator.java
1   -package com.bsth.entity.search;
2   -
3   -/**
4   - *
5   - * @ClassName: SearchOperator
6   - * @Description: 查询操作符
7   - * @author PanZhao
8   - * @date 2016年3月16日 下午4:08:22
9   - *
10   - */
11   -public enum SearchOperator {
12   -
13   - eq, // 等于
14   - ne, // 不等于
15   - gt, // 大于
16   - ge, // 大于等于
17   - lt, // 小于
18   - le, // 小于等于
19   - prefixLike, // 前缀模糊匹配
20   - prefixNotLike, // 前缀模糊不匹配
21   - suffixLike, // 后缀模糊匹配
22   - suffixNotLike, // 后缀模糊不匹配
23   - like, // 模糊匹配
24   - notLike, // 不匹配
25   - isNull, // 空
26   - isNotNull, // 非空
27   - isf, //假 isFalse,boolean
28   - ist, //真 isTrue,boolean
29   - date, //时间
30   - dateEq, //时间等于
31   - in, //数组
32   - ins //传参 List<String>
33   -}
  1 +package com.bsth.entity.search;
  2 +
  3 +/**
  4 + *
  5 + * @ClassName: SearchOperator
  6 + * @Description: 查询操作符
  7 + * @author PanZhao
  8 + * @date 2016年3月16日 下午4:08:22
  9 + *
  10 + */
  11 +public enum SearchOperator {
  12 +
  13 + eq, // 等于
  14 + ne, // 不等于
  15 + gt, // 大于
  16 + ge, // 大于等于
  17 + lt, // 小于
  18 + le, // 小于等于
  19 + prefixLike, // 前缀模糊匹配
  20 + prefixNotLike, // 前缀模糊不匹配
  21 + suffixLike, // 后缀模糊匹配
  22 + suffixNotLike, // 后缀模糊不匹配
  23 + like, // 模糊匹配
  24 + notLike, // 不匹配
  25 + isNull, // 空
  26 + isNotNull, // 非空
  27 + isf, //假 isFalse,boolean
  28 + ist, //真 isTrue,boolean
  29 + date, //时间
  30 + dateEq, //时间等于
  31 + in, //数组
  32 + ins, //传参 List<String>
  33 + ids
  34 +}
... ...
src/main/java/com/bsth/repository/StationRepository.java
... ... @@ -45,4 +45,11 @@ public interface StationRepository extends BaseRepository&lt;Station, Integer&gt; {
45 45  
46 46 @Query(value = "SELECT ST_AsText(b.buffer_polygon_wgs) g_polygon_grid, b.shaped_type,CONCAT(ST_X(a.center_point), ' ', ST_Y(a.center_point)) g_center_point , b.radius, a.station_code, b.station_name FROM bsth_c_station a JOIN bsth_c_stationroute b ON a.id = b.station WHERE b.line_code = ?1 AND a.station_code = ?2", nativeQuery = true)
47 47 Object[][] findBufferArea(String lineCode, String stationCode);
  48 +
  49 + /**
  50 + * 根据站点被引用情况生成站点的途径线路
  51 + */
  52 + @Modifying
  53 + @Query(value="UPDATE bsth_c_station t4 JOIN (SELECT t1.id, GROUP_CONCAT(t3.name,'-',t2.directions,'[',t2.station_name,']') pass_lines FROM bsth_c_station t1 LEFT JOIN bsth_c_stationroute t2 ON t1.id = t2.station LEFT JOIN bsth_c_line t3 ON t2.line = t3.id WHERE t2.destroy = 0 GROUP BY t1.id) t5 ON t4.id = t5.id SET t4.pass_lines = t5.pass_lines", nativeQuery = true)
  54 + void generatePassLine();
48 55 }
... ...
src/main/java/com/bsth/service/LsStationRouteService.java
... ... @@ -51,6 +51,8 @@ public interface LsStationRouteService extends BaseService&lt;LsStationRoute, Integ
51 51 */
52 52 void batchRecover(List<Integer> ids);
53 53  
  54 + Map<String, Object> addStationRoutes(Integer lineId, Integer versions, Integer directions, List<Integer> stationIds);
  55 +
54 56 /**
55 57 * 保存线路某个版本下单行的站点和路段路由
56 58 * 常规使用在根据百度地图生成数据或者模板导入的批量保存
... ...
src/main/java/com/bsth/service/StationService.java
... ... @@ -62,4 +62,9 @@ public interface StationService extends BaseService&lt;Station, Integer&gt; {
62 62 * 将路段的WGS坐标数据转换到百度坐标并保存
63 63 */
64 64 void translateWgs2Bd();
  65 +
  66 + /**
  67 + * 更新站点信息
  68 + */
  69 + void generatePassLine();
65 70 }
... ...
src/main/java/com/bsth/service/impl/LsStationRouteServiceImpl.java
... ... @@ -170,6 +170,69 @@ public class LsStationRouteServiceImpl extends BaseServiceImpl&lt;LsStationRoute, I
170 170 }
171 171 }
172 172  
  173 + /**
  174 + * 保存线路某个版本下的站点路由
  175 + * 常规使用在选择已有站点生成线路路由的情况
  176 + * @param lineId
  177 + * @param versions
  178 + * @param directions
  179 + * @param stationIds
  180 + * @return
  181 + */
  182 + @Transactional
  183 + @Override
  184 + public Map<String, Object> addStationRoutes(Integer lineId, Integer versions, Integer directions, List<Integer> stationIds) {
  185 + Map<String, Object> result = new HashMap<>();
  186 + Line line = lineRepository.findById(lineId).get();
  187 + Integer version = lineVersionsRepository.findCurrentVersion(lineId);
  188 + if (line == null) {
  189 + throw new RuntimeException(String.format("未找到ID为%d的线路信息", lineId));
  190 + }
  191 + Map<String, Object> params = new HashMap<>();
  192 + params.put("id_ids", stationIds);
  193 + List<Station> stations = stationRepository.findAll(new CustomerSpecs<>(params));
  194 + Map<Integer, Station> id2station = new HashMap<>();
  195 + if (stations.size() > 0) {
  196 + for (Station station : stations) {
  197 + id2station.put(station.getId(), station);
  198 + }
  199 + }
  200 + List<LsStationRoute> stationRoutes = new ArrayList<>();
  201 + for (int i = 0;i < stationIds.size();i++) {
  202 + Integer stationId = stationIds.get(i);
  203 + LsStationRoute stationRoute = new LsStationRoute();
  204 + Station station = id2station.get(stationId);
  205 + stationRoute.setStation(station);
  206 + stationRoute.setLine(line);
  207 + stationRoute.setLineCode(line.getLineCode());
  208 + stationRoute.setDirections(directions);
  209 + stationRoute.setVersions(versions);
  210 + stationRoute.setStationName(station.getStationName());
  211 + stationRoute.setStationCode(station.getStationCode());
  212 + stationRoute.setCenterPoint(station.getCenterPoint());
  213 + stationRoute.setCenterPointWgs(station.getCenterPointWgs());
  214 + stationRoute.setShapedType("r");
  215 + stationRoute.setRadius(80);
  216 + stationRoute.setStationRouteCode(100 + i * 10);
  217 + if (i == 0) {
  218 + stationRoute.setStationMark("B");
  219 + } else if (i == stationIds.size() - 1) {
  220 + stationRoute.setStationMark("E");
  221 + } else {
  222 + stationRoute.setStationMark("Z");
  223 + }
  224 +
  225 + stationRoutes.add(stationRoute);
  226 + }
  227 +
  228 + lsStationRouteRepository.saveAll(stationRoutes);
  229 + if (versions.equals(version)) {
  230 + refreshCurrent(lineId, version);
  231 + }
  232 +
  233 + return result;
  234 + }
  235 +
173 236 @Transactional
174 237 @Override
175 238 public Map<String, Object> addRoutes(Integer lineId, Integer versions, Integer directions, List<LsStationRoute> stationRoutes, List<LsSectionRoute> sectionRoutes) {
... ...
src/main/java/com/bsth/service/impl/StationServiceImpl.java
... ... @@ -152,6 +152,15 @@ public class StationServiceImpl extends BaseServiceImpl&lt;Station, Integer&gt; implem
152 152 }
153 153  
154 154 /**
  155 + * 更新站点信息
  156 + */
  157 + @Transactional
  158 + @Override
  159 + public void generatePassLine() {
  160 + stationRepository.generatePassLine();
  161 + }
  162 +
  163 + /**
155 164 * 存在wkt 则转换wkt为geo信息
156 165 * @param station
157 166 */
... ...
src/main/resources/static/index.html
... ... @@ -206,6 +206,14 @@
206 206 .page-container{
207 207 height: 100%;
208 208 }
  209 +
  210 + input.search-input{
  211 + box-sizing: border-box;
  212 + -moz-box-sizing:border-box;
  213 + width: 100%;
  214 + margin-bottom: 5px;
  215 + height: auto;
  216 + }
209 217 </style>
210 218  
211 219 <!-- ocLazyLoading载入文件的位置 -->
... ... @@ -369,11 +377,10 @@
369 377 <!-- select2 下拉框 -->
370 378 <script src="/metronic_v4.5.4/plugins/select2/js/select2.full.min.js"></script>
371 379 <!-- MULTI SELECT 多选下拉框 -->
372   -<script
373   - src="/metronic_v4.5.4/plugins/jquery-multi-select/js/jquery.multi-select.js"></script>
  380 +<script src="/metronic_v4.5.4/plugins/jquery-multi-select/js/jquery.multi-select.js"></script>
  381 +<script src="/metronic_v4.5.4/plugins/quicksearch/jquery.quicksearch.js"></script>
374 382 <!-- editable.js -->
375   -<script
376   - src="/metronic_v4.5.4/plugins/bootstrap-editable/bootstrap-editable/js/bootstrap-editable.min.js"></script>
  383 +<script src="/metronic_v4.5.4/plugins/bootstrap-editable/bootstrap-editable/js/bootstrap-editable.min.js"></script>
377 384 <!-- PJAX -->
378 385 <script src="/assets/plugins/jquery.pjax.js"></script>
379 386 <!-- layer 弹层 -->
... ...
src/main/resources/static/metronic_v4.5.4/plugins/quicksearch/jquery.quicksearch.js 0 → 100644
  1 +(function($, window, document, undefined) {
  2 + $.fn.quicksearch = function (target, opt) {
  3 +
  4 + var timeout, cache, rowcache, jq_results, val = '', e = this, options = $.extend({
  5 + delay: 100,
  6 + selector: null,
  7 + stripeRows: null,
  8 + loader: null,
  9 + noResults: '',
  10 + matchedResultsCount: 0,
  11 + bind: 'keyup',
  12 + onBefore: function () {
  13 + return;
  14 + },
  15 + onAfter: function () {
  16 + return;
  17 + },
  18 + show: function () {
  19 + this.style.display = "";
  20 + },
  21 + hide: function () {
  22 + this.style.display = "none";
  23 + },
  24 + prepareQuery: function (val) {
  25 + return val.toLowerCase().split(' ');
  26 + },
  27 + testQuery: function (query, txt, _row) {
  28 + for (var i = 0; i < query.length; i += 1) {
  29 + if (txt.indexOf(query[i]) === -1) {
  30 + return false;
  31 + }
  32 + }
  33 + return true;
  34 + }
  35 + }, opt);
  36 +
  37 + this.go = function () {
  38 +
  39 + var i = 0,
  40 + numMatchedRows = 0,
  41 + noresults = true,
  42 + query = options.prepareQuery(val),
  43 + val_empty = (val.replace(' ', '').length === 0);
  44 +
  45 + for (var i = 0, len = rowcache.length; i < len; i++) {
  46 + if (val_empty || options.testQuery(query, cache[i], rowcache[i])) {
  47 + options.show.apply(rowcache[i]);
  48 + noresults = false;
  49 + numMatchedRows++;
  50 + } else {
  51 + options.hide.apply(rowcache[i]);
  52 + }
  53 + }
  54 +
  55 + if (noresults) {
  56 + this.results(false);
  57 + } else {
  58 + this.results(true);
  59 + this.stripe();
  60 + }
  61 +
  62 + this.matchedResultsCount = numMatchedRows;
  63 + this.loader(false);
  64 + options.onAfter();
  65 +
  66 + return this;
  67 + };
  68 +
  69 + /*
  70 + * External API so that users can perform search programatically.
  71 + * */
  72 + this.search = function (submittedVal) {
  73 + val = submittedVal;
  74 + e.trigger();
  75 + };
  76 +
  77 + /*
  78 + * External API to get the number of matched results as seen in
  79 + * https://github.com/ruiz107/quicksearch/commit/f78dc440b42d95ce9caed1d087174dd4359982d6
  80 + * */
  81 + this.currentMatchedResults = function() {
  82 + return this.matchedResultsCount;
  83 + };
  84 +
  85 + this.stripe = function () {
  86 +
  87 + if (typeof options.stripeRows === "object" && options.stripeRows !== null)
  88 + {
  89 + var joined = options.stripeRows.join(' ');
  90 + var stripeRows_length = options.stripeRows.length;
  91 +
  92 + jq_results.not(':hidden').each(function (i) {
  93 + $(this).removeClass(joined).addClass(options.stripeRows[i % stripeRows_length]);
  94 + });
  95 + }
  96 +
  97 + return this;
  98 + };
  99 +
  100 + this.strip_html = function (input) {
  101 + var output = input.replace(new RegExp('<[^<]+\>', 'g'), "");
  102 + output = $.trim(output.toLowerCase());
  103 + return output;
  104 + };
  105 +
  106 + this.results = function (bool) {
  107 + if (typeof options.noResults === "string" && options.noResults !== "") {
  108 + if (bool) {
  109 + $(options.noResults).hide();
  110 + } else {
  111 + $(options.noResults).show();
  112 + }
  113 + }
  114 + return this;
  115 + };
  116 +
  117 + this.loader = function (bool) {
  118 + if (typeof options.loader === "string" && options.loader !== "") {
  119 + (bool) ? $(options.loader).show() : $(options.loader).hide();
  120 + }
  121 + return this;
  122 + };
  123 +
  124 + this.cache = function () {
  125 +
  126 + jq_results = $(target);
  127 +
  128 + if (typeof options.noResults === "string" && options.noResults !== "") {
  129 + jq_results = jq_results.not(options.noResults);
  130 + }
  131 +
  132 + var t = (typeof options.selector === "string") ? jq_results.find(options.selector) : $(target).not(options.noResults);
  133 + cache = t.map(function () {
  134 + return e.strip_html(this.innerHTML);
  135 + });
  136 +
  137 + rowcache = jq_results.map(function () {
  138 + return this;
  139 + });
  140 +
  141 + /*
  142 + * Modified fix for sync-ing "val".
  143 + * Original fix https://github.com/michaellwest/quicksearch/commit/4ace4008d079298a01f97f885ba8fa956a9703d1
  144 + * */
  145 + val = val || this.val() || "";
  146 +
  147 + return this.go();
  148 + };
  149 +
  150 + this.trigger = function () {
  151 + this.loader(true);
  152 + options.onBefore();
  153 +
  154 + window.clearTimeout(timeout);
  155 + timeout = window.setTimeout(function () {
  156 + e.go();
  157 + }, options.delay);
  158 +
  159 + return this;
  160 + };
  161 +
  162 + this.cache();
  163 + this.results(true);
  164 + this.stripe();
  165 + this.loader(false);
  166 +
  167 + return this.each(function () {
  168 +
  169 + /*
  170 + * Changed from .bind to .on.
  171 + * */
  172 + $(this).on(options.bind, function () {
  173 +
  174 + val = $(this).val();
  175 + e.trigger();
  176 + });
  177 + });
  178 +
  179 + };
  180 +
  181 +}(jQuery, this, document));
... ...
src/main/resources/static/pages/base/station/js/station-list-table.js
... ... @@ -64,6 +64,16 @@
64 64 $('tr.filter .filter-submit').on('click',function(){
65 65 initSearch();
66 66 });
  67 +
  68 + $('#generatePassLine').on('click', function () {
  69 + $.post('/station/generate-pass-line', {}, function(res) {
  70 + if(res.status == 'SUCCESS') {
  71 + layer.msg('操作成功...');
  72 + } else {
  73 + layer.msg('操作失败...');
  74 + }
  75 + });
  76 + });
67 77  
68 78 function initSearch() {
69 79 var params = getParams();
... ...
src/main/resources/static/pages/base/station/js/station-positions-function.js
... ... @@ -18,7 +18,16 @@ var PositionsPublicFunctions = function () {
18 18 var html = new Array();
19 19 html.push('<HR style="border:1 dashed #987cb9" width="100%" color=#987cb9 SIZE=1>');
20 20 html.push('<span style="color:#DDD;font-size: 15px;">站点名称:');html.push(station.stationName ? station.stationName : '');html.push('</span>');
21   - html.push('<span class="help-block" style="color:#DDD;font-size: 15px;">途经线路:');html.push(station.passLines ? station.passLines : '');html.push('</span>');
  21 + var passLines = station.passLines ? station.passLines : '';
  22 + html.push('<span class="help-block" style="color:#DDD;font-size: 15px;" title="');
  23 + html.push(passLines);
  24 + html.push('">途经线路:');
  25 + if (passLines.length > 20) {
  26 + html.push(passLines.substring(0, 20));
  27 + } else {
  28 + html.push(passLines);
  29 + }
  30 + html.push('</span>');
22 31 html.push('<span class="help-block" style="color:#DDD;font-size: 15px;">行业编码:');html.push(station.standardStationCode ? station.standardStationCode : '');html.push('</span>');
23 32 html.push('<span class="help-block" style="color:#DDD;font-size: 15px;">东西向:');html.push(station.ewDirection === undefined ? '' : station.ewDirection == 0 ? '东->西' : '西->东');html.push('</span>');
24 33 html.push('<span class="help-block" style="color:#DDD;font-size: 15px;">南北向:');html.push(station.snDirection === undefined ? '' : station.snDirection == 0 ? '南->北' : '北->南');html.push('</span>');
... ...
src/main/resources/static/pages/base/station/list.html
... ... @@ -23,6 +23,7 @@
23 23 <div class="actions">
24 24 <div class="btn-group btn-group-devided" data-toggle="buttons">
25 25 <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加站点</a>
  26 + <a class="btn btn-circle blue" href="javascript:void(0)" id="generatePassLine"><i class="fa fa-wrench"></i> 生成途径线路</a>
26 27 </div>
27 28 </div>
28 29 </div>
... ...
src/main/resources/static/pages/base/stationroute/js/routes-operation.js
... ... @@ -172,6 +172,13 @@ var RoutesOperation = (function () {
172 172 });
173 173 });
174 174  
  175 + $('.stationSelectGenerate').on('click', function () {
  176 + $.get('station_select_generate.html', function(m){
  177 + $(pjaxContainer).append(m);
  178 + $('#station_select_generate_modal').trigger('modal.show');
  179 + });
  180 + });
  181 +
175 182 // 上行站点新增事件
176 183 $('.module_tools #addUpStation').on('click', function() {
177 184 operation.addStationInit();
... ...
src/main/resources/static/pages/base/stationroute/list.html
... ... @@ -201,6 +201,10 @@
201 201 <li>
202 202 <a class="gpsRoute" href="javascript:;" data-direction="0" data-pjax><i class="fa fa-wrench"></i> 测点生成</a>
203 203 </li>
  204 + <li class="divider"> </li>
  205 + <li>
  206 + <a class="stationSelectGenerate" href="javascript:;" data-direction="0" data-pjax><i class="fa fa-wrench"></i> 选择站点生成</a>
  207 + </li>
204 208 </ul>
205 209 </div>
206 210 </div>
... ... @@ -309,6 +313,10 @@
309 313 <li>
310 314 <a class="gpsRoute" href="javascript:;" data-direction="1" data-pjax><i class="fa fa-wrench"></i> 测点生成</a>
311 315 </li>
  316 + <li class="divider"> </li>
  317 + <li>
  318 + <a class="stationSelectGenerate" href="javascript:;" data-direction="1" data-pjax><i class="fa fa-wrench"></i> 选择站点生成</a>
  319 + </li>
312 320 </ul>
313 321 </div>
314 322 </div>
... ...
src/main/resources/static/pages/base/stationroute/station_select_generate.html 0 → 100644
  1 +<div class="modal fade" id="station_select_generate_modal" tabindex="-1" role="basic" aria-hidden="true" style="min-width: 800px;">
  2 + <div class="modal-dialog">
  3 + <div class="modal-content" >
  4 +
  5 + <div class="modal-header">
  6 + <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
  7 + <h4 class="modal-title">选择站点</h4>
  8 + </div>
  9 +
  10 + <div class="modal-body">
  11 + <form class="form-horizontal" role="form" id="station_select_generate_form" action="" method="">
  12 + <div class="form-group last" >
  13 + <div>
  14 + <select multiple="multiple" class="multi-select" id="stationSelect" ></select>
  15 + </div>
  16 + </div>
  17 + </form>
  18 + </div>
  19 + <div class="modal-footer">
  20 + <button type="button" class="btn btn-primary" id="regionSaveBtn">提交</button>
  21 + <button type="button" class="btn default" data-dismiss="modal">取消</button>
  22 + </div>
  23 + </div>
  24 + </div>
  25 +</div>
  26 +<script type="text/javascript">
  27 + var properties = RoutesOperation.getProperties();
  28 +
  29 + $get('/station/all', {}, function(stations){
  30 + if (!stations || stations.length == 0) return;
  31 + var opts = new Array();
  32 + for (var idx in stations) {
  33 + var station = stations[idx];
  34 + opts.push('<option value="', station.id, '" title="', station.passLines, '">', station.stationName, '[', station.id, ']', '</option>');
  35 + }
  36 + $('#stationSelect').html(opts.join('')).multiSelect({
  37 + selectableHeader: "<input type='text' class='search-input' autocomplete='off' placeholder='未选择'>",
  38 + selectionHeader: "<input type='text' class='search-input' autocomplete='off' placeholder='已选择'>",
  39 + afterInit: function(ms){
  40 + var that = this,
  41 + $selectableSearch = that.$selectableUl.prev(),
  42 + $selectionSearch = that.$selectionUl.prev(),
  43 + selectableSearchString = '#'+that.$container.attr('id')+' .ms-elem-selectable:not(.ms-selected)',
  44 + selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
  45 +
  46 + that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
  47 + .on('keydown', function(e){
  48 + if (e.which === 40){
  49 + that.$selectableUl.focus();
  50 + return false;
  51 + }
  52 + });
  53 +
  54 + that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
  55 + .on('keydown', function(e){
  56 + if (e.which == 40){
  57 + that.$selectionUl.focus();
  58 + return false;
  59 + }
  60 + });
  61 + },
  62 + afterSelect: function(){
  63 + this.qs1.cache();
  64 + this.qs2.cache();
  65 + },
  66 + afterDeselect: function(){
  67 + this.qs1.cache();
  68 + this.qs2.cache();
  69 + }
  70 + });
  71 + });
  72 +
  73 + $('#station_select_generate_modal').on('modal.show', function(event) {
  74 + $('#station_select_generate_modal').modal({show: true, backdrop: 'static', keyboard: false});
  75 + })
  76 +
  77 + $('#station_select_generate_modal').on('show.bs.modal', function () {
  78 + })
  79 +
  80 + var form = $('#station_select_generate_form');
  81 + var error = $('.alert-danger', form);
  82 + $('#regionSaveBtn').on('click', function() {
  83 + form.submit();
  84 + });
  85 + form.validate({
  86 + errorElement : 'span',
  87 + errorClass : 'help-block help-block-error',
  88 + focusInvalid : false,
  89 + rules : {
  90 + 'regionAlias': {required: true, maxlength: 50}
  91 + },
  92 + invalidHandler : function(event, validator) {
  93 + error.show();
  94 + App.scrollTo(error, -200);
  95 + },
  96 + highlight : function(element) {
  97 + $(element).closest('.form-group').addClass('has-error');
  98 + },
  99 + unhighlight : function(element) {
  100 + $(element).closest('.form-group').removeClass('has-error');
  101 + },
  102 + success : function(label) {
  103 + label.closest('.form-group').removeClass('has-error');
  104 + },
  105 + submitHandler : function(f) {
  106 + error.hide();
  107 + var stationIds = $('#stationSelect').val();
  108 + if (!stationIds || stationIds.length == 0) {
  109 + layer.msg('请选择对应的站点');
  110 + return;
  111 + }
  112 + var params = {lineId: properties.lineId, versions: properties.versions, directions: properties.directions, stationIds: stationIds.join(',')};
  113 + $.ajax('/api/lsstationroute/addStationRoutes', {
  114 + method: 'POST',
  115 + data: JSON.stringify(params),
  116 + contentType: 'application/json',
  117 + success: function (res) {
  118 + if(res.status == 'SUCCESS') {
  119 + layer.msg('操作成功...');
  120 + } else {
  121 + layer.msg('操作失败...');
  122 + }
  123 + $('#station_select_generate_modal').modal('hide');
  124 + RoutesOperation.resjtreeDate(properties.lineId, properties.directions, properties.versions);
  125 + }
  126 + });
  127 + }
  128 + });
  129 +</script>
0 130 \ No newline at end of file
... ...