Commit f3b597167fc5a089124739ab74cfb8cb4e00b50c
1 parent
c1569fe0
update
Showing
4 changed files
with
126 additions
and
27 deletions
src/main/resources/static/real_control_v2/fragments/geo/calc_station_space.html
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/lj_zrw.html
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task/add_sub_task_inpark.html
| ... | ... | @@ -191,7 +191,7 @@ |
| 191 | 191 | <button type="button" class="uk-button uk-button-primary">提交子任务</button> |
| 192 | 192 | |
| 193 | 193 | <div class="ct-footer-left"> |
| 194 | - <a id="betweenStationRangeCalc" data-drawer-id="cal_station_space_drawer">站点间公里不准?</a> | |
| 194 | + <a id="betweenStationRangeCalc" data-drawer-id="station_route_spacing_chart_drawer">站点间公里不准?</a> | |
| 195 | 195 | </div> |
| 196 | 196 | </div> |
| 197 | 197 | </div> |
| ... | ... | @@ -211,7 +211,7 @@ |
| 211 | 211 | serviceForm = $('form[service_form]', modal), |
| 212 | 212 | emptyForm = $('form[empty_form]', modal), |
| 213 | 213 | destroyForm = $('form[destroy_form]', modal), |
| 214 | - sch, stationRoutes, parks, information, esCode; | |
| 214 | + sch, stationRoutes, parks, information, esCode, timeLocStations; | |
| 215 | 215 | var adjustExps = ['配车', '保养', '故障', '肇事', '路阻', '纠纷', '缺人', '客稀', '缺车', '气候', '援外', '吊慢', '抽减', '其他']; |
| 216 | 216 | $(modal).on('init', function (e, data) { |
| 217 | 217 | sch = data.sch; |
| ... | ... | @@ -235,26 +235,17 @@ |
| 235 | 235 | }); |
| 236 | 236 | //线路标准 |
| 237 | 237 | information = gb_data_basic.getLineInformation(sch.xlBm); |
| 238 | + //本地存储的站点耗时 | |
| 239 | + try { | |
| 240 | + timeLocStations = window.localStorage.getItem('control_route_distance_' + sch.xlBm); | |
| 241 | + if (timeLocStations) | |
| 242 | + timeLocStations = JSON.parse(timeLocStations).stations[sch.xlDir == 0 ? 'up' : 'down']; | |
| 243 | + } catch (e) { | |
| 244 | + console.log(e); | |
| 245 | + } | |
| 238 | 246 | |
| 239 | - var routeOpts = ''; | |
| 240 | - $.each(stationRoutes, function () { | |
| 241 | - routeOpts += '<option value="' + this.stationCode + '">' + this.stationName + '</option>'; | |
| 242 | - }); | |
| 243 | - esCode = stationRoutes[stationRoutes.length - 1].stationCode; | |
| 244 | - | |
| 245 | - //营运起终点 | |
| 246 | - $('select[name=startStation],select[name=endStation]', serviceForm).html(routeOpts); | |
| 247 | - //空驶起点 | |
| 248 | - $('select[name=startStation]', emptyForm).html(routeOpts).val(esCode); | |
| 249 | - //烂班起终点 | |
| 250 | - $('select[name=startStation],select[name=endStation]', destroyForm).html(routeOpts).val(esCode); | |
| 251 | - | |
| 252 | - //烂班原因 | |
| 253 | - var adjustExpsOpts = '<option value="">请选择...</option>'; | |
| 254 | - $.each(adjustExps, function (i, str) { | |
| 255 | - adjustExpsOpts += '<option value="' + str + '">' + str + '</option>'; | |
| 256 | - }); | |
| 257 | - $('select[name=destroyReason]', destroyForm).html(adjustExpsOpts); | |
| 247 | + //设置默认值 | |
| 248 | + setDefaultVal(); | |
| 258 | 249 | |
| 259 | 250 | //切换营运终点 |
| 260 | 251 | $('select[name=endStation]', serviceForm).val(esCode).on('change', function () { |
| ... | ... | @@ -269,7 +260,7 @@ |
| 269 | 260 | } |
| 270 | 261 | |
| 271 | 262 | reClac(); |
| 272 | - }); | |
| 263 | + }).trigger('change'); | |
| 273 | 264 | |
| 274 | 265 | |
| 275 | 266 | //submit |
| ... | ... | @@ -284,36 +275,87 @@ |
| 284 | 275 | |
| 285 | 276 | });*/ |
| 286 | 277 | }); |
| 278 | + | |
| 279 | + function setDefaultVal() { | |
| 280 | + var routeOpts = ''; | |
| 281 | + $.each(stationRoutes, function () { | |
| 282 | + routeOpts += '<option value="' + this.stationCode + '">' + this.stationName + '</option>'; | |
| 283 | + }); | |
| 284 | + esCode = stationRoutes[stationRoutes.length - 1].stationCode; | |
| 285 | + | |
| 286 | + //营运起终点 | |
| 287 | + $('select[name=startStation],select[name=endStation]', serviceForm).html(routeOpts); | |
| 288 | + //空驶起点 | |
| 289 | + $('select[name=startStation]', emptyForm).html(routeOpts).val(esCode); | |
| 290 | + //烂班起终点 | |
| 291 | + $('select[name=startStation],select[name=endStation]', destroyForm).html(routeOpts).val(esCode); | |
| 292 | + | |
| 293 | + //烂班原因 | |
| 294 | + var adjustExpsOpts = '<option value="">请选择...</option>'; | |
| 295 | + $.each(adjustExps, function (i, str) { | |
| 296 | + adjustExpsOpts += '<option value="' + str + '">' + str + '</option>'; | |
| 297 | + }); | |
| 298 | + $('select[name=destroyReason]', destroyForm).html(adjustExpsOpts); | |
| 299 | + | |
| 300 | + //营运开始时间 | |
| 301 | + $('input[name=startDate]', serviceForm).val(sch.dfsj); | |
| 302 | + } | |
| 287 | 303 | |
| 288 | 304 | function reClac() { |
| 289 | 305 | var serviceEnd = $('select[name=endStation]', serviceForm).val(); |
| 290 | 306 | //空驶起点 == 营运终点 |
| 291 | 307 | $('select[name=startStation]', emptyForm).val(serviceEnd); |
| 292 | 308 | |
| 309 | + //计算营运里程 | |
| 310 | + var s = $('select[name=startStation]', serviceForm).val(), | |
| 311 | + e = $('select[name=endStation]', serviceForm).val(); | |
| 312 | + var sMileage = calcMileage(s, e); | |
| 313 | + if(sMileage >= 0) | |
| 314 | + $('input[name=mileageType]', serviceForm).val(sMileage); | |
| 315 | + | |
| 293 | 316 | if (serviceEnd != esCode) { |
| 294 | 317 | //烂班起点 == 营运终点 |
| 295 | 318 | $('select[name=startStation]', destroyForm).val(serviceEnd); |
| 296 | 319 | } |
| 297 | 320 | } |
| 298 | 321 | |
| 322 | + function calcMileage(s, e) { | |
| 323 | + var mileage = 0, flag, code; | |
| 324 | + if (timeLocStations) { | |
| 325 | + $.each(timeLocStations, function () { | |
| 326 | + code = this.station.STATION_CODE; | |
| 327 | + if (code == s) { | |
| 328 | + flag = true; | |
| 329 | + } | |
| 330 | + | |
| 331 | + if (flag) | |
| 332 | + mileage += this.toDistance; | |
| 333 | + | |
| 334 | + if (code == e) | |
| 335 | + return false; | |
| 336 | + }); | |
| 337 | + } | |
| 338 | + return mileage / 1000; | |
| 339 | + } | |
| 340 | + | |
| 299 | 341 | |
| 300 | 342 | //------ 下抽屉 ------ |
| 301 | 343 | $('#betweenStationRangeCalc', modal).on('click', function () { |
| 302 | 344 | var id = $(this).data('drawer-id'); |
| 303 | - switchBtmDrawer(id, '/real_control_v2/fragments/geo/calc_station_space.html'); | |
| 345 | + switchBtmDrawer(id, '/real_control_v2/fragments/line_schedule/context_menu/sub_task/station_route_spacing_chart.html'); | |
| 304 | 346 | }); |
| 305 | 347 | |
| 306 | 348 | var btmDrawer = $('.ct-bottom-drawer', modal); |
| 307 | 349 | //打开事件 |
| 308 | 350 | btmDrawer.on('drawer_show', function () { |
| 309 | 351 | var url = $(this).data('url'); |
| 310 | - if(!url){ | |
| 352 | + if (!url) { | |
| 311 | 353 | alert('无效的地址'); |
| 312 | 354 | } |
| 313 | 355 | |
| 314 | - var drawerPanel=$(this).data('name'); | |
| 356 | + var drawerPanel = $(this).data('name'); | |
| 315 | 357 | $('.ct-bottom-drawer-body', btmDrawer).load(url, function () { |
| 316 | - $('#'+drawerPanel).trigger('drawer-init', {sch: sch}); | |
| 358 | + $('#' + drawerPanel).trigger('drawer-init', {sch: sch}); | |
| 317 | 359 | }); |
| 318 | 360 | }); |
| 319 | 361 | ... | ... |
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task/station_route_spacing_chart.html
0 → 100644
| 1 | +<!-- 站点路由间距图 --> | |
| 2 | +<div id="station_route_spacing_chart_drawer" style="width: 100%;height: 100%;font-size: 0;"> | |
| 3 | + <div style="width: 80%;height: 100%;display: inline-block;font-size: 14px;"> | |
| 4 | + | |
| 5 | + </div> | |
| 6 | + | |
| 7 | + <div style="width: 20%;height: 100%;display: inline-block;"> | |
| 8 | + | |
| 9 | + </div> | |
| 10 | + | |
| 11 | + <script> | |
| 12 | + | |
| 13 | + (function () { | |
| 14 | + var drawer = '#station_route_spacing_chart_drawer' | |
| 15 | + , sch, locData; | |
| 16 | + | |
| 17 | + $(drawer).on('drawer-init', function (e, data) { | |
| 18 | + //console.log('data', data); | |
| 19 | + sch = data.sch; | |
| 20 | + locData = window.localStorage.getItem('control_route_distance_' + sch.xlBm); | |
| 21 | + | |
| 22 | + if(locData) | |
| 23 | + drawCharts(); | |
| 24 | + else | |
| 25 | + drawerLoadPage('/real_control_v2/fragments/geo/calc_station_space.html','cal_station_space_drawer'); | |
| 26 | + }); | |
| 27 | + | |
| 28 | + function drawCharts() { | |
| 29 | + //console.log('开始绘图', locData); | |
| 30 | + var stations; | |
| 31 | + try { | |
| 32 | + stations = JSON.parse(locData).stations[sch.xlDir == 0 ? 'up' : 'down']; | |
| 33 | + }catch (e){ | |
| 34 | + alert('数据异常!!'); | |
| 35 | + return; | |
| 36 | + } | |
| 37 | + | |
| 38 | + console.log('stations..', stations); | |
| 39 | + } | |
| 40 | + | |
| 41 | + //页面切换 | |
| 42 | + function drawerLoadPage(url, id) { | |
| 43 | + $(drawer).parent('.ct-bottom-drawer-body').load(url, function () { | |
| 44 | + $('#' + id).trigger('drawer-init', {sch: sch}); | |
| 45 | + }); | |
| 46 | + } | |
| 47 | + })(); | |
| 48 | + </script> | |
| 49 | +</div> | |
| 0 | 50 | \ No newline at end of file | ... | ... |