Commit 6cae848f74298c634d9605983451cf21778be3ed
1 parent
94c325d8
1.临加班次中场到场异常修复
Showing
1 changed file
with
344 additions
and
344 deletions
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/temp_sch/main.html
| 1 | -<div class="uk-modal ct-form-modal ct_move_modal" id="schedule-addsch-modal"> | |
| 2 | - <div class="uk-modal-dialog" style="width: 800px;"> | |
| 3 | - <a href="" class="uk-modal-close uk-close"></a> | |
| 4 | - <div class="uk-modal-header"> | |
| 5 | - <h2>新增临加班次</h2></div> | |
| 6 | - | |
| 7 | - <div class="uk-grid"> | |
| 8 | - <div class="uk-width-1-4"> | |
| 9 | - <ul data-uk-switcher="{connect:'#tempScheduleContent'}" class="uk-nav uk-nav-side left_tabs_lg"> | |
| 10 | - <li data-handle="normal"><a>1、临加班次</a></li> | |
| 11 | - <li data-handle="toAndFro"><a>2、往返</a></li> | |
| 12 | - <li data-handle="parkToPark"><a>3、场到场</a></li> | |
| 13 | - </ul> | |
| 14 | - </div> | |
| 15 | - <div class="uk-width-3-4"> | |
| 16 | - <ul id="tempScheduleContent" class="uk-switcher"> | |
| 17 | - <li class="normalCont"></li> | |
| 18 | - <li class="toAndFroCont"></li> | |
| 19 | - <li class="parkToParkCont"></li> | |
| 20 | - </ul> | |
| 21 | - </div> | |
| 22 | - </div> | |
| 23 | - </div> | |
| 24 | - | |
| 25 | - <script> | |
| 26 | - (function () { | |
| 27 | - var modal = '#schedule-addsch-modal', | |
| 28 | - sch, stationRoutes, parks, information, carsArray, st_park_data; | |
| 29 | - | |
| 30 | - $(modal).on('init', function (e, data) { | |
| 31 | - e.stopPropagation(); | |
| 32 | - sch = data.sch; | |
| 33 | - //站到场数据 | |
| 34 | - st_park_data = gb_data_basic.get_stat_park_data()[sch.xlBm]; | |
| 35 | - //站点路由 | |
| 36 | - stationRoutes = gb_common.groupBy(gb_data_basic.stationRoutes(sch.xlBm).sort(function (a, b) { | |
| 37 | - return a.stationRouteCode - b.stationRouteCode; | |
| 38 | - }), 'directions'); | |
| 39 | - //停车场 | |
| 40 | - parks = gb_data_basic.simpleParksArray(); | |
| 41 | - //线路标准 | |
| 42 | - information = gb_data_basic.getLineInformation(sch.xlBm); | |
| 43 | - //停车场排序,常用的放前面 | |
| 44 | - parks = sort_parks(parks, information, st_park_data); | |
| 45 | - //车辆信息 | |
| 46 | - carsArray = gb_data_basic.carsArray(); | |
| 47 | - | |
| 48 | - var st_doms = gb_schedule_context_menu.get_add_sch_doms(); | |
| 49 | - //normal | |
| 50 | - $('.normalCont', modal).html(st_doms.normal_dom) | |
| 51 | - .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form}); | |
| 52 | - | |
| 53 | - //to and fro | |
| 54 | - $('.toAndFroCont', modal).html(st_doms.two_way_dom) | |
| 55 | - .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form, stationRoutes: stationRoutes}); | |
| 56 | - | |
| 57 | - //park to park | |
| 58 | - $('.parkToParkCont', modal).html(st_doms.park_to_park_dom) | |
| 59 | - .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form, parks: parks, carsArray: carsArray}); | |
| 60 | - }); | |
| 61 | - | |
| 62 | - //init-autoCom | |
| 63 | - $(modal).on('init-autoCom', '.add-sch-form', function () { | |
| 64 | - //车辆 | |
| 65 | - if(carsArray) | |
| 66 | - gb_common.carAutocomplete($('.car-autocom', this), carsArray); | |
| 67 | - //驾驶员 | |
| 68 | - gb_common.personAutocomplete($('.jsy-autocom', this)); | |
| 69 | - //售票员 | |
| 70 | - gb_common.personAutocomplete($('.spy-autocom', this)); | |
| 71 | - //备注补全 | |
| 72 | - gb_common.remarksAutocomplete($('.remarks-autocom', this)); | |
| 73 | - }); | |
| 74 | - | |
| 75 | - //班次类型 和 上下行 切换事件 | |
| 76 | - $(modal).on('change', '.add-sch-form [name=bcType],.add-sch-form [name=xlDir]', reCalcInputs_type); | |
| 77 | - //起终点站改变事件 | |
| 78 | - $(modal).on('change', '[name=qdzCode],[name=zdzCode]', reCalcInputs_station); | |
| 79 | - //开始时间和公里改变 | |
| 80 | - $(modal).on('input', '.add-sch-form [name=fcsj],.add-sch-form [name=jhlc]', reCalcEndTime); | |
| 81 | - | |
| 82 | - | |
| 83 | - function reCalcInputs_type() { | |
| 84 | - var f = $(this).parents('.add-sch-form'); | |
| 85 | - var bcType_e = $('[name=bcType]', f) | |
| 86 | - , xlDir_e = $('[name=xlDir]', f); | |
| 87 | - | |
| 88 | - var routes = stationRoutes[xlDir_e.val()] | |
| 89 | - , lastCode = routes[routes.length - 1].stationCode | |
| 90 | - , opts = '', park_opts = ''; | |
| 91 | - //station options | |
| 92 | - $.each(routes, function () { | |
| 93 | - opts += '<option value="' + this.stationCode + '">' + this.stationName + '</option>' | |
| 94 | - }); | |
| 95 | - //park options | |
| 96 | - for(var i=0,p;p=parks[i++];) | |
| 97 | - park_opts += '<option value="' + p.code + '">' + p.name + '</option>'; | |
| 98 | - | |
| 99 | - var qdz = $('[name=qdzCode]', f), zdz = $('[name=zdzCode]', f); | |
| 100 | - //var time, mileage; | |
| 101 | - switch (bcType_e.val()) { | |
| 102 | - case 'out': | |
| 103 | - qdz.html(park_opts).val(information.carPark); | |
| 104 | - zdz.html(opts); | |
| 105 | - break; | |
| 106 | - case 'in': | |
| 107 | - qdz.html(opts); | |
| 108 | - zdz.html(park_opts).val(information.carPark); | |
| 109 | - break; | |
| 110 | - default: | |
| 111 | - qdz.html(opts); | |
| 112 | - zdz.html(opts).val(lastCode); | |
| 113 | - } | |
| 114 | - | |
| 115 | - zdz.trigger('change'); | |
| 116 | - f.trigger('ct_callback'); | |
| 117 | - } | |
| 118 | - | |
| 119 | - function reCalcInputs_station() { | |
| 120 | - var f = $(this).parents('form'), | |
| 121 | - bcType = $('[name=bcType]', f).val(), | |
| 122 | - qdzCode = $('[name=qdzCode]', f).val(), | |
| 123 | - zdzCode =$('[name=zdzCode]', f).val(), | |
| 124 | - startDate = $('[name=fcsj]', f).val(), | |
| 125 | - upDown = $('[name=xlDir]', f).val(), mileage, time; | |
| 126 | - | |
| 127 | - //从站到场里获取数据 | |
| 128 | - var stp = search_st_park(f); | |
| 129 | - if(stp){ | |
| 130 | - mileage=bcType=='in'?stp['mileage1']:stp['mileage2']; | |
| 131 | - time=bcType=='in'?stp['time1']:stp['time2']; | |
| 132 | - } | |
| 133 | - else{ | |
| 134 | - switch (upDown + '_' + bcType) { | |
| 135 | - case '0_out'://上行出场 | |
| 136 | - mileage = information.upOutMileage; | |
| 137 | - time = information.upOutTimer; | |
| 138 | - break; | |
| 139 | - case '1_out'://下行出场 | |
| 140 | - mileage = information.downOutMileage; | |
| 141 | - time = information.downOutTimer; | |
| 142 | - break; | |
| 143 | - case '0_in'://上行进场 | |
| 144 | - mileage = information.upInMileage; | |
| 145 | - time = information.upInTimer; | |
| 146 | - break; | |
| 147 | - case '1_in'://下行进场 | |
| 148 | - mileage = information.downInMileage; | |
| 149 | - time = information.downInTimer; | |
| 150 | - break; | |
| 151 | - default: | |
| 152 | - | |
| 153 | - var qc_time=upDown==0?information.upTravelTime:information.downTravelTime, | |
| 154 | - qc_mileage=upDown==0?information.upMileage:information.downMileage, _type; | |
| 155 | - if(is_normal_sch(f)){ | |
| 156 | - _type='normal'; | |
| 157 | - mileage=qc_mileage; | |
| 158 | - } | |
| 159 | - else{ | |
| 160 | - _type='region'; | |
| 161 | - mileage = calcMileage(stationRoutes[upDown], qdzCode, zdzCode); | |
| 162 | - } | |
| 163 | - | |
| 164 | - time = gb_common.mul(gb_common.accDiv(qc_time, qc_mileage), mileage); | |
| 165 | - if(bcType!='ldks' && bcType!='major' && bcType!='venting') | |
| 166 | - $('[name=bcType]', f).val(_type); | |
| 167 | - } | |
| 168 | - } | |
| 169 | - | |
| 170 | - $('[name=jhlc]', f).val(mileage); | |
| 171 | - var et = moment(startDate, 'HH:mm').add(time, 'minutes'); | |
| 172 | - $f('zdsj', f).val(et.format('HH:mm')); | |
| 173 | - f.trigger('ct_callback'); | |
| 174 | - } | |
| 175 | - | |
| 176 | - | |
| 177 | - function reCalcEndTime() { | |
| 178 | - var f = $(this).parents('.add-sch-form') | |
| 179 | - , startDate = $f('fcsj', f).val()//开始时间 | |
| 180 | - , mileage = $f('jhlc', f).val()//公里 | |
| 181 | - , type2 = $f('bcType', f).val(),//班次类型 | |
| 182 | - upDown = $('[name=xlDir]', f).val(); | |
| 183 | - if (!startDate || !mileage) | |
| 184 | - return; | |
| 185 | - | |
| 186 | - var time; | |
| 187 | - //从站到场里获取数据 | |
| 188 | - var stp = search_st_park(f); | |
| 189 | - if(stp){ | |
| 190 | - time=type2=='in'?stp['time1']:stp['time2']; | |
| 191 | - } | |
| 192 | - else{ | |
| 193 | - if (type2 == 'in') | |
| 194 | - time = upDown == 0 ? information.upInTimer : information.downInTimer; | |
| 195 | - else if (type2 == 'out') | |
| 196 | - time = upDown == 0 ? information.upOutTimer : information.downOutTimer; | |
| 197 | - else{ | |
| 198 | - var qc_time=upDown==0?information.upTravelTime:information.downTravelTime, | |
| 199 | - qc_mileage=upDown==0?information.upMileage:information.downMileage; | |
| 200 | - | |
| 201 | - time = gb_common.mul(gb_common.accDiv(qc_time, qc_mileage), mileage); | |
| 202 | - } | |
| 203 | - } | |
| 204 | - | |
| 205 | - var et = moment(startDate, 'HH:mm').add(time, 'minutes'); | |
| 206 | - $f('zdsj', f).val(et.format('HH:mm')); | |
| 207 | - f.trigger('ct_callback'); | |
| 208 | - } | |
| 209 | - | |
| 210 | - function is_normal_sch(f) { | |
| 211 | - var qdzCode = $('[name=qdzCode]', f).val(), | |
| 212 | - zdzCode =$('[name=zdzCode]', f).val(), | |
| 213 | - upDown = $('[name=xlDir]', f).val(), | |
| 214 | - rts = stationRoutes[upDown]; | |
| 215 | - | |
| 216 | - if(rts[0].stationCode == qdzCode | |
| 217 | - && rts[rts.length - 1].stationCode == zdzCode) | |
| 218 | - return true; | |
| 219 | - else | |
| 220 | - return false; | |
| 221 | - } | |
| 222 | - | |
| 223 | - function isInOut(bcType) { | |
| 224 | - return bcType=='in' || bcType=='out'; | |
| 225 | - } | |
| 226 | - | |
| 227 | - /** | |
| 228 | - * 计算线路上站点间公里 | |
| 229 | - */ | |
| 230 | - function calcMileage(rts, s, e) { | |
| 231 | - var mileage = 0, flag, code; | |
| 232 | - $.each(rts, function () { | |
| 233 | - code = this['stationCode']; | |
| 234 | - if (flag) | |
| 235 | - mileage = gb_common.accAdd(mileage, this.distances); | |
| 236 | - if (code == s) | |
| 237 | - flag = true; | |
| 238 | - if (code == e) | |
| 239 | - return false; | |
| 240 | - }); | |
| 241 | - return mileage; | |
| 242 | - } | |
| 243 | - | |
| 244 | - function search_st_park(f) { | |
| 245 | - if(!st_park_data) | |
| 246 | - return; | |
| 247 | - var stp; | |
| 248 | - var qdSelect=$f('qdzCode', f)[0],zdSelect=$f('zdzCode', f)[0]; | |
| 249 | - | |
| 250 | - if(qdSelect.options.selectedIndex < 0) | |
| 251 | - return; | |
| 252 | - var qdzName=qdSelect.options[qdSelect.options.selectedIndex].text, | |
| 253 | - zdzName=zdSelect.options[zdSelect.options.selectedIndex].text, | |
| 254 | - type2 = $f('bcType', f).val(); | |
| 255 | - | |
| 256 | - if(!isInOut(type2)) | |
| 257 | - return; | |
| 258 | - | |
| 259 | - $.each(st_park_data, function () { | |
| 260 | - if((type2=='in' && this.stationName==qdzName && this.parkName==zdzName) | |
| 261 | - || (type2=='out' && this.stationName==zdzName && this.parkName==qdzName)){ | |
| 262 | - stp = this; | |
| 263 | - return false; | |
| 264 | - } | |
| 265 | - }); | |
| 266 | - | |
| 267 | - return stp; | |
| 268 | - } | |
| 269 | - | |
| 270 | - /** | |
| 271 | - * 停车场排序 | |
| 272 | - * @param parks 停车场 code 2 name | |
| 273 | - * @param information 线路标准 | |
| 274 | - * @param st_park_data 站到场 | |
| 275 | - */ | |
| 276 | - function sort_parks(parks, information, st_park_data) { | |
| 277 | - var array = [], names=[]; | |
| 278 | - for(var code in parks){ | |
| 279 | - array.push({code: code, name: parks[code]}); | |
| 280 | - } | |
| 281 | - | |
| 282 | - if(st_park_data && st_park_data.length > 0){ | |
| 283 | - $.each(st_park_data, function () { | |
| 284 | - names.push(this.parkName); | |
| 285 | - }); | |
| 286 | - } | |
| 287 | - | |
| 288 | - //debugger | |
| 289 | - array.sort(function (a, b) { | |
| 290 | - if(a.code==information.carPark) | |
| 291 | - return -1; | |
| 292 | - if(b.code==information.carPark) | |
| 293 | - return 1; | |
| 294 | - | |
| 295 | - var ai = names.indexOf(a.name), | |
| 296 | - bi = names.indexOf(b.name); | |
| 297 | - | |
| 298 | - if(ai!=-1 && bi==-1) | |
| 299 | - return -1; | |
| 300 | - else if(ai==-1 && bi!=-1) | |
| 301 | - return 1; | |
| 302 | - else | |
| 303 | - return $.trim(a.name).localeCompare($.trim(b.name), 'zh-CN'); | |
| 304 | - }); | |
| 305 | - return array; | |
| 306 | - } | |
| 307 | - | |
| 308 | - function $f(name, f) { | |
| 309 | - return $('[name=' + name + ']', f); | |
| 310 | - } | |
| 311 | - | |
| 312 | - /** | |
| 313 | - * 提交表单 | |
| 314 | - */ | |
| 315 | - function submit_temp_schedule_form(data, cb, err) { | |
| 316 | - data.xlBm = sch.xlBm; | |
| 317 | - data.xlName = sch.xlName; | |
| 318 | - data.lpName = sch.lpName; | |
| 319 | - //拆分驾驶员工号和姓名 | |
| 320 | - data.jGh = data.jsy.split('/')[0]; | |
| 321 | - data.jName = data.jsy.split('/')[1]; | |
| 322 | - delete data.jsy; | |
| 323 | - //拆分售票员工号和姓名 | |
| 324 | - if (data.spy != '') { | |
| 325 | - data.sGh = data.spy.split('/')[0]; | |
| 326 | - data.sName = data.spy.split('/')[1]; | |
| 327 | - delete data.spy; | |
| 328 | - } | |
| 329 | - | |
| 330 | - //公司信息 | |
| 331 | - var line = gb_data_basic.findLineByCodes([data.xlBm]); | |
| 332 | - if(line && line.length > 0){ | |
| 333 | - line = line[0]; | |
| 334 | - data.gsBm = line.company; | |
| 335 | - data.fgsBm = line.brancheCompany; | |
| 336 | - } | |
| 337 | - | |
| 338 | - gb_common.$post('/realSchedule', data, function (rs) { | |
| 339 | - notify_succ('新增临加班次成功'); | |
| 340 | - cb && cb(rs); | |
| 341 | - }, err); | |
| 342 | - } | |
| 343 | - })(); | |
| 344 | - </script> | |
| 1 | +<div class="uk-modal ct-form-modal ct_move_modal" id="schedule-addsch-modal"> | |
| 2 | + <div class="uk-modal-dialog" style="width: 800px;"> | |
| 3 | + <a href="" class="uk-modal-close uk-close"></a> | |
| 4 | + <div class="uk-modal-header"> | |
| 5 | + <h2>新增临加班次</h2></div> | |
| 6 | + | |
| 7 | + <div class="uk-grid"> | |
| 8 | + <div class="uk-width-1-4"> | |
| 9 | + <ul data-uk-switcher="{connect:'#tempScheduleContent'}" class="uk-nav uk-nav-side left_tabs_lg"> | |
| 10 | + <li data-handle="normal"><a>1、临加班次</a></li> | |
| 11 | + <li data-handle="toAndFro"><a>2、往返</a></li> | |
| 12 | + <li data-handle="parkToPark"><a>3、场到场</a></li> | |
| 13 | + </ul> | |
| 14 | + </div> | |
| 15 | + <div class="uk-width-3-4"> | |
| 16 | + <ul id="tempScheduleContent" class="uk-switcher"> | |
| 17 | + <li class="normalCont"></li> | |
| 18 | + <li class="toAndFroCont"></li> | |
| 19 | + <li class="parkToParkCont"></li> | |
| 20 | + </ul> | |
| 21 | + </div> | |
| 22 | + </div> | |
| 23 | + </div> | |
| 24 | + | |
| 25 | + <script> | |
| 26 | + (function () { | |
| 27 | + var modal = '#schedule-addsch-modal', | |
| 28 | + sch, stationRoutes, parks, information, carsArray, st_park_data; | |
| 29 | + | |
| 30 | + $(modal).on('init', function (e, data) { | |
| 31 | + e.stopPropagation(); | |
| 32 | + sch = data.sch; | |
| 33 | + //站到场数据 | |
| 34 | + st_park_data = gb_data_basic.get_stat_park_data()[sch.xlBm]; | |
| 35 | + //站点路由 | |
| 36 | + stationRoutes = gb_common.groupBy(gb_data_basic.stationRoutes(sch.xlBm).sort(function (a, b) { | |
| 37 | + return a.stationRouteCode - b.stationRouteCode; | |
| 38 | + }), 'directions'); | |
| 39 | + //停车场 | |
| 40 | + parks = gb_data_basic.simpleParksArray(); | |
| 41 | + //线路标准 | |
| 42 | + information = gb_data_basic.getLineInformation(sch.xlBm); | |
| 43 | + //停车场排序,常用的放前面 | |
| 44 | + parks = sort_parks(parks, information, st_park_data); | |
| 45 | + //车辆信息 | |
| 46 | + carsArray = gb_data_basic.carsArray(); | |
| 47 | + | |
| 48 | + var st_doms = gb_schedule_context_menu.get_add_sch_doms(); | |
| 49 | + //normal | |
| 50 | + $('.normalCont', modal).html(st_doms.normal_dom) | |
| 51 | + .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form}); | |
| 52 | + | |
| 53 | + //to and fro | |
| 54 | + $('.toAndFroCont', modal).html(st_doms.two_way_dom) | |
| 55 | + .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form, stationRoutes: stationRoutes}); | |
| 56 | + | |
| 57 | + //park to park | |
| 58 | + $('.parkToParkCont', modal).html(st_doms.park_to_park_dom) | |
| 59 | + .trigger('init', {sch: sch, submitFun: submit_temp_schedule_form, parks: parks, carsArray: carsArray}); | |
| 60 | + }); | |
| 61 | + | |
| 62 | + //init-autoCom | |
| 63 | + $(modal).on('init-autoCom', '.add-sch-form', function () { | |
| 64 | + //车辆 | |
| 65 | + if(carsArray) | |
| 66 | + gb_common.carAutocomplete($('.car-autocom', this), carsArray); | |
| 67 | + //驾驶员 | |
| 68 | + gb_common.personAutocomplete($('.jsy-autocom', this)); | |
| 69 | + //售票员 | |
| 70 | + gb_common.personAutocomplete($('.spy-autocom', this)); | |
| 71 | + //备注补全 | |
| 72 | + gb_common.remarksAutocomplete($('.remarks-autocom', this)); | |
| 73 | + }); | |
| 74 | + | |
| 75 | + //班次类型 和 上下行 切换事件 | |
| 76 | + $(modal).on('change', '.add-sch-form [name=bcType],.add-sch-form [name=xlDir]', reCalcInputs_type); | |
| 77 | + //起终点站改变事件 | |
| 78 | + $(modal).on('change', '[name=qdzCode],[name=zdzCode]', reCalcInputs_station); | |
| 79 | + //开始时间和公里改变 | |
| 80 | + $(modal).on('input', '.add-sch-form [name=fcsj],.add-sch-form [name=jhlc]', reCalcEndTime); | |
| 81 | + | |
| 82 | + | |
| 83 | + function reCalcInputs_type() { | |
| 84 | + var f = $(this).parents('.add-sch-form'); | |
| 85 | + var bcType_e = $('[name=bcType]', f) | |
| 86 | + , xlDir_e = $('[name=xlDir]', f); | |
| 87 | + | |
| 88 | + var routes = stationRoutes[xlDir_e.val()] | |
| 89 | + , lastCode = routes[routes.length - 1].stationCode | |
| 90 | + , opts = '', park_opts = ''; | |
| 91 | + //station options | |
| 92 | + $.each(routes, function () { | |
| 93 | + opts += '<option value="' + this.stationCode + '">' + this.stationName + '</option>' | |
| 94 | + }); | |
| 95 | + //park options | |
| 96 | + for(var i=0,p;p=parks[i++];) | |
| 97 | + park_opts += '<option value="' + p.code + '">' + p.name + '</option>'; | |
| 98 | + | |
| 99 | + var qdz = $('[name=qdzCode]', f), zdz = $('[name=zdzCode]', f); | |
| 100 | + //var time, mileage; | |
| 101 | + switch (bcType_e.val()) { | |
| 102 | + case 'out': | |
| 103 | + qdz.html(park_opts).val(information.carPark); | |
| 104 | + zdz.html(opts); | |
| 105 | + break; | |
| 106 | + case 'in': | |
| 107 | + qdz.html(opts); | |
| 108 | + zdz.html(park_opts).val(information.carPark); | |
| 109 | + break; | |
| 110 | + default: | |
| 111 | + qdz.html(opts); | |
| 112 | + zdz.html(opts).val(lastCode); | |
| 113 | + } | |
| 114 | + | |
| 115 | + zdz.trigger('change'); | |
| 116 | + f.trigger('ct_callback'); | |
| 117 | + } | |
| 118 | + | |
| 119 | + function reCalcInputs_station() { | |
| 120 | + var f = $(this).parents('form'), | |
| 121 | + bcType = $('[name=bcType]', f).val(), | |
| 122 | + qdzCode = $('[name=qdzCode]', f).val(), | |
| 123 | + zdzCode =$('[name=zdzCode]', f).val(), | |
| 124 | + startDate = $('[name=fcsj]', f).val(), | |
| 125 | + upDown = $('[name=xlDir]', f).val(), mileage, time; | |
| 126 | + | |
| 127 | + //从站到场里获取数据 | |
| 128 | + var stp = search_st_park(f); | |
| 129 | + if(stp){ | |
| 130 | + mileage=bcType=='in'?stp['mileage1']:stp['mileage2']; | |
| 131 | + time=bcType=='in'?stp['time1']:stp['time2']; | |
| 132 | + } | |
| 133 | + else{ | |
| 134 | + switch (upDown + '_' + bcType) { | |
| 135 | + case '0_out'://上行出场 | |
| 136 | + mileage = information.upOutMileage; | |
| 137 | + time = information.upOutTimer; | |
| 138 | + break; | |
| 139 | + case '1_out'://下行出场 | |
| 140 | + mileage = information.downOutMileage; | |
| 141 | + time = information.downOutTimer; | |
| 142 | + break; | |
| 143 | + case '0_in'://上行进场 | |
| 144 | + mileage = information.upInMileage; | |
| 145 | + time = information.upInTimer; | |
| 146 | + break; | |
| 147 | + case '1_in'://下行进场 | |
| 148 | + mileage = information.downInMileage; | |
| 149 | + time = information.downInTimer; | |
| 150 | + break; | |
| 151 | + default: | |
| 152 | + | |
| 153 | + var qc_time=upDown==0?information.upTravelTime:information.downTravelTime, | |
| 154 | + qc_mileage=upDown==0?information.upMileage:information.downMileage, _type; | |
| 155 | + if(is_normal_sch(f)){ | |
| 156 | + _type='normal'; | |
| 157 | + mileage=qc_mileage; | |
| 158 | + } | |
| 159 | + else{ | |
| 160 | + _type='region'; | |
| 161 | + mileage = calcMileage(stationRoutes[upDown], qdzCode, zdzCode); | |
| 162 | + } | |
| 163 | + | |
| 164 | + time = gb_common.mul(gb_common.accDiv(qc_time, qc_mileage), mileage); | |
| 165 | + if(bcType!='ldks' && bcType!='major' && bcType!='venting') | |
| 166 | + $('[name=bcType]', f).val(_type); | |
| 167 | + } | |
| 168 | + } | |
| 169 | + | |
| 170 | + $('[name=jhlc]', f).val(mileage); | |
| 171 | + var et = moment(startDate, 'HH:mm').add(time, 'minutes'); | |
| 172 | + $f('zdsj', f).val(et.format('HH:mm')); | |
| 173 | + f.trigger('ct_callback'); | |
| 174 | + } | |
| 175 | + | |
| 176 | + | |
| 177 | + function reCalcEndTime() { | |
| 178 | + var f = $(this).parents('.add-sch-form') | |
| 179 | + , startDate = $f('fcsj', f).val()//开始时间 | |
| 180 | + , mileage = $f('jhlc', f).val()//公里 | |
| 181 | + , type2 = $f('bcType', f).val(),//班次类型 | |
| 182 | + upDown = $('[name=xlDir]', f).val(); | |
| 183 | + if (!startDate || !mileage) | |
| 184 | + return; | |
| 185 | + | |
| 186 | + var time; | |
| 187 | + //从站到场里获取数据 | |
| 188 | + var stp = search_st_park(f); | |
| 189 | + if(stp){ | |
| 190 | + time=type2=='in'?stp['time1']:stp['time2']; | |
| 191 | + } | |
| 192 | + else{ | |
| 193 | + if (type2 == 'in') | |
| 194 | + time = upDown == 0 ? information.upInTimer : information.downInTimer; | |
| 195 | + else if (type2 == 'out') | |
| 196 | + time = upDown == 0 ? information.upOutTimer : information.downOutTimer; | |
| 197 | + else{ | |
| 198 | + var qc_time=upDown==0?information.upTravelTime:information.downTravelTime, | |
| 199 | + qc_mileage=upDown==0?information.upMileage:information.downMileage; | |
| 200 | + | |
| 201 | + time = gb_common.mul(gb_common.accDiv(qc_time, qc_mileage), mileage); | |
| 202 | + } | |
| 203 | + } | |
| 204 | + | |
| 205 | + var et = moment(startDate, 'HH:mm').add(time, 'minutes'); | |
| 206 | + $f('zdsj', f).val(et.format('HH:mm')); | |
| 207 | + f.trigger('ct_callback'); | |
| 208 | + } | |
| 209 | + | |
| 210 | + function is_normal_sch(f) { | |
| 211 | + var qdzCode = $('[name=qdzCode]', f).val(), | |
| 212 | + zdzCode =$('[name=zdzCode]', f).val(), | |
| 213 | + upDown = $('[name=xlDir]', f).val(), | |
| 214 | + rts = stationRoutes[upDown]; | |
| 215 | + | |
| 216 | + if(rts[0].stationCode == qdzCode | |
| 217 | + && rts[rts.length - 1].stationCode == zdzCode) | |
| 218 | + return true; | |
| 219 | + else | |
| 220 | + return false; | |
| 221 | + } | |
| 222 | + | |
| 223 | + function isInOut(bcType) { | |
| 224 | + return bcType=='in' || bcType=='out'; | |
| 225 | + } | |
| 226 | + | |
| 227 | + /** | |
| 228 | + * 计算线路上站点间公里 | |
| 229 | + */ | |
| 230 | + function calcMileage(rts, s, e) { | |
| 231 | + var mileage = 0, flag, code; | |
| 232 | + $.each(rts, function () { | |
| 233 | + code = this['stationCode']; | |
| 234 | + if (flag) | |
| 235 | + mileage = gb_common.accAdd(mileage, this.distances); | |
| 236 | + if (code == s) | |
| 237 | + flag = true; | |
| 238 | + if (code == e) | |
| 239 | + return false; | |
| 240 | + }); | |
| 241 | + return mileage; | |
| 242 | + } | |
| 243 | + | |
| 244 | + function search_st_park(f) { | |
| 245 | + if(!st_park_data) | |
| 246 | + return; | |
| 247 | + var stp; | |
| 248 | + var qdSelect=$f('qdzCode', f)[0],zdSelect=$f('zdzCode', f)[0]; | |
| 249 | + | |
| 250 | + if(qdSelect.options.selectedIndex < 0 || zdSelect.options.selectedIndex < 0) | |
| 251 | + return; | |
| 252 | + var qdzName=qdSelect.options[qdSelect.options.selectedIndex].text, | |
| 253 | + zdzName=zdSelect.options[zdSelect.options.selectedIndex].text, | |
| 254 | + type2 = $f('bcType', f).val(); | |
| 255 | + | |
| 256 | + if(!isInOut(type2)) | |
| 257 | + return; | |
| 258 | + | |
| 259 | + $.each(st_park_data, function () { | |
| 260 | + if((type2=='in' && this.stationName==qdzName && this.parkName==zdzName) | |
| 261 | + || (type2=='out' && this.stationName==zdzName && this.parkName==qdzName)){ | |
| 262 | + stp = this; | |
| 263 | + return false; | |
| 264 | + } | |
| 265 | + }); | |
| 266 | + | |
| 267 | + return stp; | |
| 268 | + } | |
| 269 | + | |
| 270 | + /** | |
| 271 | + * 停车场排序 | |
| 272 | + * @param parks 停车场 code 2 name | |
| 273 | + * @param information 线路标准 | |
| 274 | + * @param st_park_data 站到场 | |
| 275 | + */ | |
| 276 | + function sort_parks(parks, information, st_park_data) { | |
| 277 | + var array = [], names=[]; | |
| 278 | + for(var code in parks){ | |
| 279 | + array.push({code: code, name: parks[code]}); | |
| 280 | + } | |
| 281 | + | |
| 282 | + if(st_park_data && st_park_data.length > 0){ | |
| 283 | + $.each(st_park_data, function () { | |
| 284 | + names.push(this.parkName); | |
| 285 | + }); | |
| 286 | + } | |
| 287 | + | |
| 288 | + //debugger | |
| 289 | + array.sort(function (a, b) { | |
| 290 | + if(a.code==information.carPark) | |
| 291 | + return -1; | |
| 292 | + if(b.code==information.carPark) | |
| 293 | + return 1; | |
| 294 | + | |
| 295 | + var ai = names.indexOf(a.name), | |
| 296 | + bi = names.indexOf(b.name); | |
| 297 | + | |
| 298 | + if(ai!=-1 && bi==-1) | |
| 299 | + return -1; | |
| 300 | + else if(ai==-1 && bi!=-1) | |
| 301 | + return 1; | |
| 302 | + else | |
| 303 | + return $.trim(a.name).localeCompare($.trim(b.name), 'zh-CN'); | |
| 304 | + }); | |
| 305 | + return array; | |
| 306 | + } | |
| 307 | + | |
| 308 | + function $f(name, f) { | |
| 309 | + return $('[name=' + name + ']', f); | |
| 310 | + } | |
| 311 | + | |
| 312 | + /** | |
| 313 | + * 提交表单 | |
| 314 | + */ | |
| 315 | + function submit_temp_schedule_form(data, cb, err) { | |
| 316 | + data.xlBm = sch.xlBm; | |
| 317 | + data.xlName = sch.xlName; | |
| 318 | + data.lpName = sch.lpName; | |
| 319 | + //拆分驾驶员工号和姓名 | |
| 320 | + data.jGh = data.jsy.split('/')[0]; | |
| 321 | + data.jName = data.jsy.split('/')[1]; | |
| 322 | + delete data.jsy; | |
| 323 | + //拆分售票员工号和姓名 | |
| 324 | + if (data.spy != '') { | |
| 325 | + data.sGh = data.spy.split('/')[0]; | |
| 326 | + data.sName = data.spy.split('/')[1]; | |
| 327 | + delete data.spy; | |
| 328 | + } | |
| 329 | + | |
| 330 | + //公司信息 | |
| 331 | + var line = gb_data_basic.findLineByCodes([data.xlBm]); | |
| 332 | + if(line && line.length > 0){ | |
| 333 | + line = line[0]; | |
| 334 | + data.gsBm = line.company; | |
| 335 | + data.fgsBm = line.brancheCompany; | |
| 336 | + } | |
| 337 | + | |
| 338 | + gb_common.$post('/realSchedule', data, function (rs) { | |
| 339 | + notify_succ('新增临加班次成功'); | |
| 340 | + cb && cb(rs); | |
| 341 | + }, err); | |
| 342 | + } | |
| 343 | + })(); | |
| 344 | + </script> | |
| 345 | 345 | </div> |
| 346 | 346 | \ No newline at end of file | ... | ... |