Commit ad34a2eea7176b647a798526bad95a90c7507707

Authored by 徐烜
2 parents 56b41ada 1d01aca6

PSM-4

src/main/java/com/bsth/controller/schedule/ScheduleRule1FlatController.java
1 package com.bsth.controller.schedule; 1 package com.bsth.controller.schedule;
2 2
3 import com.bsth.controller.BaseController; 3 import com.bsth.controller.BaseController;
4 -import com.bsth.entity.schedule.EmployeeConfigInfo;  
5 -import com.bsth.entity.schedule.GuideboardInfo;  
6 import com.bsth.entity.schedule.rule.ScheduleRule1Flat; 4 import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
7 import com.bsth.repository.schedule.ScheduleRule1FlatRepository; 5 import com.bsth.repository.schedule.ScheduleRule1FlatRepository;
8 -import com.bsth.service.schedule.EmployeeConfigInfoService;  
9 -import com.bsth.service.schedule.GuideboardInfoService;  
10 -import org.apache.commons.lang3.StringUtils;  
11 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.web.bind.annotation.*; 7 import org.springframework.web.bind.annotation.*;
13 8
14 -import java.util.HashMap;  
15 import java.util.Map; 9 import java.util.Map;
16 10
17 /** 11 /**
@@ -23,10 +17,6 @@ public class ScheduleRule1FlatController extends BaseController<ScheduleRule1Fla @@ -23,10 +17,6 @@ public class ScheduleRule1FlatController extends BaseController<ScheduleRule1Fla
23 17
24 @Autowired 18 @Autowired
25 private ScheduleRule1FlatRepository scheduleRule1FlatRepository; 19 private ScheduleRule1FlatRepository scheduleRule1FlatRepository;
26 - @Autowired  
27 - private GuideboardInfoService guideboardInfoService;  
28 - @Autowired  
29 - private EmployeeConfigInfoService employeeConfigInfoService;  
30 20
31 @Override 21 @Override
32 public ScheduleRule1Flat findById(@PathVariable("id") Long aLong) { 22 public ScheduleRule1Flat findById(@PathVariable("id") Long aLong) {
@@ -44,63 +34,6 @@ public class ScheduleRule1FlatController extends BaseController<ScheduleRule1Fla @@ -44,63 +34,6 @@ public class ScheduleRule1FlatController extends BaseController<ScheduleRule1Fla
44 */ 34 */
45 @RequestMapping(method = RequestMethod.POST) 35 @RequestMapping(method = RequestMethod.POST)
46 public Map<String, Object> save(@RequestBody ScheduleRule1Flat t){ 36 public Map<String, Object> save(@RequestBody ScheduleRule1Flat t){
47 - // TODO:根据编码查找id,不做错误检测,暂时这样做,以后前端直接传过来  
48 - // 1、查找路牌配置id  
49 - Map<String, Object> param1 = new HashMap<>();  
50 - param1.put("xl.id_eq", t.getXl().getId());  
51 - param1.put("lpName_eq", null);  
52 -  
53 - String[] lpNames = t.getLpNames().split(",");  
54 - String[] lpIds = new String[lpNames.length];  
55 - for (int i = 0; i < lpNames.length; i++) {  
56 - param1.put("lpName_eq", lpNames[i]);  
57 - Iterable<GuideboardInfo> guideboardInfos = guideboardInfoService.list(param1);  
58 - if (!guideboardInfos.iterator().hasNext()) {  
59 - throw new RuntimeException("路牌:" + lpNames[i] + "没有找到!");  
60 - }  
61 - lpIds[i] = guideboardInfos.iterator().next().getId().toString();  
62 - }  
63 - t.setLpIds(StringUtils.join(lpIds, ","));  
64 -  
65 - // 2、查找人员配置id(这里要考虑分班的情况,先用-隔开,在用,隔开)  
66 - Map<String, Object> param2 = new HashMap<>();  
67 - param2.put("xl.id_eq", t.getXl().getId());  
68 - param2.put("dbbm_eq", null);  
69 -  
70 - String[] ryDbbms = t.getRyDbbms().split(",");  
71 - String[] ryIds = new String[ryDbbms.length];  
72 - for (int j = 0; j < ryDbbms.length; j++) {  
73 - if (ryDbbms[j].indexOf("-") == -1) {  
74 - param2.put("dbbm_eq", ryDbbms[j]);  
75 - Iterable<EmployeeConfigInfo> employeeConfigInfos = employeeConfigInfoService.list(param2);  
76 - if (!employeeConfigInfos.iterator().hasNext()) {  
77 - throw new RuntimeException("搭班编码::" + ryDbbms[j] + "没有找到!");  
78 - }  
79 - ryIds[j] = employeeConfigInfos.iterator().next().getId().toString();  
80 - } else {  
81 - String[] fbRyDbbms = ryDbbms[j].split("-");  
82 - if (fbRyDbbms.length != 2) {  
83 - throw new RuntimeException("搭班编码:" + ryDbbms[j] + "错误!");  
84 - }  
85 - String[] fbRyIds = new String[2];  
86 - param2.put("dbbm_eq", fbRyDbbms[0]);  
87 - Iterable<EmployeeConfigInfo> employeeConfigInfos = employeeConfigInfoService.list(param2);  
88 - if (!employeeConfigInfos.iterator().hasNext()) {  
89 - throw new RuntimeException("搭班编码::" + fbRyDbbms[0] + "没有找到!");  
90 - }  
91 - fbRyIds[0] = employeeConfigInfos.iterator().next().getId().toString();  
92 - param2.put("dbbm_eq", fbRyDbbms[1]);  
93 - employeeConfigInfos = employeeConfigInfoService.list(param2);  
94 - if (!employeeConfigInfos.iterator().hasNext()) {  
95 - throw new RuntimeException("搭班编码::" + fbRyDbbms[1] + "没有找到!");  
96 - }  
97 - fbRyIds[1] = employeeConfigInfos.iterator().next().getId().toString();  
98 - ryIds[j] = StringUtils.join(fbRyIds, "-");  
99 - }  
100 -  
101 - }  
102 - t.setRyConfigIds(StringUtils.join(ryIds, ","));  
103 -  
104 return baseService.save(t); 37 return baseService.save(t);
105 } 38 }
106 39
src/main/resources/static/pages/scheduleApp/module/common/dt/MyEmployeeGroupWrapTemplate.html 0 → 100644
  1 +<div name="{{$saEmployeegroupCtrl.$name_attr}}"
  2 + ng-model="$saEmployeegroupCtrl.$$internalmodel">
  3 +
  4 + <style>
  5 + .employee-select {
  6 + min-height: 180px;
  7 + border: 1px solid #ddd;
  8 + }
  9 + .employee-select .employee-input {
  10 + margin: 2px 5px 5px 5px;
  11 + padding-left: 0;
  12 + }
  13 + .employee-select .employee-select-cont {
  14 + text-align: left;
  15 + min-height: 60px;
  16 + padding-right: 0px;
  17 + }
  18 + .employee-select .employee-select-body {
  19 + margin-top: 10px;
  20 + overflow: auto;
  21 + width: auto;
  22 + min-height: 5px;
  23 + }
  24 + .employee-select .employee {
  25 + display: inline-block;
  26 + padding: 8px;
  27 + min-width: 50px;
  28 + text-align: center;
  29 + border: 1px solid #C1C1C1;
  30 + color: #666;
  31 + border-radius: 5px !important;
  32 + margin: 5px;
  33 + }
  34 + .employee-select .employee.active {
  35 + color: white;
  36 + background: #4095E8;
  37 + border: 1px solid #4095E8;
  38 + }
  39 + .employee-select .employee.start {
  40 + color: white;
  41 + background: #32C5D2;
  42 + border: 1px solid #32C5D2;
  43 + }
  44 +
  45 + </style>
  46 +
  47 + <div class="col-md-12 employee-select">
  48 + <div class="col-md-12 employee-input">
  49 + <div class="col-md-9">
  50 + 人员列表
  51 + <span ng-bind="$saEmployeegroupCtrl.$$dataDesc"></span>
  52 + </div>
  53 + </div>
  54 + <div class="col-md-12 employee-select-cont">
  55 + <div class="employee-select-body">
  56 + <div class="employee active"
  57 + ng-repeat="$d in $saEmployeegroupCtrl.$$data track by $index"
  58 + ng-click="$saEmployeegroupCtrl.$$internal_rylist_click($index)">
  59 + {{$d.jsy}}-{{$d.spy}}
  60 + </div>
  61 + </div>
  62 + </div>
  63 + <div class="col-md-12 employee-input">
  64 + <div class="col-md-9">
  65 + 已经选中的人员列表
  66 + <span ng-bind="$saEmployeegroupCtrl.$$dataSelectDesc"></span>
  67 + </div>
  68 + </div>
  69 + <div class="col-md-12 employee-select-cont">
  70 + <div class="employee-select-body">
  71 + <div ng-class="{employee: true, active: true, start: $d.isstart}"
  72 + ng-repeat="$d in $saEmployeegroupCtrl.$$dataSelected track by $index"
  73 + ng-click="$saEmployeegroupCtrl.$$internal_selrylist_click($index)"
  74 + ng-dblclick="$saEmployeegroupCtrl.$$internal_selrylist_dbclick($index)">
  75 + {{$d.jsy}}-{{$d.spy}}
  76 + </div>
  77 + </div>
  78 + </div>
  79 + </div>
  80 +
  81 +
  82 +</div>
0 \ No newline at end of file 83 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/dt/MyGuideboardGroupWrapTemplate.html
1 -<div name="{{$saGuideboardgroupCtrl.$name_attr}}"  
2 - ng-model="$saGuideboardgroupCtrl.$$internalmodel">  
3 -  
4 - <style>  
5 - .guideboard-select {  
6 - height: 180px;  
7 - border: 1px solid #ddd;  
8 - }  
9 - .guideboard-select .guideboard-input {  
10 - margin: 2px 5px 5px 5px;  
11 - padding-left: 0;  
12 - }  
13 - .guideboard-select .guideboard-select-cont {  
14 - text-align: left;  
15 - height: 100px;  
16 - padding-right: 0px;  
17 - }  
18 - .guideboard-select .guideboard-select-body {  
19 - margin-top: 10px;  
20 - overflow: auto;  
21 - width: auto;  
22 - height: 100px;  
23 - }  
24 - .guideboard-select .guideboard {  
25 - display: inline-block;  
26 - padding: 8px;  
27 - min-width: 85px;  
28 - text-align: center;  
29 - border: 1px solid #C1C1C1;  
30 - color: #666;  
31 - border-radius: 5px !important;  
32 - margin: 5px;  
33 - }  
34 - .guideboard-select .guideboard.active {  
35 - color: white;  
36 - background: #4095E8;  
37 - border: 1px solid #4095E8;  
38 - }  
39 -  
40 - </style>  
41 -  
42 - <div class="col-md-12 guideboard-select">  
43 - <div class="col-md-12 guideboard-input">  
44 - <div class="col-md-9">  
45 - 某某线路的路牌列表  
46 - </div>  
47 - </div>  
48 - <div class="col-md-12 guideboard-select-cont">  
49 - <div class="guideboard-select-body">  
50 - <div class="guideboard active">  
51 - 1  
52 - </div>  
53 - <div class="guideboard active">  
54 - 2  
55 - </div>  
56 - <div class="guideboard active">  
57 - 3  
58 - </div>  
59 - <div class="guideboard active">  
60 - 4  
61 - </div>  
62 - </div>  
63 - </div>  
64 - </div>  
65 -  
66 - 1 +<div name="{{$saGuideboardgroupCtrl.$name_attr}}"
  2 + ng-model="$saGuideboardgroupCtrl.$$internalmodel">
  3 +
  4 + <style>
  5 + .guideboard-select {
  6 + min-height: 180px;
  7 + border: 1px solid #ddd;
  8 + }
  9 + .guideboard-select .guideboard-input {
  10 + margin: 2px 5px 5px 5px;
  11 + padding-left: 0;
  12 + }
  13 + .guideboard-select .guideboard-select-cont {
  14 + text-align: left;
  15 + min-height: 60px;
  16 + padding-right: 0px;
  17 + }
  18 + .guideboard-select .guideboard-select-body {
  19 + margin-top: 10px;
  20 + overflow: auto;
  21 + width: auto;
  22 + min-height: 5px;
  23 + }
  24 + .guideboard-select .guideboard {
  25 + display: inline-block;
  26 + padding: 8px;
  27 + min-width: 50px;
  28 + text-align: center;
  29 + border: 1px solid #C1C1C1;
  30 + color: #666;
  31 + border-radius: 5px !important;
  32 + margin: 5px;
  33 + }
  34 + .guideboard-select .guideboard.active {
  35 + color: white;
  36 + background: #4095E8;
  37 + border: 1px solid #4095E8;
  38 + }
  39 + .guideboard-select .guideboard.start {
  40 + color: white;
  41 + background: #32C5D2;
  42 + border: 1px solid #32C5D2;
  43 + }
  44 +
  45 + </style>
  46 +
  47 + <div class="col-md-12 guideboard-select">
  48 + <div class="col-md-12 guideboard-input">
  49 + <div class="col-md-9">
  50 + 路牌列表
  51 + <span ng-bind="$saGuideboardgroupCtrl.$$dataDesc"></span>
  52 + </div>
  53 + </div>
  54 + <div class="col-md-12 guideboard-select-cont">
  55 + <div class="guideboard-select-body">
  56 + <div class="guideboard active"
  57 + ng-repeat="$d in $saGuideboardgroupCtrl.$$data track by $index"
  58 + ng-click="$saGuideboardgroupCtrl.$$internal_lplist_click($index)">
  59 + {{$d.lpname}}
  60 + </div>
  61 + </div>
  62 + </div>
  63 + <div class="col-md-12 guideboard-input">
  64 + <div class="col-md-9">
  65 + 已经选中的路牌列表
  66 + <span ng-bind="$saGuideboardgroupCtrl.$$dataSelectDesc"></span>
  67 + </div>
  68 + </div>
  69 + <div class="col-md-12 guideboard-select-cont">
  70 + <div class="guideboard-select-body">
  71 + <div ng-class="{guideboard: true, active: true, start: $d.isstart}"
  72 + ng-repeat="$d in $saGuideboardgroupCtrl.$$dataSelected track by $index"
  73 + ng-click="$saGuideboardgroupCtrl.$$internal_sellplist_click($index)"
  74 + ng-dblclick="$saGuideboardgroupCtrl.$$internal_sellplist_dbclick($index)">
  75 + {{$d.lpname}}
  76 + </div>
  77 + </div>
  78 + </div>
  79 + </div>
  80 +
67 </div> 81 </div>
68 \ No newline at end of file 82 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
1 -// 自定义指令,指令模版在dt目录下  
2 -  
3 -  
4 -angular.module('ScheduleApp').directive('loadingWidget', ['requestNotificationChannel', function(requestNotificationChannel) {  
5 - return {  
6 - restrict: 'A',  
7 - link: function(scope, element) {  
8 - // 初始隐藏loading界面  
9 - element.hide();  
10 -  
11 - // 开始请求通知处理  
12 - requestNotificationChannel.onRequestStarted(scope, function() {  
13 - element.show();  
14 - });  
15 - // 请求结束通知处理  
16 - requestNotificationChannel.onRequestEnded(scope, function() {  
17 - element.hide();  
18 - });  
19 - }  
20 - };  
21 -}]);  
22 -  
23 -angular.module('ScheduleApp').directive("saSelect", ['$timeout', function($timeout) {  
24 - return {  
25 - restrict: 'E',  
26 - templateUrl: '/pages/scheduleApp/module/other/MyDictionarySelectTemplate.html',  
27 - scope: {  
28 - model: "="  
29 - },  
30 - controllerAs: "$saSelectCtrl",  
31 - bindToController: true,  
32 - controller: function() {  
33 - var self = this;  
34 - self.datas = []; // 关联的字典数据,内部格式 {code:{值},name:{名字}}  
35 - },  
36 - /**  
37 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
38 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
39 - * @param tElem  
40 - * @param tAttrs  
41 - * @returns {{pre: Function, post: Function}}  
42 - */  
43 - compile: function(tElem, tAttrs) {  
44 - // 确定是否使用angularjs required验证  
45 - // 属性 required  
46 - // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加  
47 - var required_attr = tAttrs["required"];  
48 - if (required_attr) {  
49 - if (required_attr == "true") {  
50 - // 添加required属性指令  
51 - tElem.find("ui-select").attr("required", "");  
52 - } else {  
53 - // 不等于true,不添加required属性指令  
54 - }  
55 - } else {  
56 - // 不添加required属性指令  
57 - }  
58 -  
59 - //console.log("saSelect" + ":compile = >" + tElem.html());  
60 -  
61 - return {  
62 - pre: function(scope, element, attr) {  
63 - // TODO:  
64 - },  
65 - /**  
66 - * 相当于link函数。  
67 - *  
68 - * 重要属性如下:  
69 - * model 是绑定外部值。  
70 - * dicgroup 字典组的类型  
71 - * name input name属性值  
72 - */  
73 - post: function(scope, element, attr) {  
74 - // 1、获取属性  
75 - var dicgroup_attr = attr['dicgroup']; // 字典组的类型  
76 - var name_attr = attr['name']; // input name属性值  
77 - var dicname_attr = attr['dicname']; // model关联的字典名字段  
78 - var codename_attr = attr['codename']; // model关联的字典值字段  
79 - var placeholder_attr = attr['placeholder']; // select placeholder提示  
80 -  
81 - // 系统的字典对象,使用dictionaryUtils类获取  
82 - var origin_dicgroup;  
83 - var dic_key; // 字典key  
84 -  
85 - if (dicgroup_attr) { // 赋值指定的字典数据  
86 - origin_dicgroup = dictionaryUtils.getByGroup(dicgroup_attr);  
87 - for (dic_key in origin_dicgroup) {  
88 - var data = {}; // 重新组合的字典元素对象  
89 - if (dic_key == "true")  
90 - data.code = true;  
91 - else  
92 - data.code = dic_key;  
93 - data.name = origin_dicgroup[dic_key];  
94 - scope["$saSelectCtrl"].datas.push(data);  
95 - }  
96 - }  
97 -  
98 - if (name_attr) {  
99 - scope["$saSelectCtrl"].nv = name_attr;  
100 - }  
101 - if (placeholder_attr) {  
102 - scope["$saSelectCtrl"].ph = placeholder_attr;  
103 - }  
104 -  
105 - scope["$saSelectCtrl"].select = function($item) {  
106 - if (codename_attr) {  
107 - scope["$saSelectCtrl"].model[codename_attr] = $item.code;  
108 - }  
109 - if (dicname_attr) {  
110 - scope["$saSelectCtrl"].model[dicname_attr] = $item.name;  
111 - }  
112 - };  
113 -  
114 - scope["$saSelectCtrl"].remove = function() {  
115 - if (codename_attr) {  
116 - scope["$saSelectCtrl"].model[codename_attr] = null;  
117 - }  
118 - if (dicname_attr) {  
119 - scope["$saSelectCtrl"].model[dicname_attr] = null;  
120 - }  
121 - scope["$saSelectCtrl"].cmodel = null;  
122 - };  
123 -  
124 - $timeout(function() {  
125 - // 创建内部使用的绑定对象  
126 - var model_code = scope["$saSelectCtrl"].model[codename_attr];  
127 - scope["$saSelectCtrl"].cmodel = model_code;  
128 - }, 0);  
129 - }  
130 - }  
131 - }  
132 - };  
133 -}]);  
134 -  
135 -/**  
136 - * saRadiogroup指令  
137 - * 属性如下:  
138 - * model(必须):独立作用域,外部绑定的一个值,如:ctrl.timeTableManageForForm.isEnableDisTemplate  
139 - * dicgroup(必须):关联的字典数据type(TODO:以后增加其他数据源)  
140 - * name(必须):控件的名字  
141 - * required(可选):是否要用required验证  
142 - * disabled(可选):标示单选框是否可选  
143 - *  
144 - */  
145 -angular.module('ScheduleApp').directive("saRadiogroup", [function() {  
146 - /**  
147 - * 使用字典数据的单选按钮组的指令。  
148 - * 指令名称:truefalse-Dic  
149 - */  
150 - return {  
151 - restrict: 'E',  
152 - templateUrl: '/pages/scheduleApp/module/common/dt/MyRadioGroupWrapTemplate.html',  
153 - scope: {  
154 - model: "="  
155 - },  
156 - controllerAs: "$saRadiogroupCtrl",  
157 - bindToController: true,  
158 - controller: function($scope) {  
159 - //$scope["model"] = {selectedOption: null};  
160 - //console.log("controller");  
161 - //console.log("controller:" + $scope["model"]);  
162 -  
163 - var self = this;  
164 - self.$$data = null; // 内部数据  
165 - },  
166 -  
167 - /**  
168 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
169 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
170 - * @param tElem  
171 - * @param tAttrs  
172 - * @returns {{pre: Function, post: Function}}  
173 - */  
174 - compile: function(tElem, tAttrs) {  
175 - // 获取属性  
176 - var $dicgroup_attr = tAttrs["dicgroup"]; // 关联的字典数据type  
177 - var $name_attr = tAttrs["name"]; // 控件的名字  
178 - var $required_attr = tAttrs["required"]; // 是否要用required验证  
179 - var $disabled_attr = tAttrs["disabled"]; // 标示单选框是否可选  
180 -  
181 - // controlAs名字  
182 - var ctrlAs = "$saRadiogroupCtrl";  
183 -  
184 - // 如果有required属性,添加angularjs required验证  
185 - if ($required_attr != undefined) {  
186 - tElem.find("input").attr("required", "");  
187 - }  
188 -  
189 - return {  
190 - pre: function(scope, element, attr) {  
191 -  
192 - },  
193 -  
194 - /**  
195 - * 相当于link函数。  
196 - * @param scope  
197 - * @param element  
198 - * @param attr  
199 - */  
200 - post: function(scope, element, attr) {  
201 - //console.log("link");  
202 - //console.log("link:" + scope.model);  
203 - //scope["model"] = {selectedOption: null};  
204 -  
205 - if ($name_attr) {  
206 - scope[ctrlAs].nv = $name_attr;  
207 - }  
208 -  
209 - if ($disabled_attr) {  
210 - scope[ctrlAs].disabled = true;  
211 - }  
212 - if ($dicgroup_attr) {  
213 - var obj = dictionaryUtils.getByGroup($dicgroup_attr);  
214 - scope[ctrlAs].$$data = obj;  
215 - // 处理 scope["dic"] key值  
216 - scope[ctrlAs].dicvalueCalcu = function(value) {  
217 - if (value == "true") {  
218 - //console.log(value);  
219 - return true;  
220 - } else if (value == "false") {  
221 - //console.log(value);  
222 - return false;  
223 - } else {  
224 - return value;  
225 - }  
226 - };  
227 - }  
228 - }  
229 - };  
230 - }  
231 - };  
232 -}]);  
233 -  
234 -angular.module('ScheduleApp').directive("remoteValidaton", [  
235 - 'BusInfoManageService_g',  
236 - 'EmployeeInfoManageService_g',  
237 - 'TimeTableManageService_g',  
238 - function(  
239 - busInfoManageService_g,  
240 - employeeInfoManageService_g,  
241 - timeTableManageService_g  
242 - ) {  
243 - /**  
244 - * 远端验证指令,依赖于ngModel  
245 - * 指令名称 remote-Validation  
246 - * 需要属性 rvtype 表示验证类型  
247 - */  
248 - return {  
249 - restrict: "A",  
250 - require: "^ngModel",  
251 - link: function(scope, element, attr, ngModelCtrl) {  
252 - element.bind("keyup", function() {  
253 - var modelValue = ngModelCtrl.$modelValue;  
254 - var rv1_attr = attr["rv1"];  
255 - if (attr["rvtype"]) {  
256 -  
257 - // 根据rvtype的值,确定使用那个远端验证的url,  
258 - // rv1, rv2, rv3是关联比较值,暂时使用rv1  
259 - // 这个貌似没法通用,根据业务变换  
260 - // TODO:暂时有点乱以后改  
261 - if (attr["rvtype"] == "insideCode") {  
262 - busInfoManageService_g.validate.insideCode(  
263 - {"insideCode_eq": modelValue, type: "equale"},  
264 - function(result) {  
265 - //console.log(result);  
266 - if (result.status == "SUCCESS") {  
267 - ngModelCtrl.$setValidity('remote', true);  
268 - } else {  
269 - ngModelCtrl.$setValidity('remote', false);  
270 - }  
271 - },  
272 - function(result) {  
273 - //console.log(result);  
274 - ngModelCtrl.$setValidity('remote', true);  
275 - }  
276 - );  
277 - } else if (attr["rvtype"] == "jobCode") {  
278 - if (!rv1_attr) {  
279 - ngModelCtrl.$setValidity('remote', false);  
280 - return;  
281 - }  
282 -  
283 - employeeInfoManageService_g.validate.jobCode(  
284 - {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"},  
285 - function(result) {  
286 - //console.log(result);  
287 - if (result.status == "SUCCESS") {  
288 - ngModelCtrl.$setValidity('remote', true);  
289 - } else {  
290 - ngModelCtrl.$setValidity('remote', false);  
291 - }  
292 - },  
293 - function(result) {  
294 - //console.log(result);  
295 - ngModelCtrl.$setValidity('remote', true);  
296 - }  
297 - );  
298 - } else if (attr["rvtype"] == "ttinfoname") {  
299 - if (!rv1_attr) {  
300 - ngModelCtrl.$setValidity('remote', false);  
301 - return;  
302 - }  
303 -  
304 - timeTableManageService_g.validate.ttinfoname(  
305 - {"name_eq": modelValue, "xl.id_eq": rv1_attr, type: "equale"},  
306 - function(result) {  
307 - //console.log(result);  
308 - if (result.status == "SUCCESS") {  
309 - ngModelCtrl.$setValidity('remote', true);  
310 - } else {  
311 - ngModelCtrl.$setValidity('remote', false);  
312 - }  
313 - },  
314 - function(result) {  
315 - //console.log(result);  
316 - ngModelCtrl.$setValidity('remote', true);  
317 - }  
318 - );  
319 -  
320 - }  
321 - } else {  
322 - // 没有rvtype,就不用远端验证了  
323 - ngModelCtrl.$setValidity('remote', true);  
324 - }  
325 -  
326 - attr.$observe("rv1", function(value) {  
327 - if (attr["rvtype"] == "jobCode") {  
328 - if (!value) {  
329 - ngModelCtrl.$setValidity('remote', false);  
330 - return;  
331 - }  
332 -  
333 - employeeInfoManageService_g.validate.jobCode(  
334 - {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"},  
335 - function(result) {  
336 - //console.log(result);  
337 - if (result.status == "SUCCESS") {  
338 - ngModelCtrl.$setValidity('remote', true);  
339 - } else {  
340 - ngModelCtrl.$setValidity('remote', false);  
341 - }  
342 - },  
343 - function(result) {  
344 - //console.log(result);  
345 - ngModelCtrl.$setValidity('remote', true);  
346 - }  
347 - );  
348 - } else if (attr["rvtype"] == "ttinfoname") {  
349 - if (!value) {  
350 - ngModelCtrl.$setValidity('remote', false);  
351 - return;  
352 - }  
353 -  
354 - console.log("rv1:" + value);  
355 -  
356 - timeTableManageService_g.validate.ttinfoname(  
357 - {"name_eq": modelValue, "xl.id_eq": value, type: "equale"},  
358 - function(result) {  
359 - //console.log(result);  
360 - if (result.status == "SUCCESS") {  
361 - ngModelCtrl.$setValidity('remote', true);  
362 - } else {  
363 - ngModelCtrl.$setValidity('remote', false);  
364 - }  
365 - },  
366 - function(result) {  
367 - //console.log(result);  
368 - ngModelCtrl.$setValidity('remote', true);  
369 - }  
370 - );  
371 - }  
372 -  
373 - });  
374 - });  
375 - }  
376 - };  
377 - }]);  
378 -  
379 -  
380 -/**  
381 - * saSelect2指令,根据属性值,动态载入数据,然后支持拼音搜索,点击右边的按钮清除选择并重新载入数据。  
382 - * 1、compile阶段使用的属性如下:  
383 - * required:用于和表单验证连接,指定成required="true"才有效。  
384 - * 2、link阶段使用的属性如下  
385 - * model:关联的模型对象  
386 - * name:表单验证时需要的名字  
387 - * type:关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加  
388 - * modelcolname1:关联的模型字段名字1(一般应该是编码字段)  
389 - * modelcolname2:关联的模型字段名字2(一般应该是名字字段)  
390 - * datacolname1;内部数据对应的字段名字1(与模型字段1对应)  
391 - * datacolname2:内部数据对应的字段名字2(与模型字段2对应)  
392 - * showcolname:下拉框显示的内部数据字段名(注意:不是模型数据字段名),TODO:以后考虑放动态表达式,并在compile阶段使用  
393 - * placeholder:select placeholder字符串描述  
394 - *  
395 - * $$pyFilter,内部的filter指令,结合简拼音进行拼音过滤。  
396 - * $$SearchInfoService_g,内部使用的数据服务  
397 - */  
398 -// saSelect2指令使用的内部信service  
399 -angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', function($resource) {  
400 - return {  
401 - xl: $resource(  
402 - '/line/:type',  
403 - {order: 'name', direction: 'ASC'},  
404 - {  
405 - list: {  
406 - method: 'GET',  
407 - isArray: true  
408 - }  
409 - }  
410 - ),  
411 - zd: $resource(  
412 - '/stationroute/stations',  
413 - {order: 'stationCode', direction: 'ASC'},  
414 - {  
415 - list: {  
416 - method: 'GET',  
417 - isArray: true  
418 - }  
419 - }  
420 - ),  
421 - tcc: $resource(  
422 - '/carpark/:type',  
423 - {order: 'parkCode', direction: 'ASC'},  
424 - {  
425 - list: {  
426 - method: 'GET',  
427 - isArray: true  
428 - }  
429 - }  
430 - ),  
431 - ry: $resource(  
432 - '/personnel/:type',  
433 - {order: 'personnelName', direction: 'ASC'},  
434 - {  
435 - list: {  
436 - method: 'GET',  
437 - isArray: true  
438 - }  
439 - }  
440 - ),  
441 - cl: $resource(  
442 - '/cars/:type',  
443 - {order: "insideCode", direction: 'ASC'},  
444 - {  
445 - list: {  
446 - method: 'GET',  
447 - isArray: true  
448 - }  
449 - }  
450 - ),  
451 - ttInfo: $resource(  
452 - '/tic/:type',  
453 - {order: "name", direction: 'ASC'},  
454 - {  
455 - list: {  
456 - method: 'GET',  
457 - isArray: true  
458 - }  
459 - }  
460 - ),  
461 - cci: $resource(  
462 - '/cci/cars',  
463 - {},  
464 - {  
465 - list: {  
466 - method: 'GET',  
467 - isArray: true  
468 - }  
469 - }  
470 -  
471 - ),  
472 - cci2: $resource(  
473 - '/cci/:type',  
474 - {},  
475 - {  
476 - list: {  
477 - method: 'GET',  
478 - isArray: true  
479 - }  
480 - }  
481 - )  
482 - }  
483 -}]);  
484 -angular.module('ScheduleApp').filter("$$pyFilter", function() {  
485 - return function(items, props) {  
486 - var out = [];  
487 - var limit = props["limit"] || 20; // 默认20条记录  
488 -  
489 - if (angular.isArray(items)) {  
490 - items.forEach(function(item) {  
491 - if (out.length < limit) {  
492 - if (props.search) {  
493 - var upTerm = props.search.toUpperCase();  
494 - if(item.fullChars.indexOf(upTerm) != -1  
495 - || item.camelChars.indexOf(upTerm) != -1) {  
496 - out.push(item);  
497 - }  
498 - }  
499 - }  
500 - });  
501 - }  
502 -  
503 - return out;  
504 - };  
505 -});  
506 -angular.module('ScheduleApp').directive("saSelect2", [  
507 - '$timeout', '$$SearchInfoService_g',  
508 - function($timeout, $$searchInfoService_g) {  
509 - return {  
510 - restrict: 'E',  
511 - templateUrl: '/pages/scheduleApp/module/other/MySearchSelectTemplate.html',  
512 - scope: {  
513 - model: "=" // 独立作用域,关联外部的模型对象  
514 - },  
515 - controllerAs: "$saSelectCtrl",  
516 - bindToController: true,  
517 - controller: function($scope) {  
518 - var self = this;  
519 - self.$$data = []; // 内部关联的数据  
520 - },  
521 - /**  
522 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
523 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
524 - * @param tElem  
525 - * @param tAttrs  
526 - * @returns {{pre: Function, post: Function}}  
527 - */  
528 - compile: function(tElem, tAttrs) {  
529 - // 1、获取此阶段使用的属性  
530 - var $required_attr = tAttrs["required"]; // 用于和表单验证连接,指定成required="true"才有效。  
531 -  
532 - // 2、处理属性  
533 -  
534 - // 确定是否使用angularjs required验证  
535 - // 属性 required  
536 - // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加  
537 - if ($required_attr) {  
538 - if ($required_attr == "true") {  
539 - // 添加required属性指令  
540 - tElem.find("ui-select").attr("required", "");  
541 - } else {  
542 - // 不等于true,不添加required属性指令  
543 - }  
544 - } else {  
545 - // 不添加required属性指令  
546 - }  
547 -  
548 - //console.log("saSelect" + ":compile = >" + tElem.html());  
549 -  
550 - return {  
551 - pre: function(scope, element, attr) {  
552 - // TODO:  
553 - },  
554 - /**  
555 - * 相当于link函数。  
556 - *  
557 - * 重要属性如下:  
558 - * model 是绑定外部值。  
559 - * dicgroup 字典组的类型  
560 - * name input name属性值  
561 - */  
562 - post: function(scope, element, attr) {  
563 - // 1、获取此阶段使用的属性  
564 - var $name_attr = attr["name"]; // 表单验证时需要的名字  
565 - var $type_attr = attr["type"]; // 关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加  
566 - var $modelcolname1_attr = attr["modelcolname1"]; // 关联的模型字段名字1(一般应该是编码字段)  
567 - var $modelcolname2_attr = attr["modelcolname2"]; // 关联的模型字段名字2(一般应该是名字字段)  
568 - var $datacolname1_attr = attr["datacolname1"]; // 内部数据对应的字段名字1(与模型字段1对应)  
569 - var $datacolname2_attr = attr["datacolname2"]; // 内部数据对应的字段名字2(与模型字段2对应)  
570 - var $showcolname_attr = attr["showcolname"]; // 下拉框显示的内部数据字段名  
571 - var $placeholder_attr = attr["placeholder"]; // select placeholder字符串描述  
572 -  
573 - // 2、处理属性、转换成$saSelectCtrl内部使用的属性  
574 - if ($name_attr) {  
575 - scope["$saSelectCtrl"].$name_attr = $name_attr;  
576 - }  
577 - if ($placeholder_attr) {  
578 - scope["$saSelectCtrl"].$placeholder_attr = $placeholder_attr;  
579 - }  
580 - if ($showcolname_attr) {  
581 - scope["$saSelectCtrl"].$showcolname_attr = $showcolname_attr;  
582 - }  
583 -  
584 - // 2-1、添加内部方法,根据type值,改变$$data的值  
585 - scope["$saSelectCtrl"].$$internal_data_change_fn = function() {  
586 - // 根据type属性动态载入数据  
587 - if ($type_attr) {  
588 - $$searchInfoService_g[$type_attr].list(  
589 - {type: "all"},  
590 - function(result) {  
591 - scope["$saSelectCtrl"].$$data = [];  
592 - for (var i = 0; i < result.length; i ++) {  
593 - var data = {}; // data是result的一部分属性集合,根据配置来确定  
594 - if ($datacolname1_attr) {  
595 - data[$datacolname1_attr] = result[i][$datacolname1_attr];  
596 - }  
597 - if ($datacolname2_attr) {  
598 - data[$datacolname2_attr] = result[i][$datacolname2_attr];  
599 - }  
600 - if ($showcolname_attr) {  
601 - // 动态添加基于名字的拼音  
602 - data[$showcolname_attr] = result[i][$showcolname_attr];  
603 - if (data[$showcolname_attr]) {  
604 - data["fullChars"] = pinyin.getFullChars(result[i][$showcolname_attr]).toUpperCase(); // 全拼  
605 - data["camelChars"] = pinyin.getCamelChars(result[i][$showcolname_attr]); // 简拼  
606 - }  
607 - }  
608 - if (data["fullChars"])  
609 - scope["$saSelectCtrl"].$$data.push(data);  
610 - }  
611 - },  
612 - function(result) {  
613 -  
614 - }  
615 - );  
616 - }  
617 - };  
618 -  
619 - // 3、选择、删除事件映射模型和内部数据对应的字段  
620 - scope["$saSelectCtrl"].$select_fn_attr = function($item) {  
621 - if ($modelcolname1_attr && $datacolname1_attr) {  
622 - scope["$saSelectCtrl"].model[$modelcolname1_attr] = $item[$datacolname1_attr];  
623 - }  
624 - if ($modelcolname2_attr && $datacolname2_attr) {  
625 - scope["$saSelectCtrl"].model[$modelcolname2_attr] = $item[$datacolname2_attr];  
626 - }  
627 - };  
628 - scope["$saSelectCtrl"].$remove_fn_attr = function() {  
629 - if ($modelcolname1_attr) {  
630 - scope["$saSelectCtrl"].model[$modelcolname1_attr] = null;  
631 - }  
632 - if ($modelcolname2_attr) {  
633 - scope["$saSelectCtrl"].model[$modelcolname2_attr] = null;  
634 - }  
635 - scope["$saSelectCtrl"].$$cmodel = null; // 内部模型清空  
636 -  
637 - scope["$saSelectCtrl"].$$internal_data_change_fn();  
638 - };  
639 -  
640 - // 4、搜索事件  
641 - scope["$saSelectCtrl"].$refreshdata_fn_attr = function($search) {  
642 - //var fullChars = pinyin.getFullChars($search).toUpperCase();  
643 - //var camelChars = pinyin.getCamelChars($search);  
644 - //  
645 - //console.log(fullChars + " " + camelChars);  
646 - // TODO:事件暂时没用,放着以后再说  
647 - };  
648 -  
649 - // 5、全部载入后,输入的  
650 - $timeout(function() {  
651 - // 创建内部使用的绑定对象,用于确认选中那个值  
652 - scope["$saSelectCtrl"].$$cmodel = scope["$saSelectCtrl"].model[$modelcolname1_attr];  
653 -  
654 - scope["$saSelectCtrl"].$$internal_data_change_fn();  
655 - }, 0);  
656 - }  
657 - }  
658 - }  
659 - };  
660 - }  
661 -]);  
662 -  
663 -/**  
664 - * saSelect3指令  
665 - * 属性如下:  
666 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
667 - * name(必须):控件的名字  
668 - * placeholder(可选):占位符字符串  
669 - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}  
670 - * dcname(必须):绑定的model字段名,如:dcname=xl.id  
671 - * icname(必须):内部与之对应的字段名,如:icname=code  
672 - * dcname2(可选):其他需要赋值的model字段名2,如:dcname2=xl.name  
673 - * icname2(可选):内部与之对应的字段名2,如:icname2=name  
674 - * icnames(必须):用于用于显示,以及简评处理的内部数据字段,如:icnames=name  
675 - * required(可选):是否要用required验证  
676 - * datatype(必须):业务数据类型,有字典类型,动态数据类型,暂时写的死点  
677 - * mlp(可选):是否多级属性(这里假设外部model如果多级,内部model也是多级)  
678 - *  
679 - * 高级属性:  
680 - * dataassociate(可选):数据源是否关联属性(内部数据随外部指定的参数变化而变化)  
681 - * dataparam(可选):数据源关联的外部参数对象  
682 - *  
683 - */  
684 -angular.module('ScheduleApp').directive("saSelect3", [  
685 - '$timeout',  
686 - '$$SearchInfoService_g',  
687 - function($timeout, $$searchInfoService_g) {  
688 - return {  
689 - restrict: 'E',  
690 - templateUrl: '/pages/scheduleApp/module/common/dt/MyUiSelectWrapTemplate1.html',  
691 - scope: {  
692 - model: "=" // 独立作用域,关联外部的模型object  
693 - },  
694 - controllerAs: "$saSelectCtrl",  
695 - bindToController: true,  
696 - controller: function($scope) {  
697 - var self = this;  
698 - self.$$data = []; // ui-select显示用的数据源  
699 - self.$$data_real= []; // 内部真实的数据源  
700 - },  
701 -  
702 - /**  
703 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
704 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
705 - * @param tElem  
706 - * @param tAttrs  
707 - * @returns {{pre: Function, post: Function}}  
708 - */  
709 - compile: function(tElem, tAttrs) {  
710 - // 获取所有的属性  
711 - var $name_attr = tAttrs["name"]; // 控件的名字  
712 - var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字  
713 - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名  
714 - var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名  
715 - var $dcname2_attr = tAttrs["dcname2"]; // 其他需要赋值的model字段名2  
716 - var $icname2_attr = tAttrs["icname2"]; // 内部与之对应的字段名2  
717 - var $icname_s_attr = tAttrs["icnames"]; // 用于用于显示,以及简评处理的内部数据字段  
718 - var $datatype_attr = tAttrs["datatype"]; // 内部业务数据类型  
719 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
720 - var $mlp_attr = tAttrs["mlp"]; // 是否多级属性  
721 - var $dataassociate_attr = tAttrs["dataassociate"]; // 数据源是否关联属性  
722 -  
723 - // controlAs名字  
724 - var ctrlAs = "$saSelectCtrl";  
725 -  
726 - // 数据源初始化标志  
727 - var $$data_init = false;  
728 - // 如果有required属性,添加angularjs required验证  
729 - if ($required_attr != undefined) {  
730 - tElem.find("ui-select").attr("required", "");  
731 - }  
732 -  
733 - // 由于有的属性是多级的如xl.name,所以要在compile阶段重写属性绑定属性定义  
734 - // 原来的设置:{{$select.selected[$saSelectCtrl.$icname_s]}}  
735 - tElem.find("ui-select-match").html("{{$select.selected" + "." + $icname_s_attr + "}}");  
736 - // 原来的设置:item[$saSelectCtrl.$icname] as item in $saSelectCtrl.$$data  
737 - tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data");  
738 - // 原来的设置:item[$saSelectCtrl.$icname_s]  
739 - tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $icname_s_attr);  
740 - // 原来的设置:{{$saSelectCtrl.$name}}  
741 - tElem.find("ui-select").attr("name", $name_attr);  
742 - // 原来的设置:{{$saSelectCtrl.$placeholder}}  
743 - tElem.find("ui-select-match").attr("placeholder", $placeholder_attr);  
744 -  
745 - return {  
746 - pre: function(scope, element, attr) {  
747 - // TODO:  
748 - },  
749 - /**  
750 - * 相当于link函数。  
751 - * @param scope  
752 - * @param element  
753 - * @param attr  
754 - */  
755 - post: function(scope, element, attr) {  
756 - // 添加选中事件处理函数  
757 - scope[ctrlAs].$$internal_select_fn = function($item) {  
758 - if ($dcname_attr && $icname_attr) {  
759 - if ($mlp_attr) {  
760 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");  
761 - } else {  
762 - scope[ctrlAs].model[$dcname_attr] = $item[$icname_attr];  
763 - }  
764 - }  
765 - if ($dcname2_attr && $icname2_attr) {  
766 - if ($mlp_attr) {  
767 - eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = $item" + "." + $icname2_attr + ";");  
768 - } else {  
769 - scope[ctrlAs].model[$dcname2_attr] = $item[$icname2_attr];  
770 - }  
771 - }  
772 - };  
773 -  
774 - // 删除选中事件处理函数  
775 - scope[ctrlAs].$$internal_remove_fn = function() {  
776 - scope[ctrlAs].$$internalmodel = undefined;  
777 - if ($mlp_attr) {  
778 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");  
779 - } else {  
780 - scope[ctrlAs].model[$dcname_attr] = undefined;  
781 - }  
782 -  
783 - if ($dcname2_attr) {  
784 - if ($mlp_attr) {  
785 - eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = undefined;");  
786 - } else {  
787 - scope[ctrlAs].model[$dcname2_attr] = undefined;  
788 - }  
789 - }  
790 - };  
791 -  
792 - /**  
793 - * 内部方法,读取字典数据作为数据源。  
794 - * @param dicgroup 字典类型,如:gsType  
795 - * @param ccol 代码字段名  
796 - * @param ncol 名字字段名  
797 - */  
798 - scope[ctrlAs].$$internal_dic_data = function(dicgroup, ccol, ncol) {  
799 - var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);  
800 - var dic_key; // 字典key  
801 - // 清空内部数据  
802 - scope[ctrlAs].$$data_real = [];  
803 - for (dic_key in origin_dicgroup) {  
804 - var data = {}; // 重新组合的字典元素对象  
805 - if (dic_key == "true")  
806 - data[ccol] = true;  
807 - else  
808 - data[ccol] = dic_key;  
809 - data[ncol] = origin_dicgroup[dic_key];  
810 - scope[ctrlAs].$$data_real.push(data);  
811 - }  
812 - // 这里直接将$$data_real数据深拷贝到$$data  
813 - angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data);  
814 -  
815 - console.log(scope[ctrlAs].$$data);  
816 - };  
817 -  
818 - /**  
819 - * TODO:这个方法有性能问题,result一多就会卡一卡,之后再解决把  
820 - * 内部方法,读取字典数据作为数据源。  
821 - * @param result 原始数据  
822 - * @param dcvalue 传入的关联数据  
823 - */  
824 - scope[ctrlAs].$$internal_other_data = function(result, dcvalue) {  
825 - //console.log("start");  
826 - // 清空内部数据  
827 - scope[ctrlAs].$$data_real = [];  
828 - scope[ctrlAs].$$data = [];  
829 - for (var i = 0; i < result.length; i ++) {  
830 - if ($icname_s_attr) {  
831 - if ($mlp_attr) {  
832 - if (eval("result[i]" + "." + $icname_s_attr)) {  
833 - // 全拼  
834 - result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $icname_s_attr)).toUpperCase();  
835 - // 简拼  
836 - result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $icname_s_attr));  
837 - }  
838 - } else {  
839 - if (result[i][$icname_s_attr]) {  
840 - // 全拼  
841 - result[i]["fullChars"] = pinyin.getFullChars(result[i][$icname_s_attr]).toUpperCase();  
842 - // 简拼  
843 - result[i]["camelChars"] = pinyin.getCamelChars(result[i][$icname_s_attr]);  
844 - }  
845 - }  
846 - }  
847 -  
848 - if (result[i]["fullChars"]) { // 有拼音的加入数据源  
849 - scope[ctrlAs].$$data_real.push(result[i]);  
850 - }  
851 -  
852 - }  
853 - //console.log("start2");  
854 -  
855 - // 数量太大取前10条记录作为显示  
856 - if (angular.isArray(scope[ctrlAs].$$data_real)) {  
857 - // 先迭代循环查找已经传过来的值  
858 - if (scope[ctrlAs].$$data_real.length > 0) {  
859 - if (dcvalue) {  
860 - for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {  
861 - if (scope[ctrlAs].$$data_real[j][$icname_attr] == dcvalue) {  
862 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[j]));  
863 - break;  
864 - }  
865 - }  
866 - }  
867 - }  
868 - // 在插入剩余的数据  
869 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
870 - if (scope[ctrlAs].$$data.length < 10) {  
871 - if ($mlp_attr) {  
872 - if (eval("scope[ctrlAs].$$data_real[k]" + "." + $icname_attr + " != dcvalue")) {  
873 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
874 - }  
875 - } else {  
876 - if (scope[ctrlAs].$$data_real[k][$icname_attr] != dcvalue) {  
877 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
878 - }  
879 - }  
880 - } else {  
881 - break;  
882 - }  
883 - }  
884 - }  
885 -  
886 - //console.log("end");  
887 - };  
888 -  
889 - /**  
890 - * 判定一个对象是否为空对象。  
891 - * @param Obj  
892 - */  
893 - scope[ctrlAs].$$internal_isEmpty_obj = function(obj) {  
894 - console.log(typeof obj);  
895 -  
896 - if (typeof obj === "object" && !(obj instanceof Array)) {  
897 - for (var prop in obj) {  
898 - if (obj.hasOwnProperty(prop)) {  
899 - return false;  
900 - }  
901 - }  
902 - return true;  
903 - } else {  
904 - throw "必须是对象";  
905 - }  
906 - };  
907 -  
908 - // 刷新数据  
909 - scope[ctrlAs].$$internal_refresh_fn = function(search) {  
910 - // 绑定的model字段值,此属性是绑定属性,只能在link阶段获取  
911 - var $dcvalue_attr = attr["dcvalue"];  
912 -  
913 - console.log("刷新数据:" + $dcvalue_attr);  
914 -  
915 - if (!$$data_init) { // 只初始化$$data_real一次,重新载入页面才能重新初始化  
916 - if (dictionaryUtils.getByGroup($datatype_attr)) { // 判定是否字典类型数据源  
917 - scope[ctrlAs].$$internal_dic_data(  
918 - $datatype_attr, $icname_attr, $icname_s_attr);  
919 - if ($dcvalue_attr) {  
920 - scope[ctrlAs].$$internalmodel = $dcvalue_attr;  
921 - }  
922 - } else { // 非字典类型数据源  
923 - if (!$dataassociate_attr) {  
924 - $$searchInfoService_g[$datatype_attr].list(  
925 - {type: "all"},  
926 - function(result) {  
927 - //console.log("ok:" + $datatype_attr);  
928 - scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr);  
929 - //console.log("ok2:" + $datatype_attr);  
930 - if ($dcvalue_attr) {  
931 - scope[ctrlAs].$$internalmodel = $dcvalue_attr;  
932 - }  
933 -  
934 - $$data_init = true;  
935 - },  
936 - function(result) {  
937 -  
938 - }  
939 - );  
940 - }  
941 - }  
942 - }  
943 -  
944 - if ($$data_init) {  
945 - if (search && search != "") { // 有search值  
946 - if (!dictionaryUtils.getByGroup($datatype_attr)) { // 其他数据源  
947 - // 处理search  
948 - console.log("search:" + search);  
949 -  
950 - scope[ctrlAs].$$data = [];  
951 - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {  
952 - var upTerm = search.toUpperCase();  
953 - if (scope[ctrlAs].$$data.length < 10) {  
954 - if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1  
955 - || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) {  
956 - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));  
957 - }  
958 - } else {  
959 - break;  
960 - }  
961 - }  
962 - }  
963 - }  
964 -  
965 - }  
966 -  
967 - };  
968 -  
969 -  
970 -  
971 -  
972 -  
973 -  
974 -  
975 -  
976 -  
977 -  
978 - // TODO:  
979 -  
980 - // dom全部载入后调用  
981 - $timeout(function() {  
982 - console.log("dom全部载入后调用");  
983 - }, 0);  
984 - // 监控dcvalue model值变换  
985 - attr.$observe("dcvalue", function(value) {  
986 - console.log("监控dc1 model值变换:" + value);  
987 - scope[ctrlAs].$$internalmodel = value;  
988 - }  
989 - );  
990 - // 监控获取数据参数变换  
991 - attr.$observe("dataparam", function(value) {  
992 - // 判定是否空对象  
993 - console.log(value);  
994 - var obj = JSON.parse(value);  
995 - var $dcvalue_attr = attr["dcvalue"];  
996 - if (!scope[ctrlAs].$$internal_isEmpty_obj(obj)) {  
997 - console.log("dataparam:" + obj);  
998 -  
999 - //  
1000 -  
1001 - obj["type"] = "all";  
1002 -  
1003 - $$data_init = false;  
1004 - $$searchInfoService_g[$datatype_attr].list(  
1005 - obj,  
1006 - function(result) {  
1007 - //console.log("ok:" + $datatype_attr);  
1008 - scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr);  
1009 - //console.log("ok2:" + $datatype_attr);  
1010 - if ($dcvalue_attr) {  
1011 - scope[ctrlAs].$$internalmodel = $dcvalue_attr;  
1012 - }  
1013 -  
1014 - $$data_init = true;  
1015 - },  
1016 - function(result) {  
1017 -  
1018 - }  
1019 - );  
1020 - }  
1021 - }  
1022 - );  
1023 - }  
1024 - };  
1025 - }  
1026 - };  
1027 -  
1028 - }  
1029 -]);  
1030 -  
1031 -/**  
1032 - * saCheckboxgroup指令  
1033 - * 属性如下:  
1034 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
1035 - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}  
1036 - * dcname(必须):绑定的model字段名,如:dcname=xl.id  
1037 - * name(必须):控件的名字  
1038 - * required(可选):是否要用required验证  
1039 - * disabled(可选):标示框是否可选  
1040 - *  
1041 - */  
1042 -angular.module('ScheduleApp').directive('saCheckboxgroup', [  
1043 - function() {  
1044 - return {  
1045 - restrict: 'E',  
1046 - templateUrl: '/pages/scheduleApp/module/common/dt/MyCheckboxGroupWrapTemplate.html',  
1047 - scope: {  
1048 - model: "=" // 独立作用域,关联外部的模型object  
1049 - },  
1050 - controllerAs: "$saCheckboxgroupCtrl",  
1051 - bindToController: true,  
1052 - controller: function($scope) {  
1053 - var self = this;  
1054 - self.$$data = []; // 内部的数据  
1055 -  
1056 - // TODO:数据写死,周一至周日选择数据,以后有别的数据再议  
1057 - self.$$data = [  
1058 - {name: "星期一", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
1059 - {name: "星期二", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
1060 - {name: "星期三", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
1061 - {name: "星期四", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
1062 - {name: "星期五", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
1063 - {name: "星期六", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},  
1064 - {name: "星期日", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}  
1065 - ];  
1066 - },  
1067 -  
1068 - /**  
1069 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
1070 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
1071 - * @param tElem  
1072 - * @param tAttrs  
1073 - * @returns {{pre: Function, post: Function}}  
1074 - */  
1075 - compile: function(tElem, tAttrs) {  
1076 - // 获取所有的属性  
1077 - var $name_attr = tAttrs["name"]; // 控件的名字  
1078 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
1079 - var $disabled_attr = tAttrs["disabled"]; // 是否禁用  
1080 - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名  
1081 -  
1082 - // controlAs名字  
1083 - var ctrlAs = '$saCheckboxgroupCtrl';  
1084 -  
1085 - // 如果有required属性,添加angularjs required验证  
1086 - if ($required_attr != undefined) {  
1087 - //console.log(tElem.html());  
1088 - tElem.find("div").attr("required", "");  
1089 - }  
1090 - // 如果有disabled属性,添加禁用标志  
1091 - if ($disabled_attr != undefined) {  
1092 - tElem.find("input").attr("ng-disabled", "true");  
1093 - }  
1094 -  
1095 - return {  
1096 - pre: function(scope, element, attr) {  
1097 - // TODO:  
1098 - },  
1099 - /**  
1100 - * 相当于link函数。  
1101 - * @param scope  
1102 - * @param element  
1103 - * @param attr  
1104 - */  
1105 - post: function(scope, element, attr) {  
1106 - // name属性  
1107 - if ($name_attr) {  
1108 - scope[ctrlAs]["$name_attr"] = $name_attr;  
1109 - }  
1110 -  
1111 - /**  
1112 - * checkbox选择事件处理函数。  
1113 - * @param $d 数据对象,$$data中的元素对象  
1114 - */  
1115 - scope[ctrlAs].$$internal_updateCheck_fn = function($d) {  
1116 - $d.ischecked = !$d.ischecked;  
1117 - console.log($d);  
1118 - };  
1119 -  
1120 - // 测试使用watch监控$$data的变化  
1121 - scope.$watch(  
1122 - function() {  
1123 - return scope[ctrlAs]["$$data"];  
1124 - },  
1125 - function(newValue, oldValue) {  
1126 - // 根据$$data生成对应的数据  
1127 - var rule_days_arr = [];  
1128 - var i;  
1129 - for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {  
1130 - if (scope[ctrlAs]["$$data"][i].ischecked)  
1131 - rule_days_arr.push(scope[ctrlAs]["$$data"][i].checkedvalue);  
1132 - else  
1133 - rule_days_arr.push(scope[ctrlAs]["$$data"][i].uncheckedvalue);  
1134 - }  
1135 - scope[ctrlAs].$$internalmodel = rule_days_arr.join(",");  
1136 - //scope[ctrlAs].$$internalmodel = undefined;  
1137 - console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel);  
1138 -  
1139 - // 更新model  
1140 - if ($dcname_attr) {  
1141 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = rule_days_arr.join(',');");  
1142 - }  
1143 -  
1144 -  
1145 - },  
1146 - true  
1147 - );  
1148 -  
1149 - // TODO:  
1150 -  
1151 - // 监控dcvalue model值变换  
1152 - attr.$observe("dcvalue", function(value) {  
1153 - console.log("saCheckboxgroup 监控dc1 model值变换:" + value);  
1154 - if (value) {  
1155 - // 根据value值,修改$$data里的值  
1156 - var data_array = value.split(",");  
1157 - var i;  
1158 - if (data_array.length > scope[ctrlAs]["$$data"].length) {  
1159 - for (i = 0; i < scope[ctrlAs]["$$data"].length; i ++) {  
1160 - if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) {  
1161 - scope[ctrlAs]["$$data"][i].ischecked = true;  
1162 - } else {  
1163 - scope[ctrlAs]["$$data"][i].ischecked = false;  
1164 - }  
1165 - }  
1166 - } else {  
1167 - for (i = 0; i < data_array.length; i ++) {  
1168 - if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) {  
1169 - scope[ctrlAs]["$$data"][i].ischecked = true;  
1170 - } else {  
1171 - scope[ctrlAs]["$$data"][i].ischecked = false;  
1172 - }  
1173 - }  
1174 - }  
1175 -  
1176 - }  
1177 - });  
1178 - }  
1179 -  
1180 - };  
1181 -  
1182 -  
1183 - }  
1184 -  
1185 - };  
1186 - }  
1187 -]);  
1188 -  
1189 -/**  
1190 - * saDategroup指令  
1191 - * 属性如下:  
1192 - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave  
1193 - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}  
1194 - * dcname(必须):绑定的model字段名,如:dcname=xl.id  
1195 - * name(必须):控件的名字  
1196 - * required(可选):是否要用required验证  
1197 - * disabled(可选):标示框是否可选  
1198 - *  
1199 - */  
1200 -angular.module('ScheduleApp').directive('saDategroup', [  
1201 - '$filter',  
1202 - function($filter) {  
1203 - return {  
1204 - restrict: 'E',  
1205 - templateUrl: '/pages/scheduleApp/module/common/dt/MyDateGroupWrapTemplate.html',  
1206 - scope: {  
1207 - model: "=" // 独立作用域,关联外部的模型object  
1208 - },  
1209 - controllerAs: "$saDategroupCtrl",  
1210 - bindToController: true,  
1211 - controller: function($scope) {  
1212 - var self = this;  
1213 - self.$$data = []; // 内部的数据  
1214 - self.$$date_select; // 内部选中的日期  
1215 -  
1216 - //// 测试数据  
1217 - //self.$$data = [  
1218 - // {datestr: '2011-01-01', ischecked: true},  
1219 - // {datestr: '2011-01-01', ischecked: true},  
1220 - // {datestr: '2011-01-01', ischecked: true}  
1221 - //];  
1222 - },  
1223 -  
1224 - /**  
1225 - * 此阶段可以改dom结构,此时angular还没扫描指令,  
1226 - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。  
1227 - * @param tElem  
1228 - * @param tAttrs  
1229 - * @returns {{pre: Function, post: Function}}  
1230 - */  
1231 - compile: function(tElem, tAttrs) {  
1232 - // 获取所有的属性  
1233 - var $name_attr = tAttrs["name"]; // 控件的名字  
1234 - var $required_attr = tAttrs["required"]; // 是否需要required验证  
1235 - var $disabled_attr = tAttrs["disabled"]; // 是否禁用  
1236 - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名  
1237 -  
1238 - // controlAs名字  
1239 - var ctrlAs = '$saDategroupCtrl';  
1240 -  
1241 - // 如果有required属性,添加angularjs required验证  
1242 - if ($required_attr != undefined) {  
1243 - //console.log(tElem.html());  
1244 - tElem.find("div").attr("required", "");  
1245 - }  
1246 - // 如果有disabled属性,添加禁用标志  
1247 - if ($disabled_attr != undefined) {  
1248 - tElem.find("input").attr("ng-disabled", "true");  
1249 - tElem.find("div").attr("ng-disabled", "true");  
1250 - }  
1251 -  
1252 - return {  
1253 - pre: function (scope, element, attr) {  
1254 - // TODO:  
1255 - },  
1256 - /**  
1257 - * 相当于link函数。  
1258 - * @param scope  
1259 - * @param element  
1260 - * @param attr  
1261 - */  
1262 - post: function (scope, element, attr) {  
1263 - // name属性  
1264 - if ($name_attr) {  
1265 - scope[ctrlAs]["$name_attr"] = $name_attr;  
1266 - }  
1267 -  
1268 -  
1269 - // 日期open属性,及方法  
1270 - scope[ctrlAs].$$specialDateOpen = false;  
1271 - scope[ctrlAs].$$specialDate_open = function() {  
1272 - scope[ctrlAs].$$specialDateOpen = true;  
1273 - };  
1274 -  
1275 - // 监控选择的日期  
1276 - scope.$watch(  
1277 - function() {  
1278 - return scope[ctrlAs]['$$date_select'];  
1279 - },  
1280 - function(newValue, oldValue) {  
1281 - if (newValue) {  
1282 - //console.log("saDategroup--->selectdate:" + newValue);  
1283 - // 调用内置filter,转换日期到yyyy-MM-dd格式  
1284 - var text = $filter('date')(newValue, 'yyyy-MM-dd');  
1285 - var i;  
1286 - var isexist = false; // 日期是否已经选择标识  
1287 - for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {  
1288 - if (scope[ctrlAs]["$$data"][i].datestr == text) {  
1289 - isexist = true;  
1290 - break;  
1291 - }  
1292 - }  
1293 - if (!isexist) {  
1294 - scope[ctrlAs]["$$data"].push(  
1295 - {  
1296 - datestr: text,  
1297 - ischecked: true  
1298 - }  
1299 - );  
1300 - }  
1301 -  
1302 - }  
1303 -  
1304 - }  
1305 - );  
1306 -  
1307 - /**  
1308 - * 日期点击事件处理函数。  
1309 - * @param $index 索引  
1310 - */  
1311 - scope[ctrlAs].$$internal_datestr_click = function($index) {  
1312 - scope[ctrlAs].$$data.splice($index, 1);  
1313 - };  
1314 -  
1315 - // 测试使用watch监控$$data的变化  
1316 - scope.$watch(  
1317 - function() {  
1318 - return scope[ctrlAs]['$$data'];  
1319 - },  
1320 - function(newValue, oldValue) {  
1321 - // 根据$$data生成对应的数据  
1322 - var special_days_arr = [];  
1323 - var i;  
1324 - for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {  
1325 - special_days_arr.push(scope[ctrlAs]["$$data"][i].datestr);  
1326 - }  
1327 -  
1328 - scope[ctrlAs].$$internalmodel = special_days_arr.join(",");  
1329 - console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel);  
1330 -  
1331 - // 更新model  
1332 - if ($dcname_attr) {  
1333 - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = special_days_arr.join(',');");  
1334 - }  
1335 - },  
1336 - true  
1337 - );  
1338 -  
1339 - // 监控dcvalue model值变换  
1340 - attr.$observe("dcvalue", function(value) {  
1341 - console.log("saDategroup 监控dc1 model值变换:" + value);  
1342 - if (value) {  
1343 - // 根据value值,修改$$data里的值  
1344 - var date_array = value.split(",");  
1345 - var i;  
1346 - scope[ctrlAs]["$$data"] = [];  
1347 - for (i = 0; i < date_array.length; i++) {  
1348 - scope[ctrlAs]["$$data"].push(  
1349 - {  
1350 - datestr: date_array[i],  
1351 - ischecked: true  
1352 - }  
1353 - );  
1354 - }  
1355 -  
1356 -  
1357 -  
1358 -  
1359 -  
1360 -  
1361 -  
1362 -  
1363 -  
1364 - }  
1365 - });  
1366 -  
1367 - }  
1368 -  
1369 - };  
1370 - }  
1371 - }  
1372 - }  
1373 -]);  
1374 -  
1375 -  
1376 -  
1377 -  
1378 -  
1379 -  
1380 -  
1381 -  
1382 -  
1383 -  
1384 -  
1385 -  
1386 -  
1387 -  
1388 -  
1389 -  
1390 -  
1391 -  
1392 -  
1393 -  
1394 -  
1395 -  
1396 -  
1397 -  
1398 - 1 +// 自定义指令,指令模版在dt目录下
  2 +
  3 +
  4 +angular.module('ScheduleApp').directive('loadingWidget', ['requestNotificationChannel', function(requestNotificationChannel) {
  5 + return {
  6 + restrict: 'A',
  7 + link: function(scope, element) {
  8 + // 初始隐藏loading界面
  9 + element.hide();
  10 +
  11 + // 开始请求通知处理
  12 + requestNotificationChannel.onRequestStarted(scope, function() {
  13 + element.show();
  14 + });
  15 + // 请求结束通知处理
  16 + requestNotificationChannel.onRequestEnded(scope, function() {
  17 + element.hide();
  18 + });
  19 + }
  20 + };
  21 +}]);
  22 +
  23 +angular.module('ScheduleApp').directive("saSelect", ['$timeout', function($timeout) {
  24 + return {
  25 + restrict: 'E',
  26 + templateUrl: '/pages/scheduleApp/module/other/MyDictionarySelectTemplate.html',
  27 + scope: {
  28 + model: "="
  29 + },
  30 + controllerAs: "$saSelectCtrl",
  31 + bindToController: true,
  32 + controller: function() {
  33 + var self = this;
  34 + self.datas = []; // 关联的字典数据,内部格式 {code:{值},name:{名字}}
  35 + },
  36 + /**
  37 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  38 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  39 + * @param tElem
  40 + * @param tAttrs
  41 + * @returns {{pre: Function, post: Function}}
  42 + */
  43 + compile: function(tElem, tAttrs) {
  44 + // 确定是否使用angularjs required验证
  45 + // 属性 required
  46 + // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加
  47 + var required_attr = tAttrs["required"];
  48 + if (required_attr) {
  49 + if (required_attr == "true") {
  50 + // 添加required属性指令
  51 + tElem.find("ui-select").attr("required", "");
  52 + } else {
  53 + // 不等于true,不添加required属性指令
  54 + }
  55 + } else {
  56 + // 不添加required属性指令
  57 + }
  58 +
  59 + //console.log("saSelect" + ":compile = >" + tElem.html());
  60 +
  61 + return {
  62 + pre: function(scope, element, attr) {
  63 + // TODO:
  64 + },
  65 + /**
  66 + * 相当于link函数。
  67 + *
  68 + * 重要属性如下:
  69 + * model 是绑定外部值。
  70 + * dicgroup 字典组的类型
  71 + * name input name属性值
  72 + */
  73 + post: function(scope, element, attr) {
  74 + // 1、获取属性
  75 + var dicgroup_attr = attr['dicgroup']; // 字典组的类型
  76 + var name_attr = attr['name']; // input name属性值
  77 + var dicname_attr = attr['dicname']; // model关联的字典名字段
  78 + var codename_attr = attr['codename']; // model关联的字典值字段
  79 + var placeholder_attr = attr['placeholder']; // select placeholder提示
  80 +
  81 + // 系统的字典对象,使用dictionaryUtils类获取
  82 + var origin_dicgroup;
  83 + var dic_key; // 字典key
  84 +
  85 + if (dicgroup_attr) { // 赋值指定的字典数据
  86 + origin_dicgroup = dictionaryUtils.getByGroup(dicgroup_attr);
  87 + for (dic_key in origin_dicgroup) {
  88 + var data = {}; // 重新组合的字典元素对象
  89 + if (dic_key == "true")
  90 + data.code = true;
  91 + else
  92 + data.code = dic_key;
  93 + data.name = origin_dicgroup[dic_key];
  94 + scope["$saSelectCtrl"].datas.push(data);
  95 + }
  96 + }
  97 +
  98 + if (name_attr) {
  99 + scope["$saSelectCtrl"].nv = name_attr;
  100 + }
  101 + if (placeholder_attr) {
  102 + scope["$saSelectCtrl"].ph = placeholder_attr;
  103 + }
  104 +
  105 + scope["$saSelectCtrl"].select = function($item) {
  106 + if (codename_attr) {
  107 + scope["$saSelectCtrl"].model[codename_attr] = $item.code;
  108 + }
  109 + if (dicname_attr) {
  110 + scope["$saSelectCtrl"].model[dicname_attr] = $item.name;
  111 + }
  112 + };
  113 +
  114 + scope["$saSelectCtrl"].remove = function() {
  115 + if (codename_attr) {
  116 + scope["$saSelectCtrl"].model[codename_attr] = null;
  117 + }
  118 + if (dicname_attr) {
  119 + scope["$saSelectCtrl"].model[dicname_attr] = null;
  120 + }
  121 + scope["$saSelectCtrl"].cmodel = null;
  122 + };
  123 +
  124 + $timeout(function() {
  125 + // 创建内部使用的绑定对象
  126 + var model_code = scope["$saSelectCtrl"].model[codename_attr];
  127 + scope["$saSelectCtrl"].cmodel = model_code;
  128 + }, 0);
  129 + }
  130 + }
  131 + }
  132 + };
  133 +}]);
  134 +
  135 +/**
  136 + * saRadiogroup指令
  137 + * 属性如下:
  138 + * model(必须):独立作用域,外部绑定的一个值,如:ctrl.timeTableManageForForm.isEnableDisTemplate
  139 + * dicgroup(必须):关联的字典数据type(TODO:以后增加其他数据源)
  140 + * name(必须):控件的名字
  141 + * required(可选):是否要用required验证
  142 + * disabled(可选):标示单选框是否可选
  143 + *
  144 + */
  145 +angular.module('ScheduleApp').directive("saRadiogroup", [function() {
  146 + /**
  147 + * 使用字典数据的单选按钮组的指令。
  148 + * 指令名称:truefalse-Dic
  149 + */
  150 + return {
  151 + restrict: 'E',
  152 + templateUrl: '/pages/scheduleApp/module/common/dt/MyRadioGroupWrapTemplate.html',
  153 + scope: {
  154 + model: "="
  155 + },
  156 + controllerAs: "$saRadiogroupCtrl",
  157 + bindToController: true,
  158 + controller: function($scope) {
  159 + //$scope["model"] = {selectedOption: null};
  160 + //console.log("controller");
  161 + //console.log("controller:" + $scope["model"]);
  162 +
  163 + var self = this;
  164 + self.$$data = null; // 内部数据
  165 + },
  166 +
  167 + /**
  168 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  169 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  170 + * @param tElem
  171 + * @param tAttrs
  172 + * @returns {{pre: Function, post: Function}}
  173 + */
  174 + compile: function(tElem, tAttrs) {
  175 + // 获取属性
  176 + var $dicgroup_attr = tAttrs["dicgroup"]; // 关联的字典数据type
  177 + var $name_attr = tAttrs["name"]; // 控件的名字
  178 + var $required_attr = tAttrs["required"]; // 是否要用required验证
  179 + var $disabled_attr = tAttrs["disabled"]; // 标示单选框是否可选
  180 +
  181 + // controlAs名字
  182 + var ctrlAs = "$saRadiogroupCtrl";
  183 +
  184 + // 如果有required属性,添加angularjs required验证
  185 + if ($required_attr != undefined) {
  186 + tElem.find("input").attr("required", "");
  187 + }
  188 +
  189 + return {
  190 + pre: function(scope, element, attr) {
  191 +
  192 + },
  193 +
  194 + /**
  195 + * 相当于link函数。
  196 + * @param scope
  197 + * @param element
  198 + * @param attr
  199 + */
  200 + post: function(scope, element, attr) {
  201 + //console.log("link");
  202 + //console.log("link:" + scope.model);
  203 + //scope["model"] = {selectedOption: null};
  204 +
  205 + if ($name_attr) {
  206 + scope[ctrlAs].nv = $name_attr;
  207 + }
  208 +
  209 + if ($disabled_attr) {
  210 + scope[ctrlAs].disabled = true;
  211 + }
  212 + if ($dicgroup_attr) {
  213 + var obj = dictionaryUtils.getByGroup($dicgroup_attr);
  214 + scope[ctrlAs].$$data = obj;
  215 + // 处理 scope["dic"] key值
  216 + scope[ctrlAs].dicvalueCalcu = function(value) {
  217 + if (value == "true") {
  218 + //console.log(value);
  219 + return true;
  220 + } else if (value == "false") {
  221 + //console.log(value);
  222 + return false;
  223 + } else {
  224 + return value;
  225 + }
  226 + };
  227 + }
  228 + }
  229 + };
  230 + }
  231 + };
  232 +}]);
  233 +
  234 +angular.module('ScheduleApp').directive("remoteValidaton", [
  235 + 'BusInfoManageService_g',
  236 + 'EmployeeInfoManageService_g',
  237 + 'TimeTableManageService_g',
  238 + function(
  239 + busInfoManageService_g,
  240 + employeeInfoManageService_g,
  241 + timeTableManageService_g
  242 + ) {
  243 + /**
  244 + * 远端验证指令,依赖于ngModel
  245 + * 指令名称 remote-Validation
  246 + * 需要属性 rvtype 表示验证类型
  247 + */
  248 + return {
  249 + restrict: "A",
  250 + require: "^ngModel",
  251 + link: function(scope, element, attr, ngModelCtrl) {
  252 + element.bind("keyup", function() {
  253 + var modelValue = ngModelCtrl.$modelValue;
  254 + var rv1_attr = attr["rv1"];
  255 + if (attr["rvtype"]) {
  256 +
  257 + // 根据rvtype的值,确定使用那个远端验证的url,
  258 + // rv1, rv2, rv3是关联比较值,暂时使用rv1
  259 + // 这个貌似没法通用,根据业务变换
  260 + // TODO:暂时有点乱以后改
  261 + if (attr["rvtype"] == "insideCode") {
  262 + busInfoManageService_g.validate.insideCode(
  263 + {"insideCode_eq": modelValue, type: "equale"},
  264 + function(result) {
  265 + //console.log(result);
  266 + if (result.status == "SUCCESS") {
  267 + ngModelCtrl.$setValidity('remote', true);
  268 + } else {
  269 + ngModelCtrl.$setValidity('remote', false);
  270 + }
  271 + },
  272 + function(result) {
  273 + //console.log(result);
  274 + ngModelCtrl.$setValidity('remote', true);
  275 + }
  276 + );
  277 + } else if (attr["rvtype"] == "jobCode") {
  278 + if (!rv1_attr) {
  279 + ngModelCtrl.$setValidity('remote', false);
  280 + return;
  281 + }
  282 +
  283 + employeeInfoManageService_g.validate.jobCode(
  284 + {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"},
  285 + function(result) {
  286 + //console.log(result);
  287 + if (result.status == "SUCCESS") {
  288 + ngModelCtrl.$setValidity('remote', true);
  289 + } else {
  290 + ngModelCtrl.$setValidity('remote', false);
  291 + }
  292 + },
  293 + function(result) {
  294 + //console.log(result);
  295 + ngModelCtrl.$setValidity('remote', true);
  296 + }
  297 + );
  298 + } else if (attr["rvtype"] == "ttinfoname") {
  299 + if (!rv1_attr) {
  300 + ngModelCtrl.$setValidity('remote', false);
  301 + return;
  302 + }
  303 +
  304 + timeTableManageService_g.validate.ttinfoname(
  305 + {"name_eq": modelValue, "xl.id_eq": rv1_attr, type: "equale"},
  306 + function(result) {
  307 + //console.log(result);
  308 + if (result.status == "SUCCESS") {
  309 + ngModelCtrl.$setValidity('remote', true);
  310 + } else {
  311 + ngModelCtrl.$setValidity('remote', false);
  312 + }
  313 + },
  314 + function(result) {
  315 + //console.log(result);
  316 + ngModelCtrl.$setValidity('remote', true);
  317 + }
  318 + );
  319 +
  320 + }
  321 + } else {
  322 + // 没有rvtype,就不用远端验证了
  323 + ngModelCtrl.$setValidity('remote', true);
  324 + }
  325 +
  326 + attr.$observe("rv1", function(value) {
  327 + if (attr["rvtype"] == "jobCode") {
  328 + if (!value) {
  329 + ngModelCtrl.$setValidity('remote', false);
  330 + return;
  331 + }
  332 +
  333 + employeeInfoManageService_g.validate.jobCode(
  334 + {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"},
  335 + function(result) {
  336 + //console.log(result);
  337 + if (result.status == "SUCCESS") {
  338 + ngModelCtrl.$setValidity('remote', true);
  339 + } else {
  340 + ngModelCtrl.$setValidity('remote', false);
  341 + }
  342 + },
  343 + function(result) {
  344 + //console.log(result);
  345 + ngModelCtrl.$setValidity('remote', true);
  346 + }
  347 + );
  348 + } else if (attr["rvtype"] == "ttinfoname") {
  349 + if (!value) {
  350 + ngModelCtrl.$setValidity('remote', false);
  351 + return;
  352 + }
  353 +
  354 + console.log("rv1:" + value);
  355 +
  356 + timeTableManageService_g.validate.ttinfoname(
  357 + {"name_eq": modelValue, "xl.id_eq": value, type: "equale"},
  358 + function(result) {
  359 + //console.log(result);
  360 + if (result.status == "SUCCESS") {
  361 + ngModelCtrl.$setValidity('remote', true);
  362 + } else {
  363 + ngModelCtrl.$setValidity('remote', false);
  364 + }
  365 + },
  366 + function(result) {
  367 + //console.log(result);
  368 + ngModelCtrl.$setValidity('remote', true);
  369 + }
  370 + );
  371 + }
  372 +
  373 + });
  374 + });
  375 + }
  376 + };
  377 + }]);
  378 +
  379 +
  380 +/**
  381 + * saSelect2指令,根据属性值,动态载入数据,然后支持拼音搜索,点击右边的按钮清除选择并重新载入数据。
  382 + * 1、compile阶段使用的属性如下:
  383 + * required:用于和表单验证连接,指定成required="true"才有效。
  384 + * 2、link阶段使用的属性如下
  385 + * model:关联的模型对象
  386 + * name:表单验证时需要的名字
  387 + * type:关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加
  388 + * modelcolname1:关联的模型字段名字1(一般应该是编码字段)
  389 + * modelcolname2:关联的模型字段名字2(一般应该是名字字段)
  390 + * datacolname1;内部数据对应的字段名字1(与模型字段1对应)
  391 + * datacolname2:内部数据对应的字段名字2(与模型字段2对应)
  392 + * showcolname:下拉框显示的内部数据字段名(注意:不是模型数据字段名),TODO:以后考虑放动态表达式,并在compile阶段使用
  393 + * placeholder:select placeholder字符串描述
  394 + *
  395 + * $$pyFilter,内部的filter指令,结合简拼音进行拼音过滤。
  396 + * $$SearchInfoService_g,内部使用的数据服务
  397 + */
  398 +// saSelect2指令使用的内部信service
  399 +angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', function($resource) {
  400 + return {
  401 + xl: $resource(
  402 + '/line/:type',
  403 + {order: 'name', direction: 'ASC'},
  404 + {
  405 + list: {
  406 + method: 'GET',
  407 + isArray: true
  408 + }
  409 + }
  410 + ),
  411 + zd: $resource(
  412 + '/stationroute/stations',
  413 + {order: 'stationCode', direction: 'ASC'},
  414 + {
  415 + list: {
  416 + method: 'GET',
  417 + isArray: true
  418 + }
  419 + }
  420 + ),
  421 + tcc: $resource(
  422 + '/carpark/:type',
  423 + {order: 'parkCode', direction: 'ASC'},
  424 + {
  425 + list: {
  426 + method: 'GET',
  427 + isArray: true
  428 + }
  429 + }
  430 + ),
  431 + ry: $resource(
  432 + '/personnel/:type',
  433 + {order: 'personnelName', direction: 'ASC'},
  434 + {
  435 + list: {
  436 + method: 'GET',
  437 + isArray: true
  438 + }
  439 + }
  440 + ),
  441 + cl: $resource(
  442 + '/cars/:type',
  443 + {order: "insideCode", direction: 'ASC'},
  444 + {
  445 + list: {
  446 + method: 'GET',
  447 + isArray: true
  448 + }
  449 + }
  450 + ),
  451 + ttInfo: $resource(
  452 + '/tic/:type',
  453 + {order: "name", direction: 'ASC'},
  454 + {
  455 + list: {
  456 + method: 'GET',
  457 + isArray: true
  458 + }
  459 + }
  460 + ),
  461 + cci: $resource(
  462 + '/cci/cars',
  463 + {},
  464 + {
  465 + list: {
  466 + method: 'GET',
  467 + isArray: true
  468 + }
  469 + }
  470 +
  471 + ),
  472 + cci2: $resource(
  473 + '/cci/:type',
  474 + {},
  475 + {
  476 + list: {
  477 + method: 'GET',
  478 + isArray: true
  479 + }
  480 + }
  481 + )
  482 + }
  483 +}]);
  484 +angular.module('ScheduleApp').filter("$$pyFilter", function() {
  485 + return function(items, props) {
  486 + var out = [];
  487 + var limit = props["limit"] || 20; // 默认20条记录
  488 +
  489 + if (angular.isArray(items)) {
  490 + items.forEach(function(item) {
  491 + if (out.length < limit) {
  492 + if (props.search) {
  493 + var upTerm = props.search.toUpperCase();
  494 + if(item.fullChars.indexOf(upTerm) != -1
  495 + || item.camelChars.indexOf(upTerm) != -1) {
  496 + out.push(item);
  497 + }
  498 + }
  499 + }
  500 + });
  501 + }
  502 +
  503 + return out;
  504 + };
  505 +});
  506 +angular.module('ScheduleApp').directive("saSelect2", [
  507 + '$timeout', '$$SearchInfoService_g',
  508 + function($timeout, $$searchInfoService_g) {
  509 + return {
  510 + restrict: 'E',
  511 + templateUrl: '/pages/scheduleApp/module/other/MySearchSelectTemplate.html',
  512 + scope: {
  513 + model: "=" // 独立作用域,关联外部的模型对象
  514 + },
  515 + controllerAs: "$saSelectCtrl",
  516 + bindToController: true,
  517 + controller: function($scope) {
  518 + var self = this;
  519 + self.$$data = []; // 内部关联的数据
  520 + },
  521 + /**
  522 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  523 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  524 + * @param tElem
  525 + * @param tAttrs
  526 + * @returns {{pre: Function, post: Function}}
  527 + */
  528 + compile: function(tElem, tAttrs) {
  529 + // 1、获取此阶段使用的属性
  530 + var $required_attr = tAttrs["required"]; // 用于和表单验证连接,指定成required="true"才有效。
  531 +
  532 + // 2、处理属性
  533 +
  534 + // 确定是否使用angularjs required验证
  535 + // 属性 required
  536 + // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加
  537 + if ($required_attr) {
  538 + if ($required_attr == "true") {
  539 + // 添加required属性指令
  540 + tElem.find("ui-select").attr("required", "");
  541 + } else {
  542 + // 不等于true,不添加required属性指令
  543 + }
  544 + } else {
  545 + // 不添加required属性指令
  546 + }
  547 +
  548 + //console.log("saSelect" + ":compile = >" + tElem.html());
  549 +
  550 + return {
  551 + pre: function(scope, element, attr) {
  552 + // TODO:
  553 + },
  554 + /**
  555 + * 相当于link函数。
  556 + *
  557 + * 重要属性如下:
  558 + * model 是绑定外部值。
  559 + * dicgroup 字典组的类型
  560 + * name input name属性值
  561 + */
  562 + post: function(scope, element, attr) {
  563 + // 1、获取此阶段使用的属性
  564 + var $name_attr = attr["name"]; // 表单验证时需要的名字
  565 + var $type_attr = attr["type"]; // 关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加
  566 + var $modelcolname1_attr = attr["modelcolname1"]; // 关联的模型字段名字1(一般应该是编码字段)
  567 + var $modelcolname2_attr = attr["modelcolname2"]; // 关联的模型字段名字2(一般应该是名字字段)
  568 + var $datacolname1_attr = attr["datacolname1"]; // 内部数据对应的字段名字1(与模型字段1对应)
  569 + var $datacolname2_attr = attr["datacolname2"]; // 内部数据对应的字段名字2(与模型字段2对应)
  570 + var $showcolname_attr = attr["showcolname"]; // 下拉框显示的内部数据字段名
  571 + var $placeholder_attr = attr["placeholder"]; // select placeholder字符串描述
  572 +
  573 + // 2、处理属性、转换成$saSelectCtrl内部使用的属性
  574 + if ($name_attr) {
  575 + scope["$saSelectCtrl"].$name_attr = $name_attr;
  576 + }
  577 + if ($placeholder_attr) {
  578 + scope["$saSelectCtrl"].$placeholder_attr = $placeholder_attr;
  579 + }
  580 + if ($showcolname_attr) {
  581 + scope["$saSelectCtrl"].$showcolname_attr = $showcolname_attr;
  582 + }
  583 +
  584 + // 2-1、添加内部方法,根据type值,改变$$data的值
  585 + scope["$saSelectCtrl"].$$internal_data_change_fn = function() {
  586 + // 根据type属性动态载入数据
  587 + if ($type_attr) {
  588 + $$searchInfoService_g[$type_attr].list(
  589 + {type: "all"},
  590 + function(result) {
  591 + scope["$saSelectCtrl"].$$data = [];
  592 + for (var i = 0; i < result.length; i ++) {
  593 + var data = {}; // data是result的一部分属性集合,根据配置来确定
  594 + if ($datacolname1_attr) {
  595 + data[$datacolname1_attr] = result[i][$datacolname1_attr];
  596 + }
  597 + if ($datacolname2_attr) {
  598 + data[$datacolname2_attr] = result[i][$datacolname2_attr];
  599 + }
  600 + if ($showcolname_attr) {
  601 + // 动态添加基于名字的拼音
  602 + data[$showcolname_attr] = result[i][$showcolname_attr];
  603 + if (data[$showcolname_attr]) {
  604 + data["fullChars"] = pinyin.getFullChars(result[i][$showcolname_attr]).toUpperCase(); // 全拼
  605 + data["camelChars"] = pinyin.getCamelChars(result[i][$showcolname_attr]); // 简拼
  606 + }
  607 + }
  608 + if (data["fullChars"])
  609 + scope["$saSelectCtrl"].$$data.push(data);
  610 + }
  611 + },
  612 + function(result) {
  613 +
  614 + }
  615 + );
  616 + }
  617 + };
  618 +
  619 + // 3、选择、删除事件映射模型和内部数据对应的字段
  620 + scope["$saSelectCtrl"].$select_fn_attr = function($item) {
  621 + if ($modelcolname1_attr && $datacolname1_attr) {
  622 + scope["$saSelectCtrl"].model[$modelcolname1_attr] = $item[$datacolname1_attr];
  623 + }
  624 + if ($modelcolname2_attr && $datacolname2_attr) {
  625 + scope["$saSelectCtrl"].model[$modelcolname2_attr] = $item[$datacolname2_attr];
  626 + }
  627 + };
  628 + scope["$saSelectCtrl"].$remove_fn_attr = function() {
  629 + if ($modelcolname1_attr) {
  630 + scope["$saSelectCtrl"].model[$modelcolname1_attr] = null;
  631 + }
  632 + if ($modelcolname2_attr) {
  633 + scope["$saSelectCtrl"].model[$modelcolname2_attr] = null;
  634 + }
  635 + scope["$saSelectCtrl"].$$cmodel = null; // 内部模型清空
  636 +
  637 + scope["$saSelectCtrl"].$$internal_data_change_fn();
  638 + };
  639 +
  640 + // 4、搜索事件
  641 + scope["$saSelectCtrl"].$refreshdata_fn_attr = function($search) {
  642 + //var fullChars = pinyin.getFullChars($search).toUpperCase();
  643 + //var camelChars = pinyin.getCamelChars($search);
  644 + //
  645 + //console.log(fullChars + " " + camelChars);
  646 + // TODO:事件暂时没用,放着以后再说
  647 + };
  648 +
  649 + // 5、全部载入后,输入的
  650 + $timeout(function() {
  651 + // 创建内部使用的绑定对象,用于确认选中那个值
  652 + scope["$saSelectCtrl"].$$cmodel = scope["$saSelectCtrl"].model[$modelcolname1_attr];
  653 +
  654 + scope["$saSelectCtrl"].$$internal_data_change_fn();
  655 + }, 0);
  656 + }
  657 + }
  658 + }
  659 + };
  660 + }
  661 +]);
  662 +
  663 +/**
  664 + * saSelect3指令
  665 + * 属性如下:
  666 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  667 + * name(必须):控件的名字
  668 + * placeholder(可选):占位符字符串
  669 + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}
  670 + * dcname(必须):绑定的model字段名,如:dcname=xl.id
  671 + * icname(必须):内部与之对应的字段名,如:icname=code
  672 + * dcname2(可选):其他需要赋值的model字段名2,如:dcname2=xl.name
  673 + * icname2(可选):内部与之对应的字段名2,如:icname2=name
  674 + * icnames(必须):用于用于显示,以及简评处理的内部数据字段,如:icnames=name
  675 + * required(可选):是否要用required验证
  676 + * datatype(必须):业务数据类型,有字典类型,动态数据类型,暂时写的死点
  677 + * mlp(可选):是否多级属性(这里假设外部model如果多级,内部model也是多级)
  678 + *
  679 + * 高级属性:
  680 + * dataassociate(可选):数据源是否关联属性(内部数据随外部指定的参数变化而变化)
  681 + * dataparam(可选):数据源关联的外部参数对象
  682 + *
  683 + */
  684 +angular.module('ScheduleApp').directive("saSelect3", [
  685 + '$timeout',
  686 + '$$SearchInfoService_g',
  687 + function($timeout, $$searchInfoService_g) {
  688 + return {
  689 + restrict: 'E',
  690 + templateUrl: '/pages/scheduleApp/module/common/dt/MyUiSelectWrapTemplate1.html',
  691 + scope: {
  692 + model: "=" // 独立作用域,关联外部的模型object
  693 + },
  694 + controllerAs: "$saSelectCtrl",
  695 + bindToController: true,
  696 + controller: function($scope) {
  697 + var self = this;
  698 + self.$$data = []; // ui-select显示用的数据源
  699 + self.$$data_real= []; // 内部真实的数据源
  700 + },
  701 +
  702 + /**
  703 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  704 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  705 + * @param tElem
  706 + * @param tAttrs
  707 + * @returns {{pre: Function, post: Function}}
  708 + */
  709 + compile: function(tElem, tAttrs) {
  710 + // 获取所有的属性
  711 + var $name_attr = tAttrs["name"]; // 控件的名字
  712 + var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字
  713 + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名
  714 + var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名
  715 + var $dcname2_attr = tAttrs["dcname2"]; // 其他需要赋值的model字段名2
  716 + var $icname2_attr = tAttrs["icname2"]; // 内部与之对应的字段名2
  717 + var $icname_s_attr = tAttrs["icnames"]; // 用于用于显示,以及简评处理的内部数据字段
  718 + var $datatype_attr = tAttrs["datatype"]; // 内部业务数据类型
  719 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  720 + var $mlp_attr = tAttrs["mlp"]; // 是否多级属性
  721 + var $dataassociate_attr = tAttrs["dataassociate"]; // 数据源是否关联属性
  722 +
  723 + // controlAs名字
  724 + var ctrlAs = "$saSelectCtrl";
  725 +
  726 + // 数据源初始化标志
  727 + var $$data_init = false;
  728 + // 如果有required属性,添加angularjs required验证
  729 + if ($required_attr != undefined) {
  730 + tElem.find("ui-select").attr("required", "");
  731 + }
  732 +
  733 + // 由于有的属性是多级的如xl.name,所以要在compile阶段重写属性绑定属性定义
  734 + // 原来的设置:{{$select.selected[$saSelectCtrl.$icname_s]}}
  735 + tElem.find("ui-select-match").html("{{$select.selected" + "." + $icname_s_attr + "}}");
  736 + // 原来的设置:item[$saSelectCtrl.$icname] as item in $saSelectCtrl.$$data
  737 + tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data");
  738 + // 原来的设置:item[$saSelectCtrl.$icname_s]
  739 + tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $icname_s_attr);
  740 + // 原来的设置:{{$saSelectCtrl.$name}}
  741 + tElem.find("ui-select").attr("name", $name_attr);
  742 + // 原来的设置:{{$saSelectCtrl.$placeholder}}
  743 + tElem.find("ui-select-match").attr("placeholder", $placeholder_attr);
  744 +
  745 + return {
  746 + pre: function(scope, element, attr) {
  747 + // TODO:
  748 + },
  749 + /**
  750 + * 相当于link函数。
  751 + * @param scope
  752 + * @param element
  753 + * @param attr
  754 + */
  755 + post: function(scope, element, attr) {
  756 + // 添加选中事件处理函数
  757 + scope[ctrlAs].$$internal_select_fn = function($item) {
  758 + if ($dcname_attr && $icname_attr) {
  759 + if ($mlp_attr) {
  760 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";");
  761 + } else {
  762 + scope[ctrlAs].model[$dcname_attr] = $item[$icname_attr];
  763 + }
  764 + }
  765 + if ($dcname2_attr && $icname2_attr) {
  766 + if ($mlp_attr) {
  767 + eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = $item" + "." + $icname2_attr + ";");
  768 + } else {
  769 + scope[ctrlAs].model[$dcname2_attr] = $item[$icname2_attr];
  770 + }
  771 + }
  772 + };
  773 +
  774 + // 删除选中事件处理函数
  775 + scope[ctrlAs].$$internal_remove_fn = function() {
  776 + scope[ctrlAs].$$internalmodel = undefined;
  777 + if ($mlp_attr) {
  778 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;");
  779 + } else {
  780 + scope[ctrlAs].model[$dcname_attr] = undefined;
  781 + }
  782 +
  783 + if ($dcname2_attr) {
  784 + if ($mlp_attr) {
  785 + eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = undefined;");
  786 + } else {
  787 + scope[ctrlAs].model[$dcname2_attr] = undefined;
  788 + }
  789 + }
  790 + };
  791 +
  792 + /**
  793 + * 内部方法,读取字典数据作为数据源。
  794 + * @param dicgroup 字典类型,如:gsType
  795 + * @param ccol 代码字段名
  796 + * @param ncol 名字字段名
  797 + */
  798 + scope[ctrlAs].$$internal_dic_data = function(dicgroup, ccol, ncol) {
  799 + var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup);
  800 + var dic_key; // 字典key
  801 + // 清空内部数据
  802 + scope[ctrlAs].$$data_real = [];
  803 + for (dic_key in origin_dicgroup) {
  804 + var data = {}; // 重新组合的字典元素对象
  805 + if (dic_key == "true")
  806 + data[ccol] = true;
  807 + else
  808 + data[ccol] = dic_key;
  809 + data[ncol] = origin_dicgroup[dic_key];
  810 + scope[ctrlAs].$$data_real.push(data);
  811 + }
  812 + // 这里直接将$$data_real数据深拷贝到$$data
  813 + angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data);
  814 +
  815 + console.log(scope[ctrlAs].$$data);
  816 + };
  817 +
  818 + /**
  819 + * TODO:这个方法有性能问题,result一多就会卡一卡,之后再解决把
  820 + * 内部方法,读取字典数据作为数据源。
  821 + * @param result 原始数据
  822 + * @param dcvalue 传入的关联数据
  823 + */
  824 + scope[ctrlAs].$$internal_other_data = function(result, dcvalue) {
  825 + //console.log("start");
  826 + // 清空内部数据
  827 + scope[ctrlAs].$$data_real = [];
  828 + scope[ctrlAs].$$data = [];
  829 + for (var i = 0; i < result.length; i ++) {
  830 + if ($icname_s_attr) {
  831 + if ($mlp_attr) {
  832 + if (eval("result[i]" + "." + $icname_s_attr)) {
  833 + // 全拼
  834 + result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $icname_s_attr)).toUpperCase();
  835 + // 简拼
  836 + result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $icname_s_attr));
  837 + }
  838 + } else {
  839 + if (result[i][$icname_s_attr]) {
  840 + // 全拼
  841 + result[i]["fullChars"] = pinyin.getFullChars(result[i][$icname_s_attr]).toUpperCase();
  842 + // 简拼
  843 + result[i]["camelChars"] = pinyin.getCamelChars(result[i][$icname_s_attr]);
  844 + }
  845 + }
  846 + }
  847 +
  848 + if (result[i]["fullChars"]) { // 有拼音的加入数据源
  849 + scope[ctrlAs].$$data_real.push(result[i]);
  850 + }
  851 +
  852 + }
  853 + //console.log("start2");
  854 +
  855 + // 数量太大取前10条记录作为显示
  856 + if (angular.isArray(scope[ctrlAs].$$data_real)) {
  857 + // 先迭代循环查找已经传过来的值
  858 + if (scope[ctrlAs].$$data_real.length > 0) {
  859 + if (dcvalue) {
  860 + for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) {
  861 + if (scope[ctrlAs].$$data_real[j][$icname_attr] == dcvalue) {
  862 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[j]));
  863 + break;
  864 + }
  865 + }
  866 + }
  867 + }
  868 + // 在插入剩余的数据
  869 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  870 + if (scope[ctrlAs].$$data.length < 10) {
  871 + if ($mlp_attr) {
  872 + if (eval("scope[ctrlAs].$$data_real[k]" + "." + $icname_attr + " != dcvalue")) {
  873 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  874 + }
  875 + } else {
  876 + if (scope[ctrlAs].$$data_real[k][$icname_attr] != dcvalue) {
  877 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  878 + }
  879 + }
  880 + } else {
  881 + break;
  882 + }
  883 + }
  884 + }
  885 +
  886 + //console.log("end");
  887 + };
  888 +
  889 + /**
  890 + * 判定一个对象是否为空对象。
  891 + * @param Obj
  892 + */
  893 + scope[ctrlAs].$$internal_isEmpty_obj = function(obj) {
  894 + console.log(typeof obj);
  895 +
  896 + if (typeof obj === "object" && !(obj instanceof Array)) {
  897 + for (var prop in obj) {
  898 + if (obj.hasOwnProperty(prop)) {
  899 + return false;
  900 + }
  901 + }
  902 + return true;
  903 + } else {
  904 + throw "必须是对象";
  905 + }
  906 + };
  907 +
  908 + // 刷新数据
  909 + scope[ctrlAs].$$internal_refresh_fn = function(search) {
  910 + // 绑定的model字段值,此属性是绑定属性,只能在link阶段获取
  911 + var $dcvalue_attr = attr["dcvalue"];
  912 +
  913 + console.log("刷新数据:" + $dcvalue_attr);
  914 +
  915 + if (!$$data_init) { // 只初始化$$data_real一次,重新载入页面才能重新初始化
  916 + if (dictionaryUtils.getByGroup($datatype_attr)) { // 判定是否字典类型数据源
  917 + scope[ctrlAs].$$internal_dic_data(
  918 + $datatype_attr, $icname_attr, $icname_s_attr);
  919 + if ($dcvalue_attr) {
  920 + scope[ctrlAs].$$internalmodel = $dcvalue_attr;
  921 + }
  922 + } else { // 非字典类型数据源
  923 + if (!$dataassociate_attr) {
  924 + $$searchInfoService_g[$datatype_attr].list(
  925 + {type: "all"},
  926 + function(result) {
  927 + //console.log("ok:" + $datatype_attr);
  928 + scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr);
  929 + //console.log("ok2:" + $datatype_attr);
  930 + if ($dcvalue_attr) {
  931 + scope[ctrlAs].$$internalmodel = $dcvalue_attr;
  932 + }
  933 +
  934 + $$data_init = true;
  935 + },
  936 + function(result) {
  937 +
  938 + }
  939 + );
  940 + }
  941 + }
  942 + }
  943 +
  944 + if ($$data_init) {
  945 + if (search && search != "") { // 有search值
  946 + if (!dictionaryUtils.getByGroup($datatype_attr)) { // 其他数据源
  947 + // 处理search
  948 + console.log("search:" + search);
  949 +
  950 + scope[ctrlAs].$$data = [];
  951 + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) {
  952 + var upTerm = search.toUpperCase();
  953 + if (scope[ctrlAs].$$data.length < 10) {
  954 + if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1
  955 + || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) {
  956 + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k]));
  957 + }
  958 + } else {
  959 + break;
  960 + }
  961 + }
  962 + }
  963 + }
  964 +
  965 + }
  966 +
  967 + };
  968 +
  969 +
  970 +
  971 +
  972 +
  973 +
  974 +
  975 +
  976 +
  977 +
  978 + // TODO:
  979 +
  980 + // dom全部载入后调用
  981 + $timeout(function() {
  982 + console.log("dom全部载入后调用");
  983 + }, 0);
  984 + // 监控dcvalue model值变换
  985 + attr.$observe("dcvalue", function(value) {
  986 + console.log("监控dc1 model值变换:" + value);
  987 + scope[ctrlAs].$$internalmodel = value;
  988 + }
  989 + );
  990 + // 监控获取数据参数变换
  991 + attr.$observe("dataparam", function(value) {
  992 + // 判定是否空对象
  993 + console.log(value);
  994 + var obj = JSON.parse(value);
  995 + var $dcvalue_attr = attr["dcvalue"];
  996 + if (!scope[ctrlAs].$$internal_isEmpty_obj(obj)) {
  997 + console.log("dataparam:" + obj);
  998 +
  999 + //
  1000 +
  1001 + obj["type"] = "all";
  1002 +
  1003 + $$data_init = false;
  1004 + $$searchInfoService_g[$datatype_attr].list(
  1005 + obj,
  1006 + function(result) {
  1007 + //console.log("ok:" + $datatype_attr);
  1008 + scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr);
  1009 + //console.log("ok2:" + $datatype_attr);
  1010 + if ($dcvalue_attr) {
  1011 + scope[ctrlAs].$$internalmodel = $dcvalue_attr;
  1012 + }
  1013 +
  1014 + $$data_init = true;
  1015 + },
  1016 + function(result) {
  1017 +
  1018 + }
  1019 + );
  1020 + }
  1021 + }
  1022 + );
  1023 + }
  1024 + };
  1025 + }
  1026 + };
  1027 +
  1028 + }
  1029 +]);
  1030 +
  1031 +/**
  1032 + * saCheckboxgroup指令
  1033 + * 属性如下:
  1034 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  1035 + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}
  1036 + * dcname(必须):绑定的model字段名,如:dcname=xl.id
  1037 + * name(必须):控件的名字
  1038 + * required(可选):是否要用required验证
  1039 + * disabled(可选):标示框是否可选
  1040 + *
  1041 + */
  1042 +angular.module('ScheduleApp').directive('saCheckboxgroup', [
  1043 + function() {
  1044 + return {
  1045 + restrict: 'E',
  1046 + templateUrl: '/pages/scheduleApp/module/common/dt/MyCheckboxGroupWrapTemplate.html',
  1047 + scope: {
  1048 + model: "=" // 独立作用域,关联外部的模型object
  1049 + },
  1050 + controllerAs: "$saCheckboxgroupCtrl",
  1051 + bindToController: true,
  1052 + controller: function($scope) {
  1053 + var self = this;
  1054 + self.$$data = []; // 内部的数据
  1055 +
  1056 + // TODO:数据写死,周一至周日选择数据,以后有别的数据再议
  1057 + self.$$data = [
  1058 + {name: "星期一", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  1059 + {name: "星期二", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  1060 + {name: "星期三", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  1061 + {name: "星期四", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  1062 + {name: "星期五", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  1063 + {name: "星期六", checkedvalue: "1", uncheckedvalue: "0", ischecked: false},
  1064 + {name: "星期日", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}
  1065 + ];
  1066 + },
  1067 +
  1068 + /**
  1069 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  1070 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  1071 + * @param tElem
  1072 + * @param tAttrs
  1073 + * @returns {{pre: Function, post: Function}}
  1074 + */
  1075 + compile: function(tElem, tAttrs) {
  1076 + // 获取所有的属性
  1077 + var $name_attr = tAttrs["name"]; // 控件的名字
  1078 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  1079 + var $disabled_attr = tAttrs["disabled"]; // 是否禁用
  1080 + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名
  1081 +
  1082 + // controlAs名字
  1083 + var ctrlAs = '$saCheckboxgroupCtrl';
  1084 +
  1085 + // 如果有required属性,添加angularjs required验证
  1086 + if ($required_attr != undefined) {
  1087 + //console.log(tElem.html());
  1088 + tElem.find("div").attr("required", "");
  1089 + }
  1090 + // 如果有disabled属性,添加禁用标志
  1091 + if ($disabled_attr != undefined) {
  1092 + tElem.find("input").attr("ng-disabled", "true");
  1093 + }
  1094 +
  1095 + return {
  1096 + pre: function(scope, element, attr) {
  1097 + // TODO:
  1098 + },
  1099 + /**
  1100 + * 相当于link函数。
  1101 + * @param scope
  1102 + * @param element
  1103 + * @param attr
  1104 + */
  1105 + post: function(scope, element, attr) {
  1106 + // name属性
  1107 + if ($name_attr) {
  1108 + scope[ctrlAs]["$name_attr"] = $name_attr;
  1109 + }
  1110 +
  1111 + /**
  1112 + * checkbox选择事件处理函数。
  1113 + * @param $d 数据对象,$$data中的元素对象
  1114 + */
  1115 + scope[ctrlAs].$$internal_updateCheck_fn = function($d) {
  1116 + $d.ischecked = !$d.ischecked;
  1117 + console.log($d);
  1118 + };
  1119 +
  1120 + // 测试使用watch监控$$data的变化
  1121 + scope.$watch(
  1122 + function() {
  1123 + return scope[ctrlAs]["$$data"];
  1124 + },
  1125 + function(newValue, oldValue) {
  1126 + // 根据$$data生成对应的数据
  1127 + var rule_days_arr = [];
  1128 + var i;
  1129 + for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {
  1130 + if (scope[ctrlAs]["$$data"][i].ischecked)
  1131 + rule_days_arr.push(scope[ctrlAs]["$$data"][i].checkedvalue);
  1132 + else
  1133 + rule_days_arr.push(scope[ctrlAs]["$$data"][i].uncheckedvalue);
  1134 + }
  1135 + scope[ctrlAs].$$internalmodel = rule_days_arr.join(",");
  1136 + //scope[ctrlAs].$$internalmodel = undefined;
  1137 + console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel);
  1138 +
  1139 + // 更新model
  1140 + if ($dcname_attr) {
  1141 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = rule_days_arr.join(',');");
  1142 + }
  1143 +
  1144 +
  1145 + },
  1146 + true
  1147 + );
  1148 +
  1149 + // TODO:
  1150 +
  1151 + // 监控dcvalue model值变换
  1152 + attr.$observe("dcvalue", function(value) {
  1153 + console.log("saCheckboxgroup 监控dc1 model值变换:" + value);
  1154 + if (value) {
  1155 + // 根据value值,修改$$data里的值
  1156 + var data_array = value.split(",");
  1157 + var i;
  1158 + if (data_array.length > scope[ctrlAs]["$$data"].length) {
  1159 + for (i = 0; i < scope[ctrlAs]["$$data"].length; i ++) {
  1160 + if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) {
  1161 + scope[ctrlAs]["$$data"][i].ischecked = true;
  1162 + } else {
  1163 + scope[ctrlAs]["$$data"][i].ischecked = false;
  1164 + }
  1165 + }
  1166 + } else {
  1167 + for (i = 0; i < data_array.length; i ++) {
  1168 + if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) {
  1169 + scope[ctrlAs]["$$data"][i].ischecked = true;
  1170 + } else {
  1171 + scope[ctrlAs]["$$data"][i].ischecked = false;
  1172 + }
  1173 + }
  1174 + }
  1175 +
  1176 + }
  1177 + });
  1178 + }
  1179 +
  1180 + };
  1181 +
  1182 +
  1183 + }
  1184 +
  1185 + };
  1186 + }
  1187 +]);
  1188 +
  1189 +/**
  1190 + * saDategroup指令
  1191 + * 属性如下:
  1192 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  1193 + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}}
  1194 + * dcname(必须):绑定的model字段名,如:dcname=xl.id
  1195 + * name(必须):控件的名字
  1196 + * required(可选):是否要用required验证
  1197 + * disabled(可选):标示框是否可选
  1198 + *
  1199 + */
  1200 +angular.module('ScheduleApp').directive('saDategroup', [
  1201 + '$filter',
  1202 + function($filter) {
  1203 + return {
  1204 + restrict: 'E',
  1205 + templateUrl: '/pages/scheduleApp/module/common/dt/MyDateGroupWrapTemplate.html',
  1206 + scope: {
  1207 + model: "=" // 独立作用域,关联外部的模型object
  1208 + },
  1209 + controllerAs: "$saDategroupCtrl",
  1210 + bindToController: true,
  1211 + controller: function($scope) {
  1212 + var self = this;
  1213 + self.$$data = []; // 内部的数据
  1214 + self.$$date_select; // 内部选中的日期
  1215 +
  1216 + //// 测试数据
  1217 + //self.$$data = [
  1218 + // {datestr: '2011-01-01', ischecked: true},
  1219 + // {datestr: '2011-01-01', ischecked: true},
  1220 + // {datestr: '2011-01-01', ischecked: true}
  1221 + //];
  1222 + },
  1223 +
  1224 + /**
  1225 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  1226 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  1227 + * @param tElem
  1228 + * @param tAttrs
  1229 + * @returns {{pre: Function, post: Function}}
  1230 + */
  1231 + compile: function(tElem, tAttrs) {
  1232 + // 获取所有的属性
  1233 + var $name_attr = tAttrs["name"]; // 控件的名字
  1234 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  1235 + var $disabled_attr = tAttrs["disabled"]; // 是否禁用
  1236 + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名
  1237 +
  1238 + // controlAs名字
  1239 + var ctrlAs = '$saDategroupCtrl';
  1240 +
  1241 + // 如果有required属性,添加angularjs required验证
  1242 + if ($required_attr != undefined) {
  1243 + //console.log(tElem.html());
  1244 + tElem.find("div").attr("required", "");
  1245 + }
  1246 + // 如果有disabled属性,添加禁用标志
  1247 + if ($disabled_attr != undefined) {
  1248 + tElem.find("input").attr("ng-disabled", "true");
  1249 + tElem.find("div").attr("ng-disabled", "true");
  1250 + }
  1251 +
  1252 + return {
  1253 + pre: function (scope, element, attr) {
  1254 + // TODO:
  1255 + },
  1256 + /**
  1257 + * 相当于link函数。
  1258 + * @param scope
  1259 + * @param element
  1260 + * @param attr
  1261 + */
  1262 + post: function (scope, element, attr) {
  1263 + // name属性
  1264 + if ($name_attr) {
  1265 + scope[ctrlAs]["$name_attr"] = $name_attr;
  1266 + }
  1267 +
  1268 +
  1269 + // 日期open属性,及方法
  1270 + scope[ctrlAs].$$specialDateOpen = false;
  1271 + scope[ctrlAs].$$specialDate_open = function() {
  1272 + scope[ctrlAs].$$specialDateOpen = true;
  1273 + };
  1274 +
  1275 + // 监控选择的日期
  1276 + scope.$watch(
  1277 + function() {
  1278 + return scope[ctrlAs]['$$date_select'];
  1279 + },
  1280 + function(newValue, oldValue) {
  1281 + if (newValue) {
  1282 + //console.log("saDategroup--->selectdate:" + newValue);
  1283 + // 调用内置filter,转换日期到yyyy-MM-dd格式
  1284 + var text = $filter('date')(newValue, 'yyyy-MM-dd');
  1285 + var i;
  1286 + var isexist = false; // 日期是否已经选择标识
  1287 + for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {
  1288 + if (scope[ctrlAs]["$$data"][i].datestr == text) {
  1289 + isexist = true;
  1290 + break;
  1291 + }
  1292 + }
  1293 + if (!isexist) {
  1294 + scope[ctrlAs]["$$data"].push(
  1295 + {
  1296 + datestr: text,
  1297 + ischecked: true
  1298 + }
  1299 + );
  1300 + }
  1301 +
  1302 + }
  1303 +
  1304 + }
  1305 + );
  1306 +
  1307 + /**
  1308 + * 日期点击事件处理函数。
  1309 + * @param $index 索引
  1310 + */
  1311 + scope[ctrlAs].$$internal_datestr_click = function($index) {
  1312 + scope[ctrlAs].$$data.splice($index, 1);
  1313 + };
  1314 +
  1315 + // 测试使用watch监控$$data的变化
  1316 + scope.$watch(
  1317 + function() {
  1318 + return scope[ctrlAs]['$$data'];
  1319 + },
  1320 + function(newValue, oldValue) {
  1321 + // 根据$$data生成对应的数据
  1322 + var special_days_arr = [];
  1323 + var i;
  1324 + for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) {
  1325 + special_days_arr.push(scope[ctrlAs]["$$data"][i].datestr);
  1326 + }
  1327 +
  1328 + scope[ctrlAs].$$internalmodel = special_days_arr.join(",");
  1329 + console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel);
  1330 +
  1331 + // 更新model
  1332 + if ($dcname_attr) {
  1333 + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = special_days_arr.join(',');");
  1334 + }
  1335 + },
  1336 + true
  1337 + );
  1338 +
  1339 + // 监控dcvalue model值变换
  1340 + attr.$observe("dcvalue", function(value) {
  1341 + console.log("saDategroup 监控dc1 model值变换:" + value);
  1342 + if (value) {
  1343 + // 根据value值,修改$$data里的值
  1344 + var date_array = value.split(",");
  1345 + var i;
  1346 + scope[ctrlAs]["$$data"] = [];
  1347 + for (i = 0; i < date_array.length; i++) {
  1348 + scope[ctrlAs]["$$data"].push(
  1349 + {
  1350 + datestr: date_array[i],
  1351 + ischecked: true
  1352 + }
  1353 + );
  1354 + }
  1355 +
  1356 +
  1357 +
  1358 +
  1359 +
  1360 +
  1361 +
  1362 +
  1363 +
  1364 + }
  1365 + });
  1366 +
  1367 + }
  1368 +
  1369 + };
  1370 + }
  1371 + }
  1372 + }
  1373 +]);
  1374 +
  1375 +/**
  1376 + * saGuideboardgroup指令
  1377 + * 属性如下:
  1378 + * name(必须):控件的名字
  1379 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  1380 + * xlidvalue(必须):绑定的model线路id值,如:xlidvalue={{ctrl.employeeInfoForSave.xl.id}}
  1381 + * lprangevalue(必须):绑定的model路牌名字范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}
  1382 + * lprangename(必须):绑定的model路牌名字范围字段名,如:lprangename=lprange
  1383 + * lpidrangevalue(必须):绑定的model路牌id范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}
  1384 + * lpidrangename(必须):绑定的model路牌id范围字段名,如:lprangename=lprange
  1385 + * lpstartvalue(必须):绑定的model起始路牌值,如:lpstartvalue={{ctrl.employeeInfoForSave.lpstart}}
  1386 + * lpstartname(必须):绑定的model起始路牌字段名,如:lpstartname=lpstart
  1387 + *
  1388 + * required(可选):是否要用required验证
  1389 + *
  1390 + */
  1391 +angular.module('ScheduleApp').directive('saGuideboardgroup', [
  1392 + 'GuideboardManageService_g',
  1393 + function(guideboardManageService_g) {
  1394 + return {
  1395 + restrict: 'E',
  1396 + templateUrl: '/pages/scheduleApp/module/common/dt/MyGuideboardGroupWrapTemplate.html',
  1397 + scope: {
  1398 + model: "=" // 独立作用域,关联外部的模型object
  1399 + },
  1400 + controllerAs: '$saGuideboardgroupCtrl',
  1401 + bindToController: true,
  1402 + controller: function($scope) {
  1403 + var self = this;
  1404 + self.$$data = []; // 选择线路后,该线路的路牌数据
  1405 +
  1406 + // 测试数据
  1407 + //self.$$data = [
  1408 + // {lpid: 1, lpname: '路1', isstart: false},
  1409 + // {lpid: 2, lpname: '路2', isstart: true},
  1410 + // {lpid: 3, lpname: '路3', isstart: false}
  1411 + //];
  1412 +
  1413 +
  1414 + self.$$dataSelected = []; // 选中的路牌列表
  1415 + self.$$dataSelectedStart = undefined; // 起始路牌
  1416 +
  1417 + //self.$$dataSelected = [
  1418 + // {lpid: 11, lpname: '路11', isstart: false},
  1419 + // {lpid: 12, lpname: '路12', isstart: true},
  1420 + // {lpid: 13, lpname: '路13', isstart: false}
  1421 + //];
  1422 +
  1423 + // saGuideboardgroup组件的ng-model,用于外部绑定等操作
  1424 + self.$$internalmodel = undefined;
  1425 +
  1426 + self.$$data_init = false; // *数据源初始化标志
  1427 + self.$$data_xl_first_init = false; // 线路是否初始化
  1428 + self.$$data_lp_first_init = false; // 路牌名字是否初始化
  1429 + self.$$data_lpid_first_init = false; // 路牌id是否初始化
  1430 + self.$$data_lpstart_first_init = false; // 起始路牌是否初始化
  1431 +
  1432 + self.$$dataDesc = ""; // 路牌列表描述
  1433 + self.$$dataSelectDesc = ""; // 选中路牌描述
  1434 +
  1435 + },
  1436 +
  1437 + /**
  1438 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  1439 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  1440 + * @param tElem
  1441 + * @param tAttrs
  1442 + * @returns {{pre: Function, post: Function}}
  1443 + */
  1444 + compile: function(tElem, tAttrs) {
  1445 + // TODO:获取所有的属性
  1446 + var $name_attr = tAttrs["name"]; // 控件的名字
  1447 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  1448 + var $lprangename_attr = tAttrs["lprangename"]; // 绑定的model路牌名字范围字段名
  1449 + var $lpidrangename_attr = tAttrs["lpidrangename"]; // 绑定的model路牌id范围字段名
  1450 + var $lpstartname_attr = tAttrs["lpstartname"]; // 绑定的model起始路牌字段名
  1451 +
  1452 + // controlAs名字
  1453 + var ctrlAs = '$saGuideboardgroupCtrl';
  1454 +
  1455 + // 如果有required属性,添加angularjs required验证
  1456 + if ($required_attr != undefined) {
  1457 + //console.log(tElem.html());
  1458 + tElem.find("div").attr("required", "");
  1459 + }
  1460 +
  1461 + return {
  1462 + pre: function(scope, element, attr) {
  1463 + // TODO:
  1464 + },
  1465 +
  1466 + /**
  1467 + * 相当于link函数。
  1468 + * @param scope
  1469 + * @param element
  1470 + * @param attr
  1471 + */
  1472 + post: function(scope, element, attr) {
  1473 + // name属性
  1474 + if ($name_attr) {
  1475 + scope[ctrlAs]["$name_attr"] = $name_attr;
  1476 + }
  1477 +
  1478 + // TODO:
  1479 +
  1480 +
  1481 + /**
  1482 + * 路牌列表点击(路牌列表中选中路牌)
  1483 + * @param $index
  1484 + */
  1485 + scope[ctrlAs].$$internal_lplist_click = function($index) {
  1486 + var data_temp = scope[ctrlAs].$$data;
  1487 + if (data_temp && data_temp.length > $index) {
  1488 + scope[ctrlAs].$$dataSelected.push({
  1489 + lpid: data_temp[$index].lpid,
  1490 + lpname: data_temp[$index].lpname,
  1491 + isstart: data_temp[$index].isstart
  1492 + });
  1493 +
  1494 + // 如果没有指定过初始路牌,默认选择此路牌作为起始路牌
  1495 + if (scope[ctrlAs].$$dataSelectedStart == undefined) {
  1496 + scope[ctrlAs].$$internal_sellplist_click(
  1497 + scope[ctrlAs].$$dataSelected.length - 1);
  1498 + }
  1499 + }
  1500 + };
  1501 + /**
  1502 + * 选中的路牌单击(初始路牌选择)
  1503 + * @param $index
  1504 + */
  1505 + scope[ctrlAs].$$internal_sellplist_click = function($index) {
  1506 + var data_temp = scope[ctrlAs].$$dataSelected;
  1507 + if (data_temp && data_temp.length > $index) {
  1508 + for (var i = 0; i < data_temp.length; i++) {
  1509 + data_temp[i].isstart = false;
  1510 + }
  1511 + data_temp[$index].isstart = true;
  1512 + scope[ctrlAs].$$dataSelectedStart = $index;
  1513 + }
  1514 + };
  1515 + /**
  1516 + * 选中的路牌双击(删除选中的路牌)
  1517 + * @param $index
  1518 + */
  1519 + scope[ctrlAs].$$internal_sellplist_dbclick = function($index) {
  1520 + var data_temp = scope[ctrlAs].$$dataSelected;
  1521 + if (data_temp && data_temp.length > $index) {
  1522 + if (scope[ctrlAs].$$dataSelectedStart == $index) {
  1523 + scope[ctrlAs].$$dataSelectedStart = undefined;
  1524 + }
  1525 + data_temp.splice($index, 1);
  1526 + }
  1527 + };
  1528 +
  1529 +
  1530 + /**
  1531 + * 验证内部数据,更新外部model
  1532 + */
  1533 + scope[ctrlAs].$$internal_validate_model = function() {
  1534 + var data_temp = scope[ctrlAs].$$dataSelected;
  1535 + var data_temp2 = scope[ctrlAs].$$dataSelectedStart;
  1536 + var lpNames = [];
  1537 + var lpIds = [];
  1538 + var lpStart = 0;
  1539 + var i = 0;
  1540 +
  1541 + if (data_temp &&
  1542 + data_temp.length > 0 &&
  1543 + data_temp2 != undefined) {
  1544 +
  1545 + for (i = 0; i < data_temp.length; i++) {
  1546 + lpNames.push(data_temp[i].lpname);
  1547 + lpIds.push(data_temp[i].lpid)
  1548 + }
  1549 + data_temp[data_temp2].isstart = true;
  1550 + lpStart = data_temp2 + 1;
  1551 +
  1552 + // 更新内部model,用于外部验证
  1553 + // 内部model的值暂时随意,以后再改
  1554 + scope[ctrlAs].$$internalmodel = {desc: "ok"};
  1555 +
  1556 + // 更新外部model字段
  1557 + if ($lprangename_attr) {
  1558 + console.log("lprangename=" + lpNames.join(','));
  1559 + eval("scope[ctrlAs].model" + "." + $lprangename_attr + " = lpNames.join(',');");
  1560 + }
  1561 + if ($lpidrangename_attr) {
  1562 + console.log("lpidrangename=" + lpIds.join(','));
  1563 + eval("scope[ctrlAs].model" + "." + $lpidrangename_attr + " = lpIds.join(',');");
  1564 + }
  1565 + if ($lpstartname_attr) {
  1566 + console.log("lpstartname=" + lpStart);
  1567 + eval("scope[ctrlAs].model" + "." + $lpstartname_attr + " = lpStart;");
  1568 + }
  1569 +
  1570 + scope[ctrlAs].$$dataSelectDesc =
  1571 + ",共" + data_temp.length + "个," + "初始路牌,第" + lpStart + "个";
  1572 +
  1573 + } else {
  1574 + scope[ctrlAs].$$internalmodel = undefined;
  1575 + }
  1576 +
  1577 +
  1578 + };
  1579 +
  1580 + // 监控内部数据,$$data_selected 变化
  1581 + scope.$watch(
  1582 + function() {
  1583 + return scope[ctrlAs].$$dataSelected;
  1584 + },
  1585 + function(newValue, oldValue) {
  1586 + scope[ctrlAs].$$internal_validate_model();
  1587 + },
  1588 + true
  1589 + );
  1590 +
  1591 + // 监控内部数据,$$data_selected_start 变化
  1592 + scope.$watch(
  1593 + function() {
  1594 + return scope[ctrlAs].$$dataSelectedStart;
  1595 + },
  1596 + function(newValue, oldValue) {
  1597 + scope[ctrlAs].$$internal_validate_model();
  1598 + },
  1599 + true
  1600 + );
  1601 +
  1602 + /**
  1603 + * 验证数据是否初始化完成,
  1604 + * 所谓的初始化就是内部所有的数据被有效设定过一次。
  1605 + */
  1606 + scope[ctrlAs].$$internal_validate_init = function() {
  1607 + var self = scope[ctrlAs];
  1608 +
  1609 + if (self.$$data_xl_first_init &&
  1610 + self.$$data_lp_first_init &&
  1611 + self.$$data_lpid_first_init &&
  1612 + self.$$data_lpstart_first_init) {
  1613 + console.log("数据初始化完毕!");
  1614 + self.$$data_init = true;
  1615 + }
  1616 +
  1617 + };
  1618 +
  1619 + // 监控初始化标志,线路,路牌,路牌id,起始路牌
  1620 + scope.$watch(
  1621 + function() {
  1622 + return scope[ctrlAs].$$data_xl_first_init;
  1623 + },
  1624 + function(newValue, oldValue) {
  1625 + scope[ctrlAs].$$internal_validate_init();
  1626 + }
  1627 + );
  1628 + scope.$watch(
  1629 + function() {
  1630 + return scope[ctrlAs].$$data_lp_first_init;
  1631 + },
  1632 + function(newValue, oldValue) {
  1633 + scope[ctrlAs].$$internal_validate_init();
  1634 + }
  1635 + );
  1636 + scope.$watch(
  1637 + function() {
  1638 + return scope[ctrlAs].$$data_lpid_first_init;
  1639 + },
  1640 + function(newValue, oldValue) {
  1641 + scope[ctrlAs].$$internal_validate_init();
  1642 + }
  1643 + );
  1644 + scope.$watch(
  1645 + function() {
  1646 + return scope[ctrlAs].$$data_lpstart_first_init;
  1647 + },
  1648 + function(newValue, oldValue) {
  1649 + scope[ctrlAs].$$internal_validate_init();
  1650 + }
  1651 + );
  1652 +
  1653 +
  1654 + // 监控线路id的变化
  1655 + attr.$observe("xlidvalue", function(value) {
  1656 + if (value && value != "") {
  1657 + console.log("xlidvalue=" + value);
  1658 +
  1659 + guideboardManageService_g.rest.list(
  1660 + {"xl.id_eq": value, size: 100},
  1661 + function(result) {
  1662 + // 获取值了
  1663 + console.log("路牌获取了");
  1664 +
  1665 + scope[ctrlAs].$$data = [];
  1666 + for (var i = 0; i < result.content.length; i++) {
  1667 + scope[ctrlAs].$$data.push({
  1668 + lpid: result.content[i].id,
  1669 + lpname: result.content[i].lpName,
  1670 + isstart: false
  1671 + });
  1672 + }
  1673 + if (scope[ctrlAs].$$data_init) {
  1674 + scope[ctrlAs].$$dataSelected = [];
  1675 + scope[ctrlAs].$$dataSelectedStart = undefined;
  1676 + scope[ctrlAs].$$internalmodel = undefined;
  1677 + scope[ctrlAs].$$dataDesc = "";
  1678 + scope[ctrlAs].$$dataSelectDesc = "";
  1679 + }
  1680 + scope[ctrlAs].$$data_xl_first_init = true;
  1681 +
  1682 + scope[ctrlAs].$$dataDesc = ",共" + result.content.length + "个";
  1683 + },
  1684 + function(result) {
  1685 +
  1686 + }
  1687 + );
  1688 +
  1689 + }
  1690 + });
  1691 +
  1692 + // 监控路牌名称范围值的变化
  1693 + attr.$observe("lprangevalue", function(value) {
  1694 + if (value && value != "") {
  1695 + var data_temp = scope[ctrlAs].$$dataSelected;
  1696 + var lpnames = value.split(",");
  1697 + var i = 0;
  1698 + if (data_temp && data_temp.length == 0) { // 初始创建
  1699 + console.log("lprangevalue变换了");
  1700 + for (i = 0; i < lpnames.length; i++) {
  1701 + scope[ctrlAs].$$dataSelected.push({
  1702 + lpname: lpnames[i],
  1703 + isstart: false
  1704 + });
  1705 + }
  1706 + } else {
  1707 + for (i = 0; i < lpnames.length; i++) {
  1708 + data_temp[i].lpname = lpnames[i];
  1709 + }
  1710 + }
  1711 + scope[ctrlAs].$$data_lp_first_init = true;
  1712 + }
  1713 + });
  1714 +
  1715 + // 监控路牌id范围值的变化
  1716 + attr.$observe("lpidrangevalue", function(value) {
  1717 + if (value && value != "") {
  1718 + console.log("lpidrangevalue=" + value);
  1719 + var data_temp = scope[ctrlAs].$$dataSelected;
  1720 + var lpids = value.split(",");
  1721 + var i = 0;
  1722 + if (data_temp && data_temp.length == 0) { // 初始创建
  1723 + console.log("lpidrangevalue");
  1724 + for (i = 0; i < lpids.length; i++) {
  1725 + scope[ctrlAs].$$dataSelected.push({
  1726 + lpid: lpids[i],
  1727 + isstart: false
  1728 + });
  1729 + }
  1730 + } else {
  1731 + for (i = 0; i < lpids.length; i++) {
  1732 + data_temp[i].lpid = lpids[i];
  1733 + }
  1734 + }
  1735 + scope[ctrlAs].$$data_lpid_first_init = true;
  1736 + }
  1737 + });
  1738 +
  1739 + // 监控起始路牌的变化
  1740 + attr.$observe("lpstartvalue", function(value) {
  1741 + if (value && value != "") {
  1742 + scope[ctrlAs].$$dataSelectedStart = value - 1;
  1743 + scope[ctrlAs].$$data_lpstart_first_init = true;
  1744 + }
  1745 + });
  1746 +
  1747 +
  1748 +
  1749 + }
  1750 + }
  1751 +
  1752 + }
  1753 + }
  1754 + }
  1755 +]);
  1756 +
  1757 +/**
  1758 + * saEmployeegroup指令
  1759 + * 属性如下:
  1760 + * name(必须):控件的名字
  1761 + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave
  1762 + * xlidvalue(必须):绑定的model线路id值,如:xlidvalue={{ctrl.employeeInfoForSave.xl.id}}
  1763 + * dbbmrangevalue(必须):绑定的model搭班编码范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}
  1764 + * dbbmrangename(必须):绑定的model搭班编码范围字段名,如:lprangename=lprange
  1765 + * rycidrangevalue(必须):绑定的model人员配置idid范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}}
  1766 + * rycidrangename(必须):绑定的model人员配置id范围字段名,如:lprangename=lprange
  1767 + * rystartvalue(必须):绑定的model起始人员,如:lpstartvalue={{ctrl.employeeInfoForSave.lpstart}}
  1768 + * rystartname(必须):绑定的model起始人员字段名,如:lpstartname=lpstart
  1769 + *
  1770 + * required(可选):是否要用required验证
  1771 + *
  1772 + */
  1773 +angular.module('ScheduleApp').directive('saEmployeegroup', [
  1774 + 'EmployeeConfigService_g',
  1775 + function(employeeConfigService_g) {
  1776 + return {
  1777 + restrict: 'E',
  1778 + templateUrl: '/pages/scheduleApp/module/common/dt/MyEmployeeGroupWrapTemplate.html',
  1779 + scope: {
  1780 + model: "=" // 独立作用域,关联外部的模型object
  1781 + },
  1782 + controllerAs: '$saEmployeegroupCtrl',
  1783 + bindToController: true,
  1784 + controller: function($scope) {
  1785 + var self = this;
  1786 + self.$$data = []; // 选择线路后,该线路的人员配置数据
  1787 +
  1788 + // 测试数据
  1789 + //self.$$data = [
  1790 + // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isstart: false},
  1791 + // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true},
  1792 + // {id: 3, dbbm: "3", jsy: '忍3', spy: '守3', isstart: false}
  1793 + //];
  1794 +
  1795 +
  1796 + self.$$dataSelected = []; // 选中的人员配置列表
  1797 + self.$$dataSelectedStart = undefined; // 起始人员配置
  1798 +
  1799 + // saGuideboardgroup组件的ng-model,用于外部绑定等操作
  1800 + self.$$internalmodel = undefined;
  1801 +
  1802 + self.$$data_init = false; // *数据源初始化标志
  1803 + self.$$data_xl_first_init = false; // 线路是否初始化
  1804 + self.$$data_ry_first_init = false; // 人员配置是否初始化
  1805 + self.$$data_rycid_first_init = false; // 人员配置id是否初始化
  1806 + self.$$data_rystart_first_init = false; // 起始人员是否初始化
  1807 +
  1808 + self.$$dataDesc = ""; // 路牌列表描述
  1809 + self.$$dataSelectDesc = ""; // 选中路牌描述
  1810 +
  1811 + },
  1812 +
  1813 + /**
  1814 + * 此阶段可以改dom结构,此时angular还没扫描指令,
  1815 + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。
  1816 + * @param tElem
  1817 + * @param tAttrs
  1818 + * @returns {{pre: Function, post: Function}}
  1819 + */
  1820 + compile: function(tElem, tAttrs) {
  1821 + // TODO:获取所有的属性
  1822 + var $name_attr = tAttrs["name"]; // 控件的名字
  1823 + var $required_attr = tAttrs["required"]; // 是否需要required验证
  1824 + var $dbbmrangename_attr = tAttrs["dbbmrangename"]; // 绑定的model搭班编码范围字段名
  1825 + var rycidrangename_attr = tAttrs["rycidrangename"]; // 绑定的model人员配置id范围字段名
  1826 + var $rystartname_attr = tAttrs["rystartname"]; // 绑定的model起始人员字段名
  1827 +
  1828 + // controlAs名字
  1829 + var ctrlAs = '$saEmployeegroupCtrl';
  1830 +
  1831 + // 如果有required属性,添加angularjs required验证
  1832 + if ($required_attr != undefined) {
  1833 + //console.log(tElem.html());
  1834 + tElem.find("div").attr("required", "");
  1835 + }
  1836 +
  1837 + return {
  1838 + pre: function(scope, element, attr) {
  1839 + // TODO:
  1840 + },
  1841 +
  1842 + /**
  1843 + * 相当于link函数。
  1844 + * @param scope
  1845 + * @param element
  1846 + * @param attr
  1847 + */
  1848 + post: function(scope, element, attr) {
  1849 + // name属性
  1850 + if ($name_attr) {
  1851 + scope[ctrlAs]["$name_attr"] = $name_attr;
  1852 + }
  1853 +
  1854 + // TODO:
  1855 +
  1856 +
  1857 + /**
  1858 + * 人员配置列表点击(人员配置列表中选中路牌)
  1859 + * @param $index
  1860 + */
  1861 + scope[ctrlAs].$$internal_rylist_click = function($index) {
  1862 + var data_temp = scope[ctrlAs].$$data;
  1863 + if (data_temp && data_temp.length > $index) {
  1864 + scope[ctrlAs].$$dataSelected.push({
  1865 + id : data_temp[$index].id,
  1866 + dbbm: data_temp[$index].dbbm,
  1867 + jsy: data_temp[$index].jsy,
  1868 + spy: data_temp[$index].spy,
  1869 + isstart: data_temp[$index].isstart
  1870 + });
  1871 +
  1872 + // 如果没有指定过初始人员,默认选择此人员作为起始人员
  1873 + if (scope[ctrlAs].$$dataSelectedStart == undefined) {
  1874 + scope[ctrlAs].$$internal_selrylist_click(
  1875 + scope[ctrlAs].$$dataSelected.length - 1);
  1876 + }
  1877 + }
  1878 + };
  1879 + /**
  1880 + * 选中的人员单击(初始人员选择)
  1881 + * @param $index
  1882 + */
  1883 + scope[ctrlAs].$$internal_selrylist_click = function($index) {
  1884 + var data_temp = scope[ctrlAs].$$dataSelected;
  1885 + if (data_temp && data_temp.length > $index) {
  1886 + for (var i = 0; i < data_temp.length; i++) {
  1887 + data_temp[i].isstart = false;
  1888 + }
  1889 + data_temp[$index].isstart = true;
  1890 + scope[ctrlAs].$$dataSelectedStart = $index;
  1891 + }
  1892 + };
  1893 + /**
  1894 + * 选中的人员双击(删除选中的人员)
  1895 + * @param $index
  1896 + */
  1897 + scope[ctrlAs].$$internal_selrylist_dbclick = function($index) {
  1898 + var data_temp = scope[ctrlAs].$$dataSelected;
  1899 + if (data_temp && data_temp.length > $index) {
  1900 + if (scope[ctrlAs].$$dataSelectedStart == $index) {
  1901 + scope[ctrlAs].$$dataSelectedStart = undefined;
  1902 + }
  1903 + data_temp.splice($index, 1);
  1904 + }
  1905 + };
  1906 +
  1907 +
  1908 + /**
  1909 + * 验证内部数据,更新外部model
  1910 + */
  1911 + scope[ctrlAs].$$internal_validate_model = function() {
  1912 + var data_temp = scope[ctrlAs].$$dataSelected;
  1913 + var data_temp2 = scope[ctrlAs].$$dataSelectedStart;
  1914 + var ryDbbms = [];
  1915 + var ryCids = [];
  1916 + var ryStart = 0;
  1917 + var i = 0;
  1918 +
  1919 + if (data_temp &&
  1920 + data_temp.length > 0 &&
  1921 + data_temp2 != undefined) {
  1922 +
  1923 + for (i = 0; i < data_temp.length; i++) {
  1924 + ryDbbms.push(data_temp[i].dbbm);
  1925 + ryCids.push(data_temp[i].id);
  1926 + }
  1927 + data_temp[data_temp2].isstart = true;
  1928 + ryStart = data_temp2 + 1;
  1929 +
  1930 + // 更新内部model,用于外部验证
  1931 + // 内部model的值暂时随意,以后再改
  1932 + scope[ctrlAs].$$internalmodel = {desc: "ok"};
  1933 +
  1934 + // 更新外部model字段
  1935 + if ($dbbmrangename_attr) {
  1936 + console.log("dbbmrangename=" + ryDbbms.join(','));
  1937 + eval("scope[ctrlAs].model" + "." + $dbbmrangename_attr + " = ryDbbms.join(',');");
  1938 + }
  1939 + if (rycidrangename_attr) {
  1940 + console.log("rycidrangename=" + ryCids.join(','));
  1941 + eval("scope[ctrlAs].model" + "." + rycidrangename_attr + " = ryCids.join(',');");
  1942 + }
  1943 + if ($rystartname_attr) {
  1944 + console.log("rystartname=" + ryStart);
  1945 + eval("scope[ctrlAs].model" + "." + $rystartname_attr + " = ryStart;");
  1946 + }
  1947 +
  1948 + scope[ctrlAs].$$dataSelectDesc =
  1949 + ",共" + data_temp.length + "组," + "初始人员,第" + ryStart + "组";
  1950 +
  1951 + } else {
  1952 + scope[ctrlAs].$$internalmodel = undefined;
  1953 + }
  1954 +
  1955 +
  1956 + };
  1957 +
  1958 + // 监控内部数据,$$data_selected 变化
  1959 + scope.$watch(
  1960 + function() {
  1961 + return scope[ctrlAs].$$dataSelected;
  1962 + },
  1963 + function(newValue, oldValue) {
  1964 + scope[ctrlAs].$$internal_validate_model();
  1965 + },
  1966 + true
  1967 + );
  1968 +
  1969 + // 监控内部数据,$$data_selected_start 变化
  1970 + scope.$watch(
  1971 + function() {
  1972 + return scope[ctrlAs].$$dataSelectedStart;
  1973 + },
  1974 + function(newValue, oldValue) {
  1975 + scope[ctrlAs].$$internal_validate_model();
  1976 + },
  1977 + true
  1978 + );
  1979 +
  1980 + /**
  1981 + * 验证数据是否初始化完成,
  1982 + * 所谓的初始化就是内部所有的数据被有效设定过一次。
  1983 + */
  1984 + scope[ctrlAs].$$internal_validate_init = function() {
  1985 + var self = scope[ctrlAs];
  1986 + var data_temp = self.$$data;
  1987 + var dataSelect_temp = self.$$dataSelected;
  1988 + var i = 0;
  1989 + var j = 0;
  1990 +
  1991 + if (self.$$data_xl_first_init &&
  1992 + self.$$data_ry_first_init &&
  1993 + self.$$data_rycid_first_init &&
  1994 + self.$$data_rystart_first_init) {
  1995 + console.log("数据初始化完毕!");
  1996 + self.$$data_init = true;
  1997 +
  1998 + // 修正选择dataSelect
  1999 + for (i = 0; i < dataSelect_temp.length; i++) {
  2000 + for (j = 0; j < data_temp.length; j++) {
  2001 + if (dataSelect_temp[i].dbbm == data_temp[j].dbbm) {
  2002 + dataSelect_temp[i].jsy = data_temp[j].jsy;
  2003 + dataSelect_temp[i].spy = data_temp[j].spy;
  2004 + break;
  2005 + }
  2006 + }
  2007 + }
  2008 + }
  2009 +
  2010 + };
  2011 +
  2012 + // 监控初始化标志,线路,人员,起始人员
  2013 + scope.$watch(
  2014 + function() {
  2015 + return scope[ctrlAs].$$data_xl_first_init;
  2016 + },
  2017 + function(newValue, oldValue) {
  2018 + scope[ctrlAs].$$internal_validate_init();
  2019 + }
  2020 + );
  2021 + scope.$watch(
  2022 + function() {
  2023 + return scope[ctrlAs].$$data_ry_first_init;
  2024 + },
  2025 + function(newValue, oldValue) {
  2026 + scope[ctrlAs].$$internal_validate_init();
  2027 + }
  2028 + );
  2029 + scope.$watch(
  2030 + function() {
  2031 + return scope[ctrlAs].$$data_rycid_first_init;
  2032 + },
  2033 + function(newValue, oldValue) {
  2034 + scope[ctrlAs].$$internal_validate_init();
  2035 + }
  2036 + );
  2037 + scope.$watch(
  2038 + function() {
  2039 + return scope[ctrlAs].$$data_rystart_first_init;
  2040 + },
  2041 + function(newValue, oldValue) {
  2042 + scope[ctrlAs].$$internal_validate_init();
  2043 + }
  2044 + );
  2045 +
  2046 +
  2047 + // 监控线路id的变化
  2048 + attr.$observe("xlidvalue", function(value) {
  2049 + if (value && value != "") {
  2050 + console.log("xlidvalue=" + value);
  2051 +
  2052 + employeeConfigService_g.rest.list(
  2053 + {"xl.id_eq": value, size: 100},
  2054 + function(result) {
  2055 + // 获取值了
  2056 + console.log("人员配置获取了");
  2057 +
  2058 + scope[ctrlAs].$$data = [];
  2059 + for (var i = 0; i < result.content.length; i++) {
  2060 + scope[ctrlAs].$$data.push({
  2061 + id: result.content[i].id,
  2062 + dbbm: result.content[i].dbbm,
  2063 + jsy: result.content[i].jsy.personnelName,
  2064 + spy: result.content[i].spy == null ? "" : result.content[i].spy.personnelName,
  2065 + isstart: false
  2066 + });
  2067 + }
  2068 + if (scope[ctrlAs].$$data_init) {
  2069 + scope[ctrlAs].$$dataSelected = [];
  2070 + scope[ctrlAs].$$dataSelectedStart = undefined;
  2071 + scope[ctrlAs].$$internalmodel = undefined;
  2072 + scope[ctrlAs].$$dataDesc = "";
  2073 + scope[ctrlAs].$$dataSelectDesc = "";
  2074 + }
  2075 + scope[ctrlAs].$$data_xl_first_init = true;
  2076 +
  2077 + scope[ctrlAs].$$dataDesc = ",共" + result.content.length + "组";
  2078 + },
  2079 + function(result) {
  2080 +
  2081 + }
  2082 + );
  2083 +
  2084 + }
  2085 + });
  2086 +
  2087 + // 监控搭班编码范围值的变化
  2088 + attr.$observe("dbbmrangevalue", function(value) {
  2089 + if (value && value != "") {
  2090 + var data_temp = scope[ctrlAs].$$dataSelected;
  2091 + var dbbmnames = value.split(",");
  2092 + var i = 0;
  2093 + if (data_temp && data_temp.length == 0) { // 初始创建
  2094 + console.log("dbbmrangevalue变换了");
  2095 + for (i = 0; i < dbbmnames.length; i++) {
  2096 + scope[ctrlAs].$$dataSelected.push({
  2097 + dbbm: dbbmnames[i],
  2098 + isstart: false
  2099 + });
  2100 + }
  2101 + } else {
  2102 + for (i = 0; i < dbbmnames.length; i++) {
  2103 + data_temp[i].dbbm = dbbmnames[i];
  2104 + }
  2105 + }
  2106 + scope[ctrlAs].$$data_ry_first_init = true;
  2107 + }
  2108 + });
  2109 +
  2110 + // 监控人员配置id范围值的变化
  2111 + attr.$observe("rycidrangevalue", function(value) {
  2112 + if (value && value != "") {
  2113 + var data_temp = scope[ctrlAs].$$dataSelected;
  2114 + var rycids = value.split(",");
  2115 + var i = 0;
  2116 + if (data_temp && data_temp.length == 0) { // 初始创建
  2117 + console.log("rycidrangevalue变换了");
  2118 + for (i = 0; i < rycids.length; i++) {
  2119 + scope[ctrlAs].$$dataSelected.push({
  2120 + id: rycids[i],
  2121 + isstart: false
  2122 + });
  2123 + }
  2124 + } else {
  2125 + for (i = 0; i < rycids.length; i++) {
  2126 + data_temp[i].id = rycids[i];
  2127 + }
  2128 + }
  2129 + scope[ctrlAs].$$data_rycid_first_init = true;
  2130 + }
  2131 + });
  2132 +
  2133 + // 监控起始人员的变化
  2134 + attr.$observe("rystartvalue", function(value) {
  2135 + if (value && value != "") {
  2136 + scope[ctrlAs].$$dataSelectedStart = value - 1;
  2137 + scope[ctrlAs].$$data_rystart_first_init = true;
  2138 + }
  2139 + });
  2140 +
  2141 +
  2142 +
  2143 + }
  2144 + }
  2145 +
  2146 + }
  2147 + }
  2148 + }
  2149 +]);
  2150 +
src/main/resources/static/pages/scheduleApp/module/core/scheduleRuleManage/edit.html
@@ -107,59 +107,53 @@ @@ -107,59 +107,53 @@
107 107
108 <div class="form-group has-success has-feedback"> 108 <div class="form-group has-success has-feedback">
109 <label class="col-md-2 control-label">路牌范围*:</label> 109 <label class="col-md-2 control-label">路牌范围*:</label>
110 - <div class="col-md-4">  
111 - <input type="text" class="form-control" name="lpNames" ng-model="ctrl.scheduleRuleManageForSave.lpNames" required  
112 - placeholder="由路牌名称组成,逗号分隔"/>  
113 - </div>  
114 - <!-- 隐藏块,显示验证信息 -->  
115 - <div class="alert alert-danger well-sm" ng-show="myForm.lpNames.$error.required">  
116 - 路牌范围必须填写  
117 - </div>  
118 - </div>  
119 -  
120 - <div class="form-group has-success has-feedback">  
121 - <label class="col-md-2 control-label">起始路牌*:</label>  
122 - <div class="col-md-4">  
123 - <input type="text" class="form-control" name="lpStart" ng-model="ctrl.scheduleRuleManageForSave.lpStart" required  
124 - placeholder="起始路牌索引,从1开始"/>  
125 - </div>  
126 - <!-- 隐藏块,显示验证信息 -->  
127 - <div class="alert alert-danger well-sm" ng-show="myForm.lpStart.$error.required">  
128 - 起始路牌必须填写 110 + <div class="col-md-6">
  111 + <sa-Guideboardgroup model="ctrl.scheduleRuleManageForSave"
  112 + name="lprange"
  113 + xlidvalue="{{ctrl.scheduleRuleManageForSave.xl.id}}"
  114 + lprangevalue="{{ctrl.scheduleRuleManageForSave.lpNames}}"
  115 + lprangename="lpNames"
  116 + lpidrangevalue="{{ctrl.scheduleRuleManageForSave.lpIds}}"
  117 + lpidrangename="lpIds"
  118 + lpstartvalue="{{ctrl.scheduleRuleManageForSave.lpStart}}"
  119 + lpstartname="lpStart"
  120 + required
  121 + >
  122 + </sa-Guideboardgroup>
  123 + </div>
  124 + <div class="alert alert-danger well-sm" ng-show="myForm.lprange.$error.required">
  125 + 路牌范围,起始路牌必须选择
129 </div> 126 </div>
130 </div> 127 </div>
131 128
132 <div class="form-group has-success has-feedback"> 129 <div class="form-group has-success has-feedback">
133 <label class="col-md-2 control-label">人员范围*:</label> 130 <label class="col-md-2 control-label">人员范围*:</label>
134 - <div class="col-md-4">  
135 - <input type="text" class="form-control" name="ryDbbms" ng-model="ctrl.scheduleRuleManageForSave.ryDbbms" required  
136 - placeholder="由人员配置的搭班编码组成,逗号分隔"/>  
137 - </div>  
138 - <!-- 隐藏块,显示验证信息 -->  
139 - <div class="alert alert-danger well-sm" ng-show="myForm.ryDbbms.$error.required">  
140 - 人员范围必须填写 131 + <div class="col-md-6">
  132 + <sa-Employeegroup model="ctrl.scheduleRuleManageForSave"
  133 + name="ryrange"
  134 + xlidvalue="{{ctrl.scheduleRuleManageForSave.xl.id}}"
  135 + dbbmrangevalue="{{ctrl.scheduleRuleManageForSave.ryDbbms}}"
  136 + dbbmrangename="ryDbbms"
  137 + rycidrangevalue="{{ctrl.scheduleRuleManageForSave.ryConfigIds}}"
  138 + rycidrangename="ryConfigIds"
  139 + rystartvalue="{{ctrl.scheduleRuleManageForSave.ryStart}}"
  140 + rystartname="ryStart"
  141 + required
  142 + >
  143 + </sa-Employeegroup>
  144 + </div>
  145 + <div class="alert alert-danger well-sm" ng-show="myForm.ryrange.$error.required">
  146 + 人员范围,起始人员必须选择
141 </div> 147 </div>
142 </div> 148 </div>
143 149
144 - <div class="form-group has-success has-feedback">  
145 - <label class="col-md-2 control-label">起始人员*:</label>  
146 - <div class="col-md-4">  
147 - <input type="text" class="form-control" name="ryStart" ng-model="ctrl.scheduleRuleManageForSave.ryStart" required  
148 - placeholder="起始人员索引,从1开始"/>  
149 - </div>  
150 - <!-- 隐藏块,显示验证信息 -->  
151 - <div class="alert alert-danger well-sm" ng-show="myForm.ryStart.$error.required">  
152 - 起始路牌必须填写  
153 - </div>  
154 - </div>  
155 -  
156 - <div class="form-group">  
157 - <label class="col-md-2 control-label">翻班格式:</label>  
158 - <div class="col-md-4">  
159 - <input type="text" class="form-control" name="fbgs" ng-model="ctrl.scheduleRuleManageForSave.fbgs"  
160 - placeholder="车辆翻班格式"/>  
161 - </div>  
162 - </div> 150 + <!--<div class="form-group">-->
  151 + <!--<label class="col-md-2 control-label">翻班格式:</label>-->
  152 + <!--<div class="col-md-4">-->
  153 + <!--<input type="text" class="form-control" name="fbgs" ng-model="ctrl.scheduleRuleManageForSave.fbgs"-->
  154 + <!--placeholder="车辆翻班格式"/>-->
  155 + <!--</div>-->
  156 + <!--</div>-->
163 157
164 158
165 <!-- 其他form-group --> 159 <!-- 其他form-group -->
@@ -181,5 +175,4 @@ @@ -181,5 +175,4 @@
181 175
182 </div> 176 </div>
183 177
184 -  
185 </div> 178 </div>
186 \ No newline at end of file 179 \ No newline at end of file
src/main/resources/static/pages/scheduleApp/module/core/scheduleRuleManage/form.html
@@ -107,59 +107,53 @@ @@ -107,59 +107,53 @@
107 107
108 <div class="form-group has-success has-feedback"> 108 <div class="form-group has-success has-feedback">
109 <label class="col-md-2 control-label">路牌范围*:</label> 109 <label class="col-md-2 control-label">路牌范围*:</label>
110 - <div class="col-md-4">  
111 - <input type="text" class="form-control" name="lpNames" ng-model="ctrl.scheduleRuleManageForSave.lpNames" required  
112 - placeholder="由路牌名称组成,逗号分隔"/>  
113 - </div>  
114 - <!-- 隐藏块,显示验证信息 -->  
115 - <div class="alert alert-danger well-sm" ng-show="myForm.lpNames.$error.required">  
116 - 路牌范围必须填写  
117 - </div>  
118 - </div>  
119 -  
120 - <div class="form-group has-success has-feedback">  
121 - <label class="col-md-2 control-label">起始路牌*:</label>  
122 - <div class="col-md-4">  
123 - <input type="text" class="form-control" name="lpStart" ng-model="ctrl.scheduleRuleManageForSave.lpStart" required  
124 - placeholder="起始路牌索引,从1开始"/>  
125 - </div>  
126 - <!-- 隐藏块,显示验证信息 -->  
127 - <div class="alert alert-danger well-sm" ng-show="myForm.lpStart.$error.required">  
128 - 起始路牌必须填写 110 + <div class="col-md-6">
  111 + <sa-Guideboardgroup model="ctrl.scheduleRuleManageForSave"
  112 + name="lprange"
  113 + xlidvalue="{{ctrl.scheduleRuleManageForSave.xl.id}}"
  114 + lprangevalue="{{ctrl.scheduleRuleManageForSave.lpNames}}"
  115 + lprangename="lpNames"
  116 + lpidrangevalue="{{ctrl.scheduleRuleManageForSave.lpIds}}"
  117 + lpidrangename="lpIds"
  118 + lpstartvalue="{{ctrl.scheduleRuleManageForSave.lpStart}}"
  119 + lpstartname="lpStart"
  120 + required
  121 + >
  122 + </sa-Guideboardgroup>
  123 + </div>
  124 + <div class="alert alert-danger well-sm" ng-show="myForm.lprange.$error.required">
  125 + 路牌范围,起始路牌必须选择
129 </div> 126 </div>
130 </div> 127 </div>
131 128
132 <div class="form-group has-success has-feedback"> 129 <div class="form-group has-success has-feedback">
133 <label class="col-md-2 control-label">人员范围*:</label> 130 <label class="col-md-2 control-label">人员范围*:</label>
134 - <div class="col-md-4">  
135 - <input type="text" class="form-control" name="ryDbbms" ng-model="ctrl.scheduleRuleManageForSave.ryDbbms" required  
136 - placeholder="由人员配置的搭班编码组成,逗号分隔"/>  
137 - </div>  
138 - <!-- 隐藏块,显示验证信息 -->  
139 - <div class="alert alert-danger well-sm" ng-show="myForm.ryDbbms.$error.required">  
140 - 人员范围必须填写 131 + <div class="col-md-6">
  132 + <sa-Employeegroup model="ctrl.scheduleRuleManageForSave"
  133 + name="ryrange"
  134 + xlidvalue="{{ctrl.scheduleRuleManageForSave.xl.id}}"
  135 + dbbmrangevalue="{{ctrl.scheduleRuleManageForSave.ryDbbms}}"
  136 + dbbmrangename="ryDbbms"
  137 + rycidrangevalue="{{ctrl.scheduleRuleManageForSave.ryConfigIds}}"
  138 + rycidrangename="ryConfigIds"
  139 + rystartvalue="{{ctrl.scheduleRuleManageForSave.ryStart}}"
  140 + rystartname="ryStart"
  141 + required
  142 + >
  143 + </sa-Employeegroup>
  144 + </div>
  145 + <div class="alert alert-danger well-sm" ng-show="myForm.ryrange.$error.required">
  146 + 人员范围,起始人员必须选择
141 </div> 147 </div>
142 </div> 148 </div>
143 149
144 - <div class="form-group has-success has-feedback">  
145 - <label class="col-md-2 control-label">起始人员*:</label>  
146 - <div class="col-md-4">  
147 - <input type="text" class="form-control" name="ryStart" ng-model="ctrl.scheduleRuleManageForSave.ryStart" required  
148 - placeholder="起始人员索引,从1开始"/>  
149 - </div>  
150 - <!-- 隐藏块,显示验证信息 -->  
151 - <div class="alert alert-danger well-sm" ng-show="myForm.ryStart.$error.required">  
152 - 起始路牌必须填写  
153 - </div>  
154 - </div>  
155 -  
156 - <div class="form-group">  
157 - <label class="col-md-2 control-label">翻班格式:</label>  
158 - <div class="col-md-4">  
159 - <input type="text" class="form-control" name="fbgs" ng-model="ctrl.scheduleRuleManageForSave.fbgs"  
160 - placeholder="车辆翻班格式"/>  
161 - </div>  
162 - </div> 150 + <!--<div class="form-group">-->
  151 + <!--<label class="col-md-2 control-label">翻班格式:</label>-->
  152 + <!--<div class="col-md-4">-->
  153 + <!--<input type="text" class="form-control" name="fbgs" ng-model="ctrl.scheduleRuleManageForSave.fbgs"-->
  154 + <!--placeholder="车辆翻班格式"/>-->
  155 + <!--</div>-->
  156 + <!--</div>-->
163 157
164 158
165 <!-- 其他form-group --> 159 <!-- 其他form-group -->