Commit a7a4a2c31cac83c095a17dac9d3ca37768a232e2
1 parent
01f7c075
私改saSelect5指令小bug,创建error对象名使用Error
Showing
2 changed files
with
327 additions
and
327 deletions
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/saSelect5.js
| ... | ... | @@ -357,7 +357,7 @@ angular.module('ScheduleApp').directive('saSelect5', [ |
| 357 | 357 | */ |
| 358 | 358 | scope[ctrlAs].$$internal_dic_data = function(dictype) { |
| 359 | 359 | if (!dictionaryUtils.getByGroup(dictype)) { |
| 360 | - throw new error("字典数据不窜在=" + dictype); | |
| 360 | + throw new Error("字典数据不窜在=" + dictype); | |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | // 重新创建内部保存的数据 | ... | ... |
src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
| ... | ... | @@ -1777,7 +1777,7 @@ angular.module('ScheduleApp').directive('saSelect5', [ |
| 1777 | 1777 | */ |
| 1778 | 1778 | scope[ctrlAs].$$internal_dic_data = function(dictype) { |
| 1779 | 1779 | if (!dictionaryUtils.getByGroup(dictype)) { |
| 1780 | - throw new error("字典数据不窜在=" + dictype); | |
| 1780 | + throw new Error("字典数据不窜在=" + dictype); | |
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | 1783 | // 重新创建内部保存的数据 |
| ... | ... | @@ -4407,331 +4407,331 @@ angular.module('ScheduleApp').directive( |
| 4407 | 4407 | ] |
| 4408 | 4408 | ); |
| 4409 | 4409 | |
| 4410 | -/** | |
| 4411 | - * saTimetablePreview指令,时刻表预览模式视图。 | |
| 4412 | - */ | |
| 4413 | -angular.module("ScheduleApp").directive( | |
| 4414 | - "saTimetable2", | |
| 4415 | - [ | |
| 4416 | - '$timeout', | |
| 4417 | - function($timeout) { | |
| 4418 | - return { | |
| 4419 | - restrict : 'E', | |
| 4420 | - templateUrl : '/pages/scheduleApp/module/common/dts2/ttinfotable/saTimeTablePreViewTemplate.html', | |
| 4421 | - scope : { // 独立作用域 | |
| 4422 | - // 使用外部数据源,内部重新组合显示 | |
| 4423 | - ds : "=ngModel" | |
| 4424 | - }, | |
| 4425 | - controllerAs : "$saTimeTablePreviewCtrl", | |
| 4426 | - bindToController: true, | |
| 4427 | - controller : function() { | |
| 4428 | - var self = this; | |
| 4429 | - | |
| 4430 | - // 内部班次时刻模型 | |
| 4431 | - self.internalBcModel = { | |
| 4432 | - up_qdz_name : "", // 上行起点站名字 | |
| 4433 | - down_qdz_name : "", // 下行起点站名字 | |
| 4434 | - up_bc_list_asc : [], // 上行班次列表(按照发车时间升序) | |
| 4435 | - down_bc_list_asc : [] // 下行班次列表(按照发车时间升序) | |
| 4436 | - }; | |
| 4437 | - | |
| 4438 | - // 内部各个路牌block车次链模型 | |
| 4439 | - self.internalLpBlockModel = { | |
| 4440 | - // key:路牌名字 | |
| 4441 | - // value: 数组(按照发车时间排序) | |
| 4442 | - // value 数据内对象 {fcsj:发车时间,isUp:是否上行,fcno:发车顺序号,index:对应的班次列表索引} | |
| 4443 | - }; | |
| 4444 | - | |
| 4445 | - // TODO: | |
| 4446 | - }, | |
| 4447 | - | |
| 4448 | - /**, | |
| 4449 | - * compile阶段,angular还没有编译模版,根据需要可以修改模版dom | |
| 4450 | - * @param tElem | |
| 4451 | - * @param tAttrs | |
| 4452 | - * @returns {{pre: Function, post: Function}} | |
| 4453 | - */ | |
| 4454 | - compile : function(tElem, tAttrs) { | |
| 4455 | - // 获取属性 | |
| 4456 | - var $attr_name = tAttrs["name"]; // 控件的名字 | |
| 4457 | - if (!$attr_name) { | |
| 4458 | - throw new Error("saTimeTablePreview指令 name属性required"); | |
| 4459 | - } | |
| 4460 | - | |
| 4461 | - // 内部controlAs名字 | |
| 4462 | - var ctrlAs = "$saTimeTablePreviewCtrl"; | |
| 4463 | - | |
| 4464 | - // TODO: | |
| 4465 | - | |
| 4466 | - //------------------ 内部方法 --------------------// | |
| 4467 | - var date_wrap_prefix = "2000-01-01 "; // 包装日期的前缀 | |
| 4468 | - var date_wrap_format = "YYYY-MM-DD HH:mm"; // 日期格式 | |
| 4469 | - /** | |
| 4470 | - * 将时间包装成日期,方便计算。 | |
| 4471 | - * @param timeStr 时间格式,如 06:30 | |
| 4472 | - * @returns moment对象 | |
| 4473 | - */ | |
| 4474 | - var _fun_WrapTime = function(timeStr) { | |
| 4475 | - return moment( | |
| 4476 | - date_wrap_prefix + timeStr, | |
| 4477 | - date_wrap_format | |
| 4478 | - ); | |
| 4479 | - }; | |
| 4480 | - | |
| 4481 | - /** | |
| 4482 | - * 点击班次html元素(dl),触发班次移动,如下: | |
| 4483 | - * 1、点击上行班次,下一个下行班次在下行班次列表中移到中间位置 | |
| 4484 | - * 2、点击下行班次,下一个上行班次在上行班次列表中移到中间位置 | |
| 4485 | - * @param ctrl 内部控制器 | |
| 4486 | - * @param index 班次索引 | |
| 4487 | - * @param isUp 是否上行 | |
| 4488 | - * @private | |
| 4489 | - */ | |
| 4490 | - var _fun_bcDDViewMove = function(ctrl, index, isUp) { | |
| 4491 | - // 获取当前点击班次对象 | |
| 4492 | - var oBc; | |
| 4493 | - if (isUp) { | |
| 4494 | - oBc = ctrl.internalBcModel.up_bc_list_asc[index]; | |
| 4495 | - } else { | |
| 4496 | - oBc = ctrl.internalBcModel.down_bc_list_asc[index]; | |
| 4497 | - } | |
| 4498 | - | |
| 4499 | - // 找出车次链中的下一个班次索引,没有就undefined | |
| 4500 | - var nextIndex = undefined; | |
| 4501 | - var nextBlockBc = undefined; | |
| 4502 | - var currentBlockBcIndex = undefined; | |
| 4503 | - angular.forEach(ctrl.internalLpBlockModel[oBc.lpName], function(data, i) { | |
| 4504 | - if (data.fcsj == oBc.fcsj) { | |
| 4505 | - currentBlockBcIndex = i; | |
| 4506 | - } | |
| 4507 | - }); | |
| 4508 | - if (currentBlockBcIndex != undefined && | |
| 4509 | - currentBlockBcIndex < (ctrl.internalLpBlockModel[oBc.lpName].length - 1)) { | |
| 4510 | - nextBlockBc = ctrl.internalLpBlockModel[oBc.lpName][currentBlockBcIndex + 1]; | |
| 4511 | - nextIndex = nextBlockBc.index; | |
| 4512 | - } | |
| 4513 | - // 先删除click标记,再添加 | |
| 4514 | - angular.forEach(ctrl.internalBcModel.up_bc_list_asc, function(data) { | |
| 4515 | - delete data["isClick"]; | |
| 4516 | - }); | |
| 4517 | - angular.forEach(ctrl.internalBcModel.down_bc_list_asc, function(data) { | |
| 4518 | - delete data["isClick"]; | |
| 4519 | - }); | |
| 4520 | - oBc.isClick = true; | |
| 4521 | - if (nextIndex) { | |
| 4522 | - if (nextBlockBc.isUp) { | |
| 4523 | - ctrl.internalBcModel.up_bc_list_asc[nextIndex].isClick = true; | |
| 4524 | - } else { | |
| 4525 | - ctrl.internalBcModel.down_bc_list_asc[nextIndex].isClick = true; | |
| 4526 | - } | |
| 4527 | - } | |
| 4528 | - | |
| 4529 | - // 移动,同方向不移动 | |
| 4530 | - var clientHeight = angular.element("#temp").height() - 34; | |
| 4531 | - if (nextBlockBc && isUp != nextBlockBc.isUp) { | |
| 4532 | - if (isUp) { // 移动下行 | |
| 4533 | - angular.element(".ttpv_table_scrollbar:eq(1)").animate( | |
| 4534 | - {scrollTop : nextIndex * 30 - clientHeight / 2}, 400); | |
| 4535 | - } else { // 移动上行 | |
| 4536 | - angular.element(".ttpv_table_scrollbar:eq(0)").animate( | |
| 4537 | - {scrollTop : nextIndex * 30 - clientHeight / 2}, 400); | |
| 4538 | - } | |
| 4539 | - } | |
| 4540 | - | |
| 4541 | - }; | |
| 4542 | - | |
| 4543 | - /** | |
| 4544 | - * 刷新内部数据。 | |
| 4545 | - * @param ctrl 内部控制器对象($saTimeTablePreviewCtrl) | |
| 4546 | - * @private | |
| 4547 | - */ | |
| 4548 | - var _fun_refreshInternalModel = function(ctrl) { | |
| 4549 | - // 初始化内部数据 | |
| 4550 | - ctrl.internalBcModel = { | |
| 4551 | - up_qdz_name : "", // 上行起点站名字 | |
| 4552 | - up_zdz_name : "", // 上行终点站名字 | |
| 4553 | - down_qdz_name : "", // 下行起点站名字 | |
| 4554 | - down_zdz_name : "", // 下行终点站名字 | |
| 4555 | - up_bc_list_asc : [], // 上行班次列表(按照发车时间升序) | |
| 4556 | - down_bc_list_asc : [] // 下行班次列表(按照发车时间升序) | |
| 4557 | - }; | |
| 4558 | - ctrl.internalLpBlockModel = { | |
| 4559 | - | |
| 4560 | - }; | |
| 4561 | - | |
| 4562 | - // ngModel传入的数据 | |
| 4563 | - var dataSource = ctrl.ds.bcList; | |
| 4564 | - | |
| 4565 | - // 构造上下行班次列表,并确定上下行的首发站点 | |
| 4566 | - angular.forEach(dataSource, function(bcObj) { | |
| 4567 | - var _internalBcObj = {}; | |
| 4568 | - // 构造内部班次对象 | |
| 4569 | - _internalBcObj.lpName = bcObj.lp.lpName; // 路牌 | |
| 4570 | - _internalBcObj.fcsj = bcObj.fcsj; // 发车时间 | |
| 4571 | - _internalBcObj.ddsj = _fun_WrapTime(bcObj.fcsj).add(bcObj.bcsj, "m").format("HH:mm"); | |
| 4572 | - _internalBcObj.qdzName = bcObj.qdzName; // 起点站名字 | |
| 4573 | - _internalBcObj.zdzName = bcObj.zdzName; // 终点站名字 | |
| 4574 | - _internalBcObj.bcType = bcObj.bcType; // 班次类型 | |
| 4575 | - _internalBcObj.isTs = bcObj.isTS; // 是否停驶 | |
| 4576 | - _internalBcObj.isFb = bcObj.isFB; // 是否分班 | |
| 4577 | - _internalBcObj.remark = bcObj.remark; // 备注 | |
| 4578 | - _internalBcObj._fcno = bcObj.fcno; // 发车顺序号 | |
| 4579 | - | |
| 4580 | - if (bcObj.xlDir == "0") { // 上行 | |
| 4581 | - ctrl.internalBcModel.up_bc_list_asc.push(_internalBcObj); | |
| 4582 | - // 确定起点站 | |
| 4583 | - if (ctrl.internalBcModel.up_qdz_name == "") { | |
| 4584 | - if (bcObj.bcType == "normal") { | |
| 4585 | - ctrl.internalBcModel.up_qdz_name = bcObj.qdzName; | |
| 4586 | - } | |
| 4587 | - } | |
| 4588 | - // 确定终点站 | |
| 4589 | - if (ctrl.internalBcModel.up_zdz_name == "") { | |
| 4590 | - if (bcObj.bcType == "normal") { | |
| 4591 | - ctrl.internalBcModel.up_zdz_name = bcObj.zdzName; | |
| 4592 | - } | |
| 4593 | - } | |
| 4594 | - } | |
| 4595 | - if (bcObj.xlDir == "1") { // 下行 | |
| 4596 | - ctrl.internalBcModel.down_bc_list_asc.push(_internalBcObj); | |
| 4597 | - // 确定起点站 | |
| 4598 | - if (ctrl.internalBcModel.down_qdz_name == "") { | |
| 4599 | - if (bcObj.bcType == "normal") { | |
| 4600 | - ctrl.internalBcModel.down_qdz_name = bcObj.qdzName; | |
| 4601 | - } | |
| 4602 | - } | |
| 4603 | - // 确定终点站 | |
| 4604 | - if (ctrl.internalBcModel.down_zdz_name == "") { | |
| 4605 | - if (bcObj.bcType == "normal") { | |
| 4606 | - ctrl.internalBcModel.down_zdz_name = bcObj.zdzName; | |
| 4607 | - } | |
| 4608 | - } | |
| 4609 | - } | |
| 4610 | - | |
| 4611 | - }); | |
| 4612 | - | |
| 4613 | - // 发车时间升序排序上行班次 | |
| 4614 | - ctrl.internalBcModel.up_bc_list_asc.sort(function(a, b) { | |
| 4615 | - var a_wrapTime = _fun_WrapTime(a.fcsj); | |
| 4616 | - var b_wrapTime = _fun_WrapTime(b.fcsj); | |
| 4617 | - | |
| 4618 | - // 判定如果发车时间是以00,01,02,03开头的,说明是下一天凌晨的班次,需要加1天判定 | |
| 4619 | - // TODO:以后要配合首班车的发车时间判定 | |
| 4620 | - if (a.fcsj.indexOf("00:") == 0 || | |
| 4621 | - a.fcsj.indexOf("01:") == 0 || | |
| 4622 | - a.fcsj.indexOf("02:") == 0) { | |
| 4623 | - a_wrapTime.add(1, "day"); | |
| 4624 | - } | |
| 4625 | - if (b.fcsj.indexOf("00:") == 0 || | |
| 4626 | - b.fcsj.indexOf("01:") == 0 || | |
| 4627 | - b.fcsj.indexOf("02:") == 0) { | |
| 4628 | - b_wrapTime.add(1, "day"); | |
| 4629 | - } | |
| 4630 | - | |
| 4631 | - if (a_wrapTime.isBefore(b_wrapTime)) { | |
| 4632 | - return -1; | |
| 4633 | - } else if (a_wrapTime.isAfter(b_wrapTime)) { | |
| 4634 | - return 1; | |
| 4635 | - } else { | |
| 4636 | - return 0; | |
| 4637 | - } | |
| 4638 | - | |
| 4639 | - }); | |
| 4640 | - // 发车时间升序排序下行班次 | |
| 4641 | - ctrl.internalBcModel.down_bc_list_asc.sort(function(a, b) { | |
| 4642 | - var a_wrapTime = _fun_WrapTime(a.fcsj); | |
| 4643 | - var b_wrapTime = _fun_WrapTime(b.fcsj); | |
| 4644 | - | |
| 4645 | - // 判定如果发车时间是以00,01,02,03开头的,说明是下一天凌晨的班次,需要加1天判定 | |
| 4646 | - // TODO:以后要配合首班车的发车时间判定 | |
| 4647 | - if (a.fcsj.indexOf("00:") == 0 || | |
| 4648 | - a.fcsj.indexOf("01:") == 0 || | |
| 4649 | - a.fcsj.indexOf("02:") == 0) { | |
| 4650 | - a_wrapTime.add(1, "day"); | |
| 4651 | - } | |
| 4652 | - if (b.fcsj.indexOf("00:") == 0 || | |
| 4653 | - b.fcsj.indexOf("01:") == 0 || | |
| 4654 | - b.fcsj.indexOf("02:") == 0) { | |
| 4655 | - b_wrapTime.add(1, "day"); | |
| 4656 | - } | |
| 4657 | - | |
| 4658 | - if (a_wrapTime.isBefore(b_wrapTime)) { | |
| 4659 | - return -1; | |
| 4660 | - } else if (a_wrapTime.isAfter(b_wrapTime)) { | |
| 4661 | - return 1; | |
| 4662 | - } else { | |
| 4663 | - return 0; | |
| 4664 | - } | |
| 4665 | - }); | |
| 4666 | - | |
| 4667 | - // 构造路牌block车次链,按照发车顺序排序 | |
| 4668 | - angular.forEach(ctrl.internalBcModel.up_bc_list_asc, function(data, index) { | |
| 4669 | - if (!ctrl.internalLpBlockModel[data.lpName]) { | |
| 4670 | - ctrl.internalLpBlockModel[data.lpName] = []; | |
| 4671 | - } | |
| 4672 | - ctrl.internalLpBlockModel[data.lpName].push({ | |
| 4673 | - fcsj : data.fcsj, | |
| 4674 | - isUp : true, | |
| 4675 | - fcno : data._fcno, | |
| 4676 | - index : index | |
| 4677 | - }); | |
| 4678 | - }); | |
| 4679 | - angular.forEach(ctrl.internalBcModel.down_bc_list_asc, function(data, index) { | |
| 4680 | - if (!ctrl.internalLpBlockModel[data.lpName]) { | |
| 4681 | - ctrl.internalLpBlockModel[data.lpName] = []; | |
| 4682 | - } | |
| 4683 | - ctrl.internalLpBlockModel[data.lpName].push({ | |
| 4684 | - fcsj : data.fcsj, | |
| 4685 | - isUp : false, | |
| 4686 | - fcno : data._fcno, | |
| 4687 | - index : index | |
| 4688 | - }); | |
| 4689 | - }); | |
| 4690 | - angular.forEach(ctrl.internalLpBlockModel, function(value, key) { | |
| 4691 | - value.sort(function (a, b) { | |
| 4692 | - if (a.fcno < b.fcno) { | |
| 4693 | - return -1; | |
| 4694 | - } else if (a.fcno > b.fcno) { | |
| 4695 | - return 1; | |
| 4696 | - } else { | |
| 4697 | - return 0; | |
| 4698 | - } | |
| 4699 | - }); | |
| 4700 | - }); | |
| 4701 | - | |
| 4702 | - | |
| 4703 | - }; | |
| 4704 | - | |
| 4705 | - return { | |
| 4706 | - pre : function(scope, element, attr) { | |
| 4707 | - // TODO: | |
| 4708 | - }, | |
| 4709 | - post : function(scope, element, attr) { | |
| 4710 | - // 班次html点击事件 | |
| 4711 | - scope[ctrlAs].$$bcDD_Click = function(index, xlDir) { | |
| 4712 | - _fun_bcDDViewMove(scope[ctrlAs], index, xlDir); | |
| 4713 | - }; | |
| 4714 | - | |
| 4715 | - // 监控ngModel绑定的外部数据源的刷新状态变化 | |
| 4716 | - scope.$watch( | |
| 4717 | - function() { | |
| 4718 | - return scope[ctrlAs].ds.refreshInfos; | |
| 4719 | - }, | |
| 4720 | - function(newValue, oldValue) { | |
| 4721 | - if (newValue === undefined && oldValue === undefined) { | |
| 4722 | - return; | |
| 4723 | - } | |
| 4724 | - console.log("saTimetable2 refresh"); | |
| 4725 | - _fun_refreshInternalModel(scope[ctrlAs]); | |
| 4726 | - }, | |
| 4727 | - true | |
| 4728 | - ); | |
| 4729 | - } | |
| 4730 | - }; | |
| 4731 | - } | |
| 4732 | - }; | |
| 4733 | - } | |
| 4734 | - ] | |
| 4410 | +/** | |
| 4411 | + * saTimetablePreview指令,时刻表预览模式视图。 | |
| 4412 | + */ | |
| 4413 | +angular.module("ScheduleApp").directive( | |
| 4414 | + "saTimetable2", | |
| 4415 | + [ | |
| 4416 | + '$timeout', | |
| 4417 | + function($timeout) { | |
| 4418 | + return { | |
| 4419 | + restrict : 'E', | |
| 4420 | + templateUrl : '/pages/scheduleApp/module/common/dts2/ttinfotable/saTimeTablePreViewTemplate.html', | |
| 4421 | + scope : { // 独立作用域 | |
| 4422 | + // 使用外部数据源,内部重新组合显示 | |
| 4423 | + ds : "=ngModel" | |
| 4424 | + }, | |
| 4425 | + controllerAs : "$saTimeTablePreviewCtrl", | |
| 4426 | + bindToController: true, | |
| 4427 | + controller : function() { | |
| 4428 | + var self = this; | |
| 4429 | + | |
| 4430 | + // 内部班次时刻模型 | |
| 4431 | + self.internalBcModel = { | |
| 4432 | + up_qdz_name : "", // 上行起点站名字 | |
| 4433 | + down_qdz_name : "", // 下行起点站名字 | |
| 4434 | + up_bc_list_asc : [], // 上行班次列表(按照发车时间升序) | |
| 4435 | + down_bc_list_asc : [] // 下行班次列表(按照发车时间升序) | |
| 4436 | + }; | |
| 4437 | + | |
| 4438 | + // 内部各个路牌block车次链模型 | |
| 4439 | + self.internalLpBlockModel = { | |
| 4440 | + // key:路牌名字 | |
| 4441 | + // value: 数组(按照发车时间排序) | |
| 4442 | + // value 数据内对象 {fcsj:发车时间,isUp:是否上行,fcno:发车顺序号,index:对应的班次列表索引} | |
| 4443 | + }; | |
| 4444 | + | |
| 4445 | + // TODO: | |
| 4446 | + }, | |
| 4447 | + | |
| 4448 | + /**, | |
| 4449 | + * compile阶段,angular还没有编译模版,根据需要可以修改模版dom | |
| 4450 | + * @param tElem | |
| 4451 | + * @param tAttrs | |
| 4452 | + * @returns {{pre: Function, post: Function}} | |
| 4453 | + */ | |
| 4454 | + compile : function(tElem, tAttrs) { | |
| 4455 | + // 获取属性 | |
| 4456 | + var $attr_name = tAttrs["name"]; // 控件的名字 | |
| 4457 | + if (!$attr_name) { | |
| 4458 | + throw new Error("saTimeTablePreview指令 name属性required"); | |
| 4459 | + } | |
| 4460 | + | |
| 4461 | + // 内部controlAs名字 | |
| 4462 | + var ctrlAs = "$saTimeTablePreviewCtrl"; | |
| 4463 | + | |
| 4464 | + // TODO: | |
| 4465 | + | |
| 4466 | + //------------------ 内部方法 --------------------// | |
| 4467 | + var date_wrap_prefix = "2000-01-01 "; // 包装日期的前缀 | |
| 4468 | + var date_wrap_format = "YYYY-MM-DD HH:mm"; // 日期格式 | |
| 4469 | + /** | |
| 4470 | + * 将时间包装成日期,方便计算。 | |
| 4471 | + * @param timeStr 时间格式,如 06:30 | |
| 4472 | + * @returns moment对象 | |
| 4473 | + */ | |
| 4474 | + var _fun_WrapTime = function(timeStr) { | |
| 4475 | + return moment( | |
| 4476 | + date_wrap_prefix + timeStr, | |
| 4477 | + date_wrap_format | |
| 4478 | + ); | |
| 4479 | + }; | |
| 4480 | + | |
| 4481 | + /** | |
| 4482 | + * 点击班次html元素(dl),触发班次移动,如下: | |
| 4483 | + * 1、点击上行班次,下一个下行班次在下行班次列表中移到中间位置 | |
| 4484 | + * 2、点击下行班次,下一个上行班次在上行班次列表中移到中间位置 | |
| 4485 | + * @param ctrl 内部控制器 | |
| 4486 | + * @param index 班次索引 | |
| 4487 | + * @param isUp 是否上行 | |
| 4488 | + * @private | |
| 4489 | + */ | |
| 4490 | + var _fun_bcDDViewMove = function(ctrl, index, isUp) { | |
| 4491 | + // 获取当前点击班次对象 | |
| 4492 | + var oBc; | |
| 4493 | + if (isUp) { | |
| 4494 | + oBc = ctrl.internalBcModel.up_bc_list_asc[index]; | |
| 4495 | + } else { | |
| 4496 | + oBc = ctrl.internalBcModel.down_bc_list_asc[index]; | |
| 4497 | + } | |
| 4498 | + | |
| 4499 | + // 找出车次链中的下一个班次索引,没有就undefined | |
| 4500 | + var nextIndex = undefined; | |
| 4501 | + var nextBlockBc = undefined; | |
| 4502 | + var currentBlockBcIndex = undefined; | |
| 4503 | + angular.forEach(ctrl.internalLpBlockModel[oBc.lpName], function(data, i) { | |
| 4504 | + if (data.fcsj == oBc.fcsj) { | |
| 4505 | + currentBlockBcIndex = i; | |
| 4506 | + } | |
| 4507 | + }); | |
| 4508 | + if (currentBlockBcIndex != undefined && | |
| 4509 | + currentBlockBcIndex < (ctrl.internalLpBlockModel[oBc.lpName].length - 1)) { | |
| 4510 | + nextBlockBc = ctrl.internalLpBlockModel[oBc.lpName][currentBlockBcIndex + 1]; | |
| 4511 | + nextIndex = nextBlockBc.index; | |
| 4512 | + } | |
| 4513 | + // 先删除click标记,再添加 | |
| 4514 | + angular.forEach(ctrl.internalBcModel.up_bc_list_asc, function(data) { | |
| 4515 | + delete data["isClick"]; | |
| 4516 | + }); | |
| 4517 | + angular.forEach(ctrl.internalBcModel.down_bc_list_asc, function(data) { | |
| 4518 | + delete data["isClick"]; | |
| 4519 | + }); | |
| 4520 | + oBc.isClick = true; | |
| 4521 | + if (nextIndex) { | |
| 4522 | + if (nextBlockBc.isUp) { | |
| 4523 | + ctrl.internalBcModel.up_bc_list_asc[nextIndex].isClick = true; | |
| 4524 | + } else { | |
| 4525 | + ctrl.internalBcModel.down_bc_list_asc[nextIndex].isClick = true; | |
| 4526 | + } | |
| 4527 | + } | |
| 4528 | + | |
| 4529 | + // 移动,同方向不移动 | |
| 4530 | + var clientHeight = angular.element("#temp").height() - 34; | |
| 4531 | + if (nextBlockBc && isUp != nextBlockBc.isUp) { | |
| 4532 | + if (isUp) { // 移动下行 | |
| 4533 | + angular.element(".ttpv_table_scrollbar:eq(1)").animate( | |
| 4534 | + {scrollTop : nextIndex * 30 - clientHeight / 2}, 400); | |
| 4535 | + } else { // 移动上行 | |
| 4536 | + angular.element(".ttpv_table_scrollbar:eq(0)").animate( | |
| 4537 | + {scrollTop : nextIndex * 30 - clientHeight / 2}, 400); | |
| 4538 | + } | |
| 4539 | + } | |
| 4540 | + | |
| 4541 | + }; | |
| 4542 | + | |
| 4543 | + /** | |
| 4544 | + * 刷新内部数据。 | |
| 4545 | + * @param ctrl 内部控制器对象($saTimeTablePreviewCtrl) | |
| 4546 | + * @private | |
| 4547 | + */ | |
| 4548 | + var _fun_refreshInternalModel = function(ctrl) { | |
| 4549 | + // 初始化内部数据 | |
| 4550 | + ctrl.internalBcModel = { | |
| 4551 | + up_qdz_name : "", // 上行起点站名字 | |
| 4552 | + up_zdz_name : "", // 上行终点站名字 | |
| 4553 | + down_qdz_name : "", // 下行起点站名字 | |
| 4554 | + down_zdz_name : "", // 下行终点站名字 | |
| 4555 | + up_bc_list_asc : [], // 上行班次列表(按照发车时间升序) | |
| 4556 | + down_bc_list_asc : [] // 下行班次列表(按照发车时间升序) | |
| 4557 | + }; | |
| 4558 | + ctrl.internalLpBlockModel = { | |
| 4559 | + | |
| 4560 | + }; | |
| 4561 | + | |
| 4562 | + // ngModel传入的数据 | |
| 4563 | + var dataSource = ctrl.ds.bcList; | |
| 4564 | + | |
| 4565 | + // 构造上下行班次列表,并确定上下行的首发站点 | |
| 4566 | + angular.forEach(dataSource, function(bcObj) { | |
| 4567 | + var _internalBcObj = {}; | |
| 4568 | + // 构造内部班次对象 | |
| 4569 | + _internalBcObj.lpName = bcObj.lp.lpName; // 路牌 | |
| 4570 | + _internalBcObj.fcsj = bcObj.fcsj; // 发车时间 | |
| 4571 | + _internalBcObj.ddsj = _fun_WrapTime(bcObj.fcsj).add(bcObj.bcsj, "m").format("HH:mm"); | |
| 4572 | + _internalBcObj.qdzName = bcObj.qdzName; // 起点站名字 | |
| 4573 | + _internalBcObj.zdzName = bcObj.zdzName; // 终点站名字 | |
| 4574 | + _internalBcObj.bcType = bcObj.bcType; // 班次类型 | |
| 4575 | + _internalBcObj.isTs = bcObj.isTS; // 是否停驶 | |
| 4576 | + _internalBcObj.isFb = bcObj.isFB; // 是否分班 | |
| 4577 | + _internalBcObj.remark = bcObj.remark; // 备注 | |
| 4578 | + _internalBcObj._fcno = bcObj.fcno; // 发车顺序号 | |
| 4579 | + | |
| 4580 | + if (bcObj.xlDir == "0") { // 上行 | |
| 4581 | + ctrl.internalBcModel.up_bc_list_asc.push(_internalBcObj); | |
| 4582 | + // 确定起点站 | |
| 4583 | + if (ctrl.internalBcModel.up_qdz_name == "") { | |
| 4584 | + if (bcObj.bcType == "normal") { | |
| 4585 | + ctrl.internalBcModel.up_qdz_name = bcObj.qdzName; | |
| 4586 | + } | |
| 4587 | + } | |
| 4588 | + // 确定终点站 | |
| 4589 | + if (ctrl.internalBcModel.up_zdz_name == "") { | |
| 4590 | + if (bcObj.bcType == "normal") { | |
| 4591 | + ctrl.internalBcModel.up_zdz_name = bcObj.zdzName; | |
| 4592 | + } | |
| 4593 | + } | |
| 4594 | + } | |
| 4595 | + if (bcObj.xlDir == "1") { // 下行 | |
| 4596 | + ctrl.internalBcModel.down_bc_list_asc.push(_internalBcObj); | |
| 4597 | + // 确定起点站 | |
| 4598 | + if (ctrl.internalBcModel.down_qdz_name == "") { | |
| 4599 | + if (bcObj.bcType == "normal") { | |
| 4600 | + ctrl.internalBcModel.down_qdz_name = bcObj.qdzName; | |
| 4601 | + } | |
| 4602 | + } | |
| 4603 | + // 确定终点站 | |
| 4604 | + if (ctrl.internalBcModel.down_zdz_name == "") { | |
| 4605 | + if (bcObj.bcType == "normal") { | |
| 4606 | + ctrl.internalBcModel.down_zdz_name = bcObj.zdzName; | |
| 4607 | + } | |
| 4608 | + } | |
| 4609 | + } | |
| 4610 | + | |
| 4611 | + }); | |
| 4612 | + | |
| 4613 | + // 发车时间升序排序上行班次 | |
| 4614 | + ctrl.internalBcModel.up_bc_list_asc.sort(function(a, b) { | |
| 4615 | + var a_wrapTime = _fun_WrapTime(a.fcsj); | |
| 4616 | + var b_wrapTime = _fun_WrapTime(b.fcsj); | |
| 4617 | + | |
| 4618 | + // 判定如果发车时间是以00,01,02,03开头的,说明是下一天凌晨的班次,需要加1天判定 | |
| 4619 | + // TODO:以后要配合首班车的发车时间判定 | |
| 4620 | + if (a.fcsj.indexOf("00:") == 0 || | |
| 4621 | + a.fcsj.indexOf("01:") == 0 || | |
| 4622 | + a.fcsj.indexOf("02:") == 0) { | |
| 4623 | + a_wrapTime.add(1, "day"); | |
| 4624 | + } | |
| 4625 | + if (b.fcsj.indexOf("00:") == 0 || | |
| 4626 | + b.fcsj.indexOf("01:") == 0 || | |
| 4627 | + b.fcsj.indexOf("02:") == 0) { | |
| 4628 | + b_wrapTime.add(1, "day"); | |
| 4629 | + } | |
| 4630 | + | |
| 4631 | + if (a_wrapTime.isBefore(b_wrapTime)) { | |
| 4632 | + return -1; | |
| 4633 | + } else if (a_wrapTime.isAfter(b_wrapTime)) { | |
| 4634 | + return 1; | |
| 4635 | + } else { | |
| 4636 | + return 0; | |
| 4637 | + } | |
| 4638 | + | |
| 4639 | + }); | |
| 4640 | + // 发车时间升序排序下行班次 | |
| 4641 | + ctrl.internalBcModel.down_bc_list_asc.sort(function(a, b) { | |
| 4642 | + var a_wrapTime = _fun_WrapTime(a.fcsj); | |
| 4643 | + var b_wrapTime = _fun_WrapTime(b.fcsj); | |
| 4644 | + | |
| 4645 | + // 判定如果发车时间是以00,01,02,03开头的,说明是下一天凌晨的班次,需要加1天判定 | |
| 4646 | + // TODO:以后要配合首班车的发车时间判定 | |
| 4647 | + if (a.fcsj.indexOf("00:") == 0 || | |
| 4648 | + a.fcsj.indexOf("01:") == 0 || | |
| 4649 | + a.fcsj.indexOf("02:") == 0) { | |
| 4650 | + a_wrapTime.add(1, "day"); | |
| 4651 | + } | |
| 4652 | + if (b.fcsj.indexOf("00:") == 0 || | |
| 4653 | + b.fcsj.indexOf("01:") == 0 || | |
| 4654 | + b.fcsj.indexOf("02:") == 0) { | |
| 4655 | + b_wrapTime.add(1, "day"); | |
| 4656 | + } | |
| 4657 | + | |
| 4658 | + if (a_wrapTime.isBefore(b_wrapTime)) { | |
| 4659 | + return -1; | |
| 4660 | + } else if (a_wrapTime.isAfter(b_wrapTime)) { | |
| 4661 | + return 1; | |
| 4662 | + } else { | |
| 4663 | + return 0; | |
| 4664 | + } | |
| 4665 | + }); | |
| 4666 | + | |
| 4667 | + // 构造路牌block车次链,按照发车顺序排序 | |
| 4668 | + angular.forEach(ctrl.internalBcModel.up_bc_list_asc, function(data, index) { | |
| 4669 | + if (!ctrl.internalLpBlockModel[data.lpName]) { | |
| 4670 | + ctrl.internalLpBlockModel[data.lpName] = []; | |
| 4671 | + } | |
| 4672 | + ctrl.internalLpBlockModel[data.lpName].push({ | |
| 4673 | + fcsj : data.fcsj, | |
| 4674 | + isUp : true, | |
| 4675 | + fcno : data._fcno, | |
| 4676 | + index : index | |
| 4677 | + }); | |
| 4678 | + }); | |
| 4679 | + angular.forEach(ctrl.internalBcModel.down_bc_list_asc, function(data, index) { | |
| 4680 | + if (!ctrl.internalLpBlockModel[data.lpName]) { | |
| 4681 | + ctrl.internalLpBlockModel[data.lpName] = []; | |
| 4682 | + } | |
| 4683 | + ctrl.internalLpBlockModel[data.lpName].push({ | |
| 4684 | + fcsj : data.fcsj, | |
| 4685 | + isUp : false, | |
| 4686 | + fcno : data._fcno, | |
| 4687 | + index : index | |
| 4688 | + }); | |
| 4689 | + }); | |
| 4690 | + angular.forEach(ctrl.internalLpBlockModel, function(value, key) { | |
| 4691 | + value.sort(function (a, b) { | |
| 4692 | + if (a.fcno < b.fcno) { | |
| 4693 | + return -1; | |
| 4694 | + } else if (a.fcno > b.fcno) { | |
| 4695 | + return 1; | |
| 4696 | + } else { | |
| 4697 | + return 0; | |
| 4698 | + } | |
| 4699 | + }); | |
| 4700 | + }); | |
| 4701 | + | |
| 4702 | + | |
| 4703 | + }; | |
| 4704 | + | |
| 4705 | + return { | |
| 4706 | + pre : function(scope, element, attr) { | |
| 4707 | + // TODO: | |
| 4708 | + }, | |
| 4709 | + post : function(scope, element, attr) { | |
| 4710 | + // 班次html点击事件 | |
| 4711 | + scope[ctrlAs].$$bcDD_Click = function(index, xlDir) { | |
| 4712 | + _fun_bcDDViewMove(scope[ctrlAs], index, xlDir); | |
| 4713 | + }; | |
| 4714 | + | |
| 4715 | + // 监控ngModel绑定的外部数据源的刷新状态变化 | |
| 4716 | + scope.$watch( | |
| 4717 | + function() { | |
| 4718 | + return scope[ctrlAs].ds.refreshInfos; | |
| 4719 | + }, | |
| 4720 | + function(newValue, oldValue) { | |
| 4721 | + if (newValue === undefined && oldValue === undefined) { | |
| 4722 | + return; | |
| 4723 | + } | |
| 4724 | + console.log("saTimetable2 refresh"); | |
| 4725 | + _fun_refreshInternalModel(scope[ctrlAs]); | |
| 4726 | + }, | |
| 4727 | + true | |
| 4728 | + ); | |
| 4729 | + } | |
| 4730 | + }; | |
| 4731 | + } | |
| 4732 | + }; | |
| 4733 | + } | |
| 4734 | + ] | |
| 4735 | 4735 | ); |
| 4736 | 4736 | /** |
| 4737 | 4737 | * 滚动事件控制指令。 | ... | ... |