Commit 7d8140ed31259ce3c9723116abfb8374c77cd59c

Authored by 徐烜
1 parent c36f9287

update

src/main/resources/static/pages/scheduleApp/module/common/dts2/ttinfotable/saTimeTable.js
1 /** 1 /**
2 * saTimeTable指令,时刻表显示指令,excel表格形式,支持菜单,事件处理。 2 * saTimeTable指令,时刻表显示指令,excel表格形式,支持菜单,事件处理。
3 * name(必须),控件的名字 3 * name(必须),控件的名字
  4 + * celldbclickFn,单元格双击事件
4 * ds,外部数据源 5 * ds,外部数据源
5 * 6 *
6 * TODO:优化开发中 7 * TODO:优化开发中
7 * 8 *
8 */ 9 */
9 -angular.module('ScheduleApp').directive('saTimetable', ['$compile',  
10 - function($compile) { 10 +angular.module('ScheduleApp').directive('saTimetable', ['$compile', '$window',
  11 + function($compile, $window) {
11 return { 12 return {
12 restrict: 'E', 13 restrict: 'E',
13 templateUrl: '/pages/scheduleApp/module/common/dts2/ttinfotable/saTimeTableTemplate.html', 14 templateUrl: '/pages/scheduleApp/module/common/dts2/ttinfotable/saTimeTableTemplate.html',
14 scope: { // 独立作用域 15 scope: { // 独立作用域
15 // 注意:数据暂时从外部ngModel里获取,以后内部自己处理 16 // 注意:数据暂时从外部ngModel里获取,以后内部自己处理
16 - ds: "=ngModel" 17 + ds: "=ngModel",
  18 + celldbclickFn: "&celldbclick"
17 19
18 // TODO: 20 // TODO:
19 21
@@ -39,10 +41,19 @@ angular.module('ScheduleApp').directive('saTimetable', ['$compile', @@ -39,10 +41,19 @@ angular.module('ScheduleApp').directive('saTimetable', ['$compile',
39 if (!$attr_name) { 41 if (!$attr_name) {
40 throw new Error("saTimeTable指令 name属性required"); 42 throw new Error("saTimeTable指令 name属性required");
41 } 43 }
  44 + var $attr_celldbclick = tAttrs["celldbclick"]; // 单元格双击事件名
42 45
43 // 内部controlAs名字 46 // 内部controlAs名字
44 var ctrlAs = '$saTimeTableCtrl'; 47 var ctrlAs = '$saTimeTableCtrl';
45 48
  49 + // 当前选中的cell
  50 + var startRowIndex = undefined;
  51 + var startColIndex = undefined;
  52 + var shiftKey = false; // shift键是否被按住
  53 + var ctrlKey = false; // ctrl是否被按住
  54 + // shift选中的cell
  55 + var shiftCells = [];
  56 +
46 // TODO: 57 // TODO:
47 58
48 return { 59 return {
@@ -57,11 +68,20 @@ angular.module('ScheduleApp').directive('saTimetable', ['$compile', @@ -57,11 +68,20 @@ angular.module('ScheduleApp').directive('saTimetable', ['$compile',
57 68
58 // ------------------- dom事件处理function -----------------// 69 // ------------------- dom事件处理function -----------------//
59 scope[ctrlAs].$$cell_click = function(rowindex, colindex, cell) { 70 scope[ctrlAs].$$cell_click = function(rowindex, colindex, cell) {
60 - if (cell.ttdid) {  
61 - //alert(rowindex + "-" + colindex); 71 + console.log("click " + "row=" + rowindex + ",col=" + colindex);
  72 +
  73 + if (cell.ttdid) { // 是班次的单元格才能操作
62 cell.sel = !cell.sel; 74 cell.sel = !cell.sel;
63 } 75 }
64 - // TODO: 76 +
  77 + };
  78 + scope[ctrlAs].$$cell_dbclick = function(rowindex, colindex, cell) {
  79 + if (cell.ttdid) { // 是班次的单元格才能操作
  80 + if ($attr_celldbclick) {
  81 + // 注意调用方法
  82 + scope[ctrlAs].celldbclickFn()(rowindex, colindex);
  83 + }
  84 + }
65 }; 85 };
66 86
67 // ------------------- 监控function ------------------// 87 // ------------------- 监控function ------------------//
src/main/resources/static/pages/scheduleApp/module/common/dts2/ttinfotable/saTimeTableTemplate.html
@@ -301,6 +301,7 @@ @@ -301,6 +301,7 @@
301 <dd ng-repeat="cell in info track by $index" 301 <dd ng-repeat="cell in info track by $index"
302 ng-init="colIndex = $index" 302 ng-init="colIndex = $index"
303 ng-click="$saTimeTableCtrl.$$cell_click(rowIndex, colIndex, cell)" 303 ng-click="$saTimeTableCtrl.$$cell_click(rowIndex, colIndex, cell)"
  304 + ng-dblclick="$saTimeTableCtrl.$$cell_dbclick(rowIndex, colIndex, cell)"
304 ng-class="{lpName: !cell.ttdid, active: cell.sel}" 305 ng-class="{lpName: !cell.ttdid, active: cell.sel}"
305 > 306 >
306 {{cell.fcsj}} 307 {{cell.fcsj}}
src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
@@ -3662,19 +3662,21 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saBcgroup&#39;, [ @@ -3662,19 +3662,21 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saBcgroup&#39;, [
3662 /** 3662 /**
3663 * saTimeTable指令,时刻表显示指令,excel表格形式,支持菜单,事件处理。 3663 * saTimeTable指令,时刻表显示指令,excel表格形式,支持菜单,事件处理。
3664 * name(必须),控件的名字 3664 * name(必须),控件的名字
  3665 + * celldbclickFn,单元格双击事件
3665 * ds,外部数据源 3666 * ds,外部数据源
3666 * 3667 *
3667 * TODO:优化开发中 3668 * TODO:优化开发中
3668 * 3669 *
3669 */ 3670 */
3670 -angular.module('ScheduleApp').directive('saTimetable', ['$compile',  
3671 - function($compile) { 3671 +angular.module('ScheduleApp').directive('saTimetable', ['$compile', '$window',
  3672 + function($compile, $window) {
3672 return { 3673 return {
3673 restrict: 'E', 3674 restrict: 'E',
3674 templateUrl: '/pages/scheduleApp/module/common/dts2/ttinfotable/saTimeTableTemplate.html', 3675 templateUrl: '/pages/scheduleApp/module/common/dts2/ttinfotable/saTimeTableTemplate.html',
3675 scope: { // 独立作用域 3676 scope: { // 独立作用域
3676 // 注意:数据暂时从外部ngModel里获取,以后内部自己处理 3677 // 注意:数据暂时从外部ngModel里获取,以后内部自己处理
3677 - ds: "=ngModel" 3678 + ds: "=ngModel",
  3679 + celldbclickFn: "&celldbclick"
3678 3680
3679 // TODO: 3681 // TODO:
3680 3682
@@ -3700,10 +3702,19 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saTimetable&#39;, [&#39;$compile&#39;, @@ -3700,10 +3702,19 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saTimetable&#39;, [&#39;$compile&#39;,
3700 if (!$attr_name) { 3702 if (!$attr_name) {
3701 throw new Error("saTimeTable指令 name属性required"); 3703 throw new Error("saTimeTable指令 name属性required");
3702 } 3704 }
  3705 + var $attr_celldbclick = tAttrs["celldbclick"]; // 单元格双击事件名
3703 3706
3704 // 内部controlAs名字 3707 // 内部controlAs名字
3705 var ctrlAs = '$saTimeTableCtrl'; 3708 var ctrlAs = '$saTimeTableCtrl';
3706 3709
  3710 + // 当前选中的cell
  3711 + var startRowIndex = undefined;
  3712 + var startColIndex = undefined;
  3713 + var shiftKey = false; // shift键是否被按住
  3714 + var ctrlKey = false; // ctrl是否被按住
  3715 + // shift选中的cell
  3716 + var shiftCells = [];
  3717 +
3707 // TODO: 3718 // TODO:
3708 3719
3709 return { 3720 return {
@@ -3718,11 +3729,20 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saTimetable&#39;, [&#39;$compile&#39;, @@ -3718,11 +3729,20 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saTimetable&#39;, [&#39;$compile&#39;,
3718 3729
3719 // ------------------- dom事件处理function -----------------// 3730 // ------------------- dom事件处理function -----------------//
3720 scope[ctrlAs].$$cell_click = function(rowindex, colindex, cell) { 3731 scope[ctrlAs].$$cell_click = function(rowindex, colindex, cell) {
3721 - if (cell.ttdid) {  
3722 - //alert(rowindex + "-" + colindex); 3732 + console.log("click " + "row=" + rowindex + ",col=" + colindex);
  3733 +
  3734 + if (cell.ttdid) { // 是班次的单元格才能操作
3723 cell.sel = !cell.sel; 3735 cell.sel = !cell.sel;
3724 } 3736 }
3725 - // TODO: 3737 +
  3738 + };
  3739 + scope[ctrlAs].$$cell_dbclick = function(rowindex, colindex, cell) {
  3740 + if (cell.ttdid) { // 是班次的单元格才能操作
  3741 + if ($attr_celldbclick) {
  3742 + // 注意调用方法
  3743 + scope[ctrlAs].celldbclickFn()(rowindex, colindex);
  3744 + }
  3745 + }
3726 }; 3746 };
3727 3747
3728 // ------------------- 监控function ------------------// 3748 // ------------------- 监控function ------------------//
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage/detailedit/edit3.html
@@ -75,7 +75,7 @@ @@ -75,7 +75,7 @@
75 <div class="portlet-body"> 75 <div class="portlet-body">
76 <!--<div ng-view></div>--> 76 <!--<div ng-view></div>-->
77 <div style="height: {{ctrl.ttHeight}}px;"> 77 <div style="height: {{ctrl.ttHeight}}px;">
78 - <sa-Timetable name="tt" ng-model="ctrl.editInfo" ng-model-options="{ getterSetter: true }"> 78 + <sa-Timetable name="tt" ng-model="ctrl.editInfo" ng-model-options="{ getterSetter: true }" celldbclick="ctrl.singleEditBcDetail">
79 79
80 </sa-Timetable> 80 </sa-Timetable>
81 </div> 81 </div>
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage/detailedit/timeTableDetailManage_old.js
@@ -229,35 +229,17 @@ angular.module(&#39;ScheduleApp&#39;).controller( @@ -229,35 +229,17 @@ angular.module(&#39;ScheduleApp&#39;).controller(
229 /** 229 /**
230 * 单独修改班次明细。 230 * 单独修改班次明细。
231 */ 231 */
232 - self.singleEditBcDetail = function() {  
233 - var id = null;  
234 - if (self.editInfo &&  
235 - self.editInfo.detailInfos &&  
236 - self.editInfo.detailInfos.length > 0) { // 找出第一个被选中的就可以了  
237 - for (var i = 0; i < self.editInfo.detailInfos.length; i++) {  
238 - for (var j = 0; j < self.editInfo.detailInfos[i].length; j++) {  
239 - if (self.editInfo.detailInfos[i][j].sel) {  
240 - id = self.editInfo.detailInfos[i][j].ttdid;  
241 - break;  
242 - }  
243 - }  
244 - if (id) {  
245 - break;  
246 - } 232 + self.singleEditBcDetail = function(r, c) {
  233 + var id = self.editInfo.detailInfos[r][c].ttdid;
  234 + $state.go('ttInfoDetailManage_detail_edit',
  235 + {
  236 + id: id,
  237 + xlid: self.xlid,
  238 + ttid: self.ttid,
  239 + xlname: self.xlname,
  240 + ttname: self.ttname
247 } 241 }
248 - }  
249 - if (!id) {  
250 - alert("请选择具体班次!");  
251 - } else {  
252 - $state.go('ttInfoDetailManage_detail_edit',  
253 - {  
254 - id: id,  
255 - xlid: self.xlid,  
256 - ttid: self.ttid,  
257 - xlname: self.xlname,  
258 - ttname: self.ttname  
259 - });  
260 - } 242 + );
261 }; 243 };
262 244
263 // 批量修改 245 // 批量修改