Commit 2ce4e3106d4b8ce42e05a44b0a5774c10c7197bc

Authored by 潘钊
2 parents 9955cf0f 2b8e8687

Merge branch 'minhang' of http://222.66.0.204:8800/panzhaov5/bsth_control into minhang

Too many changes to show.

To preserve performance only 14 of 22 files are displayed.

src/main/java/com/bsth/controller/schedule/SchedulePlanController.java
... ... @@ -4,11 +4,10 @@ import com.bsth.controller.BaseController;
4 4 import com.bsth.entity.schedule.SchedulePlan;
5 5 import com.bsth.service.schedule.SchedulePlanService;
6 6 import org.springframework.beans.factory.annotation.Autowired;
7   -import org.springframework.web.bind.annotation.RequestBody;
8   -import org.springframework.web.bind.annotation.RequestMapping;
9   -import org.springframework.web.bind.annotation.RequestMethod;
10   -import org.springframework.web.bind.annotation.RestController;
  7 +import org.springframework.web.bind.annotation.*;
11 8  
  9 +import java.util.Date;
  10 +import java.util.List;
12 11 import java.util.Map;
13 12  
14 13 /**
... ... @@ -35,5 +34,21 @@ public class SchedulePlanController extends BaseController<SchedulePlan, Long> {
35 34 return baseService.save(t);
36 35 }
37 36  
  37 + // TODO:
  38 +// @RequestMapping(value = "/groupinfos/{xlid}/{date}", method = RequestMethod.GET)
  39 +// public List<Map<String, Object>> findGroupInfo(
  40 +// Integer xlid, Date scheduleDate) {
  41 +//
  42 +// }
  43 +
  44 + @RequestMapping(value = "/groupinfos/{xlid}/{date}", method = RequestMethod.GET)
  45 + public List<Map<String, Object>> findGroupInfo(
  46 + @PathVariable(value = "xlid") Integer xlid,
  47 + @PathVariable(value = "date") Date scheduleDate) {
  48 + return schedulePlanService.findGroupInfo(xlid, scheduleDate);
  49 + }
  50 +
  51 +// public int updateGroupInfo
  52 +
38 53  
39 54 }
... ...
src/main/java/com/bsth/controller/schedule/ScheduleRule1FlatController.java
1 1 package com.bsth.controller.schedule;
2 2  
3 3 import com.bsth.controller.BaseController;
4   -import com.bsth.entity.schedule.EmployeeConfigInfo;
5   -import com.bsth.entity.schedule.GuideboardInfo;
6 4 import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
7 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 6 import org.springframework.beans.factory.annotation.Autowired;
12 7 import org.springframework.web.bind.annotation.*;
13 8  
14   -import java.util.HashMap;
15 9 import java.util.Map;
16 10  
17 11 /**
... ... @@ -23,10 +17,6 @@ public class ScheduleRule1FlatController extends BaseController&lt;ScheduleRule1Fla
23 17  
24 18 @Autowired
25 19 private ScheduleRule1FlatRepository scheduleRule1FlatRepository;
26   - @Autowired
27   - private GuideboardInfoService guideboardInfoService;
28   - @Autowired
29   - private EmployeeConfigInfoService employeeConfigInfoService;
30 20  
31 21 @Override
32 22 public ScheduleRule1Flat findById(@PathVariable("id") Long aLong) {
... ... @@ -44,63 +34,6 @@ public class ScheduleRule1FlatController extends BaseController&lt;ScheduleRule1Fla
44 34 */
45 35 @RequestMapping(method = RequestMethod.POST)
46 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 37 return baseService.save(t);
105 38 }
106 39  
... ...
src/main/java/com/bsth/repository/schedule/SchedulePlanRepository.java
... ... @@ -6,8 +6,15 @@ import org.springframework.data.domain.Page;
6 6 import org.springframework.data.domain.Pageable;
7 7 import org.springframework.data.jpa.domain.Specification;
8 8 import org.springframework.data.jpa.repository.EntityGraph;
  9 +import org.springframework.data.jpa.repository.Query;
  10 +import org.springframework.data.repository.query.Param;
9 11 import org.springframework.stereotype.Repository;
10 12  
  13 +import javax.persistence.SqlResultSetMapping;
  14 +import java.util.Date;
  15 +import java.util.List;
  16 +import java.util.Map;
  17 +
11 18 /**
12 19 * Created by xu on 16/6/16.
13 20 */
... ... @@ -17,4 +24,37 @@ public interface SchedulePlanRepository extends BaseRepository&lt;SchedulePlan, Lon
17 24 @Override
18 25 Page<SchedulePlan> findAll(Specification<SchedulePlan> spec, Pageable pageable);
19 26  
  27 + @Query(value = " select " +
  28 + "xl_name as xlName, " +
  29 + "schedule_date as scheduleDate, " +
  30 + "lp_name as lpName, " +
  31 + "cl_zbh as clZbh, " +
  32 + "group_concat(distinct fcsj) ccsj, " +
  33 + "group_concat(distinct j_gh) jsyGh, " +
  34 + "group_concat(distinct j_name) jsyName, " +
  35 + "group_concat(distinct s_gh) spyGh, " +
  36 + "group_concat(distinct s_name) spyName, " +
  37 + "max(create_date) as createDate " +
  38 + "from bsth_c_s_sp_info " +
  39 + "where bc_type = 'out' and " +
  40 + "xl = ?1 and " +
  41 + "schedule_date = ?2 " +
  42 + "group by xl_name, schedule_date, lp_name " +
  43 + "order by xl_name, schedule_date, lp ", nativeQuery = true)
  44 + List<Object[]> findGroupInfo(Integer xlid, Date scheduleDate);
  45 +
  46 + @Query(value = "update " +
  47 + "bsth_c_s_sp_info " +
  48 + "set cl = :p1, cl_zbh = :p2 " +
  49 + "where xl = :p3 and " +
  50 + "schedule_date = :p4 and " +
  51 + "lp_name = :p5 ",
  52 + nativeQuery = true)
  53 + int updateGroupInfo_clinfo(
  54 + @Param("p1") Integer clid,
  55 + @Param("p2") String clZbh,
  56 + @Param("p3") Integer xlid,
  57 + @Param("p4") Date scheduleDate,
  58 + @Param("p5") String lpName);
  59 +
20 60 }
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -464,20 +464,43 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
464 464 List<Map<String,Object>> listMap = new ArrayList<Map<String,Object>>();
465 465  
466 466 DecimalFormat format = new DecimalFormat("0.00");
467   - int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
468   - int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
469   - int jhbc = 0;
470   - double jhlc = 0;
471   - float realMileage = 0l,addMileage = 0l,remMileage = 0l;
  467 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  468 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  469 + int jhbc = 0,cjbc = 0,ljbc = 0;
  470 + double jhlc = 0, yygl = 0, ksgl = 0;
  471 + float addMileage = 0l,remMileage = 0l;
472 472  
473 473 Map<String,Object> map;
474 474 for(ScheduleRealInfo scheduleRealInfo : scheduleRealInfos){
475 475 if(scheduleRealInfo != null){
476   - jhlc += scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
477   - realMileage += scheduleRealInfo.getRealMileage()==null?0:scheduleRealInfo.getRealMileage();
478   - addMileage += scheduleRealInfo.getAddMileage()==null?0:scheduleRealInfo.getAddMileage();
479   - remMileage += scheduleRealInfo.getRemMileage()==null?0:scheduleRealInfo.getRemMileage();
480   - jhbc++;
  476 + //计算计划里程(主任务过滤掉临加班次),烂班里程,临加里程,计划班次,烂班班次,增加班次
  477 + if(scheduleRealInfo.isSflj()){
  478 + addMileage += addMileage += scheduleRealInfo.getAddMileage()==null?0:scheduleRealInfo.getAddMileage();
  479 + ljbc++;
  480 + }else{
  481 + jhlc += scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  482 + if(scheduleRealInfo.getStatus() != -1){
  483 + remMileage += scheduleRealInfo.getRemMileage()==null?0:scheduleRealInfo.getRemMileage();
  484 + }else{
  485 + cjbc++;
  486 + }
  487 + jhbc++;
  488 + }
  489 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  490 + //计算营运里程,空驶里程
  491 + if(childTaskPlans.isEmpty()){
  492 + yygl += scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  493 + }else{
  494 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  495 + while(it.hasNext()){
  496 + ChildTaskPlan childTaskPlan = it.next();
  497 + if(childTaskPlan.getMileageType().equals("empty")){
  498 + ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  499 + }else{
  500 + yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  501 + }
  502 + }
  503 + }
481 504  
482 505 map = new HashMap<String, Object>();
483 506 try {
... ... @@ -509,9 +532,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
509 532 map.put("jhlc", format.format(jhlc));
510 533 map.put("remMileage", format.format(remMileage));
511 534 map.put("addMileage", format.format(addMileage));
512   - map.put("yygl", format.format(realMileage-addMileage));
513   - map.put("ksgl", format.format(realMileage-addMileage));
514   - map.put("realMileage", format.format(realMileage));
  535 + map.put("yygl", format.format(yygl));
  536 + map.put("ksgl", format.format(ksgl));
  537 + map.put("realMileage", format.format(yygl+ksgl));
515 538 map.put("jhbc", jhbc);
516 539 map.put("cjbc", cjbc);
517 540 map.put("ljbc", ljbc);
... ... @@ -520,7 +543,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
520 543 String path = this.getClass().getResource("/").getPath()+"static\\pages\\forms\\";
521 544  
522 545 list.add(listMap.iterator());
523   - ee.excelReplace(list, new Object[] { scheduleRealInfos.get(0),map }, path+"mould\\waybill.xls",
  546 + ee.excelReplace(list, new Object[] { scheduleRealInfos.get(0),map }, path+"mould\\waybill_minhang.xls",
524 547 path+"export\\" + jName + ".xls");
525 548 return scheduleRealInfos;
526 549 }
... ... @@ -983,27 +1006,58 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
983 1006 String lpName,String date) {
984 1007 List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date);
985 1008 DecimalFormat format = new DecimalFormat("0.00");
986   - int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
987   - int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
988   - int jhbc = 0;
989   - double jhlc = 0;
990   - float realMileage = 0l,addMileage = 0l,remMileage = 0l;
  1009 +// int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
  1010 +// int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
  1011 + int jhbc = 0,cjbc = 0,ljbc = 0;
  1012 + double jhlc = 0, yygl = 0, ksgl = 0,tempJhlc = 0;
  1013 + float addMileage = 0l,remMileage = 0l;
991 1014 Map<String,Object> map = new HashMap<String, Object>();
992 1015 for(ScheduleRealInfo scheduleRealInfo : list){
993 1016 if(scheduleRealInfo != null){
994   - jhlc += scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
995   - realMileage += scheduleRealInfo.getRealMileage()==null?0:scheduleRealInfo.getRealMileage();
996   - addMileage += scheduleRealInfo.getAddMileage()==null?0:scheduleRealInfo.getAddMileage();
997   - remMileage += scheduleRealInfo.getRemMileage()==null?0:scheduleRealInfo.getRemMileage();
998   - jhbc++;
  1017 + //计划里程(主任务过滤掉临加班次),
  1018 + //烂班里程(主任务烂班),
  1019 + //临加里程(主任务临加),
  1020 + //计划班次,烂班班次,增加班次
  1021 + tempJhlc = scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  1022 + if(scheduleRealInfo.isSflj()){
  1023 + addMileage += tempJhlc;
  1024 + ljbc++;
  1025 + }else{
  1026 + jhlc += tempJhlc;
  1027 + jhbc++;
  1028 + if(scheduleRealInfo.getStatus() == -1){
  1029 + remMileage += tempJhlc;
  1030 + cjbc++;
  1031 + }
  1032 + }
  1033 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1034 + //计算营运里程,空驶里程
  1035 + if(childTaskPlans.isEmpty()){
  1036 + if(scheduleRealInfo.getBcType().equals("in") || scheduleRealInfo.getBcType().equals("out")
  1037 + || scheduleRealInfo.getBcType().equals("venting")){
  1038 + ksgl += tempJhlc;
  1039 + }else{
  1040 + yygl += tempJhlc;
  1041 + }
  1042 + }else{
  1043 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1044 + while(it.hasNext()){
  1045 + ChildTaskPlan childTaskPlan = it.next();
  1046 + if(childTaskPlan.getMileageType().equals("empty")){
  1047 + ksgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  1048 + }else{
  1049 + yygl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  1050 + }
  1051 + }
  1052 + }
999 1053 }
1000 1054 }
1001 1055 map.put("jhlc", format.format(jhlc));
1002 1056 map.put("remMileage", format.format(remMileage));
1003 1057 map.put("addMileage", format.format(addMileage));
1004   - map.put("yygl", format.format(jhlc));
1005   - map.put("ksgl", format.format(realMileage-addMileage));
1006   - map.put("realMileage", format.format(jhlc));
  1058 + map.put("yygl", format.format(yygl));
  1059 + map.put("ksgl", format.format(ksgl));
  1060 + map.put("realMileage", format.format(yygl+ksgl));
1007 1061 map.put("jhbc", jhbc);
1008 1062 map.put("cjbc", cjbc);
1009 1063 map.put("ljbc", ljbc);
... ... @@ -1066,17 +1120,43 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1066 1120 public List<Map<String, Object>> statisticsDaily(String line, String date,
1067 1121 String xlName) {
1068 1122 List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
  1123 + List<Map<String,Object>> lMap = new ArrayList<Map<String,Object>>();
  1124 + DecimalFormat format = new DecimalFormat("0.00");
1069 1125 double jhlc = 0.00;
1070   - float realMileage = 0l;
  1126 + float sjgl = 0l,ssgl = 0l;
  1127 + Map<String,Object> map = new HashMap<String, Object>();
1071 1128 for(ScheduleRealInfo scheduleRealInfo: list){
1072 1129 if(scheduleRealInfo != null){
1073   - jhlc += scheduleRealInfo.getJhlc();
1074   - if(scheduleRealInfo.getsName().equals("1")){
1075   - realMileage += scheduleRealInfo.getRealMileage();
  1130 + if(!scheduleRealInfo.isSflj()){
  1131 + jhlc += scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  1132 + }
  1133 + if(scheduleRealInfo.isDestroy()){
  1134 + ssgl += scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  1135 + }
  1136 +
  1137 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1138 + //计算实际里程,空驶里程
  1139 + if(childTaskPlans.isEmpty()){
  1140 + sjgl += scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  1141 + }else{
  1142 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1143 + while(it.hasNext()){
  1144 + ChildTaskPlan childTaskPlan = it.next();
  1145 + if(childTaskPlan.isDestroy()){
  1146 + ssgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  1147 + }else{
  1148 + sjgl += childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  1149 + }
  1150 + }
1076 1151 }
1077 1152 }
1078 1153 }
1079   - return null;
  1154 + map.put("xlName", xlName);
  1155 + map.put("jhlc", format.format(jhlc));
  1156 + map.put("sjgl", format.format(sjgl));
  1157 + map.put("ssgl", format.format(ssgl));
  1158 + lMap.add(map);
  1159 + return lMap;
1080 1160 }
1081 1161  
1082 1162 @Override
... ...
src/main/java/com/bsth/service/schedule/SchedulePlanService.java
... ... @@ -3,8 +3,31 @@ package com.bsth.service.schedule;
3 3 import com.bsth.entity.schedule.SchedulePlan;
4 4 import com.bsth.service.BaseService;
5 5  
  6 +import java.util.Date;
  7 +import java.util.List;
  8 +import java.util.Map;
  9 +
6 10 /**
7 11 * Created by xu on 16/6/16.
8 12 */
9 13 public interface SchedulePlanService extends BaseService<SchedulePlan, Long> {
  14 +
  15 + /**
  16 + * 查找分组排班信息。
  17 + * @param xlid 线路Id
  18 + * @param scheduleDate 排班日期
  19 + * @return
  20 + */
  21 + List<Map<String, Object>> findGroupInfo(Integer xlid, Date scheduleDate);
  22 +
  23 + /**
  24 + * 更新分组排班信息。
  25 + * @param clid 车辆id
  26 + * @param clZbh 车辆自编号
  27 + * @param xlid 线路id
  28 + * @param scheduleDate 排班日期
  29 + * @param lpName 路牌名字
  30 + * @return
  31 + */
  32 + int updateGroupInfo_clinfo(Integer clid, String clZbh, Integer xlid, Date scheduleDate, String lpName);
10 33 }
... ...
src/main/java/com/bsth/service/schedule/SchedulePlanServiceImpl.java
... ... @@ -5,7 +5,6 @@ import com.bsth.entity.schedule.*;
5 5 import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
6 6 import com.bsth.repository.schedule.SchedulePlanInfoRepository;
7 7 import com.bsth.repository.schedule.SchedulePlanRepository;
8   -import com.bsth.service.LineService;
9 8 import com.bsth.service.impl.BaseServiceImpl;
10 9 import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input;
11 10 import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output;
... ... @@ -31,10 +30,6 @@ public class SchedulePlanServiceImpl extends BaseServiceImpl&lt;SchedulePlan, Long&gt;
31 30 @Autowired
32 31 private KieBase kieBase;
33 32 @Autowired
34   - private ScheduleRule1FlatService scheduleRule1FlatService;
35   - @Autowired
36   - private LineService lineService;
37   - @Autowired
38 33 private IStrategy strategy;
39 34 @Autowired
40 35 private SchedulePlanRepository schedulePlanRepository;
... ... @@ -126,5 +121,91 @@ public class SchedulePlanServiceImpl extends BaseServiceImpl&lt;SchedulePlan, Long&gt;
126 121 return super.save(schedulePlan);
127 122 }
128 123  
  124 + @Override
  125 + public List<Map<String, Object>> findGroupInfo(Integer xlid, Date scheduleDate) {
  126 + List<Object[]> groupInfos = schedulePlanRepository.findGroupInfo(xlid, scheduleDate);
  127 + List<Map<String, Object>> ret = new ArrayList<>();
  128 + for (Object[] datas : groupInfos) {
  129 + // TODO:貌似springdata没有优雅的方式把List<Object[]>转换成List<Map<String, Object>>方法,
  130 + // TODO:可能jpa有相关标注,以后找到,此方法就作废
  131 +
  132 + Map<String, Object> map = new HashMap<>();
  133 +
  134 + // 线路名称
  135 + map.put("xlName", datas[0]);
  136 + // 排班时间
  137 + map.put("scheduleDate", datas[1]);
  138 + // 路牌名字
  139 + map.put("lpName", datas[2]);
  140 + // 车辆自编号
  141 + map.put("clZbh", datas[3]);
  142 + // 出场时间,如果有多个,需要分开
  143 + Object ccsj = datas[4];
  144 + if (ccsj != null) {
  145 + String[] ccsj_array = ((String) ccsj).split(",");
  146 + if (ccsj_array.length > 1) {
  147 + map.put("ccsj1", ccsj_array[0]);
  148 + map.put("ccsj2", ccsj_array[1]);
  149 + } else {
  150 + map.put("ccsj1", ccsj_array[0]);
  151 + }
  152 + }
  153 + // 驾驶员工号,如果有多个,需要分开
  154 + Object jsyGh = datas[5];
  155 + if (jsyGh != null) {
  156 + String[] jsyGh_array = ((String) jsyGh).split(",");
  157 + if (jsyGh_array.length > 1) {
  158 + map.put("jsy1Gh", jsyGh_array[0]);
  159 + map.put("jsy2Gh", jsyGh_array[1]);
  160 + } else {
  161 + map.put("jsy1Gh", jsyGh_array[0]);
  162 + }
  163 + }
  164 + // 驾驶员名字,如果有多个,需要分开
  165 + Object jsyName = datas[6];
  166 + if (jsyName != null) {
  167 + String[] jsyName_array = ((String) jsyName).split(",");
  168 + if (jsyName_array.length > 1) {
  169 + map.put("jsy1Name", jsyName_array[0]);
  170 + map.put("jsy2Name", jsyName_array[1]);
  171 + } else {
  172 + map.put("jsy1Name", jsyName_array[0]);
  173 + }
  174 + }
  175 + // 售票员工号,如果有多个,需要分开
  176 + Object spyGh = datas[7];
  177 + if (spyGh != null) {
  178 + String[] spyGh_array = ((String) spyGh).split(",");
  179 + if (spyGh_array.length > 1) {
  180 + map.put("spy1Gh", spyGh_array[0]);
  181 + map.put("spy2Gh", spyGh_array[1]);
  182 + } else {
  183 + map.put("spy1Gh", spyGh_array[0]);
  184 + }
  185 + }
  186 + // 售票员名字,如果有多个,需要分开
  187 + Object spyName = datas[8];
  188 + if (spyName != null) {
  189 + String[] spyName_array = ((String) spyName).split(",");
  190 + if (spyName_array.length > 1) {
  191 + map.put("spy1Name", spyName_array[0]);
  192 + map.put("spy2Name", spyName_array[1]);
  193 + } else {
  194 + map.put("spy1Name", spyName_array[0]);
  195 + }
  196 + }
  197 + // 创建时间
  198 + map.put("createDate", datas[9]);
  199 +
  200 + // TODO:可能还有其他字段
  201 +
  202 + ret.add(map);
  203 + }
  204 + return ret;
  205 + }
129 206  
  207 + @Override
  208 + public int updateGroupInfo_clinfo(Integer clid, String clZbh, Integer xlid, Date scheduleDate, String lpName) {
  209 + return schedulePlanRepository.updateGroupInfo_clinfo(clid, clZbh, xlid, scheduleDate, lpName);
  210 + }
130 211 }
... ...
src/main/java/com/bsth/service/schedule/rules/ttinfo/TTInfo_input.java
1   -package com.bsth.service.schedule.rules.ttinfo;
2   -
3   -import com.bsth.entity.schedule.TTInfo;
4   -import org.apache.commons.lang3.StringUtils;
5   -import org.joda.time.DateTime;
6   -import org.joda.time.format.DateTimeFormat;
7   -
8   -import java.util.ArrayList;
9   -import java.util.List;
10   -
11   -/**
12   - * 时刻表_输入
13   - */
14   -public class TTInfo_input implements Comparable<TTInfo_input> {
15   - /** 时刻表id */
16   - private String ttInfoId;
17   - /** 线路Id */
18   - private String xlId;
19   - /** 周一到周日是否启用 */
20   - private List<Boolean> weekdays = new ArrayList<>();
21   - /** 特殊节假日 */
22   - private List<DateTime> specialDays = new ArrayList<>();
23   - /** 最新修改时间 */
24   - private DateTime updateDate;
25   - /** 是否启用 */
26   - private Boolean isEnable;
27   - /** 启用日期 */
28   - private DateTime qyDate;
29   -
30   - public TTInfo_input() {
31   -
32   - }
33   -
34   - @Override
35   - public int compareTo(TTInfo_input ttInfo_input) {
36   - if (ttInfo_input != null) {
37   - if (ttInfo_input.updateDate != null && this.updateDate != null)
38   - return - this.updateDate.compareTo(ttInfo_input.updateDate);
39   - }
40   - return -1;
41   - }
42   -
43   - public TTInfo_input(TTInfo ttInfo) {
44   - this.ttInfoId = String.valueOf(ttInfo.getId());
45   - this.xlId = String.valueOf(ttInfo.getXl().getId());
46   - String[] days = ttInfo.getRule_days().split(",");
47   - System.out.println(days.length);
48   - for (int i = 0; i < 7; i++) {
49   - if ("1".equals(days[i])) {
50   - weekdays.add(true);
51   - } else {
52   - weekdays.add(false);
53   - }
54   - }
55   - if (StringUtils.isNotEmpty(ttInfo.getSpecial_days())) {
56   - String[] sdays = ttInfo.getSpecial_days().split(",");
57   - for (int i = 0; i < sdays.length; i++) {
58   - specialDays.add(DateTimeFormat.forPattern("yyyy-MM-dd").
59   - parseDateTime(sdays[i]));
60   - }
61   - }
62   -
63   - this.updateDate = new DateTime(ttInfo.getUpdateDate());
64   - this.isEnable = ttInfo.getIsEnableDisTemplate();
65   - this.qyDate = new DateTime(ttInfo.getQyrq());
66   -
67   - }
68   -
69   - public String getTtInfoId() {
70   - return ttInfoId;
71   - }
72   -
73   - public void setTtInfoId(String ttInfoId) {
74   - this.ttInfoId = ttInfoId;
75   - }
76   -
77   - public String getXlId() {
78   - return xlId;
79   - }
80   -
81   - public void setXlId(String xlId) {
82   - this.xlId = xlId;
83   - }
84   -
85   - public List<Boolean> getWeekdays() {
86   - return weekdays;
87   - }
88   -
89   - public void setWeekdays(List<Boolean> weekdays) {
90   - this.weekdays = weekdays;
91   - }
92   -
93   - public List<DateTime> getSpecialDays() {
94   - return specialDays;
95   - }
96   -
97   - public void setSpecialDays(List<DateTime> specialDays) {
98   - this.specialDays = specialDays;
99   - }
100   -
101   - public DateTime getUpdateDate() {
102   - return updateDate;
103   - }
104   -
105   - public void setUpdateDate(DateTime updateDate) {
106   - this.updateDate = updateDate;
107   - }
108   -
109   - public Boolean getIsEnable() {
110   - return isEnable;
111   - }
112   -
113   - public void setIsEnable(Boolean isEnable) {
114   - this.isEnable = isEnable;
115   - }
116   -
117   - public DateTime getQyDate() {
118   - return qyDate;
119   - }
120   -
121   - public void setQyDate(DateTime qyDate) {
122   - this.qyDate = qyDate;
123   - }
124   -}
  1 +package com.bsth.service.schedule.rules.ttinfo;
  2 +
  3 +import com.bsth.entity.schedule.TTInfo;
  4 +import org.apache.commons.lang3.StringUtils;
  5 +import org.joda.time.DateTime;
  6 +import org.joda.time.format.DateTimeFormat;
  7 +
  8 +import java.util.ArrayList;
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * 时刻表_输入
  13 + */
  14 +public class TTInfo_input implements Comparable<TTInfo_input> {
  15 + /** 时刻表id */
  16 + private String ttInfoId;
  17 + /** 线路Id */
  18 + private String xlId;
  19 + /** 周一到周日是否启用 */
  20 + private List<Boolean> weekdays = new ArrayList<>();
  21 + /** 特殊节假日 */
  22 + private List<DateTime> specialDays = new ArrayList<>();
  23 + /** 最新修改时间 */
  24 + private DateTime updateDate;
  25 + /** 是否启用 */
  26 + private Boolean isEnable;
  27 + /** 启用日期 */
  28 + private DateTime qyDate;
  29 +
  30 + public TTInfo_input() {
  31 +
  32 + }
  33 +
  34 + @Override
  35 + public int compareTo(TTInfo_input ttInfo_input) {
  36 + if (ttInfo_input != null) {
  37 + if (ttInfo_input.updateDate != null && this.updateDate != null)
  38 + return - this.updateDate.compareTo(ttInfo_input.updateDate);
  39 + }
  40 + return -1;
  41 + }
  42 +
  43 + public TTInfo_input(TTInfo ttInfo) {
  44 + this.ttInfoId = String.valueOf(ttInfo.getId());
  45 + this.xlId = String.valueOf(ttInfo.getXl().getId());
  46 + String[] days = ttInfo.getRule_days().split(",");
  47 + System.out.println(days.length);
  48 + for (int i = 0; i < 7; i++) {
  49 + if ("1".equals(days[i])) {
  50 + weekdays.add(true);
  51 + } else {
  52 + weekdays.add(false);
  53 + }
  54 + }
  55 +
  56 + if (StringUtils.isNotEmpty(ttInfo.getSpecial_days())) {
  57 + String[] sdays = ttInfo.getSpecial_days().split(",");
  58 + for (int i = 0; i < sdays.length; i++) {
  59 + specialDays.add(DateTimeFormat.forPattern("yyyy-MM-dd").
  60 + parseDateTime(sdays[i]));
  61 + }
  62 + }
  63 +
  64 + this.updateDate = new DateTime(ttInfo.getUpdateDate());
  65 + this.isEnable = ttInfo.getIsEnableDisTemplate();
  66 + this.qyDate = new DateTime(ttInfo.getQyrq());
  67 +
  68 + }
  69 +
  70 + public String getTtInfoId() {
  71 + return ttInfoId;
  72 + }
  73 +
  74 + public void setTtInfoId(String ttInfoId) {
  75 + this.ttInfoId = ttInfoId;
  76 + }
  77 +
  78 + public String getXlId() {
  79 + return xlId;
  80 + }
  81 +
  82 + public void setXlId(String xlId) {
  83 + this.xlId = xlId;
  84 + }
  85 +
  86 + public List<Boolean> getWeekdays() {
  87 + return weekdays;
  88 + }
  89 +
  90 + public void setWeekdays(List<Boolean> weekdays) {
  91 + this.weekdays = weekdays;
  92 + }
  93 +
  94 + public List<DateTime> getSpecialDays() {
  95 + return specialDays;
  96 + }
  97 +
  98 + public void setSpecialDays(List<DateTime> specialDays) {
  99 + this.specialDays = specialDays;
  100 + }
  101 +
  102 + public DateTime getUpdateDate() {
  103 + return updateDate;
  104 + }
  105 +
  106 + public void setUpdateDate(DateTime updateDate) {
  107 + this.updateDate = updateDate;
  108 + }
  109 +
  110 + public Boolean getIsEnable() {
  111 + return isEnable;
  112 + }
  113 +
  114 + public void setIsEnable(Boolean isEnable) {
  115 + this.isEnable = isEnable;
  116 + }
  117 +
  118 + public DateTime getQyDate() {
  119 + return qyDate;
  120 + }
  121 +
  122 + public void setQyDate(DateTime qyDate) {
  123 + this.qyDate = qyDate;
  124 + }
  125 +}
... ...
src/main/resources/static/pages/forms/mould/waybill_minhang.xls 0 → 100644
No preview for this file type
src/main/resources/static/pages/forms/statement/scheduleDaily.html
... ... @@ -82,23 +82,23 @@
82 82 <td>援外</td>
83 83 <td>其他</td>
84 84 <td>全日</td>
85   - <td>6:31~8:30</td>
86   - <td>16:01~18:00</td>
  85 + <td>6:31~<br>8:30</td>
  86 + <td>16:01~<br>18:00</td>
87 87 <td>全日</td>
88   - <td>6:31~8:30</td>
89   - <td>16:01~18:00</td>
  88 + <td>6:31~<br>8:30</td>
  89 + <td>16:01~<br>18:00</td>
90 90 <td>全日</td>
91   - <td>6:31~8:30</td>
92   - <td>16:01~18:00</td>
  91 + <td>6:31~<br>8:30</td>
  92 + <td>16:01~<br>18:00</td>
93 93 <td>全日</td>
94   - <td>6:31~8:30</td>
95   - <td>16:01~18:00</td>
  94 + <td>6:31~<br>8:30</td>
  95 + <td>16:01~<br>18:00</td>
96 96 <td>全日</td>
97   - <td>6:31~8:30</td>
98   - <td>16:01~18:00</td>
  97 + <td>6:31~<br>8:30</td>
  98 + <td>16:01~<br>18:00</td>
99 99 <td>全日</td>
100   - <td>6:31~8:30</td>
101   - <td>16:01~18:00</td>
  100 + <td>6:31~<br>8:30</td>
  101 + <td>16:01~<br>18:00</td>
102 102 </tr>
103 103 </thead>
104 104 <tr>
... ... @@ -153,37 +153,40 @@
153 153 <td colspan="40">&nbsp;</td>
154 154 </tr>
155 155 <tr>
156   - <td colspan="2">班</td>
  156 + <td colspan="2">班</td>
157 157 <td colspan="2">车号</td>
158 158 <td>司早</td>
159 159 <td>售早</td>
160 160 <td>司晚</td>
161 161 <td>售晚</td>
162   - <td colspan="2">班</td>
  162 + <td colspan="2">班</td>
163 163 <td colspan="2">车号</td>
164 164 <td>司早</td>
165 165 <td>售早</td>
166 166 <td>司晚</td>
167 167 <td>售晚</td>
168   - <td colspan="2">班</td>
  168 + <td colspan="2">班</td>
169 169 <td colspan="2">车号</td>
170 170 <td>司早</td>
171 171 <td>售早</td>
172 172 <td>司晚</td>
173 173 <td>售晚</td>
174   - <td colspan="2">班</td>
  174 + <td colspan="2">班</td>
175 175 <td colspan="2">车号</td>
176 176 <td>司早</td>
177 177 <td>售早</td>
178 178 <td>司晚</td>
179 179 <td>售晚</td>
180   - <td colspan="2">班</td>
  180 + <td colspan="2">班</td>
181 181 <td colspan="2">车号</td>
182 182 <td>司早</td>
183 183 <td>售早</td>
184 184 <td>司晚</td>
185 185 <td>售晚</td>
186 186 </tr>
  187 + <tbody class="scheduleDaily_2">
  188 +
  189 + </tbody>
187 190 <tr>
188 191 <td colspan="40">&nbsp;</td>
189 192 </tr>
... ... @@ -232,7 +235,7 @@
232 235 <td>慢</td>
233 236 <td>&nbsp;</td>
234 237 </tr>
235   - <tbody>
  238 + <tbody class="scheduleDaily_3">
236 239  
237 240 </tbody>
238 241 </table>
... ... @@ -289,18 +292,69 @@
289 292 return '<span style="color:gray;font-size: 12px;"> 正在搜索线路...</span>';
290 293 }
291 294 }
292   - });
  295 + });
  296 +
  297 + //查询
  298 + $("#query").on('click',function(){
  299 + var line = $("#line").val();
  300 + var date = $("#date").val();
  301 + $.get('/realSchedule/queryUserInfo',{line:line,date:date},function(result){
  302 + var scheduleDaily_2 = template('scheduleDaily_2',{list:result});
  303 + $('#forms .scheduleDaily_2').html(scheduleDaily_2);
  304 + });
  305 + $.get('/realSchedule/realScheduleList',{line:line,date:date},function(result){
  306 + var scheduleDaily_3 = template('scheduleDaily_3',{list:result});
  307 + $('#forms .scheduleDaily_3').html(scheduleDaily_3);
  308 + });
  309 +
  310 + });
293 311 });
294 312 </script>
295   -<script type="text/html" id="list_forms">
  313 +<script type="text/html" id="scheduleDaily_2">
296 314 {{each list as obj i}}
  315 + {{if i%5 == 0}}
  316 + <tr>
  317 + {{/if}}
  318 + <td colspan="2">{{obj.lpName}}</td>
  319 + <td colspan="2">{{obj.clZbh}}</td>
  320 + <td>{{obj.jGh}}</td>
  321 + <td>{{obj.sGh}}</td>
  322 + <td>&nbsp;</td>
  323 + <td>&nbsp;</td>
  324 + {{if (i+1)%5 == 0}}
  325 + </tr>
  326 + {{/if}}
  327 + {{/each}}
  328 + {{if list.length == 0}}
297 329 <tr>
298   -
  330 + <td colspan="40"><h6 class="muted">没有找到相关数据</h6></td>
299 331 </tr>
  332 + {{/if}}
  333 +</script>
  334 +<script type="text/html" id="scheduleDaily_3">
  335 + {{each list as obj i}}
  336 + {{if i%3 == 0}}
  337 + <tr>
  338 + {{/if}}
  339 + <td>{{obj.lpName}}</td>
  340 + <td colspan="2">{{obj.qdzName}}</td>
  341 + <td>{{obj.zdsj}}</td>
  342 + <td>{{obj.zdsjActual}}</td>
  343 + <td>&nbsp;</td>
  344 + <td>&nbsp;</td>
  345 + <td>{{obj.fcsj}}</td>
  346 + <td>{{obj.fcsjActual}}</td>
  347 + <td>&nbsp;</td>
  348 + <td>&nbsp;</td>
  349 + <td colspan="2">{{obj.remarks}}</td>
  350 + {{if (i+1)%3 == 0}}
  351 + <td>&nbsp;</td>
  352 + </tr>
  353 + {{/if}}
300 354 {{/each}}
301 355 {{if list.length == 0}}
302 356 <tr>
303   - <td colspan="6"><h6 class="muted">没有找到相关数据</h6></td>
  357 + <td colspan="40"><h6 class="muted">没有找到相关数据</h6></td>
304 358 </tr>
305 359 {{/if}}
306 360 </script>
307 361 \ No newline at end of file
... ...
src/main/resources/static/pages/forms/statement/statisticsDaily .html
... ... @@ -101,7 +101,7 @@
101 101 <td>16:01~18:00</td>
102 102 </tr>
103 103 </thead>
104   - <tbody>
  104 + <tbody class="statisticsDaily">
105 105  
106 106 </tbody>
107 107 <tr>
... ... @@ -207,17 +207,52 @@
207 207 var date = $("#date").val();
208 208 $get('/realSchedule/statisticsDaily',{line:line,date:date,xlName:xlName},function(result){
209 209 // 把数据填充到模版中
210   - var tbodyHtml = template('list_account',{list:result});
  210 + var tbodyHtml = template('statisticsDaily',{list:result});
211 211 // 把渲染好的模版html文本追加到表格中
212   - $('#forms tbody').html(tbodyHtml);
  212 + $('#forms .statisticsDaily').html(tbodyHtml);
213 213 });
214 214 });
215 215 });
216 216 </script>
217   -<script type="text/html" id="list_forms">
  217 +<script type="text/html" id="statisticsDaily">
218 218 {{each list as obj i}}
219   - <tr>
220   -
  219 + <tr>
  220 + <td>{{obj.xlName}}</td>
  221 + <td>{{obj.jhlc}}</td>
  222 + <td>{{obj.sjgl}}</td>
  223 + <td>{{obj.ssgl}}</td>
  224 + <td>&nbsp;</td>
  225 + <td>&nbsp;</td>
  226 + <td>&nbsp;</td>
  227 + <td>&nbsp;</td>
  228 + <td>&nbsp;</td>
  229 + <td>&nbsp;</td>
  230 + <td>&nbsp;</td>
  231 + <td>&nbsp;</td>
  232 + <td>&nbsp;</td>
  233 + <td>&nbsp;</td>
  234 + <td>&nbsp;</td>
  235 + <td>&nbsp;</td>
  236 + <td>&nbsp;</td>
  237 + <td>&nbsp;</td>
  238 + <td>&nbsp;</td>
  239 + <td>&nbsp;</td>
  240 + <td>&nbsp;</td>
  241 + <td>&nbsp;</td>
  242 + <td>&nbsp;</td>
  243 + <td>&nbsp;</td>
  244 + <td>&nbsp;</td>
  245 + <td>&nbsp;</td>
  246 + <td>&nbsp;</td>
  247 + <td>&nbsp;</td>
  248 + <td>&nbsp;</td>
  249 + <td>&nbsp;</td>
  250 + <td>&nbsp;</td>
  251 + <td>&nbsp;</td>
  252 + <td>&nbsp;</td>
  253 + <td>&nbsp;</td>
  254 + <td>&nbsp;</td>
  255 + <td>&nbsp;</td>
221 256 </tr>
222 257 {{/each}}
223 258 {{if list.length == 0}}
... ...
src/main/resources/static/pages/forms/statement/waybill_minhang.html
... ... @@ -304,32 +304,32 @@
304 304 <tr>
305 305 <td colspan="2">计划公里</td>
306 306 <td>{{jhlc}}</td>
307   - <td>抽减公里</td>
  307 + <td>烂班公里</td>
308 308 <td>{{remMileage}}</td>
309   - <td colspan="2">加公里</td>
  309 + <td colspan="2">加公里</td>
310 310 <td>{{addMileage}}</td>
311   - <td colspan="2">实际计划公里</td>
312   - <td colspan="3">{{jhlc}}</td>
  311 + <td colspan="2">营运公里</td>
  312 + <td colspan="3">{{yygl}}</td>
313 313 </tr>
314 314 <tr>
315   - <td colspan="2">营运公里</td>
316   - <td>{{realMileage}}</td>
317   - <td>空驶公里</td>
  315 + <td colspan="2">空驶公里</td>
318 316 <td>{{ksgl}}</td>
319   - <td colspan="2">总公里</td>
  317 + <td>总公里</td>
320 318 <td>{{realMileage}}</td>
321 319 <td colspan="2">计划班次</td>
322   - <td colspan="3">{{jhbc}}</td>
  320 + <td>{{jhbc}}</td>
  321 + <td colspan="2">烂班班次</td>
  322 + <td colspan="3">{{cjbc}}</td>
323 323 </tr>
324 324 <tr>
325   - <td colspan="2">抽减班次</td>
326   - <td>{{cjbc}}</td>
327   - <td>增加班次</td>
  325 + <td colspan="2">增加班次</td>
328 326 <td>{{ljbc}}</td>
329   - <td colspan="2">实际计划班次</td>
330   - <td>{{jhbc}}</td>
331   - <td colspan="2">实际班次</td>
332   - <td colspan="3">{{sjbc}}</td>
  327 + <td>实际班次</td>
  328 + <td>{{sjbc}}</td>
  329 + <td colspan="2"></td>
  330 + <td></td>
  331 + <td colspan="2"></td>
  332 + <td colspan="3"></td>
333 333 </tr>
334 334 </script>
335 335 <script type="text/html" id="ludan_4">
... ...
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 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 81 </div>
68 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 +]);
... ...