Commit e3b04d2fd5dbcf54a1e6609b428134e72c80db33
1 parent
e3533c18
update...
Showing
12 changed files
with
325 additions
and
52 deletions
src/main/java/com/bsth/controller/geo_data/GeoDataController.java
| ... | ... | @@ -46,4 +46,9 @@ public class GeoDataController { |
| 46 | 46 | ,@RequestParam String stationName,@RequestParam Float lat,@RequestParam Float lng,@RequestParam int prevRouteId){ |
| 47 | 47 | return geoDataService.addNewStationRoute(lineCode, upDown, versions, stationName, lat, lng, prevRouteId); |
| 48 | 48 | } |
| 49 | + | |
| 50 | + @RequestMapping(value = "destroyStation",method = RequestMethod.POST) | |
| 51 | + public Map<String, Object> destroyStation(GeoStation station){ | |
| 52 | + return geoDataService.destroyStation(station); | |
| 53 | + } | |
| 49 | 54 | } |
| 50 | 55 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/entity/geo_data/GeoStation.java
| ... | ... | @@ -23,7 +23,7 @@ public class GeoStation { |
| 23 | 23 | |
| 24 | 24 | private String stationMark; |
| 25 | 25 | |
| 26 | - private Integer version; | |
| 26 | + private Integer versions; | |
| 27 | 27 | |
| 28 | 28 | private Float gLonx; |
| 29 | 29 | |
| ... | ... | @@ -94,14 +94,6 @@ public class GeoStation { |
| 94 | 94 | this.stationMark = stationMark; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public Integer getVersion() { | |
| 98 | - return version; | |
| 99 | - } | |
| 100 | - | |
| 101 | - public void setVersion(Integer version) { | |
| 102 | - this.version = version; | |
| 103 | - } | |
| 104 | - | |
| 105 | 97 | public Float getgLonx() { |
| 106 | 98 | return gLonx; |
| 107 | 99 | } |
| ... | ... | @@ -149,4 +141,12 @@ public class GeoStation { |
| 149 | 141 | public void setBdCoords(List<String> bdCoords) { |
| 150 | 142 | this.bdCoords = bdCoords; |
| 151 | 143 | } |
| 144 | + | |
| 145 | + public Integer getVersions() { | |
| 146 | + return versions; | |
| 147 | + } | |
| 148 | + | |
| 149 | + public void setVersions(Integer versions) { | |
| 150 | + this.versions = versions; | |
| 151 | + } | |
| 152 | 152 | } |
| 153 | 153 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/service/geo_data/GeoDataService.java
| ... | ... | @@ -20,4 +20,6 @@ public interface GeoDataService { |
| 20 | 20 | Map<String, Object> updateStationName(Map<String, Object> map); |
| 21 | 21 | |
| 22 | 22 | Map<String,Object> addNewStationRoute(String lineCode, int upDown,int versions, String stationName, Float lat, Float lng, int prevRouteId); |
| 23 | + | |
| 24 | + Map<String,Object> destroyStation(GeoStation station); | |
| 23 | 25 | } | ... | ... |
src/main/java/com/bsth/service/geo_data/impl/GeoDataServiceImpl.java
| ... | ... | @@ -183,7 +183,14 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 183 | 183 | String sql = "select * from bsth_c_ls_stationroute where line_code='"+lineCode+"' and line="+lineId+" and directions="+upDown+" and destroy=0 and versions=" + versions; |
| 184 | 184 | List<SaveStationRouteDTO> routes = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(SaveStationRouteDTO.class)); |
| 185 | 185 | |
| 186 | + for(SaveStationRouteDTO s : routes){ | |
| 187 | + if(s.getStationName().equals(stationName)){ | |
| 186 | 188 | |
| 189 | + rs.put("status", ResponseCode.ERROR); | |
| 190 | + rs.put("msg", "重复的站点路由名称!"); | |
| 191 | + return rs; | |
| 192 | + } | |
| 193 | + } | |
| 187 | 194 | //按路由顺序排列 |
| 188 | 195 | Collections.sort(routes, new StationRouteComp()); |
| 189 | 196 | |
| ... | ... | @@ -215,23 +222,23 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 215 | 222 | } |
| 216 | 223 | } |
| 217 | 224 | |
| 218 | - sr = new SaveStationRouteDTO(); | |
| 219 | - sr.setLine(lineId); | |
| 220 | - sr.setLineCode(lineCode); | |
| 221 | - sr.setDirections(upDown); | |
| 222 | - sr.setVersions(versions); | |
| 223 | - sr.setStationRouteCode(currentNo); | |
| 224 | - sr.setStation(sCode); | |
| 225 | - sr.setStationCode(sCode + ""); | |
| 226 | - sr.setStationName(stationName); | |
| 227 | - sr.setDistances(0d); | |
| 228 | - sr.setToTime(0d); | |
| 225 | + SaveStationRouteDTO nsr = new SaveStationRouteDTO(); | |
| 226 | + nsr.setLine(lineId); | |
| 227 | + nsr.setLineCode(lineCode); | |
| 228 | + nsr.setDirections(upDown); | |
| 229 | + nsr.setVersions(versions); | |
| 230 | + nsr.setStationRouteCode(currentNo); | |
| 231 | + nsr.setStation(sCode); | |
| 232 | + nsr.setStationCode(sCode + ""); | |
| 233 | + nsr.setStationName(stationName); | |
| 234 | + nsr.setDistances(0d); | |
| 235 | + nsr.setToTime(0d); | |
| 229 | 236 | Date d = new Date(); |
| 230 | - sr.setCreateDate(d); | |
| 231 | - sr.setUpdateDate(d); | |
| 232 | - sr.setDestroy(0); | |
| 237 | + nsr.setCreateDate(d); | |
| 238 | + nsr.setUpdateDate(d); | |
| 239 | + nsr.setDestroy(0); | |
| 233 | 240 | |
| 234 | - routes.add(sr); | |
| 241 | + //routes.add(sr); | |
| 235 | 242 | |
| 236 | 243 | //重新标记mark |
| 237 | 244 | Collections.sort(routes, new StationRouteComp()); |
| ... | ... | @@ -242,10 +249,16 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 242 | 249 | routes.get(routes.size() - 1).setStationMark("E"); |
| 243 | 250 | |
| 244 | 251 | final List<SaveStationRouteDTO> saveList = routes; |
| 245 | - //insert 路由 | |
| 246 | - jdbcTemplate.update("delete from bsth_c_ls_stationroute where line_code='"+lineCode+"' and line="+lineId+" and directions="+upDown+" and destroy=0 and versions=" + versions); | |
| 247 | - jdbcTemplate.batchUpdate("insert into bsth_c_ls_stationroute(line, station, station_name, station_route_code, line_code, station_code, station_mark, distances, to_time, destroy, versions, create_date, update_date,directions) " + | |
| 248 | - " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)", new BatchPreparedStatementSetter() { | |
| 252 | + //insert 新路由 (ID自增) | |
| 253 | + jdbcTemplate.update("insert into bsth_c_ls_stationroute(line, station, station_name, station_route_code, line_code, station_code, station_mark, distances, to_time, destroy, versions, create_date, update_date,directions) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)" | |
| 254 | + ,nsr.getLine(),nsr.getStation(),nsr.getStationName(),nsr.getStationRouteCode(),nsr.getLineCode(),nsr.getStationCode(),nsr.getStationMark() | |
| 255 | + ,nsr.getDistances(),nsr.getToTime(),nsr.getDestroy(),nsr.getVersions(),nsr.getCreateDate(),nsr.getUpdateDate(),nsr.getDirections()); | |
| 256 | + | |
| 257 | + // update 原路由 | |
| 258 | + jdbcTemplate.batchUpdate("update bsth_c_ls_stationroute set line=?,station=?,station_name=?,station_route_code=?," + | |
| 259 | + "line_code=?,station_code=?,station_mark=?,distances=?,to_time=?,destroy=?,versions=?,create_date=?,update_date=?,directions=?" + | |
| 260 | + " where id=?" | |
| 261 | + , new BatchPreparedStatementSetter() { | |
| 249 | 262 | @Override |
| 250 | 263 | public void setValues(PreparedStatement ps, int i) throws SQLException { |
| 251 | 264 | SaveStationRouteDTO sr = saveList.get(i); |
| ... | ... | @@ -263,6 +276,7 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 263 | 276 | ps.setTimestamp(12, new java.sql.Timestamp(sr.getCreateDate().getTime())); |
| 264 | 277 | ps.setTimestamp(13, new java.sql.Timestamp(sr.getUpdateDate().getTime())); |
| 265 | 278 | ps.setInt(14, sr.getDirections()); |
| 279 | + ps.setInt(15, sr.getId()); | |
| 266 | 280 | } |
| 267 | 281 | |
| 268 | 282 | @Override |
| ... | ... | @@ -272,6 +286,12 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 272 | 286 | }); |
| 273 | 287 | |
| 274 | 288 | tran.commit(status); |
| 289 | + | |
| 290 | + //返回更新之后的数据 | |
| 291 | + List<GeoStation> list = findByUpdown(lineCode, upDown, versions); | |
| 292 | + | |
| 293 | + rs.put("list", list); | |
| 294 | + rs.put("newStationRouteCode", currentNo); | |
| 275 | 295 | rs.put("status", ResponseCode.SUCCESS); |
| 276 | 296 | } catch (Exception e) { |
| 277 | 297 | tran.rollback(status); |
| ... | ... | @@ -282,6 +302,38 @@ public class GeoDataServiceImpl implements GeoDataService { |
| 282 | 302 | return rs; |
| 283 | 303 | } |
| 284 | 304 | |
| 305 | + private List<GeoStation> findByUpdown(String lineCode, int upDown, int versions){ | |
| 306 | + //返回更新之后的数据 | |
| 307 | + String sql = "select t1.*,t2.g_lonx,g_laty,ST_AsText(g_polygon_grid) as g_polygon_grid,radius,shapes_type from (select id,station_name,station_route_code,line_code,station_code,station_mark,versions,directions from bsth_c_ls_stationroute where line=" + lineCode + " and directions="+upDown+" and destroy=0 and versions="+versions+") t1 LEFT JOIN bsth_c_station t2 on t1.station_code=t2.station_cod"; | |
| 308 | + List<GeoStation> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(GeoStation.class)); | |
| 309 | + | |
| 310 | + for (GeoStation station : list) { | |
| 311 | + if (station.getShapesType().equals("d")) | |
| 312 | + station.setBdCoords(multiWgsToBd(station.getgPolygonGrid(), 9, 3)); | |
| 313 | + } | |
| 314 | + return list; | |
| 315 | + } | |
| 316 | + | |
| 317 | + @Override | |
| 318 | + public Map<String, Object> destroyStation(GeoStation station) { | |
| 319 | + Map<String, Object> rs = new HashMap<>(); | |
| 320 | + | |
| 321 | + try { | |
| 322 | + String sql = "update bsth_c_ls_stationroute set destroy=1 where id=?"; | |
| 323 | + jdbcTemplate.update(sql, station.getId()); | |
| 324 | + | |
| 325 | + //返回更新之后的数据 | |
| 326 | + List<GeoStation> list = findByUpdown(station.getLineCode(), station.getDirections(), station.getVersions()); | |
| 327 | + rs.put("list", list); | |
| 328 | + rs.put("status", ResponseCode.SUCCESS); | |
| 329 | + } catch (Exception e) { | |
| 330 | + logger.error("", e); | |
| 331 | + rs.put("status", ResponseCode.ERROR); | |
| 332 | + rs.put("msg", "服务器出现异常"); | |
| 333 | + } | |
| 334 | + return rs; | |
| 335 | + } | |
| 336 | + | |
| 285 | 337 | |
| 286 | 338 | /** |
| 287 | 339 | * 根据路由ID 获取站点 | ... | ... |
src/main/resources/static/pages/base/geo_data_edit/css/mian.css
| ... | ... | @@ -259,11 +259,11 @@ ul.uk-list.station_info_win>li.s_name{ |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | .road_route .uk-list ul{ |
| 262 | - padding-left: 22px; | |
| 262 | + padding-left: 0; | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | .road_route>ul>li>ul>li{ |
| 266 | - padding-left: 8px; | |
| 266 | + padding-left: 22px; | |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | .ct_coord_str{ | ... | ... |
src/main/resources/static/pages/base/geo_data_edit/fragments/f_road_route.html
| ... | ... | @@ -2,14 +2,14 @@ |
| 2 | 2 | <script id="geo_d_e_road_route-temp" type="text/html"> |
| 3 | 3 | <ul class="uk-list"> |
| 4 | 4 | {{each list as subArr i}} |
| 5 | - <li class="road_li_{{subArr[0].sectionCode}} first_road_active"> | |
| 5 | + <li class="r_r_item first_road_active" > | |
| 6 | 6 | <a data-code="{{subArr[0].sectionCode}}" data-updown="{{subArr[0].directions}}">{{subArr[0].sectionName}}<span class="sub_name">{{subArr[0].crosesRoad}}</span></a> |
| 7 | 7 | |
| 8 | 8 | {{if subArr.length > 1}} |
| 9 | 9 | {{each subArr as obj j}} |
| 10 | 10 | <ul class="uk-list"> |
| 11 | 11 | {{if j > 0}} |
| 12 | - <li class="road_li_{{obj.sectionCode}}"> | |
| 12 | + <li class="r_r_item"> | |
| 13 | 13 | <a data-code="{{obj.sectionCode}}" data-updown="{{obj.directions}}">{{obj.sectionName}}<span class="sub_name">{{obj.crosesRoad}}</span></a></li> |
| 14 | 14 | {{/if}} |
| 15 | 15 | </ul> | ... | ... |
src/main/resources/static/pages/base/geo_data_edit/fragments/f_station_route.html
| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | </script> |
| 15 | 15 | |
| 16 | 16 | <script id="geo_d_e_station_route_one-temp" type="text/html"> |
| 17 | - <li class="station_li_{{stationCode}}"> | |
| 17 | + <li class="s_r_item" data-code="{{stationCode}}" data-id="{{id}}"> | |
| 18 | 18 | <div class="ct_route_badge_wrap"> |
| 19 | 19 | <span class="uk-badge ct_route_badge {{if stationMark=='B'}}start{{else if stationMark=='E'}}end{{/if}} {{if shapesType=='d'}}polygon{{/if}}"> |
| 20 | 20 | {{if stationMark=='B'}}起点站{{else if stationMark=='E'}}终点站{{else}}{{index}}{{/if}}</span> | ... | ... |
src/main/resources/static/pages/base/geo_data_edit/js/map.js
| ... | ... | @@ -76,7 +76,7 @@ var gb_ct_map = function () { |
| 76 | 76 | array.push(marker); |
| 77 | 77 | }); |
| 78 | 78 | |
| 79 | - stationMarkers.push(array); | |
| 79 | + stationMarkers[routes[0].directions] = array; | |
| 80 | 80 | }; |
| 81 | 81 | |
| 82 | 82 | function transCoord(obj) { |
| ... | ... | @@ -303,6 +303,8 @@ var gb_ct_map = function () { |
| 303 | 303 | |
| 304 | 304 | var exitEditBufferStatus = function (s) { |
| 305 | 305 | map_status = 0; |
| 306 | + $('.main_left_panel_m_layer').hide(); | |
| 307 | + $('.buffer_edit_panel').remove(); | |
| 306 | 308 | //enabledOtherElem(); |
| 307 | 309 | //gb_station_route.hideEditPanel(); |
| 308 | 310 | |
| ... | ... | @@ -543,10 +545,25 @@ var gb_ct_map = function () { |
| 543 | 545 | var local = new BMap.LocalSearch(map, { |
| 544 | 546 | renderOptions: {map: map}, |
| 545 | 547 | onMarkersSet: function (pos) { |
| 546 | - var old_m = pos[0].marker; | |
| 547 | - var point = old_m.point; | |
| 548 | - //清除默认的点 | |
| 549 | - map.removeOverlay(old_m); | |
| 548 | + var point; | |
| 549 | + if(!pos || pos.length==0){ | |
| 550 | + var pId = gb_station_route.getAddPrevId(); | |
| 551 | + if(pId){ | |
| 552 | + //百度没有定位到位置,默认靠近在上一个站 | |
| 553 | + var prev = gb_station_route.getStationById(pId); | |
| 554 | + point = new BMap.Point(prev.bd_lon - 0.0001, prev.bd_lat - 0.0001); | |
| 555 | + } | |
| 556 | + else{ | |
| 557 | + //没有上一个站点,默认在地图中间 | |
| 558 | + point = map.getCenter() | |
| 559 | + } | |
| 560 | + } | |
| 561 | + else{ | |
| 562 | + var old_m = pos[0].marker; | |
| 563 | + point = old_m.point; | |
| 564 | + //清除默认的点 | |
| 565 | + map.removeOverlay(old_m); | |
| 566 | + } | |
| 550 | 567 | //进入新增点位 地图选点模式 |
| 551 | 568 | startSearchPoint(point, name); |
| 552 | 569 | } |
| ... | ... | @@ -560,6 +577,10 @@ var gb_ct_map = function () { |
| 560 | 577 | var m = createYellowStation(point, name); |
| 561 | 578 | m.enableDragging(); |
| 562 | 579 | map.addOverlay(m); |
| 580 | + map.setCenter(point); | |
| 581 | + | |
| 582 | + if(map.getZoom() < 16) | |
| 583 | + map.setZoom(16); | |
| 563 | 584 | |
| 564 | 585 | _updateSearchPoint(m); |
| 565 | 586 | m.addEventListener('dragging', function () { |
| ... | ... | @@ -616,6 +637,20 @@ var gb_ct_map = function () { |
| 616 | 637 | return marker; |
| 617 | 638 | } |
| 618 | 639 | |
| 640 | + /** | |
| 641 | + * 重绘一个走向的站点 | |
| 642 | + * @param upDown | |
| 643 | + */ | |
| 644 | + var reDrawStation = function (upDown) { | |
| 645 | + $.each(stationMarkers[upDown], function () { | |
| 646 | + map.removeOverlay(this); | |
| 647 | + }); | |
| 648 | + stationMarkers[upDown] = []; | |
| 649 | + | |
| 650 | + clearOtherOverlay(); | |
| 651 | + _renderStationMarket(gb_station_route.getData()[upDown]); | |
| 652 | + }; | |
| 653 | + | |
| 619 | 654 | res_load_ep.emitLater('load_map'); |
| 620 | 655 | return { |
| 621 | 656 | _render: _render, |
| ... | ... | @@ -639,6 +674,7 @@ var gb_ct_map = function () { |
| 639 | 674 | clearOtherOverlay(); |
| 640 | 675 | map.removeEventListener('dblclick', pickupPoint); |
| 641 | 676 | map.enableDoubleClickZoom(); |
| 642 | - } | |
| 677 | + }, | |
| 678 | + reDrawStation: reDrawStation | |
| 643 | 679 | }; |
| 644 | 680 | }(); |
| 645 | 681 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/base/geo_data_edit/js/road_route.js
| ... | ... | @@ -15,7 +15,6 @@ var gb_road_route = function () { |
| 15 | 15 | //按顺序,名称分组 |
| 16 | 16 | var ups = _group(road_maps[0]); |
| 17 | 17 | var downs = _group(road_maps[1]); |
| 18 | - console.log('upsupsups', ups, 'downsdownsdowns', downs); | |
| 19 | 18 | //渲染 |
| 20 | 19 | var upHtmlStr = temps['geo_d_e_road_route-temp']({list: ups}); |
| 21 | 20 | $('.up_down_route_list>li:first>.road_route').html(upHtmlStr); |
| ... | ... | @@ -71,7 +70,8 @@ var gb_road_route = function () { |
| 71 | 70 | |
| 72 | 71 | var focus = function (data) { |
| 73 | 72 | //sectionCode |
| 74 | - var elem = $('.up_down_route_list>li>.road_route .road_li_' + data.sectionCode); | |
| 73 | + var elem = $('.up_down_route_list>li>.road_route .r_r_item a[data-code='+data.sectionCode+']'); | |
| 74 | + elem = elem.parent(); | |
| 75 | 75 | elem.addClass('ct_active'); |
| 76 | 76 | |
| 77 | 77 | if (!isShow(elem)) { |
| ... | ... | @@ -89,6 +89,36 @@ var gb_road_route = function () { |
| 89 | 89 | return elem.offset().top < wrap.height() + 122 && elem.offset().top > 122; |
| 90 | 90 | }; |
| 91 | 91 | |
| 92 | + //$('.up_down_route_list>li>.road_route .r_r_item a[data-code='+data.sectionCode+']') | |
| 93 | + $.contextMenu({ | |
| 94 | + selector: '.up_down_route_list>li>.road_route .r_r_item a[data-code]', | |
| 95 | + className: 'station-route-ct-menu', | |
| 96 | + callback: function (key, options) { | |
| 97 | + /*var aLink = options.$trigger; | |
| 98 | + var code = aLink.data('code'), | |
| 99 | + updown = aLink.data('updown'); | |
| 100 | + var station = getStation(code, updown); | |
| 101 | + realEditStation = station; | |
| 102 | + callbackHandler[key] && callbackHandler[key](station);*/ | |
| 103 | + }, | |
| 104 | + items: { | |
| 105 | + 'edit_buffer': { | |
| 106 | + name: '编辑' | |
| 107 | + }, | |
| 108 | + 'sep1': '---------', | |
| 109 | + 'insert_after': { | |
| 110 | + name: '新增路段(之后)' | |
| 111 | + }, | |
| 112 | + 'insert_before': { | |
| 113 | + name: '新增路段(之前)' | |
| 114 | + }, | |
| 115 | + 'destroy': { | |
| 116 | + name: '撤销路段' | |
| 117 | + } | |
| 118 | + } | |
| 119 | + }); | |
| 120 | + | |
| 121 | + | |
| 92 | 122 | res_load_ep.emitLater('load_road_route'); |
| 93 | 123 | return { |
| 94 | 124 | init: init, getData: function () { | ... | ... |
src/main/resources/static/pages/base/geo_data_edit/js/station_route.js
| ... | ... | @@ -106,6 +106,10 @@ var gb_station_route = function () { |
| 106 | 106 | var addCell = $(temps['geo_d_e_add_station_panel-temp'](station)); |
| 107 | 107 | cell.before(addCell); |
| 108 | 108 | |
| 109 | + add_station(addCell); | |
| 110 | + }; | |
| 111 | + | |
| 112 | + var add_station = function (addCell) { | |
| 109 | 113 | gb_ct_map.closeInfoWin(); |
| 110 | 114 | //焦点 |
| 111 | 115 | var $nameInput = $('input[name=stationName]', addCell); |
| ... | ... | @@ -117,13 +121,23 @@ var gb_station_route = function () { |
| 117 | 121 | |
| 118 | 122 | //选择地图位置 |
| 119 | 123 | $('.search_point_icon_btn', addCell).on('click', function () { |
| 124 | + $('.station_li_transient').removeClass('_search_point'); | |
| 125 | + $(this).parents('.station_li_transient').addClass('_search_point'); | |
| 120 | 126 | var name = $nameInput.val(); |
| 121 | 127 | if(!name) |
| 122 | - return UIkit.notification("你必须输入站点名称!", {status: 'danger',pos: 'bottom-left'}); | |
| 128 | + return UIkit.notification("你必须输入站点名称!", {status: 'danger'}); | |
| 129 | + | |
| 130 | + if(is_duplication(name)) | |
| 131 | + return UIkit.notification("站点路由名称重复!!", {status: 'danger'}); | |
| 123 | 132 | |
| 124 | 133 | $('.main_left_panel_m_layer').show(); |
| 125 | 134 | gb_ct_map.showAddPointPanel(name); |
| 126 | 135 | }); |
| 136 | + //监听回车事件 | |
| 137 | + $('[name=stationName]', addCell).on('keydown', function (e) { | |
| 138 | + if(event.keyCode == "13") | |
| 139 | + $('.search_point_icon_btn', addCell).trigger('click'); | |
| 140 | + }); | |
| 127 | 141 | |
| 128 | 142 | //上一个站点的ID |
| 129 | 143 | var $prev = addCell.prev('.s_r_item'); |
| ... | ... | @@ -133,13 +147,40 @@ var gb_station_route = function () { |
| 133 | 147 | addPrevId = -1; |
| 134 | 148 | }; |
| 135 | 149 | |
| 150 | + /** | |
| 151 | + * name 是否重复 | |
| 152 | + * @param name | |
| 153 | + */ | |
| 154 | + var is_duplication = function (name) { | |
| 155 | + var array = station_maps[getUpDown()]; | |
| 156 | + for(var i=0, s; s=array[i++];){ | |
| 157 | + if(s.stationName==name) | |
| 158 | + return true; | |
| 159 | + } | |
| 160 | + return false; | |
| 161 | + }; | |
| 162 | + | |
| 163 | + var insert_station_after = function (station) { | |
| 164 | + //在之后插入站点 | |
| 165 | + var cell = getStationLI(station); | |
| 166 | + | |
| 167 | + var addCell = $(temps['geo_d_e_add_station_panel-temp'](station)); | |
| 168 | + cell.after(addCell); | |
| 169 | + | |
| 170 | + add_station(addCell); | |
| 171 | + }; | |
| 172 | + | |
| 136 | 173 | var realEditStation; |
| 137 | 174 | var callbackHandler = { |
| 138 | 175 | edit_buffer: function (station) { |
| 139 | 176 | gb_ct_map.editStationBuffer(station); |
| 140 | 177 | }, |
| 141 | 178 | edit_name: station_edit_name, |
| 142 | - insert_before: insert_station_before | |
| 179 | + insert_before: insert_station_before, | |
| 180 | + insert_after: insert_station_after, | |
| 181 | + destroy: function (station) { | |
| 182 | + gb_data_submit.destroyStation(station); | |
| 183 | + } | |
| 143 | 184 | }; |
| 144 | 185 | |
| 145 | 186 | $.contextMenu({ |
| ... | ... | @@ -161,12 +202,12 @@ var gb_station_route = function () { |
| 161 | 202 | 'edit_name': { |
| 162 | 203 | name: '修改站点名称' |
| 163 | 204 | }, |
| 164 | - 'insert_before': { | |
| 165 | - name: '新增站点(之前)' | |
| 166 | - }, | |
| 167 | 205 | 'insert_after': { |
| 168 | 206 | name: '新增站点(之后)' |
| 169 | 207 | }, |
| 208 | + 'insert_before': { | |
| 209 | + name: '新增站点(之前)' | |
| 210 | + }, | |
| 170 | 211 | 'destroy': { |
| 171 | 212 | name: '撤销站点' |
| 172 | 213 | } |
| ... | ... | @@ -319,6 +360,85 @@ var gb_station_route = function () { |
| 319 | 360 | }, 200); |
| 320 | 361 | }; |
| 321 | 362 | |
| 363 | + var updateStationRouteData = function (list) { | |
| 364 | + list.sort(function (a, b) { | |
| 365 | + return parseInt(a.stationRouteCode) - parseInt(b.stationRouteCode); | |
| 366 | + }); | |
| 367 | + | |
| 368 | + var upDown = list[0].directions; | |
| 369 | + var dataMaps = {}; | |
| 370 | + //更新数据 | |
| 371 | + for(var i=0,s;s=list[i++];){ | |
| 372 | + s.index = i; | |
| 373 | + dataMaps[s.id] = s; | |
| 374 | + } | |
| 375 | + station_maps[upDown] = list; | |
| 376 | + //更新序号 | |
| 377 | + var wrap = $('.up_down_route_list>li:eq('+upDown+')>.station_route'); | |
| 378 | + $('.s_r_item', wrap).each(function () { | |
| 379 | + $(this).replaceWith( | |
| 380 | + temps['geo_d_e_station_route_one-temp'](dataMaps[$(this).data('id')])); | |
| 381 | + }); | |
| 382 | + | |
| 383 | + //延迟清除动画class | |
| 384 | + setTimeout(function () { | |
| 385 | + $('.s_r_item a.uk-animation-shake', wrap).removeClass('uk-animation-shake'); | |
| 386 | + }, 1000); | |
| 387 | + | |
| 388 | + //更新地图 | |
| 389 | + gb_ct_map.reDrawStation(upDown); | |
| 390 | + }; | |
| 391 | + | |
| 392 | + /** | |
| 393 | + * 添加结束,刷新List | |
| 394 | + * @param list | |
| 395 | + */ | |
| 396 | + var addEnd = function (list, _newRCode) { | |
| 397 | + updateStationRouteData(list); | |
| 398 | + | |
| 399 | + var upDown = list[0].directions; | |
| 400 | + var wrap = $('.up_down_route_list>li:eq('+upDown+')>.station_route'); | |
| 401 | + //新增的站点路由 | |
| 402 | + var ns = getStationByRouteCode(upDown, _newRCode); | |
| 403 | + $('.station_li_transient._search_point', wrap).replaceWith( | |
| 404 | + temps['geo_d_e_station_route_one-temp'](ns) | |
| 405 | + ); | |
| 406 | + | |
| 407 | + $('.main_left_panel_m_layer').hide(); | |
| 408 | + $('.add_station_search_point_wrap').remove(); | |
| 409 | + }; | |
| 410 | + | |
| 411 | + /** | |
| 412 | + * 撤销完成 | |
| 413 | + * @param list | |
| 414 | + */ | |
| 415 | + var destroyEnd = function (list, station) { | |
| 416 | + //被撤销的 | |
| 417 | + $('.up_down_route_list .s_r_item[data-id='+station.id+']').remove(); | |
| 418 | + updateStationRouteData(list); | |
| 419 | + }; | |
| 420 | + | |
| 421 | + var getStationByRouteCode = function (upDown, _newRCode) { | |
| 422 | + var list = station_maps[upDown]; | |
| 423 | + for(var i=0,s; s=list[i++];){ | |
| 424 | + if(s.stationRouteCode==_newRCode) | |
| 425 | + return s; | |
| 426 | + } | |
| 427 | + return null; | |
| 428 | + }; | |
| 429 | + | |
| 430 | + var getStationById = function (id) { | |
| 431 | + for(var i=0,s;s=station_maps[0][i++];){ | |
| 432 | + if(s.id == id) | |
| 433 | + return s; | |
| 434 | + } | |
| 435 | + for(var i=0,s;s=station_maps[1][i++];){ | |
| 436 | + if(s.id == id) | |
| 437 | + return s; | |
| 438 | + } | |
| 439 | + return null; | |
| 440 | + }; | |
| 441 | + | |
| 322 | 442 | res_load_ep.emitLater('load_station_route'); |
| 323 | 443 | return { |
| 324 | 444 | init: init, |
| ... | ... | @@ -340,6 +460,9 @@ var gb_station_route = function () { |
| 340 | 460 | reWriteSearchPointPanel: reWriteSearchPointPanel, |
| 341 | 461 | getAddPrevId: function () { |
| 342 | 462 | return addPrevId; |
| 343 | - } | |
| 463 | + }, | |
| 464 | + addEnd: addEnd, | |
| 465 | + destroyEnd: destroyEnd, | |
| 466 | + getStationById:getStationById | |
| 344 | 467 | }; |
| 345 | 468 | }(); |
| 346 | 469 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/base/geo_data_edit/js/submit.js
| ... | ... | @@ -77,9 +77,10 @@ var gb_data_submit = function () { |
| 77 | 77 | |
| 78 | 78 | delete data.gLonx; |
| 79 | 79 | delete data.gLaty; |
| 80 | - //console.log('data', data); | |
| 81 | 80 | //添加 |
| 82 | 81 | gb_common.$post('/_geo_data/addNewStationRoute', data, function (rs) { |
| 82 | + gb_station_route.addEnd(rs.list, rs.newStationRouteCode); | |
| 83 | + | |
| 83 | 84 | hide_run_text(); |
| 84 | 85 | UIkit.notification("修改成功!", {status: 'success'}); |
| 85 | 86 | }); |
| ... | ... | @@ -97,8 +98,27 @@ var gb_data_submit = function () { |
| 97 | 98 | $loadPanel.hide(); |
| 98 | 99 | }; |
| 99 | 100 | |
| 101 | + /** | |
| 102 | + * 撤销站点 | |
| 103 | + * @param station | |
| 104 | + */ | |
| 105 | + var destroyStation = function (station) { | |
| 106 | + | |
| 107 | + UIkit.modal.confirm('确定撤销站点【'+station.stationName+'】?').then(function() { | |
| 108 | + show_run_text('正在撤销...'); | |
| 109 | + | |
| 110 | + gb_common.$post("/_geo_data/destroyStation", station, function (rs) { | |
| 111 | + gb_station_route.destroyEnd(rs.list, station); | |
| 112 | + hide_run_text(); | |
| 113 | + UIkit.notification("撤销成功!", {status: 'success'}); | |
| 114 | + }); | |
| 115 | + }); | |
| 116 | + } | |
| 117 | + | |
| 100 | 118 | function getUpDown(){ |
| 101 | 119 | return $('._route_info_wrap>ul>li:first').hasClass('uk-active')?0:1; |
| 102 | 120 | } |
| 103 | - return {}; | |
| 121 | + return { | |
| 122 | + destroyStation: destroyStation | |
| 123 | + }; | |
| 104 | 124 | }(); |
| 105 | 125 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/base/geo_data_edit/main.html
| ... | ... | @@ -108,7 +108,7 @@ |
| 108 | 108 | var $loadPanel = $('body>.loading'); |
| 109 | 109 | //___________________________________ |
| 110 | 110 | var storage = window.localStorage; |
| 111 | - storage.setItem("geo_data_edit_line_code" , "70123"); | |
| 111 | + storage.setItem("geo_data_edit_line_code" , "10648"); | |
| 112 | 112 | storage.setItem("geo_data_edit_line_version" , "1"); |
| 113 | 113 | //___________________________________ |
| 114 | 114 | |
| ... | ... | @@ -142,7 +142,7 @@ |
| 142 | 142 | eq.once('end', function () { |
| 143 | 143 | $loadPanel.hide(); |
| 144 | 144 | }); |
| 145 | - }); | |
| 145 | + }); | |
| 146 | 146 | |
| 147 | 147 | function g_emit(id) { |
| 148 | 148 | console.log('g_emit [' + id + ']'); |
| ... | ... | @@ -161,13 +161,18 @@ |
| 161 | 161 | }); |
| 162 | 162 | |
| 163 | 163 | function getUpDown(){ |
| 164 | - return $('._route_info_wrap>ul>li:first').hasClass('uk-active')?0:1; | |
| 164 | + return $('.up_down_route_list>li:first').hasClass('uk-active')?0:1; | |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | //切换上下行显示 |
| 168 | 168 | $('.up_down_route_list').on('show', function () { |
| 169 | 169 | gb_ct_map.changeUpDown(); |
| 170 | 170 | }); |
| 171 | + | |
| 172 | + $(document).on('submit', 'form', function (e) { | |
| 173 | + e.stopPropagation(); | |
| 174 | + return false; | |
| 175 | + }); | |
| 171 | 176 | </script> |
| 172 | 177 | |
| 173 | 178 | <!--- js --> | ... | ... |