Commit 316f67ab81432e24b0412fd1629a2353aca5f068

Authored by 潘钊
2 parents a9cc5402 4a5801f4

Merge branch 'minhang' into qingpu

# Conflicts:
#	src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
#	src/main/java/com/bsth/data/gpsdata/GpsRealData.java
#	src/main/resources/application-dev.properties
Showing 36 changed files with 4195 additions and 4119 deletions
src/main/java/com/bsth/controller/realcontrol/BasicDataController.java
@@ -47,6 +47,15 @@ public class BasicDataController { @@ -47,6 +47,15 @@ public class BasicDataController {
47 return rs; 47 return rs;
48 } 48 }
49 49
  50 + @RequestMapping("/all_personnel")
  51 + public Map<String, String> all_personnel(){
  52 + //Map<String, Object> rs = new HashMap<>();
  53 + //PersonnelFieldFilter filter=new PersonnelFieldFilter();
  54 +
  55 + //rs.put("list", JSON.parse(JSON.toJSONString(BasicData.jsyMap.values(), filter)));
  56 + return BasicData.allPerson;
  57 + }
  58 +
50 59
51 public class PersonnelFieldFilter implements PropertyFilter{ 60 public class PersonnelFieldFilter implements PropertyFilter{
52 61
src/main/java/com/bsth/data/arrival/ArrivalData_GPS.java
@@ -144,4 +144,4 @@ public class ArrivalData_GPS implements CommandLineRunner{ @@ -144,4 +144,4 @@ public class ArrivalData_GPS implements CommandLineRunner{
144 carIndexMap.put(nbbm, size); 144 carIndexMap.put(nbbm, size);
145 return rs; 145 return rs;
146 } 146 }
147 -} 147 +}
148 \ No newline at end of file 148 \ No newline at end of file
src/main/java/com/bsth/oplog/db/DBHelper.java
@@ -37,7 +37,7 @@ public class DBHelper implements CommandLineRunner{ @@ -37,7 +37,7 @@ public class DBHelper implements CommandLineRunner{
37 37
38 @Override 38 @Override
39 public void run() { 39 public void run() {
40 - persistence.batchSave(buffer); 40 + //persistence.batchSave(buffer);
41 } 41 }
42 } 42 }
43 43
src/main/resources/application-dev.properties
@@ -8,9 +8,9 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy @@ -8,9 +8,9 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy
8 spring.jpa.database= MYSQL 8 spring.jpa.database= MYSQL
9 spring.jpa.show-sql= true 9 spring.jpa.show-sql= true
10 spring.datasource.driver-class-name= com.mysql.jdbc.Driver 10 spring.datasource.driver-class-name= com.mysql.jdbc.Driver
11 -spring.datasource.url= jdbc:mysql://127.0.0.1:3306/qp_control 11 +spring.datasource.url= jdbc:mysql://192.168.168.201:3306/qp_control
12 spring.datasource.username= root 12 spring.datasource.username= root
13 -spring.datasource.password= panzhao 13 +spring.datasource.password= 123456
14 #DATASOURCE 14 #DATASOURCE
15 spring.datasource.max-active=100 15 spring.datasource.max-active=100
16 spring.datasource.max-idle=8 16 spring.datasource.max-idle=8
src/main/resources/datatools/config-prod.properties
@@ -4,11 +4,11 @@ @@ -4,11 +4,11 @@
4 datatools.kettle_properties=/datatools/kettle.properties 4 datatools.kettle_properties=/datatools/kettle.properties
5 # 2、ktr文件通用配置变量(数据库连接,根据不同的环境需要修正) 5 # 2、ktr文件通用配置变量(数据库连接,根据不同的环境需要修正)
6 #数据库ip地址 6 #数据库ip地址
7 -datatools.kvars_dbip=192.168.40.82 7 +datatools.kvars_dbip=192.168.40.100
8 #数据库用户名 8 #数据库用户名
9 datatools.kvars_dbuname=root 9 datatools.kvars_dbuname=root
10 #数据库密码 10 #数据库密码
11 -datatools.kvars_dbpwd=123456 11 +datatools.kvars_dbpwd=root@JSP2jsp
12 #数据库库名 12 #数据库库名
13 datatools.kvars_dbdname=qp_control 13 datatools.kvars_dbdname=qp_control
14 14
src/main/resources/static/assets/img/bg_9b9dcb65ff.png

17.4 KB | W: | H:

5.9 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
src/main/resources/static/pages/scheduleApp/module/common/dts1/checkbox/saCheckboxgroup.js
1 -  
2 -  
3 -/**  
4 - * saCheckboxgroup指令  
5 - * 属性如下:  
6 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
7 - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}  
8 - * dcname(必须):绑定的model字段名,如:dcname=xl.id  
9 - * name(必须):控件的名字  
10 - * required(可选):是否要用required验证  
11 - * disabled(可选):标示框是否可选  
12 - *  
13 - */  
14 -angular.module('ScheduleApp').directive('saCheckboxgroup', [  
15 - function() {  
16 - return {  
17 - restrict: 'E',  
18 - templateUrl: '/pages/scheduleApp/module/common/dts1/checkbox/saCheckboxgroupTemplate.html',  
19 - scope: {  
20 - model: "=" // 独立作用域,关联外部的模型object  
21 - },  
22 - controllerAs: "$saCheckboxgroupCtrl",  
23 - bindToController: true,  
24 - controller: function($scope) {  
25 - var self = this;  
26 - self.$$data = []; // 内部的数据  
27 -  
28 - // TODO:数据写死,周一至周日选择数据,以后有别的数据再议  
29 - self.$$data = [  
30 - {name: "星期一", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
31 - {name: "星期二", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
32 - {name: "星期三", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
33 - {name: "星期四", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
34 - {name: "星期五", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
35 - {name: "星期六", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
36 - {name: "星期日", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}  
37 - ];  
38 - },  
39 -  
40 - /**  
41 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
42 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
43 - * @param tElem  
44 - * @param tAttrs  
45 - * @returns {{pre: Function, post: Function}}  
46 - */  
47 - compile: function(tElem, tAttrs) {  
48 - // 获取所有的属性  
49 - var $name_attr = tAttrs["name"]; // 控件的名字  
50 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
51 - var $disabled_attr = tAttrs["disabled"]; // 是否禁用  
52 - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名  
53 -  
54 - // controlAs名字  
55 - var ctrlAs = '$saCheckboxgroupCtrl';  
56 -  
57 - // 如果有required属性,添加angularjs required验证  
58 - if ($required_attr != undefined) {  
59 - //console.log(tElem.html());  
60 - tElem.find("div").attr("required", "");  
61 - }  
62 - // 如果有disabled属性,添加禁用标志  
63 - if ($disabled_attr != undefined) {  
64 - tElem.find("input").attr("ng-disabled", "true");  
65 - }  
66 -  
67 - return {  
68 - pre: function(scope, element, attr) {  
69 - // TODO:  
70 - },  
71 - /**  
72 - * 相当于link函数。  
73 - * @param scope  
74 - * @param element  
75 - * @param attr  
76 - */  
77 - post: function(scope, element, attr) {  
78 - // name属性  
79 - if ($name_attr) {  
80 - scope[ctrlAs]["$name_attr"] = $name_attr;  
81 - }  
82 -  
83 - /**  
84 - * checkbox选择事件处理函数。  
85 - * @param $d 数据对象,$$data中的元素对象  
86 - */  
87 - scope[ctrlAs].$$internal_updateCheck_fn = function($d) {  
88 - $d.ischecked = !$d.ischecked;  
89 - console.log($d);  
90 - };  
91 -  
92 - // 测试使用watch监控$$data的变化  
93 - scope.$watch(  
94 - function() {  
95 - return scope[ctrlAs]["$$data"];  
96 - },  
97 - function(newValue, oldValue) {  
98 - // 根据$$data生成对应的数据  
99 - var rule_days_arr = [];  
100 - var i;  
101 - for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {  
102 - if (scope[ctrlAs]["$$data"][i].ischecked)  
103 - rule_days_arr.push(scope[ctrlAs]["$$data"][i].checkedvalue);  
104 - else  
105 - rule_days_arr.push(scope[ctrlAs]["$$data"][i].uncheckedvalue);  
106 - }  
107 - scope[ctrlAs].$$internalmodel = rule_days_arr.join(",");  
108 - //scope[ctrlAs].$$internalmodel = undefined;  
109 - console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel);  
110 -  
111 - // 更新model  
112 - if ($dcname_attr) {  
113 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = rule_days_arr.join(',');");  
114 - }  
115 -  
116 -  
117 - },  
118 - true  
119 - );  
120 -  
121 - // TODO:  
122 -  
123 - // 监控dcvalue model值变换  
124 - attr.$observe("dcvalue", function(value) {  
125 - console.log("saCheckboxgroup 监控dc1 model值变换:" + value);  
126 - if (value) {  
127 - // 根据value值,修改$$data里的值  
128 - var data_array = value.split(",");  
129 - var i;  
130 - if (data_array.length > scope[ctrlAs]["$$data"].length) {  
131 - for (i = 0; i < scope[ctrlAs]["$$data"].length; i ++) {  
132 - if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) {  
133 - scope[ctrlAs]["$$data"][i].ischecked = true;  
134 - } else {  
135 - scope[ctrlAs]["$$data"][i].ischecked = false;  
136 - }  
137 - }  
138 - } else {  
139 - for (i = 0; i < data_array.length; i ++) {  
140 - if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) {  
141 - scope[ctrlAs]["$$data"][i].ischecked = true;  
142 - } else {  
143 - scope[ctrlAs]["$$data"][i].ischecked = false;  
144 - }  
145 - }  
146 - }  
147 -  
148 - }  
149 - });  
150 - }  
151 -  
152 - };  
153 -  
154 -  
155 - }  
156 -  
157 - };  
158 - }  
159 -]);  
160 - 1 +
  2 +
  3 +/**
  4 + * saCheckboxgroup指令
  5 + * 属性如下:
  6 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  7 + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}
  8 + * dcname(必须):绑定的model字段名,如:dcname=xl.id
  9 + * name(必须):控件的名字
  10 + * required(可选):是否要用required验证
  11 + * disabled(可选):标示框是否可选
  12 + *
  13 + */
  14 +angular.module('ScheduleApp').directive('saCheckboxgroup', [
  15 + function() {
  16 + return {
  17 + restrict: 'E',
  18 + templateUrl: '/pages/scheduleApp/module/common/dts1/checkbox/saCheckboxgroupTemplate.html',
  19 + scope: {
  20 + model: "=" // 独立作用域,关联外部的模型object
  21 + },
  22 + controllerAs: "$saCheckboxgroupCtrl",
  23 + bindToController: true,
  24 + controller: function($scope) {
  25 + var self = this;
  26 + self.$$data = []; // 内部的数据
  27 +
  28 + // TODO:数据写死,周一至周日选择数据,以后有别的数据再议
  29 + self.$$data = [
  30 + {name: "星期一", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  31 + {name: "星期二", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  32 + {name: "星期三", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  33 + {name: "星期四", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  34 + {name: "星期五", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  35 + {name: "星期六", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  36 + {name: "星期日", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}
  37 + ];
  38 + },
  39 +
  40 + /**
  41 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  42 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  43 + * @param tElem
  44 + * @param tAttrs
  45 + * @returns {{pre: Function, post: Function}}
  46 + */
  47 + compile: function(tElem, tAttrs) {
  48 + // 获取所有的属性
  49 + var $name_attr = tAttrs["name"]; // 控件的名字
  50 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  51 + var $disabled_attr = tAttrs["disabled"]; // 是否禁用
  52 + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名
  53 +
  54 + // controlAs名字
  55 + var ctrlAs = '$saCheckboxgroupCtrl';
  56 +
  57 + // 如果有required属性,添加angularjs required验证
  58 + if ($required_attr != undefined) {
  59 + //console.log(tElem.html());
  60 + tElem.find("div").attr("required", "");
  61 + }
  62 + // 如果有disabled属性,添加禁用标志
  63 + if ($disabled_attr != undefined) {
  64 + tElem.find("input").attr("ng-disabled", "true");
  65 + }
  66 +
  67 + return {
  68 + pre: function(scope, element, attr) {
  69 + // TODO:
  70 + },
  71 + /**
  72 + * 相当于link函数。
  73 + * @param scope
  74 + * @param element
  75 + * @param attr
  76 + */
  77 + post: function(scope, element, attr) {
  78 + // name属性
  79 + if ($name_attr) {
  80 + scope[ctrlAs]["$name_attr"] = $name_attr;
  81 + }
  82 +
  83 + /**
  84 + * checkbox选择事件处理函数。
  85 + * @param $d 数据对象,$$data中的元素对象
  86 + */
  87 + scope[ctrlAs].$$internal_updateCheck_fn = function($d) {
  88 + $d.ischecked = !$d.ischecked;
  89 + console.log($d);
  90 + };
  91 +
  92 + // 测试使用watch监控$$data的变化
  93 + scope.$watch(
  94 + function() {
  95 + return scope[ctrlAs]["$$data"];
  96 + },
  97 + function(newValue, oldValue) {
  98 + // 根据$$data生成对应的数据
  99 + var rule_days_arr = [];
  100 + var i;
  101 + for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {
  102 + if (scope[ctrlAs]["$$data"][i].ischecked)
  103 + rule_days_arr.push(scope[ctrlAs]["$$data"][i].checkedvalue);
  104 + else
  105 + rule_days_arr.push(scope[ctrlAs]["$$data"][i].uncheckedvalue);
  106 + }
  107 + scope[ctrlAs].$$internalmodel = rule_days_arr.join(",");
  108 + //scope[ctrlAs].$$internalmodel = undefined;
  109 + console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel);
  110 +
  111 + // 更新model
  112 + if ($dcname_attr) {
  113 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = rule_days_arr.join(',');");
  114 + }
  115 +
  116 +
  117 + },
  118 + true
  119 + );
  120 +
  121 + // TODO:
  122 +
  123 + // 监控dcvalue model值变换
  124 + attr.$observe("dcvalue", function(value) {
  125 + console.log("saCheckboxgroup 监控dc1 model值变换:" + value);
  126 + if (value) {
  127 + // 根据value值,修改$$data里的值
  128 + var data_array = value.split(",");
  129 + var i;
  130 + if (data_array.length > scope[ctrlAs]["$$data"].length) {
  131 + for (i = 0; i < scope[ctrlAs]["$$data"].length; i ++) {
  132 + if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) {
  133 + scope[ctrlAs]["$$data"][i].ischecked = true;
  134 + } else {
  135 + scope[ctrlAs]["$$data"][i].ischecked = false;
  136 + }
  137 + }
  138 + } else {
  139 + for (i = 0; i < data_array.length; i ++) {
  140 + if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) {
  141 + scope[ctrlAs]["$$data"][i].ischecked = true;
  142 + } else {
  143 + scope[ctrlAs]["$$data"][i].ischecked = false;
  144 + }
  145 + }
  146 + }
  147 +
  148 + }
  149 + });
  150 + }
  151 +
  152 + };
  153 +
  154 +
  155 + }
  156 +
  157 + };
  158 + }
  159 +]);
  160 +
src/main/resources/static/pages/scheduleApp/module/common/dts1/load/loadingWidget.js
1 -  
2 -/**  
3 - * loading载入中指令。  
4 - */  
5 -angular.module('ScheduleApp').directive('loadingWidget', ['requestNotificationChannel', function(requestNotificationChannel) {  
6 - return {  
7 - restrict: 'A',  
8 - link: function(scope, element) {  
9 - // 初始隐藏loading界面  
10 - element.hide();  
11 -  
12 - // 开始请求通知处理  
13 - requestNotificationChannel.onRequestStarted(scope, function() {  
14 - element.show();  
15 - });  
16 - // 请求结束通知处理  
17 - requestNotificationChannel.onRequestEnded(scope, function() {  
18 - element.hide();  
19 - });  
20 - }  
21 - }; 1 +
  2 +/**
  3 + * loading载入中指令。
  4 + */
  5 +angular.module('ScheduleApp').directive('loadingWidget', ['requestNotificationChannel', function(requestNotificationChannel) {
  6 + return {
  7 + restrict: 'A',
  8 + link: function(scope, element) {
  9 + // 初始隐藏loading界面
  10 + element.hide();
  11 +
  12 + // 开始请求通知处理
  13 + requestNotificationChannel.onRequestStarted(scope, function() {
  14 + element.show();
  15 + });
  16 + // 请求结束通知处理
  17 + requestNotificationChannel.onRequestEnded(scope, function() {
  18 + element.hide();
  19 + });
  20 + }
  21 + };
22 }]); 22 }]);
23 \ No newline at end of file 23 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts1/radioButton/saRadiogroup.js
1 -  
2 -/**  
3 - * saRadiogroup指令  
4 - * 属性如下:  
5 - * model(必须):独立作用域,外部绑定的一个值,如:ctrl.timeTableManageForForm.isEnableDisTemplate  
6 - * dicgroup(必须):关联的字典数据type(TODO:以后增加其他数据源)  
7 - * name(必须):控件的名字  
8 - * required(可选):是否要用required验证  
9 - * disabled(可选):标示单选框是否可选  
10 - *  
11 - */  
12 -angular.module('ScheduleApp').directive("saRadiogroup", [function() {  
13 - /**  
14 - * 使用字典数据的单选按钮组的指令。  
15 - * 指令名称:truefalse-Dic  
16 - */  
17 - return {  
18 - restrict: 'E',  
19 - templateUrl: '/pages/scheduleApp/module/common/dts1/radioButton/saRadiogroupTemplate.html',  
20 - scope: {  
21 - model: "="  
22 - },  
23 - controllerAs: "$saRadiogroupCtrl",  
24 - bindToController: true,  
25 - controller: function($scope) {  
26 - //$scope["model"] = {selectedOption: null};  
27 - //console.log("controller");  
28 - //console.log("controller:" + $scope["model"]);  
29 -  
30 - var self = this;  
31 - self.$$data = null; // 内部数据  
32 - },  
33 -  
34 - /**  
35 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
36 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
37 - * @param tElem  
38 - * @param tAttrs  
39 - * @returns {{pre: Function, post: Function}}  
40 - */  
41 - compile: function(tElem, tAttrs) {  
42 - // 获取属性  
43 - var $dicgroup_attr = tAttrs["dicgroup"]; // 关联的字典数据type  
44 - var $name_attr = tAttrs["name"]; // 控件的名字  
45 - var $required_attr = tAttrs["required"]; // 是否要用required验证  
46 - var $disabled_attr = tAttrs["disabled"]; // 标示单选框是否可选  
47 -  
48 - // controlAs名字  
49 - var ctrlAs = "$saRadiogroupCtrl";  
50 -  
51 - // 如果有required属性,添加angularjs required验证  
52 - if ($required_attr != undefined) {  
53 - tElem.find("input").attr("required", "");  
54 - }  
55 -  
56 - return {  
57 - pre: function(scope, element, attr) {  
58 -  
59 - },  
60 -  
61 - /**  
62 - * 相当于link函数。  
63 - * @param scope  
64 - * @param element  
65 - * @param attr  
66 - */  
67 - post: function(scope, element, attr) {  
68 - //console.log("link");  
69 - //console.log("link:" + scope.model);  
70 - //scope["model"] = {selectedOption: null};  
71 -  
72 - if ($name_attr) {  
73 - scope[ctrlAs].nv = $name_attr;  
74 - }  
75 -  
76 - if ($disabled_attr) {  
77 - scope[ctrlAs].disabled = true;  
78 - }  
79 - if ($dicgroup_attr) {  
80 - var obj = dictionaryUtils.getByGroup($dicgroup_attr);  
81 - scope[ctrlAs].$$data = obj;  
82 - // 处理 scope["dic"] key值  
83 - scope[ctrlAs].dicvalueCalcu = function(value) {  
84 - if (value == "true") {  
85 - //console.log(value);  
86 - return true;  
87 - } else if (value == "false") {  
88 - //console.log(value);  
89 - return false;  
90 - } else {  
91 - return value;  
92 - }  
93 - };  
94 - }  
95 - }  
96 - };  
97 - }  
98 - };  
99 -}]); 1 +
  2 +/**
  3 + * saRadiogroup指令
  4 + * 属性如下:
  5 + * model(必须):独立作用域,外部绑定的一个值,如:ctrl.timeTableManageForForm.isEnableDisTemplate
  6 + * dicgroup(必须):关联的字典数据type(TODO:以后增加其他数据源)
  7 + * name(必须):控件的名字
  8 + * required(可选):是否要用required验证
  9 + * disabled(可选):标示单选框是否可选
  10 + *
  11 + */
  12 +angular.module('ScheduleApp').directive("saRadiogroup", [function() {
  13 + /**
  14 + * 使用字典数据的单选按钮组的指令。
  15 + * 指令名称:truefalse-Dic
  16 + */
  17 + return {
  18 + restrict: 'E',
  19 + templateUrl: '/pages/scheduleApp/module/common/dts1/radioButton/saRadiogroupTemplate.html',
  20 + scope: {
  21 + model: "="
  22 + },
  23 + controllerAs: "$saRadiogroupCtrl",
  24 + bindToController: true,
  25 + controller: function($scope) {
  26 + //$scope["model"] = {selectedOption: null};
  27 + //console.log("controller");
  28 + //console.log("controller:" + $scope["model"]);
  29 +
  30 + var self = this;
  31 + self.$$data = null; // 内部数据
  32 + },
  33 +
  34 + /**
  35 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  36 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  37 + * @param tElem
  38 + * @param tAttrs
  39 + * @returns {{pre: Function, post: Function}}
  40 + */
  41 + compile: function(tElem, tAttrs) {
  42 + // 获取属性
  43 + var $dicgroup_attr = tAttrs["dicgroup"]; // 关联的字典数据type
  44 + var $name_attr = tAttrs["name"]; // 控件的名字
  45 + var $required_attr = tAttrs["required"]; // 是否要用required验证
  46 + var $disabled_attr = tAttrs["disabled"]; // 标示单选框是否可选
  47 +
  48 + // controlAs名字
  49 + var ctrlAs = "$saRadiogroupCtrl";
  50 +
  51 + // 如果有required属性,添加angularjs required验证
  52 + if ($required_attr != undefined) {
  53 + tElem.find("input").attr("required", "");
  54 + }
  55 +
  56 + return {
  57 + pre: function(scope, element, attr) {
  58 +
  59 + },
  60 +
  61 + /**
  62 + * 相当于link函数。
  63 + * @param scope
  64 + * @param element
  65 + * @param attr
  66 + */
  67 + post: function(scope, element, attr) {
  68 + //console.log("link");
  69 + //console.log("link:" + scope.model);
  70 + //scope["model"] = {selectedOption: null};
  71 +
  72 + if ($name_attr) {
  73 + scope[ctrlAs].nv = $name_attr;
  74 + }
  75 +
  76 + if ($disabled_attr) {
  77 + scope[ctrlAs].disabled = true;
  78 + }
  79 + if ($dicgroup_attr) {
  80 + var obj = dictionaryUtils.getByGroup($dicgroup_attr);
  81 + scope[ctrlAs].$$data = obj;
  82 + // 处理 scope["dic"] key值
  83 + scope[ctrlAs].dicvalueCalcu = function(value) {
  84 + if (value == "true") {
  85 + //console.log(value);
  86 + return true;
  87 + } else if (value == "false") {
  88 + //console.log(value);
  89 + return false;
  90 + } else {
  91 + return value;
  92 + }
  93 + };
  94 + }
  95 + }
  96 + };
  97 + }
  98 + };
  99 +}]);
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/saSelect.js
1 -  
2 -angular.module('ScheduleApp').directive("saSelect", ['$timeout', function($timeout) {  
3 - return {  
4 - restrict: 'E',  
5 - templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelectTemplate.html',  
6 - scope: {  
7 - model: "="  
8 - },  
9 - controllerAs: "$saSelectCtrl",  
10 - bindToController: true,  
11 - controller: function() {  
12 - var self = this;  
13 - self.datas = []; // 关联的字典数据,内部格式 {code:{值},name:{名字}}  
14 - },  
15 - /**  
16 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
17 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
18 - * @param tElem  
19 - * @param tAttrs  
20 - * @returns {{pre: Function, post: Function}}  
21 - */  
22 - compile: function(tElem, tAttrs) {  
23 - // 确定是否使用angularjs required验证  
24 - // 属性 required  
25 - // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加  
26 - var required_attr = tAttrs["required"];  
27 - if (required_attr) {  
28 - if (required_attr == "true") {  
29 - // 添加required属性指令  
30 - tElem.find("ui-select").attr("required", "");  
31 - } else {  
32 - // 不等于true,不添加required属性指令  
33 - }  
34 - } else {  
35 - // 不添加required属性指令  
36 - }  
37 -  
38 - //console.log("saSelect" + ":compile = >" + tElem.html());  
39 -  
40 - return {  
41 - pre: function(scope, element, attr) {  
42 - // TODO:  
43 - },  
44 - /**  
45 - * 相当于link函数。  
46 - *  
47 - * 重要属性如下:  
48 - * model 是绑定外部值。  
49 - * dicgroup 字典组的类型  
50 - * name input name属性值  
51 - */  
52 - post: function(scope, element, attr) {  
53 - // 1、获取属性  
54 - var dicgroup_attr = attr['dicgroup']; // 字典组的类型  
55 - var name_attr = attr['name']; // input name属性值  
56 - var dicname_attr = attr['dicname']; // model关联的字典名字段  
57 - var codename_attr = attr['codename']; // model关联的字典值字段  
58 - var placeholder_attr = attr['placeholder']; // select placeholder提示  
59 -  
60 - // 系统的字典对象,使用dictionaryUtils类获取  
61 - var origin_dicgroup;  
62 - var dic_key; // 字典key  
63 -  
64 - if (dicgroup_attr) { // 赋值指定的字典数据  
65 - origin_dicgroup = dictionaryUtils.getByGroup(dicgroup_attr);  
66 - for (dic_key in origin_dicgroup) {  
67 - var data = {}; // 重新组合的字典元素对象  
68 - if (dic_key == "true")  
69 - data.code = true;  
70 - else  
71 - data.code = dic_key;  
72 - data.name = origin_dicgroup[dic_key];  
73 - scope["$saSelectCtrl"].datas.push(data);  
74 - }  
75 - }  
76 -  
77 - if (name_attr) {  
78 - scope["$saSelectCtrl"].nv = name_attr;  
79 - }  
80 - if (placeholder_attr) {  
81 - scope["$saSelectCtrl"].ph = placeholder_attr;  
82 - }  
83 -  
84 - scope["$saSelectCtrl"].select = function($item) {  
85 - if (codename_attr) {  
86 - scope["$saSelectCtrl"].model[codename_attr] = $item.code;  
87 - }  
88 - if (dicname_attr) {  
89 - scope["$saSelectCtrl"].model[dicname_attr] = $item.name;  
90 - }  
91 - };  
92 -  
93 - scope["$saSelectCtrl"].remove = function() {  
94 - if (codename_attr) {  
95 - scope["$saSelectCtrl"].model[codename_attr] = null;  
96 - }  
97 - if (dicname_attr) {  
98 - scope["$saSelectCtrl"].model[dicname_attr] = null;  
99 - }  
100 - scope["$saSelectCtrl"].cmodel = null;  
101 - };  
102 -  
103 - $timeout(function() {  
104 - // 创建内部使用的绑定对象  
105 - var model_code = scope["$saSelectCtrl"].model[codename_attr];  
106 - scope["$saSelectCtrl"].cmodel = model_code;  
107 - }, 0);  
108 - }  
109 - }  
110 - }  
111 - };  
112 -}]); 1 +
  2 +angular.module('ScheduleApp').directive("saSelect", ['$timeout', function($timeout) {
  3 + return {
  4 + restrict: 'E',
  5 + templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelectTemplate.html',
  6 + scope: {
  7 + model: "="
  8 + },
  9 + controllerAs: "$saSelectCtrl",
  10 + bindToController: true,
  11 + controller: function() {
  12 + var self = this;
  13 + self.datas = []; // 关联的字典数据,内部格式 {code:{值},name:{名字}}
  14 + },
  15 + /**
  16 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  17 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  18 + * @param tElem
  19 + * @param tAttrs
  20 + * @returns {{pre: Function, post: Function}}
  21 + */
  22 + compile: function(tElem, tAttrs) {
  23 + // 确定是否使用angularjs required验证
  24 + // 属性 required
  25 + // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加
  26 + var required_attr = tAttrs["required"];
  27 + if (required_attr) {
  28 + if (required_attr == "true") {
  29 + // 添加required属性指令
  30 + tElem.find("ui-select").attr("required", "");
  31 + } else {
  32 + // 不等于true,不添加required属性指令
  33 + }
  34 + } else {
  35 + // 不添加required属性指令
  36 + }
  37 +
  38 + //console.log("saSelect" + ":compile = >" + tElem.html());
  39 +
  40 + return {
  41 + pre: function(scope, element, attr) {
  42 + // TODO:
  43 + },
  44 + /**
  45 + * 相当于link函数。
  46 + *
  47 + * 重要属性如下:
  48 + * model 是绑定外部值。
  49 + * dicgroup 字典组的类型
  50 + * name input name属性值
  51 + */
  52 + post: function(scope, element, attr) {
  53 + // 1、获取属性
  54 + var dicgroup_attr = attr['dicgroup']; // 字典组的类型
  55 + var name_attr = attr['name']; // input name属性值
  56 + var dicname_attr = attr['dicname']; // model关联的字典名字段
  57 + var codename_attr = attr['codename']; // model关联的字典值字段
  58 + var placeholder_attr = attr['placeholder']; // select placeholder提示
  59 +
  60 + // 系统的字典对象,使用dictionaryUtils类获取
  61 + var origin_dicgroup;
  62 + var dic_key; // 字典key
  63 +
  64 + if (dicgroup_attr) { // 赋值指定的字典数据
  65 + origin_dicgroup = dictionaryUtils.getByGroup(dicgroup_attr);
  66 + for (dic_key in origin_dicgroup) {
  67 + var data = {}; // 重新组合的字典元素对象
  68 + if (dic_key == "true")
  69 + data.code = true;
  70 + else
  71 + data.code = dic_key;
  72 + data.name = origin_dicgroup[dic_key];
  73 + scope["$saSelectCtrl"].datas.push(data);
  74 + }
  75 + }
  76 +
  77 + if (name_attr) {
  78 + scope["$saSelectCtrl"].nv = name_attr;
  79 + }
  80 + if (placeholder_attr) {
  81 + scope["$saSelectCtrl"].ph = placeholder_attr;
  82 + }
  83 +
  84 + scope["$saSelectCtrl"].select = function($item) {
  85 + if (codename_attr) {
  86 + scope["$saSelectCtrl"].model[codename_attr] = $item.code;
  87 + }
  88 + if (dicname_attr) {
  89 + scope["$saSelectCtrl"].model[dicname_attr] = $item.name;
  90 + }
  91 + };
  92 +
  93 + scope["$saSelectCtrl"].remove = function() {
  94 + if (codename_attr) {
  95 + scope["$saSelectCtrl"].model[codename_attr] = null;
  96 + }
  97 + if (dicname_attr) {
  98 + scope["$saSelectCtrl"].model[dicname_attr] = null;
  99 + }
  100 + scope["$saSelectCtrl"].cmodel = null;
  101 + };
  102 +
  103 + $timeout(function() {
  104 + // 创建内部使用的绑定对象
  105 + var model_code = scope["$saSelectCtrl"].model[codename_attr];
  106 + scope["$saSelectCtrl"].cmodel = model_code;
  107 + }, 0);
  108 + }
  109 + }
  110 + }
  111 + };
  112 +}]);
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/saSelect2.js
1 -  
2 -  
3 -angular.module('ScheduleApp').directive("saSelect2", [  
4 - '$timeout', '$$SearchInfoService_g',  
5 - function($timeout, $$searchInfoService_g) {  
6 - return {  
7 - restrict: 'E',  
8 - templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect2Template.html',  
9 - scope: {  
10 - model: "=" // 独立作用域,关联外部的模型对象  
11 - },  
12 - controllerAs: "$saSelectCtrl",  
13 - bindToController: true,  
14 - controller: function($scope) {  
15 - var self = this;  
16 - self.$$data = []; // 内部关联的数据  
17 - },  
18 - /**  
19 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
20 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
21 - * @param tElem  
22 - * @param tAttrs  
23 - * @returns {{pre: Function, post: Function}}  
24 - */  
25 - compile: function(tElem, tAttrs) {  
26 - // 1、获取此阶段使用的属性  
27 - var $required_attr = tAttrs["required"]; // 用于和表单验证连接,指定成required="true"才有效。  
28 -  
29 - // 2、处理属性  
30 -  
31 - // 确定是否使用angularjs required验证  
32 - // 属性 required  
33 - // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加  
34 - if ($required_attr) {  
35 - if ($required_attr == "true") {  
36 - // 添加required属性指令  
37 - tElem.find("ui-select").attr("required", "");  
38 - } else {  
39 - // 不等于true,不添加required属性指令  
40 - }  
41 - } else {  
42 - // 不添加required属性指令  
43 - }  
44 -  
45 - //console.log("saSelect" + ":compile = >" + tElem.html());  
46 -  
47 - return {  
48 - pre: function(scope, element, attr) {  
49 - // TODO:  
50 - },  
51 - /**  
52 - * 相当于link函数。  
53 - *  
54 - * 重要属性如下:  
55 - * model 是绑定外部值。  
56 - * dicgroup 字典组的类型  
57 - * name input name属性值  
58 - */  
59 - post: function(scope, element, attr) {  
60 - // 1、获取此阶段使用的属性  
61 - var $name_attr = attr["name"]; // 表单验证时需要的名字  
62 - var $type_attr = attr["type"]; // 关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加  
63 - var $modelcolname1_attr = attr["modelcolname1"]; // 关联的模型字段名字1(一般应该是编码字段)  
64 - var $modelcolname2_attr = attr["modelcolname2"]; // 关联的模型字段名字2(一般应该是名字字段)  
65 - var $datacolname1_attr = attr["datacolname1"]; // 内部数据对应的字段名字1(与模型字段1对应)  
66 - var $datacolname2_attr = attr["datacolname2"]; // 内部数据对应的字段名字2(与模型字段2对应)  
67 - var $showcolname_attr = attr["showcolname"]; // 下拉框显示的内部数据字段名  
68 - var $placeholder_attr = attr["placeholder"]; // select placeholder字符串描述  
69 -  
70 - // 2、处理属性、转换成$saSelectCtrl内部使用的属性  
71 - if ($name_attr) {  
72 - scope["$saSelectCtrl"].$name_attr = $name_attr;  
73 - }  
74 - if ($placeholder_attr) {  
75 - scope["$saSelectCtrl"].$placeholder_attr = $placeholder_attr;  
76 - }  
77 - if ($showcolname_attr) {  
78 - scope["$saSelectCtrl"].$showcolname_attr = $showcolname_attr;  
79 - }  
80 -  
81 - // 2-1、添加内部方法,根据type值,改变$$data的值  
82 - scope["$saSelectCtrl"].$$internal_data_change_fn = function() {  
83 - // 根据type属性动态载入数据  
84 - if ($type_attr) {  
85 - $$searchInfoService_g[$type_attr].list(  
86 - {type: "all"},  
87 - function(result) {  
88 - scope["$saSelectCtrl"].$$data = [];  
89 - for (var i = 0; i < result.length; i ++) {  
90 - var data = {}; // data是result的一部分属性集合,根据配置来确定  
91 - if ($datacolname1_attr) {  
92 - data[$datacolname1_attr] = result[i][$datacolname1_attr];  
93 - }  
94 - if ($datacolname2_attr) {  
95 - data[$datacolname2_attr] = result[i][$datacolname2_attr];  
96 - }  
97 - if ($showcolname_attr) {  
98 - // 动态添加基于名字的拼音  
99 - data[$showcolname_attr] = result[i][$showcolname_attr];  
100 - if (data[$showcolname_attr]) {  
101 - data["fullChars"] = pinyin.getFullChars(result[i][$showcolname_attr]).toUpperCase(); // 全拼  
102 - data["camelChars"] = pinyin.getCamelChars(result[i][$showcolname_attr]); // 简拼  
103 - }  
104 - }  
105 - if (data["fullChars"])  
106 - scope["$saSelectCtrl"].$$data.push(data);  
107 - }  
108 - },  
109 - function(result) {  
110 -  
111 - }  
112 - );  
113 - }  
114 - };  
115 -  
116 - // 3、选择、删除事件映射模型和内部数据对应的字段  
117 - scope["$saSelectCtrl"].$select_fn_attr = function($item) {  
118 - if ($modelcolname1_attr && $datacolname1_attr) {  
119 - scope["$saSelectCtrl"].model[$modelcolname1_attr] = $item[$datacolname1_attr];  
120 - }  
121 - if ($modelcolname2_attr && $datacolname2_attr) {  
122 - scope["$saSelectCtrl"].model[$modelcolname2_attr] = $item[$datacolname2_attr];  
123 - }  
124 - };  
125 - scope["$saSelectCtrl"].$remove_fn_attr = function() {  
126 - if ($modelcolname1_attr) {  
127 - scope["$saSelectCtrl"].model[$modelcolname1_attr] = null;  
128 - }  
129 - if ($modelcolname2_attr) {  
130 - scope["$saSelectCtrl"].model[$modelcolname2_attr] = null;  
131 - }  
132 - scope["$saSelectCtrl"].$$cmodel = null; // 内部模型清空  
133 -  
134 - scope["$saSelectCtrl"].$$internal_data_change_fn();  
135 - };  
136 -  
137 - // 4、搜索事件  
138 - scope["$saSelectCtrl"].$refreshdata_fn_attr = function($search) {  
139 - //var fullChars = pinyin.getFullChars($search).toUpperCase();  
140 - //var camelChars = pinyin.getCamelChars($search);  
141 - //  
142 - //console.log(fullChars + " " + camelChars);  
143 - // TODO:事件暂时没用,放着以后再说  
144 - };  
145 -  
146 - // 5、全部载入后,输入的  
147 - $timeout(function() {  
148 - // 创建内部使用的绑定对象,用于确认选中那个值  
149 - scope["$saSelectCtrl"].$$cmodel = scope["$saSelectCtrl"].model[$modelcolname1_attr];  
150 -  
151 - scope["$saSelectCtrl"].$$internal_data_change_fn();  
152 - }, 0);  
153 - }  
154 - }  
155 - }  
156 - };  
157 - }  
158 -]);  
159 - 1 +
  2 +
  3 +angular.module('ScheduleApp').directive("saSelect2", [
  4 + '$timeout', '$$SearchInfoService_g',
  5 + function($timeout, $$searchInfoService_g) {
  6 + return {
  7 + restrict: 'E',
  8 + templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect2Template.html',
  9 + scope: {
  10 + model: "=" // 独立作用域,关联外部的模型对象
  11 + },
  12 + controllerAs: "$saSelectCtrl",
  13 + bindToController: true,
  14 + controller: function($scope) {
  15 + var self = this;
  16 + self.$$data = []; // 内部关联的数据
  17 + },
  18 + /**
  19 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  20 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  21 + * @param tElem
  22 + * @param tAttrs
  23 + * @returns {{pre: Function, post: Function}}
  24 + */
  25 + compile: function(tElem, tAttrs) {
  26 + // 1、获取此阶段使用的属性
  27 + var $required_attr = tAttrs["required"]; // 用于和表单验证连接,指定成required="true"才有效。
  28 +
  29 + // 2、处理属性
  30 +
  31 + // 确定是否使用angularjs required验证
  32 + // 属性 required
  33 + // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加
  34 + if ($required_attr) {
  35 + if ($required_attr == "true") {
  36 + // 添加required属性指令
  37 + tElem.find("ui-select").attr("required", "");
  38 + } else {
  39 + // 不等于true,不添加required属性指令
  40 + }
  41 + } else {
  42 + // 不添加required属性指令
  43 + }
  44 +
  45 + //console.log("saSelect" + ":compile = >" + tElem.html());
  46 +
  47 + return {
  48 + pre: function(scope, element, attr) {
  49 + // TODO:
  50 + },
  51 + /**
  52 + * 相当于link函数。
  53 + *
  54 + * 重要属性如下:
  55 + * model 是绑定外部值。
  56 + * dicgroup 字典组的类型
  57 + * name input name属性值
  58 + */
  59 + post: function(scope, element, attr) {
  60 + // 1、获取此阶段使用的属性
  61 + var $name_attr = attr["name"]; // 表单验证时需要的名字
  62 + var $type_attr = attr["type"]; // 关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加
  63 + var $modelcolname1_attr = attr["modelcolname1"]; // 关联的模型字段名字1(一般应该是编码字段)
  64 + var $modelcolname2_attr = attr["modelcolname2"]; // 关联的模型字段名字2(一般应该是名字字段)
  65 + var $datacolname1_attr = attr["datacolname1"]; // 内部数据对应的字段名字1(与模型字段1对应)
  66 + var $datacolname2_attr = attr["datacolname2"]; // 内部数据对应的字段名字2(与模型字段2对应)
  67 + var $showcolname_attr = attr["showcolname"]; // 下拉框显示的内部数据字段名
  68 + var $placeholder_attr = attr["placeholder"]; // select placeholder字符串描述
  69 +
  70 + // 2、处理属性、转换成$saSelectCtrl内部使用的属性
  71 + if ($name_attr) {
  72 + scope["$saSelectCtrl"].$name_attr = $name_attr;
  73 + }
  74 + if ($placeholder_attr) {
  75 + scope["$saSelectCtrl"].$placeholder_attr = $placeholder_attr;
  76 + }
  77 + if ($showcolname_attr) {
  78 + scope["$saSelectCtrl"].$showcolname_attr = $showcolname_attr;
  79 + }
  80 +
  81 + // 2-1、添加内部方法,根据type值,改变$$data的值
  82 + scope["$saSelectCtrl"].$$internal_data_change_fn = function() {
  83 + // 根据type属性动态载入数据
  84 + if ($type_attr) {
  85 + $$searchInfoService_g[$type_attr].list(
  86 + {type: "all"},
  87 + function(result) {
  88 + scope["$saSelectCtrl"].$$data = [];
  89 + for (var i = 0; i < result.length; i ++) {
  90 + var data = {}; // data是result的一部分属性集合,根据配置来确定
  91 + if ($datacolname1_attr) {
  92 + data[$datacolname1_attr] = result[i][$datacolname1_attr];
  93 + }
  94 + if ($datacolname2_attr) {
  95 + data[$datacolname2_attr] = result[i][$datacolname2_attr];
  96 + }
  97 + if ($showcolname_attr) {
  98 + // 动态添加基于名字的拼音
  99 + data[$showcolname_attr] = result[i][$showcolname_attr];
  100 + if (data[$showcolname_attr]) {
  101 + data["fullChars"] = pinyin.getFullChars(result[i][$showcolname_attr]).toUpperCase(); // 全拼
  102 + data["camelChars"] = pinyin.getCamelChars(result[i][$showcolname_attr]); // 简拼
  103 + }
  104 + }
  105 + if (data["fullChars"])
  106 + scope["$saSelectCtrl"].$$data.push(data);
  107 + }
  108 + },
  109 + function(result) {
  110 +
  111 + }
  112 + );
  113 + }
  114 + };
  115 +
  116 + // 3、选择、删除事件映射模型和内部数据对应的字段
  117 + scope["$saSelectCtrl"].$select_fn_attr = function($item) {
  118 + if ($modelcolname1_attr && $datacolname1_attr) {
  119 + scope["$saSelectCtrl"].model[$modelcolname1_attr] = $item[$datacolname1_attr];
  120 + }
  121 + if ($modelcolname2_attr && $datacolname2_attr) {
  122 + scope["$saSelectCtrl"].model[$modelcolname2_attr] = $item[$datacolname2_attr];
  123 + }
  124 + };
  125 + scope["$saSelectCtrl"].$remove_fn_attr = function() {
  126 + if ($modelcolname1_attr) {
  127 + scope["$saSelectCtrl"].model[$modelcolname1_attr] = null;
  128 + }
  129 + if ($modelcolname2_attr) {
  130 + scope["$saSelectCtrl"].model[$modelcolname2_attr] = null;
  131 + }
  132 + scope["$saSelectCtrl"].$$cmodel = null; // 内部模型清空
  133 +
  134 + scope["$saSelectCtrl"].$$internal_data_change_fn();
  135 + };
  136 +
  137 + // 4、搜索事件
  138 + scope["$saSelectCtrl"].$refreshdata_fn_attr = function($search) {
  139 + //var fullChars = pinyin.getFullChars($search).toUpperCase();
  140 + //var camelChars = pinyin.getCamelChars($search);
  141 + //
  142 + //console.log(fullChars + " " + camelChars);
  143 + // TODO:事件暂时没用,放着以后再说
  144 + };
  145 +
  146 + // 5、全部载入后,输入的
  147 + $timeout(function() {
  148 + // 创建内部使用的绑定对象,用于确认选中那个值
  149 + scope["$saSelectCtrl"].$$cmodel = scope["$saSelectCtrl"].model[$modelcolname1_attr];
  150 +
  151 + scope["$saSelectCtrl"].$$internal_data_change_fn();
  152 + }, 0);
  153 + }
  154 + }
  155 + }
  156 + };
  157 + }
  158 +]);
  159 +
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/saSelect3.js
1 -  
2 -  
3 -  
4 -/**  
5 - * saSelect3指令  
6 - * 属性如下:  
7 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
8 - * name(必须):控件的名字  
9 - * placeholder(可选):占位符字符串  
10 - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}  
11 - * dcname(必须):绑定的model字段名,如:dcname=xl.id  
12 - * icname(必须):内部与之对应的字段名,如:icname=code  
13 - * dcname2(可选):其他需要赋值的model字段名2,如:dcname2=xl.name  
14 - * icname2(可选):内部与之对应的字段名2,如:icname2=name  
15 - * dcname3(可选):其他需要赋值的model字段名3,如:dcname2=xl.name  
16 - * icname3(可选):内部与之对应的字段名3,如:icname2=name  
17 - * icnames(必须):用于用于显示,以及简评处理的内部数据字段,如:icnames=name  
18 - * required(可选):是否要用required验证  
19 - * datatype(必须):业务数据类型,有字典类型,动态数据类型,暂时写的死点  
20 - * mlp(可选):是否多级属性(这里假设外部model如果多级,内部model也是多级)  
21 - *  
22 - * 高级属性:  
23 - * dataassociate(可选):数据源是否关联属性(内部数据随外部指定的参数变化而变化)  
24 - * dataparam(可选):数据源关联的外部参数对象  
25 - *  
26 - */  
27 -angular.module('ScheduleApp').directive("saSelect3", [  
28 - '$timeout',  
29 - '$$SearchInfoService_g',  
30 - function($timeout, $$searchInfoService_g) {  
31 - return {  
32 - restrict: 'E',  
33 - templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect3Template.html',  
34 - scope: {  
35 - model: "=" // 独立作用域,关联外部的模型object  
36 - },  
37 - controllerAs: "$saSelectCtrl",  
38 - bindToController: true,  
39 - controller: function($scope) {  
40 - var self = this;  
41 - self.$$data = []; // ui-select显示用的数据源  
42 - self.$$data_real= []; // 内部真实的数据源  
43 - },  
44 -  
45 - /**  
46 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
47 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
48 - * @param tElem  
49 - * @param tAttrs  
50 - * @returns {{pre: Function, post: Function}}  
51 - */  
52 - compile: function(tElem, tAttrs) {  
53 - // 获取所有的属性  
54 - var $name_attr = tAttrs["name"]; // 控件的名字  
55 - var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字  
56 - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名  
57 - var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名  
58 - var $dcname2_attr = tAttrs["dcname2"]; // 其他需要赋值的model字段名2  
59 - var $icname2_attr = tAttrs["icname2"]; // 内部与之对应的字段名2  
60 - var $dcname3_attr = tAttrs["dcname3"]; // 其他需要赋值的model字段名3  
61 - var $icname3_attr = tAttrs["icname3"]; // 内部与之对应的字段名3  
62 -  
63 - var $icname_s_attr = tAttrs["icnames"]; // 用于用于显示,以及简评处理的内部数据字段  
64 - var $datatype_attr = tAttrs["datatype"]; // 内部业务数据类型  
65 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
66 - var $mlp_attr = tAttrs["mlp"]; // 是否多级属性  
67 - var $dataassociate_attr = tAttrs["dataassociate"]; // 数据源是否关联属性  
68 -  
69 - // controlAs名字  
70 - var ctrlAs = "$saSelectCtrl";  
71 -  
72 - // 数据源初始化标志  
73 - var $$data_init = false;  
74 - // 如果有required属性,添加angularjs required验证  
75 - if ($required_attr != undefined) {  
76 - tElem.find("ui-select").attr("required", "");  
77 - }  
78 -  
79 - // 由于有的属性是多级的如xl.name,所以要在compile阶段重写属性绑定属性定义  
80 - // 原来的设置:{{$select.selected[$saSelectCtrl.$icname_s]}}  
81 - tElem.find("ui-select-match").html("{{$select.selected" + "." + $icname_s_attr + "}}");  
82 - // 原来的设置:item[$saSelectCtrl.$icname] as item in $saSelectCtrl.$$data  
83 - tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data");  
84 - // 原来的设置:item[$saSelectCtrl.$icname_s]  
85 - tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $icname_s_attr);  
86 - // 原来的设置:{{$saSelectCtrl.$name}}  
87 - tElem.find("ui-select").attr("name", $name_attr);  
88 - // 原来的设置:{{$saSelectCtrl.$placeholder}}  
89 - tElem.find("ui-select-match").attr("placeholder", $placeholder_attr);  
90 -  
91 - return {  
92 - pre: function(scope, element, attr) {  
93 - // TODO:  
94 - },  
95 - /**  
96 - * 相当于link函数。  
97 - * @param scope  
98 - * @param element  
99 - * @param attr  
100 - */  
101 - post: function(scope, element, attr) {  
102 - // 添加选中事件处理函数  
103 - scope[ctrlAs].$$internal_select_fn = function($item) {  
104 - if ($dcname_attr && $icname_attr) {  
105 - if ($mlp_attr) {  
106 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");  
107 - } else {  
108 - scope[ctrlAs].model[$dcname_attr] = $item[$icname_attr];  
109 - }  
110 - }  
111 - if ($dcname2_attr && $icname2_attr) {  
112 - if ($mlp_attr) {  
113 - eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = $item" + "." + $icname2_attr + ";");  
114 - } else {  
115 - scope[ctrlAs].model[$dcname2_attr] = $item[$icname2_attr];  
116 - }  
117 - }  
118 - if ($dcname3_attr && $icname3_attr) {  
119 - if ($mlp_attr) {  
120 - eval("scope[ctrlAs].model" + "." + $dcname3_attr + " = $item" + "." + $icname3_attr + ";");  
121 - } else {  
122 - scope[ctrlAs].model[$dcname3_attr] = $item[$icname3_attr];  
123 - }  
124 - }  
125 - };  
126 -  
127 - // 删除选中事件处理函数  
128 - scope[ctrlAs].$$internal_remove_fn = function() {  
129 - scope[ctrlAs].$$internalmodel = undefined;  
130 - if ($mlp_attr) {  
131 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");  
132 - } else {  
133 - scope[ctrlAs].model[$dcname_attr] = undefined;  
134 - }  
135 -  
136 - if ($dcname2_attr) {  
137 - if ($mlp_attr) {  
138 - eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = undefined;");  
139 - } else {  
140 - scope[ctrlAs].model[$dcname2_attr] = undefined;  
141 - }  
142 - }  
143 - if ($dcname3_attr) {  
144 - if ($mlp_attr) {  
145 - eval("scope[ctrlAs].model" + "." + $dcname3_attr + " = undefined;");  
146 - } else {  
147 - scope[ctrlAs].model[$dcname3_attr] = undefined;  
148 - }  
149 - }  
150 - };  
151 -  
152 - /**  
153 - * 内部方法,读取字典数据作为数据源。  
154 - * @param dicgroup 字典类型,如:gsType  
155 - * @param ccol 代码字段名  
156 - * @param ncol 名字字段名  
157 - */  
158 - scope[ctrlAs].$$internal_dic_data = function(dicgroup, ccol, ncol) {  
159 - var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);  
160 - var dic_key; // 字典key  
161 - // 清空内部数据  
162 - scope[ctrlAs].$$data_real = [];  
163 - for (dic_key in origin_dicgroup) {  
164 - var data = {}; // 重新组合的字典元素对象  
165 - if (dic_key == "true")  
166 - data[ccol] = true;  
167 - else  
168 - data[ccol] = dic_key;  
169 - data[ncol] = origin_dicgroup[dic_key];  
170 - scope[ctrlAs].$$data_real.push(data);  
171 - }  
172 - // 这里直接将$$data_real数据深拷贝到$$data  
173 - angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data);  
174 -  
175 - console.log(scope[ctrlAs].$$data);  
176 - };  
177 -  
178 - /**  
179 - * TODO:这个方法有性能问题,result一多就会卡一卡,之后再解决把  
180 - * 内部方法,读取字典数据作为数据源。  
181 - * @param result 原始数据  
182 - * @param dcvalue 传入的关联数据  
183 - */  
184 - scope[ctrlAs].$$internal_other_data = function(result, dcvalue) {  
185 - console.log("start=" + dcvalue);  
186 - // 清空内部数据  
187 - scope[ctrlAs].$$data_real = [];  
188 - scope[ctrlAs].$$data = [];  
189 - for (var i = 0; i < result.length; i ++) {  
190 - if ($icname_s_attr) {  
191 - if ($mlp_attr) {  
192 - if (eval("result[i]" + "." + $icname_s_attr)) {  
193 - // 全拼  
194 - result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $icname_s_attr)).toUpperCase();  
195 - // 简拼  
196 - result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $icname_s_attr));  
197 - }  
198 - } else {  
199 - if (result[i][$icname_s_attr]) {  
200 - // 全拼  
201 - result[i]["fullChars"] = pinyin.getFullChars(result[i][$icname_s_attr]).toUpperCase();  
202 - // 简拼  
203 - result[i]["camelChars"] = pinyin.getCamelChars(result[i][$icname_s_attr]);  
204 - }  
205 - }  
206 - }  
207 -  
208 - if (result[i]["fullChars"]) { // 有拼音的加入数据源  
209 - scope[ctrlAs].$$data_real.push(result[i]);  
210 - }  
211 -  
212 - }  
213 - //console.log("start2");  
214 -  
215 - // 数量太大取前10条记录作为显示  
216 - if (angular.isArray(scope[ctrlAs].$$data_real)) {  
217 - // 先迭代循环查找已经传过来的值  
218 - if (scope[ctrlAs].$$data_real.length > 0) {  
219 - if (dcvalue) {  
220 - for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {  
221 - if (scope[ctrlAs].$$data_real[j][$icname_attr] == dcvalue) {  
222 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[j]));  
223 - break;  
224 - }  
225 - }  
226 - }  
227 - }  
228 - // 在插入剩余的数据  
229 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
230 - if (scope[ctrlAs].$$data.length < 10) {  
231 - if ($mlp_attr) {  
232 - if (eval("scope[ctrlAs].$$data_real[k]" + "." + $icname_attr + " != dcvalue")) {  
233 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
234 - }  
235 - } else {  
236 - if (scope[ctrlAs].$$data_real[k][$icname_attr] != dcvalue) {  
237 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
238 - }  
239 - }  
240 - } else {  
241 - break;  
242 - }  
243 - }  
244 - }  
245 -  
246 - //console.log("end");  
247 - };  
248 -  
249 - /**  
250 - * 判定一个对象是否为空对象。  
251 - * @param Obj  
252 - */  
253 - scope[ctrlAs].$$internal_isEmpty_obj = function(obj) {  
254 - console.log(typeof obj);  
255 -  
256 - if (typeof obj === "object" && !(obj instanceof Array)) {  
257 - for (var prop in obj) {  
258 - if (obj.hasOwnProperty(prop)) {  
259 - return false;  
260 - }  
261 - }  
262 - return true;  
263 - } else {  
264 - throw "必须是对象";  
265 - }  
266 - };  
267 -  
268 - // 刷新数据  
269 - scope[ctrlAs].$$internal_refresh_fn = function(search) {  
270 - // 绑定的model字段值,此属性是绑定属性,只能在link阶段获取  
271 - var $dcvalue_attr = attr["dcvalue"];  
272 -  
273 - console.log("刷新数据:" + $dcvalue_attr);  
274 -  
275 - if (!$$data_init) { // 只初始化$$data_real一次,重新载入页面才能重新初始化  
276 - if (dictionaryUtils.getByGroup($datatype_attr)) { // 判定是否字典类型数据源  
277 - scope[ctrlAs].$$internal_dic_data(  
278 - $datatype_attr, $icname_attr, $icname_s_attr);  
279 - if ($dcvalue_attr) {  
280 - scope[ctrlAs].$$internalmodel = $dcvalue_attr;  
281 - }  
282 - } else { // 非字典类型数据源  
283 - if (!$dataassociate_attr) {  
284 - $$searchInfoService_g[$datatype_attr].list(  
285 - {type: "all"},  
286 - function(result) {  
287 - //console.log("ok:" + $datatype_attr);  
288 - scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr);  
289 - //console.log("ok2:" + $datatype_attr);  
290 - if ($dcvalue_attr) {  
291 - scope[ctrlAs].$$internalmodel = $dcvalue_attr;  
292 - }  
293 -  
294 - $$data_init = true;  
295 - },  
296 - function(result) {  
297 -  
298 - }  
299 - );  
300 - }  
301 - }  
302 - }  
303 -  
304 - if ($$data_init) {  
305 - if (search && search != "") { // 有search值  
306 - if (!dictionaryUtils.getByGroup($datatype_attr)) { // 其他数据源  
307 - // 处理search  
308 - console.log("search:" + search);  
309 -  
310 - scope[ctrlAs].$$data = [];  
311 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
312 - var upTerm = search.toUpperCase();  
313 - if (scope[ctrlAs].$$data.length < 10) {  
314 - if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1  
315 - || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) {  
316 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
317 - }  
318 - } else {  
319 - break;  
320 - }  
321 - }  
322 - }  
323 - }  
324 -  
325 - }  
326 -  
327 - };  
328 -  
329 -  
330 -  
331 -  
332 -  
333 -  
334 -  
335 -  
336 -  
337 -  
338 - // TODO:  
339 -  
340 - // dom全部载入后调用  
341 - $timeout(function() {  
342 - console.log("dom全部载入后调用");  
343 - }, 0);  
344 - // 监控dcvalue model值变换  
345 - attr.$observe("dcvalue", function(value) {  
346 - console.log("监控dc1 model值变换:" + value);  
347 - scope[ctrlAs].$$internalmodel = value;  
348 - }  
349 - );  
350 - // 监控获取数据参数变换  
351 - attr.$observe("dataparam", function(value) {  
352 - // 判定是否空对象  
353 - console.log(value);  
354 - var obj = JSON.parse(value);  
355 - var $dcvalue_attr = attr["dcvalue"];  
356 - if (!scope[ctrlAs].$$internal_isEmpty_obj(obj)) {  
357 - console.log("dataparam:" + obj);  
358 -  
359 - //  
360 -  
361 - obj["type"] = "all";  
362 -  
363 - $$data_init = false;  
364 - $$searchInfoService_g[$datatype_attr].list(  
365 - obj,  
366 - function(result) {  
367 - //console.log("ok:" + $datatype_attr);  
368 - scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr);  
369 - //console.log("ok2:" + $datatype_attr);  
370 - if ($dcvalue_attr) {  
371 - scope[ctrlAs].$$internalmodel = $dcvalue_attr;  
372 - }  
373 -  
374 - $$data_init = true;  
375 - },  
376 - function(result) {  
377 -  
378 - }  
379 - );  
380 - }  
381 - }  
382 - );  
383 - }  
384 - };  
385 - }  
386 - };  
387 -  
388 - }  
389 -]);  
390 - 1 +
  2 +
  3 +
  4 +/**
  5 + * saSelect3指令
  6 + * 属性如下:
  7 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  8 + * name(必须):控件的名字
  9 + * placeholder(可选):占位符字符串
  10 + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}
  11 + * dcname(必须):绑定的model字段名,如:dcname=xl.id
  12 + * icname(必须):内部与之对应的字段名,如:icname=code
  13 + * dcname2(可选):其他需要赋值的model字段名2,如:dcname2=xl.name
  14 + * icname2(可选):内部与之对应的字段名2,如:icname2=name
  15 + * dcname3(可选):其他需要赋值的model字段名3,如:dcname2=xl.name
  16 + * icname3(可选):内部与之对应的字段名3,如:icname2=name
  17 + * icnames(必须):用于用于显示,以及简评处理的内部数据字段,如:icnames=name
  18 + * required(可选):是否要用required验证
  19 + * datatype(必须):业务数据类型,有字典类型,动态数据类型,暂时写的死点
  20 + * mlp(可选):是否多级属性(这里假设外部model如果多级,内部model也是多级)
  21 + *
  22 + * 高级属性:
  23 + * dataassociate(可选):数据源是否关联属性(内部数据随外部指定的参数变化而变化)
  24 + * dataparam(可选):数据源关联的外部参数对象
  25 + *
  26 + */
  27 +angular.module('ScheduleApp').directive("saSelect3", [
  28 + '$timeout',
  29 + '$$SearchInfoService_g',
  30 + function($timeout, $$searchInfoService_g) {
  31 + return {
  32 + restrict: 'E',
  33 + templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect3Template.html',
  34 + scope: {
  35 + model: "=" // 独立作用域,关联外部的模型object
  36 + },
  37 + controllerAs: "$saSelectCtrl",
  38 + bindToController: true,
  39 + controller: function($scope) {
  40 + var self = this;
  41 + self.$$data = []; // ui-select显示用的数据源
  42 + self.$$data_real= []; // 内部真实的数据源
  43 + },
  44 +
  45 + /**
  46 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  47 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  48 + * @param tElem
  49 + * @param tAttrs
  50 + * @returns {{pre: Function, post: Function}}
  51 + */
  52 + compile: function(tElem, tAttrs) {
  53 + // 获取所有的属性
  54 + var $name_attr = tAttrs["name"]; // 控件的名字
  55 + var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字
  56 + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名
  57 + var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名
  58 + var $dcname2_attr = tAttrs["dcname2"]; // 其他需要赋值的model字段名2
  59 + var $icname2_attr = tAttrs["icname2"]; // 内部与之对应的字段名2
  60 + var $dcname3_attr = tAttrs["dcname3"]; // 其他需要赋值的model字段名3
  61 + var $icname3_attr = tAttrs["icname3"]; // 内部与之对应的字段名3
  62 +
  63 + var $icname_s_attr = tAttrs["icnames"]; // 用于用于显示,以及简评处理的内部数据字段
  64 + var $datatype_attr = tAttrs["datatype"]; // 内部业务数据类型
  65 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  66 + var $mlp_attr = tAttrs["mlp"]; // 是否多级属性
  67 + var $dataassociate_attr = tAttrs["dataassociate"]; // 数据源是否关联属性
  68 +
  69 + // controlAs名字
  70 + var ctrlAs = "$saSelectCtrl";
  71 +
  72 + // 数据源初始化标志
  73 + var $$data_init = false;
  74 + // 如果有required属性,添加angularjs required验证
  75 + if ($required_attr != undefined) {
  76 + tElem.find("ui-select").attr("required", "");
  77 + }
  78 +
  79 + // 由于有的属性是多级的如xl.name,所以要在compile阶段重写属性绑定属性定义
  80 + // 原来的设置:{{$select.selected[$saSelectCtrl.$icname_s]}}
  81 + tElem.find("ui-select-match").html("{{$select.selected" + "." + $icname_s_attr + "}}");
  82 + // 原来的设置:item[$saSelectCtrl.$icname] as item in $saSelectCtrl.$$data
  83 + tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data");
  84 + // 原来的设置:item[$saSelectCtrl.$icname_s]
  85 + tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $icname_s_attr);
  86 + // 原来的设置:{{$saSelectCtrl.$name}}
  87 + tElem.find("ui-select").attr("name", $name_attr);
  88 + // 原来的设置:{{$saSelectCtrl.$placeholder}}
  89 + tElem.find("ui-select-match").attr("placeholder", $placeholder_attr);
  90 +
  91 + return {
  92 + pre: function(scope, element, attr) {
  93 + // TODO:
  94 + },
  95 + /**
  96 + * 相当于link函数。
  97 + * @param scope
  98 + * @param element
  99 + * @param attr
  100 + */
  101 + post: function(scope, element, attr) {
  102 + // 添加选中事件处理函数
  103 + scope[ctrlAs].$$internal_select_fn = function($item) {
  104 + if ($dcname_attr && $icname_attr) {
  105 + if ($mlp_attr) {
  106 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");
  107 + } else {
  108 + scope[ctrlAs].model[$dcname_attr] = $item[$icname_attr];
  109 + }
  110 + }
  111 + if ($dcname2_attr && $icname2_attr) {
  112 + if ($mlp_attr) {
  113 + eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = $item" + "." + $icname2_attr + ";");
  114 + } else {
  115 + scope[ctrlAs].model[$dcname2_attr] = $item[$icname2_attr];
  116 + }
  117 + }
  118 + if ($dcname3_attr && $icname3_attr) {
  119 + if ($mlp_attr) {
  120 + eval("scope[ctrlAs].model" + "." + $dcname3_attr + " = $item" + "." + $icname3_attr + ";");
  121 + } else {
  122 + scope[ctrlAs].model[$dcname3_attr] = $item[$icname3_attr];
  123 + }
  124 + }
  125 + };
  126 +
  127 + // 删除选中事件处理函数
  128 + scope[ctrlAs].$$internal_remove_fn = function() {
  129 + scope[ctrlAs].$$internalmodel = undefined;
  130 + if ($mlp_attr) {
  131 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");
  132 + } else {
  133 + scope[ctrlAs].model[$dcname_attr] = undefined;
  134 + }
  135 +
  136 + if ($dcname2_attr) {
  137 + if ($mlp_attr) {
  138 + eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = undefined;");
  139 + } else {
  140 + scope[ctrlAs].model[$dcname2_attr] = undefined;
  141 + }
  142 + }
  143 + if ($dcname3_attr) {
  144 + if ($mlp_attr) {
  145 + eval("scope[ctrlAs].model" + "." + $dcname3_attr + " = undefined;");
  146 + } else {
  147 + scope[ctrlAs].model[$dcname3_attr] = undefined;
  148 + }
  149 + }
  150 + };
  151 +
  152 + /**
  153 + * 内部方法,读取字典数据作为数据源。
  154 + * @param dicgroup 字典类型,如:gsType
  155 + * @param ccol 代码字段名
  156 + * @param ncol 名字字段名
  157 + */
  158 + scope[ctrlAs].$$internal_dic_data = function(dicgroup, ccol, ncol) {
  159 + var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);
  160 + var dic_key; // 字典key
  161 + // 清空内部数据
  162 + scope[ctrlAs].$$data_real = [];
  163 + for (dic_key in origin_dicgroup) {
  164 + var data = {}; // 重新组合的字典元素对象
  165 + if (dic_key == "true")
  166 + data[ccol] = true;
  167 + else
  168 + data[ccol] = dic_key;
  169 + data[ncol] = origin_dicgroup[dic_key];
  170 + scope[ctrlAs].$$data_real.push(data);
  171 + }
  172 + // 这里直接将$$data_real数据深拷贝到$$data
  173 + angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data);
  174 +
  175 + console.log(scope[ctrlAs].$$data);
  176 + };
  177 +
  178 + /**
  179 + * TODO:这个方法有性能问题,result一多就会卡一卡,之后再解决把
  180 + * 内部方法,读取字典数据作为数据源。
  181 + * @param result 原始数据
  182 + * @param dcvalue 传入的关联数据
  183 + */
  184 + scope[ctrlAs].$$internal_other_data = function(result, dcvalue) {
  185 + console.log("start=" + dcvalue);
  186 + // 清空内部数据
  187 + scope[ctrlAs].$$data_real = [];
  188 + scope[ctrlAs].$$data = [];
  189 + for (var i = 0; i < result.length; i ++) {
  190 + if ($icname_s_attr) {
  191 + if ($mlp_attr) {
  192 + if (eval("result[i]" + "." + $icname_s_attr)) {
  193 + // 全拼
  194 + result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $icname_s_attr)).toUpperCase();
  195 + // 简拼
  196 + result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $icname_s_attr));
  197 + }
  198 + } else {
  199 + if (result[i][$icname_s_attr]) {
  200 + // 全拼
  201 + result[i]["fullChars"] = pinyin.getFullChars(result[i][$icname_s_attr]).toUpperCase();
  202 + // 简拼
  203 + result[i]["camelChars"] = pinyin.getCamelChars(result[i][$icname_s_attr]);
  204 + }
  205 + }
  206 + }
  207 +
  208 + if (result[i]["fullChars"]) { // 有拼音的加入数据源
  209 + scope[ctrlAs].$$data_real.push(result[i]);
  210 + }
  211 +
  212 + }
  213 + //console.log("start2");
  214 +
  215 + // 数量太大取前10条记录作为显示
  216 + if (angular.isArray(scope[ctrlAs].$$data_real)) {
  217 + // 先迭代循环查找已经传过来的值
  218 + if (scope[ctrlAs].$$data_real.length > 0) {
  219 + if (dcvalue) {
  220 + for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {
  221 + if (scope[ctrlAs].$$data_real[j][$icname_attr] == dcvalue) {
  222 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[j]));
  223 + break;
  224 + }
  225 + }
  226 + }
  227 + }
  228 + // 在插入剩余的数据
  229 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  230 + if (scope[ctrlAs].$$data.length < 10) {
  231 + if ($mlp_attr) {
  232 + if (eval("scope[ctrlAs].$$data_real[k]" + "." + $icname_attr + " != dcvalue")) {
  233 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  234 + }
  235 + } else {
  236 + if (scope[ctrlAs].$$data_real[k][$icname_attr] != dcvalue) {
  237 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  238 + }
  239 + }
  240 + } else {
  241 + break;
  242 + }
  243 + }
  244 + }
  245 +
  246 + //console.log("end");
  247 + };
  248 +
  249 + /**
  250 + * 判定一个对象是否为空对象。
  251 + * @param Obj
  252 + */
  253 + scope[ctrlAs].$$internal_isEmpty_obj = function(obj) {
  254 + console.log(typeof obj);
  255 +
  256 + if (typeof obj === "object" && !(obj instanceof Array)) {
  257 + for (var prop in obj) {
  258 + if (obj.hasOwnProperty(prop)) {
  259 + return false;
  260 + }
  261 + }
  262 + return true;
  263 + } else {
  264 + throw "必须是对象";
  265 + }
  266 + };
  267 +
  268 + // 刷新数据
  269 + scope[ctrlAs].$$internal_refresh_fn = function(search) {
  270 + // 绑定的model字段值,此属性是绑定属性,只能在link阶段获取
  271 + var $dcvalue_attr = attr["dcvalue"];
  272 +
  273 + console.log("刷新数据:" + $dcvalue_attr);
  274 +
  275 + if (!$$data_init) { // 只初始化$$data_real一次,重新载入页面才能重新初始化
  276 + if (dictionaryUtils.getByGroup($datatype_attr)) { // 判定是否字典类型数据源
  277 + scope[ctrlAs].$$internal_dic_data(
  278 + $datatype_attr, $icname_attr, $icname_s_attr);
  279 + if ($dcvalue_attr) {
  280 + scope[ctrlAs].$$internalmodel = $dcvalue_attr;
  281 + }
  282 + } else { // 非字典类型数据源
  283 + if (!$dataassociate_attr) {
  284 + $$searchInfoService_g[$datatype_attr].list(
  285 + {type: "all"},
  286 + function(result) {
  287 + //console.log("ok:" + $datatype_attr);
  288 + scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr);
  289 + //console.log("ok2:" + $datatype_attr);
  290 + if ($dcvalue_attr) {
  291 + scope[ctrlAs].$$internalmodel = $dcvalue_attr;
  292 + }
  293 +
  294 + $$data_init = true;
  295 + },
  296 + function(result) {
  297 +
  298 + }
  299 + );
  300 + }
  301 + }
  302 + }
  303 +
  304 + if ($$data_init) {
  305 + if (search && search != "") { // 有search值
  306 + if (!dictionaryUtils.getByGroup($datatype_attr)) { // 其他数据源
  307 + // 处理search
  308 + console.log("search:" + search);
  309 +
  310 + scope[ctrlAs].$$data = [];
  311 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  312 + var upTerm = search.toUpperCase();
  313 + if (scope[ctrlAs].$$data.length < 10) {
  314 + if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1
  315 + || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) {
  316 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  317 + }
  318 + } else {
  319 + break;
  320 + }
  321 + }
  322 + }
  323 + }
  324 +
  325 + }
  326 +
  327 + };
  328 +
  329 +
  330 +
  331 +
  332 +
  333 +
  334 +
  335 +
  336 +
  337 +
  338 + // TODO:
  339 +
  340 + // dom全部载入后调用
  341 + $timeout(function() {
  342 + console.log("dom全部载入后调用");
  343 + }, 0);
  344 + // 监控dcvalue model值变换
  345 + attr.$observe("dcvalue", function(value) {
  346 + console.log("监控dc1 model值变换:" + value);
  347 + scope[ctrlAs].$$internalmodel = value;
  348 + }
  349 + );
  350 + // 监控获取数据参数变换
  351 + attr.$observe("dataparam", function(value) {
  352 + // 判定是否空对象
  353 + console.log(value);
  354 + var obj = JSON.parse(value);
  355 + var $dcvalue_attr = attr["dcvalue"];
  356 + if (!scope[ctrlAs].$$internal_isEmpty_obj(obj)) {
  357 + console.log("dataparam:" + obj);
  358 +
  359 + //
  360 +
  361 + obj["type"] = "all";
  362 +
  363 + $$data_init = false;
  364 + $$searchInfoService_g[$datatype_attr].list(
  365 + obj,
  366 + function(result) {
  367 + //console.log("ok:" + $datatype_attr);
  368 + scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr);
  369 + //console.log("ok2:" + $datatype_attr);
  370 + if ($dcvalue_attr) {
  371 + scope[ctrlAs].$$internalmodel = $dcvalue_attr;
  372 + }
  373 +
  374 + $$data_init = true;
  375 + },
  376 + function(result) {
  377 +
  378 + }
  379 + );
  380 + }
  381 + }
  382 + );
  383 + }
  384 + };
  385 + }
  386 + };
  387 +
  388 + }
  389 +]);
  390 +
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/saSelect4.js
1 -/**  
2 - * saSelect4指令,封装angular-ui-select控件,并添加相应的业务。  
3 - * name(必须):控件的名字  
4 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
5 - * placeholder(可选):输入框占位符字符串  
6 - *  
7 - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}  
8 - * dcname(必须):绑定的model字段名,如:dcname=xl.id  
9 - * icname(必须):内部与之对应的字段名,如:icname=code  
10 - *  
11 - * cmaps(可选):model其他字段和内部数据字段名映射,如:{{ {'xl.id' : 'id', 'xl.name' : 'name'} | json}}  
12 - * dsparams(必须):内部数据源查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}  
13 - * dscol(必须):内部显示的信息(暂时用内部字段),如:dscol=name  
14 - * required(可选):是否要用required验证  
15 - */  
16 -angular.module('ScheduleApp').directive('saSelect4', [  
17 - '$timeout',  
18 - '$$SearchInfoService_g',  
19 - function($timeout, $$searchInfoService_g) {  
20 - return {  
21 - restrict: 'E',  
22 - templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect4Template.html',  
23 - scope: {  
24 - model: "=" // 独立作用域,关联外部的模型object  
25 - },  
26 - controllerAs: "$saSelectCtrl",  
27 - bindToController: true,  
28 - controller: function($scope) {  
29 - var self = this;  
30 - self.$$data = []; // ui-select显示用的数据  
31 - self.$$data_real = []; // 内部真实的数据  
32 -  
33 - // saSelect4组件的ng-model,用于外部绑定验证等操作  
34 - self.$$internalmodel = undefined;  
35 -  
36 - self.$$internal_select_value = undefined; // 选中的值  
37 - },  
38 -  
39 - /**  
40 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
41 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
42 - * @param tElem  
43 - * @param tAttrs  
44 - * @returns {{pre: Function, post: Function}}  
45 - */  
46 - compile: function(tElem, tAttrs) {  
47 - // 获取属性  
48 - var $name_attr = tAttrs["name"]; // 控件的名字  
49 - var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字  
50 -  
51 - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名  
52 - var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名  
53 -  
54 - var $cmaps_attr = tAttrs["cmaps"]; // model其他字段和内部数据字段名映射  
55 - var $dscol_attr = tAttrs["dscol"]; // 内部显示的信息  
56 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
57 -  
58 - // controlAs名字  
59 - var ctrlAs = "$saSelectCtrl";  
60 -  
61 - // 验证属性  
62 - if (!$name_attr) {  
63 - throw new error("name属性必须填写");  
64 - }  
65 - if (!$dcname_attr) {  
66 - throw new error("dcname属性必须填写");  
67 - }  
68 - if (!$icname_attr) {  
69 - throw new error("icname属性必须填写");  
70 - }  
71 - if (!$dscol_attr) {  
72 - throw new error("dscol属性必须填写");  
73 - }  
74 -  
75 - // 动态设置dom  
76 - // dom required 属性  
77 - if ($required_attr != undefined) {  
78 - tElem.find("div").attr("required", "");  
79 - }  
80 - // dom placeholder 属性  
81 - tElem.find("ui-select-match").attr("placeholder", $placeholder_attr);  
82 - // dom dscol 属性  
83 - tElem.find("ui-select-match").html("{{$select.selected" + "." + $dscol_attr + "}}");  
84 - tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $dscol_attr);  
85 - // dom icname 属性  
86 - tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data");  
87 - // dom name 属性  
88 - tElem.find("div").attr("name", $name_attr);  
89 -  
90 - return {  
91 - pre: function(scope, element, attr) {  
92 - // TODO:  
93 - },  
94 -  
95 - /**  
96 - * 相当于link函数。  
97 - * @param scope  
98 - * @param element  
99 - * @param attr  
100 - */  
101 - post: function(scope, element, attr) {  
102 -  
103 - // 添加选中事件处理函数  
104 - scope[ctrlAs].$$internal_select_fn = function($item) {  
105 - if ($dcname_attr && $icname_attr) {  
106 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");  
107 - }  
108 -  
109 - if ($cmaps_attr) {  
110 - for (var mc in $cmaps_attr) { // model的字段名:内部数据源对应字段名  
111 - var ic = $cmaps_attr[mc]; // 内部数据源对应字段  
112 - eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");  
113 - }  
114 - }  
115 - };  
116 -  
117 - // 删除选中事件处理函数  
118 - scope[ctrlAs].$$internal_remove_fn = function() {  
119 - scope[ctrlAs].$$internal_select_value = undefined;  
120 - if ($dcname_attr) {  
121 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");  
122 - }  
123 -  
124 - if ($cmaps_attr) {  
125 - var mc; // model的字段名  
126 - for (mc in $cmaps_attr) {  
127 - eval("scope[ctrlAs].model" + "." + mc + " = undefined;");  
128 - }  
129 - }  
130 - scope[ctrlAs].$$internal_validate_model();  
131 - };  
132 -  
133 - // 刷新数据  
134 - scope[ctrlAs].$$internal_refresh_fn = function(search) {  
135 - if (search && search != "") { // 有search值  
136 - // 处理search  
137 - console.log("search:" + search);  
138 -  
139 - scope[ctrlAs].$$data = [];  
140 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
141 - var upTerm = search.toUpperCase();  
142 - if (scope[ctrlAs].$$data.length < 10) {  
143 - if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1  
144 - || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) {  
145 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
146 - }  
147 - } else {  
148 - break;  
149 - }  
150 - }  
151 - }  
152 - };  
153 -  
154 - /**  
155 - * 验证内部数据,更新外部model  
156 - */  
157 - scope[ctrlAs].$$internal_validate_model = function() {  
158 - if (scope[ctrlAs].$$internal_select_value) {  
159 - var select_value_temp = scope[ctrlAs].$$internal_select_value;  
160 - if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) {  
161 - var obj;  
162 - for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {  
163 - if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) {  
164 - obj = angular.copy(scope[ctrlAs].$$data_real[j]);  
165 - break;  
166 - }  
167 - }  
168 - if (obj) { // 在data中判定有没有  
169 - for (var k = 0; k < scope[ctrlAs].$$data.length; k++) {  
170 - if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) {  
171 - obj = undefined;  
172 - break;  
173 - }  
174 - }  
175 - if (obj) {  
176 - scope[ctrlAs].$$data.push(obj);  
177 - }  
178 - // 更新内部model,用于外部验证  
179 - // 内部model的值暂时随意,以后再改  
180 - scope[ctrlAs].$$internalmodel = {desc: "ok"};  
181 - } else {  
182 - scope[ctrlAs].$$internalmodel = undefined;  
183 - }  
184 -  
185 - } else {  
186 - scope[ctrlAs].$$internalmodel = undefined;  
187 - }  
188 -  
189 - } else {  
190 - scope[ctrlAs].$$internalmodel = undefined;  
191 - }  
192 - };  
193 -  
194 - /**  
195 - * 内部方法,读取字典数据作为数据源。  
196 - * @param atype ajax查询类型  
197 - * @param ajaxparamobj 查询参数对象  
198 - */  
199 - scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) {  
200 - ajaxparamobj.type = 'all';  
201 - $$searchInfoService_g[atype].list(  
202 - ajaxparamobj,  
203 - function(result) {  
204 - console.log("$$internal_ajax_data result");  
205 -  
206 - // 清空内部数据  
207 - scope[ctrlAs].$$data_real = [];  
208 - scope[ctrlAs].$$data = [];  
209 -  
210 - // result中添加拼音数据,注意:这里要求result返回对象数组  
211 - for (var i = 0; i < result.length; i ++) {  
212 - if ($dscol_attr) {  
213 - if (eval("result[i]" + "." + $dscol_attr)) {  
214 - // 全拼  
215 - result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $dscol_attr)).toUpperCase();  
216 - // 简拼  
217 - result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $dscol_attr));  
218 - }  
219 - }  
220 -  
221 - if (result[i]["fullChars"]) { // 有拼音的加入数据源  
222 - scope[ctrlAs].$$data_real.push(result[i]);  
223 - }  
224 -  
225 - }  
226 -  
227 - // 数据量太大,取10条记录显示  
228 - if (angular.isArray(scope[ctrlAs].$$data_real)) {  
229 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
230 - if (scope[ctrlAs].$$data.length < 10) {  
231 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
232 - } else {  
233 - break;  
234 - }  
235 - }  
236 - }  
237 -  
238 - scope[ctrlAs].$$internal_validate_model();  
239 - },  
240 - function(result) {  
241 -  
242 - }  
243 - );  
244 - };  
245 -  
246 - /**  
247 - * 内部方法,读取字典数据作为数据源。  
248 - * @param dictype 字典类型,如:gsType  
249 - */  
250 - scope[ctrlAs].$$internal_dic_data = function(dictype) {  
251 - if (!dictionaryUtils.getByGroup(dictype)) {  
252 - throw new error("字典数据不窜在=" + dictype);  
253 - }  
254 -  
255 - // 清空内部数据  
256 - scope[ctrlAs].$$data_real = [];  
257 - scope[ctrlAs].$$data = [];  
258 -  
259 - var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);  
260 - var dic_key; // 字典key  
261 -  
262 - for (dic_key in origin_dicgroup) {  
263 - var data = {}; // 重新组合的字典元素对象  
264 - if (dic_key == "true")  
265 - data[$icname_attr] = true;  
266 - else  
267 - data[$icname_attr] = dic_key;  
268 - data[$dscol_attr] = origin_dicgroup[dic_key];  
269 - scope[ctrlAs].$$data_real.push(data);  
270 - }  
271 - // 这里直接将$$data_real数据深拷贝到$$data  
272 - angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data);  
273 - scope[ctrlAs].$$internal_validate_model();  
274 - };  
275 -  
276 - attr.$observe("dsparams", function(value) {  
277 - if (value && value != "") {  
278 - var obj = JSON.parse(value);  
279 - console.log("observe 监控 dsparams=" + obj);  
280 -  
281 - // dsparams格式如下:  
282 - // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'}  
283 -  
284 - if (obj.type == 'dic') {  
285 - scope[ctrlAs].$$internal_dic_data(obj.param);  
286 -  
287 - } else if (obj.type == 'ajax') {  
288 - scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param);  
289 - } else {  
290 - throw new Error("dsparams参数格式异常=" + obj);  
291 - }  
292 -  
293 - }  
294 -  
295 - });  
296 -  
297 - // 监控model绑定的dcvalue值变化  
298 - attr.$observe("dcvalue", function(value) {  
299 - if (value && value != "") {  
300 - console.log("observe 监控 dcvalue=" + value);  
301 - scope[ctrlAs].$$internal_select_value = value;  
302 - scope[ctrlAs].$$internal_validate_model();  
303 - }  
304 -  
305 - // 闭包测试  
306 - var obj = {'a':1,'b':2};  
307 - var tfx = scope[ctrlAs].$$test.bind(obj);  
308 - console.log("闭包测试=" + tfx());  
309 - });  
310 -  
311 - scope[ctrlAs].$$test = function() {  
312 - var exp = "this.a + '(' + this.b + ')'";  
313 - console.log("exp=" + exp);  
314 - return eval(exp);  
315 - };  
316 - }  
317 - };  
318 -  
319 - }  
320 -  
321 - };  
322 - } 1 +/**
  2 + * saSelect4指令,封装angular-ui-select控件,并添加相应的业务。
  3 + * name(必须):控件的名字
  4 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  5 + * placeholder(可选):输入框占位符字符串
  6 + *
  7 + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}
  8 + * dcname(必须):绑定的model字段名,如:dcname=xl.id
  9 + * icname(必须):内部与之对应的字段名,如:icname=code
  10 + *
  11 + * cmaps(可选):model其他字段和内部数据字段名映射,如:{{ {'xl.id' : 'id', 'xl.name' : 'name'} | json}}
  12 + * dsparams(必须):内部数据源查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}
  13 + * dscol(必须):内部显示的信息(暂时用内部字段),如:dscol=name
  14 + * required(可选):是否要用required验证
  15 + */
  16 +angular.module('ScheduleApp').directive('saSelect4', [
  17 + '$timeout',
  18 + '$$SearchInfoService_g',
  19 + function($timeout, $$searchInfoService_g) {
  20 + return {
  21 + restrict: 'E',
  22 + templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect4Template.html',
  23 + scope: {
  24 + model: "=" // 独立作用域,关联外部的模型object
  25 + },
  26 + controllerAs: "$saSelectCtrl",
  27 + bindToController: true,
  28 + controller: function($scope) {
  29 + var self = this;
  30 + self.$$data = []; // ui-select显示用的数据
  31 + self.$$data_real = []; // 内部真实的数据
  32 +
  33 + // saSelect4组件的ng-model,用于外部绑定验证等操作
  34 + self.$$internalmodel = undefined;
  35 +
  36 + self.$$internal_select_value = undefined; // 选中的值
  37 + },
  38 +
  39 + /**
  40 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  41 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  42 + * @param tElem
  43 + * @param tAttrs
  44 + * @returns {{pre: Function, post: Function}}
  45 + */
  46 + compile: function(tElem, tAttrs) {
  47 + // 获取属性
  48 + var $name_attr = tAttrs["name"]; // 控件的名字
  49 + var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字
  50 +
  51 + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名
  52 + var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名
  53 +
  54 + var $cmaps_attr = tAttrs["cmaps"]; // model其他字段和内部数据字段名映射
  55 + var $dscol_attr = tAttrs["dscol"]; // 内部显示的信息
  56 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  57 +
  58 + // controlAs名字
  59 + var ctrlAs = "$saSelectCtrl";
  60 +
  61 + // 验证属性
  62 + if (!$name_attr) {
  63 + throw new error("name属性必须填写");
  64 + }
  65 + if (!$dcname_attr) {
  66 + throw new error("dcname属性必须填写");
  67 + }
  68 + if (!$icname_attr) {
  69 + throw new error("icname属性必须填写");
  70 + }
  71 + if (!$dscol_attr) {
  72 + throw new error("dscol属性必须填写");
  73 + }
  74 +
  75 + // 动态设置dom
  76 + // dom required 属性
  77 + if ($required_attr != undefined) {
  78 + tElem.find("div").attr("required", "");
  79 + }
  80 + // dom placeholder 属性
  81 + tElem.find("ui-select-match").attr("placeholder", $placeholder_attr);
  82 + // dom dscol 属性
  83 + tElem.find("ui-select-match").html("{{$select.selected" + "." + $dscol_attr + "}}");
  84 + tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $dscol_attr);
  85 + // dom icname 属性
  86 + tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data");
  87 + // dom name 属性
  88 + tElem.find("div").attr("name", $name_attr);
  89 +
  90 + return {
  91 + pre: function(scope, element, attr) {
  92 + // TODO:
  93 + },
  94 +
  95 + /**
  96 + * 相当于link函数。
  97 + * @param scope
  98 + * @param element
  99 + * @param attr
  100 + */
  101 + post: function(scope, element, attr) {
  102 +
  103 + // 添加选中事件处理函数
  104 + scope[ctrlAs].$$internal_select_fn = function($item) {
  105 + if ($dcname_attr && $icname_attr) {
  106 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");
  107 + }
  108 +
  109 + if ($cmaps_attr) {
  110 + for (var mc in $cmaps_attr) { // model的字段名:内部数据源对应字段名
  111 + var ic = $cmaps_attr[mc]; // 内部数据源对应字段
  112 + eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");
  113 + }
  114 + }
  115 + };
  116 +
  117 + // 删除选中事件处理函数
  118 + scope[ctrlAs].$$internal_remove_fn = function() {
  119 + scope[ctrlAs].$$internal_select_value = undefined;
  120 + if ($dcname_attr) {
  121 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");
  122 + }
  123 +
  124 + if ($cmaps_attr) {
  125 + var mc; // model的字段名
  126 + for (mc in $cmaps_attr) {
  127 + eval("scope[ctrlAs].model" + "." + mc + " = undefined;");
  128 + }
  129 + }
  130 + scope[ctrlAs].$$internal_validate_model();
  131 + };
  132 +
  133 + // 刷新数据
  134 + scope[ctrlAs].$$internal_refresh_fn = function(search) {
  135 + if (search && search != "") { // 有search值
  136 + // 处理search
  137 + console.log("search:" + search);
  138 +
  139 + scope[ctrlAs].$$data = [];
  140 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  141 + var upTerm = search.toUpperCase();
  142 + if (scope[ctrlAs].$$data.length < 10) {
  143 + if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1
  144 + || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) {
  145 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  146 + }
  147 + } else {
  148 + break;
  149 + }
  150 + }
  151 + }
  152 + };
  153 +
  154 + /**
  155 + * 验证内部数据,更新外部model
  156 + */
  157 + scope[ctrlAs].$$internal_validate_model = function() {
  158 + if (scope[ctrlAs].$$internal_select_value) {
  159 + var select_value_temp = scope[ctrlAs].$$internal_select_value;
  160 + if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) {
  161 + var obj;
  162 + for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {
  163 + if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) {
  164 + obj = angular.copy(scope[ctrlAs].$$data_real[j]);
  165 + break;
  166 + }
  167 + }
  168 + if (obj) { // 在data中判定有没有
  169 + for (var k = 0; k < scope[ctrlAs].$$data.length; k++) {
  170 + if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) {
  171 + obj = undefined;
  172 + break;
  173 + }
  174 + }
  175 + if (obj) {
  176 + scope[ctrlAs].$$data.push(obj);
  177 + }
  178 + // 更新内部model,用于外部验证
  179 + // 内部model的值暂时随意,以后再改
  180 + scope[ctrlAs].$$internalmodel = {desc: "ok"};
  181 + } else {
  182 + scope[ctrlAs].$$internalmodel = undefined;
  183 + }
  184 +
  185 + } else {
  186 + scope[ctrlAs].$$internalmodel = undefined;
  187 + }
  188 +
  189 + } else {
  190 + scope[ctrlAs].$$internalmodel = undefined;
  191 + }
  192 + };
  193 +
  194 + /**
  195 + * 内部方法,读取字典数据作为数据源。
  196 + * @param atype ajax查询类型
  197 + * @param ajaxparamobj 查询参数对象
  198 + */
  199 + scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) {
  200 + ajaxparamobj.type = 'all';
  201 + $$searchInfoService_g[atype].list(
  202 + ajaxparamobj,
  203 + function(result) {
  204 + console.log("$$internal_ajax_data result");
  205 +
  206 + // 清空内部数据
  207 + scope[ctrlAs].$$data_real = [];
  208 + scope[ctrlAs].$$data = [];
  209 +
  210 + // result中添加拼音数据,注意:这里要求result返回对象数组
  211 + for (var i = 0; i < result.length; i ++) {
  212 + if ($dscol_attr) {
  213 + if (eval("result[i]" + "." + $dscol_attr)) {
  214 + // 全拼
  215 + result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $dscol_attr)).toUpperCase();
  216 + // 简拼
  217 + result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $dscol_attr));
  218 + }
  219 + }
  220 +
  221 + if (result[i]["fullChars"]) { // 有拼音的加入数据源
  222 + scope[ctrlAs].$$data_real.push(result[i]);
  223 + }
  224 +
  225 + }
  226 +
  227 + // 数据量太大,取10条记录显示
  228 + if (angular.isArray(scope[ctrlAs].$$data_real)) {
  229 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  230 + if (scope[ctrlAs].$$data.length < 10) {
  231 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  232 + } else {
  233 + break;
  234 + }
  235 + }
  236 + }
  237 +
  238 + scope[ctrlAs].$$internal_validate_model();
  239 + },
  240 + function(result) {
  241 +
  242 + }
  243 + );
  244 + };
  245 +
  246 + /**
  247 + * 内部方法,读取字典数据作为数据源。
  248 + * @param dictype 字典类型,如:gsType
  249 + */
  250 + scope[ctrlAs].$$internal_dic_data = function(dictype) {
  251 + if (!dictionaryUtils.getByGroup(dictype)) {
  252 + throw new error("字典数据不窜在=" + dictype);
  253 + }
  254 +
  255 + // 清空内部数据
  256 + scope[ctrlAs].$$data_real = [];
  257 + scope[ctrlAs].$$data = [];
  258 +
  259 + var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);
  260 + var dic_key; // 字典key
  261 +
  262 + for (dic_key in origin_dicgroup) {
  263 + var data = {}; // 重新组合的字典元素对象
  264 + if (dic_key == "true")
  265 + data[$icname_attr] = true;
  266 + else
  267 + data[$icname_attr] = dic_key;
  268 + data[$dscol_attr] = origin_dicgroup[dic_key];
  269 + scope[ctrlAs].$$data_real.push(data);
  270 + }
  271 + // 这里直接将$$data_real数据深拷贝到$$data
  272 + angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data);
  273 + scope[ctrlAs].$$internal_validate_model();
  274 + };
  275 +
  276 + attr.$observe("dsparams", function(value) {
  277 + if (value && value != "") {
  278 + var obj = JSON.parse(value);
  279 + console.log("observe 监控 dsparams=" + obj);
  280 +
  281 + // dsparams格式如下:
  282 + // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'}
  283 +
  284 + if (obj.type == 'dic') {
  285 + scope[ctrlAs].$$internal_dic_data(obj.param);
  286 +
  287 + } else if (obj.type == 'ajax') {
  288 + scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param);
  289 + } else {
  290 + throw new Error("dsparams参数格式异常=" + obj);
  291 + }
  292 +
  293 + }
  294 +
  295 + });
  296 +
  297 + // 监控model绑定的dcvalue值变化
  298 + attr.$observe("dcvalue", function(value) {
  299 + if (value && value != "") {
  300 + console.log("observe 监控 dcvalue=" + value);
  301 + scope[ctrlAs].$$internal_select_value = value;
  302 + scope[ctrlAs].$$internal_validate_model();
  303 + }
  304 +
  305 + // 闭包测试
  306 + var obj = {'a':1,'b':2};
  307 + var tfx = scope[ctrlAs].$$test.bind(obj);
  308 + console.log("闭包测试=" + tfx());
  309 + });
  310 +
  311 + scope[ctrlAs].$$test = function() {
  312 + var exp = "this.a + '(' + this.b + ')'";
  313 + console.log("exp=" + exp);
  314 + return eval(exp);
  315 + };
  316 + }
  317 + };
  318 +
  319 + }
  320 +
  321 + };
  322 + }
323 ]); 323 ]);
324 \ No newline at end of file 324 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/saSelect5.js
1 -/**  
2 - * saSelect5指令,基于简拼查询的select,内部封装angular-ui-select控件,并嵌入相应的业务逻辑。  
3 - * name(必须):控件的名字  
4 - * model(必须):独立作用域,指定一个外部对象模型双向绑定,如:model=ctrl.employeeInfoForSave  
5 - * cmaps(必须):外部对象与指令内部数据对象字段名映射对象字符串,如:{'xl.id' : 'id', 'xl.name' : 'name'}  
6 - * dcname(必须):绑定的model字段名,如:dcname=xl.id  
7 - * icname(必须):内部与之对应的字段名,如:icname=id  
8 - *  
9 - * dsparams(必须):内部数据源查询参数对象,如:{{ {'ttid_eq': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}  
10 - * dsparamsextra(可选):内部数据源查询附加参数对象字符串,如:{'type':'all'}  
11 - * iterobjname(必须):内部数据源迭代的数据变量名,如:iterobjname=item  
12 - * iterobjexp(必须):内部显示用的表达式  
13 - * searchph(必须):查询输入占位符字符串,如:searchph=请输入...  
14 - * searchexp(必须):查询基于的内部数据源的表达式,如:searchexp=this.name+'('+this.code+')'  
15 - *  
16 - * required(可选):是否需要form的required验证  
17 - *  
18 - */  
19 -angular.module('ScheduleApp').directive('saSelect5', [  
20 - '$timeout',  
21 - '$$SearchInfoService_g',  
22 - function($timeout, $$searchInfoService_g) {  
23 - return {  
24 - restrict: 'E',  
25 - templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect5Template.html',  
26 - scope: { // 独立作用域  
27 - model: "=" // 绑定外部对象  
28 - },  
29 - controllerAs: "$saSelectCtrl",  
30 - bindToController: true,  
31 - controller: function($scope) {  
32 - var self = this;  
33 - self.$$data = []; // 内部ui-select显示用数据  
34 - self.$$data_real = []; // 内部保存的实际数据  
35 -  
36 - // myselect组件的ng-model,用于外部绑定验证等操作  
37 - self.$$internalmodel = undefined;  
38 -  
39 - self.$$internal_select_value = undefined; // 选中的值  
40 -  
41 - },  
42 -  
43 - /**  
44 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
45 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
46 - * @param tElem  
47 - * @param tAttrs  
48 - * @returns {{pre: Function, post: Function}}  
49 - */  
50 - compile: function(tElem, tAttrs) {  
51 - // 获取属性,并验证必须按属性  
52 - var $name_attr = tAttrs["name"]; // 控件的名字  
53 - var $cmaps_attr = tAttrs["cmaps"]; // 外部对象与指令内部数据对象字段名映射对象  
54 - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名  
55 - var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名  
56 -  
57 - var $dsparams_attr = tAttrs["dsparams"]; // 内部数据源查询参数对象  
58 - var $dsparamsextra_attr = tAttrs["dsparamsextra"]; // 内部数据源查询附加参数对象字符串  
59 - var $iterobjname_attr = tAttrs["iterobjname"]; // 内部数据源迭代的数据变量名  
60 - var $iterobjexp_attr = tAttrs["iterobjexp"]; // 内部显示用的表达式  
61 - var $searchph_attr = tAttrs["searchph"]; // 查询输入占位符字符串  
62 - var $searchexp_attr = tAttrs["searchexp"]; // 查询基于的内部数据源的表达式  
63 -  
64 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
65 -  
66 - if (!$name_attr) {  
67 - throw new Error("name属性必须填写");  
68 - }  
69 - if (!$cmaps_attr) {  
70 - throw new Error("cmaps属性必须填写")  
71 - }  
72 - if (!$dcname_attr || !$icname_attr) {  
73 - throw new Error("dcname、icname属性必须填写");  
74 - }  
75 - if (!$dsparams_attr) {  
76 - throw new Error("dsparams属性必须填写");  
77 - }  
78 - if (!$iterobjname_attr) {  
79 - throw new Error("iterobjname属性必须填写");  
80 - }  
81 - if (!$iterobjexp_attr) {  
82 - throw new Error("iterobjexp属性必须填写");  
83 - }  
84 - if (!$searchph_attr) {  
85 - throw new Error("searchph属性必须填写");  
86 - }  
87 - if (!$searchexp_attr) {  
88 - throw new Error("searchexp属性必须填写");  
89 - }  
90 -  
91 - // 内部controlAs名字  
92 - var ctrlAs = "$saSelectCtrl";  
93 -  
94 - // 动态设置dom  
95 - // dom,最外层name属性设置  
96 - tElem.find("div:first").attr("name", $name_attr);  
97 - // dom,最外层divrequired属性设置  
98 - if ($required_attr != undefined) {  
99 - tElem.find("div[name=\'" + $name_attr + "\']").attr("required", "");  
100 - }  
101 - // dom,ui-select-match的placeholder属性设定  
102 - tElem.find("ui-select-match").attr("placeholder", $searchph_attr);  
103 - // dom,ui-select-match的内容设定  
104 - var uiSelectMatchHtml = "{{" + ctrlAs + ".$$internal_match_str($select.selected)}}";  
105 - tElem.find("ui-select-match").html(uiSelectMatchHtml);  
106 - // dom,ui-select-choices的repeat属性设定  
107 - var uiSelectChoices_repeatAttr = $iterobjname_attr + "." + $icname_attr + " as " + $iterobjname_attr + " in " + ctrlAs + ".$$data";  
108 - tElem.find("ui-select-choices").attr("repeat", uiSelectChoices_repeatAttr);  
109 - // dom,span ng-bind属性设置,TODO:暂时无法用transclude设置,先用属性设置  
110 - tElem.find("ui-select-choices").html("{{" + $iterobjexp_attr + "}}");  
111 -  
112 - return {  
113 - pre: function (scope, element, attr) {  
114 - // TODO:  
115 - },  
116 -  
117 - /**  
118 - * 相当于link函数。  
119 - * @param scope  
120 - * @param element  
121 - * @param attr  
122 - */  
123 - post: function (scope, element, attr) {  
124 -  
125 - // 添加选中事件处理函数  
126 - scope[ctrlAs].$$internal_select_fn = function($item) {  
127 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");  
128 -  
129 - eval("var obj=" + $cmaps_attr);  
130 - for (var mc in obj) { // model的字段名:内部数据源对应字段名  
131 - var ic = obj[mc]; // 内部数据源对应字段  
132 - eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");  
133 - }  
134 - };  
135 -  
136 - // 删除选中事件处理函数  
137 - scope[ctrlAs].$$internal_remove_fn = function() {  
138 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");  
139 -  
140 - eval("var obj=" + $cmaps_attr);  
141 - var mc; // model的字段名  
142 - for (mc in obj) {  
143 - eval("scope[ctrlAs].model" + "." + mc + " = undefined;");  
144 - }  
145 - };  
146 -  
147 - // 刷新数据  
148 - scope[ctrlAs].$$internal_refresh_fn = function(search) {  
149 - if (search && search != "") { // 有search值  
150 - // 处理search  
151 - console.log("search:" + search);  
152 -  
153 - scope[ctrlAs].$$data = [];  
154 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
155 - var upTerm = search.toUpperCase();  
156 - if (scope[ctrlAs].$$data.length < 10) {  
157 - if (scope[ctrlAs].$$data_real[k].$fullChars.indexOf(upTerm) != -1  
158 - || scope[ctrlAs].$$data_real[k].$camelChars.indexOf(upTerm) != -1  
159 - || scope[ctrlAs].$$data_real[k].$calcu_str.indexOf(upTerm) != -1) {  
160 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
161 - }  
162 - } else {  
163 - break;  
164 - }  
165 - }  
166 - }  
167 - };  
168 -  
169 - /**  
170 - * 验证内部数据,更新外部model  
171 - */  
172 - scope[ctrlAs].$$internal_validate_model = function() {  
173 - if (scope[ctrlAs].$$internal_select_value) {  
174 - var select_value_temp = scope[ctrlAs].$$internal_select_value;  
175 - if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) {  
176 - var obj;  
177 - for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {  
178 - if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) {  
179 - obj = angular.copy(scope[ctrlAs].$$data_real[j]);  
180 - break;  
181 - }  
182 - }  
183 - if (obj) { // 在data中判定有没有  
184 - for (var k = 0; k < scope[ctrlAs].$$data.length; k++) {  
185 - if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) {  
186 - obj = undefined;  
187 - break;  
188 - }  
189 - }  
190 - if (obj) {  
191 - scope[ctrlAs].$$data.push(obj);  
192 - }  
193 - // 更新内部model,用于外部验证  
194 - // 内部model的值暂时随意,以后再改  
195 - scope[ctrlAs].$$internalmodel = {desc: "ok"};  
196 - } else {  
197 - scope[ctrlAs].$$internalmodel = undefined;  
198 - }  
199 -  
200 - } else {  
201 - scope[ctrlAs].$$internalmodel = undefined;  
202 - }  
203 -  
204 - } else {  
205 - scope[ctrlAs].$$internalmodel = undefined;  
206 - }  
207 - };  
208 -  
209 - /**  
210 - * 内部match表达式转换函数,需要外部绑定此函数的上下文。  
211 - * @param context function上下文  
212 - */  
213 - scope[ctrlAs].$$internal_match_str = function (context) {  
214 - var fx = function() {  
215 - try {  
216 - return eval($searchexp_attr);  
217 - } catch (err) {  
218 - //console.log(err);  
219 - return undefined;  
220 - }  
221 -  
222 - };  
223 -  
224 - var str = fx.bind(context)();  
225 - if (str && str != "")  
226 - return str;  
227 - else  
228 - return undefined;  
229 - };  
230 -  
231 - /**  
232 - * 内部方法,读取字典数据作为数据源。  
233 - * @param atype ajax查询类型  
234 - * @param ajaxparamobj 查询参数对象  
235 - */  
236 - scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) {  
237 - // 如果ajaxparamobj为空对象,则表示清空内部选项  
238 - var isEmptyObj = true;  
239 - for (var name in ajaxparamobj) {  
240 - isEmptyObj = false;  
241 - }  
242 - if (isEmptyObj) {  
243 - // 重新创建内部保存的数据  
244 - scope[ctrlAs].$$data_real = [];  
245 - // 重新创建内部ui-select显示用数据,默认取10条记录显示  
246 - scope[ctrlAs].$$data = [];  
247 -  
248 - scope[ctrlAs].$$internal_remove_fn();  
249 - scope[ctrlAs].$$internal_validate_model();  
250 -  
251 - return;  
252 - }  
253 -  
254 - if ($dsparamsextra_attr) { // 合并附加参数  
255 - eval("var extra = " + $dsparamsextra_attr);  
256 - for (var extrakey in extra) {  
257 - ajaxparamobj[extrakey] = extra[extrakey];  
258 - }  
259 - }  
260 -  
261 - $$searchInfoService_g[atype].list(  
262 - ajaxparamobj,  
263 - function(result) {  
264 - console.log("$$internal_ajax_data result");  
265 -  
266 - // 重新创建内部保存的数据  
267 - scope[ctrlAs].$$data_real = [];  
268 - // result中添加拼音数据,注意:这里要求result返回对象数组  
269 - for (var i = 0; i < result.length; i++) {  
270 - // 闭包绑定返回最终查询的值  
271 - var calcu_str = scope[ctrlAs].$$internal_match_str(result[i]);  
272 - if (calcu_str) {  
273 - // 全拼  
274 - result[i]["$fullChars"] = pinyin.getFullChars(calcu_str);  
275 - // 简拼  
276 - result[i]["$camelChars"] = pinyin.getCamelChars(calcu_str);  
277 - // 原值  
278 - result[i]["$calcu_str"] = calcu_str;  
279 -  
280 - scope[ctrlAs].$$data_real.push(result[i]);  
281 - }  
282 - }  
283 -  
284 - // 重新创建内部ui-select显示用数据,默认取10条记录显示  
285 - scope[ctrlAs].$$data = [];  
286 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
287 - if (scope[ctrlAs].$$data.length < 10) {  
288 - scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]);  
289 - } else {  
290 - break;  
291 - }  
292 - }  
293 -  
294 - scope[ctrlAs].$$internal_validate_model();  
295 - },  
296 - function(result) {  
297 - throw new Error("ajax查询出错");  
298 - }  
299 - );  
300 - };  
301 -  
302 - /**  
303 - * 内部方法,读取字典数据作为数据源。  
304 - * @param dictype 字典类型,如:gsType  
305 - */  
306 - scope[ctrlAs].$$internal_dic_data = function(dictype) {  
307 - if (!dictionaryUtils.getByGroup(dictype)) {  
308 - throw new error("字典数据不窜在=" + dictype);  
309 - }  
310 -  
311 - // 重新创建内部保存的数据  
312 - scope[ctrlAs].$$data_real = [];  
313 - var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);  
314 - var dic_key; // 字典key  
315 -  
316 - for (dic_key in origin_dicgroup) {  
317 - var data = {}; // 重新组合的字典元素对象  
318 - if (dic_key == "true")  
319 - data[$icname_attr] = true;  
320 - else  
321 - data[$icname_attr] = dic_key;  
322 - data[$dscol_attr] = origin_dicgroup[dic_key];  
323 - scope[ctrlAs].$$data_real.push(data);  
324 - }  
325 -  
326 - // 重新创建内部ui-select显示用数据,直接复制所有的字典数据  
327 - scope[ctrlAs].$$data = [];  
328 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
329 - scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]);  
330 - }  
331 -  
332 - scope[ctrlAs].$$internal_validate_model();  
333 - };  
334 -  
335 - /**  
336 - * 监控dsparams属性变化  
337 - */  
338 - attr.$observe("dsparams", function(value) {  
339 - if (value && value != "") {  
340 - var obj = JSON.parse(value);  
341 - console.log("saSelect5 监控到dsparams属性变化,old=" + $dsparams_attr + ",new=" + value);  
342 -  
343 - // dsparams格式如下:  
344 - // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'}  
345 -  
346 - if (obj.type == 'dic') {  
347 - scope[ctrlAs].$$internal_dic_data(obj.param);  
348 -  
349 - } else if (obj.type == 'ajax') {  
350 - scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param);  
351 - } else {  
352 - throw new Error("dsparams参数格式异常=" + obj);  
353 - }  
354 -  
355 - }  
356 - });  
357 -  
358 - /**  
359 - * 监控外部模型dcname的值的变化。  
360 - */  
361 - scope.$watch(  
362 - function() {  
363 - return eval("scope." + ctrlAs + ".model" + "." + $dcname_attr);  
364 - },  
365 - function(newValue, oldValue) {  
366 - if (newValue === undefined && oldValue === undefined) {  
367 - // 两侧都是undefined,不处理  
368 -  
369 - } else {  
370 - console.log("saSelect5 监控到外部模型" + $dcname_attr + "属性值变化,old=" + oldValue + ",new=" + newValue);  
371 - scope[ctrlAs].$$internal_select_value = newValue;  
372 - scope[ctrlAs].$$internal_validate_model();  
373 - }  
374 - },  
375 - true  
376 - );  
377 - }  
378 - };  
379 - }  
380 - };  
381 - } 1 +/**
  2 + * saSelect5指令,基于简拼查询的select,内部封装angular-ui-select控件,并嵌入相应的业务逻辑。
  3 + * name(必须):控件的名字
  4 + * model(必须):独立作用域,指定一个外部对象模型双向绑定,如:model=ctrl.employeeInfoForSave
  5 + * cmaps(必须):外部对象与指令内部数据对象字段名映射对象字符串,如:{'xl.id' : 'id', 'xl.name' : 'name'}
  6 + * dcname(必须):绑定的model字段名,如:dcname=xl.id
  7 + * icname(必须):内部与之对应的字段名,如:icname=id
  8 + *
  9 + * dsparams(必须):内部数据源查询参数对象,如:{{ {'ttid_eq': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}
  10 + * dsparamsextra(可选):内部数据源查询附加参数对象字符串,如:{'type':'all'}
  11 + * iterobjname(必须):内部数据源迭代的数据变量名,如:iterobjname=item
  12 + * iterobjexp(必须):内部显示用的表达式
  13 + * searchph(必须):查询输入占位符字符串,如:searchph=请输入...
  14 + * searchexp(必须):查询基于的内部数据源的表达式,如:searchexp=this.name+'('+this.code+')'
  15 + *
  16 + * required(可选):是否需要form的required验证
  17 + *
  18 + */
  19 +angular.module('ScheduleApp').directive('saSelect5', [
  20 + '$timeout',
  21 + '$$SearchInfoService_g',
  22 + function($timeout, $$searchInfoService_g) {
  23 + return {
  24 + restrict: 'E',
  25 + templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect5Template.html',
  26 + scope: { // 独立作用域
  27 + model: "=" // 绑定外部对象
  28 + },
  29 + controllerAs: "$saSelectCtrl",
  30 + bindToController: true,
  31 + controller: function($scope) {
  32 + var self = this;
  33 + self.$$data = []; // 内部ui-select显示用数据
  34 + self.$$data_real = []; // 内部保存的实际数据
  35 +
  36 + // myselect组件的ng-model,用于外部绑定验证等操作
  37 + self.$$internalmodel = undefined;
  38 +
  39 + self.$$internal_select_value = undefined; // 选中的值
  40 +
  41 + },
  42 +
  43 + /**
  44 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  45 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  46 + * @param tElem
  47 + * @param tAttrs
  48 + * @returns {{pre: Function, post: Function}}
  49 + */
  50 + compile: function(tElem, tAttrs) {
  51 + // 获取属性,并验证必须按属性
  52 + var $name_attr = tAttrs["name"]; // 控件的名字
  53 + var $cmaps_attr = tAttrs["cmaps"]; // 外部对象与指令内部数据对象字段名映射对象
  54 + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名
  55 + var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名
  56 +
  57 + var $dsparams_attr = tAttrs["dsparams"]; // 内部数据源查询参数对象
  58 + var $dsparamsextra_attr = tAttrs["dsparamsextra"]; // 内部数据源查询附加参数对象字符串
  59 + var $iterobjname_attr = tAttrs["iterobjname"]; // 内部数据源迭代的数据变量名
  60 + var $iterobjexp_attr = tAttrs["iterobjexp"]; // 内部显示用的表达式
  61 + var $searchph_attr = tAttrs["searchph"]; // 查询输入占位符字符串
  62 + var $searchexp_attr = tAttrs["searchexp"]; // 查询基于的内部数据源的表达式
  63 +
  64 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  65 +
  66 + if (!$name_attr) {
  67 + throw new Error("name属性必须填写");
  68 + }
  69 + if (!$cmaps_attr) {
  70 + throw new Error("cmaps属性必须填写")
  71 + }
  72 + if (!$dcname_attr || !$icname_attr) {
  73 + throw new Error("dcname、icname属性必须填写");
  74 + }
  75 + if (!$dsparams_attr) {
  76 + throw new Error("dsparams属性必须填写");
  77 + }
  78 + if (!$iterobjname_attr) {
  79 + throw new Error("iterobjname属性必须填写");
  80 + }
  81 + if (!$iterobjexp_attr) {
  82 + throw new Error("iterobjexp属性必须填写");
  83 + }
  84 + if (!$searchph_attr) {
  85 + throw new Error("searchph属性必须填写");
  86 + }
  87 + if (!$searchexp_attr) {
  88 + throw new Error("searchexp属性必须填写");
  89 + }
  90 +
  91 + // 内部controlAs名字
  92 + var ctrlAs = "$saSelectCtrl";
  93 +
  94 + // 动态设置dom
  95 + // dom,最外层name属性设置
  96 + tElem.find("div:first").attr("name", $name_attr);
  97 + // dom,最外层divrequired属性设置
  98 + if ($required_attr != undefined) {
  99 + tElem.find("div[name=\'" + $name_attr + "\']").attr("required", "");
  100 + }
  101 + // dom,ui-select-match的placeholder属性设定
  102 + tElem.find("ui-select-match").attr("placeholder", $searchph_attr);
  103 + // dom,ui-select-match的内容设定
  104 + var uiSelectMatchHtml = "{{" + ctrlAs + ".$$internal_match_str($select.selected)}}";
  105 + tElem.find("ui-select-match").html(uiSelectMatchHtml);
  106 + // dom,ui-select-choices的repeat属性设定
  107 + var uiSelectChoices_repeatAttr = $iterobjname_attr + "." + $icname_attr + " as " + $iterobjname_attr + " in " + ctrlAs + ".$$data";
  108 + tElem.find("ui-select-choices").attr("repeat", uiSelectChoices_repeatAttr);
  109 + // dom,span ng-bind属性设置,TODO:暂时无法用transclude设置,先用属性设置
  110 + tElem.find("ui-select-choices").html("{{" + $iterobjexp_attr + "}}");
  111 +
  112 + return {
  113 + pre: function (scope, element, attr) {
  114 + // TODO:
  115 + },
  116 +
  117 + /**
  118 + * 相当于link函数。
  119 + * @param scope
  120 + * @param element
  121 + * @param attr
  122 + */
  123 + post: function (scope, element, attr) {
  124 +
  125 + // 添加选中事件处理函数
  126 + scope[ctrlAs].$$internal_select_fn = function($item) {
  127 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");
  128 +
  129 + eval("var obj=" + $cmaps_attr);
  130 + for (var mc in obj) { // model的字段名:内部数据源对应字段名
  131 + var ic = obj[mc]; // 内部数据源对应字段
  132 + eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";");
  133 + }
  134 + };
  135 +
  136 + // 删除选中事件处理函数
  137 + scope[ctrlAs].$$internal_remove_fn = function() {
  138 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");
  139 +
  140 + eval("var obj=" + $cmaps_attr);
  141 + var mc; // model的字段名
  142 + for (mc in obj) {
  143 + eval("scope[ctrlAs].model" + "." + mc + " = undefined;");
  144 + }
  145 + };
  146 +
  147 + // 刷新数据
  148 + scope[ctrlAs].$$internal_refresh_fn = function(search) {
  149 + if (search && search != "") { // 有search值
  150 + // 处理search
  151 + console.log("search:" + search);
  152 +
  153 + scope[ctrlAs].$$data = [];
  154 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  155 + var upTerm = search.toUpperCase();
  156 + if (scope[ctrlAs].$$data.length < 10) {
  157 + if (scope[ctrlAs].$$data_real[k].$fullChars.indexOf(upTerm) != -1
  158 + || scope[ctrlAs].$$data_real[k].$camelChars.indexOf(upTerm) != -1
  159 + || scope[ctrlAs].$$data_real[k].$calcu_str.indexOf(upTerm) != -1) {
  160 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  161 + }
  162 + } else {
  163 + break;
  164 + }
  165 + }
  166 + }
  167 + };
  168 +
  169 + /**
  170 + * 验证内部数据,更新外部model
  171 + */
  172 + scope[ctrlAs].$$internal_validate_model = function() {
  173 + if (scope[ctrlAs].$$internal_select_value) {
  174 + var select_value_temp = scope[ctrlAs].$$internal_select_value;
  175 + if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) {
  176 + var obj;
  177 + for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {
  178 + if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) {
  179 + obj = angular.copy(scope[ctrlAs].$$data_real[j]);
  180 + break;
  181 + }
  182 + }
  183 + if (obj) { // 在data中判定有没有
  184 + for (var k = 0; k < scope[ctrlAs].$$data.length; k++) {
  185 + if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) {
  186 + obj = undefined;
  187 + break;
  188 + }
  189 + }
  190 + if (obj) {
  191 + scope[ctrlAs].$$data.push(obj);
  192 + }
  193 + // 更新内部model,用于外部验证
  194 + // 内部model的值暂时随意,以后再改
  195 + scope[ctrlAs].$$internalmodel = {desc: "ok"};
  196 + } else {
  197 + scope[ctrlAs].$$internalmodel = undefined;
  198 + }
  199 +
  200 + } else {
  201 + scope[ctrlAs].$$internalmodel = undefined;
  202 + }
  203 +
  204 + } else {
  205 + scope[ctrlAs].$$internalmodel = undefined;
  206 + }
  207 + };
  208 +
  209 + /**
  210 + * 内部match表达式转换函数,需要外部绑定此函数的上下文。
  211 + * @param context function上下文
  212 + */
  213 + scope[ctrlAs].$$internal_match_str = function (context) {
  214 + var fx = function() {
  215 + try {
  216 + return eval($searchexp_attr);
  217 + } catch (err) {
  218 + //console.log(err);
  219 + return undefined;
  220 + }
  221 +
  222 + };
  223 +
  224 + var str = fx.bind(context)();
  225 + if (str && str != "")
  226 + return str;
  227 + else
  228 + return undefined;
  229 + };
  230 +
  231 + /**
  232 + * 内部方法,读取字典数据作为数据源。
  233 + * @param atype ajax查询类型
  234 + * @param ajaxparamobj 查询参数对象
  235 + */
  236 + scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) {
  237 + // 如果ajaxparamobj为空对象,则表示清空内部选项
  238 + var isEmptyObj = true;
  239 + for (var name in ajaxparamobj) {
  240 + isEmptyObj = false;
  241 + }
  242 + if (isEmptyObj) {
  243 + // 重新创建内部保存的数据
  244 + scope[ctrlAs].$$data_real = [];
  245 + // 重新创建内部ui-select显示用数据,默认取10条记录显示
  246 + scope[ctrlAs].$$data = [];
  247 +
  248 + scope[ctrlAs].$$internal_remove_fn();
  249 + scope[ctrlAs].$$internal_validate_model();
  250 +
  251 + return;
  252 + }
  253 +
  254 + if ($dsparamsextra_attr) { // 合并附加参数
  255 + eval("var extra = " + $dsparamsextra_attr);
  256 + for (var extrakey in extra) {
  257 + ajaxparamobj[extrakey] = extra[extrakey];
  258 + }
  259 + }
  260 +
  261 + $$searchInfoService_g[atype].list(
  262 + ajaxparamobj,
  263 + function(result) {
  264 + console.log("$$internal_ajax_data result");
  265 +
  266 + // 重新创建内部保存的数据
  267 + scope[ctrlAs].$$data_real = [];
  268 + // result中添加拼音数据,注意:这里要求result返回对象数组
  269 + for (var i = 0; i < result.length; i++) {
  270 + // 闭包绑定返回最终查询的值
  271 + var calcu_str = scope[ctrlAs].$$internal_match_str(result[i]);
  272 + if (calcu_str) {
  273 + // 全拼
  274 + result[i]["$fullChars"] = pinyin.getFullChars(calcu_str);
  275 + // 简拼
  276 + result[i]["$camelChars"] = pinyin.getCamelChars(calcu_str);
  277 + // 原值
  278 + result[i]["$calcu_str"] = calcu_str;
  279 +
  280 + scope[ctrlAs].$$data_real.push(result[i]);
  281 + }
  282 + }
  283 +
  284 + // 重新创建内部ui-select显示用数据,默认取10条记录显示
  285 + scope[ctrlAs].$$data = [];
  286 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  287 + if (scope[ctrlAs].$$data.length < 10) {
  288 + scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]);
  289 + } else {
  290 + break;
  291 + }
  292 + }
  293 +
  294 + scope[ctrlAs].$$internal_validate_model();
  295 + },
  296 + function(result) {
  297 + throw new Error("ajax查询出错");
  298 + }
  299 + );
  300 + };
  301 +
  302 + /**
  303 + * 内部方法,读取字典数据作为数据源。
  304 + * @param dictype 字典类型,如:gsType
  305 + */
  306 + scope[ctrlAs].$$internal_dic_data = function(dictype) {
  307 + if (!dictionaryUtils.getByGroup(dictype)) {
  308 + throw new error("字典数据不窜在=" + dictype);
  309 + }
  310 +
  311 + // 重新创建内部保存的数据
  312 + scope[ctrlAs].$$data_real = [];
  313 + var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);
  314 + var dic_key; // 字典key
  315 +
  316 + for (dic_key in origin_dicgroup) {
  317 + var data = {}; // 重新组合的字典元素对象
  318 + if (dic_key == "true")
  319 + data[$icname_attr] = true;
  320 + else
  321 + data[$icname_attr] = dic_key;
  322 + data[$dscol_attr] = origin_dicgroup[dic_key];
  323 + scope[ctrlAs].$$data_real.push(data);
  324 + }
  325 +
  326 + // 重新创建内部ui-select显示用数据,直接复制所有的字典数据
  327 + scope[ctrlAs].$$data = [];
  328 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  329 + scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]);
  330 + }
  331 +
  332 + scope[ctrlAs].$$internal_validate_model();
  333 + };
  334 +
  335 + /**
  336 + * 监控dsparams属性变化
  337 + */
  338 + attr.$observe("dsparams", function(value) {
  339 + if (value && value != "") {
  340 + var obj = JSON.parse(value);
  341 + console.log("saSelect5 监控到dsparams属性变化,old=" + $dsparams_attr + ",new=" + value);
  342 +
  343 + // dsparams格式如下:
  344 + // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'}
  345 +
  346 + if (obj.type == 'dic') {
  347 + scope[ctrlAs].$$internal_dic_data(obj.param);
  348 +
  349 + } else if (obj.type == 'ajax') {
  350 + scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param);
  351 + } else {
  352 + throw new Error("dsparams参数格式异常=" + obj);
  353 + }
  354 +
  355 + }
  356 + });
  357 +
  358 + /**
  359 + * 监控外部模型dcname的值的变化。
  360 + */
  361 + scope.$watch(
  362 + function() {
  363 + return eval("scope." + ctrlAs + ".model" + "." + $dcname_attr);
  364 + },
  365 + function(newValue, oldValue) {
  366 + if (newValue === undefined && oldValue === undefined) {
  367 + // 两侧都是undefined,不处理
  368 +
  369 + } else {
  370 + console.log("saSelect5 监控到外部模型" + $dcname_attr + "属性值变化,old=" + oldValue + ",new=" + newValue);
  371 + scope[ctrlAs].$$internal_select_value = newValue;
  372 + scope[ctrlAs].$$internal_validate_model();
  373 + }
  374 + },
  375 + true
  376 + );
  377 + }
  378 + };
  379 + }
  380 + };
  381 + }
382 ]); 382 ]);
383 \ No newline at end of file 383 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts1/validation/remoteValidaton.js
1 -angular.module('ScheduleApp').directive("remoteValidaton", [  
2 - 'BusInfoManageService_g',  
3 - 'EmployeeInfoManageService_g',  
4 - 'TimeTableManageService_g',  
5 - function(  
6 - busInfoManageService_g,  
7 - employeeInfoManageService_g,  
8 - timeTableManageService_g  
9 - ) {  
10 - /**  
11 - * 远端验证指令,依赖于ngModel  
12 - * 指令名称 remote-Validation  
13 - * 需要属性 rvtype 表示验证类型  
14 - */  
15 - return {  
16 - restrict: "A",  
17 - require: "^ngModel",  
18 - link: function(scope, element, attr, ngModelCtrl) {  
19 - element.bind("keyup", function() {  
20 - var modelValue = ngModelCtrl.$modelValue;  
21 - var rv1_attr = attr["rv1"];  
22 - if (attr["rvtype"]) {  
23 -  
24 - // 根据rvtype的值,确定使用那个远端验证的url,  
25 - // rv1, rv2, rv3是关联比较值,暂时使用rv1  
26 - // 这个貌似没法通用,根据业务变换  
27 - // TODO:暂时有点乱以后改  
28 - if (attr["rvtype"] == "insideCode") {  
29 - busInfoManageService_g.validate.insideCode(  
30 - {"insideCode_eq": modelValue, type: "equale"},  
31 - function(result) {  
32 - //console.log(result);  
33 - if (result.status == "SUCCESS") {  
34 - ngModelCtrl.$setValidity('remote', true);  
35 - } else {  
36 - ngModelCtrl.$setValidity('remote', false);  
37 - }  
38 - },  
39 - function(result) {  
40 - //console.log(result);  
41 - ngModelCtrl.$setValidity('remote', true);  
42 - }  
43 - );  
44 - } else if (attr["rvtype"] == "jobCode") {  
45 - if (!rv1_attr) {  
46 - ngModelCtrl.$setValidity('remote', false);  
47 - return;  
48 - }  
49 -  
50 - employeeInfoManageService_g.validate.jobCode(  
51 - {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"},  
52 - function(result) {  
53 - //console.log(result);  
54 - if (result.status == "SUCCESS") {  
55 - ngModelCtrl.$setValidity('remote', true);  
56 - } else {  
57 - ngModelCtrl.$setValidity('remote', false);  
58 - }  
59 - },  
60 - function(result) {  
61 - //console.log(result);  
62 - ngModelCtrl.$setValidity('remote', true);  
63 - }  
64 - );  
65 - } else if (attr["rvtype"] == "ttinfoname") {  
66 - if (!rv1_attr) {  
67 - ngModelCtrl.$setValidity('remote', false);  
68 - return;  
69 - }  
70 -  
71 - timeTableManageService_g.validate.ttinfoname(  
72 - {"name_eq": modelValue, "xl.id_eq": rv1_attr, type: "equale"},  
73 - function(result) {  
74 - //console.log(result);  
75 - if (result.status == "SUCCESS") {  
76 - ngModelCtrl.$setValidity('remote', true);  
77 - } else {  
78 - ngModelCtrl.$setValidity('remote', false);  
79 - }  
80 - },  
81 - function(result) {  
82 - //console.log(result);  
83 - ngModelCtrl.$setValidity('remote', true);  
84 - }  
85 - );  
86 -  
87 - }  
88 - } else {  
89 - // 没有rvtype,就不用远端验证了  
90 - ngModelCtrl.$setValidity('remote', true);  
91 - }  
92 -  
93 - attr.$observe("rv1", function(value) {  
94 - if (attr["rvtype"] == "jobCode") {  
95 - if (!value) {  
96 - ngModelCtrl.$setValidity('remote', false);  
97 - return;  
98 - }  
99 -  
100 - employeeInfoManageService_g.validate.jobCode(  
101 - {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"},  
102 - function(result) {  
103 - //console.log(result);  
104 - if (result.status == "SUCCESS") {  
105 - ngModelCtrl.$setValidity('remote', true);  
106 - } else {  
107 - ngModelCtrl.$setValidity('remote', false);  
108 - }  
109 - },  
110 - function(result) {  
111 - //console.log(result);  
112 - ngModelCtrl.$setValidity('remote', true);  
113 - }  
114 - );  
115 - } else if (attr["rvtype"] == "ttinfoname") {  
116 - if (!value) {  
117 - ngModelCtrl.$setValidity('remote', false);  
118 - return;  
119 - }  
120 -  
121 - console.log("rv1:" + value);  
122 -  
123 - timeTableManageService_g.validate.ttinfoname(  
124 - {"name_eq": modelValue, "xl.id_eq": value, type: "equale"},  
125 - function(result) {  
126 - //console.log(result);  
127 - if (result.status == "SUCCESS") {  
128 - ngModelCtrl.$setValidity('remote', true);  
129 - } else {  
130 - ngModelCtrl.$setValidity('remote', false);  
131 - }  
132 - },  
133 - function(result) {  
134 - //console.log(result);  
135 - ngModelCtrl.$setValidity('remote', true);  
136 - }  
137 - );  
138 - }  
139 -  
140 - });  
141 - });  
142 - }  
143 - };  
144 - }  
145 - ] 1 +angular.module('ScheduleApp').directive("remoteValidaton", [
  2 + 'BusInfoManageService_g',
  3 + 'EmployeeInfoManageService_g',
  4 + 'TimeTableManageService_g',
  5 + function(
  6 + busInfoManageService_g,
  7 + employeeInfoManageService_g,
  8 + timeTableManageService_g
  9 + ) {
  10 + /**
  11 + * 远端验证指令,依赖于ngModel
  12 + * 指令名称 remote-Validation
  13 + * 需要属性 rvtype 表示验证类型
  14 + */
  15 + return {
  16 + restrict: "A",
  17 + require: "^ngModel",
  18 + link: function(scope, element, attr, ngModelCtrl) {
  19 + element.bind("keyup", function() {
  20 + var modelValue = ngModelCtrl.$modelValue;
  21 + var rv1_attr = attr["rv1"];
  22 + if (attr["rvtype"]) {
  23 +
  24 + // 根据rvtype的值,确定使用那个远端验证的url,
  25 + // rv1, rv2, rv3是关联比较值,暂时使用rv1
  26 + // 这个貌似没法通用,根据业务变换
  27 + // TODO:暂时有点乱以后改
  28 + if (attr["rvtype"] == "insideCode") {
  29 + busInfoManageService_g.validate.insideCode(
  30 + {"insideCode_eq": modelValue, type: "equale"},
  31 + function(result) {
  32 + //console.log(result);
  33 + if (result.status == "SUCCESS") {
  34 + ngModelCtrl.$setValidity('remote', true);
  35 + } else {
  36 + ngModelCtrl.$setValidity('remote', false);
  37 + }
  38 + },
  39 + function(result) {
  40 + //console.log(result);
  41 + ngModelCtrl.$setValidity('remote', true);
  42 + }
  43 + );
  44 + } else if (attr["rvtype"] == "jobCode") {
  45 + if (!rv1_attr) {
  46 + ngModelCtrl.$setValidity('remote', false);
  47 + return;
  48 + }
  49 +
  50 + employeeInfoManageService_g.validate.jobCode(
  51 + {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"},
  52 + function(result) {
  53 + //console.log(result);
  54 + if (result.status == "SUCCESS") {
  55 + ngModelCtrl.$setValidity('remote', true);
  56 + } else {
  57 + ngModelCtrl.$setValidity('remote', false);
  58 + }
  59 + },
  60 + function(result) {
  61 + //console.log(result);
  62 + ngModelCtrl.$setValidity('remote', true);
  63 + }
  64 + );
  65 + } else if (attr["rvtype"] == "ttinfoname") {
  66 + if (!rv1_attr) {
  67 + ngModelCtrl.$setValidity('remote', false);
  68 + return;
  69 + }
  70 +
  71 + timeTableManageService_g.validate.ttinfoname(
  72 + {"name_eq": modelValue, "xl.id_eq": rv1_attr, type: "equale"},
  73 + function(result) {
  74 + //console.log(result);
  75 + if (result.status == "SUCCESS") {
  76 + ngModelCtrl.$setValidity('remote', true);
  77 + } else {
  78 + ngModelCtrl.$setValidity('remote', false);
  79 + }
  80 + },
  81 + function(result) {
  82 + //console.log(result);
  83 + ngModelCtrl.$setValidity('remote', true);
  84 + }
  85 + );
  86 +
  87 + }
  88 + } else {
  89 + // 没有rvtype,就不用远端验证了
  90 + ngModelCtrl.$setValidity('remote', true);
  91 + }
  92 +
  93 + attr.$observe("rv1", function(value) {
  94 + if (attr["rvtype"] == "jobCode") {
  95 + if (!value) {
  96 + ngModelCtrl.$setValidity('remote', false);
  97 + return;
  98 + }
  99 +
  100 + employeeInfoManageService_g.validate.jobCode(
  101 + {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"},
  102 + function(result) {
  103 + //console.log(result);
  104 + if (result.status == "SUCCESS") {
  105 + ngModelCtrl.$setValidity('remote', true);
  106 + } else {
  107 + ngModelCtrl.$setValidity('remote', false);
  108 + }
  109 + },
  110 + function(result) {
  111 + //console.log(result);
  112 + ngModelCtrl.$setValidity('remote', true);
  113 + }
  114 + );
  115 + } else if (attr["rvtype"] == "ttinfoname") {
  116 + if (!value) {
  117 + ngModelCtrl.$setValidity('remote', false);
  118 + return;
  119 + }
  120 +
  121 + console.log("rv1:" + value);
  122 +
  123 + timeTableManageService_g.validate.ttinfoname(
  124 + {"name_eq": modelValue, "xl.id_eq": value, type: "equale"},
  125 + function(result) {
  126 + //console.log(result);
  127 + if (result.status == "SUCCESS") {
  128 + ngModelCtrl.$setValidity('remote', true);
  129 + } else {
  130 + ngModelCtrl.$setValidity('remote', false);
  131 + }
  132 + },
  133 + function(result) {
  134 + //console.log(result);
  135 + ngModelCtrl.$setValidity('remote', true);
  136 + }
  137 + );
  138 + }
  139 +
  140 + });
  141 + });
  142 + }
  143 + };
  144 + }
  145 + ]
146 ); 146 );
147 \ No newline at end of file 147 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts2/bcGroup/saBcgroup.js
1 -/**  
2 - * saBcgroup指令,用于套跑界面中,从指定线路,指定时刻表,指定路牌的班次列表中选择套跑班次。  
3 - * 属性如下:  
4 - * name(必须):控件的名字  
5 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
6 - * bcttinfoidsvalue(必须):绑定的model班次ids字段值,如:bcttinfoidsvalue={{ctrl.employeeInfoForSave.lprange}}  
7 - * bcttinfoidsname(必须):bind的model班次ids字段名,如:bcttinfoidsname=lprange  
8 - * dataparams (必须):内部数据关联的查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}  
9 - * required(可选):是否要用required验证  
10 - *  
11 - */  
12 -angular.module('ScheduleApp').directive('saBcgroup', [  
13 - 'TimeTableDetailManageService_g',  
14 - function(timeTableDetailManageService_g) {  
15 - return {  
16 - restrict: 'E',  
17 - templateUrl: '/pages/scheduleApp/module/common/dts2/bcGroup/saBcgroupTemplate.html',  
18 - scope: {  
19 - model: "=" // 独立作用域,关联外部的模型object  
20 - },  
21 - controllerAs: '$saBcgroupCtrl',  
22 - bindToController: true,  
23 - controller: function($scope) {  
24 - var self = this;  
25 - self.$$data = []; // 选择线路,时刻表,路牌后的班次列表  
26 -  
27 - // 测试数据  
28 - //self.$$data = [  
29 - // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'},  
30 - // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'},  
31 - // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'}  
32 - //];  
33 -  
34 -  
35 - self.$$dataSelected = []; // 套跑选中的班次列表  
36 -  
37 - //self.$$dataSelected = [  
38 - // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'},  
39 - // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'},  
40 - // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'}  
41 - //];  
42 -  
43 - // saBcgroup组件的ng-model,用于外部绑定等操作  
44 - self.$$internalmodel = undefined;  
45 -  
46 - self.$$data_bcdata_first_init = false; // 班次数据首次初始化标志  
47 - self.$$data_bcttinfoids_first_init = false; // 班次ids数据首次初始化标志  
48 - self.$$data_bcttinfoids_first_data = undefined; // 班次ids数据首次初始化数据  
49 -  
50 - },  
51 -  
52 - /**  
53 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
54 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
55 - * @param tElem  
56 - * @param tAttrs  
57 - * @returns {{pre: Function, post: Function}}  
58 - */  
59 - compile: function(tElem, tAttrs) {  
60 - // TODO:获取所有的属性  
61 - var $name_attr = tAttrs["name"]; // 控件的名字  
62 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
63 - var $bcttinfoidsname_attr = tAttrs["bcttinfoidsname"]; // bind的model班次ids字段名  
64 -  
65 - // controlAs名字  
66 - var ctrlAs = '$saBcgroupCtrl';  
67 -  
68 - // 如果有required属性,添加angularjs required验证  
69 - if ($required_attr != undefined) {  
70 - //console.log(tElem.html());  
71 - tElem.find("div").attr("required", "");  
72 - }  
73 -  
74 - return {  
75 - pre: function(scope, element, attr) {  
76 - // TODO:  
77 - },  
78 -  
79 - /**  
80 - * 相当于link函数。  
81 - * @param scope  
82 - * @param element  
83 - * @param attr  
84 - */  
85 - post: function(scope, element, attr) {  
86 - // name属性  
87 - if ($name_attr) {  
88 - scope[ctrlAs]["$name_attr"] = $name_attr;  
89 - }  
90 -  
91 - // TODO:  
92 -  
93 -  
94 - /**  
95 - * 班次列表点击(班次列表中选中班次)  
96 - * @param $index  
97 - */  
98 - scope[ctrlAs].$$internal_bclist_click = function($index) {  
99 - var data_temp = scope[ctrlAs].$$data;  
100 - var data_temp2 = scope[ctrlAs].$$dataSelected;  
101 - var i = 0;  
102 - var isunique = true; // 是否已经选择过  
103 - if (data_temp && data_temp.length > $index) {  
104 - for (i = 0; i < data_temp2.length; i++) {  
105 - if (data_temp2[i].bcttinfoid == data_temp[$index].bcttinfoid) {  
106 - isunique = false;  
107 - break;  
108 - }  
109 - }  
110 - if (isunique) {  
111 - data_temp2.push({  
112 - bcttinfoid: data_temp[$index].bcttinfoid,  
113 - bcfcsj: data_temp[$index].bcfcsj,  
114 - bctype: data_temp[$index].bctype  
115 - });  
116 - }  
117 -  
118 - }  
119 - };  
120 - /**  
121 - * 选中的班次双击(删除选中的班次)  
122 - * @param $index  
123 - */  
124 - scope[ctrlAs].$$internal_selbclist_dbclick = function($index) {  
125 - var data_temp = scope[ctrlAs].$$dataSelected;  
126 - if (data_temp && data_temp.length > $index) {  
127 - data_temp.splice($index, 1);  
128 - }  
129 - };  
130 -  
131 -  
132 - /**  
133 - * 验证内部数据,更新外部model  
134 - */  
135 - scope[ctrlAs].$$internal_validate_model = function() {  
136 - var data_temp = scope[ctrlAs].$$dataSelected;  
137 - var bcttinfoIds = [];  
138 - var i = 0;  
139 -  
140 - if (data_temp &&  
141 - data_temp.length > 0) {  
142 -  
143 - for (i = 0; i < data_temp.length; i++) {  
144 - bcttinfoIds.push(data_temp[i].bcttinfoid);  
145 - }  
146 -  
147 - // 更新外部model字段  
148 - if ($bcttinfoidsname_attr) {  
149 - console.log("bcttinfoidsname=" + bcttinfoIds.join(','));  
150 - eval("scope[ctrlAs].model" + "." + $bcttinfoidsname_attr + " = bcttinfoIds.join(',');");  
151 - }  
152 -  
153 - // 更新内部model,用于外部验证  
154 - // 内部model的值暂时随意,以后再改  
155 - scope[ctrlAs].$$internalmodel = {desc: "ok"};  
156 -  
157 - scope[ctrlAs].$$data_bcdata_first_init = true;  
158 - scope[ctrlAs].$$data_bcttinfoids_first_init = true;  
159 -  
160 - } else {  
161 - scope[ctrlAs].$$internalmodel = undefined;  
162 - }  
163 -  
164 - };  
165 -  
166 - // 监控内部数据,$$data_selected 变化  
167 - scope.$watch(  
168 - function() {  
169 - console.log("长度:" + scope[ctrlAs].$$dataSelected.length);  
170 - return scope[ctrlAs].$$dataSelected;  
171 - },  
172 - function(newValue, oldValue) {  
173 - scope[ctrlAs].$$internal_validate_model();  
174 - },  
175 - true  
176 - );  
177 -  
178 - /**  
179 - * 验证数据是否初始化完成,  
180 - * 所谓的初始化就是内部所有的数据被有效设定过一次。  
181 - */  
182 - scope[ctrlAs].$$internal_validate_init = function() {  
183 - var self = scope[ctrlAs];  
184 -  
185 - var data_temp = self.$$data;  
186 - var dataSelect_temp = self.$$dataSelected;  
187 - var bcttinfoids = null;  
188 -  
189 - var i = 0;  
190 - var j = 0;  
191 -  
192 - if (self.$$data_bcdata_first_init &&  
193 - self.$$data_bcttinfoids_first_init) {  
194 - console.log("开始初始化数据");  
195 -  
196 - bcttinfoids = self.$$data_bcttinfoids_first_data ? self.$$data_bcttinfoids_first_data.split(",") : [];  
197 -  
198 - for (i = 0; i < bcttinfoids.length; i++) {  
199 - dataSelect_temp.push({  
200 - bcttinfoid: bcttinfoids[i]  
201 - });  
202 - for (j = 0; j < data_temp.length; j++) {  
203 - if (dataSelect_temp[i].bcttinfoid == data_temp[j].bcttinfoid) {  
204 - dataSelect_temp[i].bcfcsj = data_temp[j].bcfcsj;  
205 - dataSelect_temp[i].bctype = data_temp[j].bctype;  
206 - break;  
207 - }  
208 - }  
209 - }  
210 -  
211 - console.log("数据初始化完毕!");  
212 - }  
213 -  
214 - };  
215 -  
216 - // 监控初始化标志  
217 - scope.$watch(  
218 - function() {  
219 - return scope[ctrlAs].$$data_bcdata_first_init;  
220 - },  
221 - function(newValue, oldValue) {  
222 - scope[ctrlAs].$$internal_validate_init();  
223 - }  
224 - );  
225 - scope.$watch(  
226 - function() {  
227 - return scope[ctrlAs].$$data_bcttinfoids_first_init;  
228 - },  
229 - function(newValue, oldValue) {  
230 - scope[ctrlAs].$$internal_validate_init();  
231 - }  
232 - );  
233 -  
234 - // 监控内部数据的变化  
235 - attr.$observe("dataparams", function(value) {  
236 - if (value && value != "") {  
237 - if (value == '{}') {  
238 - return;  
239 - }  
240 -  
241 - console.log("bcgroup observe 监控 dataparams=" + value);  
242 -  
243 - timeTableDetailManageService_g.bcdetails.list(  
244 - JSON.parse(value),  
245 - function(result) {  
246 - // 获取值了  
247 - console.log("内部班次数据获取了");  
248 -  
249 - scope[ctrlAs].$$data = [];  
250 - for (var i = 0; i < result.length; i++) {  
251 - scope[ctrlAs].$$data.push({  
252 - bcttinfoid: result[i].id,  
253 - bcfcsj: result[i].fcsj,  
254 - bctype: result[i].bcType  
255 - });  
256 - }  
257 - if (scope[ctrlAs].$$data_bcdata_first_init &&  
258 - scope[ctrlAs].$$data_bcttinfoids_first_init) {  
259 -  
260 - scope[ctrlAs].$$dataSelected = [];  
261 - scope[ctrlAs].$$internalmodel = undefined;  
262 - }  
263 - scope[ctrlAs].$$data_bcdata_first_init = true;  
264 - },  
265 - function(result) {  
266 -  
267 - }  
268 - );  
269 - }  
270 - });  
271 - // 监控班次ids数据的变化  
272 - attr.$observe("bcttinfoidsvalue", function(value) {  
273 - if (value && value != "") {  
274 - console.log("observe 监控 bcttinfoidsvalue=" + value);  
275 - scope[ctrlAs].$$data_bcttinfoids_first_init = true;  
276 - scope[ctrlAs].$$data_bcttinfoids_first_data = value;  
277 - }  
278 - });  
279 -  
280 - }  
281 - }  
282 -  
283 - }  
284 - }  
285 - } 1 +/**
  2 + * saBcgroup指令,用于套跑界面中,从指定线路,指定时刻表,指定路牌的班次列表中选择套跑班次。
  3 + * 属性如下:
  4 + * name(必须):控件的名字
  5 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  6 + * bcttinfoidsvalue(必须):绑定的model班次ids字段值,如:bcttinfoidsvalue={{ctrl.employeeInfoForSave.lprange}}
  7 + * bcttinfoidsname(必须):bind的model班次ids字段名,如:bcttinfoidsname=lprange
  8 + * dataparams (必须):内部数据关联的查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }}
  9 + * required(可选):是否要用required验证
  10 + *
  11 + */
  12 +angular.module('ScheduleApp').directive('saBcgroup', [
  13 + 'TimeTableDetailManageService_g',
  14 + function(timeTableDetailManageService_g) {
  15 + return {
  16 + restrict: 'E',
  17 + templateUrl: '/pages/scheduleApp/module/common/dts2/bcGroup/saBcgroupTemplate.html',
  18 + scope: {
  19 + model: "=" // 独立作用域,关联外部的模型object
  20 + },
  21 + controllerAs: '$saBcgroupCtrl',
  22 + bindToController: true,
  23 + controller: function($scope) {
  24 + var self = this;
  25 + self.$$data = []; // 选择线路,时刻表,路牌后的班次列表
  26 +
  27 + // 测试数据
  28 + //self.$$data = [
  29 + // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'},
  30 + // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'},
  31 + // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'}
  32 + //];
  33 +
  34 +
  35 + self.$$dataSelected = []; // 套跑选中的班次列表
  36 +
  37 + //self.$$dataSelected = [
  38 + // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'},
  39 + // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'},
  40 + // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'}
  41 + //];
  42 +
  43 + // saBcgroup组件的ng-model,用于外部绑定等操作
  44 + self.$$internalmodel = undefined;
  45 +
  46 + self.$$data_bcdata_first_init = false; // 班次数据首次初始化标志
  47 + self.$$data_bcttinfoids_first_init = false; // 班次ids数据首次初始化标志
  48 + self.$$data_bcttinfoids_first_data = undefined; // 班次ids数据首次初始化数据
  49 +
  50 + },
  51 +
  52 + /**
  53 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  54 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  55 + * @param tElem
  56 + * @param tAttrs
  57 + * @returns {{pre: Function, post: Function}}
  58 + */
  59 + compile: function(tElem, tAttrs) {
  60 + // TODO:获取所有的属性
  61 + var $name_attr = tAttrs["name"]; // 控件的名字
  62 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  63 + var $bcttinfoidsname_attr = tAttrs["bcttinfoidsname"]; // bind的model班次ids字段名
  64 +
  65 + // controlAs名字
  66 + var ctrlAs = '$saBcgroupCtrl';
  67 +
  68 + // 如果有required属性,添加angularjs required验证
  69 + if ($required_attr != undefined) {
  70 + //console.log(tElem.html());
  71 + tElem.find("div").attr("required", "");
  72 + }
  73 +
  74 + return {
  75 + pre: function(scope, element, attr) {
  76 + // TODO:
  77 + },
  78 +
  79 + /**
  80 + * 相当于link函数。
  81 + * @param scope
  82 + * @param element
  83 + * @param attr
  84 + */
  85 + post: function(scope, element, attr) {
  86 + // name属性
  87 + if ($name_attr) {
  88 + scope[ctrlAs]["$name_attr"] = $name_attr;
  89 + }
  90 +
  91 + // TODO:
  92 +
  93 +
  94 + /**
  95 + * 班次列表点击(班次列表中选中班次)
  96 + * @param $index
  97 + */
  98 + scope[ctrlAs].$$internal_bclist_click = function($index) {
  99 + var data_temp = scope[ctrlAs].$$data;
  100 + var data_temp2 = scope[ctrlAs].$$dataSelected;
  101 + var i = 0;
  102 + var isunique = true; // 是否已经选择过
  103 + if (data_temp && data_temp.length > $index) {
  104 + for (i = 0; i < data_temp2.length; i++) {
  105 + if (data_temp2[i].bcttinfoid == data_temp[$index].bcttinfoid) {
  106 + isunique = false;
  107 + break;
  108 + }
  109 + }
  110 + if (isunique) {
  111 + data_temp2.push({
  112 + bcttinfoid: data_temp[$index].bcttinfoid,
  113 + bcfcsj: data_temp[$index].bcfcsj,
  114 + bctype: data_temp[$index].bctype
  115 + });
  116 + }
  117 +
  118 + }
  119 + };
  120 + /**
  121 + * 选中的班次双击(删除选中的班次)
  122 + * @param $index
  123 + */
  124 + scope[ctrlAs].$$internal_selbclist_dbclick = function($index) {
  125 + var data_temp = scope[ctrlAs].$$dataSelected;
  126 + if (data_temp && data_temp.length > $index) {
  127 + data_temp.splice($index, 1);
  128 + }
  129 + };
  130 +
  131 +
  132 + /**
  133 + * 验证内部数据,更新外部model
  134 + */
  135 + scope[ctrlAs].$$internal_validate_model = function() {
  136 + var data_temp = scope[ctrlAs].$$dataSelected;
  137 + var bcttinfoIds = [];
  138 + var i = 0;
  139 +
  140 + if (data_temp &&
  141 + data_temp.length > 0) {
  142 +
  143 + for (i = 0; i < data_temp.length; i++) {
  144 + bcttinfoIds.push(data_temp[i].bcttinfoid);
  145 + }
  146 +
  147 + // 更新外部model字段
  148 + if ($bcttinfoidsname_attr) {
  149 + console.log("bcttinfoidsname=" + bcttinfoIds.join(','));
  150 + eval("scope[ctrlAs].model" + "." + $bcttinfoidsname_attr + " = bcttinfoIds.join(',');");
  151 + }
  152 +
  153 + // 更新内部model,用于外部验证
  154 + // 内部model的值暂时随意,以后再改
  155 + scope[ctrlAs].$$internalmodel = {desc: "ok"};
  156 +
  157 + scope[ctrlAs].$$data_bcdata_first_init = true;
  158 + scope[ctrlAs].$$data_bcttinfoids_first_init = true;
  159 +
  160 + } else {
  161 + scope[ctrlAs].$$internalmodel = undefined;
  162 + }
  163 +
  164 + };
  165 +
  166 + // 监控内部数据,$$data_selected 变化
  167 + scope.$watch(
  168 + function() {
  169 + console.log("长度:" + scope[ctrlAs].$$dataSelected.length);
  170 + return scope[ctrlAs].$$dataSelected;
  171 + },
  172 + function(newValue, oldValue) {
  173 + scope[ctrlAs].$$internal_validate_model();
  174 + },
  175 + true
  176 + );
  177 +
  178 + /**
  179 + * 验证数据是否初始化完成,
  180 + * 所谓的初始化就是内部所有的数据被有效设定过一次。
  181 + */
  182 + scope[ctrlAs].$$internal_validate_init = function() {
  183 + var self = scope[ctrlAs];
  184 +
  185 + var data_temp = self.$$data;
  186 + var dataSelect_temp = self.$$dataSelected;
  187 + var bcttinfoids = null;
  188 +
  189 + var i = 0;
  190 + var j = 0;
  191 +
  192 + if (self.$$data_bcdata_first_init &&
  193 + self.$$data_bcttinfoids_first_init) {
  194 + console.log("开始初始化数据");
  195 +
  196 + bcttinfoids = self.$$data_bcttinfoids_first_data ? self.$$data_bcttinfoids_first_data.split(",") : [];
  197 +
  198 + for (i = 0; i < bcttinfoids.length; i++) {
  199 + dataSelect_temp.push({
  200 + bcttinfoid: bcttinfoids[i]
  201 + });
  202 + for (j = 0; j < data_temp.length; j++) {
  203 + if (dataSelect_temp[i].bcttinfoid == data_temp[j].bcttinfoid) {
  204 + dataSelect_temp[i].bcfcsj = data_temp[j].bcfcsj;
  205 + dataSelect_temp[i].bctype = data_temp[j].bctype;
  206 + break;
  207 + }
  208 + }
  209 + }
  210 +
  211 + console.log("数据初始化完毕!");
  212 + }
  213 +
  214 + };
  215 +
  216 + // 监控初始化标志
  217 + scope.$watch(
  218 + function() {
  219 + return scope[ctrlAs].$$data_bcdata_first_init;
  220 + },
  221 + function(newValue, oldValue) {
  222 + scope[ctrlAs].$$internal_validate_init();
  223 + }
  224 + );
  225 + scope.$watch(
  226 + function() {
  227 + return scope[ctrlAs].$$data_bcttinfoids_first_init;
  228 + },
  229 + function(newValue, oldValue) {
  230 + scope[ctrlAs].$$internal_validate_init();
  231 + }
  232 + );
  233 +
  234 + // 监控内部数据的变化
  235 + attr.$observe("dataparams", function(value) {
  236 + if (value && value != "") {
  237 + if (value == '{}') {
  238 + return;
  239 + }
  240 +
  241 + console.log("bcgroup observe 监控 dataparams=" + value);
  242 +
  243 + timeTableDetailManageService_g.bcdetails.list(
  244 + JSON.parse(value),
  245 + function(result) {
  246 + // 获取值了
  247 + console.log("内部班次数据获取了");
  248 +
  249 + scope[ctrlAs].$$data = [];
  250 + for (var i = 0; i < result.length; i++) {
  251 + scope[ctrlAs].$$data.push({
  252 + bcttinfoid: result[i].id,
  253 + bcfcsj: result[i].fcsj,
  254 + bctype: result[i].bcType
  255 + });
  256 + }
  257 + if (scope[ctrlAs].$$data_bcdata_first_init &&
  258 + scope[ctrlAs].$$data_bcttinfoids_first_init) {
  259 +
  260 + scope[ctrlAs].$$dataSelected = [];
  261 + scope[ctrlAs].$$internalmodel = undefined;
  262 + }
  263 + scope[ctrlAs].$$data_bcdata_first_init = true;
  264 + },
  265 + function(result) {
  266 +
  267 + }
  268 + );
  269 + }
  270 + });
  271 + // 监控班次ids数据的变化
  272 + attr.$observe("bcttinfoidsvalue", function(value) {
  273 + if (value && value != "") {
  274 + console.log("observe 监控 bcttinfoidsvalue=" + value);
  275 + scope[ctrlAs].$$data_bcttinfoids_first_init = true;
  276 + scope[ctrlAs].$$data_bcttinfoids_first_data = value;
  277 + }
  278 + });
  279 +
  280 + }
  281 + }
  282 +
  283 + }
  284 + }
  285 + }
286 ]); 286 ]);
287 \ No newline at end of file 287 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dts2/dateGroup/saDategroup.js
1 -  
2 -  
3 -/**  
4 - * saDategroup指令  
5 - * 属性如下:  
6 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
7 - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}  
8 - * dcname(必须):绑定的model字段名,如:dcname=xl.id  
9 - * name(必须):控件的名字  
10 - * required(可选):是否要用required验证  
11 - * disabled(可选):标示框是否可选  
12 - *  
13 - */  
14 -angular.module('ScheduleApp').directive('saDategroup', [  
15 - '$filter',  
16 - function($filter) {  
17 - return {  
18 - restrict: 'E',  
19 - templateUrl: '/pages/scheduleApp/module/common/dts2/dateGroup/saDategroupTemplate.html',  
20 - scope: {  
21 - model: "=" // 独立作用域,关联外部的模型object  
22 - },  
23 - controllerAs: "$saDategroupCtrl",  
24 - bindToController: true,  
25 - controller: function($scope) {  
26 - var self = this;  
27 - self.$$data = []; // 内部的数据  
28 - self.$$date_select; // 内部选中的日期  
29 -  
30 - //// 测试数据  
31 - //self.$$data = [  
32 - // {datestr: '2011-01-01', ischecked: true},  
33 - // {datestr: '2011-01-01', ischecked: true},  
34 - // {datestr: '2011-01-01', ischecked: true}  
35 - //];  
36 - },  
37 -  
38 - /**  
39 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
40 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
41 - * @param tElem  
42 - * @param tAttrs  
43 - * @returns {{pre: Function, post: Function}}  
44 - */  
45 - compile: function(tElem, tAttrs) {  
46 - // 获取所有的属性  
47 - var $name_attr = tAttrs["name"]; // 控件的名字  
48 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
49 - var $disabled_attr = tAttrs["disabled"]; // 是否禁用  
50 - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名  
51 -  
52 - // controlAs名字  
53 - var ctrlAs = '$saDategroupCtrl';  
54 -  
55 - // 如果有required属性,添加angularjs required验证  
56 - if ($required_attr != undefined) {  
57 - //console.log(tElem.html());  
58 - tElem.find("div").attr("required", "");  
59 - }  
60 - // 如果有disabled属性,添加禁用标志  
61 - if ($disabled_attr != undefined) {  
62 - tElem.find("input").attr("ng-disabled", "true");  
63 - tElem.find("div").attr("ng-disabled", "true");  
64 - }  
65 -  
66 - return {  
67 - pre: function (scope, element, attr) {  
68 - // TODO:  
69 - },  
70 - /**  
71 - * 相当于link函数。  
72 - * @param scope  
73 - * @param element  
74 - * @param attr  
75 - */  
76 - post: function (scope, element, attr) {  
77 - // name属性  
78 - if ($name_attr) {  
79 - scope[ctrlAs]["$name_attr"] = $name_attr;  
80 - }  
81 -  
82 -  
83 - // 日期open属性,及方法  
84 - scope[ctrlAs].$$specialDateOpen = false;  
85 - scope[ctrlAs].$$specialDate_open = function() {  
86 - scope[ctrlAs].$$specialDateOpen = true;  
87 - };  
88 -  
89 - // 监控选择的日期  
90 - scope.$watch(  
91 - function() {  
92 - return scope[ctrlAs]['$$date_select'];  
93 - },  
94 - function(newValue, oldValue) {  
95 - if (newValue) {  
96 - //console.log("saDategroup--->selectdate:" + newValue);  
97 - // 调用内置filter,转换日期到yyyy-MM-dd格式  
98 - var text = $filter('date')(newValue, 'yyyy-MM-dd');  
99 - var i;  
100 - var isexist = false; // 日期是否已经选择标识  
101 - for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {  
102 - if (scope[ctrlAs]["$$data"][i].datestr == text) {  
103 - isexist = true;  
104 - break;  
105 - }  
106 - }  
107 - if (!isexist) {  
108 - scope[ctrlAs]["$$data"].push(  
109 - {  
110 - datestr: text,  
111 - ischecked: true  
112 - }  
113 - );  
114 - }  
115 -  
116 - }  
117 -  
118 - }  
119 - );  
120 -  
121 - /**  
122 - * 日期点击事件处理函数。  
123 - * @param $index 索引  
124 - */  
125 - scope[ctrlAs].$$internal_datestr_click = function($index) {  
126 - scope[ctrlAs].$$data.splice($index, 1);  
127 - };  
128 -  
129 - // 测试使用watch监控$$data的变化  
130 - scope.$watch(  
131 - function() {  
132 - return scope[ctrlAs]['$$data'];  
133 - },  
134 - function(newValue, oldValue) {  
135 - // 根据$$data生成对应的数据  
136 - var special_days_arr = [];  
137 - var i;  
138 - for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {  
139 - special_days_arr.push(scope[ctrlAs]["$$data"][i].datestr);  
140 - }  
141 -  
142 - scope[ctrlAs].$$internalmodel = special_days_arr.join(",");  
143 - console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel);  
144 -  
145 - // 更新model  
146 - if ($dcname_attr) {  
147 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = special_days_arr.join(',');");  
148 - }  
149 - },  
150 - true  
151 - );  
152 -  
153 - // 监控dcvalue model值变换  
154 - attr.$observe("dcvalue", function(value) {  
155 - console.log("saDategroup 监控dc1 model值变换:" + value);  
156 - if (value) {  
157 - // 根据value值,修改$$data里的值  
158 - var date_array = value.split(",");  
159 - var i;  
160 - scope[ctrlAs]["$$data"] = [];  
161 - for (i = 0; i < date_array.length; i++) {  
162 - scope[ctrlAs]["$$data"].push(  
163 - {  
164 - datestr: date_array[i],  
165 - ischecked: true  
166 - }  
167 - );  
168 - }  
169 -  
170 -  
171 -  
172 -  
173 -  
174 -  
175 -  
176 -  
177 -  
178 - }  
179 - });  
180 -  
181 - }  
182 -  
183 - };  
184 - }  
185 - }  
186 - }  
187 -]);  
188 - 1 +
  2 +
  3 +/**
  4 + * saDategroup指令
  5 + * 属性如下:
  6 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  7 + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}
  8 + * dcname(必须):绑定的model字段名,如:dcname=xl.id
  9 + * name(必须):控件的名字
  10 + * required(可选):是否要用required验证
  11 + * disabled(可选):标示框是否可选
  12 + *
  13 + */
  14 +angular.module('ScheduleApp').directive('saDategroup', [
  15 + '$filter',
  16 + function($filter) {
  17 + return {
  18 + restrict: 'E',
  19 + templateUrl: '/pages/scheduleApp/module/common/dts2/dateGroup/saDategroupTemplate.html',
  20 + scope: {
  21 + model: "=" // 独立作用域,关联外部的模型object
  22 + },
  23 + controllerAs: "$saDategroupCtrl",
  24 + bindToController: true,
  25 + controller: function($scope) {
  26 + var self = this;
  27 + self.$$data = []; // 内部的数据
  28 + self.$$date_select; // 内部选中的日期
  29 +
  30 + //// 测试数据
  31 + //self.$$data = [
  32 + // {datestr: '2011-01-01', ischecked: true},
  33 + // {datestr: '2011-01-01', ischecked: true},
  34 + // {datestr: '2011-01-01', ischecked: true}
  35 + //];
  36 + },
  37 +
  38 + /**
  39 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  40 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  41 + * @param tElem
  42 + * @param tAttrs
  43 + * @returns {{pre: Function, post: Function}}
  44 + */
  45 + compile: function(tElem, tAttrs) {
  46 + // 获取所有的属性
  47 + var $name_attr = tAttrs["name"]; // 控件的名字
  48 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  49 + var $disabled_attr = tAttrs["disabled"]; // 是否禁用
  50 + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名
  51 +
  52 + // controlAs名字
  53 + var ctrlAs = '$saDategroupCtrl';
  54 +
  55 + // 如果有required属性,添加angularjs required验证
  56 + if ($required_attr != undefined) {
  57 + //console.log(tElem.html());
  58 + tElem.find("div").attr("required", "");
  59 + }
  60 + // 如果有disabled属性,添加禁用标志
  61 + if ($disabled_attr != undefined) {
  62 + tElem.find("input").attr("ng-disabled", "true");
  63 + tElem.find("div").attr("ng-disabled", "true");
  64 + }
  65 +
  66 + return {
  67 + pre: function (scope, element, attr) {
  68 + // TODO:
  69 + },
  70 + /**
  71 + * 相当于link函数。
  72 + * @param scope
  73 + * @param element
  74 + * @param attr
  75 + */
  76 + post: function (scope, element, attr) {
  77 + // name属性
  78 + if ($name_attr) {
  79 + scope[ctrlAs]["$name_attr"] = $name_attr;
  80 + }
  81 +
  82 +
  83 + // 日期open属性,及方法
  84 + scope[ctrlAs].$$specialDateOpen = false;
  85 + scope[ctrlAs].$$specialDate_open = function() {
  86 + scope[ctrlAs].$$specialDateOpen = true;
  87 + };
  88 +
  89 + // 监控选择的日期
  90 + scope.$watch(
  91 + function() {
  92 + return scope[ctrlAs]['$$date_select'];
  93 + },
  94 + function(newValue, oldValue) {
  95 + if (newValue) {
  96 + //console.log("saDategroup--->selectdate:" + newValue);
  97 + // 调用内置filter,转换日期到yyyy-MM-dd格式
  98 + var text = $filter('date')(newValue, 'yyyy-MM-dd');
  99 + var i;
  100 + var isexist = false; // 日期是否已经选择标识
  101 + for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {
  102 + if (scope[ctrlAs]["$$data"][i].datestr == text) {
  103 + isexist = true;
  104 + break;
  105 + }
  106 + }
  107 + if (!isexist) {
  108 + scope[ctrlAs]["$$data"].push(
  109 + {
  110 + datestr: text,
  111 + ischecked: true
  112 + }
  113 + );
  114 + }
  115 +
  116 + }
  117 +
  118 + }
  119 + );
  120 +
  121 + /**
  122 + * 日期点击事件处理函数。
  123 + * @param $index 索引
  124 + */
  125 + scope[ctrlAs].$$internal_datestr_click = function($index) {
  126 + scope[ctrlAs].$$data.splice($index, 1);
  127 + };
  128 +
  129 + // 测试使用watch监控$$data的变化
  130 + scope.$watch(
  131 + function() {
  132 + return scope[ctrlAs]['$$data'];
  133 + },
  134 + function(newValue, oldValue) {
  135 + // 根据$$data生成对应的数据
  136 + var special_days_arr = [];
  137 + var i;
  138 + for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {
  139 + special_days_arr.push(scope[ctrlAs]["$$data"][i].datestr);
  140 + }
  141 +
  142 + scope[ctrlAs].$$internalmodel = special_days_arr.join(",");
  143 + console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel);
  144 +
  145 + // 更新model
  146 + if ($dcname_attr) {
  147 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = special_days_arr.join(',');");
  148 + }
  149 + },
  150 + true
  151 + );
  152 +
  153 + // 监控dcvalue model值变换
  154 + attr.$observe("dcvalue", function(value) {
  155 + console.log("saDategroup 监控dc1 model值变换:" + value);
  156 + if (value) {
  157 + // 根据value值,修改$$data里的值
  158 + var date_array = value.split(",");
  159 + var i;
  160 + scope[ctrlAs]["$$data"] = [];
  161 + for (i = 0; i < date_array.length; i++) {
  162 + scope[ctrlAs]["$$data"].push(
  163 + {
  164 + datestr: date_array[i],
  165 + ischecked: true
  166 + }
  167 + );
  168 + }
  169 +
  170 +
  171 +
  172 +
  173 +
  174 +
  175 +
  176 +
  177 +
  178 + }
  179 + });
  180 +
  181 + }
  182 +
  183 + };
  184 + }
  185 + }
  186 + }
  187 +]);
  188 +
src/main/resources/static/pages/scheduleApp/module/common/dts2/employeeGroup/saEmployeegroup.js
1 -  
2 -  
3 -/**  
4 - * saEmployeegroup指令  
5 - * 属性如下:  
6 - * name(必须):控件的名字  
7 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
8 - * xlidvalue(必须):绑定的model线路id值,如:xlidvalue={{ctrl.employeeInfoForSave.xl.id}}  
9 - * dbbmrangevalue(必须):绑定的model搭班编码范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}  
10 - * dbbmrangename(必须):绑定的model搭班编码范围字段名,如:lprangename=lprange  
11 - * rycidrangevalue(必须):绑定的model人员配置idid范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}  
12 - * rycidrangename(必须):绑定的model人员配置id范围字段名,如:lprangename=lprange  
13 - * rystartvalue(必须):绑定的model起始人员,如:lpstartvalue={{ctrl.employeeInfoForSave.lpstart}}  
14 - * rystartname(必须):绑定的model起始人员字段名,如:lpstartname=lpstart  
15 - *  
16 - * required(可选):是否要用required验证  
17 - *  
18 - */  
19 -angular.module('ScheduleApp').directive('saEmployeegroup', [  
20 - 'EmployeeConfigService_g',  
21 - function(employeeConfigService_g) {  
22 - return {  
23 - restrict: 'E',  
24 - templateUrl: '/pages/scheduleApp/module/common/dts2/employeeGroup/saEmployeegroupTemplate.html',  
25 - scope: {  
26 - model: "=" // 独立作用域,关联外部的模型object  
27 - },  
28 - controllerAs: '$saEmployeegroupCtrl',  
29 - bindToController: true,  
30 - controller: function($scope) {  
31 - var self = this;  
32 - self.$$data = []; // 选择线路后,该线路的人员配置数据  
33 -  
34 - // 测试数据  
35 - //self.$$data = [  
36 - // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1'},  
37 - // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2'},  
38 - // {id: 3, dbbm: "3", jsy: '忍3', spy: '守3'}  
39 - //];  
40 -  
41 - self.$$dataSelected = []; // 选中的人员配置列表  
42 - self.$$dataSelectedStart = undefined; // 起始人员配置  
43 -  
44 - //self.$$dataSelected = [  
45 - // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isstart: false},  
46 - // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true},  
47 - // {id: 3, dbbm: "3", jsy: '忍3', spy: '守3', isstart: false}  
48 - //];  
49 -  
50 - self.$$isFB = false; // 是否分班  
51 - self.$$dataFBSelected = []; // 选中的分班人员组配置列表  
52 - self.$$dataFBInternalSelected = undefined; // 分班组内人员选中标识  
53 - self.$$dataFBSelectedStart = undefined; // 选中的起始分班人员组合  
54 -  
55 - //self.$$dataFBSelected = [  
56 - // {isstart: true, group: [  
57 - // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isselected: false},  
58 - // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true}  
59 - // ]},  
60 - // {isstart: false, group: [  
61 - // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isselected: false},  
62 - // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true}  
63 - // ]}  
64 - //];  
65 -  
66 - // saGuideboardgroup组件的ng-model,用于外部绑定等操作  
67 - self.$$internalmodel = undefined;  
68 -  
69 - self.$$data_init = false; // *数据源初始化标志  
70 - self.$$data_xl_first_init = false; // 线路是否初始化  
71 - self.$$data_ry_first_init = false; // 人员配置是否初始化  
72 - self.$$data_ry_first_data = undefined; // 人员配置初始化数据  
73 - self.$$data_rycid_first_init = false; // 人员配置id是否初始化  
74 - self.$$data_rycid_first_data = undefined; // 人员配置id初始化数据  
75 - self.$$data_rystart_first_init = false; // 起始人员是否初始化  
76 - self.$$data_rystart_first_data = undefined; // 起始人员初始化数据  
77 -  
78 - },  
79 -  
80 - /**  
81 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
82 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
83 - * @param tElem  
84 - * @param tAttrs  
85 - * @returns {{pre: Function, post: Function}}  
86 - */  
87 - compile: function(tElem, tAttrs) {  
88 - // TODO:获取所有的属性  
89 - var $name_attr = tAttrs["name"]; // 控件的名字  
90 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
91 - var $dbbmrangename_attr = tAttrs["dbbmrangename"]; // 绑定的model搭班编码范围字段名  
92 - var rycidrangename_attr = tAttrs["rycidrangename"]; // 绑定的model人员配置id范围字段名  
93 - var $rystartname_attr = tAttrs["rystartname"]; // 绑定的model起始人员字段名  
94 -  
95 - // controlAs名字  
96 - var ctrlAs = '$saEmployeegroupCtrl';  
97 -  
98 - // 如果有required属性,添加angularjs required验证  
99 - if ($required_attr != undefined) {  
100 - //console.log(tElem.html());  
101 - tElem.find("div").attr("required", "");  
102 - }  
103 -  
104 - return {  
105 - pre: function(scope, element, attr) {  
106 - // TODO:  
107 - },  
108 -  
109 - /**  
110 - * 相当于link函数。  
111 - * @param scope  
112 - * @param element  
113 - * @param attr  
114 - */  
115 - post: function(scope, element, attr) {  
116 - // name属性  
117 - if ($name_attr) {  
118 - scope[ctrlAs]["$name_attr"] = $name_attr;  
119 - }  
120 -  
121 - /**  
122 - * 人员配置列表点击(人员配置列表中选中路牌)  
123 - * @param $index  
124 - */  
125 - scope[ctrlAs].$$internal_rylist_click = function($index) {  
126 - var data_temp = scope[ctrlAs].$$data;  
127 - if (data_temp && data_temp.length > $index) {  
128 - if (!scope[ctrlAs].$$isFB) { // 不分班  
129 - scope[ctrlAs].$$dataSelected.push({  
130 - id : data_temp[$index].id,  
131 - dbbm: data_temp[$index].dbbm,  
132 - jsy: data_temp[$index].jsy,  
133 - spy: data_temp[$index].spy,  
134 - isstart: false  
135 - });  
136 -  
137 - // 如果没有指定过初始人员,默认选择此人员作为起始人员  
138 - if (scope[ctrlAs].$$dataSelectedStart == undefined) {  
139 - scope[ctrlAs].$$internal_selrylist_click(  
140 - scope[ctrlAs].$$dataSelected.length - 1);  
141 - }  
142 - } else { // 分班  
143 - if (scope[ctrlAs].$$dataFBInternalSelected) { // 替换组内人员  
144 - scope[ctrlAs].$$dataFBSelected  
145 - [scope[ctrlAs].$$dataFBInternalSelected.gindex].group  
146 - [scope[ctrlAs].$$dataFBInternalSelected.index] = {  
147 - id : data_temp[$index].id,  
148 - dbbm: data_temp[$index].dbbm,  
149 - jsy: data_temp[$index].jsy,  
150 - spy: data_temp[$index].spy,  
151 - isselected: true  
152 - };  
153 -  
154 - } else {  
155 - scope[ctrlAs].$$dataFBSelected.push({  
156 - isstart: false,  
157 - group: [].concat(  
158 - {  
159 - id : data_temp[$index].id,  
160 - dbbm: data_temp[$index].dbbm,  
161 - jsy: data_temp[$index].jsy,  
162 - spy: data_temp[$index].spy,  
163 - isselected: false  
164 - }, {  
165 - id : data_temp[$index].id,  
166 - dbbm: data_temp[$index].dbbm,  
167 - jsy: data_temp[$index].jsy,  
168 - spy: data_temp[$index].spy,  
169 - isselected: false  
170 - }  
171 - )  
172 - });  
173 - if (scope[ctrlAs].$$dataFBSelectedStart == undefined) {  
174 - scope[ctrlAs].$$internal_selrygrouplist_click(  
175 - scope[ctrlAs].$$dataFBSelected.length - 1);  
176 - }  
177 - }  
178 - }  
179 -  
180 - }  
181 - };  
182 -  
183 - /**  
184 - * 选中的人员单击(初始人员选择)  
185 - * @param $index  
186 - */  
187 - scope[ctrlAs].$$internal_selrylist_click = function($index) {  
188 - var data_temp = scope[ctrlAs].$$dataSelected;  
189 - if (data_temp && data_temp.length > $index) {  
190 - for (var i = 0; i < data_temp.length; i++) {  
191 - data_temp[i].isstart = false;  
192 - }  
193 - data_temp[$index].isstart = true;  
194 - scope[ctrlAs].$$dataSelectedStart = $index;  
195 - }  
196 - };  
197 - /**  
198 - * 选中的人员双击(删除选中的人员)  
199 - * @param $index  
200 - */  
201 - scope[ctrlAs].$$internal_selrylist_dbclick = function($index) {  
202 - var data_temp = scope[ctrlAs].$$dataSelected;  
203 - if (data_temp && data_temp.length > $index) {  
204 - if (scope[ctrlAs].$$dataSelectedStart == $index) {  
205 - scope[ctrlAs].$$dataSelectedStart = undefined;  
206 - }  
207 - data_temp.splice($index, 1);  
208 - }  
209 - };  
210 -  
211 - /**  
212 - * 选中的分班组人员单击(初始人员选择)  
213 - * @param $index  
214 - */  
215 - scope[ctrlAs].$$internal_selrygrouplist_click = function($index) {  
216 - var data_temp = scope[ctrlAs].$$dataFBSelected;  
217 - if (data_temp && data_temp.length > $index) {  
218 - for (var i = 0; i < data_temp.length; i++) {  
219 - data_temp[i].isstart = false;  
220 - for (var j = 0; j < data_temp[i].group.length; j++) {  
221 - data_temp[i].group[j].isselected = false;  
222 - }  
223 - }  
224 - data_temp[$index].isstart = true;  
225 - scope[ctrlAs].$$dataFBSelectedStart = $index;  
226 - scope[ctrlAs].$$dataFBInternalSelected = undefined;  
227 - }  
228 - };  
229 - /**  
230 - * 分组内部单击(选中分班中的某组人员)  
231 - * @param $groupindex 组index  
232 - * @param $index 组内部某个index  
233 - * @param $event 事件防止冒泡  
234 - */  
235 - scope[ctrlAs].$$internal_selrygroup_click = function($groupindex, $index, $event) {  
236 - var data_temp = scope[ctrlAs].$$dataFBSelected;  
237 - if (data_temp && data_temp.length > $groupindex) {  
238 - if (data_temp[$groupindex].group && data_temp[$groupindex].group.length > $index) {  
239 - // $$dataFBInternalSelected的格式如下:  
240 - //{gindex: 1, index: 0}  
241 - for (var i = 0; i < data_temp.length; i++) {  
242 - data_temp[i].isstart = false;  
243 - for (var j = 0; j < data_temp[i].group.length; j++) {  
244 - data_temp[i].group[j].isselected = false;  
245 - }  
246 - }  
247 - data_temp[$groupindex].group[$index].isselected = true;  
248 - scope[ctrlAs].$$dataFBInternalSelected = {  
249 - gindex: $groupindex, index: $index  
250 - };  
251 - scope[ctrlAs].$$dataFBSelectedStart = undefined;  
252 - $event.stopPropagation();  
253 - }  
254 - }  
255 -  
256 - };  
257 - /**  
258 - * 选中的分班人员双击(删除选中的人员)  
259 - * @param $index  
260 - */  
261 - scope[ctrlAs].$$internal_selrygrouplist_dbclick = function($index) {  
262 - var data_temp = scope[ctrlAs].$$dataFBSelected;  
263 - if (data_temp && data_temp.length > $index) {  
264 - if (scope[ctrlAs].$$dataFBSelectedStart == $index) {  
265 - scope[ctrlAs].$$dataFBSelectedStart = undefined;  
266 - }  
267 - if (scope[ctrlAs].$$dataFBInternalSelected &&  
268 - scope[ctrlAs].$$dataFBInternalSelected.gindex == $index) {  
269 - scope[ctrlAs].$$dataFBInternalSelected = undefined;  
270 - }  
271 - data_temp.splice($index, 1);  
272 - }  
273 - };  
274 -  
275 - /**  
276 - * 验证内部数据,更新外部model  
277 - */  
278 - scope[ctrlAs].$$internal_validate_model = function() {  
279 - var data_temp = scope[ctrlAs].$$dataSelected;  
280 - var data_temp2 = scope[ctrlAs].$$dataSelectedStart;  
281 - var data_temp3 = scope[ctrlAs].$$dataFBSelected;  
282 - var data_temp4 = scope[ctrlAs].$$dataFBSelectedStart;  
283 - var ryDbbms = [];  
284 - var ryDbbm_group = [];  
285 - var ryCids = [];  
286 - var ryCid_group = [];  
287 - var ryStart = 0;  
288 - var i = 0;  
289 - var j = 0;  
290 -  
291 - var isFB = scope[ctrlAs].$$isFB;  
292 -  
293 - if (isFB) {  
294 - if (data_temp3 &&  
295 - data_temp3.length > 0 &&  
296 - data_temp4 != undefined) {  
297 -  
298 - for (i = 0; i < data_temp3.length; i++) {  
299 - for (j = 0; j < data_temp3[i].group.length; j++) {  
300 - ryDbbm_group.push(data_temp3[i].group[j].dbbm);  
301 - ryCid_group.push(data_temp3[i].group[j].id);  
302 - }  
303 - ryDbbms.push(ryDbbm_group.join("-"));  
304 - ryCids.push(ryCid_group.join("-"));  
305 - ryDbbm_group = [];  
306 - ryCid_group = [];  
307 - }  
308 -  
309 - data_temp3[data_temp4].isstart = true;  
310 - ryStart = data_temp4 + 1;  
311 -  
312 - // 更新内部model,用于外部验证  
313 - // 内部model的值暂时随意,以后再改  
314 - scope[ctrlAs].$$internalmodel = {desc: "ok"};  
315 -  
316 - // 更新外部model字段  
317 - if ($dbbmrangename_attr) {  
318 - console.log("dbbmrangename=" + ryDbbms.join(','));  
319 - eval("scope[ctrlAs].model" + "." + $dbbmrangename_attr + " = ryDbbms.join(',');");  
320 - }  
321 - if (rycidrangename_attr) {  
322 - console.log("rycidrangename=" + ryCids.join(','));  
323 - eval("scope[ctrlAs].model" + "." + rycidrangename_attr + " = ryCids.join(',');");  
324 - }  
325 - if ($rystartname_attr) {  
326 - console.log("rystartname=" + ryStart);  
327 - eval("scope[ctrlAs].model" + "." + $rystartname_attr + " = ryStart;");  
328 - }  
329 -  
330 - } else {  
331 - scope[ctrlAs].$$internalmodel = undefined;  
332 - }  
333 -  
334 - } else {  
335 - if (data_temp &&  
336 - data_temp.length > 0 &&  
337 - data_temp2 != undefined) {  
338 -  
339 - for (i = 0; i < data_temp.length; i++) {  
340 - ryDbbms.push(data_temp[i].dbbm);  
341 - ryCids.push(data_temp[i].id);  
342 - }  
343 - data_temp[data_temp2].isstart = true;  
344 - ryStart = data_temp2 + 1;  
345 -  
346 - // 更新内部model,用于外部验证  
347 - // 内部model的值暂时随意,以后再改  
348 - scope[ctrlAs].$$internalmodel = {desc: "ok"};  
349 -  
350 - // 更新外部model字段  
351 - if ($dbbmrangename_attr) {  
352 - console.log("dbbmrangename=" + ryDbbms.join(','));  
353 - eval("scope[ctrlAs].model" + "." + $dbbmrangename_attr + " = ryDbbms.join(',');");  
354 - }  
355 - if (rycidrangename_attr) {  
356 - console.log("rycidrangename=" + ryCids.join(','));  
357 - eval("scope[ctrlAs].model" + "." + rycidrangename_attr + " = ryCids.join(',');");  
358 - }  
359 - if ($rystartname_attr) {  
360 - console.log("rystartname=" + ryStart);  
361 - eval("scope[ctrlAs].model" + "." + $rystartname_attr + " = ryStart;");  
362 - }  
363 -  
364 - } else {  
365 - scope[ctrlAs].$$internalmodel = undefined;  
366 - }  
367 - }  
368 -  
369 - };  
370 -  
371 - // 监控内部数据,$$dataSelected 变化  
372 - scope.$watch(  
373 - function() {  
374 - return scope[ctrlAs].$$dataSelected;  
375 - },  
376 - function(newValue, oldValue) {  
377 - scope[ctrlAs].$$internal_validate_model();  
378 - },  
379 - true  
380 - );  
381 -  
382 - // 监控内部数据,$$dataSelectedStart 变化  
383 - scope.$watch(  
384 - function() {  
385 - return scope[ctrlAs].$$dataSelectedStart;  
386 - },  
387 - function(newValue, oldValue) {  
388 - scope[ctrlAs].$$internal_validate_model();  
389 - },  
390 - true  
391 - );  
392 -  
393 -  
394 - // 监控内部数据,$$dataFBSelected 变化  
395 - scope.$watch(  
396 - function() {  
397 - return scope[ctrlAs].$$dataFBSelected;  
398 - },  
399 - function(newValue, oldValue) {  
400 - scope[ctrlAs].$$internal_validate_model();  
401 - },  
402 - true  
403 - );  
404 -  
405 - // 监控内部数据,$$dataFBSelectedStart 变化  
406 - scope.$watch(  
407 - function() {  
408 - return scope[ctrlAs].$$dataFBSelectedStart;  
409 - },  
410 - function(newValue, oldValue) {  
411 - scope[ctrlAs].$$internal_validate_model();  
412 - },  
413 - true  
414 - );  
415 -  
416 - // 监控内部数据,$$dataFBInternalSelected 变化  
417 - scope.$watch(  
418 - function() {  
419 - return scope[ctrlAs].$$dataFBInternalSelected;  
420 - },  
421 - function(newValue, oldValue) {  
422 - scope[ctrlAs].$$internal_validate_model();  
423 - },  
424 - true  
425 - );  
426 -  
427 - // 监控内部数据,$$isFB 变化  
428 - scope.$watch(  
429 - function() {  
430 - return scope[ctrlAs].$$isFB;  
431 - },  
432 - function(newValue, oldValue) {  
433 - scope[ctrlAs].$$internal_validate_model();  
434 - },  
435 - true  
436 - );  
437 -  
438 - /**  
439 - * 验证数据是否初始化完成,  
440 - * 所谓的初始化就是内部所有的数据被有效设定过一次。  
441 - */  
442 - scope[ctrlAs].$$internal_validate_init = function() {  
443 - var self = scope[ctrlAs];  
444 - var data_temp = self.$$data;  
445 - var dataSelect_temp = self.$$dataSelected;  
446 - var dataFBSelect_temp = self.$$dataFBSelected;  
447 - var dbbmnames = null;  
448 - var dbbmnamegroup = null;  
449 - var rycids = null;  
450 - var rycidgroup = null;  
451 -  
452 - var i = 0;  
453 - var j = 0;  
454 - var k = 0;  
455 -  
456 - if (self.$$data_xl_first_init &&  
457 - self.$$data_ry_first_init &&  
458 - self.$$data_rycid_first_init &&  
459 - self.$$data_rystart_first_init && !self.$$data_init) {  
460 - console.log("开始初始化数据");  
461 -  
462 - // 判定是否分班,字符串中包含-就是了  
463 - if (self.$$data_ry_first_data.indexOf("-") != -1 && dataFBSelect_temp.length == 0) { // 分班  
464 - self.$$isFB = true;  
465 -  
466 - // 搭班编码、人员配置id  
467 - dbbmnames = self.$$data_ry_first_data.split(",");  
468 - rycids = self.$$data_rycid_first_data.split(",");  
469 - for (i = 0; i < dbbmnames.length; i++) {  
470 - dataFBSelect_temp.push({  
471 - group: [],  
472 - isstart: false  
473 - });  
474 - dbbmnamegroup = dbbmnames[i].split("-");  
475 - rycidgroup = rycids[i].split("-");  
476 -  
477 - for (k = 0; k < dbbmnamegroup.length; k++) {  
478 - dataFBSelect_temp[i].group.push({  
479 - id: rycidgroup[k],  
480 - dbbm: dbbmnamegroup[k],  
481 - isselected: false  
482 - });  
483 -  
484 - for (j = 0; j < data_temp.length; j++) {  
485 - if (dataFBSelect_temp[i].group[k].dbbm == data_temp[j].dbbm) {  
486 - dataFBSelect_temp[i].group[k].jsy = data_temp[j].jsy;  
487 - dataFBSelect_temp[i].group[k].spy = data_temp[j].spy;  
488 - break;  
489 - }  
490 - }  
491 - }  
492 -  
493 - }  
494 -  
495 - // 初始人员  
496 - scope[ctrlAs].$$dataFBSelectedStart = self.$$data_rystart_first_data - 1;  
497 -  
498 -  
499 - } else if (dataSelect_temp.length == 0) {  
500 - self.$$isFB = false;  
501 -  
502 - // 搭班编码、人员配置id  
503 - dbbmnames = self.$$data_ry_first_data.split(",");  
504 - rycids = self.$$data_rycid_first_data.split(",");  
505 - for (i = 0; i < dbbmnames.length; i++) {  
506 - dataSelect_temp.push({  
507 - id: rycids[i],  
508 - dbbm: dbbmnames[i],  
509 - isstart: false  
510 - });  
511 - for (j = 0; j < data_temp.length; j++) {  
512 - if (dataSelect_temp[i].dbbm == data_temp[j].dbbm) {  
513 - dataSelect_temp[i].jsy = data_temp[j].jsy;  
514 - dataSelect_temp[i].spy = data_temp[j].spy;  
515 - break;  
516 - }  
517 - }  
518 - }  
519 - // 初始人员  
520 - scope[ctrlAs].$$dataSelectedStart = self.$$data_rystart_first_data - 1;  
521 -  
522 - }  
523 -  
524 - console.log("数据初始化完毕!");  
525 - self.$$data_init = true;  
526 - }  
527 -  
528 - };  
529 -  
530 - // 监控初始化标志,线路,人员,起始人员  
531 - scope.$watch(  
532 - function() {  
533 - return scope[ctrlAs].$$data_xl_first_init;  
534 - },  
535 - function(newValue, oldValue) {  
536 - scope[ctrlAs].$$internal_validate_init();  
537 - }  
538 - );  
539 - scope.$watch(  
540 - function() {  
541 - return scope[ctrlAs].$$data_ry_first_init;  
542 - },  
543 - function(newValue, oldValue) {  
544 - scope[ctrlAs].$$internal_validate_init();  
545 - }  
546 - );  
547 - scope.$watch(  
548 - function() {  
549 - return scope[ctrlAs].$$data_rycid_first_init;  
550 - },  
551 - function(newValue, oldValue) {  
552 - scope[ctrlAs].$$internal_validate_init();  
553 - }  
554 - );  
555 - scope.$watch(  
556 - function() {  
557 - return scope[ctrlAs].$$data_rystart_first_init;  
558 - },  
559 - function(newValue, oldValue) {  
560 - scope[ctrlAs].$$internal_validate_init();  
561 - }  
562 - );  
563 -  
564 -  
565 - // 监控线路id的变化  
566 - attr.$observe("xlidvalue", function(value) {  
567 - if (value && value != "") {  
568 - console.log("xlidvalue=" + value);  
569 -  
570 - employeeConfigService_g.rest.list(  
571 - {"xl.id_eq": value, "isCancel_eq" : false, size: 100},  
572 - function(result) {  
573 - // 获取值了  
574 - console.log("人员配置获取了");  
575 -  
576 - scope[ctrlAs].$$data = [];  
577 - for (var i = 0; i < result.content.length; i++) {  
578 - scope[ctrlAs].$$data.push({  
579 - id: result.content[i].id,  
580 - dbbm: result.content[i].dbbm,  
581 - jsy: result.content[i].jsy.personnelName,  
582 - spy: result.content[i].spy == null ? "" : result.content[i].spy.personnelName  
583 - });  
584 - }  
585 - if (scope[ctrlAs].$$data_init) {  
586 - scope[ctrlAs].$$dataSelected = [];  
587 - scope[ctrlAs].$$dataSelectedStart = undefined;  
588 -  
589 - scope[ctrlAs].$$dataFBSelected = [];  
590 - scope[ctrlAs].$$dataFBInternalSelected = undefined;  
591 - scope[ctrlAs].$$dataFBSelectedStart = undefined;  
592 -  
593 - scope[ctrlAs].$$internalmodel = undefined;  
594 - }  
595 - scope[ctrlAs].$$data_xl_first_init = true;  
596 - },  
597 - function(result) {  
598 -  
599 - }  
600 - );  
601 -  
602 - }  
603 - });  
604 -  
605 - // 监控搭班编码范围值的变化  
606 - attr.$observe("dbbmrangevalue", function(value) {  
607 - if (value && value != "") {  
608 - console.log("dbbmrangevalue变换了");  
609 - scope[ctrlAs].$$data_ry_first_init = true;  
610 - scope[ctrlAs].$$data_ry_first_data = value;  
611 - }  
612 - });  
613 -  
614 - // 监控人员配置id范围值的变化  
615 - attr.$observe("rycidrangevalue", function(value) {  
616 - if (value && value != "") {  
617 - console.log("rycidrangevalue变换了");  
618 - scope[ctrlAs].$$data_rycid_first_init = true;  
619 - scope[ctrlAs].$$data_rycid_first_data = value;  
620 - }  
621 - });  
622 -  
623 - // 监控起始人员的变化  
624 - attr.$observe("rystartvalue", function(value) {  
625 - if (value && value != "") {  
626 - console.log("rystartvalue变换了");  
627 - scope[ctrlAs].$$data_rystart_first_init = true;  
628 - scope[ctrlAs].$$data_rystart_first_data = value;  
629 - }  
630 - });  
631 -  
632 - }  
633 - }  
634 -  
635 - }  
636 - }  
637 - }  
638 -]);  
639 - 1 +
  2 +
  3 +/**
  4 + * saEmployeegroup指令
  5 + * 属性如下:
  6 + * name(必须):控件的名字
  7 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  8 + * xlidvalue(必须):绑定的model线路id值,如:xlidvalue={{ctrl.employeeInfoForSave.xl.id}}
  9 + * dbbmrangevalue(必须):绑定的model搭班编码范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}
  10 + * dbbmrangename(必须):绑定的model搭班编码范围字段名,如:lprangename=lprange
  11 + * rycidrangevalue(必须):绑定的model人员配置idid范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}
  12 + * rycidrangename(必须):绑定的model人员配置id范围字段名,如:lprangename=lprange
  13 + * rystartvalue(必须):绑定的model起始人员,如:lpstartvalue={{ctrl.employeeInfoForSave.lpstart}}
  14 + * rystartname(必须):绑定的model起始人员字段名,如:lpstartname=lpstart
  15 + *
  16 + * required(可选):是否要用required验证
  17 + *
  18 + */
  19 +angular.module('ScheduleApp').directive('saEmployeegroup', [
  20 + 'EmployeeConfigService_g',
  21 + function(employeeConfigService_g) {
  22 + return {
  23 + restrict: 'E',
  24 + templateUrl: '/pages/scheduleApp/module/common/dts2/employeeGroup/saEmployeegroupTemplate.html',
  25 + scope: {
  26 + model: "=" // 独立作用域,关联外部的模型object
  27 + },
  28 + controllerAs: '$saEmployeegroupCtrl',
  29 + bindToController: true,
  30 + controller: function($scope) {
  31 + var self = this;
  32 + self.$$data = []; // 选择线路后,该线路的人员配置数据
  33 +
  34 + // 测试数据
  35 + //self.$$data = [
  36 + // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1'},
  37 + // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2'},
  38 + // {id: 3, dbbm: "3", jsy: '忍3', spy: '守3'}
  39 + //];
  40 +
  41 + self.$$dataSelected = []; // 选中的人员配置列表
  42 + self.$$dataSelectedStart = undefined; // 起始人员配置
  43 +
  44 + //self.$$dataSelected = [
  45 + // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isstart: false},
  46 + // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true},
  47 + // {id: 3, dbbm: "3", jsy: '忍3', spy: '守3', isstart: false}
  48 + //];
  49 +
  50 + self.$$isFB = false; // 是否分班
  51 + self.$$dataFBSelected = []; // 选中的分班人员组配置列表
  52 + self.$$dataFBInternalSelected = undefined; // 分班组内人员选中标识
  53 + self.$$dataFBSelectedStart = undefined; // 选中的起始分班人员组合
  54 +
  55 + //self.$$dataFBSelected = [
  56 + // {isstart: true, group: [
  57 + // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isselected: false},
  58 + // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true}
  59 + // ]},
  60 + // {isstart: false, group: [
  61 + // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isselected: false},
  62 + // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true}
  63 + // ]}
  64 + //];
  65 +
  66 + // saGuideboardgroup组件的ng-model,用于外部绑定等操作
  67 + self.$$internalmodel = undefined;
  68 +
  69 + self.$$data_init = false; // *数据源初始化标志
  70 + self.$$data_xl_first_init = false; // 线路是否初始化
  71 + self.$$data_ry_first_init = false; // 人员配置是否初始化
  72 + self.$$data_ry_first_data = undefined; // 人员配置初始化数据
  73 + self.$$data_rycid_first_init = false; // 人员配置id是否初始化
  74 + self.$$data_rycid_first_data = undefined; // 人员配置id初始化数据
  75 + self.$$data_rystart_first_init = false; // 起始人员是否初始化
  76 + self.$$data_rystart_first_data = undefined; // 起始人员初始化数据
  77 +
  78 + },
  79 +
  80 + /**
  81 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  82 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  83 + * @param tElem
  84 + * @param tAttrs
  85 + * @returns {{pre: Function, post: Function}}
  86 + */
  87 + compile: function(tElem, tAttrs) {
  88 + // TODO:获取所有的属性
  89 + var $name_attr = tAttrs["name"]; // 控件的名字
  90 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  91 + var $dbbmrangename_attr = tAttrs["dbbmrangename"]; // 绑定的model搭班编码范围字段名
  92 + var rycidrangename_attr = tAttrs["rycidrangename"]; // 绑定的model人员配置id范围字段名
  93 + var $rystartname_attr = tAttrs["rystartname"]; // 绑定的model起始人员字段名
  94 +
  95 + // controlAs名字
  96 + var ctrlAs = '$saEmployeegroupCtrl';
  97 +
  98 + // 如果有required属性,添加angularjs required验证
  99 + if ($required_attr != undefined) {
  100 + //console.log(tElem.html());
  101 + tElem.find("div").attr("required", "");
  102 + }
  103 +
  104 + return {
  105 + pre: function(scope, element, attr) {
  106 + // TODO:
  107 + },
  108 +
  109 + /**
  110 + * 相当于link函数。
  111 + * @param scope
  112 + * @param element
  113 + * @param attr
  114 + */
  115 + post: function(scope, element, attr) {
  116 + // name属性
  117 + if ($name_attr) {
  118 + scope[ctrlAs]["$name_attr"] = $name_attr;
  119 + }
  120 +
  121 + /**
  122 + * 人员配置列表点击(人员配置列表中选中路牌)
  123 + * @param $index
  124 + */
  125 + scope[ctrlAs].$$internal_rylist_click = function($index) {
  126 + var data_temp = scope[ctrlAs].$$data;
  127 + if (data_temp && data_temp.length > $index) {
  128 + if (!scope[ctrlAs].$$isFB) { // 不分班
  129 + scope[ctrlAs].$$dataSelected.push({
  130 + id : data_temp[$index].id,
  131 + dbbm: data_temp[$index].dbbm,
  132 + jsy: data_temp[$index].jsy,
  133 + spy: data_temp[$index].spy,
  134 + isstart: false
  135 + });
  136 +
  137 + // 如果没有指定过初始人员,默认选择此人员作为起始人员
  138 + if (scope[ctrlAs].$$dataSelectedStart == undefined) {
  139 + scope[ctrlAs].$$internal_selrylist_click(
  140 + scope[ctrlAs].$$dataSelected.length - 1);
  141 + }
  142 + } else { // 分班
  143 + if (scope[ctrlAs].$$dataFBInternalSelected) { // 替换组内人员
  144 + scope[ctrlAs].$$dataFBSelected
  145 + [scope[ctrlAs].$$dataFBInternalSelected.gindex].group
  146 + [scope[ctrlAs].$$dataFBInternalSelected.index] = {
  147 + id : data_temp[$index].id,
  148 + dbbm: data_temp[$index].dbbm,
  149 + jsy: data_temp[$index].jsy,
  150 + spy: data_temp[$index].spy,
  151 + isselected: true
  152 + };
  153 +
  154 + } else {
  155 + scope[ctrlAs].$$dataFBSelected.push({
  156 + isstart: false,
  157 + group: [].concat(
  158 + {
  159 + id : data_temp[$index].id,
  160 + dbbm: data_temp[$index].dbbm,
  161 + jsy: data_temp[$index].jsy,
  162 + spy: data_temp[$index].spy,
  163 + isselected: false
  164 + }, {
  165 + id : data_temp[$index].id,
  166 + dbbm: data_temp[$index].dbbm,
  167 + jsy: data_temp[$index].jsy,
  168 + spy: data_temp[$index].spy,
  169 + isselected: false
  170 + }
  171 + )
  172 + });
  173 + if (scope[ctrlAs].$$dataFBSelectedStart == undefined) {
  174 + scope[ctrlAs].$$internal_selrygrouplist_click(
  175 + scope[ctrlAs].$$dataFBSelected.length - 1);
  176 + }
  177 + }
  178 + }
  179 +
  180 + }
  181 + };
  182 +
  183 + /**
  184 + * 选中的人员单击(初始人员选择)
  185 + * @param $index
  186 + */
  187 + scope[ctrlAs].$$internal_selrylist_click = function($index) {
  188 + var data_temp = scope[ctrlAs].$$dataSelected;
  189 + if (data_temp && data_temp.length > $index) {
  190 + for (var i = 0; i < data_temp.length; i++) {
  191 + data_temp[i].isstart = false;
  192 + }
  193 + data_temp[$index].isstart = true;
  194 + scope[ctrlAs].$$dataSelectedStart = $index;
  195 + }
  196 + };
  197 + /**
  198 + * 选中的人员双击(删除选中的人员)
  199 + * @param $index
  200 + */
  201 + scope[ctrlAs].$$internal_selrylist_dbclick = function($index) {
  202 + var data_temp = scope[ctrlAs].$$dataSelected;
  203 + if (data_temp && data_temp.length > $index) {
  204 + if (scope[ctrlAs].$$dataSelectedStart == $index) {
  205 + scope[ctrlAs].$$dataSelectedStart = undefined;
  206 + }
  207 + data_temp.splice($index, 1);
  208 + }
  209 + };
  210 +
  211 + /**
  212 + * 选中的分班组人员单击(初始人员选择)
  213 + * @param $index
  214 + */
  215 + scope[ctrlAs].$$internal_selrygrouplist_click = function($index) {
  216 + var data_temp = scope[ctrlAs].$$dataFBSelected;
  217 + if (data_temp && data_temp.length > $index) {
  218 + for (var i = 0; i < data_temp.length; i++) {
  219 + data_temp[i].isstart = false;
  220 + for (var j = 0; j < data_temp[i].group.length; j++) {
  221 + data_temp[i].group[j].isselected = false;
  222 + }
  223 + }
  224 + data_temp[$index].isstart = true;
  225 + scope[ctrlAs].$$dataFBSelectedStart = $index;
  226 + scope[ctrlAs].$$dataFBInternalSelected = undefined;
  227 + }
  228 + };
  229 + /**
  230 + * 分组内部单击(选中分班中的某组人员)
  231 + * @param $groupindex 组index
  232 + * @param $index 组内部某个index
  233 + * @param $event 事件防止冒泡
  234 + */
  235 + scope[ctrlAs].$$internal_selrygroup_click = function($groupindex, $index, $event) {
  236 + var data_temp = scope[ctrlAs].$$dataFBSelected;
  237 + if (data_temp && data_temp.length > $groupindex) {
  238 + if (data_temp[$groupindex].group && data_temp[$groupindex].group.length > $index) {
  239 + // $$dataFBInternalSelected的格式如下:
  240 + //{gindex: 1, index: 0}
  241 + for (var i = 0; i < data_temp.length; i++) {
  242 + data_temp[i].isstart = false;
  243 + for (var j = 0; j < data_temp[i].group.length; j++) {
  244 + data_temp[i].group[j].isselected = false;
  245 + }
  246 + }
  247 + data_temp[$groupindex].group[$index].isselected = true;
  248 + scope[ctrlAs].$$dataFBInternalSelected = {
  249 + gindex: $groupindex, index: $index
  250 + };
  251 + scope[ctrlAs].$$dataFBSelectedStart = undefined;
  252 + $event.stopPropagation();
  253 + }
  254 + }
  255 +
  256 + };
  257 + /**
  258 + * 选中的分班人员双击(删除选中的人员)
  259 + * @param $index
  260 + */
  261 + scope[ctrlAs].$$internal_selrygrouplist_dbclick = function($index) {
  262 + var data_temp = scope[ctrlAs].$$dataFBSelected;
  263 + if (data_temp && data_temp.length > $index) {
  264 + if (scope[ctrlAs].$$dataFBSelectedStart == $index) {
  265 + scope[ctrlAs].$$dataFBSelectedStart = undefined;
  266 + }
  267 + if (scope[ctrlAs].$$dataFBInternalSelected &&
  268 + scope[ctrlAs].$$dataFBInternalSelected.gindex == $index) {
  269 + scope[ctrlAs].$$dataFBInternalSelected = undefined;
  270 + }
  271 + data_temp.splice($index, 1);
  272 + }
  273 + };
  274 +
  275 + /**
  276 + * 验证内部数据,更新外部model
  277 + */
  278 + scope[ctrlAs].$$internal_validate_model = function() {
  279 + var data_temp = scope[ctrlAs].$$dataSelected;
  280 + var data_temp2 = scope[ctrlAs].$$dataSelectedStart;
  281 + var data_temp3 = scope[ctrlAs].$$dataFBSelected;
  282 + var data_temp4 = scope[ctrlAs].$$dataFBSelectedStart;
  283 + var ryDbbms = [];
  284 + var ryDbbm_group = [];
  285 + var ryCids = [];
  286 + var ryCid_group = [];
  287 + var ryStart = 0;
  288 + var i = 0;
  289 + var j = 0;
  290 +
  291 + var isFB = scope[ctrlAs].$$isFB;
  292 +
  293 + if (isFB) {
  294 + if (data_temp3 &&
  295 + data_temp3.length > 0 &&
  296 + data_temp4 != undefined) {
  297 +
  298 + for (i = 0; i < data_temp3.length; i++) {
  299 + for (j = 0; j < data_temp3[i].group.length; j++) {
  300 + ryDbbm_group.push(data_temp3[i].group[j].dbbm);
  301 + ryCid_group.push(data_temp3[i].group[j].id);
  302 + }
  303 + ryDbbms.push(ryDbbm_group.join("-"));
  304 + ryCids.push(ryCid_group.join("-"));
  305 + ryDbbm_group = [];
  306 + ryCid_group = [];
  307 + }
  308 +
  309 + data_temp3[data_temp4].isstart = true;
  310 + ryStart = data_temp4 + 1;
  311 +
  312 + // 更新内部model,用于外部验证
  313 + // 内部model的值暂时随意,以后再改
  314 + scope[ctrlAs].$$internalmodel = {desc: "ok"};
  315 +
  316 + // 更新外部model字段
  317 + if ($dbbmrangename_attr) {
  318 + console.log("dbbmrangename=" + ryDbbms.join(','));
  319 + eval("scope[ctrlAs].model" + "." + $dbbmrangename_attr + " = ryDbbms.join(',');");
  320 + }
  321 + if (rycidrangename_attr) {
  322 + console.log("rycidrangename=" + ryCids.join(','));
  323 + eval("scope[ctrlAs].model" + "." + rycidrangename_attr + " = ryCids.join(',');");
  324 + }
  325 + if ($rystartname_attr) {
  326 + console.log("rystartname=" + ryStart);
  327 + eval("scope[ctrlAs].model" + "." + $rystartname_attr + " = ryStart;");
  328 + }
  329 +
  330 + } else {
  331 + scope[ctrlAs].$$internalmodel = undefined;
  332 + }
  333 +
  334 + } else {
  335 + if (data_temp &&
  336 + data_temp.length > 0 &&
  337 + data_temp2 != undefined) {
  338 +
  339 + for (i = 0; i < data_temp.length; i++) {
  340 + ryDbbms.push(data_temp[i].dbbm);
  341 + ryCids.push(data_temp[i].id);
  342 + }
  343 + data_temp[data_temp2].isstart = true;
  344 + ryStart = data_temp2 + 1;
  345 +
  346 + // 更新内部model,用于外部验证
  347 + // 内部model的值暂时随意,以后再改
  348 + scope[ctrlAs].$$internalmodel = {desc: "ok"};
  349 +
  350 + // 更新外部model字段
  351 + if ($dbbmrangename_attr) {
  352 + console.log("dbbmrangename=" + ryDbbms.join(','));
  353 + eval("scope[ctrlAs].model" + "." + $dbbmrangename_attr + " = ryDbbms.join(',');");
  354 + }
  355 + if (rycidrangename_attr) {
  356 + console.log("rycidrangename=" + ryCids.join(','));
  357 + eval("scope[ctrlAs].model" + "." + rycidrangename_attr + " = ryCids.join(',');");
  358 + }
  359 + if ($rystartname_attr) {
  360 + console.log("rystartname=" + ryStart);
  361 + eval("scope[ctrlAs].model" + "." + $rystartname_attr + " = ryStart;");
  362 + }
  363 +
  364 + } else {
  365 + scope[ctrlAs].$$internalmodel = undefined;
  366 + }
  367 + }
  368 +
  369 + };
  370 +
  371 + // 监控内部数据,$$dataSelected 变化
  372 + scope.$watch(
  373 + function() {
  374 + return scope[ctrlAs].$$dataSelected;
  375 + },
  376 + function(newValue, oldValue) {
  377 + scope[ctrlAs].$$internal_validate_model();
  378 + },
  379 + true
  380 + );
  381 +
  382 + // 监控内部数据,$$dataSelectedStart 变化
  383 + scope.$watch(
  384 + function() {
  385 + return scope[ctrlAs].$$dataSelectedStart;
  386 + },
  387 + function(newValue, oldValue) {
  388 + scope[ctrlAs].$$internal_validate_model();
  389 + },
  390 + true
  391 + );
  392 +
  393 +
  394 + // 监控内部数据,$$dataFBSelected 变化
  395 + scope.$watch(
  396 + function() {
  397 + return scope[ctrlAs].$$dataFBSelected;
  398 + },
  399 + function(newValue, oldValue) {
  400 + scope[ctrlAs].$$internal_validate_model();
  401 + },
  402 + true
  403 + );
  404 +
  405 + // 监控内部数据,$$dataFBSelectedStart 变化
  406 + scope.$watch(
  407 + function() {
  408 + return scope[ctrlAs].$$dataFBSelectedStart;
  409 + },
  410 + function(newValue, oldValue) {
  411 + scope[ctrlAs].$$internal_validate_model();
  412 + },
  413 + true
  414 + );
  415 +
  416 + // 监控内部数据,$$dataFBInternalSelected 变化
  417 + scope.$watch(
  418 + function() {
  419 + return scope[ctrlAs].$$dataFBInternalSelected;
  420 + },
  421 + function(newValue, oldValue) {
  422 + scope[ctrlAs].$$internal_validate_model();
  423 + },
  424 + true
  425 + );
  426 +
  427 + // 监控内部数据,$$isFB 变化
  428 + scope.$watch(
  429 + function() {
  430 + return scope[ctrlAs].$$isFB;
  431 + },
  432 + function(newValue, oldValue) {
  433 + scope[ctrlAs].$$internal_validate_model();
  434 + },
  435 + true
  436 + );
  437 +
  438 + /**
  439 + * 验证数据是否初始化完成,
  440 + * 所谓的初始化就是内部所有的数据被有效设定过一次。
  441 + */
  442 + scope[ctrlAs].$$internal_validate_init = function() {
  443 + var self = scope[ctrlAs];
  444 + var data_temp = self.$$data;
  445 + var dataSelect_temp = self.$$dataSelected;
  446 + var dataFBSelect_temp = self.$$dataFBSelected;
  447 + var dbbmnames = null;
  448 + var dbbmnamegroup = null;
  449 + var rycids = null;
  450 + var rycidgroup = null;
  451 +
  452 + var i = 0;
  453 + var j = 0;
  454 + var k = 0;
  455 +
  456 + if (self.$$data_xl_first_init &&
  457 + self.$$data_ry_first_init &&
  458 + self.$$data_rycid_first_init &&
  459 + self.$$data_rystart_first_init && !self.$$data_init) {
  460 + console.log("开始初始化数据");
  461 +
  462 + // 判定是否分班,字符串中包含-就是了
  463 + if (self.$$data_ry_first_data.indexOf("-") != -1 && dataFBSelect_temp.length == 0) { // 分班
  464 + self.$$isFB = true;
  465 +
  466 + // 搭班编码、人员配置id
  467 + dbbmnames = self.$$data_ry_first_data.split(",");
  468 + rycids = self.$$data_rycid_first_data.split(",");
  469 + for (i = 0; i < dbbmnames.length; i++) {
  470 + dataFBSelect_temp.push({
  471 + group: [],
  472 + isstart: false
  473 + });
  474 + dbbmnamegroup = dbbmnames[i].split("-");
  475 + rycidgroup = rycids[i].split("-");
  476 +
  477 + for (k = 0; k < dbbmnamegroup.length; k++) {
  478 + dataFBSelect_temp[i].group.push({
  479 + id: rycidgroup[k],
  480 + dbbm: dbbmnamegroup[k],
  481 + isselected: false
  482 + });
  483 +
  484 + for (j = 0; j < data_temp.length; j++) {
  485 + if (dataFBSelect_temp[i].group[k].dbbm == data_temp[j].dbbm) {
  486 + dataFBSelect_temp[i].group[k].jsy = data_temp[j].jsy;
  487 + dataFBSelect_temp[i].group[k].spy = data_temp[j].spy;
  488 + break;
  489 + }
  490 + }
  491 + }
  492 +
  493 + }
  494 +
  495 + // 初始人员
  496 + scope[ctrlAs].$$dataFBSelectedStart = self.$$data_rystart_first_data - 1;
  497 +
  498 +
  499 + } else if (dataSelect_temp.length == 0) {
  500 + self.$$isFB = false;
  501 +
  502 + // 搭班编码、人员配置id
  503 + dbbmnames = self.$$data_ry_first_data.split(",");
  504 + rycids = self.$$data_rycid_first_data.split(",");
  505 + for (i = 0; i < dbbmnames.length; i++) {
  506 + dataSelect_temp.push({
  507 + id: rycids[i],
  508 + dbbm: dbbmnames[i],
  509 + isstart: false
  510 + });
  511 + for (j = 0; j < data_temp.length; j++) {
  512 + if (dataSelect_temp[i].dbbm == data_temp[j].dbbm) {
  513 + dataSelect_temp[i].jsy = data_temp[j].jsy;
  514 + dataSelect_temp[i].spy = data_temp[j].spy;
  515 + break;
  516 + }
  517 + }
  518 + }
  519 + // 初始人员
  520 + scope[ctrlAs].$$dataSelectedStart = self.$$data_rystart_first_data - 1;
  521 +
  522 + }
  523 +
  524 + console.log("数据初始化完毕!");
  525 + self.$$data_init = true;
  526 + }
  527 +
  528 + };
  529 +
  530 + // 监控初始化标志,线路,人员,起始人员
  531 + scope.$watch(
  532 + function() {
  533 + return scope[ctrlAs].$$data_xl_first_init;
  534 + },
  535 + function(newValue, oldValue) {
  536 + scope[ctrlAs].$$internal_validate_init();
  537 + }
  538 + );
  539 + scope.$watch(
  540 + function() {
  541 + return scope[ctrlAs].$$data_ry_first_init;
  542 + },
  543 + function(newValue, oldValue) {
  544 + scope[ctrlAs].$$internal_validate_init();
  545 + }
  546 + );
  547 + scope.$watch(
  548 + function() {
  549 + return scope[ctrlAs].$$data_rycid_first_init;
  550 + },
  551 + function(newValue, oldValue) {
  552 + scope[ctrlAs].$$internal_validate_init();
  553 + }
  554 + );
  555 + scope.$watch(
  556 + function() {
  557 + return scope[ctrlAs].$$data_rystart_first_init;
  558 + },
  559 + function(newValue, oldValue) {
  560 + scope[ctrlAs].$$internal_validate_init();
  561 + }
  562 + );
  563 +
  564 +
  565 + // 监控线路id的变化
  566 + attr.$observe("xlidvalue", function(value) {
  567 + if (value && value != "") {
  568 + console.log("xlidvalue=" + value);
  569 +
  570 + employeeConfigService_g.rest.list(
  571 + {"xl.id_eq": value, "isCancel_eq" : false, size: 100},
  572 + function(result) {
  573 + // 获取值了
  574 + console.log("人员配置获取了");
  575 +
  576 + scope[ctrlAs].$$data = [];
  577 + for (var i = 0; i < result.content.length; i++) {
  578 + scope[ctrlAs].$$data.push({
  579 + id: result.content[i].id,
  580 + dbbm: result.content[i].dbbm,
  581 + jsy: result.content[i].jsy.personnelName,
  582 + spy: result.content[i].spy == null ? "" : result.content[i].spy.personnelName
  583 + });
  584 + }
  585 + if (scope[ctrlAs].$$data_init) {
  586 + scope[ctrlAs].$$dataSelected = [];
  587 + scope[ctrlAs].$$dataSelectedStart = undefined;
  588 +
  589 + scope[ctrlAs].$$dataFBSelected = [];
  590 + scope[ctrlAs].$$dataFBInternalSelected = undefined;
  591 + scope[ctrlAs].$$dataFBSelectedStart = undefined;
  592 +
  593 + scope[ctrlAs].$$internalmodel = undefined;
  594 + }
  595 + scope[ctrlAs].$$data_xl_first_init = true;
  596 + },
  597 + function(result) {
  598 +
  599 + }
  600 + );
  601 +
  602 + }
  603 + });
  604 +
  605 + // 监控搭班编码范围值的变化
  606 + attr.$observe("dbbmrangevalue", function(value) {
  607 + if (value && value != "") {
  608 + console.log("dbbmrangevalue变换了");
  609 + scope[ctrlAs].$$data_ry_first_init = true;
  610 + scope[ctrlAs].$$data_ry_first_data = value;
  611 + }
  612 + });
  613 +
  614 + // 监控人员配置id范围值的变化
  615 + attr.$observe("rycidrangevalue", function(value) {
  616 + if (value && value != "") {
  617 + console.log("rycidrangevalue变换了");
  618 + scope[ctrlAs].$$data_rycid_first_init = true;
  619 + scope[ctrlAs].$$data_rycid_first_data = value;
  620 + }
  621 + });
  622 +
  623 + // 监控起始人员的变化
  624 + attr.$observe("rystartvalue", function(value) {
  625 + if (value && value != "") {
  626 + console.log("rystartvalue变换了");
  627 + scope[ctrlAs].$$data_rystart_first_init = true;
  628 + scope[ctrlAs].$$data_rystart_first_data = value;
  629 + }
  630 + });
  631 +
  632 + }
  633 + }
  634 +
  635 + }
  636 + }
  637 + }
  638 +]);
  639 +
src/main/resources/static/pages/scheduleApp/module/common/dts2/guideboardGroup/saGuideboardgroup.js
1 -  
2 -  
3 -/**  
4 - * saGuideboardgroup指令  
5 - * 属性如下:  
6 - * name(必须):控件的名字  
7 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
8 - * xlidvalue(必须):绑定的model线路id值,如:xlidvalue={{ctrl.employeeInfoForSave.xl.id}}  
9 - * lprangevalue(必须):绑定的model路牌名字范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}  
10 - * lprangename(必须):绑定的model路牌名字范围字段名,如:lprangename=lprange  
11 - * lpidrangevalue(必须):绑定的model路牌id范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}  
12 - * lpidrangename(必须):绑定的model路牌id范围字段名,如:lprangename=lprange  
13 - * lpstartvalue(必须):绑定的model起始路牌值,如:lpstartvalue={{ctrl.employeeInfoForSave.lpstart}}  
14 - * lpstartname(必须):绑定的model起始路牌字段名,如:lpstartname=lpstart  
15 - *  
16 - * required(可选):是否要用required验证  
17 - *  
18 - */  
19 -angular.module('ScheduleApp').directive('saGuideboardgroup', [  
20 - 'GuideboardManageService_g',  
21 - function(guideboardManageService_g) {  
22 - return {  
23 - restrict: 'E',  
24 - templateUrl: '/pages/scheduleApp/module/common/dts2/guideboardGroup/saGuideboardgroupTemplate.html',  
25 - scope: {  
26 - model: "=" // 独立作用域,关联外部的模型object  
27 - },  
28 - controllerAs: '$saGuideboardgroupCtrl',  
29 - bindToController: true,  
30 - controller: function($scope) {  
31 - var self = this;  
32 - self.$$data = []; // 选择线路后,该线路的路牌数据  
33 -  
34 - // 测试数据  
35 - //self.$$data = [  
36 - // {lpid: 1, lpname: '路1', isstart: false},  
37 - // {lpid: 2, lpname: '路2', isstart: true},  
38 - // {lpid: 3, lpname: '路3', isstart: false}  
39 - //];  
40 -  
41 -  
42 - self.$$dataSelected = []; // 选中的路牌列表  
43 - self.$$dataSelectedStart = undefined; // 起始路牌  
44 -  
45 - //self.$$dataSelected = [  
46 - // {lpid: 11, lpname: '路11', isstart: false},  
47 - // {lpid: 12, lpname: '路12', isstart: true},  
48 - // {lpid: 13, lpname: '路13', isstart: false}  
49 - //];  
50 -  
51 - // saGuideboardgroup组件的ng-model,用于外部绑定等操作  
52 - self.$$internalmodel = undefined;  
53 -  
54 - self.$$data_init = false; // *数据源初始化标志  
55 - self.$$data_xl_first_init = false; // 线路是否初始化  
56 - self.$$data_lp_first_init = false; // 路牌名字是否初始化  
57 - self.$$data_lpid_first_init = false; // 路牌id是否初始化  
58 - self.$$data_lpstart_first_init = false; // 起始路牌是否初始化  
59 -  
60 - },  
61 -  
62 - /**  
63 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
64 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
65 - * @param tElem  
66 - * @param tAttrs  
67 - * @returns {{pre: Function, post: Function}}  
68 - */  
69 - compile: function(tElem, tAttrs) {  
70 - // TODO:获取所有的属性  
71 - var $name_attr = tAttrs["name"]; // 控件的名字  
72 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
73 - var $lprangename_attr = tAttrs["lprangename"]; // 绑定的model路牌名字范围字段名  
74 - var $lpidrangename_attr = tAttrs["lpidrangename"]; // 绑定的model路牌id范围字段名  
75 - var $lpstartname_attr = tAttrs["lpstartname"]; // 绑定的model起始路牌字段名  
76 -  
77 - // controlAs名字  
78 - var ctrlAs = '$saGuideboardgroupCtrl';  
79 -  
80 - // 如果有required属性,添加angularjs required验证  
81 - if ($required_attr != undefined) {  
82 - //console.log(tElem.html());  
83 - tElem.find("div").attr("required", "");  
84 - }  
85 -  
86 - return {  
87 - pre: function(scope, element, attr) {  
88 - // TODO:  
89 - },  
90 -  
91 - /**  
92 - * 相当于link函数。  
93 - * @param scope  
94 - * @param element  
95 - * @param attr  
96 - */  
97 - post: function(scope, element, attr) {  
98 - // name属性  
99 - if ($name_attr) {  
100 - scope[ctrlAs]["$name_attr"] = $name_attr;  
101 - }  
102 -  
103 - // TODO:  
104 -  
105 -  
106 - /**  
107 - * 路牌列表点击(路牌列表中选中路牌)  
108 - * @param $index  
109 - */  
110 - scope[ctrlAs].$$internal_lplist_click = function($index) {  
111 - var data_temp = scope[ctrlAs].$$data;  
112 - if (data_temp && data_temp.length > $index) {  
113 - scope[ctrlAs].$$dataSelected.push({  
114 - lpid: data_temp[$index].lpid,  
115 - lpname: data_temp[$index].lpname,  
116 - isstart: data_temp[$index].isstart  
117 - });  
118 -  
119 - // 如果没有指定过初始路牌,默认选择此路牌作为起始路牌  
120 - if (scope[ctrlAs].$$dataSelectedStart == undefined) {  
121 - scope[ctrlAs].$$internal_sellplist_click(  
122 - scope[ctrlAs].$$dataSelected.length - 1);  
123 - }  
124 - }  
125 - };  
126 - /**  
127 - * 选中的路牌单击(初始路牌选择)  
128 - * @param $index  
129 - */  
130 - scope[ctrlAs].$$internal_sellplist_click = function($index) {  
131 - var data_temp = scope[ctrlAs].$$dataSelected;  
132 - if (data_temp && data_temp.length > $index) {  
133 - for (var i = 0; i < data_temp.length; i++) {  
134 - data_temp[i].isstart = false;  
135 - }  
136 - data_temp[$index].isstart = true;  
137 - scope[ctrlAs].$$dataSelectedStart = $index;  
138 - }  
139 - };  
140 - /**  
141 - * 选中的路牌双击(删除选中的路牌)  
142 - * @param $index  
143 - */  
144 - scope[ctrlAs].$$internal_sellplist_dbclick = function($index) {  
145 - var data_temp = scope[ctrlAs].$$dataSelected;  
146 - if (data_temp && data_temp.length > $index) {  
147 - if (scope[ctrlAs].$$dataSelectedStart == $index) {  
148 - scope[ctrlAs].$$dataSelectedStart = undefined;  
149 - }  
150 - data_temp.splice($index, 1);  
151 - }  
152 - };  
153 -  
154 -  
155 - /**  
156 - * 验证内部数据,更新外部model  
157 - */  
158 - scope[ctrlAs].$$internal_validate_model = function() {  
159 - var data_temp = scope[ctrlAs].$$dataSelected;  
160 - var data_temp2 = scope[ctrlAs].$$dataSelectedStart;  
161 - var lpNames = [];  
162 - var lpIds = [];  
163 - var lpStart = 0;  
164 - var i = 0;  
165 -  
166 - if (data_temp &&  
167 - data_temp.length > 0 &&  
168 - data_temp2 != undefined) {  
169 -  
170 - for (i = 0; i < data_temp.length; i++) {  
171 - lpNames.push(data_temp[i].lpname);  
172 - lpIds.push(data_temp[i].lpid)  
173 - }  
174 - data_temp[data_temp2].isstart = true;  
175 - lpStart = data_temp2 + 1;  
176 -  
177 - // 更新内部model,用于外部验证  
178 - // 内部model的值暂时随意,以后再改  
179 - scope[ctrlAs].$$internalmodel = {desc: "ok"};  
180 -  
181 - // 更新外部model字段  
182 - if ($lprangename_attr) {  
183 - console.log("lprangename=" + lpNames.join(','));  
184 - eval("scope[ctrlAs].model" + "." + $lprangename_attr + " = lpNames.join(',');");  
185 - }  
186 - if ($lpidrangename_attr) {  
187 - console.log("lpidrangename=" + lpIds.join(','));  
188 - eval("scope[ctrlAs].model" + "." + $lpidrangename_attr + " = lpIds.join(',');");  
189 - }  
190 - if ($lpstartname_attr) {  
191 - console.log("lpstartname=" + lpStart);  
192 - eval("scope[ctrlAs].model" + "." + $lpstartname_attr + " = lpStart;");  
193 - }  
194 -  
195 - } else {  
196 - scope[ctrlAs].$$internalmodel = undefined;  
197 - }  
198 -  
199 -  
200 - };  
201 -  
202 - // 监控内部数据,$$data_selected 变化  
203 - scope.$watch(  
204 - function() {  
205 - return scope[ctrlAs].$$dataSelected;  
206 - },  
207 - function(newValue, oldValue) {  
208 - scope[ctrlAs].$$internal_validate_model();  
209 - },  
210 - true  
211 - );  
212 -  
213 - // 监控内部数据,$$data_selected_start 变化  
214 - scope.$watch(  
215 - function() {  
216 - return scope[ctrlAs].$$dataSelectedStart;  
217 - },  
218 - function(newValue, oldValue) {  
219 - scope[ctrlAs].$$internal_validate_model();  
220 - },  
221 - true  
222 - );  
223 -  
224 - /**  
225 - * 验证数据是否初始化完成,  
226 - * 所谓的初始化就是内部所有的数据被有效设定过一次。  
227 - */  
228 - scope[ctrlAs].$$internal_validate_init = function() {  
229 - var self = scope[ctrlAs];  
230 -  
231 - if (self.$$data_xl_first_init &&  
232 - self.$$data_lp_first_init &&  
233 - self.$$data_lpid_first_init &&  
234 - self.$$data_lpstart_first_init) {  
235 - console.log("数据初始化完毕!");  
236 - self.$$data_init = true;  
237 - }  
238 -  
239 - };  
240 -  
241 - // 监控初始化标志,线路,路牌,路牌id,起始路牌  
242 - scope.$watch(  
243 - function() {  
244 - return scope[ctrlAs].$$data_xl_first_init;  
245 - },  
246 - function(newValue, oldValue) {  
247 - scope[ctrlAs].$$internal_validate_init();  
248 - }  
249 - );  
250 - scope.$watch(  
251 - function() {  
252 - return scope[ctrlAs].$$data_lp_first_init;  
253 - },  
254 - function(newValue, oldValue) {  
255 - scope[ctrlAs].$$internal_validate_init();  
256 - }  
257 - );  
258 - scope.$watch(  
259 - function() {  
260 - return scope[ctrlAs].$$data_lpid_first_init;  
261 - },  
262 - function(newValue, oldValue) {  
263 - scope[ctrlAs].$$internal_validate_init();  
264 - }  
265 - );  
266 - scope.$watch(  
267 - function() {  
268 - return scope[ctrlAs].$$data_lpstart_first_init;  
269 - },  
270 - function(newValue, oldValue) {  
271 - scope[ctrlAs].$$internal_validate_init();  
272 - }  
273 - );  
274 -  
275 -  
276 - // 监控线路id的变化  
277 - attr.$observe("xlidvalue", function(value) {  
278 - if (value && value != "") {  
279 - console.log("xlidvalue=" + value);  
280 -  
281 - guideboardManageService_g.rest.list(  
282 - {"xl.id_eq": value, size: 100},  
283 - function(result) {  
284 - // 获取值了  
285 - console.log("路牌获取了");  
286 -  
287 - scope[ctrlAs].$$data = [];  
288 - for (var i = 0; i < result.content.length; i++) {  
289 - scope[ctrlAs].$$data.push({  
290 - lpid: result.content[i].id,  
291 - lpname: result.content[i].lpName,  
292 - isstart: false  
293 - });  
294 - }  
295 - if (scope[ctrlAs].$$data_init) {  
296 - scope[ctrlAs].$$dataSelected = [];  
297 - scope[ctrlAs].$$dataSelectedStart = undefined;  
298 - scope[ctrlAs].$$internalmodel = undefined;  
299 - }  
300 - scope[ctrlAs].$$data_xl_first_init = true;  
301 - },  
302 - function(result) {  
303 -  
304 - }  
305 - );  
306 -  
307 - }  
308 - });  
309 -  
310 - // 监控路牌名称范围值的变化  
311 - attr.$observe("lprangevalue", function(value) {  
312 - if (value && value != "") {  
313 - var data_temp = scope[ctrlAs].$$dataSelected;  
314 - var lpnames = value.split(",");  
315 - var i = 0;  
316 - if (data_temp && data_temp.length == 0) { // 初始创建  
317 - console.log("lprangevalue变换了");  
318 - for (i = 0; i < lpnames.length; i++) {  
319 - scope[ctrlAs].$$dataSelected.push({  
320 - lpname: lpnames[i],  
321 - isstart: false  
322 - });  
323 - }  
324 - } else {  
325 - for (i = 0; i < lpnames.length; i++) {  
326 - data_temp[i].lpname = lpnames[i];  
327 - }  
328 - }  
329 - scope[ctrlAs].$$data_lp_first_init = true;  
330 - }  
331 - });  
332 -  
333 - // 监控路牌id范围值的变化  
334 - attr.$observe("lpidrangevalue", function(value) {  
335 - if (value && value != "") {  
336 - console.log("lpidrangevalue=" + value);  
337 - var data_temp = scope[ctrlAs].$$dataSelected;  
338 - var lpids = value.split(",");  
339 - var i = 0;  
340 - if (data_temp && data_temp.length == 0) { // 初始创建  
341 - console.log("lpidrangevalue");  
342 - for (i = 0; i < lpids.length; i++) {  
343 - scope[ctrlAs].$$dataSelected.push({  
344 - lpid: lpids[i],  
345 - isstart: false  
346 - });  
347 - }  
348 - } else {  
349 - for (i = 0; i < lpids.length; i++) {  
350 - data_temp[i].lpid = lpids[i];  
351 - }  
352 - }  
353 - scope[ctrlAs].$$data_lpid_first_init = true;  
354 - }  
355 - });  
356 -  
357 - // 监控起始路牌的变化  
358 - attr.$observe("lpstartvalue", function(value) {  
359 - if (value && value != "") {  
360 - scope[ctrlAs].$$dataSelectedStart = value - 1;  
361 - scope[ctrlAs].$$data_lpstart_first_init = true;  
362 - }  
363 - });  
364 -  
365 -  
366 -  
367 - }  
368 - }  
369 -  
370 - }  
371 - }  
372 - }  
373 -]);  
374 - 1 +
  2 +
  3 +/**
  4 + * saGuideboardgroup指令
  5 + * 属性如下:
  6 + * name(必须):控件的名字
  7 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  8 + * xlidvalue(必须):绑定的model线路id值,如:xlidvalue={{ctrl.employeeInfoForSave.xl.id}}
  9 + * lprangevalue(必须):绑定的model路牌名字范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}
  10 + * lprangename(必须):绑定的model路牌名字范围字段名,如:lprangename=lprange
  11 + * lpidrangevalue(必须):绑定的model路牌id范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}
  12 + * lpidrangename(必须):绑定的model路牌id范围字段名,如:lprangename=lprange
  13 + * lpstartvalue(必须):绑定的model起始路牌值,如:lpstartvalue={{ctrl.employeeInfoForSave.lpstart}}
  14 + * lpstartname(必须):绑定的model起始路牌字段名,如:lpstartname=lpstart
  15 + *
  16 + * required(可选):是否要用required验证
  17 + *
  18 + */
  19 +angular.module('ScheduleApp').directive('saGuideboardgroup', [
  20 + 'GuideboardManageService_g',
  21 + function(guideboardManageService_g) {
  22 + return {
  23 + restrict: 'E',
  24 + templateUrl: '/pages/scheduleApp/module/common/dts2/guideboardGroup/saGuideboardgroupTemplate.html',
  25 + scope: {
  26 + model: "=" // 独立作用域,关联外部的模型object
  27 + },
  28 + controllerAs: '$saGuideboardgroupCtrl',
  29 + bindToController: true,
  30 + controller: function($scope) {
  31 + var self = this;
  32 + self.$$data = []; // 选择线路后,该线路的路牌数据
  33 +
  34 + // 测试数据
  35 + //self.$$data = [
  36 + // {lpid: 1, lpname: '路1', isstart: false},
  37 + // {lpid: 2, lpname: '路2', isstart: true},
  38 + // {lpid: 3, lpname: '路3', isstart: false}
  39 + //];
  40 +
  41 +
  42 + self.$$dataSelected = []; // 选中的路牌列表
  43 + self.$$dataSelectedStart = undefined; // 起始路牌
  44 +
  45 + //self.$$dataSelected = [
  46 + // {lpid: 11, lpname: '路11', isstart: false},
  47 + // {lpid: 12, lpname: '路12', isstart: true},
  48 + // {lpid: 13, lpname: '路13', isstart: false}
  49 + //];
  50 +
  51 + // saGuideboardgroup组件的ng-model,用于外部绑定等操作
  52 + self.$$internalmodel = undefined;
  53 +
  54 + self.$$data_init = false; // *数据源初始化标志
  55 + self.$$data_xl_first_init = false; // 线路是否初始化
  56 + self.$$data_lp_first_init = false; // 路牌名字是否初始化
  57 + self.$$data_lpid_first_init = false; // 路牌id是否初始化
  58 + self.$$data_lpstart_first_init = false; // 起始路牌是否初始化
  59 +
  60 + },
  61 +
  62 + /**
  63 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  64 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  65 + * @param tElem
  66 + * @param tAttrs
  67 + * @returns {{pre: Function, post: Function}}
  68 + */
  69 + compile: function(tElem, tAttrs) {
  70 + // TODO:获取所有的属性
  71 + var $name_attr = tAttrs["name"]; // 控件的名字
  72 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  73 + var $lprangename_attr = tAttrs["lprangename"]; // 绑定的model路牌名字范围字段名
  74 + var $lpidrangename_attr = tAttrs["lpidrangename"]; // 绑定的model路牌id范围字段名
  75 + var $lpstartname_attr = tAttrs["lpstartname"]; // 绑定的model起始路牌字段名
  76 +
  77 + // controlAs名字
  78 + var ctrlAs = '$saGuideboardgroupCtrl';
  79 +
  80 + // 如果有required属性,添加angularjs required验证
  81 + if ($required_attr != undefined) {
  82 + //console.log(tElem.html());
  83 + tElem.find("div").attr("required", "");
  84 + }
  85 +
  86 + return {
  87 + pre: function(scope, element, attr) {
  88 + // TODO:
  89 + },
  90 +
  91 + /**
  92 + * 相当于link函数。
  93 + * @param scope
  94 + * @param element
  95 + * @param attr
  96 + */
  97 + post: function(scope, element, attr) {
  98 + // name属性
  99 + if ($name_attr) {
  100 + scope[ctrlAs]["$name_attr"] = $name_attr;
  101 + }
  102 +
  103 + // TODO:
  104 +
  105 +
  106 + /**
  107 + * 路牌列表点击(路牌列表中选中路牌)
  108 + * @param $index
  109 + */
  110 + scope[ctrlAs].$$internal_lplist_click = function($index) {
  111 + var data_temp = scope[ctrlAs].$$data;
  112 + if (data_temp && data_temp.length > $index) {
  113 + scope[ctrlAs].$$dataSelected.push({
  114 + lpid: data_temp[$index].lpid,
  115 + lpname: data_temp[$index].lpname,
  116 + isstart: data_temp[$index].isstart
  117 + });
  118 +
  119 + // 如果没有指定过初始路牌,默认选择此路牌作为起始路牌
  120 + if (scope[ctrlAs].$$dataSelectedStart == undefined) {
  121 + scope[ctrlAs].$$internal_sellplist_click(
  122 + scope[ctrlAs].$$dataSelected.length - 1);
  123 + }
  124 + }
  125 + };
  126 + /**
  127 + * 选中的路牌单击(初始路牌选择)
  128 + * @param $index
  129 + */
  130 + scope[ctrlAs].$$internal_sellplist_click = function($index) {
  131 + var data_temp = scope[ctrlAs].$$dataSelected;
  132 + if (data_temp && data_temp.length > $index) {
  133 + for (var i = 0; i < data_temp.length; i++) {
  134 + data_temp[i].isstart = false;
  135 + }
  136 + data_temp[$index].isstart = true;
  137 + scope[ctrlAs].$$dataSelectedStart = $index;
  138 + }
  139 + };
  140 + /**
  141 + * 选中的路牌双击(删除选中的路牌)
  142 + * @param $index
  143 + */
  144 + scope[ctrlAs].$$internal_sellplist_dbclick = function($index) {
  145 + var data_temp = scope[ctrlAs].$$dataSelected;
  146 + if (data_temp && data_temp.length > $index) {
  147 + if (scope[ctrlAs].$$dataSelectedStart == $index) {
  148 + scope[ctrlAs].$$dataSelectedStart = undefined;
  149 + }
  150 + data_temp.splice($index, 1);
  151 + }
  152 + };
  153 +
  154 +
  155 + /**
  156 + * 验证内部数据,更新外部model
  157 + */
  158 + scope[ctrlAs].$$internal_validate_model = function() {
  159 + var data_temp = scope[ctrlAs].$$dataSelected;
  160 + var data_temp2 = scope[ctrlAs].$$dataSelectedStart;
  161 + var lpNames = [];
  162 + var lpIds = [];
  163 + var lpStart = 0;
  164 + var i = 0;
  165 +
  166 + if (data_temp &&
  167 + data_temp.length > 0 &&
  168 + data_temp2 != undefined) {
  169 +
  170 + for (i = 0; i < data_temp.length; i++) {
  171 + lpNames.push(data_temp[i].lpname);
  172 + lpIds.push(data_temp[i].lpid)
  173 + }
  174 + data_temp[data_temp2].isstart = true;
  175 + lpStart = data_temp2 + 1;
  176 +
  177 + // 更新内部model,用于外部验证
  178 + // 内部model的值暂时随意,以后再改
  179 + scope[ctrlAs].$$internalmodel = {desc: "ok"};
  180 +
  181 + // 更新外部model字段
  182 + if ($lprangename_attr) {
  183 + console.log("lprangename=" + lpNames.join(','));
  184 + eval("scope[ctrlAs].model" + "." + $lprangename_attr + " = lpNames.join(',');");
  185 + }
  186 + if ($lpidrangename_attr) {
  187 + console.log("lpidrangename=" + lpIds.join(','));
  188 + eval("scope[ctrlAs].model" + "." + $lpidrangename_attr + " = lpIds.join(',');");
  189 + }
  190 + if ($lpstartname_attr) {
  191 + console.log("lpstartname=" + lpStart);
  192 + eval("scope[ctrlAs].model" + "." + $lpstartname_attr + " = lpStart;");
  193 + }
  194 +
  195 + } else {
  196 + scope[ctrlAs].$$internalmodel = undefined;
  197 + }
  198 +
  199 +
  200 + };
  201 +
  202 + // 监控内部数据,$$data_selected 变化
  203 + scope.$watch(
  204 + function() {
  205 + return scope[ctrlAs].$$dataSelected;
  206 + },
  207 + function(newValue, oldValue) {
  208 + scope[ctrlAs].$$internal_validate_model();
  209 + },
  210 + true
  211 + );
  212 +
  213 + // 监控内部数据,$$data_selected_start 变化
  214 + scope.$watch(
  215 + function() {
  216 + return scope[ctrlAs].$$dataSelectedStart;
  217 + },
  218 + function(newValue, oldValue) {
  219 + scope[ctrlAs].$$internal_validate_model();
  220 + },
  221 + true
  222 + );
  223 +
  224 + /**
  225 + * 验证数据是否初始化完成,
  226 + * 所谓的初始化就是内部所有的数据被有效设定过一次。
  227 + */
  228 + scope[ctrlAs].$$internal_validate_init = function() {
  229 + var self = scope[ctrlAs];
  230 +
  231 + if (self.$$data_xl_first_init &&
  232 + self.$$data_lp_first_init &&
  233 + self.$$data_lpid_first_init &&
  234 + self.$$data_lpstart_first_init) {
  235 + console.log("数据初始化完毕!");
  236 + self.$$data_init = true;
  237 + }
  238 +
  239 + };
  240 +
  241 + // 监控初始化标志,线路,路牌,路牌id,起始路牌
  242 + scope.$watch(
  243 + function() {
  244 + return scope[ctrlAs].$$data_xl_first_init;
  245 + },
  246 + function(newValue, oldValue) {
  247 + scope[ctrlAs].$$internal_validate_init();
  248 + }
  249 + );
  250 + scope.$watch(
  251 + function() {
  252 + return scope[ctrlAs].$$data_lp_first_init;
  253 + },
  254 + function(newValue, oldValue) {
  255 + scope[ctrlAs].$$internal_validate_init();
  256 + }
  257 + );
  258 + scope.$watch(
  259 + function() {
  260 + return scope[ctrlAs].$$data_lpid_first_init;
  261 + },
  262 + function(newValue, oldValue) {
  263 + scope[ctrlAs].$$internal_validate_init();
  264 + }
  265 + );
  266 + scope.$watch(
  267 + function() {
  268 + return scope[ctrlAs].$$data_lpstart_first_init;
  269 + },
  270 + function(newValue, oldValue) {
  271 + scope[ctrlAs].$$internal_validate_init();
  272 + }
  273 + );
  274 +
  275 +
  276 + // 监控线路id的变化
  277 + attr.$observe("xlidvalue", function(value) {
  278 + if (value && value != "") {
  279 + console.log("xlidvalue=" + value);
  280 +
  281 + guideboardManageService_g.rest.list(
  282 + {"xl.id_eq": value, size: 100},
  283 + function(result) {
  284 + // 获取值了
  285 + console.log("路牌获取了");
  286 +
  287 + scope[ctrlAs].$$data = [];
  288 + for (var i = 0; i < result.content.length; i++) {
  289 + scope[ctrlAs].$$data.push({
  290 + lpid: result.content[i].id,
  291 + lpname: result.content[i].lpName,
  292 + isstart: false
  293 + });
  294 + }
  295 + if (scope[ctrlAs].$$data_init) {
  296 + scope[ctrlAs].$$dataSelected = [];
  297 + scope[ctrlAs].$$dataSelectedStart = undefined;
  298 + scope[ctrlAs].$$internalmodel = undefined;
  299 + }
  300 + scope[ctrlAs].$$data_xl_first_init = true;
  301 + },
  302 + function(result) {
  303 +
  304 + }
  305 + );
  306 +
  307 + }
  308 + });
  309 +
  310 + // 监控路牌名称范围值的变化
  311 + attr.$observe("lprangevalue", function(value) {
  312 + if (value && value != "") {
  313 + var data_temp = scope[ctrlAs].$$dataSelected;
  314 + var lpnames = value.split(",");
  315 + var i = 0;
  316 + if (data_temp && data_temp.length == 0) { // 初始创建
  317 + console.log("lprangevalue变换了");
  318 + for (i = 0; i < lpnames.length; i++) {
  319 + scope[ctrlAs].$$dataSelected.push({
  320 + lpname: lpnames[i],
  321 + isstart: false
  322 + });
  323 + }
  324 + } else {
  325 + for (i = 0; i < lpnames.length; i++) {
  326 + data_temp[i].lpname = lpnames[i];
  327 + }
  328 + }
  329 + scope[ctrlAs].$$data_lp_first_init = true;
  330 + }
  331 + });
  332 +
  333 + // 监控路牌id范围值的变化
  334 + attr.$observe("lpidrangevalue", function(value) {
  335 + if (value && value != "") {
  336 + console.log("lpidrangevalue=" + value);
  337 + var data_temp = scope[ctrlAs].$$dataSelected;
  338 + var lpids = value.split(",");
  339 + var i = 0;
  340 + if (data_temp && data_temp.length == 0) { // 初始创建
  341 + console.log("lpidrangevalue");
  342 + for (i = 0; i < lpids.length; i++) {
  343 + scope[ctrlAs].$$dataSelected.push({
  344 + lpid: lpids[i],
  345 + isstart: false
  346 + });
  347 + }
  348 + } else {
  349 + for (i = 0; i < lpids.length; i++) {
  350 + data_temp[i].lpid = lpids[i];
  351 + }
  352 + }
  353 + scope[ctrlAs].$$data_lpid_first_init = true;
  354 + }
  355 + });
  356 +
  357 + // 监控起始路牌的变化
  358 + attr.$observe("lpstartvalue", function(value) {
  359 + if (value && value != "") {
  360 + scope[ctrlAs].$$dataSelectedStart = value - 1;
  361 + scope[ctrlAs].$$data_lpstart_first_init = true;
  362 + }
  363 + });
  364 +
  365 +
  366 +
  367 + }
  368 + }
  369 +
  370 + }
  371 + }
  372 + }
  373 +]);
  374 +
src/main/resources/static/pages/scheduleApp/module/common/prj-common-filter.js
1 -// 自定义filter  
2 -  
3 -angular.module('ScheduleApp').filter("dict", [function() {  
4 - /**  
5 - * 字典过滤器,将后台的字典编码转换成文字说明。  
6 - * code,过滤的值,group,过滤的参数(字典group类型),dv没有匹配到的默认值  
7 - * 用例:sfdc | dict:'dctype':'默认值'  
8 - */  
9 - return function(code, group, dv) {  
10 - if (code == null) {  
11 - return dv;  
12 - } else {  
13 - return dictionaryUtils.transformCode(group, code);  
14 - }  
15 - };  
16 -}]);  
17 -  
18 -  
19 -  
20 -angular.module('ScheduleApp').filter("$$pyFilter", function() {  
21 - return function(items, props) {  
22 - var out = [];  
23 - var limit = props["limit"] || 20; // 默认20条记录  
24 -  
25 - if (angular.isArray(items)) {  
26 - items.forEach(function(item) {  
27 - if (out.length < limit) {  
28 - if (props.search) {  
29 - var upTerm = props.search.toUpperCase();  
30 - if(item.fullChars.indexOf(upTerm) != -1  
31 - || item.camelChars.indexOf(upTerm) != -1) {  
32 - out.push(item);  
33 - }  
34 - }  
35 - }  
36 - });  
37 - }  
38 -  
39 - return out;  
40 - };  
41 -}); 1 +// 自定义filter
  2 +
  3 +angular.module('ScheduleApp').filter("dict", [function() {
  4 + /**
  5 + * 字典过滤器,将后台的字典编码转换成文字说明。
  6 + * code,过滤的值,group,过滤的参数(字典group类型),dv没有匹配到的默认值
  7 + * 用例:sfdc | dict:'dctype':'默认值'
  8 + */
  9 + return function(code, group, dv) {
  10 + if (code == null) {
  11 + return dv;
  12 + } else {
  13 + return dictionaryUtils.transformCode(group, code);
  14 + }
  15 + };
  16 +}]);
  17 +
  18 +
  19 +
  20 +angular.module('ScheduleApp').filter("$$pyFilter", function() {
  21 + return function(items, props) {
  22 + var out = [];
  23 + var limit = props["limit"] || 20; // 默认20条记录
  24 +
  25 + if (angular.isArray(items)) {
  26 + items.forEach(function(item) {
  27 + if (out.length < limit) {
  28 + if (props.search) {
  29 + var upTerm = props.search.toUpperCase();
  30 + if(item.fullChars.indexOf(upTerm) != -1
  31 + || item.camelChars.indexOf(upTerm) != -1) {
  32 + out.push(item);
  33 + }
  34 + }
  35 + }
  36 + });
  37 + }
  38 +
  39 + return out;
  40 + };
  41 +});
42 \ No newline at end of file 42 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
1 -// 项目通用的全局service服务,供不同的controller使用,自定义指令不使用  
2 -  
3 -// 文件下载服务  
4 -angular.module('ScheduleApp').factory('FileDownload_g', function() {  
5 - return {  
6 - downloadFile: function (data, mimeType, fileName) {  
7 - var success = false;  
8 - var blob = new Blob([data], { type: mimeType });  
9 - try {  
10 - if (navigator.msSaveBlob)  
11 - navigator.msSaveBlob(blob, fileName);  
12 - else {  
13 - // Try using other saveBlob implementations, if available  
14 - var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;  
15 - if (saveBlob === undefined) throw "Not supported";  
16 - saveBlob(blob, fileName);  
17 - }  
18 - success = true;  
19 - } catch (ex) {  
20 - console.log("saveBlob method failed with the following exception:");  
21 - console.log(ex);  
22 - }  
23 -  
24 - if (!success) {  
25 - // Get the blob url creator  
26 - var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;  
27 - if (urlCreator) {  
28 - // Try to use a download link  
29 - var link = document.createElement('a');  
30 - if ('download' in link) {  
31 - // Try to simulate a click  
32 - try {  
33 - // Prepare a blob URL  
34 - var url = urlCreator.createObjectURL(blob);  
35 - link.setAttribute('href', url);  
36 -  
37 - // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)  
38 - link.setAttribute("download", fileName);  
39 -  
40 - // Simulate clicking the download link  
41 - var event = document.createEvent('MouseEvents');  
42 - event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);  
43 - link.dispatchEvent(event);  
44 - success = true;  
45 -  
46 - } catch (ex) {  
47 - console.log("Download link method with simulated click failed with the following exception:");  
48 - console.log(ex);  
49 - }  
50 - }  
51 -  
52 - if (!success) {  
53 - // Fallback to window.location method  
54 - try {  
55 - // Prepare a blob URL  
56 - // Use application/octet-stream when using window.location to force download  
57 - var url = urlCreator.createObjectURL(blob);  
58 - window.location = url;  
59 - console.log("Download link method with window.location succeeded");  
60 - success = true;  
61 - } catch (ex) {  
62 - console.log("Download link method with window.location failed with the following exception:");  
63 - console.log(ex);  
64 - }  
65 - }  
66 - }  
67 - }  
68 -  
69 - if (!success) {  
70 - // Fallback to window.open method  
71 - console.log("No methods worked for saving the arraybuffer, using last resort window.open");  
72 - window.open("", '_blank', '');  
73 - }  
74 - }  
75 - };  
76 -});  
77 -  
78 -// 车辆信息service  
79 -angular.module('ScheduleApp').factory('BusInfoManageService_g', ['$resource', function($resource) {  
80 - return {  
81 - rest: $resource(  
82 - '/cars/:id',  
83 - {order: 'carCode', direction: 'ASC', id: '@id_route'},  
84 - {  
85 - list: {  
86 - method: 'GET',  
87 - params: {  
88 - page: 0  
89 - }  
90 - },  
91 - get: {  
92 - method: 'GET'  
93 - },  
94 - save: {  
95 - method: 'POST'  
96 - }  
97 - }  
98 - ),  
99 - validate: $resource(  
100 - '/cars/validate/:type',  
101 - {},  
102 - {  
103 - insideCode: {  
104 - method: 'GET'  
105 - }  
106 - }  
107 - ),  
108 - dataTools: $resource(  
109 - '/cars/:type',  
110 - {},  
111 - {  
112 - dataExport: {  
113 - method: 'GET',  
114 - responseType: "arraybuffer",  
115 - params: {  
116 - type: "dataExport"  
117 - },  
118 - transformResponse: function(data, headers){  
119 - return {data : data};  
120 - }  
121 - }  
122 - }  
123 - )  
124 - };  
125 -}]);  
126 -// 人员信息service  
127 -angular.module('ScheduleApp').factory('EmployeeInfoManageService_g', ['$resource', function($resource) {  
128 - return {  
129 - rest : $resource(  
130 - '/personnel/:id',  
131 - {order: 'jobCode', direction: 'ASC', id: '@id_route'},  
132 - {  
133 - list: {  
134 - method: 'GET',  
135 - params: {  
136 - page: 0  
137 - }  
138 - },  
139 - get: {  
140 - method: 'GET'  
141 - },  
142 - save: {  
143 - method: 'POST'  
144 - }  
145 - }  
146 - ),  
147 - validate: $resource(  
148 - '/personnel/validate/:type',  
149 - {},  
150 - {  
151 - jobCode: {  
152 - method: 'GET'  
153 - }  
154 - }  
155 - ),  
156 - dataTools: $resource(  
157 - '/personnel/:type',  
158 - {},  
159 - {  
160 - dataExport: {  
161 - method: 'GET',  
162 - responseType: "arraybuffer",  
163 - params: {  
164 - type: "dataExport"  
165 - },  
166 - transformResponse: function(data, headers){  
167 - return {data : data};  
168 - }  
169 - }  
170 - }  
171 - )  
172 - };  
173 -}]);  
174 -// 车辆设备信息service  
175 -angular.module('ScheduleApp').factory('DeviceInfoManageService_g', ['$resource', function($resource) {  
176 - return $resource(  
177 - '/cde/:id',  
178 - {order: 'xl,cl,qyrq', direction: 'DESC', id: '@id_route'},  
179 - {  
180 - list: {  
181 - method: 'GET',  
182 - params: {  
183 - page: 0  
184 - }  
185 - },  
186 - get: {  
187 - method: 'GET'  
188 - },  
189 - save: {  
190 - method: 'POST'  
191 - },  
192 - delete: {  
193 - method: 'DELETE'  
194 - }  
195 - }  
196 - );  
197 -}]);  
198 -  
199 -// 车辆配置service  
200 -angular.module('ScheduleApp').factory('BusConfigService_g', ['$resource', function($resource) {  
201 - return {  
202 - rest : $resource(  
203 - '/cci/:id',  
204 - {order: 'xl.id,cl.insideCode,isCancel', direction: 'ASC', id: '@id_route'},  
205 - {  
206 - list: {  
207 - method: 'GET',  
208 - params: {  
209 - page: 0  
210 - }  
211 - },  
212 - get: {  
213 - method: 'GET'  
214 - },  
215 - save: {  
216 - method: 'POST'  
217 - }  
218 - }  
219 - )  
220 - };  
221 -}]);  
222 -  
223 -// 人员配置service  
224 -angular.module('ScheduleApp').factory('EmployeeConfigService_g', ['$resource', function($resource) {  
225 - return {  
226 - rest : $resource(  
227 - '/eci/:id',  
228 - {order: 'xl.id,isCancel,dbbmFormula', direction: 'ASC', id: '@id_route'},  
229 - {  
230 - list: {  
231 - method: 'GET',  
232 - params: {  
233 - page: 0  
234 - }  
235 - },  
236 - get: {  
237 - method: 'GET'  
238 - },  
239 - save: {  
240 - method: 'POST'  
241 - },  
242 - delete: {  
243 - method: 'DELETE'  
244 - }  
245 - }  
246 - ),  
247 - validate: $resource( // TODO:  
248 - '/personnel/validate/:type',  
249 - {},  
250 - {  
251 - jobCode: {  
252 - method: 'GET'  
253 - }  
254 - }  
255 - )  
256 - };  
257 -}]);  
258 -  
259 -// 路牌管理service  
260 -angular.module('ScheduleApp').factory('GuideboardManageService_g', ['$resource', function($resource) {  
261 - return {  
262 - rest: $resource(  
263 - '/gic/:id',  
264 - {order: 'createDate', direction: 'DESC', id: '@id_route'},  
265 - {  
266 - list: {  
267 - method: 'GET',  
268 - params: {  
269 - page: 0  
270 - }  
271 - },  
272 - get: {  
273 - method: 'GET'  
274 - },  
275 - save: {  
276 - method: 'POST'  
277 - }  
278 - }  
279 - )  
280 - };  
281 -}]);  
282 -  
283 -// 排班管理service  
284 -angular.module('ScheduleApp').factory('ScheduleRuleManageService_g', ['$resource', function($resource) {  
285 - return {  
286 - rest: $resource(  
287 - '/sr1fc/:id',  
288 - {order: 'createDate', direction: 'DESC', id: '@id_route'},  
289 - {  
290 - list: {  
291 - method: 'GET',  
292 - params: {  
293 - page: 0  
294 - }  
295 - },  
296 - get: {  
297 - method: 'GET'  
298 - },  
299 - save: {  
300 - method: 'POST'  
301 - },  
302 - delete: {  
303 - method: 'DELETE'  
304 - }  
305 - }  
306 - )  
307 - };  
308 -}]);  
309 -  
310 -// 套跑管理service  
311 -angular.module('ScheduleApp').factory('rerunManageService_g', ['$resource', function($resource) {  
312 - return {  
313 - rest: $resource(  
314 - 'rms/:id',  
315 - {order: 'rerunXl.id,isCancel', direction: 'ASC', id: '@id_route'},  
316 - {  
317 - list: {  
318 - method: 'GET',  
319 - params: {  
320 - page: 0  
321 - }  
322 - },  
323 - get: {  
324 - method: 'GET'  
325 - },  
326 - save: {  
327 - method: 'POST'  
328 - },  
329 - delete: {  
330 - method: 'DELETE'  
331 - }  
332 - }  
333 - )  
334 - };  
335 -}]);  
336 -  
337 -// 时刻表管理service  
338 -angular.module('ScheduleApp').factory('TimeTableManageService_g', ['$resource', function($resource) {  
339 - return {  
340 - rest: $resource(  
341 - '/tic/:id',  
342 - {order: 'createDate', direction: 'DESC', id: '@id_route'},  
343 - {  
344 - list: {  
345 - method: 'GET',  
346 - params: {  
347 - page: 0,  
348 - isCancel_eq: 'false'  
349 - }  
350 - },  
351 - get: {  
352 - method: 'GET'  
353 - },  
354 - save: {  
355 - method: 'POST'  
356 - },  
357 - delete: {  
358 - method: 'DELETE'  
359 - }  
360 - }  
361 - ),  
362 - validate: $resource(  
363 - '/tic/validate/:type',  
364 - {},  
365 - {  
366 - ttinfoname: {  
367 - method: 'GET'  
368 - }  
369 - }  
370 - )  
371 - };  
372 -}]);  
373 -// 时刻表明细管理service  
374 -angular.module('ScheduleApp').factory('TimeTableDetailManageService_g', ['$resource', function($resource) {  
375 - return {  
376 - rest: $resource(  
377 - '/tidc/:id',  
378 - {order: 'createDate', direction: 'DESC', id: '@id_route'},  
379 - {  
380 - get: {  
381 - method: 'GET'  
382 - },  
383 - save: {  
384 - method: 'POST'  
385 - }  
386 - }  
387 - ),  
388 - edit: $resource(  
389 - '/tidc/edit/:xlid/:ttid',  
390 - {},  
391 - {  
392 - list: {  
393 - method: 'GET'  
394 - }  
395 - }  
396 - ),  
397 - bcdetails: $resource(  
398 - '/tidc/bcdetail',  
399 - {},  
400 - {  
401 - list: {  
402 - method: 'GET',  
403 - isArray: true  
404 - }  
405 - }  
406 - )  
407 - };  
408 -}]);  
409 -  
410 -  
411 -  
412 -// 排班计划管理service  
413 -angular.module('ScheduleApp').factory('SchedulePlanManageService_g', ['$resource', function($resource) {  
414 - return {  
415 - rest : $resource(  
416 - '/spc/:id',  
417 - {order: 'createDate', direction: 'DESC', id: '@id_route'},  
418 - {  
419 - list: {  
420 - method: 'GET',  
421 - params: {  
422 - page: 0  
423 - }  
424 - },  
425 - get: {  
426 - method: 'GET'  
427 - },  
428 - save: {  
429 - method: 'POST'  
430 - },  
431 - delete: {  
432 - method: 'DELETE'  
433 - }  
434 - }  
435 - ),  
436 - tommorw: $resource(  
437 - '/spc/tommorw',  
438 - {},  
439 - {  
440 - list: {  
441 - method: 'GET'  
442 - }  
443 - }  
444 - )  
445 - };  
446 -}]);  
447 -  
448 -// 排班计划明细管理service  
449 -angular.module('ScheduleApp').factory('SchedulePlanInfoManageService_g', ['$resource', function($resource) {  
450 - return {  
451 - rest : $resource(  
452 - '/spic/:id',  
453 - {order: 'scheduleDate,lp,fcno', direction: 'ASC', id: '@id_route'},  
454 - {  
455 - list: {  
456 - method: 'GET',  
457 - params: {  
458 - page: 0  
459 - }  
460 - },  
461 - get: {  
462 - method: 'GET'  
463 - },  
464 - save: {  
465 - method: 'POST'  
466 - }  
467 - }  
468 - ),  
469 - groupinfo : $resource(  
470 - '/spic/groupinfos/:xlid/:sdate',  
471 - {},  
472 - {  
473 - list: {  
474 - method: 'GET',  
475 - isArray: true  
476 - }  
477 - }  
478 - ),  
479 - updateGroupInfo : $resource(  
480 - '/spic/groupinfos/update',  
481 - {},  
482 - {  
483 - update: {  
484 - method: 'POST'  
485 - }  
486 - }  
487 - )  
488 - };  
489 -}]);  
490 -  
491 -// 线路运营统计service  
492 -angular.module('ScheduleApp').factory('BusLineInfoStatService_g', ['$resource', function($resource) {  
493 - return $resource(  
494 - '/bic/:id',  
495 - {order: 'createDate', direction: 'DESC', id: '@id_route'}, // TODO:以后需要根据属性对象的属性查询  
496 - {  
497 - list: {  
498 - method: 'GET',  
499 - params: {  
500 - page: 0  
501 - }  
502 - }  
503 - }  
504 - );  
505 -}]);  
506 -  
507 -  
508 -  
509 -  
510 -/**  
511 - * saSelect2指令,根据属性值,动态载入数据,然后支持拼音搜索,点击右边的按钮清除选择并重新载入数据。  
512 - * 1、compile阶段使用的属性如下:  
513 - * required:用于和表单验证连接,指定成required="true"才有效。  
514 - * 2、link阶段使用的属性如下  
515 - * model:关联的模型对象  
516 - * name:表单验证时需要的名字  
517 - * type:关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加  
518 - * modelcolname1:关联的模型字段名字1(一般应该是编码字段)  
519 - * modelcolname2:关联的模型字段名字2(一般应该是名字字段)  
520 - * datacolname1;内部数据对应的字段名字1(与模型字段1对应)  
521 - * datacolname2:内部数据对应的字段名字2(与模型字段2对应)  
522 - * showcolname:下拉框显示的内部数据字段名(注意:不是模型数据字段名),TODO:以后考虑放动态表达式,并在compile阶段使用  
523 - * placeholder:select placeholder字符串描述  
524 - *  
525 - * $$pyFilter,内部的filter指令,结合简拼音进行拼音过滤。  
526 - * $$SearchInfoService_g,内部使用的数据服务  
527 - */  
528 -// saSelect2指令使用的内部信service  
529 -angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', function($resource) {  
530 - return {  
531 - xl: $resource(  
532 - '/line/:type',  
533 - {order: 'name', direction: 'ASC'},  
534 - {  
535 - list: {  
536 - method: 'GET',  
537 - isArray: true  
538 - }  
539 - }  
540 - ),  
541 - zd: $resource(  
542 - '/stationroute/stations',  
543 - {order: 'stationCode', direction: 'ASC'},  
544 - {  
545 - list: {  
546 - method: 'GET',  
547 - isArray: true  
548 - }  
549 - }  
550 - ),  
551 - tcc: $resource(  
552 - '/carpark/:type',  
553 - {order: 'parkCode', direction: 'ASC'},  
554 - {  
555 - list: {  
556 - method: 'GET',  
557 - isArray: true  
558 - }  
559 - }  
560 - ),  
561 - ry: $resource(  
562 - '/personnel/:type',  
563 - {order: 'personnelName', direction: 'ASC'},  
564 - {  
565 - list: {  
566 - method: 'GET',  
567 - isArray: true  
568 - }  
569 - }  
570 - ),  
571 - cl: $resource(  
572 - '/cars/:type',  
573 - {order: "insideCode", direction: 'ASC'},  
574 - {  
575 - list: {  
576 - method: 'GET',  
577 - isArray: true  
578 - }  
579 - }  
580 - ),  
581 - ttInfo: $resource(  
582 - '/tic/:type',  
583 - {order: "name", direction: 'ASC'},  
584 - {  
585 - list: {  
586 - method: 'GET',  
587 - isArray: true  
588 - }  
589 - }  
590 - ),  
591 - lpInfo: $resource(  
592 - '/gic/ttlpnames',  
593 - {order: "lpName", direction: 'ASC'},  
594 - {  
595 - list: {  
596 - method: 'GET',  
597 - isArray: true  
598 - }  
599 - }  
600 - ),  
601 - lpInfo2: $resource(  
602 - '/gic/:type',  
603 - {order: "lpName", direction: 'ASC'},  
604 - {  
605 - list: {  
606 - method: 'GET',  
607 - isArray: true  
608 - }  
609 - }  
610 - ),  
611 - cci: $resource(  
612 - '/cci/cars',  
613 - {},  
614 - {  
615 - list: {  
616 - method: 'GET',  
617 - isArray: true  
618 - }  
619 - }  
620 -  
621 - ),  
622 - cci2: $resource(  
623 - '/cci/:type',  
624 - {},  
625 - {  
626 - list: {  
627 - method: 'GET',  
628 - isArray: true  
629 - }  
630 - }  
631 - ),  
632 - cci3: $resource(  
633 - '/cci/cars2',  
634 - {},  
635 - {  
636 - list: {  
637 - method: 'GET',  
638 - isArray: true  
639 - }  
640 - }  
641 -  
642 - ),  
643 - eci: $resource(  
644 - '/eci/jsy',  
645 - {},  
646 - {  
647 - list: {  
648 - method: 'GET',  
649 - isArray: true  
650 - }  
651 - }  
652 - ),  
653 - eci2: $resource(  
654 - '/eci/spy',  
655 - {},  
656 - {  
657 - list: {  
658 - method: 'GET',  
659 - isArray: true  
660 - }  
661 - }  
662 - ),  
663 - eci3: $resource(  
664 - '/eci/:type',  
665 - {},  
666 - {  
667 - list: {  
668 - method: 'GET',  
669 - isArray: true  
670 - }  
671 - }  
672 - )  
673 - }  
674 -}]);  
675 -  
676 -  
677 - 1 +// 项目通用的全局service服务,供不同的controller使用,自定义指令不使用
  2 +
  3 +// 文件下载服务
  4 +angular.module('ScheduleApp').factory('FileDownload_g', function() {
  5 + return {
  6 + downloadFile: function (data, mimeType, fileName) {
  7 + var success = false;
  8 + var blob = new Blob([data], { type: mimeType });
  9 + try {
  10 + if (navigator.msSaveBlob)
  11 + navigator.msSaveBlob(blob, fileName);
  12 + else {
  13 + // Try using other saveBlob implementations, if available
  14 + var saveBlob = navigator.webkitSaveBlob || navigator.mozSaveBlob || navigator.saveBlob;
  15 + if (saveBlob === undefined) throw "Not supported";
  16 + saveBlob(blob, fileName);
  17 + }
  18 + success = true;
  19 + } catch (ex) {
  20 + console.log("saveBlob method failed with the following exception:");
  21 + console.log(ex);
  22 + }
  23 +
  24 + if (!success) {
  25 + // Get the blob url creator
  26 + var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL;
  27 + if (urlCreator) {
  28 + // Try to use a download link
  29 + var link = document.createElement('a');
  30 + if ('download' in link) {
  31 + // Try to simulate a click
  32 + try {
  33 + // Prepare a blob URL
  34 + var url = urlCreator.createObjectURL(blob);
  35 + link.setAttribute('href', url);
  36 +
  37 + // Set the download attribute (Supported in Chrome 14+ / Firefox 20+)
  38 + link.setAttribute("download", fileName);
  39 +
  40 + // Simulate clicking the download link
  41 + var event = document.createEvent('MouseEvents');
  42 + event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
  43 + link.dispatchEvent(event);
  44 + success = true;
  45 +
  46 + } catch (ex) {
  47 + console.log("Download link method with simulated click failed with the following exception:");
  48 + console.log(ex);
  49 + }
  50 + }
  51 +
  52 + if (!success) {
  53 + // Fallback to window.location method
  54 + try {
  55 + // Prepare a blob URL
  56 + // Use application/octet-stream when using window.location to force download
  57 + var url = urlCreator.createObjectURL(blob);
  58 + window.location = url;
  59 + console.log("Download link method with window.location succeeded");
  60 + success = true;
  61 + } catch (ex) {
  62 + console.log("Download link method with window.location failed with the following exception:");
  63 + console.log(ex);
  64 + }
  65 + }
  66 + }
  67 + }
  68 +
  69 + if (!success) {
  70 + // Fallback to window.open method
  71 + console.log("No methods worked for saving the arraybuffer, using last resort window.open");
  72 + window.open("", '_blank', '');
  73 + }
  74 + }
  75 + };
  76 +});
  77 +
  78 +// 车辆信息service
  79 +angular.module('ScheduleApp').factory('BusInfoManageService_g', ['$resource', function($resource) {
  80 + return {
  81 + rest: $resource(
  82 + '/cars/:id',
  83 + {order: 'carCode', direction: 'ASC', id: '@id_route'},
  84 + {
  85 + list: {
  86 + method: 'GET',
  87 + params: {
  88 + page: 0
  89 + }
  90 + },
  91 + get: {
  92 + method: 'GET'
  93 + },
  94 + save: {
  95 + method: 'POST'
  96 + }
  97 + }
  98 + ),
  99 + validate: $resource(
  100 + '/cars/validate/:type',
  101 + {},
  102 + {
  103 + insideCode: {
  104 + method: 'GET'
  105 + }
  106 + }
  107 + ),
  108 + dataTools: $resource(
  109 + '/cars/:type',
  110 + {},
  111 + {
  112 + dataExport: {
  113 + method: 'GET',
  114 + responseType: "arraybuffer",
  115 + params: {
  116 + type: "dataExport"
  117 + },
  118 + transformResponse: function(data, headers){
  119 + return {data : data};
  120 + }
  121 + }
  122 + }
  123 + )
  124 + };
  125 +}]);
  126 +// 人员信息service
  127 +angular.module('ScheduleApp').factory('EmployeeInfoManageService_g', ['$resource', function($resource) {
  128 + return {
  129 + rest : $resource(
  130 + '/personnel/:id',
  131 + {order: 'jobCode', direction: 'ASC', id: '@id_route'},
  132 + {
  133 + list: {
  134 + method: 'GET',
  135 + params: {
  136 + page: 0
  137 + }
  138 + },
  139 + get: {
  140 + method: 'GET'
  141 + },
  142 + save: {
  143 + method: 'POST'
  144 + }
  145 + }
  146 + ),
  147 + validate: $resource(
  148 + '/personnel/validate/:type',
  149 + {},
  150 + {
  151 + jobCode: {
  152 + method: 'GET'
  153 + }
  154 + }
  155 + ),
  156 + dataTools: $resource(
  157 + '/personnel/:type',
  158 + {},
  159 + {
  160 + dataExport: {
  161 + method: 'GET',
  162 + responseType: "arraybuffer",
  163 + params: {
  164 + type: "dataExport"
  165 + },
  166 + transformResponse: function(data, headers){
  167 + return {data : data};
  168 + }
  169 + }
  170 + }
  171 + )
  172 + };
  173 +}]);
  174 +// 车辆设备信息service
  175 +angular.module('ScheduleApp').factory('DeviceInfoManageService_g', ['$resource', function($resource) {
  176 + return $resource(
  177 + '/cde/:id',
  178 + {order: 'xl,cl,qyrq', direction: 'DESC', id: '@id_route'},
  179 + {
  180 + list: {
  181 + method: 'GET',
  182 + params: {
  183 + page: 0
  184 + }
  185 + },
  186 + get: {
  187 + method: 'GET'
  188 + },
  189 + save: {
  190 + method: 'POST'
  191 + },
  192 + delete: {
  193 + method: 'DELETE'
  194 + }
  195 + }
  196 + );
  197 +}]);
  198 +
  199 +// 车辆配置service
  200 +angular.module('ScheduleApp').factory('BusConfigService_g', ['$resource', function($resource) {
  201 + return {
  202 + rest : $resource(
  203 + '/cci/:id',
  204 + {order: 'xl.id,cl.insideCode,isCancel', direction: 'ASC', id: '@id_route'},
  205 + {
  206 + list: {
  207 + method: 'GET',
  208 + params: {
  209 + page: 0
  210 + }
  211 + },
  212 + get: {
  213 + method: 'GET'
  214 + },
  215 + save: {
  216 + method: 'POST'
  217 + }
  218 + }
  219 + )
  220 + };
  221 +}]);
  222 +
  223 +// 人员配置service
  224 +angular.module('ScheduleApp').factory('EmployeeConfigService_g', ['$resource', function($resource) {
  225 + return {
  226 + rest : $resource(
  227 + '/eci/:id',
  228 + {order: 'xl.id,isCancel,dbbmFormula', direction: 'ASC', id: '@id_route'},
  229 + {
  230 + list: {
  231 + method: 'GET',
  232 + params: {
  233 + page: 0
  234 + }
  235 + },
  236 + get: {
  237 + method: 'GET'
  238 + },
  239 + save: {
  240 + method: 'POST'
  241 + },
  242 + delete: {
  243 + method: 'DELETE'
  244 + }
  245 + }
  246 + ),
  247 + validate: $resource( // TODO:
  248 + '/personnel/validate/:type',
  249 + {},
  250 + {
  251 + jobCode: {
  252 + method: 'GET'
  253 + }
  254 + }
  255 + )
  256 + };
  257 +}]);
  258 +
  259 +// 路牌管理service
  260 +angular.module('ScheduleApp').factory('GuideboardManageService_g', ['$resource', function($resource) {
  261 + return {
  262 + rest: $resource(
  263 + '/gic/:id',
  264 + {order: 'createDate', direction: 'DESC', id: '@id_route'},
  265 + {
  266 + list: {
  267 + method: 'GET',
  268 + params: {
  269 + page: 0
  270 + }
  271 + },
  272 + get: {
  273 + method: 'GET'
  274 + },
  275 + save: {
  276 + method: 'POST'
  277 + }
  278 + }
  279 + )
  280 + };
  281 +}]);
  282 +
  283 +// 排班管理service
  284 +angular.module('ScheduleApp').factory('ScheduleRuleManageService_g', ['$resource', function($resource) {
  285 + return {
  286 + rest: $resource(
  287 + '/sr1fc/:id',
  288 + {order: 'createDate', direction: 'DESC', id: '@id_route'},
  289 + {
  290 + list: {
  291 + method: 'GET',
  292 + params: {
  293 + page: 0
  294 + }
  295 + },
  296 + get: {
  297 + method: 'GET'
  298 + },
  299 + save: {
  300 + method: 'POST'
  301 + },
  302 + delete: {
  303 + method: 'DELETE'
  304 + }
  305 + }
  306 + )
  307 + };
  308 +}]);
  309 +
  310 +// 套跑管理service
  311 +angular.module('ScheduleApp').factory('rerunManageService_g', ['$resource', function($resource) {
  312 + return {
  313 + rest: $resource(
  314 + 'rms/:id',
  315 + {order: 'rerunXl.id,isCancel', direction: 'ASC', id: '@id_route'},
  316 + {
  317 + list: {
  318 + method: 'GET',
  319 + params: {
  320 + page: 0
  321 + }
  322 + },
  323 + get: {
  324 + method: 'GET'
  325 + },
  326 + save: {
  327 + method: 'POST'
  328 + },
  329 + delete: {
  330 + method: 'DELETE'
  331 + }
  332 + }
  333 + )
  334 + };
  335 +}]);
  336 +
  337 +// 时刻表管理service
  338 +angular.module('ScheduleApp').factory('TimeTableManageService_g', ['$resource', function($resource) {
  339 + return {
  340 + rest: $resource(
  341 + '/tic/:id',
  342 + {order: 'createDate', direction: 'DESC', id: '@id_route'},
  343 + {
  344 + list: {
  345 + method: 'GET',
  346 + params: {
  347 + page: 0,
  348 + isCancel_eq: 'false'
  349 + }
  350 + },
  351 + get: {
  352 + method: 'GET'
  353 + },
  354 + save: {
  355 + method: 'POST'
  356 + },
  357 + delete: {
  358 + method: 'DELETE'
  359 + }
  360 + }
  361 + ),
  362 + validate: $resource(
  363 + '/tic/validate/:type',
  364 + {},
  365 + {
  366 + ttinfoname: {
  367 + method: 'GET'
  368 + }
  369 + }
  370 + )
  371 + };
  372 +}]);
  373 +// 时刻表明细管理service
  374 +angular.module('ScheduleApp').factory('TimeTableDetailManageService_g', ['$resource', function($resource) {
  375 + return {
  376 + rest: $resource(
  377 + '/tidc/:id',
  378 + {order: 'createDate', direction: 'DESC', id: '@id_route'},
  379 + {
  380 + get: {
  381 + method: 'GET'
  382 + },
  383 + save: {
  384 + method: 'POST'
  385 + }
  386 + }
  387 + ),
  388 + edit: $resource(
  389 + '/tidc/edit/:xlid/:ttid',
  390 + {},
  391 + {
  392 + list: {
  393 + method: 'GET'
  394 + }
  395 + }
  396 + ),
  397 + bcdetails: $resource(
  398 + '/tidc/bcdetail',
  399 + {},
  400 + {
  401 + list: {
  402 + method: 'GET',
  403 + isArray: true
  404 + }
  405 + }
  406 + )
  407 + };
  408 +}]);
  409 +
  410 +
  411 +
  412 +// 排班计划管理service
  413 +angular.module('ScheduleApp').factory('SchedulePlanManageService_g', ['$resource', function($resource) {
  414 + return {
  415 + rest : $resource(
  416 + '/spc/:id',
  417 + {order: 'createDate', direction: 'DESC', id: '@id_route'},
  418 + {
  419 + list: {
  420 + method: 'GET',
  421 + params: {
  422 + page: 0
  423 + }
  424 + },
  425 + get: {
  426 + method: 'GET'
  427 + },
  428 + save: {
  429 + method: 'POST'
  430 + },
  431 + delete: {
  432 + method: 'DELETE'
  433 + }
  434 + }
  435 + ),
  436 + tommorw: $resource(
  437 + '/spc/tommorw',
  438 + {},
  439 + {
  440 + list: {
  441 + method: 'GET'
  442 + }
  443 + }
  444 + )
  445 + };
  446 +}]);
  447 +
  448 +// 排班计划明细管理service
  449 +angular.module('ScheduleApp').factory('SchedulePlanInfoManageService_g', ['$resource', function($resource) {
  450 + return {
  451 + rest : $resource(
  452 + '/spic/:id',
  453 + {order: 'scheduleDate,lp,fcno', direction: 'ASC', id: '@id_route'},
  454 + {
  455 + list: {
  456 + method: 'GET',
  457 + params: {
  458 + page: 0
  459 + }
  460 + },
  461 + get: {
  462 + method: 'GET'
  463 + },
  464 + save: {
  465 + method: 'POST'
  466 + }
  467 + }
  468 + ),
  469 + groupinfo : $resource(
  470 + '/spic/groupinfos/:xlid/:sdate',
  471 + {},
  472 + {
  473 + list: {
  474 + method: 'GET',
  475 + isArray: true
  476 + }
  477 + }
  478 + ),
  479 + updateGroupInfo : $resource(
  480 + '/spic/groupinfos/update',
  481 + {},
  482 + {
  483 + update: {
  484 + method: 'POST'
  485 + }
  486 + }
  487 + )
  488 + };
  489 +}]);
  490 +
  491 +// 线路运营统计service
  492 +angular.module('ScheduleApp').factory('BusLineInfoStatService_g', ['$resource', function($resource) {
  493 + return $resource(
  494 + '/bic/:id',
  495 + {order: 'createDate', direction: 'DESC', id: '@id_route'}, // TODO:以后需要根据属性对象的属性查询
  496 + {
  497 + list: {
  498 + method: 'GET',
  499 + params: {
  500 + page: 0
  501 + }
  502 + }
  503 + }
  504 + );
  505 +}]);
  506 +
  507 +
  508 +
  509 +
  510 +/**
  511 + * saSelect2指令,根据属性值,动态载入数据,然后支持拼音搜索,点击右边的按钮清除选择并重新载入数据。
  512 + * 1、compile阶段使用的属性如下:
  513 + * required:用于和表单验证连接,指定成required="true"才有效。
  514 + * 2、link阶段使用的属性如下
  515 + * model:关联的模型对象
  516 + * name:表单验证时需要的名字
  517 + * type:关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加
  518 + * modelcolname1:关联的模型字段名字1(一般应该是编码字段)
  519 + * modelcolname2:关联的模型字段名字2(一般应该是名字字段)
  520 + * datacolname1;内部数据对应的字段名字1(与模型字段1对应)
  521 + * datacolname2:内部数据对应的字段名字2(与模型字段2对应)
  522 + * showcolname:下拉框显示的内部数据字段名(注意:不是模型数据字段名),TODO:以后考虑放动态表达式,并在compile阶段使用
  523 + * placeholder:select placeholder字符串描述
  524 + *
  525 + * $$pyFilter,内部的filter指令,结合简拼音进行拼音过滤。
  526 + * $$SearchInfoService_g,内部使用的数据服务
  527 + */
  528 +// saSelect2指令使用的内部信service
  529 +angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', function($resource) {
  530 + return {
  531 + xl: $resource(
  532 + '/line/:type',
  533 + {order: 'name', direction: 'ASC'},
  534 + {
  535 + list: {
  536 + method: 'GET',
  537 + isArray: true
  538 + }
  539 + }
  540 + ),
  541 + zd: $resource(
  542 + '/stationroute/stations',
  543 + {order: 'stationCode', direction: 'ASC'},
  544 + {
  545 + list: {
  546 + method: 'GET',
  547 + isArray: true
  548 + }
  549 + }
  550 + ),
  551 + tcc: $resource(
  552 + '/carpark/:type',
  553 + {order: 'parkCode', direction: 'ASC'},
  554 + {
  555 + list: {
  556 + method: 'GET',
  557 + isArray: true
  558 + }
  559 + }
  560 + ),
  561 + ry: $resource(
  562 + '/personnel/:type',
  563 + {order: 'personnelName', direction: 'ASC'},
  564 + {
  565 + list: {
  566 + method: 'GET',
  567 + isArray: true
  568 + }
  569 + }
  570 + ),
  571 + cl: $resource(
  572 + '/cars/:type',
  573 + {order: "insideCode", direction: 'ASC'},
  574 + {
  575 + list: {
  576 + method: 'GET',
  577 + isArray: true
  578 + }
  579 + }
  580 + ),
  581 + ttInfo: $resource(
  582 + '/tic/:type',
  583 + {order: "name", direction: 'ASC'},
  584 + {
  585 + list: {
  586 + method: 'GET',
  587 + isArray: true
  588 + }
  589 + }
  590 + ),
  591 + lpInfo: $resource(
  592 + '/gic/ttlpnames',
  593 + {order: "lpName", direction: 'ASC'},
  594 + {
  595 + list: {
  596 + method: 'GET',
  597 + isArray: true
  598 + }
  599 + }
  600 + ),
  601 + lpInfo2: $resource(
  602 + '/gic/:type',
  603 + {order: "lpName", direction: 'ASC'},
  604 + {
  605 + list: {
  606 + method: 'GET',
  607 + isArray: true
  608 + }
  609 + }
  610 + ),
  611 + cci: $resource(
  612 + '/cci/cars',
  613 + {},
  614 + {
  615 + list: {
  616 + method: 'GET',
  617 + isArray: true
  618 + }
  619 + }
  620 +
  621 + ),
  622 + cci2: $resource(
  623 + '/cci/:type',
  624 + {},
  625 + {
  626 + list: {
  627 + method: 'GET',
  628 + isArray: true
  629 + }
  630 + }
  631 + ),
  632 + cci3: $resource(
  633 + '/cci/cars2',
  634 + {},
  635 + {
  636 + list: {
  637 + method: 'GET',
  638 + isArray: true
  639 + }
  640 + }
  641 +
  642 + ),
  643 + eci: $resource(
  644 + '/eci/jsy',
  645 + {},
  646 + {
  647 + list: {
  648 + method: 'GET',
  649 + isArray: true
  650 + }
  651 + }
  652 + ),
  653 + eci2: $resource(
  654 + '/eci/spy',
  655 + {},
  656 + {
  657 + list: {
  658 + method: 'GET',
  659 + isArray: true
  660 + }
  661 + }
  662 + ),
  663 + eci3: $resource(
  664 + '/eci/:type',
  665 + {},
  666 + {
  667 + list: {
  668 + method: 'GET',
  669 + isArray: true
  670 + }
  671 + }
  672 + )
  673 + }
  674 +}]);
  675 +
  676 +
src/main/resources/static/pages/scheduleApp/module/core/rerunManage/index.html
1 -<div class="page-head">  
2 - <div class="page-title">  
3 - <h1>套跑管理</h1>  
4 - </div>  
5 -</div>  
6 -  
7 -<ul class="page-breadcrumb breadcrumb">  
8 - <li>  
9 - <a href="/pages/home.html" data-pjax>首页</a>  
10 - <i class="fa fa-circle"></i>  
11 - </li>  
12 - <li>  
13 - <span class="active">运营计划管理</span>  
14 - <i class="fa fa-circle"></i>  
15 - </li>  
16 - <li>  
17 - <span class="active">套跑管理</span>  
18 - </li>  
19 -</ul>  
20 -  
21 -<div class="row">  
22 - <div class="col-md-12" ng-controller="RerunManageCtrl as ctrl">  
23 - <div class="portlet light bordered">  
24 - <div class="portlet-title">  
25 - <div class="caption font-dark">  
26 - <i class="fa fa-database font-dark"></i>  
27 - <span class="caption-subject bold uppercase">套跑信息</span>  
28 - </div>  
29 - <div class="actions">  
30 - <a href="javascirpt:" class="btn btn-circle blue" ng-click="ctrl.goForm()">  
31 - <i class="fa fa-plus"></i>  
32 - 添加套跑  
33 - </a>  
34 -  
35 - <div class="btn-group">  
36 - <a href="javascript:" class="btn red btn-outline btn-circle" data-toggle="dropdown">  
37 - <i class="fa fa-share"></i>  
38 - <span>数据工具</span>  
39 - <i class="fa fa-angle-down"></i>  
40 - </a>  
41 - <ul class="dropdown-menu pull-right">  
42 - <li>  
43 - <a href="javascript:" class="tool-action">  
44 - <i class="fa fa-file-excel-o"></i>  
45 - 导入excel  
46 - </a>  
47 - </li>  
48 - <li>  
49 - <a href="javascript:" class="tool-action">  
50 - <i class="fa fa-file-excel-o"></i>  
51 - 导出excel  
52 - </a>  
53 - </li>  
54 - <li class="divider"></li>  
55 - <li>  
56 - <a href="javascript:" class="tool-action">  
57 - <i class="fa fa-refresh"></i>  
58 - 刷行数据  
59 - </a>  
60 - </li>  
61 - </ul>  
62 - </div>  
63 - </div>  
64 - </div>  
65 -  
66 - <div class="portlet-body">  
67 - <div ui-view="rerunManage_list"></div>  
68 - </div>  
69 - </div>  
70 - </div> 1 +<div class="page-head">
  2 + <div class="page-title">
  3 + <h1>套跑管理</h1>
  4 + </div>
  5 +</div>
  6 +
  7 +<ul class="page-breadcrumb breadcrumb">
  8 + <li>
  9 + <a href="/pages/home.html" data-pjax>首页</a>
  10 + <i class="fa fa-circle"></i>
  11 + </li>
  12 + <li>
  13 + <span class="active">运营计划管理</span>
  14 + <i class="fa fa-circle"></i>
  15 + </li>
  16 + <li>
  17 + <span class="active">套跑管理</span>
  18 + </li>
  19 +</ul>
  20 +
  21 +<div class="row">
  22 + <div class="col-md-12" ng-controller="RerunManageCtrl as ctrl">
  23 + <div class="portlet light bordered">
  24 + <div class="portlet-title">
  25 + <div class="caption font-dark">
  26 + <i class="fa fa-database font-dark"></i>
  27 + <span class="caption-subject bold uppercase">套跑信息</span>
  28 + </div>
  29 + <div class="actions">
  30 + <a href="javascirpt:" class="btn btn-circle blue" ng-click="ctrl.goForm()">
  31 + <i class="fa fa-plus"></i>
  32 + 添加套跑
  33 + </a>
  34 +
  35 + <div class="btn-group">
  36 + <a href="javascript:" class="btn red btn-outline btn-circle" data-toggle="dropdown">
  37 + <i class="fa fa-share"></i>
  38 + <span>数据工具</span>
  39 + <i class="fa fa-angle-down"></i>
  40 + </a>
  41 + <ul class="dropdown-menu pull-right">
  42 + <li>
  43 + <a href="javascript:" class="tool-action">
  44 + <i class="fa fa-file-excel-o"></i>
  45 + 导入excel
  46 + </a>
  47 + </li>
  48 + <li>
  49 + <a href="javascript:" class="tool-action">
  50 + <i class="fa fa-file-excel-o"></i>
  51 + 导出excel
  52 + </a>
  53 + </li>
  54 + <li class="divider"></li>
  55 + <li>
  56 + <a href="javascript:" class="tool-action">
  57 + <i class="fa fa-refresh"></i>
  58 + 刷行数据
  59 + </a>
  60 + </li>
  61 + </ul>
  62 + </div>
  63 + </div>
  64 + </div>
  65 +
  66 + <div class="portlet-body">
  67 + <div ui-view="rerunManage_list"></div>
  68 + </div>
  69 + </div>
  70 + </div>
71 </div> 71 </div>
72 \ No newline at end of file 72 \ No newline at end of file
src/main/resources/static/real_control_v2/css/line_schedule.css
@@ -486,31 +486,39 @@ div.drop-rail[data-type=&quot;car&quot;]:before { @@ -486,31 +486,39 @@ div.drop-rail[data-type=&quot;car&quot;]:before {
486 } 486 }
487 487
488 dl.relevance-active dd:nth-child(n+2) { 488 dl.relevance-active dd:nth-child(n+2) {
489 - background: #76a6c7 !important;  
490 - color: white; 489 + background: #f1efef !important;
491 } 490 }
492 491
493 -dl.relevance-active dd.tl-qrlb { 492 +dl.relevance-active.intimity dd:nth-child(n+2) {
  493 + background: #76a6c7 !important;
  494 + color: white;
  495 +}
  496 +
  497 +dl.relevance-active dd.tl-qrlb,
  498 +dl.relevance-active.intimity dd.tl-qrlb{
494 background: linear-gradient(to right, #7B6B24, #4992c3) !important; 499 background: linear-gradient(to right, #7B6B24, #4992c3) !important;
495 color: #f8e9cd; 500 color: #f8e9cd;
496 } 501 }
497 502
498 -dl.relevance-active dd.tl-zzzx { 503 +dl.relevance-active dd.tl-zzzx,
  504 +dl.relevance-active.intimity dd.tl-zzzx {
499 background: linear-gradient(to right, #96F396, #4992c3) !important; 505 background: linear-gradient(to right, #96F396, #4992c3) !important;
500 color: #565252; 506 color: #565252;
501 } 507 }
502 508
503 -dl.relevance-active dd.tl-zzzx span.fcsj-diff { 509 +dl.relevance-active dd.tl-zzzx span.fcsj-diff,
  510 +dl.relevance-active.intimity dd.tl-zzzx span.fcsj-diff {
504 color: #5e5a5a 511 color: #5e5a5a
505 } 512 }
506 513
507 -dl.relevance-active dd span.fcsj-diff { 514 +dl.relevance-active dd span.fcsj-diff,
  515 +dl.relevance-active.intimity dd span.fcsj-diff {
508 color: #d7d6d6; 516 color: #d7d6d6;
509 } 517 }
510 518
511 -dl.relevance-active a { 519 +/*dl.relevance-active a {
512 color: #dff0ff; 520 color: #dff0ff;
513 -} 521 +}*/
514 522
515 .right-text-lp { 523 .right-text-lp {
516 position: absolute; 524 position: absolute;
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/add_temp_sch.html
@@ -131,11 +131,11 @@ @@ -131,11 +131,11 @@
131 //车辆 131 //车辆
132 gb_common.carAutocomplete($('.car-autocom', modal), rs); 132 gb_common.carAutocomplete($('.car-autocom', modal), rs);
133 }); 133 });
134 - $.get('/basic/personnel', function(rs) { 134 + $.get('/basic/all_personnel', function(rs) {
135 //驾驶员 135 //驾驶员
136 - gb_common.personAutocomplete($('.jsy-autocom', modal), rs.jsy); 136 + gb_common.personAutocomplete($('.jsy-autocom', modal), rs);
137 //售票员 137 //售票员
138 - gb_common.personAutocomplete($('.spy-autocom', modal), rs.spy); 138 + gb_common.personAutocomplete($('.spy-autocom', modal), rs);
139 }); 139 });
140 140
141 //站点路由 141 //站点路由
@@ -152,6 +152,7 @@ @@ -152,6 +152,7 @@
152 //submit 152 //submit
153 var f = $('form', modal).formValidation(gb_form_validation_opts); 153 var f = $('form', modal).formValidation(gb_form_validation_opts);
154 f.on('success.form.fv', function(e) { 154 f.on('success.form.fv', function(e) {
  155 + disabled_submit_btn(this);
155 e.preventDefault(); 156 e.preventDefault();
156 var data = $(this).serializeJSON(); 157 var data = $(this).serializeJSON();
157 data.xlBm=sch.xlBm; 158 data.xlBm=sch.xlBm;
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/fcxxwt.html
@@ -123,7 +123,7 @@ @@ -123,7 +123,7 @@
123 <div class="uk-width-1-1"> 123 <div class="uk-width-1-1">
124 <div class="uk-form-row ct-stacked"> 124 <div class="uk-form-row ct-stacked">
125 <div class="uk-form-controls" style="margin-top: 5px;"> 125 <div class="uk-form-controls" style="margin-top: 5px;">
126 - <textarea id="form-s-t" cols="30" rows="5" name="remarks" data-fv-stringlength="true" data-fv-stringlength-max="20" placeholder="备注,不超过20个字符"></textarea> 126 + <textarea id="form-s-t" cols="30" rows="5" name="remarks" data-fv-stringlength="true" data-fv-stringlength-max="20" placeholder="备注,不超过20个字符">{{sch.remarks}}</textarea>
127 </div> 127 </div>
128 </div> 128 </div>
129 </div> 129 </div>
@@ -157,6 +157,8 @@ @@ -157,6 +157,8 @@
157 gb_schedule_table.updateSchedule(rs.ts); 157 gb_schedule_table.updateSchedule(rs.ts);
158 UIkit.modal(modal).hide(); 158 UIkit.modal(modal).hide();
159 notify_succ('操作成功!'); 159 notify_succ('操作成功!');
  160 + //计算应发未发
  161 + gb_schedule_table.calc_yfwf_num(sch.xlBm);
160 }); 162 });
161 }); 163 });
162 164
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/jhlb.html
@@ -119,6 +119,8 @@ @@ -119,6 +119,8 @@
119 gb_schedule_table.updateSchedule(rs.ts); 119 gb_schedule_table.updateSchedule(rs.ts);
120 UIkit.modal(modal).hide(); 120 UIkit.modal(modal).hide();
121 notify_succ('烂班操作成功!'); 121 notify_succ('烂班操作成功!');
  122 + //calc 应发未发
  123 + gb_schedule_table.calc_yfwf_num(sch.xlBm);
122 }); 124 });
123 }); 125 });
124 126
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sftz.html
@@ -87,6 +87,9 @@ @@ -87,6 +87,9 @@
87 gb_schedule_table.updateSchedule(rs.ts); 87 gb_schedule_table.updateSchedule(rs.ts);
88 UIkit.modal(modal).hide(); 88 UIkit.modal(modal).hide();
89 notify_succ('实发调整成功!'); 89 notify_succ('实发调整成功!');
  90 +
  91 + if(data.fcsjActual)
  92 + gb_schedule_table.calc_yfwf_num(sch.xlBm);
90 } 93 }
91 }); 94 });
92 }); 95 });
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/sub_task/add_sub_task_other.html
@@ -134,16 +134,16 @@ @@ -134,16 +134,16 @@
134 dictionaryUtils.transformDom($('.nt-dictionary', modal)); 134 dictionaryUtils.transformDom($('.nt-dictionary', modal));
135 135
136 //----------- Autocomplete -------------- 136 //----------- Autocomplete --------------
137 - $.get('/basic/cars', function(rs) {  
138 - //车辆  
139 - gb_common.carAutocomplete($('.car-autocom', modal), rs);  
140 - });  
141 - $.get('/basic/personnel', function(rs) {  
142 - //驾驶员  
143 - gb_common.personAutocomplete($('.jsy-autocom', modal), rs.jsy);  
144 - //售票员  
145 - gb_common.personAutocomplete($('.spy-autocom', modal), rs.spy);  
146 - }); 137 + // $.get('/basic/cars', function(rs) {
  138 + // //车辆
  139 + // gb_common.carAutocomplete($('.car-autocom', modal), rs);
  140 + // });
  141 + // $.get('/basic/all_personnel', function(rs) {
  142 + // //驾驶员
  143 + // gb_common.personAutocomplete($('.jsy-autocom', modal), rs);
  144 + // //售票员
  145 + // gb_common.personAutocomplete($('.spy-autocom', modal), rs);
  146 + // });
147 147
148 //站点路由 148 //站点路由
149 stationRoutes = gb_common.groupBy(gb_data_basic.stationRoutes(sch.xlBm).sort(function(a, b){ 149 stationRoutes = gb_common.groupBy(gb_data_basic.stationRoutes(sch.xlBm).sort(function(a, b){
@@ -159,6 +159,7 @@ @@ -159,6 +159,7 @@
159 //submit 159 //submit
160 var f = $('form', modal).formValidation(gb_form_validation_opts); 160 var f = $('form', modal).formValidation(gb_form_validation_opts);
161 f.on('success.form.fv', function(e) { 161 f.on('success.form.fv', function(e) {
  162 + disabled_submit_btn(this);
162 e.preventDefault(); 163 e.preventDefault();
163 var data = $(this).serializeJSON(); 164 var data = $(this).serializeJSON();
164 165
@@ -166,7 +167,6 @@ @@ -166,7 +167,6 @@
166 notify_succ('子任务添加成功'); 167 notify_succ('子任务添加成功');
167 gb_schedule_table.updateSchedule(rs.t); 168 gb_schedule_table.updateSchedule(rs.t);
168 $('#schedule-lj_zrw-modal .main-schedule-table').trigger('refresh', {sch: rs.t}); 169 $('#schedule-lj_zrw-modal .main-schedule-table').trigger('refresh', {sch: rs.t});
169 - //$('#schedule-lj_zrw-modal .sub-task-table').trigger('refresh');  
170 UIkit.modal(modal).hide(); 170 UIkit.modal(modal).hide();
171 }); 171 });
172 }); 172 });
src/main/resources/static/real_control_v2/fragments/line_schedule/context_menu/tzrc.html
@@ -159,11 +159,11 @@ @@ -159,11 +159,11 @@
159 //车辆 159 //车辆
160 gb_common.carAutocomplete($('.car-autocom', modal), rs); 160 gb_common.carAutocomplete($('.car-autocom', modal), rs);
161 }); 161 });
162 - $.get('/basic/personnel', function(rs) { 162 + $.get('/basic/all_personnel', function(rs) {
163 //驾驶员 163 //驾驶员
164 - gb_common.personAutocomplete($('.jsy-autocom', modal), rs.jsy); 164 + gb_common.personAutocomplete($('.jsy-autocom', modal), rs);
165 //售票员 165 //售票员
166 - gb_common.personAutocomplete($('.spy-autocom', modal), rs.spy); 166 + gb_common.personAutocomplete($('.spy-autocom', modal), rs);
167 }); 167 });
168 168
169 //默认选中项 169 //默认选中项
src/main/resources/static/real_control_v2/fragments/line_schedule/sch_table.html
@@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@
58 {{sch.fcsjActual}}<span class="fcsj-diff">{{sch.fcsj_diff}}</span> 58 {{sch.fcsjActual}}<span class="fcsj-diff">{{sch.fcsj_diff}}</span>
59 </dd> 59 </dd>
60 <dd data-uk-observe> 60 <dd data-uk-observe>
61 - <span title="{{sch.remarks}}" data-uk-tooltip>{{sch.remarks}}</span> 61 + <span title="{{sch.remarks}}" data-uk-tooltip="{pos:'top-left'}" >{{sch.remarks}}</span>
62 </dd> 62 </dd>
63 </dl> 63 </dl>
64 {{/each}} 64 {{/each}}
src/main/resources/static/real_control_v2/fragments/north/tabs.html
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <li class="uk-active" ><a>主页</a></li> 4 <li class="uk-active" ><a>主页</a></li>
5 <li class=""><a>地图</a></li> 5 <li class=""><a>地图</a></li>
6 {{each list as line i}} 6 {{each list as line i}}
7 - <li class="tab-line"><a>{{line.name}}(0, 0)</a></li> 7 + <li class="tab-line"><a>{{line.name}}(0, <span id="badge_yfwf_num_{{line.lineCode}}">0</span>)</a></li>
8 {{/each}} 8 {{/each}}
9 </ul> 9 </ul>
10 </script> 10 </script>
src/main/resources/static/real_control_v2/js/common.js
@@ -176,18 +176,26 @@ var gb_common = (function() { @@ -176,18 +176,26 @@ var gb_common = (function() {
176 init_autocom_pinyin(element, data); 176 init_autocom_pinyin(element, data);
177 }; 177 };
178 178
179 - var personAutocomplete = function(element, personList) { 179 + var personAutocomplete = function(element, personMaps) {
180 var data = [],name; 180 var data = [],name;
181 - $.each(personList, function(){  
182 - name=this.personnelName; 181 + // $.each(personList, function(){
  182 + // name=this.personnelName;
  183 + // data.push({
  184 + // value: this.jobCode+'/'+name,
  185 + // fullChars: pinyin.getFullChars(name).toUpperCase(),
  186 + // camelChars: pinyin.getCamelChars(name),
  187 + // brancheCompany: this.brancheCompany
  188 + // });
  189 + // });
  190 + // console.log('data', data);
  191 + for(var jobCode in personMaps){
  192 + name=personMaps[jobCode];
183 data.push({ 193 data.push({
184 - value: this.jobCode+'/'+name,  
185 - fullChars: pinyin.getFullChars(name).toUpperCase(),  
186 - camelChars: pinyin.getCamelChars(name),  
187 - brancheCompany: this.brancheCompany 194 + value: jobCode+'/'+name,
  195 + fullChars: pinyin.getFullChars(name).toUpperCase(),
  196 + camelChars: pinyin.getCamelChars(name)
188 }); 197 });
189 - });  
190 - console.log('data', data); 198 + }
191 init_autocom_pinyin(element, data); 199 init_autocom_pinyin(element, data);
192 }; 200 };
193 201
src/main/resources/static/real_control_v2/js/line_schedule/context_menu.js
@@ -39,6 +39,9 @@ var gb_schedule_context_menu = (function() { @@ -39,6 +39,9 @@ var gb_schedule_context_menu = (function() {
39 }, function(rs) { 39 }, function(rs) {
40 gb_schedule_table.updateSchedule(rs.t); 40 gb_schedule_table.updateSchedule(rs.t);
41 notify_succ('撤销烂班操作成功!'); 41 notify_succ('撤销烂班操作成功!');
  42 +
  43 + //calc 应发未发
  44 + gb_schedule_table.calc_yfwf_num(sch.xlBm);
42 }); 45 });
43 }, '确认撤销'); 46 }, '确认撤销');
44 }, 47 },
@@ -58,6 +61,8 @@ var gb_schedule_context_menu = (function() { @@ -58,6 +61,8 @@ var gb_schedule_context_menu = (function() {
58 }, function(rs) { 61 }, function(rs) {
59 gb_schedule_table.updateSchedule(rs.ts); 62 gb_schedule_table.updateSchedule(rs.ts);
60 notify_succ('撤销实发操作成功!'); 63 notify_succ('撤销实发操作成功!');
  64 + //calc 应发未发
  65 + gb_schedule_table.calc_yfwf_num(sch.xlBm);
61 }); 66 });
62 }, '确认撤销实发'); 67 }, '确认撤销实发');
63 }, 68 },
src/main/resources/static/real_control_v2/js/line_schedule/sch_table.js
@@ -24,6 +24,8 @@ var gb_schedule_table = (function() { @@ -24,6 +24,8 @@ var gb_schedule_table = (function() {
24 calc_sch_real_shift(this); 24 calc_sch_real_shift(this);
25 line2Schedule[lineCode][this.id] = this; 25 line2Schedule[lineCode][this.id] = this;
26 }); 26 });
  27 + //计算应发未发
  28 + calc_yfwf_num(lineCode);
27 } 29 }
28 ep.emit('data', rs); 30 ep.emit('data', rs);
29 }); 31 });
@@ -110,10 +112,12 @@ var gb_schedule_table = (function() { @@ -110,10 +112,12 @@ var gb_schedule_table = (function() {
110 for (var upDown in dirData) { 112 for (var upDown in dirData) {
111 htmlStr = temps['line-schedule-table-temp']({ 113 htmlStr = temps['line-schedule-table-temp']({
112 dir: upDown, 114 dir: upDown,
  115 + line: gb_data_basic.codeToLine[sch.xlBm],
113 list: dirData[upDown] 116 list: dirData[upDown]
114 }); 117 });
115 $('.schedule-wrap .card-panel:eq(' + upDown + ')', tabCont).html(htmlStr); 118 $('.schedule-wrap .card-panel:eq(' + upDown + ')', tabCont).html(htmlStr);
116 } 119 }
  120 + calc_yfwf_num(sch.xlBm);
117 //定位到新添加的班次 121 //定位到新添加的班次
118 scroToDl(sch); 122 scroToDl(sch);
119 } 123 }
@@ -127,6 +131,7 @@ var gb_schedule_table = (function() { @@ -127,6 +131,7 @@ var gb_schedule_table = (function() {
127 delete line2Schedule[sch.xlBm][sch.id]; 131 delete line2Schedule[sch.xlBm][sch.id];
128 dl.remove(); 132 dl.remove();
129 reset_seq_no(dls); 133 reset_seq_no(dls);
  134 + calc_yfwf_num(sch.xlBm);
130 } 135 }
131 } 136 }
132 137
@@ -150,6 +155,7 @@ var gb_schedule_table = (function() { @@ -150,6 +155,7 @@ var gb_schedule_table = (function() {
150 $(dds[2]).data('nbbm', sch.clZbh).text(sch.clZbh); 155 $(dds[2]).data('nbbm', sch.clZbh).text(sch.clZbh);
151 if (sch.qdzArrDateJH) 156 if (sch.qdzArrDateJH)
152 $(dds[3]).text(sch.qdzArrDateJH); 157 $(dds[3]).text(sch.qdzArrDateJH);
  158 +
153 if (sch.qdzArrDateSJ) 159 if (sch.qdzArrDateSJ)
154 $(dds[4]).text(sch.qdzArrDateSJ); 160 $(dds[4]).text(sch.qdzArrDateSJ);
155 161
@@ -162,7 +168,9 @@ var gb_schedule_table = (function() { @@ -162,7 +168,9 @@ var gb_schedule_table = (function() {
162 var sfsjDd = temps['line-schedule-sfsj-temp'](sch); 168 var sfsjDd = temps['line-schedule-sfsj-temp'](sch);
163 $(dds[7]).replaceWith(sfsjDd); 169 $(dds[7]).replaceWith(sfsjDd);
164 if(sch.remarks) 170 if(sch.remarks)
165 - $(dds[8]).html('<span title="'+sch.remarks+'" data-uk-tooltip>'+sch.remarks+'</span>'); 171 + $(dds[8]).html('<span title="'+sch.remarks+'" data-uk-tooltip="{pos:\'top-left\'}">'+sch.remarks+'</span>');
  172 + else
  173 + $(dds[8]).html('');
166 } 174 }
167 175
168 //拖拽选中... 176 //拖拽选中...
@@ -205,13 +213,17 @@ var gb_schedule_table = (function() { @@ -205,13 +213,17 @@ var gb_schedule_table = (function() {
205 schArr = gb_common.get_vals(line2Schedule[lineCode]).filter(function(item) { 213 schArr = gb_common.get_vals(line2Schedule[lineCode]).filter(function(item) {
206 return item.clZbh == sch.clZbh; 214 return item.clZbh == sch.clZbh;
207 }).sort(schedule_sort), 215 }).sort(schedule_sort),
208 - nextSch; 216 + nextSch,tempDL;
209 $.each(schArr, function(i) { 217 $.each(schArr, function(i) {
210 - $('dl[data-id=' + this.id + ']', contWrap).addClass('relevance-active');  
211 - if (i < schArr.length - 1 && this.id == id)  
212 - nextSch = schArr[i + 1]; 218 + tempDL=$('dl[data-id=' + this.id + ']', contWrap);
  219 + tempDL.addClass('relevance-active');
  220 + if (i < schArr.length - 1 && this.id == id){
  221 + nextSch = schArr[i + 1];
  222 + tempDL.addClass('intimity');
  223 + }
213 }); 224 });
214 225
  226 + $('dl[data-id=' + nextSch.id + ']', contWrap).addClass('intimity');
215 if (nextSch.xlDir == sch.xlDir) 227 if (nextSch.xlDir == sch.xlDir)
216 return; 228 return;
217 //滚动到下一个班次 229 //滚动到下一个班次
@@ -230,7 +242,7 @@ var gb_schedule_table = (function() { @@ -230,7 +242,7 @@ var gb_schedule_table = (function() {
230 return item.lpName == sch.lpName; 242 return item.lpName == sch.lpName;
231 }).sort(schedule_sort); 243 }).sort(schedule_sort);
232 $.each(schArr, function(i) { 244 $.each(schArr, function(i) {
233 - $('dl[data-id=' + this.id + ']', contWrap).addClass('relevance-active'); 245 + $('dl[data-id=' + this.id + ']', contWrap).addClass('relevance-active intimity');
234 }); 246 });
235 247
236 notify_succ('高亮路牌 ' + sch.lpName); 248 notify_succ('高亮路牌 ' + sch.lpName);
@@ -258,7 +270,25 @@ var gb_schedule_table = (function() { @@ -258,7 +270,25 @@ var gb_schedule_table = (function() {
258 } 270 }
259 271
260 var reset_relevance_active = function(dd) { 272 var reset_relevance_active = function(dd) {
261 - $(dd).parents('.uk-grid.schedule-wrap').find('.relevance-active').removeClass('relevance-active'); 273 + $(dd).parents('.uk-grid.schedule-wrap').find('.relevance-active').removeClass('relevance-active intimity');
  274 + }
  275 +
  276 + //计算应发未发数量
  277 + var calc_yfwf_num = function(lineCode){
  278 + console.log('calc_yfwf_num...', lineCode);
  279 + var schArr=line2Schedule[lineCode]
  280 + ,yfwf_num=0
  281 + ,t = new Date().valueOf();
  282 +
  283 + $.each(schArr, function(){
  284 + if(this.fcsjT > t)
  285 + return false;
  286 +
  287 + if(this.fcsjActual == null && this.fcsjActualTime == null && this.status != -1)
  288 + yfwf_num ++;
  289 + });
  290 +
  291 + $('#badge_yfwf_num_'+lineCode).text(yfwf_num);
262 } 292 }
263 293
264 return { 294 return {
@@ -267,6 +297,7 @@ var gb_schedule_table = (function() { @@ -267,6 +297,7 @@ var gb_schedule_table = (function() {
267 updateSchedule: updateSchedule, 297 updateSchedule: updateSchedule,
268 deheteSchedule: deheteSchedule, 298 deheteSchedule: deheteSchedule,
269 insertSchedule: insertSchedule, 299 insertSchedule: insertSchedule,
270 - schedule_sort: schedule_sort 300 + schedule_sort: schedule_sort,
  301 + calc_yfwf_num: calc_yfwf_num
271 }; 302 };
272 })(); 303 })();
src/main/resources/static/real_control_v2/js/main.js
@@ -128,6 +128,13 @@ var enable_submit_btn = function(form) { @@ -128,6 +128,13 @@ var enable_submit_btn = function(form) {
128 } 128 }
129 } 129 }
130 130
  131 +var disabled_submit_btn = function(form) {
  132 + var subBtn = $('button[type=submit]', form);
  133 + if (subBtn) {
  134 + subBtn.addClass('disabled').attr('disabled','disabled');
  135 + }
  136 +}
  137 +
131 var show_modal = function(id, dom) { 138 var show_modal = function(id, dom) {
132 $(document.body).append(dom); 139 $(document.body).append(dom);
133 return UIkit.modal(id, { 140 return UIkit.modal(id, {
src/main/resources/static/real_control_v2/js/websocket/sch_websocket.js
@@ -35,11 +35,10 @@ var gb_sch_websocket = (function() { @@ -35,11 +35,10 @@ var gb_sch_websocket = (function() {
35 35
36 //80协议上报 36 //80协议上报
37 var report80 = function(msg) { 37 var report80 = function(msg) {
38 -// console.log('report80...', msg);  
39 -// msg.dateStr = moment(msg.timestamp).format('HH:mm');  
40 -// msg.text = gb_common.reqCode80[msg.data.requestCode];  
41 -//  
42 -// findMailBox(msg.data.lineId).prepend(temps['sys-note-80-temp'](msg)); 38 + msg.dateStr = moment(msg.timestamp).format('HH:mm');
  39 + msg.text = gb_common.reqCode80[msg.data.requestCode];
  40 +
  41 + findMailBox(msg.data.lineId).prepend(temps['sys-note-80-temp'](msg));
43 } 42 }
44 43
45 var waitRemoves = []; 44 var waitRemoves = [];
@@ -53,6 +52,8 @@ var gb_sch_websocket = (function() { @@ -53,6 +52,8 @@ var gb_sch_websocket = (function() {
53 t: currentSecond(), 52 t: currentSecond(),
54 dom: msg.domId 53 dom: msg.domId
55 }); 54 });
  55 +
  56 + gb_schedule_table.calc_yfwf_num(msg.t.xlBm);
56 } 57 }
57 58
58 //到达终点 59 //到达终点