Commit 5e99b8a669fd0966f2cbd7cfd4d64386f9663854
1 parent
12df3542
PSM-14
Showing
33 changed files
with
6005 additions
and
3667 deletions
src/main/java/com/bsth/controller/BaseController2.java
| ... | ... | @@ -99,6 +99,12 @@ public class BaseController2<T, ID extends Serializable> { |
| 99 | 99 | return t; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | + @RequestMapping(value="/{id}", method = RequestMethod.POST) | |
| 103 | + public T update(@RequestBody T t) { | |
| 104 | + baseService.save(t); | |
| 105 | + return t; | |
| 106 | + } | |
| 107 | + | |
| 102 | 108 | /** |
| 103 | 109 | * |
| 104 | 110 | * @Title: findById | ... | ... |
src/main/java/com/bsth/controller/schedule/TTInfoDetailController.java
| ... | ... | @@ -4,20 +4,32 @@ import com.bsth.common.ResponseCode; |
| 4 | 4 | import com.bsth.controller.BaseController; |
| 5 | 5 | import com.bsth.entity.CarPark; |
| 6 | 6 | import com.bsth.entity.LineInformation; |
| 7 | +import com.bsth.entity.StationRoute; | |
| 8 | +import com.bsth.entity.schedule.GuideboardInfo; | |
| 7 | 9 | import com.bsth.entity.schedule.TTInfoDetail; |
| 8 | 10 | import com.bsth.repository.schedule.TTInfoDetailRepository; |
| 9 | 11 | import com.bsth.service.CarParkService; |
| 10 | 12 | import com.bsth.service.LineInformationService; |
| 11 | -import com.bsth.service.schedule.TTInfoDetailServiceImpl; | |
| 13 | +import com.bsth.service.StationRouteService; | |
| 14 | +import com.bsth.service.schedule.GuideboardInfoService; | |
| 15 | +import com.bsth.service.schedule.TTInfoDetailService; | |
| 16 | +import com.bsth.service.schedule.utils.DataImportExportService; | |
| 17 | +import jxl.Cell; | |
| 18 | +import jxl.Sheet; | |
| 19 | +import jxl.Workbook; | |
| 20 | +import jxl.write.Label; | |
| 21 | +import jxl.write.WritableSheet; | |
| 22 | +import jxl.write.WritableWorkbook; | |
| 12 | 23 | import org.apache.commons.lang3.StringUtils; |
| 13 | 24 | import org.springframework.beans.factory.annotation.Autowired; |
| 25 | +import org.springframework.util.CollectionUtils; | |
| 14 | 26 | import org.springframework.web.bind.annotation.*; |
| 15 | 27 | import org.springframework.web.multipart.MultipartFile; |
| 16 | 28 | |
| 17 | -import java.util.HashMap; | |
| 18 | -import java.util.Iterator; | |
| 19 | -import java.util.List; | |
| 20 | -import java.util.Map; | |
| 29 | +import java.io.File; | |
| 30 | +import java.util.*; | |
| 31 | +import java.util.regex.Matcher; | |
| 32 | +import java.util.regex.Pattern; | |
| 21 | 33 | |
| 22 | 34 | /** |
| 23 | 35 | * Created by xu on 16/7/2. |
| ... | ... | @@ -26,14 +38,340 @@ import java.util.Map; |
| 26 | 38 | @RequestMapping("tidc") |
| 27 | 39 | public class TTInfoDetailController extends BaseController<TTInfoDetail, Long> { |
| 28 | 40 | @Autowired |
| 29 | - private TTInfoDetailServiceImpl ttInfoDetailService; | |
| 41 | + private TTInfoDetailService ttInfoDetailService; | |
| 30 | 42 | @Autowired |
| 31 | 43 | private CarParkService carParkService; |
| 32 | 44 | @Autowired |
| 33 | 45 | private LineInformationService lineInformationService; |
| 34 | 46 | @Autowired |
| 35 | 47 | private TTInfoDetailRepository ttInfoDetailRepository; |
| 48 | + @Autowired | |
| 49 | + private DataImportExportService dataImportExportService; | |
| 50 | + @Autowired | |
| 51 | + private StationRouteService stationRouteService; | |
| 52 | + @Autowired | |
| 53 | + private GuideboardInfoService guideboardInfoService; | |
| 54 | + | |
| 55 | + | |
| 56 | + public static class ExcelFileOutput { | |
| 57 | + private String fileName; | |
| 58 | + private List<Map<String, Object>> sheetnames = new ArrayList<>(); | |
| 59 | + | |
| 60 | + public String getFileName() { | |
| 61 | + return fileName; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public void setFileName(String fileName) { | |
| 65 | + this.fileName = fileName; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public List<Map<String, Object>> getSheetnames() { | |
| 69 | + return sheetnames; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public void setSheetnames(List<Map<String, Object>> sheetnames) { | |
| 73 | + this.sheetnames = sheetnames; | |
| 74 | + } | |
| 75 | + } | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * 1、上传Excel文件,返回文件全路径名,工作区名称列表。 | |
| 79 | + * @param file | |
| 80 | + * @return | |
| 81 | + * @throws Exception | |
| 82 | + */ | |
| 83 | + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 84 | + public ExcelFileOutput fileUpload(MultipartFile file) throws Exception { | |
| 85 | + // 返回对象 | |
| 86 | + ExcelFileOutput rs = new ExcelFileOutput(); | |
| 87 | + | |
| 88 | + // 上传文件 | |
| 89 | + File file1 = dataImportExportService.uploadFile(file); | |
| 90 | + // 获取文件的sheet | |
| 91 | + Workbook book = Workbook.getWorkbook(file1); | |
| 92 | + for (Sheet sheet : book.getSheets()) { | |
| 93 | + String sheetname = sheet.getName(); | |
| 94 | + Map<String, Object> s = new HashMap<>(); | |
| 95 | + s.put("name", sheetname); | |
| 96 | + rs.getSheetnames().add(s); | |
| 97 | + } | |
| 98 | + | |
| 99 | + rs.setFileName(file1.getAbsolutePath()); | |
| 100 | + return rs; | |
| 101 | + } | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * 2、验证sheet(以后放到规则引擎里去做)。 | |
| 105 | + * @param filename excel文件全路径名 | |
| 106 | + * @param sheetname sheet名字 | |
| 107 | + * @param lineid 线路id | |
| 108 | + * @param linename 线路名称 | |
| 109 | + * @return | |
| 110 | + */ | |
| 111 | + @RequestMapping(value = "/validate/sheet", method = RequestMethod.POST) | |
| 112 | + public Map<String, Object> validateSheet(String filename, String sheetname, Integer lineid, String linename) throws Exception { | |
| 113 | + Map<String, Object> rtn = new HashMap<>(); | |
| 114 | + Workbook book = Workbook.getWorkbook(new File(filename)); | |
| 115 | + Sheet sheet = book.getSheet(sheetname); | |
| 116 | + if (sheet.getRows() == 0 || sheet.getColumns() == 0) { // 工作区是否为空 | |
| 117 | + rtn.put("status", ResponseCode.ERROR); | |
| 118 | + rtn.put("msg", String.format("%s 工作区没有数据!", sheetname)); | |
| 119 | + } else { | |
| 120 | + if (sheet.getRows() <= 1 || sheet.getColumns() <= 1) { | |
| 121 | + rtn.put("status", ResponseCode.ERROR); | |
| 122 | + rtn.put("msg", String.format("工作区至少包含2行2列的数据")); | |
| 123 | + return rtn; | |
| 124 | + } else { | |
| 125 | + Cell[] cells = sheet.getRow(0); // 获取第一行数据列 | |
| 126 | + for (int i = 0; i < cells.length; i++) { | |
| 127 | + String cell_con = cells[i].getContents(); | |
| 128 | + if (StringUtils.isEmpty(cell_con)) { | |
| 129 | + rtn.put("status", ResponseCode.ERROR); | |
| 130 | + rtn.put("msg", String.format("第1行,第%d列数据不能为空", i + 1)); | |
| 131 | + return rtn; | |
| 132 | + } else { | |
| 133 | + if (i == 0) { // 第一列必须是路牌2个字 | |
| 134 | + if (!"路牌".equals(cell_con.trim())) { | |
| 135 | + rtn.put("status", ResponseCode.ERROR); | |
| 136 | + rtn.put("msg", "第1行,第1列数据必须是路牌2个字"); | |
| 137 | + return rtn; | |
| 138 | + } | |
| 139 | + } else { // 排除出场,进场,其余内容到站点路由里查询,以各个方向的起点站为查询依据 | |
| 140 | + if ((!"出场".equals(cell_con.trim())) && | |
| 141 | + (!"进场".equals(cell_con.trim()))) { | |
| 142 | + Map<String, Object> p1 = new HashMap<>(); | |
| 143 | + p1.put("line.id_eq", lineid); | |
| 144 | + p1.put("stationName_eq", cell_con.trim()); | |
| 145 | + p1.put("stationMark_eq", "B"); | |
| 146 | + | |
| 147 | + List<StationRoute> stationRouteList = (List<StationRoute>) stationRouteService.list(p1); | |
| 148 | + if (CollectionUtils.isEmpty(stationRouteList)) { | |
| 149 | + rtn.put("status", ResponseCode.ERROR); | |
| 150 | + rtn.put("msg", String.format("第1行,第%d列数据在%s站点路由中不是起点站", i + 1, linename)); | |
| 151 | + return rtn; | |
| 152 | + } else if (stationRouteList.size() > 1) { | |
| 153 | + rtn.put("status", ResponseCode.ERROR); | |
| 154 | + rtn.put("msg", String.format("第1行,第%d列数据在%s站点路由中上下行都是起点站", i + 1, linename)); | |
| 155 | + return rtn; | |
| 156 | + } | |
| 157 | + } | |
| 158 | + | |
| 159 | + } | |
| 160 | + } | |
| 161 | + } | |
| 162 | + | |
| 163 | + // 验证路牌内容 | |
| 164 | + Map<String, Integer> gbindexmap = new HashMap<>(); // 记录每个路牌在第几行 | |
| 165 | + for (int i = 1; i < sheet.getRows(); i++) { // 从第2行开始验证数据 | |
| 166 | + Cell bcell = sheet.getRow(i)[0]; // 获取第1列 | |
| 167 | + String bcell_con = bcell.getContents(); | |
| 168 | + if (StringUtils.isEmpty(bcell_con)) { | |
| 169 | + rtn.put("status", ResponseCode.ERROR); | |
| 170 | + rtn.put("msg", String.format("第%d行,第1列路牌无数据", i + 1)); | |
| 171 | + return rtn; | |
| 172 | + } else if (gbindexmap.get(bcell_con.trim()) != null) { | |
| 173 | + rtn.put("status", ResponseCode.ERROR); | |
| 174 | + rtn.put("msg", String.format("第%d行,第1列的路牌数据与第%d行,第1列数据重复", | |
| 175 | + i + 1, | |
| 176 | + gbindexmap.get(bcell_con.trim()))); | |
| 177 | + return rtn; | |
| 178 | + } else { | |
| 179 | + Map<String, Object> p2 = new HashMap<>(); | |
| 180 | + p2.put("xl.id_eq", lineid); | |
| 181 | + p2.put("lpName_eq", bcell_con.trim()); | |
| 182 | + List<GuideboardInfo> guideboardInfoList = (List<GuideboardInfo>) guideboardInfoService.list(p2); | |
| 183 | + if (CollectionUtils.isEmpty(guideboardInfoList)) { | |
| 184 | + rtn.put("status", ResponseCode.ERROR); | |
| 185 | + rtn.put("msg", String.format("第%d行,第1列的路牌在%s中不存在", i + 1, linename)); | |
| 186 | + return rtn; | |
| 187 | + } else if (guideboardInfoList.size() > 1) { | |
| 188 | + rtn.put("status", ResponseCode.ERROR); | |
| 189 | + rtn.put("msg", String.format("第%d行,第1列的路牌在%s中重复", i + 1, linename)); | |
| 190 | + return rtn; | |
| 191 | + } else { | |
| 192 | + gbindexmap.put(bcell_con.trim(), i + 1); | |
| 193 | + } | |
| 194 | + } | |
| 195 | + } | |
| 196 | + | |
| 197 | + // 班次时间验证,正则表达式,格式hh:mm或者hhmm | |
| 198 | + String el = "^(([0-1]\\d)|(2[0-4])):[0-5]\\d$"; // hh:mm格式 | |
| 199 | + String el2 = "^(([0-1]\\d)|(2[0-4]))[0-5]\\d$"; // hhmm格式 | |
| 200 | + Pattern p = Pattern.compile(el); | |
| 201 | + Pattern p2 = Pattern.compile(el2); | |
| 202 | + | |
| 203 | + for (int i = 1; i < sheet.getRows(); i++) { // 从第2行开始验证数据 | |
| 204 | + Cell[] bcells = sheet.getRow(i); | |
| 205 | + for (int j = 1; j < bcells.length; j++) { // 从第2列开始 | |
| 206 | + String bcell_con = bcells[j].getContents(); | |
| 207 | + if (StringUtils.isNotEmpty(bcell_con)) { | |
| 208 | + Matcher m = p.matcher(bcell_con.trim()); | |
| 209 | + Matcher m2 = p2.matcher(bcell_con.trim()); | |
| 210 | + if ((!m.matches()) && (!m2.matches())) { | |
| 211 | + rtn.put("status", ResponseCode.ERROR); | |
| 212 | + rtn.put("msg", String.format("第%d行,第%d列的发车时间格式不正确,格式应为hh:mm或hhmm", i + 1, j + 1)); | |
| 213 | + return rtn; | |
| 214 | + } | |
| 215 | + } | |
| 216 | + } | |
| 217 | + } | |
| 218 | + } | |
| 219 | + | |
| 220 | + } | |
| 221 | + | |
| 222 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 223 | + return rtn; | |
| 224 | + } | |
| 225 | + | |
| 226 | + /** | |
| 227 | + * 3、验证关联的线路标准信息(以后放到规则引擎里去做)。 | |
| 228 | + * @param lineinfoid | |
| 229 | + * @return | |
| 230 | + */ | |
| 231 | + @RequestMapping(value = "/validate/lineinfo", method = RequestMethod.GET) | |
| 232 | + public Map<String, Object> validateAssoLineInfo(Integer lineinfoid) { | |
| 233 | + Map<String, Object> rtn = new HashMap<>(); | |
| 234 | + LineInformation lineInformation = lineInformationService.findById(lineinfoid); | |
| 235 | + if (lineInformation.getUpInMileage() == null) { | |
| 236 | + rtn.put("status", ResponseCode.ERROR); | |
| 237 | + rtn.put("msg", "上行进场里程为空"); | |
| 238 | + return rtn; | |
| 239 | + } else if (lineInformation.getUpInTimer() == null) { | |
| 240 | + rtn.put("status", ResponseCode.ERROR); | |
| 241 | + rtn.put("msg", "上行进场时间为空"); | |
| 242 | + return rtn; | |
| 243 | + } else if (lineInformation.getUpOutMileage() == null) { | |
| 244 | + rtn.put("status", ResponseCode.ERROR); | |
| 245 | + rtn.put("msg", "上行出场里程为空"); | |
| 246 | + return rtn; | |
| 247 | + } else if (lineInformation.getUpOutTimer() == null) { | |
| 248 | + rtn.put("status", ResponseCode.ERROR); | |
| 249 | + rtn.put("msg", "上行出场时间为空"); | |
| 250 | + return rtn; | |
| 251 | + } else if (lineInformation.getUpMileage() == null) { | |
| 252 | + rtn.put("status", ResponseCode.ERROR); | |
| 253 | + rtn.put("msg", "上行班次里程为空"); | |
| 254 | + return rtn; | |
| 255 | + } else if (lineInformation.getUpTravelTime() == null) { | |
| 256 | + rtn.put("status", ResponseCode.ERROR); | |
| 257 | + rtn.put("msg", "上行班次时间为空"); | |
| 258 | + return rtn; | |
| 259 | + } else if (lineInformation.getDownInMileage() == null) { | |
| 260 | + rtn.put("status", ResponseCode.ERROR); | |
| 261 | + rtn.put("msg", "下行进场里程为空"); | |
| 262 | + return rtn; | |
| 263 | + } else if (lineInformation.getDownInTimer() == null) { | |
| 264 | + rtn.put("status", ResponseCode.ERROR); | |
| 265 | + rtn.put("msg", "下行进场时间为空"); | |
| 266 | + return rtn; | |
| 267 | + } else if (lineInformation.getDownOutMileage() == null) { | |
| 268 | + rtn.put("status", ResponseCode.ERROR); | |
| 269 | + rtn.put("msg", "下行出场里程为空"); | |
| 270 | + return rtn; | |
| 271 | + } else if (lineInformation.getDownOutTimer() == null) { | |
| 272 | + rtn.put("status", ResponseCode.ERROR); | |
| 273 | + rtn.put("msg", "下行出场时间为空"); | |
| 274 | + return rtn; | |
| 275 | + } else if (lineInformation.getDownMileage() == null) { | |
| 276 | + rtn.put("status", ResponseCode.ERROR); | |
| 277 | + rtn.put("msg", "下行班次里程为空"); | |
| 278 | + return rtn; | |
| 279 | + } else if (lineInformation.getDownTravelTime() == null) { | |
| 280 | + rtn.put("status", ResponseCode.ERROR); | |
| 281 | + rtn.put("msg", "下行班次时间为空"); | |
| 282 | + return rtn; | |
| 283 | + } else if (StringUtils.isEmpty(lineInformation.getCarPark())) { | |
| 284 | + rtn.put("status", ResponseCode.ERROR); | |
| 285 | + rtn.put("msg", "停车场必须选择"); | |
| 286 | + return rtn; | |
| 287 | + } | |
| 288 | + | |
| 289 | + // 单独验证停车场信息 | |
| 290 | + String tcccode = lineInformation.getCarPark(); | |
| 291 | + Map<String, Object> p1 = new HashMap<>(); | |
| 292 | + p1.put("parkCode_eq", tcccode); | |
| 293 | + List<CarPark> carParkList = (List<CarPark>) carParkService.list(p1); | |
| 294 | + if (CollectionUtils.isEmpty(carParkList)) { | |
| 295 | + rtn.put("status", ResponseCode.ERROR); | |
| 296 | + rtn.put("msg", String.format("线路标准里的停车场code=%s,在停车场信息中未找到", tcccode)); | |
| 297 | + return rtn; | |
| 298 | + } else if (carParkList.size() > 1) { | |
| 299 | + rtn.put("status", ResponseCode.ERROR); | |
| 300 | + rtn.put("msg", String.format("线路标准里的停车场code=%s,在停车场信息中有重复数据", tcccode)); | |
| 301 | + return rtn; | |
| 302 | + } else { | |
| 303 | + CarPark carPark = carParkList.get(0); | |
| 304 | + if (StringUtils.isEmpty(carPark.getParkName())) { | |
| 305 | + rtn.put("status", ResponseCode.ERROR); | |
| 306 | + rtn.put("msg", String.format("线路标准里的停车场code=%s,在停车场信息中没有停车场名字", tcccode)); | |
| 307 | + return rtn; | |
| 308 | + } | |
| 309 | + } | |
| 310 | + | |
| 311 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 312 | + return rtn; | |
| 313 | + } | |
| 314 | + | |
| 315 | + /** | |
| 316 | + * 4、导入时刻表明细数据。 | |
| 317 | + * @param form | |
| 318 | + * @return | |
| 319 | + */ | |
| 320 | + @RequestMapping(value = "/importfile", method = RequestMethod.POST) | |
| 321 | + public Map<String, Object> importTTinfo(@RequestParam Map<String, Object> form) throws Exception { | |
| 322 | + Map<String, Object> rtn = new HashMap<>(); | |
| 323 | + | |
| 324 | + // 1、修改已经上传的excel文件,在每个起点站后标示数字,表示第几个班次 | |
| 325 | + // 2、由于格式问题,需要把内容都转换成字符串 | |
| 326 | + String filename = (String) form.get("filename"); | |
| 327 | + List<String> colList = new ArrayList<>(); | |
| 328 | + Workbook workbook = Workbook.getWorkbook(new File(filename)); | |
| 329 | + Sheet sheet = workbook.getSheet((String) form.get("sheetname")); | |
| 330 | + Cell[] cells = sheet.getRow(0); | |
| 331 | + for (int i = 0; i < cells.length; i++) { | |
| 332 | + if (i == 0) { | |
| 333 | + colList.add(cells[i].getContents().trim()); | |
| 334 | + } else { | |
| 335 | + colList.add(cells[i].getContents() + i); | |
| 336 | + } | |
| 337 | + } | |
| 338 | + | |
| 339 | + WritableWorkbook writableWorkbook = Workbook.createWorkbook(new File(filename + "_temp.xls"), workbook); | |
| 340 | + WritableSheet sheet1 = writableWorkbook.getSheet((String) form.get("sheetname")); | |
| 341 | + for (int i = 0; i < sheet1.getColumns(); i++) { // 第一行数据 | |
| 342 | + sheet1.addCell(new Label(i, 0, colList.get(i))); | |
| 343 | + } | |
| 344 | + for (int i = 1; i < sheet1.getRows(); i++) { // 第二行开始 | |
| 345 | + Cell[] cells1 = sheet.getRow(i); | |
| 346 | + for (int j = 0; j < cells1.length; j++) { | |
| 347 | + sheet1.addCell(new Label(j, i, cells1[j].getContents())); | |
| 348 | + } | |
| 349 | + } | |
| 350 | + writableWorkbook.write(); | |
| 351 | + writableWorkbook.close(); | |
| 352 | + | |
| 353 | + // 2、删除原有数据 | |
| 354 | + ttInfoDetailService.deleteByTtinfo(Long.valueOf(form.get("ttid").toString())); | |
| 355 | + | |
| 356 | + // 3、导入时刻表 | |
| 357 | + // 获取停车场名字 | |
| 358 | + LineInformation lineInformation = lineInformationService.findById(Integer.valueOf(form.get("lineinfo").toString())); | |
| 359 | + Map<String, Object> p1 = new HashMap<>(); | |
| 360 | + p1.put("parkCode_eq", lineInformation.getCarPark()); | |
| 361 | + List<CarPark> carParkList = (List<CarPark>) carParkService.list(p1); | |
| 362 | + String tccname = carParkList.get(0).getParkName(); | |
| 363 | + | |
| 364 | + ttInfoDetailService.fileDataImport( | |
| 365 | + new File(filename + "_temp.xls"), | |
| 366 | + (String) form.get("xlname"), | |
| 367 | + (String) form.get("ttname"), | |
| 368 | + tccname | |
| 369 | + ); | |
| 370 | + | |
| 371 | + return rtn; | |
| 372 | + } | |
| 36 | 373 | |
| 374 | + //------------- 旧版本 --------------// | |
| 37 | 375 | @RequestMapping(value = "/dataImportExtend", method = RequestMethod.POST) |
| 38 | 376 | public Map<String, Object> uploadDataAndImport( |
| 39 | 377 | MultipartFile file, String xlmc, String ttinfoname) throws Exception { | ... | ... |
src/main/java/com/bsth/repository/schedule/TTInfoDetailRepository.java
| ... | ... | @@ -7,8 +7,12 @@ import org.springframework.data.domain.Page; |
| 7 | 7 | import org.springframework.data.domain.Pageable; |
| 8 | 8 | import org.springframework.data.jpa.domain.Specification; |
| 9 | 9 | import org.springframework.data.jpa.repository.EntityGraph; |
| 10 | +import org.springframework.data.jpa.repository.Modifying; | |
| 10 | 11 | import org.springframework.data.jpa.repository.Query; |
| 11 | 12 | import org.springframework.stereotype.Repository; |
| 13 | +import org.springframework.transaction.annotation.Isolation; | |
| 14 | +import org.springframework.transaction.annotation.Propagation; | |
| 15 | +import org.springframework.transaction.annotation.Transactional; | |
| 12 | 16 | |
| 13 | 17 | import java.util.List; |
| 14 | 18 | |
| ... | ... | @@ -38,4 +42,8 @@ public interface TTInfoDetailRepository extends BaseRepository<TTInfoDetail, Lon |
| 38 | 42 | @Query(value = "select tt from TTInfoDetail tt where tt.xl.id = ?1 and tt.ttinfo.id = ?2 and tt.lp.id = ?3 order by tt.fcno asc") |
| 39 | 43 | List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId); |
| 40 | 44 | |
| 45 | + @Modifying | |
| 46 | + @Query(value = "delete from TTInfoDetail t where t.ttinfo.id = ?1") | |
| 47 | + void deleteByTtinfo(Long ttinfoid); | |
| 48 | + | |
| 41 | 49 | } | ... | ... |
src/main/java/com/bsth/service/schedule/TTInfoDetailService.java
| ... | ... | @@ -2,9 +2,141 @@ package com.bsth.service.schedule; |
| 2 | 2 | |
| 3 | 3 | import com.bsth.entity.schedule.TTInfoDetail; |
| 4 | 4 | import com.bsth.service.BaseService; |
| 5 | +import org.apache.commons.lang3.StringUtils; | |
| 6 | +import org.springframework.web.multipart.MultipartFile; | |
| 7 | + | |
| 8 | +import java.io.File; | |
| 9 | +import java.util.ArrayList; | |
| 10 | +import java.util.List; | |
| 5 | 11 | |
| 6 | 12 | /** |
| 7 | 13 | * Created by xu on 16/7/2. |
| 8 | 14 | */ |
| 9 | 15 | public interface TTInfoDetailService extends BaseService<TTInfoDetail, Long> { |
| 16 | + | |
| 17 | + void deleteByTtinfo(Long ttinfoid); | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * 发车信息内部类。 | |
| 21 | + */ | |
| 22 | + public static class FcInfo { | |
| 23 | + /** 时刻明细id */ | |
| 24 | + private Long ttdid; | |
| 25 | + /** 发车时间 */ | |
| 26 | + private String fcsj; | |
| 27 | + /** 班次类型 */ | |
| 28 | + private String bc_type; | |
| 29 | + /** 线路上下行 */ | |
| 30 | + private String xldir; | |
| 31 | + /** 是偶分班 */ | |
| 32 | + private Boolean isfb; | |
| 33 | + | |
| 34 | + public FcInfo() { | |
| 35 | + } | |
| 36 | + | |
| 37 | + public FcInfo(String ttdid_str, String bc_type, String fcsj, String xldir, String isfb) { | |
| 38 | + this.ttdid = StringUtils.isEmpty(ttdid_str) ? null : Long.valueOf(ttdid_str); | |
| 39 | + this.bc_type = bc_type; | |
| 40 | + this.fcsj = fcsj; | |
| 41 | + this.xldir = xldir; | |
| 42 | + if ("N".equals(isfb)) | |
| 43 | + this.isfb = false; | |
| 44 | + else if ("Y".equals(isfb)) | |
| 45 | + this.isfb = true; | |
| 46 | + else | |
| 47 | + this.isfb = false; | |
| 48 | + | |
| 49 | + } | |
| 50 | + | |
| 51 | + public Long getTtdid() { | |
| 52 | + return ttdid; | |
| 53 | + } | |
| 54 | + | |
| 55 | + public void setTtdid(Long ttdid) { | |
| 56 | + this.ttdid = ttdid; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public String getFcsj() { | |
| 60 | + return fcsj; | |
| 61 | + } | |
| 62 | + | |
| 63 | + public void setFcsj(String fcsj) { | |
| 64 | + this.fcsj = fcsj; | |
| 65 | + } | |
| 66 | + | |
| 67 | + public String getBc_type() { | |
| 68 | + return bc_type; | |
| 69 | + } | |
| 70 | + | |
| 71 | + public void setBc_type(String bc_type) { | |
| 72 | + this.bc_type = bc_type; | |
| 73 | + } | |
| 74 | + | |
| 75 | + public String getXldir() { | |
| 76 | + return xldir; | |
| 77 | + } | |
| 78 | + | |
| 79 | + public void setXldir(String xldir) { | |
| 80 | + this.xldir = xldir; | |
| 81 | + } | |
| 82 | + | |
| 83 | + public Boolean getIsfb() { | |
| 84 | + return isfb; | |
| 85 | + } | |
| 86 | + | |
| 87 | + public void setIsfb(Boolean isfb) { | |
| 88 | + this.isfb = isfb; | |
| 89 | + } | |
| 90 | + } | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * 时刻表编辑用的返回数据。 | |
| 94 | + */ | |
| 95 | + public static class EditInfo { | |
| 96 | + /** 标题数据 */ | |
| 97 | + private List<String> header = new ArrayList<>(); | |
| 98 | + /** 内容数据 */ | |
| 99 | + private List<List<FcInfo>> contents = new ArrayList<>(); | |
| 100 | + | |
| 101 | + public List<String> getHeader() { | |
| 102 | + return header; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setHeader(List<String> header) { | |
| 106 | + this.header = header; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public List<List<FcInfo>> getContents() { | |
| 110 | + return contents; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void setContents(List<List<FcInfo>> contents) { | |
| 114 | + this.contents = contents; | |
| 115 | + } | |
| 116 | + } | |
| 117 | + | |
| 118 | + /** | |
| 119 | + * 获取待编辑的数据。 | |
| 120 | + * @param xlid 线路id | |
| 121 | + * @param ttid 时刻表id | |
| 122 | + * @return | |
| 123 | + */ | |
| 124 | + EditInfo getEditInfo(Integer xlid, Long ttid) throws Exception; | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * 上传并导入数据,和DataImportExportService的同名方法有差别。 | |
| 128 | + * @param datafile form上传文件 | |
| 129 | + * @param xlmc 线路名称 | |
| 130 | + * @param ttinfoname 时刻表名字 | |
| 131 | + * @param tccname 停车场名字 | |
| 132 | + * @throws Exception | |
| 133 | + */ | |
| 134 | + void fileDataImport(MultipartFile datafile, | |
| 135 | + String xlmc, | |
| 136 | + String ttinfoname, | |
| 137 | + String tccname) throws Exception; | |
| 138 | + | |
| 139 | + void fileDataImport(File file, String xlmc, String ttinfoname, String tccname) throws Exception; | |
| 140 | + | |
| 141 | + | |
| 10 | 142 | } | ... | ... |
src/main/java/com/bsth/service/schedule/TTInfoDetailServiceImpl.java
| ... | ... | @@ -14,6 +14,9 @@ import org.pentaho.di.trans.TransMeta; |
| 14 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | 15 | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
| 16 | 16 | import org.springframework.stereotype.Service; |
| 17 | +import org.springframework.transaction.annotation.Isolation; | |
| 18 | +import org.springframework.transaction.annotation.Propagation; | |
| 19 | +import org.springframework.transaction.annotation.Transactional; | |
| 17 | 20 | import org.springframework.web.multipart.MultipartFile; |
| 18 | 21 | |
| 19 | 22 | import java.io.File; |
| ... | ... | @@ -34,103 +37,10 @@ public class TTInfoDetailServiceImpl extends BaseServiceImpl<TTInfoDetail, Long> |
| 34 | 37 | @Autowired |
| 35 | 38 | private TTInfoDetailRepository ttInfoDetailRepository; |
| 36 | 39 | |
| 37 | - /** | |
| 38 | - * 发车信息内部类。 | |
| 39 | - */ | |
| 40 | - public static class FcInfo { | |
| 41 | - /** 时刻明细id */ | |
| 42 | - private Long ttdid; | |
| 43 | - /** 发车时间 */ | |
| 44 | - private String fcsj; | |
| 45 | - /** 班次类型 */ | |
| 46 | - private String bc_type; | |
| 47 | - /** 线路上下行 */ | |
| 48 | - private String xldir; | |
| 49 | - /** 是偶分班 */ | |
| 50 | - private Boolean isfb; | |
| 51 | - | |
| 52 | - public FcInfo() { | |
| 53 | - } | |
| 54 | - | |
| 55 | - public FcInfo(String ttdid_str, String bc_type, String fcsj, String xldir, String isfb) { | |
| 56 | - this.ttdid = StringUtils.isEmpty(ttdid_str) ? null : Long.valueOf(ttdid_str); | |
| 57 | - this.bc_type = bc_type; | |
| 58 | - this.fcsj = fcsj; | |
| 59 | - this.xldir = xldir; | |
| 60 | - if ("N".equals(isfb)) | |
| 61 | - this.isfb = false; | |
| 62 | - else if ("Y".equals(isfb)) | |
| 63 | - this.isfb = true; | |
| 64 | - else | |
| 65 | - this.isfb = false; | |
| 66 | - | |
| 67 | - } | |
| 68 | - | |
| 69 | - public Long getTtdid() { | |
| 70 | - return ttdid; | |
| 71 | - } | |
| 72 | - | |
| 73 | - public void setTtdid(Long ttdid) { | |
| 74 | - this.ttdid = ttdid; | |
| 75 | - } | |
| 76 | - | |
| 77 | - public String getFcsj() { | |
| 78 | - return fcsj; | |
| 79 | - } | |
| 80 | - | |
| 81 | - public void setFcsj(String fcsj) { | |
| 82 | - this.fcsj = fcsj; | |
| 83 | - } | |
| 84 | - | |
| 85 | - public String getBc_type() { | |
| 86 | - return bc_type; | |
| 87 | - } | |
| 88 | - | |
| 89 | - public void setBc_type(String bc_type) { | |
| 90 | - this.bc_type = bc_type; | |
| 91 | - } | |
| 92 | - | |
| 93 | - public String getXldir() { | |
| 94 | - return xldir; | |
| 95 | - } | |
| 96 | - | |
| 97 | - public void setXldir(String xldir) { | |
| 98 | - this.xldir = xldir; | |
| 99 | - } | |
| 100 | - | |
| 101 | - public Boolean getIsfb() { | |
| 102 | - return isfb; | |
| 103 | - } | |
| 104 | - | |
| 105 | - public void setIsfb(Boolean isfb) { | |
| 106 | - this.isfb = isfb; | |
| 107 | - } | |
| 108 | - } | |
| 109 | - | |
| 110 | - /** | |
| 111 | - * 时刻表编辑用的返回数据。 | |
| 112 | - */ | |
| 113 | - public static class EditInfo { | |
| 114 | - /** 标题数据 */ | |
| 115 | - private List<String> header = new ArrayList<>(); | |
| 116 | - /** 内容数据 */ | |
| 117 | - private List<List<FcInfo>> contents = new ArrayList<>(); | |
| 118 | - | |
| 119 | - public List<String> getHeader() { | |
| 120 | - return header; | |
| 121 | - } | |
| 122 | - | |
| 123 | - public void setHeader(List<String> header) { | |
| 124 | - this.header = header; | |
| 125 | - } | |
| 126 | - | |
| 127 | - public List<List<FcInfo>> getContents() { | |
| 128 | - return contents; | |
| 129 | - } | |
| 130 | - | |
| 131 | - public void setContents(List<List<FcInfo>> contents) { | |
| 132 | - this.contents = contents; | |
| 133 | - } | |
| 40 | + @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) | |
| 41 | + @Override | |
| 42 | + public void deleteByTtinfo(Long ttinfoid) { | |
| 43 | + ttInfoDetailRepository.deleteByTtinfo(ttinfoid); | |
| 134 | 44 | } |
| 135 | 45 | |
| 136 | 46 | /** |
| ... | ... | @@ -139,6 +49,7 @@ public class TTInfoDetailServiceImpl extends BaseServiceImpl<TTInfoDetail, Long> |
| 139 | 49 | * @param ttid 时刻表id |
| 140 | 50 | * @return |
| 141 | 51 | */ |
| 52 | + @Override | |
| 142 | 53 | public EditInfo getEditInfo(Integer xlid, Long ttid) throws Exception { |
| 143 | 54 | // 1、使用ktr转换获取输出文件 |
| 144 | 55 | // 1.1、获取转换用ktr |
| ... | ... | @@ -215,9 +126,15 @@ public class TTInfoDetailServiceImpl extends BaseServiceImpl<TTInfoDetail, Long> |
| 215 | 126 | String xlmc, |
| 216 | 127 | String ttinfoname, |
| 217 | 128 | String tccname) throws Exception { |
| 218 | - // 1、上传数据文件 | |
| 129 | + // 上传数据文件 | |
| 219 | 130 | File uploadFile = dataImportExportService.uploadFile(datafile); |
| 131 | + fileDataImport(uploadFile, xlmc, ttinfoname, tccname); | |
| 220 | 132 | |
| 133 | + } | |
| 134 | + | |
| 135 | + @Override | |
| 136 | + public void fileDataImport(File uploadFile, String xlmc, String ttinfoname, String tccname) throws Exception { | |
| 137 | + // 1、上传数据文件 | |
| 221 | 138 | System.out.println("线路名称:" + xlmc); |
| 222 | 139 | System.out.println("时刻表名称:" + ttinfoname); |
| 223 | 140 | System.out.println("停车场名字:" + tccname); | ... | ... |
src/main/resources/static/pages/scheduleApp/Gruntfile.js
| ... | ... | @@ -64,7 +64,8 @@ module.exports = function (grunt) { |
| 64 | 64 | }, |
| 65 | 65 | src: [ |
| 66 | 66 | 'module/common/dts1/load/loadingWidget.js', // loading界面指令 |
| 67 | - 'module/common/dts1/validation/remoteValidaton.js',// 服务端验证指令 | |
| 67 | + 'module/common/dts1/validation/remoteValidation.js',// 服务端验证指令 | |
| 68 | + 'module/common/dts1/validation/remoteValidationt2.js',// 服务端验证指令(时刻表专用) | |
| 68 | 69 | 'module/common/dts1/select/saSelect.js', // select整合指令1 |
| 69 | 70 | 'module/common/dts1/select/saSelect2.js', // select整合指令2 |
| 70 | 71 | 'module/common/dts1/select/saSelect3.js', // select整合指令3 | ... | ... |
src/main/resources/static/pages/scheduleApp/module/basicInfo/busInfoManage/list.html
| ... | ... | @@ -88,8 +88,8 @@ |
| 88 | 88 | <td> |
| 89 | 89 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 90 | 90 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 91 | - <a ui-sref="busInfoManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | |
| 92 | - <a ui-sref="busInfoManage_edit({id: info.id})" class="btn default blue-stripe btn-sm"> 修改 </a> | |
| 91 | + <a ui-sref="busInfoManage_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a> | |
| 92 | + <a ui-sref="busInfoManage_edit({id: info.id})" class="btn btn-info btn-sm"> 修改 </a> | |
| 93 | 93 | </td> |
| 94 | 94 | </tr> |
| 95 | 95 | </tbody> | ... | ... |
src/main/resources/static/pages/scheduleApp/module/basicInfo/deviceInfoManage/list.html
| ... | ... | @@ -84,10 +84,10 @@ |
| 84 | 84 | <td> |
| 85 | 85 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 86 | 86 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 87 | - <a ui-sref="deviceInfoManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | |
| 88 | - <a ui-sref="deviceInfoManage_edit({id: info.id})" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | |
| 89 | - <a ng-click="ctrl.toggleCde(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | |
| 90 | - <a ng-click="ctrl.toggleCde(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | |
| 87 | + <a ui-sref="deviceInfoManage_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a> | |
| 88 | + <a ui-sref="deviceInfoManage_edit({id: info.id})" class="btn btn-info btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | |
| 89 | + <a ng-click="ctrl.toggleCde(info.id)" class="btn btn-danger btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | |
| 90 | + <a ng-click="ctrl.toggleCde(info.id)" class="btn btn-success btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | |
| 91 | 91 | </td> |
| 92 | 92 | </tr> |
| 93 | 93 | </tbody> | ... | ... |
src/main/resources/static/pages/scheduleApp/module/basicInfo/employeeInfoManage/list.html
| ... | ... | @@ -94,8 +94,8 @@ |
| 94 | 94 | <td> |
| 95 | 95 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 96 | 96 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 97 | - <a ui-sref="employeeInfoManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | |
| 98 | - <a ui-sref="employeeInfoManage_edit({id: info.id})" class="btn default blue-stripe btn-sm"> 修改 </a> | |
| 97 | + <a ui-sref="employeeInfoManage_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a> | |
| 98 | + <a ui-sref="employeeInfoManage_edit({id: info.id})" class="btn btn-info btn-sm"> 修改 </a> | |
| 99 | 99 | </td> |
| 100 | 100 | </tr> |
| 101 | 101 | </tbody> | ... | ... |
src/main/resources/static/pages/scheduleApp/module/common/dts1/select/saSelect5.js
| ... | ... | @@ -333,6 +333,25 @@ angular.module('ScheduleApp').directive('saSelect5', [ |
| 333 | 333 | }; |
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | + * 内部方法,读取本地动态数据源。 | |
| 337 | + * @param ldata | |
| 338 | + */ | |
| 339 | + scope[ctrlAs].$$internal_local_data = function(ldata) { | |
| 340 | + // 重新创建内部保存的数据 | |
| 341 | + scope[ctrlAs].$$data_real = []; | |
| 342 | + // 重新创建内部ui-select显示用数据,默认取10条记录显示 | |
| 343 | + scope[ctrlAs].$$data = []; | |
| 344 | + | |
| 345 | + // 本地动态数据直接显示,暂时不优化 | |
| 346 | + for (var i = 0; i < ldata.length; i++) { | |
| 347 | + scope[ctrlAs].$$data_real.push(ldata[i]); | |
| 348 | + scope[ctrlAs].$$data.push(ldata[i]); | |
| 349 | + } | |
| 350 | + | |
| 351 | + scope[ctrlAs].$$internal_validate_model(); | |
| 352 | + }; | |
| 353 | + | |
| 354 | + /** | |
| 336 | 355 | * 监控dsparams属性变化 |
| 337 | 356 | */ |
| 338 | 357 | attr.$observe("dsparams", function(value) { |
| ... | ... | @@ -348,6 +367,8 @@ angular.module('ScheduleApp').directive('saSelect5', [ |
| 348 | 367 | |
| 349 | 368 | } else if (obj.type == 'ajax') { |
| 350 | 369 | scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param); |
| 370 | + } else if (obj.type == 'local') { | |
| 371 | + scope[ctrlAs].$$internal_local_data(obj.ldata); | |
| 351 | 372 | } else { |
| 352 | 373 | throw new Error("dsparams参数格式异常=" + obj); |
| 353 | 374 | } | ... | ... |
src/main/resources/static/pages/scheduleApp/module/common/dts1/upload/saFileupload.js
0 → 100644
src/main/resources/static/pages/scheduleApp/module/common/dts1/upload/saFileuploadTemplate.html
0 → 100644
| 1 | +<div class="input-group"> | |
| 2 | + <input type="file" name="file" id="file"/> | |
| 3 | + | |
| 4 | + <input type="file" class="form-control" nv-file-select="" uploader="ctrl.uploader"/> | |
| 5 | + <span class="input-group-btn"> | |
| 6 | + <button type="button" ng-click="ctrl.clearInputFile()" class="btn btn-default"> | |
| 7 | + <span class="glyphicon glyphicon-trash"></span> | |
| 8 | + </button> | |
| 9 | + <button type="button" class="btn btn-success"> | |
| 10 | + <span class="glyphicon glyphicon-upload"></span> 上传 | |
| 11 | + </button> | |
| 12 | + </span> | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | +</div> | |
| 0 | 18 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/scheduleApp/module/common/dts1/validation/remoteValidaton.js renamed to src/main/resources/static/pages/scheduleApp/module/common/dts1/validation/remoteValidation.js
src/main/resources/static/pages/scheduleApp/module/common/dts1/validation/remoteValidationt2.js
0 → 100644
| 1 | +/** | |
| 2 | + * remoteValidatiot2指令,远程数据验证验证,作为属性放在某个指令上,依赖与指令的ngModel(专门用于时刻表sheet验证)。 | |
| 3 | + * 属性如下: | |
| 4 | + * remotevtype(必须):验证类型(在service中有对应映射),如rvtype="xl" | |
| 5 | + * remotevparam(必须):后端判定查询参数,如rvparam={{ {'xl.id_eq': '123'} | json }} | |
| 6 | + * | |
| 7 | + */ | |
| 8 | +angular.module('ScheduleApp').directive('remoteValidationt2', [ | |
| 9 | + '$$SearchInfoService_g', | |
| 10 | + function($$SearchInfoService_g) { | |
| 11 | + return { | |
| 12 | + restrict: "A", // 属性 | |
| 13 | + require: "^ngModel", // 依赖所属指令的ngModel | |
| 14 | + compile: function(tElem, tAttrs) { | |
| 15 | + // 验证属性 | |
| 16 | + if (!tAttrs["remotevtype"]) { // 验证类型 | |
| 17 | + throw new Error("remotevtype属性必须填写"); | |
| 18 | + } else if (!$$SearchInfoService_g.validate[tAttrs["remotevtype"]]) { | |
| 19 | + throw new Error(!tAttrs["remotevtype"] + "验证类型不存在"); | |
| 20 | + } | |
| 21 | + if (!tAttrs["remotevparam"]) { // 查询参数 | |
| 22 | + throw new Error("remotevparam属性必须填写"); | |
| 23 | + } | |
| 24 | + | |
| 25 | + // 监听获取的数据 | |
| 26 | + var $watch_rvtype = undefined; | |
| 27 | + var $watch_rvparam_obj = undefined; | |
| 28 | + | |
| 29 | + // 验证数据 | |
| 30 | + var $$internal_validate = function(ngModelCtrl, scope) { | |
| 31 | + if ($watch_rvtype && $watch_rvparam_obj) { | |
| 32 | + // 获取查询参数模版 | |
| 33 | + var paramTemplate = $$SearchInfoService_g.validate[$watch_rvtype].template; | |
| 34 | + if (!paramTemplate) { | |
| 35 | + throw new Error($watch_rvtype + "查询模版不存在"); | |
| 36 | + } | |
| 37 | + // 判定如果参数对象不全,没有完全和模版参数里对应上,则不验证 | |
| 38 | + var isParamAll = true; | |
| 39 | + for (var key in paramTemplate) { | |
| 40 | + if (!$watch_rvparam_obj[key]) { | |
| 41 | + isParamAll = false; | |
| 42 | + break; | |
| 43 | + } | |
| 44 | + } | |
| 45 | + if (!isParamAll) { | |
| 46 | + ngModelCtrl.$setValidity('remote', true); | |
| 47 | + } else { // 开始验证 | |
| 48 | + $$SearchInfoService_g.validate[$watch_rvtype].remote.do( | |
| 49 | + $watch_rvparam_obj, | |
| 50 | + function(result) { | |
| 51 | + if (result.status == "SUCCESS") { | |
| 52 | + ngModelCtrl.$setValidity('remote', true); | |
| 53 | + } else { | |
| 54 | + ngModelCtrl.$setValidity('remote', false); | |
| 55 | + scope.ctrl.ttInfoDetailManageForForm.sheetvaliddesc = result.msg; | |
| 56 | + } | |
| 57 | + }, | |
| 58 | + function(result) { | |
| 59 | + alert("出错拉"); | |
| 60 | + ngModelCtrl.$setValidity('remote', true); | |
| 61 | + } | |
| 62 | + ); | |
| 63 | + } | |
| 64 | + } | |
| 65 | + }; | |
| 66 | + | |
| 67 | + return { | |
| 68 | + pre: function(scope, element, attr) { | |
| 69 | + | |
| 70 | + }, | |
| 71 | + | |
| 72 | + post: function(scope, element, attr, ngModelCtrl) { | |
| 73 | + /** | |
| 74 | + * 监控验证类型属性变化。 | |
| 75 | + */ | |
| 76 | + attr.$observe("remotevtype", function(value) { | |
| 77 | + if (value && value != "") { | |
| 78 | + $watch_rvtype = value; | |
| 79 | + $$internal_validate(ngModelCtrl, scope); | |
| 80 | + } | |
| 81 | + }); | |
| 82 | + /** | |
| 83 | + * 监控查询结果属性变化。 | |
| 84 | + */ | |
| 85 | + attr.$observe("remotevparam", function(value) { | |
| 86 | + if (value && value != "") { | |
| 87 | + //if (!ngModelCtrl.$dirty) { // 没有修改过模型数据,不验证 | |
| 88 | + // return; | |
| 89 | + //} | |
| 90 | + $watch_rvparam_obj = JSON.parse(value); | |
| 91 | + $$internal_validate(ngModelCtrl, scope); | |
| 92 | + } | |
| 93 | + }); | |
| 94 | + } | |
| 95 | + }; | |
| 96 | + } | |
| 97 | + } | |
| 98 | + } | |
| 99 | +]); | ... | ... |
src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
| 1 | -//自定义指令 | |
| 2 | -/** | |
| 3 | - * loading载入中指令。 | |
| 4 | - */ | |
| 5 | -angular.module('ScheduleApp').directive('loadingWidget', ['requestNotificationChannel', function(requestNotificationChannel) { | |
| 6 | - return { | |
| 7 | - restrict: 'A', | |
| 8 | - link: function(scope, element) { | |
| 9 | - // 初始隐藏loading界面 | |
| 10 | - element.hide(); | |
| 11 | - | |
| 12 | - // 开始请求通知处理 | |
| 13 | - requestNotificationChannel.onRequestStarted(scope, function() { | |
| 14 | - element.show(); | |
| 15 | - }); | |
| 16 | - // 请求结束通知处理 | |
| 17 | - requestNotificationChannel.onRequestEnded(scope, function() { | |
| 18 | - element.hide(); | |
| 19 | - }); | |
| 20 | - } | |
| 21 | - }; | |
| 1 | +//自定义指令 | |
| 2 | +/** | |
| 3 | + * loading载入中指令。 | |
| 4 | + */ | |
| 5 | +angular.module('ScheduleApp').directive('loadingWidget', ['requestNotificationChannel', function(requestNotificationChannel) { | |
| 6 | + return { | |
| 7 | + restrict: 'A', | |
| 8 | + link: function(scope, element) { | |
| 9 | + // 初始隐藏loading界面 | |
| 10 | + element.hide(); | |
| 11 | + | |
| 12 | + // 开始请求通知处理 | |
| 13 | + requestNotificationChannel.onRequestStarted(scope, function() { | |
| 14 | + element.show(); | |
| 15 | + }); | |
| 16 | + // 请求结束通知处理 | |
| 17 | + requestNotificationChannel.onRequestEnded(scope, function() { | |
| 18 | + element.hide(); | |
| 19 | + }); | |
| 20 | + } | |
| 21 | + }; | |
| 22 | 22 | }]); |
| 23 | +/** | |
| 24 | + * remoteValidation指令,远程数据验证验证,作为属性放在某个指令上,依赖与指令的ngModel。 | |
| 25 | + * 属性如下: | |
| 26 | + * remotevtype(必须):验证类型(在service中有对应映射),如rvtype="xl" | |
| 27 | + * remotevparam(必须):后端判定查询参数,如rvparam={{ {'xl.id_eq': '123'} | json }} | |
| 28 | + * | |
| 29 | + */ | |
| 30 | +angular.module('ScheduleApp').directive('remoteValidation', [ | |
| 31 | + '$$SearchInfoService_g', | |
| 32 | + function($$SearchInfoService_g) { | |
| 33 | + return { | |
| 34 | + restrict: "A", // 属性 | |
| 35 | + require: "^ngModel", // 依赖所属指令的ngModel | |
| 36 | + compile: function(tElem, tAttrs) { | |
| 37 | + // 验证属性 | |
| 38 | + if (!tAttrs["remotevtype"]) { // 验证类型 | |
| 39 | + throw new Error("remotevtype属性必须填写"); | |
| 40 | + } else if (!$$SearchInfoService_g.validate[tAttrs["remotevtype"]]) { | |
| 41 | + throw new Error(!tAttrs["remotevtype"] + "验证类型不存在"); | |
| 42 | + } | |
| 43 | + if (!tAttrs["remotevparam"]) { // 查询参数 | |
| 44 | + throw new Error("remotevparam属性必须填写"); | |
| 45 | + } | |
| 46 | + | |
| 47 | + // 监听获取的数据 | |
| 48 | + var $watch_rvtype = undefined; | |
| 49 | + var $watch_rvparam_obj = undefined; | |
| 50 | + | |
| 51 | + // 验证数据 | |
| 52 | + var $$internal_validate = function(ngModelCtrl) { | |
| 53 | + if ($watch_rvtype && $watch_rvparam_obj) { | |
| 54 | + // 获取查询参数模版 | |
| 55 | + var paramTemplate = $$SearchInfoService_g.validate[$watch_rvtype].template; | |
| 56 | + if (!paramTemplate) { | |
| 57 | + throw new Error($watch_rvtype + "查询模版不存在"); | |
| 58 | + } | |
| 59 | + // 判定如果参数对象不全,没有完全和模版参数里对应上,则不验证 | |
| 60 | + var isParamAll = true; | |
| 61 | + for (var key in paramTemplate) { | |
| 62 | + if (!$watch_rvparam_obj[key]) { | |
| 63 | + isParamAll = false; | |
| 64 | + break; | |
| 65 | + } | |
| 66 | + } | |
| 67 | + if (!isParamAll) { | |
| 68 | + ngModelCtrl.$setValidity('remote', true); | |
| 69 | + } else { // 开始验证 | |
| 70 | + $$SearchInfoService_g.validate[$watch_rvtype].remote.do( | |
| 71 | + $watch_rvparam_obj, | |
| 72 | + function(result) { | |
| 73 | + if (result.status == "SUCCESS") { | |
| 74 | + ngModelCtrl.$setValidity('remote', true); | |
| 75 | + } else { | |
| 76 | + ngModelCtrl.$setValidity('remote', false); | |
| 77 | + } | |
| 78 | + }, | |
| 79 | + function(result) { | |
| 80 | + ngModelCtrl.$setValidity('remote', true); | |
| 81 | + } | |
| 82 | + ); | |
| 83 | + } | |
| 84 | + } | |
| 85 | + }; | |
| 86 | + | |
| 87 | + return { | |
| 88 | + pre: function(scope, element, attr) { | |
| 89 | + | |
| 90 | + }, | |
| 91 | + | |
| 92 | + post: function(scope, element, attr, ngModelCtrl) { | |
| 93 | + /** | |
| 94 | + * 监控验证类型属性变化。 | |
| 95 | + */ | |
| 96 | + attr.$observe("remotevtype", function(value) { | |
| 97 | + if (value && value != "") { | |
| 98 | + $watch_rvtype = value; | |
| 99 | + $$internal_validate(ngModelCtrl); | |
| 100 | + } | |
| 101 | + }); | |
| 102 | + /** | |
| 103 | + * 监控查询结果属性变化。 | |
| 104 | + */ | |
| 105 | + attr.$observe("remotevparam", function(value) { | |
| 106 | + if (value && value != "") { | |
| 107 | + if (!ngModelCtrl.$dirty) { // 没有修改过模型数据,不验证 | |
| 108 | + return; | |
| 109 | + } | |
| 110 | + $watch_rvparam_obj = JSON.parse(value); | |
| 111 | + $$internal_validate(ngModelCtrl); | |
| 112 | + } | |
| 113 | + }); | |
| 114 | + } | |
| 115 | + }; | |
| 116 | + } | |
| 117 | + } | |
| 118 | + } | |
| 119 | +]); | |
| 120 | + | |
| 23 | 121 | /** |
| 24 | - * remoteValidatio指令,远程数据验证验证,作为属性放在某个指令上,依赖与指令的ngModel。 | |
| 122 | + * remoteValidatiot2指令,远程数据验证验证,作为属性放在某个指令上,依赖与指令的ngModel(专门用于时刻表sheet验证)。 | |
| 25 | 123 | * 属性如下: |
| 26 | 124 | * remotevtype(必须):验证类型(在service中有对应映射),如rvtype="xl" |
| 27 | 125 | * remotevparam(必须):后端判定查询参数,如rvparam={{ {'xl.id_eq': '123'} | json }} |
| 28 | 126 | * |
| 29 | 127 | */ |
| 30 | -angular.module('ScheduleApp').directive('remoteValidation', [ | |
| 128 | +angular.module('ScheduleApp').directive('remoteValidationt2', [ | |
| 31 | 129 | '$$SearchInfoService_g', |
| 32 | 130 | function($$SearchInfoService_g) { |
| 33 | 131 | return { |
| ... | ... | @@ -49,7 +147,7 @@ angular.module('ScheduleApp').directive('remoteValidation', [ |
| 49 | 147 | var $watch_rvparam_obj = undefined; |
| 50 | 148 | |
| 51 | 149 | // 验证数据 |
| 52 | - var $$internal_validate = function(ngModelCtrl) { | |
| 150 | + var $$internal_validate = function(ngModelCtrl, scope) { | |
| 53 | 151 | if ($watch_rvtype && $watch_rvparam_obj) { |
| 54 | 152 | // 获取查询参数模版 |
| 55 | 153 | var paramTemplate = $$SearchInfoService_g.validate[$watch_rvtype].template; |
| ... | ... | @@ -74,9 +172,11 @@ angular.module('ScheduleApp').directive('remoteValidation', [ |
| 74 | 172 | ngModelCtrl.$setValidity('remote', true); |
| 75 | 173 | } else { |
| 76 | 174 | ngModelCtrl.$setValidity('remote', false); |
| 175 | + scope.ctrl.ttInfoDetailManageForForm.sheetvaliddesc = result.msg; | |
| 77 | 176 | } |
| 78 | 177 | }, |
| 79 | 178 | function(result) { |
| 179 | + alert("出错拉"); | |
| 80 | 180 | ngModelCtrl.$setValidity('remote', true); |
| 81 | 181 | } |
| 82 | 182 | ); |
| ... | ... | @@ -96,7 +196,7 @@ angular.module('ScheduleApp').directive('remoteValidation', [ |
| 96 | 196 | attr.$observe("remotevtype", function(value) { |
| 97 | 197 | if (value && value != "") { |
| 98 | 198 | $watch_rvtype = value; |
| 99 | - $$internal_validate(ngModelCtrl); | |
| 199 | + $$internal_validate(ngModelCtrl, scope); | |
| 100 | 200 | } |
| 101 | 201 | }); |
| 102 | 202 | /** |
| ... | ... | @@ -104,11 +204,11 @@ angular.module('ScheduleApp').directive('remoteValidation', [ |
| 104 | 204 | */ |
| 105 | 205 | attr.$observe("remotevparam", function(value) { |
| 106 | 206 | if (value && value != "") { |
| 107 | - if (!ngModelCtrl.$dirty) { // 没有修改过模型数据,不验证 | |
| 108 | - return; | |
| 109 | - } | |
| 207 | + //if (!ngModelCtrl.$dirty) { // 没有修改过模型数据,不验证 | |
| 208 | + // return; | |
| 209 | + //} | |
| 110 | 210 | $watch_rvparam_obj = JSON.parse(value); |
| 111 | - $$internal_validate(ngModelCtrl); | |
| 211 | + $$internal_validate(ngModelCtrl, scope); | |
| 112 | 212 | } |
| 113 | 213 | }); |
| 114 | 214 | } |
| ... | ... | @@ -118,3123 +218,3144 @@ angular.module('ScheduleApp').directive('remoteValidation', [ |
| 118 | 218 | } |
| 119 | 219 | ]); |
| 120 | 220 | |
| 121 | - | |
| 122 | -angular.module('ScheduleApp').directive("saSelect", ['$timeout', function($timeout) { | |
| 123 | - return { | |
| 124 | - restrict: 'E', | |
| 125 | - templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelectTemplate.html', | |
| 126 | - scope: { | |
| 127 | - model: "=" | |
| 128 | - }, | |
| 129 | - controllerAs: "$saSelectCtrl", | |
| 130 | - bindToController: true, | |
| 131 | - controller: function() { | |
| 132 | - var self = this; | |
| 133 | - self.datas = []; // 关联的字典数据,内部格式 {code:{值},name:{名字}} | |
| 134 | - }, | |
| 135 | - /** | |
| 136 | - * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 137 | - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 138 | - * @param tElem | |
| 139 | - * @param tAttrs | |
| 140 | - * @returns {{pre: Function, post: Function}} | |
| 141 | - */ | |
| 142 | - compile: function(tElem, tAttrs) { | |
| 143 | - // 确定是否使用angularjs required验证 | |
| 144 | - // 属性 required | |
| 145 | - // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加 | |
| 146 | - var required_attr = tAttrs["required"]; | |
| 147 | - if (required_attr) { | |
| 148 | - if (required_attr == "true") { | |
| 149 | - // 添加required属性指令 | |
| 150 | - tElem.find("ui-select").attr("required", ""); | |
| 151 | - } else { | |
| 152 | - // 不等于true,不添加required属性指令 | |
| 153 | - } | |
| 154 | - } else { | |
| 155 | - // 不添加required属性指令 | |
| 156 | - } | |
| 157 | - | |
| 158 | - //console.log("saSelect" + ":compile = >" + tElem.html()); | |
| 159 | - | |
| 160 | - return { | |
| 161 | - pre: function(scope, element, attr) { | |
| 162 | - // TODO: | |
| 163 | - }, | |
| 164 | - /** | |
| 165 | - * 相当于link函数。 | |
| 166 | - * | |
| 167 | - * 重要属性如下: | |
| 168 | - * model 是绑定外部值。 | |
| 169 | - * dicgroup 字典组的类型 | |
| 170 | - * name input name属性值 | |
| 171 | - */ | |
| 172 | - post: function(scope, element, attr) { | |
| 173 | - // 1、获取属性 | |
| 174 | - var dicgroup_attr = attr['dicgroup']; // 字典组的类型 | |
| 175 | - var name_attr = attr['name']; // input name属性值 | |
| 176 | - var dicname_attr = attr['dicname']; // model关联的字典名字段 | |
| 177 | - var codename_attr = attr['codename']; // model关联的字典值字段 | |
| 178 | - var placeholder_attr = attr['placeholder']; // select placeholder提示 | |
| 179 | - | |
| 180 | - // 系统的字典对象,使用dictionaryUtils类获取 | |
| 181 | - var origin_dicgroup; | |
| 182 | - var dic_key; // 字典key | |
| 183 | - | |
| 184 | - if (dicgroup_attr) { // 赋值指定的字典数据 | |
| 185 | - origin_dicgroup = dictionaryUtils.getByGroup(dicgroup_attr); | |
| 186 | - for (dic_key in origin_dicgroup) { | |
| 187 | - var data = {}; // 重新组合的字典元素对象 | |
| 188 | - if (dic_key == "true") | |
| 189 | - data.code = true; | |
| 190 | - else | |
| 191 | - data.code = dic_key; | |
| 192 | - data.name = origin_dicgroup[dic_key]; | |
| 193 | - scope["$saSelectCtrl"].datas.push(data); | |
| 194 | - } | |
| 195 | - } | |
| 196 | - | |
| 197 | - if (name_attr) { | |
| 198 | - scope["$saSelectCtrl"].nv = name_attr; | |
| 199 | - } | |
| 200 | - if (placeholder_attr) { | |
| 201 | - scope["$saSelectCtrl"].ph = placeholder_attr; | |
| 202 | - } | |
| 203 | - | |
| 204 | - scope["$saSelectCtrl"].select = function($item) { | |
| 205 | - if (codename_attr) { | |
| 206 | - scope["$saSelectCtrl"].model[codename_attr] = $item.code; | |
| 207 | - } | |
| 208 | - if (dicname_attr) { | |
| 209 | - scope["$saSelectCtrl"].model[dicname_attr] = $item.name; | |
| 210 | - } | |
| 211 | - }; | |
| 212 | - | |
| 213 | - scope["$saSelectCtrl"].remove = function() { | |
| 214 | - if (codename_attr) { | |
| 215 | - scope["$saSelectCtrl"].model[codename_attr] = null; | |
| 216 | - } | |
| 217 | - if (dicname_attr) { | |
| 218 | - scope["$saSelectCtrl"].model[dicname_attr] = null; | |
| 219 | - } | |
| 220 | - scope["$saSelectCtrl"].cmodel = null; | |
| 221 | - }; | |
| 222 | - | |
| 223 | - $timeout(function() { | |
| 224 | - // 创建内部使用的绑定对象 | |
| 225 | - var model_code = scope["$saSelectCtrl"].model[codename_attr]; | |
| 226 | - scope["$saSelectCtrl"].cmodel = model_code; | |
| 227 | - }, 0); | |
| 228 | - } | |
| 229 | - } | |
| 230 | - } | |
| 231 | - }; | |
| 232 | -}]); | |
| 233 | - | |
| 234 | - | |
| 235 | - | |
| 236 | -angular.module('ScheduleApp').directive("saSelect2", [ | |
| 237 | - '$timeout', '$$SearchInfoService_g', | |
| 238 | - function($timeout, $$searchInfoService_g) { | |
| 239 | - return { | |
| 240 | - restrict: 'E', | |
| 241 | - templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect2Template.html', | |
| 242 | - scope: { | |
| 243 | - model: "=" // 独立作用域,关联外部的模型对象 | |
| 244 | - }, | |
| 245 | - controllerAs: "$saSelectCtrl", | |
| 246 | - bindToController: true, | |
| 247 | - controller: function($scope) { | |
| 248 | - var self = this; | |
| 249 | - self.$$data = []; // 内部关联的数据 | |
| 250 | - }, | |
| 251 | - /** | |
| 252 | - * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 253 | - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 254 | - * @param tElem | |
| 255 | - * @param tAttrs | |
| 256 | - * @returns {{pre: Function, post: Function}} | |
| 257 | - */ | |
| 258 | - compile: function(tElem, tAttrs) { | |
| 259 | - // 1、获取此阶段使用的属性 | |
| 260 | - var $required_attr = tAttrs["required"]; // 用于和表单验证连接,指定成required="true"才有效。 | |
| 261 | - | |
| 262 | - // 2、处理属性 | |
| 263 | - | |
| 264 | - // 确定是否使用angularjs required验证 | |
| 265 | - // 属性 required | |
| 266 | - // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加 | |
| 267 | - if ($required_attr) { | |
| 268 | - if ($required_attr == "true") { | |
| 269 | - // 添加required属性指令 | |
| 270 | - tElem.find("ui-select").attr("required", ""); | |
| 271 | - } else { | |
| 272 | - // 不等于true,不添加required属性指令 | |
| 273 | - } | |
| 274 | - } else { | |
| 275 | - // 不添加required属性指令 | |
| 276 | - } | |
| 277 | - | |
| 278 | - //console.log("saSelect" + ":compile = >" + tElem.html()); | |
| 279 | - | |
| 280 | - return { | |
| 281 | - pre: function(scope, element, attr) { | |
| 282 | - // TODO: | |
| 283 | - }, | |
| 284 | - /** | |
| 285 | - * 相当于link函数。 | |
| 286 | - * | |
| 287 | - * 重要属性如下: | |
| 288 | - * model 是绑定外部值。 | |
| 289 | - * dicgroup 字典组的类型 | |
| 290 | - * name input name属性值 | |
| 291 | - */ | |
| 292 | - post: function(scope, element, attr) { | |
| 293 | - // 1、获取此阶段使用的属性 | |
| 294 | - var $name_attr = attr["name"]; // 表单验证时需要的名字 | |
| 295 | - var $type_attr = attr["type"]; // 关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加 | |
| 296 | - var $modelcolname1_attr = attr["modelcolname1"]; // 关联的模型字段名字1(一般应该是编码字段) | |
| 297 | - var $modelcolname2_attr = attr["modelcolname2"]; // 关联的模型字段名字2(一般应该是名字字段) | |
| 298 | - var $datacolname1_attr = attr["datacolname1"]; // 内部数据对应的字段名字1(与模型字段1对应) | |
| 299 | - var $datacolname2_attr = attr["datacolname2"]; // 内部数据对应的字段名字2(与模型字段2对应) | |
| 300 | - var $showcolname_attr = attr["showcolname"]; // 下拉框显示的内部数据字段名 | |
| 301 | - var $placeholder_attr = attr["placeholder"]; // select placeholder字符串描述 | |
| 302 | - | |
| 303 | - // 2、处理属性、转换成$saSelectCtrl内部使用的属性 | |
| 304 | - if ($name_attr) { | |
| 305 | - scope["$saSelectCtrl"].$name_attr = $name_attr; | |
| 306 | - } | |
| 307 | - if ($placeholder_attr) { | |
| 308 | - scope["$saSelectCtrl"].$placeholder_attr = $placeholder_attr; | |
| 309 | - } | |
| 310 | - if ($showcolname_attr) { | |
| 311 | - scope["$saSelectCtrl"].$showcolname_attr = $showcolname_attr; | |
| 312 | - } | |
| 313 | - | |
| 314 | - // 2-1、添加内部方法,根据type值,改变$$data的值 | |
| 315 | - scope["$saSelectCtrl"].$$internal_data_change_fn = function() { | |
| 316 | - // 根据type属性动态载入数据 | |
| 317 | - if ($type_attr) { | |
| 318 | - $$searchInfoService_g[$type_attr].list( | |
| 319 | - {type: "all"}, | |
| 320 | - function(result) { | |
| 321 | - scope["$saSelectCtrl"].$$data = []; | |
| 322 | - for (var i = 0; i < result.length; i ++) { | |
| 323 | - var data = {}; // data是result的一部分属性集合,根据配置来确定 | |
| 324 | - if ($datacolname1_attr) { | |
| 325 | - data[$datacolname1_attr] = result[i][$datacolname1_attr]; | |
| 326 | - } | |
| 327 | - if ($datacolname2_attr) { | |
| 328 | - data[$datacolname2_attr] = result[i][$datacolname2_attr]; | |
| 329 | - } | |
| 330 | - if ($showcolname_attr) { | |
| 331 | - // 动态添加基于名字的拼音 | |
| 332 | - data[$showcolname_attr] = result[i][$showcolname_attr]; | |
| 333 | - if (data[$showcolname_attr]) { | |
| 334 | - data["fullChars"] = pinyin.getFullChars(result[i][$showcolname_attr]).toUpperCase(); // 全拼 | |
| 335 | - data["camelChars"] = pinyin.getCamelChars(result[i][$showcolname_attr]); // 简拼 | |
| 336 | - } | |
| 337 | - } | |
| 338 | - if (data["fullChars"]) | |
| 339 | - scope["$saSelectCtrl"].$$data.push(data); | |
| 340 | - } | |
| 341 | - }, | |
| 342 | - function(result) { | |
| 343 | - | |
| 344 | - } | |
| 345 | - ); | |
| 346 | - } | |
| 347 | - }; | |
| 348 | - | |
| 349 | - // 3、选择、删除事件映射模型和内部数据对应的字段 | |
| 350 | - scope["$saSelectCtrl"].$select_fn_attr = function($item) { | |
| 351 | - if ($modelcolname1_attr && $datacolname1_attr) { | |
| 352 | - scope["$saSelectCtrl"].model[$modelcolname1_attr] = $item[$datacolname1_attr]; | |
| 353 | - } | |
| 354 | - if ($modelcolname2_attr && $datacolname2_attr) { | |
| 355 | - scope["$saSelectCtrl"].model[$modelcolname2_attr] = $item[$datacolname2_attr]; | |
| 356 | - } | |
| 357 | - }; | |
| 358 | - scope["$saSelectCtrl"].$remove_fn_attr = function() { | |
| 359 | - if ($modelcolname1_attr) { | |
| 360 | - scope["$saSelectCtrl"].model[$modelcolname1_attr] = null; | |
| 361 | - } | |
| 362 | - if ($modelcolname2_attr) { | |
| 363 | - scope["$saSelectCtrl"].model[$modelcolname2_attr] = null; | |
| 364 | - } | |
| 365 | - scope["$saSelectCtrl"].$$cmodel = null; // 内部模型清空 | |
| 366 | - | |
| 367 | - scope["$saSelectCtrl"].$$internal_data_change_fn(); | |
| 368 | - }; | |
| 369 | - | |
| 370 | - // 4、搜索事件 | |
| 371 | - scope["$saSelectCtrl"].$refreshdata_fn_attr = function($search) { | |
| 372 | - //var fullChars = pinyin.getFullChars($search).toUpperCase(); | |
| 373 | - //var camelChars = pinyin.getCamelChars($search); | |
| 374 | - // | |
| 375 | - //console.log(fullChars + " " + camelChars); | |
| 376 | - // TODO:事件暂时没用,放着以后再说 | |
| 377 | - }; | |
| 378 | - | |
| 379 | - // 5、全部载入后,输入的 | |
| 380 | - $timeout(function() { | |
| 381 | - // 创建内部使用的绑定对象,用于确认选中那个值 | |
| 382 | - scope["$saSelectCtrl"].$$cmodel = scope["$saSelectCtrl"].model[$modelcolname1_attr]; | |
| 383 | - | |
| 384 | - scope["$saSelectCtrl"].$$internal_data_change_fn(); | |
| 385 | - }, 0); | |
| 386 | - } | |
| 387 | - } | |
| 388 | - } | |
| 389 | - }; | |
| 390 | - } | |
| 221 | + | |
| 222 | +angular.module('ScheduleApp').directive("saSelect", ['$timeout', function($timeout) { | |
| 223 | + return { | |
| 224 | + restrict: 'E', | |
| 225 | + templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelectTemplate.html', | |
| 226 | + scope: { | |
| 227 | + model: "=" | |
| 228 | + }, | |
| 229 | + controllerAs: "$saSelectCtrl", | |
| 230 | + bindToController: true, | |
| 231 | + controller: function() { | |
| 232 | + var self = this; | |
| 233 | + self.datas = []; // 关联的字典数据,内部格式 {code:{值},name:{名字}} | |
| 234 | + }, | |
| 235 | + /** | |
| 236 | + * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 237 | + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 238 | + * @param tElem | |
| 239 | + * @param tAttrs | |
| 240 | + * @returns {{pre: Function, post: Function}} | |
| 241 | + */ | |
| 242 | + compile: function(tElem, tAttrs) { | |
| 243 | + // 确定是否使用angularjs required验证 | |
| 244 | + // 属性 required | |
| 245 | + // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加 | |
| 246 | + var required_attr = tAttrs["required"]; | |
| 247 | + if (required_attr) { | |
| 248 | + if (required_attr == "true") { | |
| 249 | + // 添加required属性指令 | |
| 250 | + tElem.find("ui-select").attr("required", ""); | |
| 251 | + } else { | |
| 252 | + // 不等于true,不添加required属性指令 | |
| 253 | + } | |
| 254 | + } else { | |
| 255 | + // 不添加required属性指令 | |
| 256 | + } | |
| 257 | + | |
| 258 | + //console.log("saSelect" + ":compile = >" + tElem.html()); | |
| 259 | + | |
| 260 | + return { | |
| 261 | + pre: function(scope, element, attr) { | |
| 262 | + // TODO: | |
| 263 | + }, | |
| 264 | + /** | |
| 265 | + * 相当于link函数。 | |
| 266 | + * | |
| 267 | + * 重要属性如下: | |
| 268 | + * model 是绑定外部值。 | |
| 269 | + * dicgroup 字典组的类型 | |
| 270 | + * name input name属性值 | |
| 271 | + */ | |
| 272 | + post: function(scope, element, attr) { | |
| 273 | + // 1、获取属性 | |
| 274 | + var dicgroup_attr = attr['dicgroup']; // 字典组的类型 | |
| 275 | + var name_attr = attr['name']; // input name属性值 | |
| 276 | + var dicname_attr = attr['dicname']; // model关联的字典名字段 | |
| 277 | + var codename_attr = attr['codename']; // model关联的字典值字段 | |
| 278 | + var placeholder_attr = attr['placeholder']; // select placeholder提示 | |
| 279 | + | |
| 280 | + // 系统的字典对象,使用dictionaryUtils类获取 | |
| 281 | + var origin_dicgroup; | |
| 282 | + var dic_key; // 字典key | |
| 283 | + | |
| 284 | + if (dicgroup_attr) { // 赋值指定的字典数据 | |
| 285 | + origin_dicgroup = dictionaryUtils.getByGroup(dicgroup_attr); | |
| 286 | + for (dic_key in origin_dicgroup) { | |
| 287 | + var data = {}; // 重新组合的字典元素对象 | |
| 288 | + if (dic_key == "true") | |
| 289 | + data.code = true; | |
| 290 | + else | |
| 291 | + data.code = dic_key; | |
| 292 | + data.name = origin_dicgroup[dic_key]; | |
| 293 | + scope["$saSelectCtrl"].datas.push(data); | |
| 294 | + } | |
| 295 | + } | |
| 296 | + | |
| 297 | + if (name_attr) { | |
| 298 | + scope["$saSelectCtrl"].nv = name_attr; | |
| 299 | + } | |
| 300 | + if (placeholder_attr) { | |
| 301 | + scope["$saSelectCtrl"].ph = placeholder_attr; | |
| 302 | + } | |
| 303 | + | |
| 304 | + scope["$saSelectCtrl"].select = function($item) { | |
| 305 | + if (codename_attr) { | |
| 306 | + scope["$saSelectCtrl"].model[codename_attr] = $item.code; | |
| 307 | + } | |
| 308 | + if (dicname_attr) { | |
| 309 | + scope["$saSelectCtrl"].model[dicname_attr] = $item.name; | |
| 310 | + } | |
| 311 | + }; | |
| 312 | + | |
| 313 | + scope["$saSelectCtrl"].remove = function() { | |
| 314 | + if (codename_attr) { | |
| 315 | + scope["$saSelectCtrl"].model[codename_attr] = null; | |
| 316 | + } | |
| 317 | + if (dicname_attr) { | |
| 318 | + scope["$saSelectCtrl"].model[dicname_attr] = null; | |
| 319 | + } | |
| 320 | + scope["$saSelectCtrl"].cmodel = null; | |
| 321 | + }; | |
| 322 | + | |
| 323 | + $timeout(function() { | |
| 324 | + // 创建内部使用的绑定对象 | |
| 325 | + var model_code = scope["$saSelectCtrl"].model[codename_attr]; | |
| 326 | + scope["$saSelectCtrl"].cmodel = model_code; | |
| 327 | + }, 0); | |
| 328 | + } | |
| 329 | + } | |
| 330 | + } | |
| 331 | + }; | |
| 332 | +}]); | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | +angular.module('ScheduleApp').directive("saSelect2", [ | |
| 337 | + '$timeout', '$$SearchInfoService_g', | |
| 338 | + function($timeout, $$searchInfoService_g) { | |
| 339 | + return { | |
| 340 | + restrict: 'E', | |
| 341 | + templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect2Template.html', | |
| 342 | + scope: { | |
| 343 | + model: "=" // 独立作用域,关联外部的模型对象 | |
| 344 | + }, | |
| 345 | + controllerAs: "$saSelectCtrl", | |
| 346 | + bindToController: true, | |
| 347 | + controller: function($scope) { | |
| 348 | + var self = this; | |
| 349 | + self.$$data = []; // 内部关联的数据 | |
| 350 | + }, | |
| 351 | + /** | |
| 352 | + * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 353 | + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 354 | + * @param tElem | |
| 355 | + * @param tAttrs | |
| 356 | + * @returns {{pre: Function, post: Function}} | |
| 357 | + */ | |
| 358 | + compile: function(tElem, tAttrs) { | |
| 359 | + // 1、获取此阶段使用的属性 | |
| 360 | + var $required_attr = tAttrs["required"]; // 用于和表单验证连接,指定成required="true"才有效。 | |
| 361 | + | |
| 362 | + // 2、处理属性 | |
| 363 | + | |
| 364 | + // 确定是否使用angularjs required验证 | |
| 365 | + // 属性 required | |
| 366 | + // 如果没有填写,内部不添加验证,如果填写了,并且等于true添加验证,否则不添加 | |
| 367 | + if ($required_attr) { | |
| 368 | + if ($required_attr == "true") { | |
| 369 | + // 添加required属性指令 | |
| 370 | + tElem.find("ui-select").attr("required", ""); | |
| 371 | + } else { | |
| 372 | + // 不等于true,不添加required属性指令 | |
| 373 | + } | |
| 374 | + } else { | |
| 375 | + // 不添加required属性指令 | |
| 376 | + } | |
| 377 | + | |
| 378 | + //console.log("saSelect" + ":compile = >" + tElem.html()); | |
| 379 | + | |
| 380 | + return { | |
| 381 | + pre: function(scope, element, attr) { | |
| 382 | + // TODO: | |
| 383 | + }, | |
| 384 | + /** | |
| 385 | + * 相当于link函数。 | |
| 386 | + * | |
| 387 | + * 重要属性如下: | |
| 388 | + * model 是绑定外部值。 | |
| 389 | + * dicgroup 字典组的类型 | |
| 390 | + * name input name属性值 | |
| 391 | + */ | |
| 392 | + post: function(scope, element, attr) { | |
| 393 | + // 1、获取此阶段使用的属性 | |
| 394 | + var $name_attr = attr["name"]; // 表单验证时需要的名字 | |
| 395 | + var $type_attr = attr["type"]; // 关联的那种数据值(xl/cl/ry)-> 对应线路信息/车辆信息/人员信息,后面有的继续加 | |
| 396 | + var $modelcolname1_attr = attr["modelcolname1"]; // 关联的模型字段名字1(一般应该是编码字段) | |
| 397 | + var $modelcolname2_attr = attr["modelcolname2"]; // 关联的模型字段名字2(一般应该是名字字段) | |
| 398 | + var $datacolname1_attr = attr["datacolname1"]; // 内部数据对应的字段名字1(与模型字段1对应) | |
| 399 | + var $datacolname2_attr = attr["datacolname2"]; // 内部数据对应的字段名字2(与模型字段2对应) | |
| 400 | + var $showcolname_attr = attr["showcolname"]; // 下拉框显示的内部数据字段名 | |
| 401 | + var $placeholder_attr = attr["placeholder"]; // select placeholder字符串描述 | |
| 402 | + | |
| 403 | + // 2、处理属性、转换成$saSelectCtrl内部使用的属性 | |
| 404 | + if ($name_attr) { | |
| 405 | + scope["$saSelectCtrl"].$name_attr = $name_attr; | |
| 406 | + } | |
| 407 | + if ($placeholder_attr) { | |
| 408 | + scope["$saSelectCtrl"].$placeholder_attr = $placeholder_attr; | |
| 409 | + } | |
| 410 | + if ($showcolname_attr) { | |
| 411 | + scope["$saSelectCtrl"].$showcolname_attr = $showcolname_attr; | |
| 412 | + } | |
| 413 | + | |
| 414 | + // 2-1、添加内部方法,根据type值,改变$$data的值 | |
| 415 | + scope["$saSelectCtrl"].$$internal_data_change_fn = function() { | |
| 416 | + // 根据type属性动态载入数据 | |
| 417 | + if ($type_attr) { | |
| 418 | + $$searchInfoService_g[$type_attr].list( | |
| 419 | + {type: "all"}, | |
| 420 | + function(result) { | |
| 421 | + scope["$saSelectCtrl"].$$data = []; | |
| 422 | + for (var i = 0; i < result.length; i ++) { | |
| 423 | + var data = {}; // data是result的一部分属性集合,根据配置来确定 | |
| 424 | + if ($datacolname1_attr) { | |
| 425 | + data[$datacolname1_attr] = result[i][$datacolname1_attr]; | |
| 426 | + } | |
| 427 | + if ($datacolname2_attr) { | |
| 428 | + data[$datacolname2_attr] = result[i][$datacolname2_attr]; | |
| 429 | + } | |
| 430 | + if ($showcolname_attr) { | |
| 431 | + // 动态添加基于名字的拼音 | |
| 432 | + data[$showcolname_attr] = result[i][$showcolname_attr]; | |
| 433 | + if (data[$showcolname_attr]) { | |
| 434 | + data["fullChars"] = pinyin.getFullChars(result[i][$showcolname_attr]).toUpperCase(); // 全拼 | |
| 435 | + data["camelChars"] = pinyin.getCamelChars(result[i][$showcolname_attr]); // 简拼 | |
| 436 | + } | |
| 437 | + } | |
| 438 | + if (data["fullChars"]) | |
| 439 | + scope["$saSelectCtrl"].$$data.push(data); | |
| 440 | + } | |
| 441 | + }, | |
| 442 | + function(result) { | |
| 443 | + | |
| 444 | + } | |
| 445 | + ); | |
| 446 | + } | |
| 447 | + }; | |
| 448 | + | |
| 449 | + // 3、选择、删除事件映射模型和内部数据对应的字段 | |
| 450 | + scope["$saSelectCtrl"].$select_fn_attr = function($item) { | |
| 451 | + if ($modelcolname1_attr && $datacolname1_attr) { | |
| 452 | + scope["$saSelectCtrl"].model[$modelcolname1_attr] = $item[$datacolname1_attr]; | |
| 453 | + } | |
| 454 | + if ($modelcolname2_attr && $datacolname2_attr) { | |
| 455 | + scope["$saSelectCtrl"].model[$modelcolname2_attr] = $item[$datacolname2_attr]; | |
| 456 | + } | |
| 457 | + }; | |
| 458 | + scope["$saSelectCtrl"].$remove_fn_attr = function() { | |
| 459 | + if ($modelcolname1_attr) { | |
| 460 | + scope["$saSelectCtrl"].model[$modelcolname1_attr] = null; | |
| 461 | + } | |
| 462 | + if ($modelcolname2_attr) { | |
| 463 | + scope["$saSelectCtrl"].model[$modelcolname2_attr] = null; | |
| 464 | + } | |
| 465 | + scope["$saSelectCtrl"].$$cmodel = null; // 内部模型清空 | |
| 466 | + | |
| 467 | + scope["$saSelectCtrl"].$$internal_data_change_fn(); | |
| 468 | + }; | |
| 469 | + | |
| 470 | + // 4、搜索事件 | |
| 471 | + scope["$saSelectCtrl"].$refreshdata_fn_attr = function($search) { | |
| 472 | + //var fullChars = pinyin.getFullChars($search).toUpperCase(); | |
| 473 | + //var camelChars = pinyin.getCamelChars($search); | |
| 474 | + // | |
| 475 | + //console.log(fullChars + " " + camelChars); | |
| 476 | + // TODO:事件暂时没用,放着以后再说 | |
| 477 | + }; | |
| 478 | + | |
| 479 | + // 5、全部载入后,输入的 | |
| 480 | + $timeout(function() { | |
| 481 | + // 创建内部使用的绑定对象,用于确认选中那个值 | |
| 482 | + scope["$saSelectCtrl"].$$cmodel = scope["$saSelectCtrl"].model[$modelcolname1_attr]; | |
| 483 | + | |
| 484 | + scope["$saSelectCtrl"].$$internal_data_change_fn(); | |
| 485 | + }, 0); | |
| 486 | + } | |
| 487 | + } | |
| 488 | + } | |
| 489 | + }; | |
| 490 | + } | |
| 491 | +]); | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | +/** | |
| 498 | + * saSelect3指令 | |
| 499 | + * 属性如下: | |
| 500 | + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 501 | + * name(必须):控件的名字 | |
| 502 | + * placeholder(可选):占位符字符串 | |
| 503 | + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 504 | + * dcname(必须):绑定的model字段名,如:dcname=xl.id | |
| 505 | + * icname(必须):内部与之对应的字段名,如:icname=code | |
| 506 | + * dcname2(可选):其他需要赋值的model字段名2,如:dcname2=xl.name | |
| 507 | + * icname2(可选):内部与之对应的字段名2,如:icname2=name | |
| 508 | + * dcname3(可选):其他需要赋值的model字段名3,如:dcname2=xl.name | |
| 509 | + * icname3(可选):内部与之对应的字段名3,如:icname2=name | |
| 510 | + * icnames(必须):用于用于显示,以及简评处理的内部数据字段,如:icnames=name | |
| 511 | + * required(可选):是否要用required验证 | |
| 512 | + * datatype(必须):业务数据类型,有字典类型,动态数据类型,暂时写的死点 | |
| 513 | + * mlp(可选):是否多级属性(这里假设外部model如果多级,内部model也是多级) | |
| 514 | + * | |
| 515 | + * 高级属性: | |
| 516 | + * dataassociate(可选):数据源是否关联属性(内部数据随外部指定的参数变化而变化) | |
| 517 | + * dataparam(可选):数据源关联的外部参数对象 | |
| 518 | + * | |
| 519 | + */ | |
| 520 | +angular.module('ScheduleApp').directive("saSelect3", [ | |
| 521 | + '$timeout', | |
| 522 | + '$$SearchInfoService_g', | |
| 523 | + function($timeout, $$searchInfoService_g) { | |
| 524 | + return { | |
| 525 | + restrict: 'E', | |
| 526 | + templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect3Template.html', | |
| 527 | + scope: { | |
| 528 | + model: "=" // 独立作用域,关联外部的模型object | |
| 529 | + }, | |
| 530 | + controllerAs: "$saSelectCtrl", | |
| 531 | + bindToController: true, | |
| 532 | + controller: function($scope) { | |
| 533 | + var self = this; | |
| 534 | + self.$$data = []; // ui-select显示用的数据源 | |
| 535 | + self.$$data_real= []; // 内部真实的数据源 | |
| 536 | + }, | |
| 537 | + | |
| 538 | + /** | |
| 539 | + * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 540 | + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 541 | + * @param tElem | |
| 542 | + * @param tAttrs | |
| 543 | + * @returns {{pre: Function, post: Function}} | |
| 544 | + */ | |
| 545 | + compile: function(tElem, tAttrs) { | |
| 546 | + // 获取所有的属性 | |
| 547 | + var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 548 | + var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字 | |
| 549 | + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名 | |
| 550 | + var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名 | |
| 551 | + var $dcname2_attr = tAttrs["dcname2"]; // 其他需要赋值的model字段名2 | |
| 552 | + var $icname2_attr = tAttrs["icname2"]; // 内部与之对应的字段名2 | |
| 553 | + var $dcname3_attr = tAttrs["dcname3"]; // 其他需要赋值的model字段名3 | |
| 554 | + var $icname3_attr = tAttrs["icname3"]; // 内部与之对应的字段名3 | |
| 555 | + | |
| 556 | + var $icname_s_attr = tAttrs["icnames"]; // 用于用于显示,以及简评处理的内部数据字段 | |
| 557 | + var $datatype_attr = tAttrs["datatype"]; // 内部业务数据类型 | |
| 558 | + var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 559 | + var $mlp_attr = tAttrs["mlp"]; // 是否多级属性 | |
| 560 | + var $dataassociate_attr = tAttrs["dataassociate"]; // 数据源是否关联属性 | |
| 561 | + | |
| 562 | + // controlAs名字 | |
| 563 | + var ctrlAs = "$saSelectCtrl"; | |
| 564 | + | |
| 565 | + // 数据源初始化标志 | |
| 566 | + var $$data_init = false; | |
| 567 | + // 如果有required属性,添加angularjs required验证 | |
| 568 | + if ($required_attr != undefined) { | |
| 569 | + tElem.find("ui-select").attr("required", ""); | |
| 570 | + } | |
| 571 | + | |
| 572 | + // 由于有的属性是多级的如xl.name,所以要在compile阶段重写属性绑定属性定义 | |
| 573 | + // 原来的设置:{{$select.selected[$saSelectCtrl.$icname_s]}} | |
| 574 | + tElem.find("ui-select-match").html("{{$select.selected" + "." + $icname_s_attr + "}}"); | |
| 575 | + // 原来的设置:item[$saSelectCtrl.$icname] as item in $saSelectCtrl.$$data | |
| 576 | + tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data"); | |
| 577 | + // 原来的设置:item[$saSelectCtrl.$icname_s] | |
| 578 | + tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $icname_s_attr); | |
| 579 | + // 原来的设置:{{$saSelectCtrl.$name}} | |
| 580 | + tElem.find("ui-select").attr("name", $name_attr); | |
| 581 | + // 原来的设置:{{$saSelectCtrl.$placeholder}} | |
| 582 | + tElem.find("ui-select-match").attr("placeholder", $placeholder_attr); | |
| 583 | + | |
| 584 | + return { | |
| 585 | + pre: function(scope, element, attr) { | |
| 586 | + // TODO: | |
| 587 | + }, | |
| 588 | + /** | |
| 589 | + * 相当于link函数。 | |
| 590 | + * @param scope | |
| 591 | + * @param element | |
| 592 | + * @param attr | |
| 593 | + */ | |
| 594 | + post: function(scope, element, attr) { | |
| 595 | + // 添加选中事件处理函数 | |
| 596 | + scope[ctrlAs].$$internal_select_fn = function($item) { | |
| 597 | + if ($dcname_attr && $icname_attr) { | |
| 598 | + if ($mlp_attr) { | |
| 599 | + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";"); | |
| 600 | + } else { | |
| 601 | + scope[ctrlAs].model[$dcname_attr] = $item[$icname_attr]; | |
| 602 | + } | |
| 603 | + } | |
| 604 | + if ($dcname2_attr && $icname2_attr) { | |
| 605 | + if ($mlp_attr) { | |
| 606 | + eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = $item" + "." + $icname2_attr + ";"); | |
| 607 | + } else { | |
| 608 | + scope[ctrlAs].model[$dcname2_attr] = $item[$icname2_attr]; | |
| 609 | + } | |
| 610 | + } | |
| 611 | + if ($dcname3_attr && $icname3_attr) { | |
| 612 | + if ($mlp_attr) { | |
| 613 | + eval("scope[ctrlAs].model" + "." + $dcname3_attr + " = $item" + "." + $icname3_attr + ";"); | |
| 614 | + } else { | |
| 615 | + scope[ctrlAs].model[$dcname3_attr] = $item[$icname3_attr]; | |
| 616 | + } | |
| 617 | + } | |
| 618 | + }; | |
| 619 | + | |
| 620 | + // 删除选中事件处理函数 | |
| 621 | + scope[ctrlAs].$$internal_remove_fn = function() { | |
| 622 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 623 | + if ($mlp_attr) { | |
| 624 | + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;"); | |
| 625 | + } else { | |
| 626 | + scope[ctrlAs].model[$dcname_attr] = undefined; | |
| 627 | + } | |
| 628 | + | |
| 629 | + if ($dcname2_attr) { | |
| 630 | + if ($mlp_attr) { | |
| 631 | + eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = undefined;"); | |
| 632 | + } else { | |
| 633 | + scope[ctrlAs].model[$dcname2_attr] = undefined; | |
| 634 | + } | |
| 635 | + } | |
| 636 | + if ($dcname3_attr) { | |
| 637 | + if ($mlp_attr) { | |
| 638 | + eval("scope[ctrlAs].model" + "." + $dcname3_attr + " = undefined;"); | |
| 639 | + } else { | |
| 640 | + scope[ctrlAs].model[$dcname3_attr] = undefined; | |
| 641 | + } | |
| 642 | + } | |
| 643 | + }; | |
| 644 | + | |
| 645 | + /** | |
| 646 | + * 内部方法,读取字典数据作为数据源。 | |
| 647 | + * @param dicgroup 字典类型,如:gsType | |
| 648 | + * @param ccol 代码字段名 | |
| 649 | + * @param ncol 名字字段名 | |
| 650 | + */ | |
| 651 | + scope[ctrlAs].$$internal_dic_data = function(dicgroup, ccol, ncol) { | |
| 652 | + var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup); | |
| 653 | + var dic_key; // 字典key | |
| 654 | + // 清空内部数据 | |
| 655 | + scope[ctrlAs].$$data_real = []; | |
| 656 | + for (dic_key in origin_dicgroup) { | |
| 657 | + var data = {}; // 重新组合的字典元素对象 | |
| 658 | + if (dic_key == "true") | |
| 659 | + data[ccol] = true; | |
| 660 | + else | |
| 661 | + data[ccol] = dic_key; | |
| 662 | + data[ncol] = origin_dicgroup[dic_key]; | |
| 663 | + scope[ctrlAs].$$data_real.push(data); | |
| 664 | + } | |
| 665 | + // 这里直接将$$data_real数据深拷贝到$$data | |
| 666 | + angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data); | |
| 667 | + | |
| 668 | + console.log(scope[ctrlAs].$$data); | |
| 669 | + }; | |
| 670 | + | |
| 671 | + /** | |
| 672 | + * TODO:这个方法有性能问题,result一多就会卡一卡,之后再解决把 | |
| 673 | + * 内部方法,读取字典数据作为数据源。 | |
| 674 | + * @param result 原始数据 | |
| 675 | + * @param dcvalue 传入的关联数据 | |
| 676 | + */ | |
| 677 | + scope[ctrlAs].$$internal_other_data = function(result, dcvalue) { | |
| 678 | + console.log("start=" + dcvalue); | |
| 679 | + // 清空内部数据 | |
| 680 | + scope[ctrlAs].$$data_real = []; | |
| 681 | + scope[ctrlAs].$$data = []; | |
| 682 | + for (var i = 0; i < result.length; i ++) { | |
| 683 | + if ($icname_s_attr) { | |
| 684 | + if ($mlp_attr) { | |
| 685 | + if (eval("result[i]" + "." + $icname_s_attr)) { | |
| 686 | + // 全拼 | |
| 687 | + result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $icname_s_attr)).toUpperCase(); | |
| 688 | + // 简拼 | |
| 689 | + result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $icname_s_attr)); | |
| 690 | + } | |
| 691 | + } else { | |
| 692 | + if (result[i][$icname_s_attr]) { | |
| 693 | + // 全拼 | |
| 694 | + result[i]["fullChars"] = pinyin.getFullChars(result[i][$icname_s_attr]).toUpperCase(); | |
| 695 | + // 简拼 | |
| 696 | + result[i]["camelChars"] = pinyin.getCamelChars(result[i][$icname_s_attr]); | |
| 697 | + } | |
| 698 | + } | |
| 699 | + } | |
| 700 | + | |
| 701 | + if (result[i]["fullChars"]) { // 有拼音的加入数据源 | |
| 702 | + scope[ctrlAs].$$data_real.push(result[i]); | |
| 703 | + } | |
| 704 | + | |
| 705 | + } | |
| 706 | + //console.log("start2"); | |
| 707 | + | |
| 708 | + // 数量太大取前10条记录作为显示 | |
| 709 | + if (angular.isArray(scope[ctrlAs].$$data_real)) { | |
| 710 | + // 先迭代循环查找已经传过来的值 | |
| 711 | + if (scope[ctrlAs].$$data_real.length > 0) { | |
| 712 | + if (dcvalue) { | |
| 713 | + for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) { | |
| 714 | + if (scope[ctrlAs].$$data_real[j][$icname_attr] == dcvalue) { | |
| 715 | + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[j])); | |
| 716 | + break; | |
| 717 | + } | |
| 718 | + } | |
| 719 | + } | |
| 720 | + } | |
| 721 | + // 在插入剩余的数据 | |
| 722 | + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 723 | + if (scope[ctrlAs].$$data.length < 10) { | |
| 724 | + if ($mlp_attr) { | |
| 725 | + if (eval("scope[ctrlAs].$$data_real[k]" + "." + $icname_attr + " != dcvalue")) { | |
| 726 | + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 727 | + } | |
| 728 | + } else { | |
| 729 | + if (scope[ctrlAs].$$data_real[k][$icname_attr] != dcvalue) { | |
| 730 | + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 731 | + } | |
| 732 | + } | |
| 733 | + } else { | |
| 734 | + break; | |
| 735 | + } | |
| 736 | + } | |
| 737 | + } | |
| 738 | + | |
| 739 | + //console.log("end"); | |
| 740 | + }; | |
| 741 | + | |
| 742 | + /** | |
| 743 | + * 判定一个对象是否为空对象。 | |
| 744 | + * @param Obj | |
| 745 | + */ | |
| 746 | + scope[ctrlAs].$$internal_isEmpty_obj = function(obj) { | |
| 747 | + console.log(typeof obj); | |
| 748 | + | |
| 749 | + if (typeof obj === "object" && !(obj instanceof Array)) { | |
| 750 | + for (var prop in obj) { | |
| 751 | + if (obj.hasOwnProperty(prop)) { | |
| 752 | + return false; | |
| 753 | + } | |
| 754 | + } | |
| 755 | + return true; | |
| 756 | + } else { | |
| 757 | + throw "必须是对象"; | |
| 758 | + } | |
| 759 | + }; | |
| 760 | + | |
| 761 | + // 刷新数据 | |
| 762 | + scope[ctrlAs].$$internal_refresh_fn = function(search) { | |
| 763 | + // 绑定的model字段值,此属性是绑定属性,只能在link阶段获取 | |
| 764 | + var $dcvalue_attr = attr["dcvalue"]; | |
| 765 | + | |
| 766 | + console.log("刷新数据:" + $dcvalue_attr); | |
| 767 | + | |
| 768 | + if (!$$data_init) { // 只初始化$$data_real一次,重新载入页面才能重新初始化 | |
| 769 | + if (dictionaryUtils.getByGroup($datatype_attr)) { // 判定是否字典类型数据源 | |
| 770 | + scope[ctrlAs].$$internal_dic_data( | |
| 771 | + $datatype_attr, $icname_attr, $icname_s_attr); | |
| 772 | + if ($dcvalue_attr) { | |
| 773 | + scope[ctrlAs].$$internalmodel = $dcvalue_attr; | |
| 774 | + } | |
| 775 | + } else { // 非字典类型数据源 | |
| 776 | + if (!$dataassociate_attr) { | |
| 777 | + $$searchInfoService_g[$datatype_attr].list( | |
| 778 | + {type: "all"}, | |
| 779 | + function(result) { | |
| 780 | + //console.log("ok:" + $datatype_attr); | |
| 781 | + scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr); | |
| 782 | + //console.log("ok2:" + $datatype_attr); | |
| 783 | + if ($dcvalue_attr) { | |
| 784 | + scope[ctrlAs].$$internalmodel = $dcvalue_attr; | |
| 785 | + } | |
| 786 | + | |
| 787 | + $$data_init = true; | |
| 788 | + }, | |
| 789 | + function(result) { | |
| 790 | + | |
| 791 | + } | |
| 792 | + ); | |
| 793 | + } | |
| 794 | + } | |
| 795 | + } | |
| 796 | + | |
| 797 | + if ($$data_init) { | |
| 798 | + if (search && search != "") { // 有search值 | |
| 799 | + if (!dictionaryUtils.getByGroup($datatype_attr)) { // 其他数据源 | |
| 800 | + // 处理search | |
| 801 | + console.log("search:" + search); | |
| 802 | + | |
| 803 | + scope[ctrlAs].$$data = []; | |
| 804 | + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 805 | + var upTerm = search.toUpperCase(); | |
| 806 | + if (scope[ctrlAs].$$data.length < 10) { | |
| 807 | + if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1 | |
| 808 | + || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) { | |
| 809 | + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 810 | + } | |
| 811 | + } else { | |
| 812 | + break; | |
| 813 | + } | |
| 814 | + } | |
| 815 | + } | |
| 816 | + } | |
| 817 | + | |
| 818 | + } | |
| 819 | + | |
| 820 | + }; | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + // TODO: | |
| 832 | + | |
| 833 | + // dom全部载入后调用 | |
| 834 | + $timeout(function() { | |
| 835 | + console.log("dom全部载入后调用"); | |
| 836 | + }, 0); | |
| 837 | + // 监控dcvalue model值变换 | |
| 838 | + attr.$observe("dcvalue", function(value) { | |
| 839 | + console.log("监控dc1 model值变换:" + value); | |
| 840 | + scope[ctrlAs].$$internalmodel = value; | |
| 841 | + } | |
| 842 | + ); | |
| 843 | + // 监控获取数据参数变换 | |
| 844 | + attr.$observe("dataparam", function(value) { | |
| 845 | + // 判定是否空对象 | |
| 846 | + console.log(value); | |
| 847 | + var obj = JSON.parse(value); | |
| 848 | + var $dcvalue_attr = attr["dcvalue"]; | |
| 849 | + if (!scope[ctrlAs].$$internal_isEmpty_obj(obj)) { | |
| 850 | + console.log("dataparam:" + obj); | |
| 851 | + | |
| 852 | + // | |
| 853 | + | |
| 854 | + obj["type"] = "all"; | |
| 855 | + | |
| 856 | + $$data_init = false; | |
| 857 | + $$searchInfoService_g[$datatype_attr].list( | |
| 858 | + obj, | |
| 859 | + function(result) { | |
| 860 | + //console.log("ok:" + $datatype_attr); | |
| 861 | + scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr); | |
| 862 | + //console.log("ok2:" + $datatype_attr); | |
| 863 | + if ($dcvalue_attr) { | |
| 864 | + scope[ctrlAs].$$internalmodel = $dcvalue_attr; | |
| 865 | + } | |
| 866 | + | |
| 867 | + $$data_init = true; | |
| 868 | + }, | |
| 869 | + function(result) { | |
| 870 | + | |
| 871 | + } | |
| 872 | + ); | |
| 873 | + } | |
| 874 | + } | |
| 875 | + ); | |
| 876 | + } | |
| 877 | + }; | |
| 878 | + } | |
| 879 | + }; | |
| 880 | + | |
| 881 | + } | |
| 882 | +]); | |
| 883 | + | |
| 884 | + | |
| 885 | +/** | |
| 886 | + * saSelect4指令,封装angular-ui-select控件,并添加相应的业务。 | |
| 887 | + * name(必须):控件的名字 | |
| 888 | + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 889 | + * placeholder(可选):输入框占位符字符串 | |
| 890 | + * | |
| 891 | + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 892 | + * dcname(必须):绑定的model字段名,如:dcname=xl.id | |
| 893 | + * icname(必须):内部与之对应的字段名,如:icname=code | |
| 894 | + * | |
| 895 | + * cmaps(可选):model其他字段和内部数据字段名映射,如:{{ {'xl.id' : 'id', 'xl.name' : 'name'} | json}} | |
| 896 | + * dsparams(必须):内部数据源查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }} | |
| 897 | + * dscol(必须):内部显示的信息(暂时用内部字段),如:dscol=name | |
| 898 | + * required(可选):是否要用required验证 | |
| 899 | + */ | |
| 900 | +angular.module('ScheduleApp').directive('saSelect4', [ | |
| 901 | + '$timeout', | |
| 902 | + '$$SearchInfoService_g', | |
| 903 | + function($timeout, $$searchInfoService_g) { | |
| 904 | + return { | |
| 905 | + restrict: 'E', | |
| 906 | + templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect4Template.html', | |
| 907 | + scope: { | |
| 908 | + model: "=" // 独立作用域,关联外部的模型object | |
| 909 | + }, | |
| 910 | + controllerAs: "$saSelectCtrl", | |
| 911 | + bindToController: true, | |
| 912 | + controller: function($scope) { | |
| 913 | + var self = this; | |
| 914 | + self.$$data = []; // ui-select显示用的数据 | |
| 915 | + self.$$data_real = []; // 内部真实的数据 | |
| 916 | + | |
| 917 | + // saSelect4组件的ng-model,用于外部绑定验证等操作 | |
| 918 | + self.$$internalmodel = undefined; | |
| 919 | + | |
| 920 | + self.$$internal_select_value = undefined; // 选中的值 | |
| 921 | + }, | |
| 922 | + | |
| 923 | + /** | |
| 924 | + * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 925 | + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 926 | + * @param tElem | |
| 927 | + * @param tAttrs | |
| 928 | + * @returns {{pre: Function, post: Function}} | |
| 929 | + */ | |
| 930 | + compile: function(tElem, tAttrs) { | |
| 931 | + // 获取属性 | |
| 932 | + var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 933 | + var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字 | |
| 934 | + | |
| 935 | + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名 | |
| 936 | + var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名 | |
| 937 | + | |
| 938 | + var $cmaps_attr = tAttrs["cmaps"]; // model其他字段和内部数据字段名映射 | |
| 939 | + var $dscol_attr = tAttrs["dscol"]; // 内部显示的信息 | |
| 940 | + var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 941 | + | |
| 942 | + // controlAs名字 | |
| 943 | + var ctrlAs = "$saSelectCtrl"; | |
| 944 | + | |
| 945 | + // 验证属性 | |
| 946 | + if (!$name_attr) { | |
| 947 | + throw new error("name属性必须填写"); | |
| 948 | + } | |
| 949 | + if (!$dcname_attr) { | |
| 950 | + throw new error("dcname属性必须填写"); | |
| 951 | + } | |
| 952 | + if (!$icname_attr) { | |
| 953 | + throw new error("icname属性必须填写"); | |
| 954 | + } | |
| 955 | + if (!$dscol_attr) { | |
| 956 | + throw new error("dscol属性必须填写"); | |
| 957 | + } | |
| 958 | + | |
| 959 | + // 动态设置dom | |
| 960 | + // dom required 属性 | |
| 961 | + if ($required_attr != undefined) { | |
| 962 | + tElem.find("div").attr("required", ""); | |
| 963 | + } | |
| 964 | + // dom placeholder 属性 | |
| 965 | + tElem.find("ui-select-match").attr("placeholder", $placeholder_attr); | |
| 966 | + // dom dscol 属性 | |
| 967 | + tElem.find("ui-select-match").html("{{$select.selected" + "." + $dscol_attr + "}}"); | |
| 968 | + tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $dscol_attr); | |
| 969 | + // dom icname 属性 | |
| 970 | + tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data"); | |
| 971 | + // dom name 属性 | |
| 972 | + tElem.find("div").attr("name", $name_attr); | |
| 973 | + | |
| 974 | + return { | |
| 975 | + pre: function(scope, element, attr) { | |
| 976 | + // TODO: | |
| 977 | + }, | |
| 978 | + | |
| 979 | + /** | |
| 980 | + * 相当于link函数。 | |
| 981 | + * @param scope | |
| 982 | + * @param element | |
| 983 | + * @param attr | |
| 984 | + */ | |
| 985 | + post: function(scope, element, attr) { | |
| 986 | + | |
| 987 | + // 添加选中事件处理函数 | |
| 988 | + scope[ctrlAs].$$internal_select_fn = function($item) { | |
| 989 | + if ($dcname_attr && $icname_attr) { | |
| 990 | + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";"); | |
| 991 | + } | |
| 992 | + | |
| 993 | + if ($cmaps_attr) { | |
| 994 | + for (var mc in $cmaps_attr) { // model的字段名:内部数据源对应字段名 | |
| 995 | + var ic = $cmaps_attr[mc]; // 内部数据源对应字段 | |
| 996 | + eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";"); | |
| 997 | + } | |
| 998 | + } | |
| 999 | + }; | |
| 1000 | + | |
| 1001 | + // 删除选中事件处理函数 | |
| 1002 | + scope[ctrlAs].$$internal_remove_fn = function() { | |
| 1003 | + scope[ctrlAs].$$internal_select_value = undefined; | |
| 1004 | + if ($dcname_attr) { | |
| 1005 | + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;"); | |
| 1006 | + } | |
| 1007 | + | |
| 1008 | + if ($cmaps_attr) { | |
| 1009 | + var mc; // model的字段名 | |
| 1010 | + for (mc in $cmaps_attr) { | |
| 1011 | + eval("scope[ctrlAs].model" + "." + mc + " = undefined;"); | |
| 1012 | + } | |
| 1013 | + } | |
| 1014 | + scope[ctrlAs].$$internal_validate_model(); | |
| 1015 | + }; | |
| 1016 | + | |
| 1017 | + // 刷新数据 | |
| 1018 | + scope[ctrlAs].$$internal_refresh_fn = function(search) { | |
| 1019 | + if (search && search != "") { // 有search值 | |
| 1020 | + // 处理search | |
| 1021 | + console.log("search:" + search); | |
| 1022 | + | |
| 1023 | + scope[ctrlAs].$$data = []; | |
| 1024 | + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 1025 | + var upTerm = search.toUpperCase(); | |
| 1026 | + if (scope[ctrlAs].$$data.length < 10) { | |
| 1027 | + if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1 | |
| 1028 | + || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) { | |
| 1029 | + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 1030 | + } | |
| 1031 | + } else { | |
| 1032 | + break; | |
| 1033 | + } | |
| 1034 | + } | |
| 1035 | + } | |
| 1036 | + }; | |
| 1037 | + | |
| 1038 | + /** | |
| 1039 | + * 验证内部数据,更新外部model | |
| 1040 | + */ | |
| 1041 | + scope[ctrlAs].$$internal_validate_model = function() { | |
| 1042 | + if (scope[ctrlAs].$$internal_select_value) { | |
| 1043 | + var select_value_temp = scope[ctrlAs].$$internal_select_value; | |
| 1044 | + if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) { | |
| 1045 | + var obj; | |
| 1046 | + for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) { | |
| 1047 | + if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) { | |
| 1048 | + obj = angular.copy(scope[ctrlAs].$$data_real[j]); | |
| 1049 | + break; | |
| 1050 | + } | |
| 1051 | + } | |
| 1052 | + if (obj) { // 在data中判定有没有 | |
| 1053 | + for (var k = 0; k < scope[ctrlAs].$$data.length; k++) { | |
| 1054 | + if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) { | |
| 1055 | + obj = undefined; | |
| 1056 | + break; | |
| 1057 | + } | |
| 1058 | + } | |
| 1059 | + if (obj) { | |
| 1060 | + scope[ctrlAs].$$data.push(obj); | |
| 1061 | + } | |
| 1062 | + // 更新内部model,用于外部验证 | |
| 1063 | + // 内部model的值暂时随意,以后再改 | |
| 1064 | + scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 1065 | + } else { | |
| 1066 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 1067 | + } | |
| 1068 | + | |
| 1069 | + } else { | |
| 1070 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 1071 | + } | |
| 1072 | + | |
| 1073 | + } else { | |
| 1074 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 1075 | + } | |
| 1076 | + }; | |
| 1077 | + | |
| 1078 | + /** | |
| 1079 | + * 内部方法,读取字典数据作为数据源。 | |
| 1080 | + * @param atype ajax查询类型 | |
| 1081 | + * @param ajaxparamobj 查询参数对象 | |
| 1082 | + */ | |
| 1083 | + scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) { | |
| 1084 | + ajaxparamobj.type = 'all'; | |
| 1085 | + $$searchInfoService_g[atype].list( | |
| 1086 | + ajaxparamobj, | |
| 1087 | + function(result) { | |
| 1088 | + console.log("$$internal_ajax_data result"); | |
| 1089 | + | |
| 1090 | + // 清空内部数据 | |
| 1091 | + scope[ctrlAs].$$data_real = []; | |
| 1092 | + scope[ctrlAs].$$data = []; | |
| 1093 | + | |
| 1094 | + // result中添加拼音数据,注意:这里要求result返回对象数组 | |
| 1095 | + for (var i = 0; i < result.length; i ++) { | |
| 1096 | + if ($dscol_attr) { | |
| 1097 | + if (eval("result[i]" + "." + $dscol_attr)) { | |
| 1098 | + // 全拼 | |
| 1099 | + result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $dscol_attr)).toUpperCase(); | |
| 1100 | + // 简拼 | |
| 1101 | + result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $dscol_attr)); | |
| 1102 | + } | |
| 1103 | + } | |
| 1104 | + | |
| 1105 | + if (result[i]["fullChars"]) { // 有拼音的加入数据源 | |
| 1106 | + scope[ctrlAs].$$data_real.push(result[i]); | |
| 1107 | + } | |
| 1108 | + | |
| 1109 | + } | |
| 1110 | + | |
| 1111 | + // 数据量太大,取10条记录显示 | |
| 1112 | + if (angular.isArray(scope[ctrlAs].$$data_real)) { | |
| 1113 | + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 1114 | + if (scope[ctrlAs].$$data.length < 10) { | |
| 1115 | + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 1116 | + } else { | |
| 1117 | + break; | |
| 1118 | + } | |
| 1119 | + } | |
| 1120 | + } | |
| 1121 | + | |
| 1122 | + scope[ctrlAs].$$internal_validate_model(); | |
| 1123 | + }, | |
| 1124 | + function(result) { | |
| 1125 | + | |
| 1126 | + } | |
| 1127 | + ); | |
| 1128 | + }; | |
| 1129 | + | |
| 1130 | + /** | |
| 1131 | + * 内部方法,读取字典数据作为数据源。 | |
| 1132 | + * @param dictype 字典类型,如:gsType | |
| 1133 | + */ | |
| 1134 | + scope[ctrlAs].$$internal_dic_data = function(dictype) { | |
| 1135 | + if (!dictionaryUtils.getByGroup(dictype)) { | |
| 1136 | + throw new error("字典数据不窜在=" + dictype); | |
| 1137 | + } | |
| 1138 | + | |
| 1139 | + // 清空内部数据 | |
| 1140 | + scope[ctrlAs].$$data_real = []; | |
| 1141 | + scope[ctrlAs].$$data = []; | |
| 1142 | + | |
| 1143 | + var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup); | |
| 1144 | + var dic_key; // 字典key | |
| 1145 | + | |
| 1146 | + for (dic_key in origin_dicgroup) { | |
| 1147 | + var data = {}; // 重新组合的字典元素对象 | |
| 1148 | + if (dic_key == "true") | |
| 1149 | + data[$icname_attr] = true; | |
| 1150 | + else | |
| 1151 | + data[$icname_attr] = dic_key; | |
| 1152 | + data[$dscol_attr] = origin_dicgroup[dic_key]; | |
| 1153 | + scope[ctrlAs].$$data_real.push(data); | |
| 1154 | + } | |
| 1155 | + // 这里直接将$$data_real数据深拷贝到$$data | |
| 1156 | + angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data); | |
| 1157 | + scope[ctrlAs].$$internal_validate_model(); | |
| 1158 | + }; | |
| 1159 | + | |
| 1160 | + attr.$observe("dsparams", function(value) { | |
| 1161 | + if (value && value != "") { | |
| 1162 | + var obj = JSON.parse(value); | |
| 1163 | + console.log("observe 监控 dsparams=" + obj); | |
| 1164 | + | |
| 1165 | + // dsparams格式如下: | |
| 1166 | + // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'} | |
| 1167 | + | |
| 1168 | + if (obj.type == 'dic') { | |
| 1169 | + scope[ctrlAs].$$internal_dic_data(obj.param); | |
| 1170 | + | |
| 1171 | + } else if (obj.type == 'ajax') { | |
| 1172 | + scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param); | |
| 1173 | + } else { | |
| 1174 | + throw new Error("dsparams参数格式异常=" + obj); | |
| 1175 | + } | |
| 1176 | + | |
| 1177 | + } | |
| 1178 | + | |
| 1179 | + }); | |
| 1180 | + | |
| 1181 | + // 监控model绑定的dcvalue值变化 | |
| 1182 | + attr.$observe("dcvalue", function(value) { | |
| 1183 | + if (value && value != "") { | |
| 1184 | + console.log("observe 监控 dcvalue=" + value); | |
| 1185 | + scope[ctrlAs].$$internal_select_value = value; | |
| 1186 | + scope[ctrlAs].$$internal_validate_model(); | |
| 1187 | + } | |
| 1188 | + | |
| 1189 | + // 闭包测试 | |
| 1190 | + var obj = {'a':1,'b':2}; | |
| 1191 | + var tfx = scope[ctrlAs].$$test.bind(obj); | |
| 1192 | + console.log("闭包测试=" + tfx()); | |
| 1193 | + }); | |
| 1194 | + | |
| 1195 | + scope[ctrlAs].$$test = function() { | |
| 1196 | + var exp = "this.a + '(' + this.b + ')'"; | |
| 1197 | + console.log("exp=" + exp); | |
| 1198 | + return eval(exp); | |
| 1199 | + }; | |
| 1200 | + } | |
| 1201 | + }; | |
| 1202 | + | |
| 1203 | + } | |
| 1204 | + | |
| 1205 | + }; | |
| 1206 | + } | |
| 391 | 1207 | ]); |
| 392 | - | |
| 393 | - | |
| 394 | - | |
| 395 | - | |
| 396 | - | |
| 397 | -/** | |
| 398 | - * saSelect3指令 | |
| 399 | - * 属性如下: | |
| 400 | - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 401 | - * name(必须):控件的名字 | |
| 402 | - * placeholder(可选):占位符字符串 | |
| 403 | - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 404 | - * dcname(必须):绑定的model字段名,如:dcname=xl.id | |
| 405 | - * icname(必须):内部与之对应的字段名,如:icname=code | |
| 406 | - * dcname2(可选):其他需要赋值的model字段名2,如:dcname2=xl.name | |
| 407 | - * icname2(可选):内部与之对应的字段名2,如:icname2=name | |
| 408 | - * dcname3(可选):其他需要赋值的model字段名3,如:dcname2=xl.name | |
| 409 | - * icname3(可选):内部与之对应的字段名3,如:icname2=name | |
| 410 | - * icnames(必须):用于用于显示,以及简评处理的内部数据字段,如:icnames=name | |
| 411 | - * required(可选):是否要用required验证 | |
| 412 | - * datatype(必须):业务数据类型,有字典类型,动态数据类型,暂时写的死点 | |
| 413 | - * mlp(可选):是否多级属性(这里假设外部model如果多级,内部model也是多级) | |
| 414 | - * | |
| 415 | - * 高级属性: | |
| 416 | - * dataassociate(可选):数据源是否关联属性(内部数据随外部指定的参数变化而变化) | |
| 417 | - * dataparam(可选):数据源关联的外部参数对象 | |
| 418 | - * | |
| 419 | - */ | |
| 420 | -angular.module('ScheduleApp').directive("saSelect3", [ | |
| 421 | - '$timeout', | |
| 422 | - '$$SearchInfoService_g', | |
| 423 | - function($timeout, $$searchInfoService_g) { | |
| 424 | - return { | |
| 425 | - restrict: 'E', | |
| 426 | - templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect3Template.html', | |
| 427 | - scope: { | |
| 428 | - model: "=" // 独立作用域,关联外部的模型object | |
| 429 | - }, | |
| 430 | - controllerAs: "$saSelectCtrl", | |
| 431 | - bindToController: true, | |
| 432 | - controller: function($scope) { | |
| 433 | - var self = this; | |
| 434 | - self.$$data = []; // ui-select显示用的数据源 | |
| 435 | - self.$$data_real= []; // 内部真实的数据源 | |
| 436 | - }, | |
| 437 | - | |
| 438 | - /** | |
| 439 | - * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 440 | - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 441 | - * @param tElem | |
| 442 | - * @param tAttrs | |
| 443 | - * @returns {{pre: Function, post: Function}} | |
| 444 | - */ | |
| 445 | - compile: function(tElem, tAttrs) { | |
| 446 | - // 获取所有的属性 | |
| 447 | - var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 448 | - var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字 | |
| 449 | - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名 | |
| 450 | - var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名 | |
| 451 | - var $dcname2_attr = tAttrs["dcname2"]; // 其他需要赋值的model字段名2 | |
| 452 | - var $icname2_attr = tAttrs["icname2"]; // 内部与之对应的字段名2 | |
| 453 | - var $dcname3_attr = tAttrs["dcname3"]; // 其他需要赋值的model字段名3 | |
| 454 | - var $icname3_attr = tAttrs["icname3"]; // 内部与之对应的字段名3 | |
| 455 | - | |
| 456 | - var $icname_s_attr = tAttrs["icnames"]; // 用于用于显示,以及简评处理的内部数据字段 | |
| 457 | - var $datatype_attr = tAttrs["datatype"]; // 内部业务数据类型 | |
| 458 | - var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 459 | - var $mlp_attr = tAttrs["mlp"]; // 是否多级属性 | |
| 460 | - var $dataassociate_attr = tAttrs["dataassociate"]; // 数据源是否关联属性 | |
| 461 | - | |
| 462 | - // controlAs名字 | |
| 463 | - var ctrlAs = "$saSelectCtrl"; | |
| 464 | - | |
| 465 | - // 数据源初始化标志 | |
| 466 | - var $$data_init = false; | |
| 467 | - // 如果有required属性,添加angularjs required验证 | |
| 468 | - if ($required_attr != undefined) { | |
| 469 | - tElem.find("ui-select").attr("required", ""); | |
| 470 | - } | |
| 471 | - | |
| 472 | - // 由于有的属性是多级的如xl.name,所以要在compile阶段重写属性绑定属性定义 | |
| 473 | - // 原来的设置:{{$select.selected[$saSelectCtrl.$icname_s]}} | |
| 474 | - tElem.find("ui-select-match").html("{{$select.selected" + "." + $icname_s_attr + "}}"); | |
| 475 | - // 原来的设置:item[$saSelectCtrl.$icname] as item in $saSelectCtrl.$$data | |
| 476 | - tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data"); | |
| 477 | - // 原来的设置:item[$saSelectCtrl.$icname_s] | |
| 478 | - tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $icname_s_attr); | |
| 479 | - // 原来的设置:{{$saSelectCtrl.$name}} | |
| 480 | - tElem.find("ui-select").attr("name", $name_attr); | |
| 481 | - // 原来的设置:{{$saSelectCtrl.$placeholder}} | |
| 482 | - tElem.find("ui-select-match").attr("placeholder", $placeholder_attr); | |
| 483 | - | |
| 484 | - return { | |
| 485 | - pre: function(scope, element, attr) { | |
| 486 | - // TODO: | |
| 487 | - }, | |
| 488 | - /** | |
| 489 | - * 相当于link函数。 | |
| 490 | - * @param scope | |
| 491 | - * @param element | |
| 492 | - * @param attr | |
| 493 | - */ | |
| 494 | - post: function(scope, element, attr) { | |
| 495 | - // 添加选中事件处理函数 | |
| 496 | - scope[ctrlAs].$$internal_select_fn = function($item) { | |
| 497 | - if ($dcname_attr && $icname_attr) { | |
| 498 | - if ($mlp_attr) { | |
| 499 | - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";"); | |
| 500 | - } else { | |
| 501 | - scope[ctrlAs].model[$dcname_attr] = $item[$icname_attr]; | |
| 502 | - } | |
| 503 | - } | |
| 504 | - if ($dcname2_attr && $icname2_attr) { | |
| 505 | - if ($mlp_attr) { | |
| 506 | - eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = $item" + "." + $icname2_attr + ";"); | |
| 507 | - } else { | |
| 508 | - scope[ctrlAs].model[$dcname2_attr] = $item[$icname2_attr]; | |
| 509 | - } | |
| 510 | - } | |
| 511 | - if ($dcname3_attr && $icname3_attr) { | |
| 512 | - if ($mlp_attr) { | |
| 513 | - eval("scope[ctrlAs].model" + "." + $dcname3_attr + " = $item" + "." + $icname3_attr + ";"); | |
| 514 | - } else { | |
| 515 | - scope[ctrlAs].model[$dcname3_attr] = $item[$icname3_attr]; | |
| 516 | - } | |
| 517 | - } | |
| 518 | - }; | |
| 519 | - | |
| 520 | - // 删除选中事件处理函数 | |
| 521 | - scope[ctrlAs].$$internal_remove_fn = function() { | |
| 522 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 523 | - if ($mlp_attr) { | |
| 524 | - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;"); | |
| 525 | - } else { | |
| 526 | - scope[ctrlAs].model[$dcname_attr] = undefined; | |
| 527 | - } | |
| 528 | - | |
| 529 | - if ($dcname2_attr) { | |
| 530 | - if ($mlp_attr) { | |
| 531 | - eval("scope[ctrlAs].model" + "." + $dcname2_attr + " = undefined;"); | |
| 532 | - } else { | |
| 533 | - scope[ctrlAs].model[$dcname2_attr] = undefined; | |
| 534 | - } | |
| 535 | - } | |
| 536 | - if ($dcname3_attr) { | |
| 537 | - if ($mlp_attr) { | |
| 538 | - eval("scope[ctrlAs].model" + "." + $dcname3_attr + " = undefined;"); | |
| 539 | - } else { | |
| 540 | - scope[ctrlAs].model[$dcname3_attr] = undefined; | |
| 541 | - } | |
| 542 | - } | |
| 543 | - }; | |
| 544 | - | |
| 545 | - /** | |
| 546 | - * 内部方法,读取字典数据作为数据源。 | |
| 547 | - * @param dicgroup 字典类型,如:gsType | |
| 548 | - * @param ccol 代码字段名 | |
| 549 | - * @param ncol 名字字段名 | |
| 550 | - */ | |
| 551 | - scope[ctrlAs].$$internal_dic_data = function(dicgroup, ccol, ncol) { | |
| 552 | - var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup); | |
| 553 | - var dic_key; // 字典key | |
| 554 | - // 清空内部数据 | |
| 555 | - scope[ctrlAs].$$data_real = []; | |
| 556 | - for (dic_key in origin_dicgroup) { | |
| 557 | - var data = {}; // 重新组合的字典元素对象 | |
| 558 | - if (dic_key == "true") | |
| 559 | - data[ccol] = true; | |
| 560 | - else | |
| 561 | - data[ccol] = dic_key; | |
| 562 | - data[ncol] = origin_dicgroup[dic_key]; | |
| 563 | - scope[ctrlAs].$$data_real.push(data); | |
| 564 | - } | |
| 565 | - // 这里直接将$$data_real数据深拷贝到$$data | |
| 566 | - angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data); | |
| 567 | - | |
| 568 | - console.log(scope[ctrlAs].$$data); | |
| 569 | - }; | |
| 570 | - | |
| 571 | - /** | |
| 572 | - * TODO:这个方法有性能问题,result一多就会卡一卡,之后再解决把 | |
| 573 | - * 内部方法,读取字典数据作为数据源。 | |
| 574 | - * @param result 原始数据 | |
| 575 | - * @param dcvalue 传入的关联数据 | |
| 576 | - */ | |
| 577 | - scope[ctrlAs].$$internal_other_data = function(result, dcvalue) { | |
| 578 | - console.log("start=" + dcvalue); | |
| 579 | - // 清空内部数据 | |
| 580 | - scope[ctrlAs].$$data_real = []; | |
| 581 | - scope[ctrlAs].$$data = []; | |
| 582 | - for (var i = 0; i < result.length; i ++) { | |
| 583 | - if ($icname_s_attr) { | |
| 584 | - if ($mlp_attr) { | |
| 585 | - if (eval("result[i]" + "." + $icname_s_attr)) { | |
| 586 | - // 全拼 | |
| 587 | - result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $icname_s_attr)).toUpperCase(); | |
| 588 | - // 简拼 | |
| 589 | - result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $icname_s_attr)); | |
| 590 | - } | |
| 591 | - } else { | |
| 592 | - if (result[i][$icname_s_attr]) { | |
| 593 | - // 全拼 | |
| 594 | - result[i]["fullChars"] = pinyin.getFullChars(result[i][$icname_s_attr]).toUpperCase(); | |
| 595 | - // 简拼 | |
| 596 | - result[i]["camelChars"] = pinyin.getCamelChars(result[i][$icname_s_attr]); | |
| 597 | - } | |
| 598 | - } | |
| 599 | - } | |
| 600 | - | |
| 601 | - if (result[i]["fullChars"]) { // 有拼音的加入数据源 | |
| 602 | - scope[ctrlAs].$$data_real.push(result[i]); | |
| 603 | - } | |
| 604 | - | |
| 605 | - } | |
| 606 | - //console.log("start2"); | |
| 607 | - | |
| 608 | - // 数量太大取前10条记录作为显示 | |
| 609 | - if (angular.isArray(scope[ctrlAs].$$data_real)) { | |
| 610 | - // 先迭代循环查找已经传过来的值 | |
| 611 | - if (scope[ctrlAs].$$data_real.length > 0) { | |
| 612 | - if (dcvalue) { | |
| 613 | - for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) { | |
| 614 | - if (scope[ctrlAs].$$data_real[j][$icname_attr] == dcvalue) { | |
| 615 | - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[j])); | |
| 616 | - break; | |
| 617 | - } | |
| 618 | - } | |
| 619 | - } | |
| 620 | - } | |
| 621 | - // 在插入剩余的数据 | |
| 622 | - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 623 | - if (scope[ctrlAs].$$data.length < 10) { | |
| 624 | - if ($mlp_attr) { | |
| 625 | - if (eval("scope[ctrlAs].$$data_real[k]" + "." + $icname_attr + " != dcvalue")) { | |
| 626 | - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 627 | - } | |
| 628 | - } else { | |
| 629 | - if (scope[ctrlAs].$$data_real[k][$icname_attr] != dcvalue) { | |
| 630 | - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 631 | - } | |
| 632 | - } | |
| 633 | - } else { | |
| 634 | - break; | |
| 635 | - } | |
| 636 | - } | |
| 637 | - } | |
| 638 | - | |
| 639 | - //console.log("end"); | |
| 640 | - }; | |
| 641 | - | |
| 642 | - /** | |
| 643 | - * 判定一个对象是否为空对象。 | |
| 644 | - * @param Obj | |
| 645 | - */ | |
| 646 | - scope[ctrlAs].$$internal_isEmpty_obj = function(obj) { | |
| 647 | - console.log(typeof obj); | |
| 648 | - | |
| 649 | - if (typeof obj === "object" && !(obj instanceof Array)) { | |
| 650 | - for (var prop in obj) { | |
| 651 | - if (obj.hasOwnProperty(prop)) { | |
| 652 | - return false; | |
| 653 | - } | |
| 654 | - } | |
| 655 | - return true; | |
| 656 | - } else { | |
| 657 | - throw "必须是对象"; | |
| 658 | - } | |
| 659 | - }; | |
| 660 | - | |
| 661 | - // 刷新数据 | |
| 662 | - scope[ctrlAs].$$internal_refresh_fn = function(search) { | |
| 663 | - // 绑定的model字段值,此属性是绑定属性,只能在link阶段获取 | |
| 664 | - var $dcvalue_attr = attr["dcvalue"]; | |
| 665 | - | |
| 666 | - console.log("刷新数据:" + $dcvalue_attr); | |
| 667 | - | |
| 668 | - if (!$$data_init) { // 只初始化$$data_real一次,重新载入页面才能重新初始化 | |
| 669 | - if (dictionaryUtils.getByGroup($datatype_attr)) { // 判定是否字典类型数据源 | |
| 670 | - scope[ctrlAs].$$internal_dic_data( | |
| 671 | - $datatype_attr, $icname_attr, $icname_s_attr); | |
| 672 | - if ($dcvalue_attr) { | |
| 673 | - scope[ctrlAs].$$internalmodel = $dcvalue_attr; | |
| 674 | - } | |
| 675 | - } else { // 非字典类型数据源 | |
| 676 | - if (!$dataassociate_attr) { | |
| 677 | - $$searchInfoService_g[$datatype_attr].list( | |
| 678 | - {type: "all"}, | |
| 679 | - function(result) { | |
| 680 | - //console.log("ok:" + $datatype_attr); | |
| 681 | - scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr); | |
| 682 | - //console.log("ok2:" + $datatype_attr); | |
| 683 | - if ($dcvalue_attr) { | |
| 684 | - scope[ctrlAs].$$internalmodel = $dcvalue_attr; | |
| 685 | - } | |
| 686 | - | |
| 687 | - $$data_init = true; | |
| 688 | - }, | |
| 689 | - function(result) { | |
| 690 | - | |
| 691 | - } | |
| 692 | - ); | |
| 693 | - } | |
| 694 | - } | |
| 695 | - } | |
| 696 | - | |
| 697 | - if ($$data_init) { | |
| 698 | - if (search && search != "") { // 有search值 | |
| 699 | - if (!dictionaryUtils.getByGroup($datatype_attr)) { // 其他数据源 | |
| 700 | - // 处理search | |
| 701 | - console.log("search:" + search); | |
| 702 | - | |
| 703 | - scope[ctrlAs].$$data = []; | |
| 704 | - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 705 | - var upTerm = search.toUpperCase(); | |
| 706 | - if (scope[ctrlAs].$$data.length < 10) { | |
| 707 | - if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1 | |
| 708 | - || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) { | |
| 709 | - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 710 | - } | |
| 711 | - } else { | |
| 712 | - break; | |
| 713 | - } | |
| 714 | - } | |
| 715 | - } | |
| 716 | - } | |
| 717 | - | |
| 718 | - } | |
| 719 | - | |
| 720 | - }; | |
| 721 | - | |
| 722 | - | |
| 723 | - | |
| 724 | - | |
| 725 | - | |
| 726 | - | |
| 727 | - | |
| 728 | - | |
| 729 | - | |
| 730 | - | |
| 731 | - // TODO: | |
| 732 | - | |
| 733 | - // dom全部载入后调用 | |
| 734 | - $timeout(function() { | |
| 735 | - console.log("dom全部载入后调用"); | |
| 736 | - }, 0); | |
| 737 | - // 监控dcvalue model值变换 | |
| 738 | - attr.$observe("dcvalue", function(value) { | |
| 739 | - console.log("监控dc1 model值变换:" + value); | |
| 740 | - scope[ctrlAs].$$internalmodel = value; | |
| 741 | - } | |
| 742 | - ); | |
| 743 | - // 监控获取数据参数变换 | |
| 744 | - attr.$observe("dataparam", function(value) { | |
| 745 | - // 判定是否空对象 | |
| 746 | - console.log(value); | |
| 747 | - var obj = JSON.parse(value); | |
| 748 | - var $dcvalue_attr = attr["dcvalue"]; | |
| 749 | - if (!scope[ctrlAs].$$internal_isEmpty_obj(obj)) { | |
| 750 | - console.log("dataparam:" + obj); | |
| 751 | - | |
| 752 | - // | |
| 753 | - | |
| 754 | - obj["type"] = "all"; | |
| 755 | - | |
| 756 | - $$data_init = false; | |
| 757 | - $$searchInfoService_g[$datatype_attr].list( | |
| 758 | - obj, | |
| 759 | - function(result) { | |
| 760 | - //console.log("ok:" + $datatype_attr); | |
| 761 | - scope[ctrlAs].$$internal_other_data(result, $dcvalue_attr); | |
| 762 | - //console.log("ok2:" + $datatype_attr); | |
| 763 | - if ($dcvalue_attr) { | |
| 764 | - scope[ctrlAs].$$internalmodel = $dcvalue_attr; | |
| 765 | - } | |
| 766 | - | |
| 767 | - $$data_init = true; | |
| 768 | - }, | |
| 769 | - function(result) { | |
| 770 | - | |
| 771 | - } | |
| 772 | - ); | |
| 773 | - } | |
| 774 | - } | |
| 775 | - ); | |
| 776 | - } | |
| 777 | - }; | |
| 778 | - } | |
| 779 | - }; | |
| 780 | - | |
| 781 | - } | |
| 1208 | +/** | |
| 1209 | + * saSelect5指令,基于简拼查询的select,内部封装angular-ui-select控件,并嵌入相应的业务逻辑。 | |
| 1210 | + * name(必须):控件的名字 | |
| 1211 | + * model(必须):独立作用域,指定一个外部对象模型双向绑定,如:model=ctrl.employeeInfoForSave | |
| 1212 | + * cmaps(必须):外部对象与指令内部数据对象字段名映射对象字符串,如:{'xl.id' : 'id', 'xl.name' : 'name'} | |
| 1213 | + * dcname(必须):绑定的model字段名,如:dcname=xl.id | |
| 1214 | + * icname(必须):内部与之对应的字段名,如:icname=id | |
| 1215 | + * | |
| 1216 | + * dsparams(必须):内部数据源查询参数对象,如:{{ {'ttid_eq': ctrl.rerunManageForSave.rerunTtinfo.id} | json }} | |
| 1217 | + * dsparamsextra(可选):内部数据源查询附加参数对象字符串,如:{'type':'all'} | |
| 1218 | + * iterobjname(必须):内部数据源迭代的数据变量名,如:iterobjname=item | |
| 1219 | + * iterobjexp(必须):内部显示用的表达式 | |
| 1220 | + * searchph(必须):查询输入占位符字符串,如:searchph=请输入... | |
| 1221 | + * searchexp(必须):查询基于的内部数据源的表达式,如:searchexp=this.name+'('+this.code+')' | |
| 1222 | + * | |
| 1223 | + * required(可选):是否需要form的required验证 | |
| 1224 | + * | |
| 1225 | + */ | |
| 1226 | +angular.module('ScheduleApp').directive('saSelect5', [ | |
| 1227 | + '$timeout', | |
| 1228 | + '$$SearchInfoService_g', | |
| 1229 | + function($timeout, $$searchInfoService_g) { | |
| 1230 | + return { | |
| 1231 | + restrict: 'E', | |
| 1232 | + templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect5Template.html', | |
| 1233 | + scope: { // 独立作用域 | |
| 1234 | + model: "=" // 绑定外部对象 | |
| 1235 | + }, | |
| 1236 | + controllerAs: "$saSelectCtrl", | |
| 1237 | + bindToController: true, | |
| 1238 | + controller: function($scope) { | |
| 1239 | + var self = this; | |
| 1240 | + self.$$data = []; // 内部ui-select显示用数据 | |
| 1241 | + self.$$data_real = []; // 内部保存的实际数据 | |
| 1242 | + | |
| 1243 | + // myselect组件的ng-model,用于外部绑定验证等操作 | |
| 1244 | + self.$$internalmodel = undefined; | |
| 1245 | + | |
| 1246 | + self.$$internal_select_value = undefined; // 选中的值 | |
| 1247 | + | |
| 1248 | + }, | |
| 1249 | + | |
| 1250 | + /** | |
| 1251 | + * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 1252 | + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 1253 | + * @param tElem | |
| 1254 | + * @param tAttrs | |
| 1255 | + * @returns {{pre: Function, post: Function}} | |
| 1256 | + */ | |
| 1257 | + compile: function(tElem, tAttrs) { | |
| 1258 | + // 获取属性,并验证必须按属性 | |
| 1259 | + var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 1260 | + var $cmaps_attr = tAttrs["cmaps"]; // 外部对象与指令内部数据对象字段名映射对象 | |
| 1261 | + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名 | |
| 1262 | + var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名 | |
| 1263 | + | |
| 1264 | + var $dsparams_attr = tAttrs["dsparams"]; // 内部数据源查询参数对象 | |
| 1265 | + var $dsparamsextra_attr = tAttrs["dsparamsextra"]; // 内部数据源查询附加参数对象字符串 | |
| 1266 | + var $iterobjname_attr = tAttrs["iterobjname"]; // 内部数据源迭代的数据变量名 | |
| 1267 | + var $iterobjexp_attr = tAttrs["iterobjexp"]; // 内部显示用的表达式 | |
| 1268 | + var $searchph_attr = tAttrs["searchph"]; // 查询输入占位符字符串 | |
| 1269 | + var $searchexp_attr = tAttrs["searchexp"]; // 查询基于的内部数据源的表达式 | |
| 1270 | + | |
| 1271 | + var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 1272 | + | |
| 1273 | + if (!$name_attr) { | |
| 1274 | + throw new Error("name属性必须填写"); | |
| 1275 | + } | |
| 1276 | + if (!$cmaps_attr) { | |
| 1277 | + throw new Error("cmaps属性必须填写") | |
| 1278 | + } | |
| 1279 | + if (!$dcname_attr || !$icname_attr) { | |
| 1280 | + throw new Error("dcname、icname属性必须填写"); | |
| 1281 | + } | |
| 1282 | + if (!$dsparams_attr) { | |
| 1283 | + throw new Error("dsparams属性必须填写"); | |
| 1284 | + } | |
| 1285 | + if (!$iterobjname_attr) { | |
| 1286 | + throw new Error("iterobjname属性必须填写"); | |
| 1287 | + } | |
| 1288 | + if (!$iterobjexp_attr) { | |
| 1289 | + throw new Error("iterobjexp属性必须填写"); | |
| 1290 | + } | |
| 1291 | + if (!$searchph_attr) { | |
| 1292 | + throw new Error("searchph属性必须填写"); | |
| 1293 | + } | |
| 1294 | + if (!$searchexp_attr) { | |
| 1295 | + throw new Error("searchexp属性必须填写"); | |
| 1296 | + } | |
| 1297 | + | |
| 1298 | + // 内部controlAs名字 | |
| 1299 | + var ctrlAs = "$saSelectCtrl"; | |
| 1300 | + | |
| 1301 | + // 动态设置dom | |
| 1302 | + // dom,最外层name属性设置 | |
| 1303 | + tElem.find("div:first").attr("name", $name_attr); | |
| 1304 | + // dom,最外层divrequired属性设置 | |
| 1305 | + if ($required_attr != undefined) { | |
| 1306 | + tElem.find("div[name=\'" + $name_attr + "\']").attr("required", ""); | |
| 1307 | + } | |
| 1308 | + // dom,ui-select-match的placeholder属性设定 | |
| 1309 | + tElem.find("ui-select-match").attr("placeholder", $searchph_attr); | |
| 1310 | + // dom,ui-select-match的内容设定 | |
| 1311 | + var uiSelectMatchHtml = "{{" + ctrlAs + ".$$internal_match_str($select.selected)}}"; | |
| 1312 | + tElem.find("ui-select-match").html(uiSelectMatchHtml); | |
| 1313 | + // dom,ui-select-choices的repeat属性设定 | |
| 1314 | + var uiSelectChoices_repeatAttr = $iterobjname_attr + "." + $icname_attr + " as " + $iterobjname_attr + " in " + ctrlAs + ".$$data"; | |
| 1315 | + tElem.find("ui-select-choices").attr("repeat", uiSelectChoices_repeatAttr); | |
| 1316 | + // dom,span ng-bind属性设置,TODO:暂时无法用transclude设置,先用属性设置 | |
| 1317 | + tElem.find("ui-select-choices").html("{{" + $iterobjexp_attr + "}}"); | |
| 1318 | + | |
| 1319 | + return { | |
| 1320 | + pre: function (scope, element, attr) { | |
| 1321 | + // TODO: | |
| 1322 | + }, | |
| 1323 | + | |
| 1324 | + /** | |
| 1325 | + * 相当于link函数。 | |
| 1326 | + * @param scope | |
| 1327 | + * @param element | |
| 1328 | + * @param attr | |
| 1329 | + */ | |
| 1330 | + post: function (scope, element, attr) { | |
| 1331 | + | |
| 1332 | + // 添加选中事件处理函数 | |
| 1333 | + scope[ctrlAs].$$internal_select_fn = function($item) { | |
| 1334 | + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";"); | |
| 1335 | + | |
| 1336 | + eval("var obj=" + $cmaps_attr); | |
| 1337 | + for (var mc in obj) { // model的字段名:内部数据源对应字段名 | |
| 1338 | + var ic = obj[mc]; // 内部数据源对应字段 | |
| 1339 | + eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";"); | |
| 1340 | + } | |
| 1341 | + }; | |
| 1342 | + | |
| 1343 | + // 删除选中事件处理函数 | |
| 1344 | + scope[ctrlAs].$$internal_remove_fn = function() { | |
| 1345 | + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;"); | |
| 1346 | + | |
| 1347 | + eval("var obj=" + $cmaps_attr); | |
| 1348 | + var mc; // model的字段名 | |
| 1349 | + for (mc in obj) { | |
| 1350 | + eval("scope[ctrlAs].model" + "." + mc + " = undefined;"); | |
| 1351 | + } | |
| 1352 | + }; | |
| 1353 | + | |
| 1354 | + // 刷新数据 | |
| 1355 | + scope[ctrlAs].$$internal_refresh_fn = function(search) { | |
| 1356 | + if (search && search != "") { // 有search值 | |
| 1357 | + // 处理search | |
| 1358 | + console.log("search:" + search); | |
| 1359 | + | |
| 1360 | + scope[ctrlAs].$$data = []; | |
| 1361 | + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 1362 | + var upTerm = search.toUpperCase(); | |
| 1363 | + if (scope[ctrlAs].$$data.length < 10) { | |
| 1364 | + if (scope[ctrlAs].$$data_real[k].$fullChars.indexOf(upTerm) != -1 | |
| 1365 | + || scope[ctrlAs].$$data_real[k].$camelChars.indexOf(upTerm) != -1 | |
| 1366 | + || scope[ctrlAs].$$data_real[k].$calcu_str.indexOf(upTerm) != -1) { | |
| 1367 | + scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 1368 | + } | |
| 1369 | + } else { | |
| 1370 | + break; | |
| 1371 | + } | |
| 1372 | + } | |
| 1373 | + } | |
| 1374 | + }; | |
| 1375 | + | |
| 1376 | + /** | |
| 1377 | + * 验证内部数据,更新外部model | |
| 1378 | + */ | |
| 1379 | + scope[ctrlAs].$$internal_validate_model = function() { | |
| 1380 | + if (scope[ctrlAs].$$internal_select_value) { | |
| 1381 | + var select_value_temp = scope[ctrlAs].$$internal_select_value; | |
| 1382 | + if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) { | |
| 1383 | + var obj; | |
| 1384 | + for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) { | |
| 1385 | + if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) { | |
| 1386 | + obj = angular.copy(scope[ctrlAs].$$data_real[j]); | |
| 1387 | + break; | |
| 1388 | + } | |
| 1389 | + } | |
| 1390 | + if (obj) { // 在data中判定有没有 | |
| 1391 | + for (var k = 0; k < scope[ctrlAs].$$data.length; k++) { | |
| 1392 | + if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) { | |
| 1393 | + obj = undefined; | |
| 1394 | + break; | |
| 1395 | + } | |
| 1396 | + } | |
| 1397 | + if (obj) { | |
| 1398 | + scope[ctrlAs].$$data.push(obj); | |
| 1399 | + } | |
| 1400 | + // 更新内部model,用于外部验证 | |
| 1401 | + // 内部model的值暂时随意,以后再改 | |
| 1402 | + scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 1403 | + } else { | |
| 1404 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 1405 | + } | |
| 1406 | + | |
| 1407 | + } else { | |
| 1408 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 1409 | + } | |
| 1410 | + | |
| 1411 | + } else { | |
| 1412 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 1413 | + } | |
| 1414 | + }; | |
| 1415 | + | |
| 1416 | + /** | |
| 1417 | + * 内部match表达式转换函数,需要外部绑定此函数的上下文。 | |
| 1418 | + * @param context function上下文 | |
| 1419 | + */ | |
| 1420 | + scope[ctrlAs].$$internal_match_str = function (context) { | |
| 1421 | + var fx = function() { | |
| 1422 | + try { | |
| 1423 | + return eval($searchexp_attr); | |
| 1424 | + } catch (err) { | |
| 1425 | + //console.log(err); | |
| 1426 | + return undefined; | |
| 1427 | + } | |
| 1428 | + | |
| 1429 | + }; | |
| 1430 | + | |
| 1431 | + var str = fx.bind(context)(); | |
| 1432 | + if (str && str != "") | |
| 1433 | + return str; | |
| 1434 | + else | |
| 1435 | + return undefined; | |
| 1436 | + }; | |
| 1437 | + | |
| 1438 | + /** | |
| 1439 | + * 内部方法,读取字典数据作为数据源。 | |
| 1440 | + * @param atype ajax查询类型 | |
| 1441 | + * @param ajaxparamobj 查询参数对象 | |
| 1442 | + */ | |
| 1443 | + scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) { | |
| 1444 | + // 如果ajaxparamobj为空对象,则表示清空内部选项 | |
| 1445 | + var isEmptyObj = true; | |
| 1446 | + for (var name in ajaxparamobj) { | |
| 1447 | + isEmptyObj = false; | |
| 1448 | + } | |
| 1449 | + if (isEmptyObj) { | |
| 1450 | + // 重新创建内部保存的数据 | |
| 1451 | + scope[ctrlAs].$$data_real = []; | |
| 1452 | + // 重新创建内部ui-select显示用数据,默认取10条记录显示 | |
| 1453 | + scope[ctrlAs].$$data = []; | |
| 1454 | + | |
| 1455 | + scope[ctrlAs].$$internal_remove_fn(); | |
| 1456 | + scope[ctrlAs].$$internal_validate_model(); | |
| 1457 | + | |
| 1458 | + return; | |
| 1459 | + } | |
| 1460 | + | |
| 1461 | + if ($dsparamsextra_attr) { // 合并附加参数 | |
| 1462 | + eval("var extra = " + $dsparamsextra_attr); | |
| 1463 | + for (var extrakey in extra) { | |
| 1464 | + ajaxparamobj[extrakey] = extra[extrakey]; | |
| 1465 | + } | |
| 1466 | + } | |
| 1467 | + | |
| 1468 | + $$searchInfoService_g[atype].list( | |
| 1469 | + ajaxparamobj, | |
| 1470 | + function(result) { | |
| 1471 | + console.log("$$internal_ajax_data result"); | |
| 1472 | + | |
| 1473 | + // 重新创建内部保存的数据 | |
| 1474 | + scope[ctrlAs].$$data_real = []; | |
| 1475 | + // result中添加拼音数据,注意:这里要求result返回对象数组 | |
| 1476 | + for (var i = 0; i < result.length; i++) { | |
| 1477 | + // 闭包绑定返回最终查询的值 | |
| 1478 | + var calcu_str = scope[ctrlAs].$$internal_match_str(result[i]); | |
| 1479 | + if (calcu_str) { | |
| 1480 | + // 全拼 | |
| 1481 | + result[i]["$fullChars"] = pinyin.getFullChars(calcu_str); | |
| 1482 | + // 简拼 | |
| 1483 | + result[i]["$camelChars"] = pinyin.getCamelChars(calcu_str); | |
| 1484 | + // 原值 | |
| 1485 | + result[i]["$calcu_str"] = calcu_str; | |
| 1486 | + | |
| 1487 | + scope[ctrlAs].$$data_real.push(result[i]); | |
| 1488 | + } | |
| 1489 | + } | |
| 1490 | + | |
| 1491 | + // 重新创建内部ui-select显示用数据,默认取10条记录显示 | |
| 1492 | + scope[ctrlAs].$$data = []; | |
| 1493 | + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 1494 | + if (scope[ctrlAs].$$data.length < 10) { | |
| 1495 | + scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]); | |
| 1496 | + } else { | |
| 1497 | + break; | |
| 1498 | + } | |
| 1499 | + } | |
| 1500 | + | |
| 1501 | + scope[ctrlAs].$$internal_validate_model(); | |
| 1502 | + }, | |
| 1503 | + function(result) { | |
| 1504 | + throw new Error("ajax查询出错"); | |
| 1505 | + } | |
| 1506 | + ); | |
| 1507 | + }; | |
| 1508 | + | |
| 1509 | + /** | |
| 1510 | + * 内部方法,读取字典数据作为数据源。 | |
| 1511 | + * @param dictype 字典类型,如:gsType | |
| 1512 | + */ | |
| 1513 | + scope[ctrlAs].$$internal_dic_data = function(dictype) { | |
| 1514 | + if (!dictionaryUtils.getByGroup(dictype)) { | |
| 1515 | + throw new error("字典数据不窜在=" + dictype); | |
| 1516 | + } | |
| 1517 | + | |
| 1518 | + // 重新创建内部保存的数据 | |
| 1519 | + scope[ctrlAs].$$data_real = []; | |
| 1520 | + var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup); | |
| 1521 | + var dic_key; // 字典key | |
| 1522 | + | |
| 1523 | + for (dic_key in origin_dicgroup) { | |
| 1524 | + var data = {}; // 重新组合的字典元素对象 | |
| 1525 | + if (dic_key == "true") | |
| 1526 | + data[$icname_attr] = true; | |
| 1527 | + else | |
| 1528 | + data[$icname_attr] = dic_key; | |
| 1529 | + data[$dscol_attr] = origin_dicgroup[dic_key]; | |
| 1530 | + scope[ctrlAs].$$data_real.push(data); | |
| 1531 | + } | |
| 1532 | + | |
| 1533 | + // 重新创建内部ui-select显示用数据,直接复制所有的字典数据 | |
| 1534 | + scope[ctrlAs].$$data = []; | |
| 1535 | + for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 1536 | + scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]); | |
| 1537 | + } | |
| 1538 | + | |
| 1539 | + scope[ctrlAs].$$internal_validate_model(); | |
| 1540 | + }; | |
| 1541 | + | |
| 1542 | + /** | |
| 1543 | + * 内部方法,读取本地动态数据源。 | |
| 1544 | + * @param ldata | |
| 1545 | + */ | |
| 1546 | + scope[ctrlAs].$$internal_local_data = function(ldata) { | |
| 1547 | + // 重新创建内部保存的数据 | |
| 1548 | + scope[ctrlAs].$$data_real = []; | |
| 1549 | + // 重新创建内部ui-select显示用数据,默认取10条记录显示 | |
| 1550 | + scope[ctrlAs].$$data = []; | |
| 1551 | + | |
| 1552 | + // 本地动态数据直接显示,暂时不优化 | |
| 1553 | + for (var i = 0; i < ldata.length; i++) { | |
| 1554 | + scope[ctrlAs].$$data_real.push(ldata[i]); | |
| 1555 | + scope[ctrlAs].$$data.push(ldata[i]); | |
| 1556 | + } | |
| 1557 | + | |
| 1558 | + scope[ctrlAs].$$internal_validate_model(); | |
| 1559 | + }; | |
| 1560 | + | |
| 1561 | + /** | |
| 1562 | + * 监控dsparams属性变化 | |
| 1563 | + */ | |
| 1564 | + attr.$observe("dsparams", function(value) { | |
| 1565 | + if (value && value != "") { | |
| 1566 | + var obj = JSON.parse(value); | |
| 1567 | + console.log("saSelect5 监控到dsparams属性变化,old=" + $dsparams_attr + ",new=" + value); | |
| 1568 | + | |
| 1569 | + // dsparams格式如下: | |
| 1570 | + // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'} | |
| 1571 | + | |
| 1572 | + if (obj.type == 'dic') { | |
| 1573 | + scope[ctrlAs].$$internal_dic_data(obj.param); | |
| 1574 | + | |
| 1575 | + } else if (obj.type == 'ajax') { | |
| 1576 | + scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param); | |
| 1577 | + } else if (obj.type == 'local') { | |
| 1578 | + scope[ctrlAs].$$internal_local_data(obj.ldata); | |
| 1579 | + } else { | |
| 1580 | + throw new Error("dsparams参数格式异常=" + obj); | |
| 1581 | + } | |
| 1582 | + | |
| 1583 | + } | |
| 1584 | + }); | |
| 1585 | + | |
| 1586 | + /** | |
| 1587 | + * 监控外部模型dcname的值的变化。 | |
| 1588 | + */ | |
| 1589 | + scope.$watch( | |
| 1590 | + function() { | |
| 1591 | + return eval("scope." + ctrlAs + ".model" + "." + $dcname_attr); | |
| 1592 | + }, | |
| 1593 | + function(newValue, oldValue) { | |
| 1594 | + if (newValue === undefined && oldValue === undefined) { | |
| 1595 | + // 两侧都是undefined,不处理 | |
| 1596 | + | |
| 1597 | + } else { | |
| 1598 | + console.log("saSelect5 监控到外部模型" + $dcname_attr + "属性值变化,old=" + oldValue + ",new=" + newValue); | |
| 1599 | + scope[ctrlAs].$$internal_select_value = newValue; | |
| 1600 | + scope[ctrlAs].$$internal_validate_model(); | |
| 1601 | + } | |
| 1602 | + }, | |
| 1603 | + true | |
| 1604 | + ); | |
| 1605 | + } | |
| 1606 | + }; | |
| 1607 | + } | |
| 1608 | + }; | |
| 1609 | + } | |
| 782 | 1610 | ]); |
| 783 | - | |
| 784 | - | |
| 785 | -/** | |
| 786 | - * saSelect4指令,封装angular-ui-select控件,并添加相应的业务。 | |
| 787 | - * name(必须):控件的名字 | |
| 788 | - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 789 | - * placeholder(可选):输入框占位符字符串 | |
| 790 | - * | |
| 791 | - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 792 | - * dcname(必须):绑定的model字段名,如:dcname=xl.id | |
| 793 | - * icname(必须):内部与之对应的字段名,如:icname=code | |
| 794 | - * | |
| 795 | - * cmaps(可选):model其他字段和内部数据字段名映射,如:{{ {'xl.id' : 'id', 'xl.name' : 'name'} | json}} | |
| 796 | - * dsparams(必须):内部数据源查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }} | |
| 797 | - * dscol(必须):内部显示的信息(暂时用内部字段),如:dscol=name | |
| 798 | - * required(可选):是否要用required验证 | |
| 799 | - */ | |
| 800 | -angular.module('ScheduleApp').directive('saSelect4', [ | |
| 801 | - '$timeout', | |
| 802 | - '$$SearchInfoService_g', | |
| 803 | - function($timeout, $$searchInfoService_g) { | |
| 804 | - return { | |
| 805 | - restrict: 'E', | |
| 806 | - templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect4Template.html', | |
| 807 | - scope: { | |
| 808 | - model: "=" // 独立作用域,关联外部的模型object | |
| 809 | - }, | |
| 810 | - controllerAs: "$saSelectCtrl", | |
| 811 | - bindToController: true, | |
| 812 | - controller: function($scope) { | |
| 813 | - var self = this; | |
| 814 | - self.$$data = []; // ui-select显示用的数据 | |
| 815 | - self.$$data_real = []; // 内部真实的数据 | |
| 816 | - | |
| 817 | - // saSelect4组件的ng-model,用于外部绑定验证等操作 | |
| 818 | - self.$$internalmodel = undefined; | |
| 819 | - | |
| 820 | - self.$$internal_select_value = undefined; // 选中的值 | |
| 821 | - }, | |
| 822 | - | |
| 823 | - /** | |
| 824 | - * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 825 | - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 826 | - * @param tElem | |
| 827 | - * @param tAttrs | |
| 828 | - * @returns {{pre: Function, post: Function}} | |
| 829 | - */ | |
| 830 | - compile: function(tElem, tAttrs) { | |
| 831 | - // 获取属性 | |
| 832 | - var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 833 | - var $placeholder_attr = tAttrs["placeholder"]; // 占位符的名字 | |
| 834 | - | |
| 835 | - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名 | |
| 836 | - var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名 | |
| 837 | - | |
| 838 | - var $cmaps_attr = tAttrs["cmaps"]; // model其他字段和内部数据字段名映射 | |
| 839 | - var $dscol_attr = tAttrs["dscol"]; // 内部显示的信息 | |
| 840 | - var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 841 | - | |
| 842 | - // controlAs名字 | |
| 843 | - var ctrlAs = "$saSelectCtrl"; | |
| 844 | - | |
| 845 | - // 验证属性 | |
| 846 | - if (!$name_attr) { | |
| 847 | - throw new error("name属性必须填写"); | |
| 848 | - } | |
| 849 | - if (!$dcname_attr) { | |
| 850 | - throw new error("dcname属性必须填写"); | |
| 851 | - } | |
| 852 | - if (!$icname_attr) { | |
| 853 | - throw new error("icname属性必须填写"); | |
| 854 | - } | |
| 855 | - if (!$dscol_attr) { | |
| 856 | - throw new error("dscol属性必须填写"); | |
| 857 | - } | |
| 858 | - | |
| 859 | - // 动态设置dom | |
| 860 | - // dom required 属性 | |
| 861 | - if ($required_attr != undefined) { | |
| 862 | - tElem.find("div").attr("required", ""); | |
| 863 | - } | |
| 864 | - // dom placeholder 属性 | |
| 865 | - tElem.find("ui-select-match").attr("placeholder", $placeholder_attr); | |
| 866 | - // dom dscol 属性 | |
| 867 | - tElem.find("ui-select-match").html("{{$select.selected" + "." + $dscol_attr + "}}"); | |
| 868 | - tElem.find("ui-select-choices span").attr("ng-bind", "item" + "." + $dscol_attr); | |
| 869 | - // dom icname 属性 | |
| 870 | - tElem.find("ui-select-choices").attr("repeat", "item" + "." + $icname_attr + " as item in $saSelectCtrl.$$data"); | |
| 871 | - // dom name 属性 | |
| 872 | - tElem.find("div").attr("name", $name_attr); | |
| 873 | - | |
| 874 | - return { | |
| 875 | - pre: function(scope, element, attr) { | |
| 876 | - // TODO: | |
| 877 | - }, | |
| 878 | - | |
| 879 | - /** | |
| 880 | - * 相当于link函数。 | |
| 881 | - * @param scope | |
| 882 | - * @param element | |
| 883 | - * @param attr | |
| 884 | - */ | |
| 885 | - post: function(scope, element, attr) { | |
| 886 | - | |
| 887 | - // 添加选中事件处理函数 | |
| 888 | - scope[ctrlAs].$$internal_select_fn = function($item) { | |
| 889 | - if ($dcname_attr && $icname_attr) { | |
| 890 | - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";"); | |
| 891 | - } | |
| 892 | - | |
| 893 | - if ($cmaps_attr) { | |
| 894 | - for (var mc in $cmaps_attr) { // model的字段名:内部数据源对应字段名 | |
| 895 | - var ic = $cmaps_attr[mc]; // 内部数据源对应字段 | |
| 896 | - eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";"); | |
| 897 | - } | |
| 898 | - } | |
| 899 | - }; | |
| 900 | - | |
| 901 | - // 删除选中事件处理函数 | |
| 902 | - scope[ctrlAs].$$internal_remove_fn = function() { | |
| 903 | - scope[ctrlAs].$$internal_select_value = undefined; | |
| 904 | - if ($dcname_attr) { | |
| 905 | - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;"); | |
| 906 | - } | |
| 907 | - | |
| 908 | - if ($cmaps_attr) { | |
| 909 | - var mc; // model的字段名 | |
| 910 | - for (mc in $cmaps_attr) { | |
| 911 | - eval("scope[ctrlAs].model" + "." + mc + " = undefined;"); | |
| 912 | - } | |
| 913 | - } | |
| 914 | - scope[ctrlAs].$$internal_validate_model(); | |
| 915 | - }; | |
| 916 | - | |
| 917 | - // 刷新数据 | |
| 918 | - scope[ctrlAs].$$internal_refresh_fn = function(search) { | |
| 919 | - if (search && search != "") { // 有search值 | |
| 920 | - // 处理search | |
| 921 | - console.log("search:" + search); | |
| 922 | - | |
| 923 | - scope[ctrlAs].$$data = []; | |
| 924 | - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 925 | - var upTerm = search.toUpperCase(); | |
| 926 | - if (scope[ctrlAs].$$data.length < 10) { | |
| 927 | - if (scope[ctrlAs].$$data_real[k].fullChars.indexOf(upTerm) != -1 | |
| 928 | - || scope[ctrlAs].$$data_real[k].camelChars.indexOf(upTerm) != -1) { | |
| 929 | - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 930 | - } | |
| 931 | - } else { | |
| 932 | - break; | |
| 933 | - } | |
| 934 | - } | |
| 935 | - } | |
| 936 | - }; | |
| 937 | - | |
| 938 | - /** | |
| 939 | - * 验证内部数据,更新外部model | |
| 940 | - */ | |
| 941 | - scope[ctrlAs].$$internal_validate_model = function() { | |
| 942 | - if (scope[ctrlAs].$$internal_select_value) { | |
| 943 | - var select_value_temp = scope[ctrlAs].$$internal_select_value; | |
| 944 | - if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) { | |
| 945 | - var obj; | |
| 946 | - for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) { | |
| 947 | - if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) { | |
| 948 | - obj = angular.copy(scope[ctrlAs].$$data_real[j]); | |
| 949 | - break; | |
| 950 | - } | |
| 951 | - } | |
| 952 | - if (obj) { // 在data中判定有没有 | |
| 953 | - for (var k = 0; k < scope[ctrlAs].$$data.length; k++) { | |
| 954 | - if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) { | |
| 955 | - obj = undefined; | |
| 956 | - break; | |
| 957 | - } | |
| 958 | - } | |
| 959 | - if (obj) { | |
| 960 | - scope[ctrlAs].$$data.push(obj); | |
| 961 | - } | |
| 962 | - // 更新内部model,用于外部验证 | |
| 963 | - // 内部model的值暂时随意,以后再改 | |
| 964 | - scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 965 | - } else { | |
| 966 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 967 | - } | |
| 968 | - | |
| 969 | - } else { | |
| 970 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 971 | - } | |
| 972 | - | |
| 973 | - } else { | |
| 974 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 975 | - } | |
| 976 | - }; | |
| 977 | - | |
| 978 | - /** | |
| 979 | - * 内部方法,读取字典数据作为数据源。 | |
| 980 | - * @param atype ajax查询类型 | |
| 981 | - * @param ajaxparamobj 查询参数对象 | |
| 982 | - */ | |
| 983 | - scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) { | |
| 984 | - ajaxparamobj.type = 'all'; | |
| 985 | - $$searchInfoService_g[atype].list( | |
| 986 | - ajaxparamobj, | |
| 987 | - function(result) { | |
| 988 | - console.log("$$internal_ajax_data result"); | |
| 989 | - | |
| 990 | - // 清空内部数据 | |
| 991 | - scope[ctrlAs].$$data_real = []; | |
| 992 | - scope[ctrlAs].$$data = []; | |
| 993 | - | |
| 994 | - // result中添加拼音数据,注意:这里要求result返回对象数组 | |
| 995 | - for (var i = 0; i < result.length; i ++) { | |
| 996 | - if ($dscol_attr) { | |
| 997 | - if (eval("result[i]" + "." + $dscol_attr)) { | |
| 998 | - // 全拼 | |
| 999 | - result[i]["fullChars"] = pinyin.getFullChars(eval("result[i]" + "." + $dscol_attr)).toUpperCase(); | |
| 1000 | - // 简拼 | |
| 1001 | - result[i]["camelChars"] = pinyin.getCamelChars(eval("result[i]" + "." + $dscol_attr)); | |
| 1002 | - } | |
| 1003 | - } | |
| 1004 | - | |
| 1005 | - if (result[i]["fullChars"]) { // 有拼音的加入数据源 | |
| 1006 | - scope[ctrlAs].$$data_real.push(result[i]); | |
| 1007 | - } | |
| 1008 | - | |
| 1009 | - } | |
| 1010 | - | |
| 1011 | - // 数据量太大,取10条记录显示 | |
| 1012 | - if (angular.isArray(scope[ctrlAs].$$data_real)) { | |
| 1013 | - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 1014 | - if (scope[ctrlAs].$$data.length < 10) { | |
| 1015 | - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 1016 | - } else { | |
| 1017 | - break; | |
| 1018 | - } | |
| 1019 | - } | |
| 1020 | - } | |
| 1021 | - | |
| 1022 | - scope[ctrlAs].$$internal_validate_model(); | |
| 1023 | - }, | |
| 1024 | - function(result) { | |
| 1025 | - | |
| 1026 | - } | |
| 1027 | - ); | |
| 1028 | - }; | |
| 1029 | - | |
| 1030 | - /** | |
| 1031 | - * 内部方法,读取字典数据作为数据源。 | |
| 1032 | - * @param dictype 字典类型,如:gsType | |
| 1033 | - */ | |
| 1034 | - scope[ctrlAs].$$internal_dic_data = function(dictype) { | |
| 1035 | - if (!dictionaryUtils.getByGroup(dictype)) { | |
| 1036 | - throw new error("字典数据不窜在=" + dictype); | |
| 1037 | - } | |
| 1038 | - | |
| 1039 | - // 清空内部数据 | |
| 1040 | - scope[ctrlAs].$$data_real = []; | |
| 1041 | - scope[ctrlAs].$$data = []; | |
| 1042 | - | |
| 1043 | - var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup); | |
| 1044 | - var dic_key; // 字典key | |
| 1045 | - | |
| 1046 | - for (dic_key in origin_dicgroup) { | |
| 1047 | - var data = {}; // 重新组合的字典元素对象 | |
| 1048 | - if (dic_key == "true") | |
| 1049 | - data[$icname_attr] = true; | |
| 1050 | - else | |
| 1051 | - data[$icname_attr] = dic_key; | |
| 1052 | - data[$dscol_attr] = origin_dicgroup[dic_key]; | |
| 1053 | - scope[ctrlAs].$$data_real.push(data); | |
| 1054 | - } | |
| 1055 | - // 这里直接将$$data_real数据深拷贝到$$data | |
| 1056 | - angular.copy(scope[ctrlAs].$$data_real, scope[ctrlAs].$$data); | |
| 1057 | - scope[ctrlAs].$$internal_validate_model(); | |
| 1058 | - }; | |
| 1059 | - | |
| 1060 | - attr.$observe("dsparams", function(value) { | |
| 1061 | - if (value && value != "") { | |
| 1062 | - var obj = JSON.parse(value); | |
| 1063 | - console.log("observe 监控 dsparams=" + obj); | |
| 1064 | - | |
| 1065 | - // dsparams格式如下: | |
| 1066 | - // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'} | |
| 1067 | - | |
| 1068 | - if (obj.type == 'dic') { | |
| 1069 | - scope[ctrlAs].$$internal_dic_data(obj.param); | |
| 1070 | - | |
| 1071 | - } else if (obj.type == 'ajax') { | |
| 1072 | - scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param); | |
| 1073 | - } else { | |
| 1074 | - throw new Error("dsparams参数格式异常=" + obj); | |
| 1075 | - } | |
| 1076 | - | |
| 1077 | - } | |
| 1078 | - | |
| 1079 | - }); | |
| 1080 | - | |
| 1081 | - // 监控model绑定的dcvalue值变化 | |
| 1082 | - attr.$observe("dcvalue", function(value) { | |
| 1083 | - if (value && value != "") { | |
| 1084 | - console.log("observe 监控 dcvalue=" + value); | |
| 1085 | - scope[ctrlAs].$$internal_select_value = value; | |
| 1086 | - scope[ctrlAs].$$internal_validate_model(); | |
| 1087 | - } | |
| 1088 | - | |
| 1089 | - // 闭包测试 | |
| 1090 | - var obj = {'a':1,'b':2}; | |
| 1091 | - var tfx = scope[ctrlAs].$$test.bind(obj); | |
| 1092 | - console.log("闭包测试=" + tfx()); | |
| 1093 | - }); | |
| 1094 | - | |
| 1095 | - scope[ctrlAs].$$test = function() { | |
| 1096 | - var exp = "this.a + '(' + this.b + ')'"; | |
| 1097 | - console.log("exp=" + exp); | |
| 1098 | - return eval(exp); | |
| 1099 | - }; | |
| 1100 | - } | |
| 1101 | - }; | |
| 1102 | - | |
| 1103 | - } | |
| 1104 | - | |
| 1105 | - }; | |
| 1106 | - } | |
| 1107 | -]); | |
| 1108 | -/** | |
| 1109 | - * saSelect5指令,基于简拼查询的select,内部封装angular-ui-select控件,并嵌入相应的业务逻辑。 | |
| 1110 | - * name(必须):控件的名字 | |
| 1111 | - * model(必须):独立作用域,指定一个外部对象模型双向绑定,如:model=ctrl.employeeInfoForSave | |
| 1112 | - * cmaps(必须):外部对象与指令内部数据对象字段名映射对象字符串,如:{'xl.id' : 'id', 'xl.name' : 'name'} | |
| 1113 | - * dcname(必须):绑定的model字段名,如:dcname=xl.id | |
| 1114 | - * icname(必须):内部与之对应的字段名,如:icname=id | |
| 1115 | - * | |
| 1116 | - * dsparams(必须):内部数据源查询参数对象,如:{{ {'ttid_eq': ctrl.rerunManageForSave.rerunTtinfo.id} | json }} | |
| 1117 | - * dsparamsextra(可选):内部数据源查询附加参数对象字符串,如:{'type':'all'} | |
| 1118 | - * iterobjname(必须):内部数据源迭代的数据变量名,如:iterobjname=item | |
| 1119 | - * iterobjexp(必须):内部显示用的表达式 | |
| 1120 | - * searchph(必须):查询输入占位符字符串,如:searchph=请输入... | |
| 1121 | - * searchexp(必须):查询基于的内部数据源的表达式,如:searchexp=this.name+'('+this.code+')' | |
| 1122 | - * | |
| 1123 | - * required(可选):是否需要form的required验证 | |
| 1124 | - * | |
| 1125 | - */ | |
| 1126 | -angular.module('ScheduleApp').directive('saSelect5', [ | |
| 1127 | - '$timeout', | |
| 1128 | - '$$SearchInfoService_g', | |
| 1129 | - function($timeout, $$searchInfoService_g) { | |
| 1130 | - return { | |
| 1131 | - restrict: 'E', | |
| 1132 | - templateUrl: '/pages/scheduleApp/module/common/dts1/select/saSelect5Template.html', | |
| 1133 | - scope: { // 独立作用域 | |
| 1134 | - model: "=" // 绑定外部对象 | |
| 1135 | - }, | |
| 1136 | - controllerAs: "$saSelectCtrl", | |
| 1137 | - bindToController: true, | |
| 1138 | - controller: function($scope) { | |
| 1139 | - var self = this; | |
| 1140 | - self.$$data = []; // 内部ui-select显示用数据 | |
| 1141 | - self.$$data_real = []; // 内部保存的实际数据 | |
| 1142 | - | |
| 1143 | - // myselect组件的ng-model,用于外部绑定验证等操作 | |
| 1144 | - self.$$internalmodel = undefined; | |
| 1145 | - | |
| 1146 | - self.$$internal_select_value = undefined; // 选中的值 | |
| 1147 | - | |
| 1148 | - }, | |
| 1149 | - | |
| 1150 | - /** | |
| 1151 | - * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 1152 | - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 1153 | - * @param tElem | |
| 1154 | - * @param tAttrs | |
| 1155 | - * @returns {{pre: Function, post: Function}} | |
| 1156 | - */ | |
| 1157 | - compile: function(tElem, tAttrs) { | |
| 1158 | - // 获取属性,并验证必须按属性 | |
| 1159 | - var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 1160 | - var $cmaps_attr = tAttrs["cmaps"]; // 外部对象与指令内部数据对象字段名映射对象 | |
| 1161 | - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名 | |
| 1162 | - var $icname_attr = tAttrs["icname"]; // 内部与之对应的字段名 | |
| 1163 | - | |
| 1164 | - var $dsparams_attr = tAttrs["dsparams"]; // 内部数据源查询参数对象 | |
| 1165 | - var $dsparamsextra_attr = tAttrs["dsparamsextra"]; // 内部数据源查询附加参数对象字符串 | |
| 1166 | - var $iterobjname_attr = tAttrs["iterobjname"]; // 内部数据源迭代的数据变量名 | |
| 1167 | - var $iterobjexp_attr = tAttrs["iterobjexp"]; // 内部显示用的表达式 | |
| 1168 | - var $searchph_attr = tAttrs["searchph"]; // 查询输入占位符字符串 | |
| 1169 | - var $searchexp_attr = tAttrs["searchexp"]; // 查询基于的内部数据源的表达式 | |
| 1170 | - | |
| 1171 | - var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 1172 | - | |
| 1173 | - if (!$name_attr) { | |
| 1174 | - throw new Error("name属性必须填写"); | |
| 1175 | - } | |
| 1176 | - if (!$cmaps_attr) { | |
| 1177 | - throw new Error("cmaps属性必须填写") | |
| 1178 | - } | |
| 1179 | - if (!$dcname_attr || !$icname_attr) { | |
| 1180 | - throw new Error("dcname、icname属性必须填写"); | |
| 1181 | - } | |
| 1182 | - if (!$dsparams_attr) { | |
| 1183 | - throw new Error("dsparams属性必须填写"); | |
| 1184 | - } | |
| 1185 | - if (!$iterobjname_attr) { | |
| 1186 | - throw new Error("iterobjname属性必须填写"); | |
| 1187 | - } | |
| 1188 | - if (!$iterobjexp_attr) { | |
| 1189 | - throw new Error("iterobjexp属性必须填写"); | |
| 1190 | - } | |
| 1191 | - if (!$searchph_attr) { | |
| 1192 | - throw new Error("searchph属性必须填写"); | |
| 1193 | - } | |
| 1194 | - if (!$searchexp_attr) { | |
| 1195 | - throw new Error("searchexp属性必须填写"); | |
| 1196 | - } | |
| 1197 | - | |
| 1198 | - // 内部controlAs名字 | |
| 1199 | - var ctrlAs = "$saSelectCtrl"; | |
| 1200 | - | |
| 1201 | - // 动态设置dom | |
| 1202 | - // dom,最外层name属性设置 | |
| 1203 | - tElem.find("div:first").attr("name", $name_attr); | |
| 1204 | - // dom,最外层divrequired属性设置 | |
| 1205 | - if ($required_attr != undefined) { | |
| 1206 | - tElem.find("div[name=\'" + $name_attr + "\']").attr("required", ""); | |
| 1207 | - } | |
| 1208 | - // dom,ui-select-match的placeholder属性设定 | |
| 1209 | - tElem.find("ui-select-match").attr("placeholder", $searchph_attr); | |
| 1210 | - // dom,ui-select-match的内容设定 | |
| 1211 | - var uiSelectMatchHtml = "{{" + ctrlAs + ".$$internal_match_str($select.selected)}}"; | |
| 1212 | - tElem.find("ui-select-match").html(uiSelectMatchHtml); | |
| 1213 | - // dom,ui-select-choices的repeat属性设定 | |
| 1214 | - var uiSelectChoices_repeatAttr = $iterobjname_attr + "." + $icname_attr + " as " + $iterobjname_attr + " in " + ctrlAs + ".$$data"; | |
| 1215 | - tElem.find("ui-select-choices").attr("repeat", uiSelectChoices_repeatAttr); | |
| 1216 | - // dom,span ng-bind属性设置,TODO:暂时无法用transclude设置,先用属性设置 | |
| 1217 | - tElem.find("ui-select-choices").html("{{" + $iterobjexp_attr + "}}"); | |
| 1218 | - | |
| 1219 | - return { | |
| 1220 | - pre: function (scope, element, attr) { | |
| 1221 | - // TODO: | |
| 1222 | - }, | |
| 1223 | - | |
| 1224 | - /** | |
| 1225 | - * 相当于link函数。 | |
| 1226 | - * @param scope | |
| 1227 | - * @param element | |
| 1228 | - * @param attr | |
| 1229 | - */ | |
| 1230 | - post: function (scope, element, attr) { | |
| 1231 | - | |
| 1232 | - // 添加选中事件处理函数 | |
| 1233 | - scope[ctrlAs].$$internal_select_fn = function($item) { | |
| 1234 | - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = $item" + "." + $icname_attr + ";"); | |
| 1235 | - | |
| 1236 | - eval("var obj=" + $cmaps_attr); | |
| 1237 | - for (var mc in obj) { // model的字段名:内部数据源对应字段名 | |
| 1238 | - var ic = obj[mc]; // 内部数据源对应字段 | |
| 1239 | - eval("scope[ctrlAs].model" + "." + mc + " = $item" + "." + ic + ";"); | |
| 1240 | - } | |
| 1241 | - }; | |
| 1242 | - | |
| 1243 | - // 删除选中事件处理函数 | |
| 1244 | - scope[ctrlAs].$$internal_remove_fn = function() { | |
| 1245 | - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = undefined;"); | |
| 1246 | - | |
| 1247 | - eval("var obj=" + $cmaps_attr); | |
| 1248 | - var mc; // model的字段名 | |
| 1249 | - for (mc in obj) { | |
| 1250 | - eval("scope[ctrlAs].model" + "." + mc + " = undefined;"); | |
| 1251 | - } | |
| 1252 | - }; | |
| 1253 | - | |
| 1254 | - // 刷新数据 | |
| 1255 | - scope[ctrlAs].$$internal_refresh_fn = function(search) { | |
| 1256 | - if (search && search != "") { // 有search值 | |
| 1257 | - // 处理search | |
| 1258 | - console.log("search:" + search); | |
| 1259 | - | |
| 1260 | - scope[ctrlAs].$$data = []; | |
| 1261 | - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 1262 | - var upTerm = search.toUpperCase(); | |
| 1263 | - if (scope[ctrlAs].$$data.length < 10) { | |
| 1264 | - if (scope[ctrlAs].$$data_real[k].$fullChars.indexOf(upTerm) != -1 | |
| 1265 | - || scope[ctrlAs].$$data_real[k].$camelChars.indexOf(upTerm) != -1 | |
| 1266 | - || scope[ctrlAs].$$data_real[k].$calcu_str.indexOf(upTerm) != -1) { | |
| 1267 | - scope[ctrlAs].$$data.push(angular.copy(scope[ctrlAs].$$data_real[k])); | |
| 1268 | - } | |
| 1269 | - } else { | |
| 1270 | - break; | |
| 1271 | - } | |
| 1272 | - } | |
| 1273 | - } | |
| 1274 | - }; | |
| 1275 | - | |
| 1276 | - /** | |
| 1277 | - * 验证内部数据,更新外部model | |
| 1278 | - */ | |
| 1279 | - scope[ctrlAs].$$internal_validate_model = function() { | |
| 1280 | - if (scope[ctrlAs].$$internal_select_value) { | |
| 1281 | - var select_value_temp = scope[ctrlAs].$$internal_select_value; | |
| 1282 | - if (scope[ctrlAs].$$data_real && scope[ctrlAs].$$data_real.length > 0) { | |
| 1283 | - var obj; | |
| 1284 | - for (var j = 0; j < scope[ctrlAs].$$data_real.length; j++) { | |
| 1285 | - if (eval("scope[ctrlAs].$$data_real[j]" + "." + $icname_attr + " == select_value_temp")) { | |
| 1286 | - obj = angular.copy(scope[ctrlAs].$$data_real[j]); | |
| 1287 | - break; | |
| 1288 | - } | |
| 1289 | - } | |
| 1290 | - if (obj) { // 在data中判定有没有 | |
| 1291 | - for (var k = 0; k < scope[ctrlAs].$$data.length; k++) { | |
| 1292 | - if (eval("scope[ctrlAs].$$data[k]" + "." + $icname_attr + " == obj." + $icname_attr)) { | |
| 1293 | - obj = undefined; | |
| 1294 | - break; | |
| 1295 | - } | |
| 1296 | - } | |
| 1297 | - if (obj) { | |
| 1298 | - scope[ctrlAs].$$data.push(obj); | |
| 1299 | - } | |
| 1300 | - // 更新内部model,用于外部验证 | |
| 1301 | - // 内部model的值暂时随意,以后再改 | |
| 1302 | - scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 1303 | - } else { | |
| 1304 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 1305 | - } | |
| 1306 | - | |
| 1307 | - } else { | |
| 1308 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 1309 | - } | |
| 1310 | - | |
| 1311 | - } else { | |
| 1312 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 1313 | - } | |
| 1314 | - }; | |
| 1315 | - | |
| 1316 | - /** | |
| 1317 | - * 内部match表达式转换函数,需要外部绑定此函数的上下文。 | |
| 1318 | - * @param context function上下文 | |
| 1319 | - */ | |
| 1320 | - scope[ctrlAs].$$internal_match_str = function (context) { | |
| 1321 | - var fx = function() { | |
| 1322 | - try { | |
| 1323 | - return eval($searchexp_attr); | |
| 1324 | - } catch (err) { | |
| 1325 | - //console.log(err); | |
| 1326 | - return undefined; | |
| 1327 | - } | |
| 1328 | - | |
| 1329 | - }; | |
| 1330 | - | |
| 1331 | - var str = fx.bind(context)(); | |
| 1332 | - if (str && str != "") | |
| 1333 | - return str; | |
| 1334 | - else | |
| 1335 | - return undefined; | |
| 1336 | - }; | |
| 1337 | - | |
| 1338 | - /** | |
| 1339 | - * 内部方法,读取字典数据作为数据源。 | |
| 1340 | - * @param atype ajax查询类型 | |
| 1341 | - * @param ajaxparamobj 查询参数对象 | |
| 1342 | - */ | |
| 1343 | - scope[ctrlAs].$$internal_ajax_data = function(atype, ajaxparamobj) { | |
| 1344 | - // 如果ajaxparamobj为空对象,则表示清空内部选项 | |
| 1345 | - var isEmptyObj = true; | |
| 1346 | - for (var name in ajaxparamobj) { | |
| 1347 | - isEmptyObj = false; | |
| 1348 | - } | |
| 1349 | - if (isEmptyObj) { | |
| 1350 | - // 重新创建内部保存的数据 | |
| 1351 | - scope[ctrlAs].$$data_real = []; | |
| 1352 | - // 重新创建内部ui-select显示用数据,默认取10条记录显示 | |
| 1353 | - scope[ctrlAs].$$data = []; | |
| 1354 | - | |
| 1355 | - scope[ctrlAs].$$internal_remove_fn(); | |
| 1356 | - scope[ctrlAs].$$internal_validate_model(); | |
| 1357 | - | |
| 1358 | - return; | |
| 1359 | - } | |
| 1360 | - | |
| 1361 | - if ($dsparamsextra_attr) { // 合并附加参数 | |
| 1362 | - eval("var extra = " + $dsparamsextra_attr); | |
| 1363 | - for (var extrakey in extra) { | |
| 1364 | - ajaxparamobj[extrakey] = extra[extrakey]; | |
| 1365 | - } | |
| 1366 | - } | |
| 1367 | - | |
| 1368 | - $$searchInfoService_g[atype].list( | |
| 1369 | - ajaxparamobj, | |
| 1370 | - function(result) { | |
| 1371 | - console.log("$$internal_ajax_data result"); | |
| 1372 | - | |
| 1373 | - // 重新创建内部保存的数据 | |
| 1374 | - scope[ctrlAs].$$data_real = []; | |
| 1375 | - // result中添加拼音数据,注意:这里要求result返回对象数组 | |
| 1376 | - for (var i = 0; i < result.length; i++) { | |
| 1377 | - // 闭包绑定返回最终查询的值 | |
| 1378 | - var calcu_str = scope[ctrlAs].$$internal_match_str(result[i]); | |
| 1379 | - if (calcu_str) { | |
| 1380 | - // 全拼 | |
| 1381 | - result[i]["$fullChars"] = pinyin.getFullChars(calcu_str); | |
| 1382 | - // 简拼 | |
| 1383 | - result[i]["$camelChars"] = pinyin.getCamelChars(calcu_str); | |
| 1384 | - // 原值 | |
| 1385 | - result[i]["$calcu_str"] = calcu_str; | |
| 1386 | - | |
| 1387 | - scope[ctrlAs].$$data_real.push(result[i]); | |
| 1388 | - } | |
| 1389 | - } | |
| 1390 | - | |
| 1391 | - // 重新创建内部ui-select显示用数据,默认取10条记录显示 | |
| 1392 | - scope[ctrlAs].$$data = []; | |
| 1393 | - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 1394 | - if (scope[ctrlAs].$$data.length < 10) { | |
| 1395 | - scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]); | |
| 1396 | - } else { | |
| 1397 | - break; | |
| 1398 | - } | |
| 1399 | - } | |
| 1400 | - | |
| 1401 | - scope[ctrlAs].$$internal_validate_model(); | |
| 1402 | - }, | |
| 1403 | - function(result) { | |
| 1404 | - throw new Error("ajax查询出错"); | |
| 1405 | - } | |
| 1406 | - ); | |
| 1407 | - }; | |
| 1408 | - | |
| 1409 | - /** | |
| 1410 | - * 内部方法,读取字典数据作为数据源。 | |
| 1411 | - * @param dictype 字典类型,如:gsType | |
| 1412 | - */ | |
| 1413 | - scope[ctrlAs].$$internal_dic_data = function(dictype) { | |
| 1414 | - if (!dictionaryUtils.getByGroup(dictype)) { | |
| 1415 | - throw new error("字典数据不窜在=" + dictype); | |
| 1416 | - } | |
| 1417 | - | |
| 1418 | - // 重新创建内部保存的数据 | |
| 1419 | - scope[ctrlAs].$$data_real = []; | |
| 1420 | - var origin_dicgroup = dictionaryUtils.getByGroup(dicgroup); | |
| 1421 | - var dic_key; // 字典key | |
| 1422 | - | |
| 1423 | - for (dic_key in origin_dicgroup) { | |
| 1424 | - var data = {}; // 重新组合的字典元素对象 | |
| 1425 | - if (dic_key == "true") | |
| 1426 | - data[$icname_attr] = true; | |
| 1427 | - else | |
| 1428 | - data[$icname_attr] = dic_key; | |
| 1429 | - data[$dscol_attr] = origin_dicgroup[dic_key]; | |
| 1430 | - scope[ctrlAs].$$data_real.push(data); | |
| 1431 | - } | |
| 1432 | - | |
| 1433 | - // 重新创建内部ui-select显示用数据,直接复制所有的字典数据 | |
| 1434 | - scope[ctrlAs].$$data = []; | |
| 1435 | - for (var k = 0; k < scope[ctrlAs].$$data_real.length; k++) { | |
| 1436 | - scope[ctrlAs].$$data.push(scope[ctrlAs].$$data_real[k]); | |
| 1437 | - } | |
| 1438 | - | |
| 1439 | - scope[ctrlAs].$$internal_validate_model(); | |
| 1440 | - }; | |
| 1441 | - | |
| 1442 | - /** | |
| 1443 | - * 监控dsparams属性变化 | |
| 1444 | - */ | |
| 1445 | - attr.$observe("dsparams", function(value) { | |
| 1446 | - if (value && value != "") { | |
| 1447 | - var obj = JSON.parse(value); | |
| 1448 | - console.log("saSelect5 监控到dsparams属性变化,old=" + $dsparams_attr + ",new=" + value); | |
| 1449 | - | |
| 1450 | - // dsparams格式如下: | |
| 1451 | - // {type: 'dic/ajax', param: 'dic名字'/'ajax查询参数对象', atype: 'ajax查询类型'} | |
| 1452 | - | |
| 1453 | - if (obj.type == 'dic') { | |
| 1454 | - scope[ctrlAs].$$internal_dic_data(obj.param); | |
| 1455 | - | |
| 1456 | - } else if (obj.type == 'ajax') { | |
| 1457 | - scope[ctrlAs].$$internal_ajax_data(obj.atype, obj.param); | |
| 1458 | - } else { | |
| 1459 | - throw new Error("dsparams参数格式异常=" + obj); | |
| 1460 | - } | |
| 1461 | - | |
| 1462 | - } | |
| 1463 | - }); | |
| 1464 | - | |
| 1465 | - /** | |
| 1466 | - * 监控外部模型dcname的值的变化。 | |
| 1467 | - */ | |
| 1468 | - scope.$watch( | |
| 1469 | - function() { | |
| 1470 | - return eval("scope." + ctrlAs + ".model" + "." + $dcname_attr); | |
| 1471 | - }, | |
| 1472 | - function(newValue, oldValue) { | |
| 1473 | - if (newValue === undefined && oldValue === undefined) { | |
| 1474 | - // 两侧都是undefined,不处理 | |
| 1475 | - | |
| 1476 | - } else { | |
| 1477 | - console.log("saSelect5 监控到外部模型" + $dcname_attr + "属性值变化,old=" + oldValue + ",new=" + newValue); | |
| 1478 | - scope[ctrlAs].$$internal_select_value = newValue; | |
| 1479 | - scope[ctrlAs].$$internal_validate_model(); | |
| 1480 | - } | |
| 1481 | - }, | |
| 1482 | - true | |
| 1483 | - ); | |
| 1484 | - } | |
| 1485 | - }; | |
| 1486 | - } | |
| 1487 | - }; | |
| 1488 | - } | |
| 1489 | -]); | |
| 1490 | - | |
| 1491 | -/** | |
| 1492 | - * saRadiogroup指令 | |
| 1493 | - * 属性如下: | |
| 1494 | - * model(必须):独立作用域,外部绑定的一个值,如:ctrl.timeTableManageForForm.isEnableDisTemplate | |
| 1495 | - * dicgroup(必须):关联的字典数据type(TODO:以后增加其他数据源) | |
| 1496 | - * name(必须):控件的名字 | |
| 1497 | - * required(可选):是否要用required验证 | |
| 1498 | - * disabled(可选):标示单选框是否可选 | |
| 1499 | - * | |
| 1500 | - */ | |
| 1501 | -angular.module('ScheduleApp').directive("saRadiogroup", [function() { | |
| 1502 | - /** | |
| 1503 | - * 使用字典数据的单选按钮组的指令。 | |
| 1504 | - * 指令名称:truefalse-Dic | |
| 1505 | - */ | |
| 1506 | - return { | |
| 1507 | - restrict: 'E', | |
| 1508 | - templateUrl: '/pages/scheduleApp/module/common/dts1/radioButton/saRadiogroupTemplate.html', | |
| 1509 | - scope: { | |
| 1510 | - model: "=" | |
| 1511 | - }, | |
| 1512 | - controllerAs: "$saRadiogroupCtrl", | |
| 1513 | - bindToController: true, | |
| 1514 | - controller: function($scope) { | |
| 1515 | - //$scope["model"] = {selectedOption: null}; | |
| 1516 | - //console.log("controller"); | |
| 1517 | - //console.log("controller:" + $scope["model"]); | |
| 1518 | - | |
| 1519 | - var self = this; | |
| 1520 | - self.$$data = null; // 内部数据 | |
| 1521 | - }, | |
| 1522 | - | |
| 1523 | - /** | |
| 1524 | - * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 1525 | - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 1526 | - * @param tElem | |
| 1527 | - * @param tAttrs | |
| 1528 | - * @returns {{pre: Function, post: Function}} | |
| 1529 | - */ | |
| 1530 | - compile: function(tElem, tAttrs) { | |
| 1531 | - // 获取属性 | |
| 1532 | - var $dicgroup_attr = tAttrs["dicgroup"]; // 关联的字典数据type | |
| 1533 | - var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 1534 | - var $required_attr = tAttrs["required"]; // 是否要用required验证 | |
| 1535 | - var $disabled_attr = tAttrs["disabled"]; // 标示单选框是否可选 | |
| 1536 | - | |
| 1537 | - // controlAs名字 | |
| 1538 | - var ctrlAs = "$saRadiogroupCtrl"; | |
| 1539 | - | |
| 1540 | - // 如果有required属性,添加angularjs required验证 | |
| 1541 | - if ($required_attr != undefined) { | |
| 1542 | - tElem.find("input").attr("required", ""); | |
| 1543 | - } | |
| 1544 | - | |
| 1545 | - return { | |
| 1546 | - pre: function(scope, element, attr) { | |
| 1547 | - | |
| 1548 | - }, | |
| 1549 | - | |
| 1550 | - /** | |
| 1551 | - * 相当于link函数。 | |
| 1552 | - * @param scope | |
| 1553 | - * @param element | |
| 1554 | - * @param attr | |
| 1555 | - */ | |
| 1556 | - post: function(scope, element, attr) { | |
| 1557 | - //console.log("link"); | |
| 1558 | - //console.log("link:" + scope.model); | |
| 1559 | - //scope["model"] = {selectedOption: null}; | |
| 1560 | - | |
| 1561 | - if ($name_attr) { | |
| 1562 | - scope[ctrlAs].nv = $name_attr; | |
| 1563 | - } | |
| 1564 | - | |
| 1565 | - if ($disabled_attr) { | |
| 1566 | - scope[ctrlAs].disabled = true; | |
| 1567 | - } | |
| 1568 | - if ($dicgroup_attr) { | |
| 1569 | - var obj = dictionaryUtils.getByGroup($dicgroup_attr); | |
| 1570 | - scope[ctrlAs].$$data = obj; | |
| 1571 | - // 处理 scope["dic"] key值 | |
| 1572 | - scope[ctrlAs].dicvalueCalcu = function(value) { | |
| 1573 | - if (value == "true") { | |
| 1574 | - //console.log(value); | |
| 1575 | - return true; | |
| 1576 | - } else if (value == "false") { | |
| 1577 | - //console.log(value); | |
| 1578 | - return false; | |
| 1579 | - } else { | |
| 1580 | - return value; | |
| 1581 | - } | |
| 1582 | - }; | |
| 1583 | - } | |
| 1584 | - } | |
| 1585 | - }; | |
| 1586 | - } | |
| 1587 | - }; | |
| 1588 | -}]); | |
| 1589 | - | |
| 1590 | - | |
| 1591 | - | |
| 1592 | -/** | |
| 1593 | - * saCheckboxgroup指令 | |
| 1594 | - * 属性如下: | |
| 1595 | - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 1596 | - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 1597 | - * dcname(必须):绑定的model字段名,如:dcname=xl.id | |
| 1598 | - * name(必须):控件的名字 | |
| 1599 | - * required(可选):是否要用required验证 | |
| 1600 | - * disabled(可选):标示框是否可选 | |
| 1601 | - * | |
| 1602 | - */ | |
| 1603 | -angular.module('ScheduleApp').directive('saCheckboxgroup', [ | |
| 1604 | - function() { | |
| 1605 | - return { | |
| 1606 | - restrict: 'E', | |
| 1607 | - templateUrl: '/pages/scheduleApp/module/common/dts1/checkbox/saCheckboxgroupTemplate.html', | |
| 1608 | - scope: { | |
| 1609 | - model: "=" // 独立作用域,关联外部的模型object | |
| 1610 | - }, | |
| 1611 | - controllerAs: "$saCheckboxgroupCtrl", | |
| 1612 | - bindToController: true, | |
| 1613 | - controller: function($scope) { | |
| 1614 | - var self = this; | |
| 1615 | - self.$$data = []; // 内部的数据 | |
| 1616 | - | |
| 1617 | - // TODO:数据写死,周一至周日选择数据,以后有别的数据再议 | |
| 1618 | - self.$$data = [ | |
| 1619 | - {name: "星期一", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1620 | - {name: "星期二", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1621 | - {name: "星期三", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1622 | - {name: "星期四", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1623 | - {name: "星期五", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1624 | - {name: "星期六", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1625 | - {name: "星期日", checkedvalue: "1", uncheckedvalue: "0", ischecked: false} | |
| 1626 | - ]; | |
| 1627 | - }, | |
| 1628 | - | |
| 1629 | - /** | |
| 1630 | - * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 1631 | - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 1632 | - * @param tElem | |
| 1633 | - * @param tAttrs | |
| 1634 | - * @returns {{pre: Function, post: Function}} | |
| 1635 | - */ | |
| 1636 | - compile: function(tElem, tAttrs) { | |
| 1637 | - // 获取所有的属性 | |
| 1638 | - var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 1639 | - var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 1640 | - var $disabled_attr = tAttrs["disabled"]; // 是否禁用 | |
| 1641 | - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名 | |
| 1642 | - | |
| 1643 | - // controlAs名字 | |
| 1644 | - var ctrlAs = '$saCheckboxgroupCtrl'; | |
| 1645 | - | |
| 1646 | - // 如果有required属性,添加angularjs required验证 | |
| 1647 | - if ($required_attr != undefined) { | |
| 1648 | - //console.log(tElem.html()); | |
| 1649 | - tElem.find("div").attr("required", ""); | |
| 1650 | - } | |
| 1651 | - // 如果有disabled属性,添加禁用标志 | |
| 1652 | - if ($disabled_attr != undefined) { | |
| 1653 | - tElem.find("input").attr("ng-disabled", "true"); | |
| 1654 | - } | |
| 1655 | - | |
| 1656 | - return { | |
| 1657 | - pre: function(scope, element, attr) { | |
| 1658 | - // TODO: | |
| 1659 | - }, | |
| 1660 | - /** | |
| 1661 | - * 相当于link函数。 | |
| 1662 | - * @param scope | |
| 1663 | - * @param element | |
| 1664 | - * @param attr | |
| 1665 | - */ | |
| 1666 | - post: function(scope, element, attr) { | |
| 1667 | - // name属性 | |
| 1668 | - if ($name_attr) { | |
| 1669 | - scope[ctrlAs]["$name_attr"] = $name_attr; | |
| 1670 | - } | |
| 1671 | - | |
| 1672 | - /** | |
| 1673 | - * checkbox选择事件处理函数。 | |
| 1674 | - * @param $d 数据对象,$$data中的元素对象 | |
| 1675 | - */ | |
| 1676 | - scope[ctrlAs].$$internal_updateCheck_fn = function($d) { | |
| 1677 | - $d.ischecked = !$d.ischecked; | |
| 1678 | - console.log($d); | |
| 1679 | - }; | |
| 1680 | - | |
| 1681 | - // 测试使用watch监控$$data的变化 | |
| 1682 | - scope.$watch( | |
| 1683 | - function() { | |
| 1684 | - return scope[ctrlAs]["$$data"]; | |
| 1685 | - }, | |
| 1686 | - function(newValue, oldValue) { | |
| 1687 | - // 根据$$data生成对应的数据 | |
| 1688 | - var rule_days_arr = []; | |
| 1689 | - var i; | |
| 1690 | - for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) { | |
| 1691 | - if (scope[ctrlAs]["$$data"][i].ischecked) | |
| 1692 | - rule_days_arr.push(scope[ctrlAs]["$$data"][i].checkedvalue); | |
| 1693 | - else | |
| 1694 | - rule_days_arr.push(scope[ctrlAs]["$$data"][i].uncheckedvalue); | |
| 1695 | - } | |
| 1696 | - scope[ctrlAs].$$internalmodel = rule_days_arr.join(","); | |
| 1697 | - //scope[ctrlAs].$$internalmodel = undefined; | |
| 1698 | - console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel); | |
| 1699 | - | |
| 1700 | - // 更新model | |
| 1701 | - if ($dcname_attr) { | |
| 1702 | - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = rule_days_arr.join(',');"); | |
| 1703 | - } | |
| 1704 | - | |
| 1705 | - | |
| 1706 | - }, | |
| 1707 | - true | |
| 1708 | - ); | |
| 1709 | - | |
| 1710 | - // TODO: | |
| 1711 | - | |
| 1712 | - // 监控dcvalue model值变换 | |
| 1713 | - attr.$observe("dcvalue", function(value) { | |
| 1714 | - console.log("saCheckboxgroup 监控dc1 model值变换:" + value); | |
| 1715 | - if (value) { | |
| 1716 | - // 根据value值,修改$$data里的值 | |
| 1717 | - var data_array = value.split(","); | |
| 1718 | - var i; | |
| 1719 | - if (data_array.length > scope[ctrlAs]["$$data"].length) { | |
| 1720 | - for (i = 0; i < scope[ctrlAs]["$$data"].length; i ++) { | |
| 1721 | - if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) { | |
| 1722 | - scope[ctrlAs]["$$data"][i].ischecked = true; | |
| 1723 | - } else { | |
| 1724 | - scope[ctrlAs]["$$data"][i].ischecked = false; | |
| 1725 | - } | |
| 1726 | - } | |
| 1727 | - } else { | |
| 1728 | - for (i = 0; i < data_array.length; i ++) { | |
| 1729 | - if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) { | |
| 1730 | - scope[ctrlAs]["$$data"][i].ischecked = true; | |
| 1731 | - } else { | |
| 1732 | - scope[ctrlAs]["$$data"][i].ischecked = false; | |
| 1733 | - } | |
| 1734 | - } | |
| 1735 | - } | |
| 1736 | - | |
| 1737 | - } | |
| 1738 | - }); | |
| 1739 | - } | |
| 1740 | - | |
| 1741 | - }; | |
| 1742 | - | |
| 1743 | - | |
| 1744 | - } | |
| 1745 | - | |
| 1746 | - }; | |
| 1747 | - } | |
| 1748 | -]); | |
| 1749 | - | |
| 1750 | - | |
| 1751 | - | |
| 1752 | - | |
| 1753 | -/** | |
| 1754 | - * saDategroup指令 | |
| 1755 | - * 属性如下: | |
| 1756 | - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 1757 | - * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 1758 | - * dcname(必须):绑定的model字段名,如:dcname=xl.id | |
| 1759 | - * name(必须):控件的名字 | |
| 1760 | - * required(可选):是否要用required验证 | |
| 1761 | - * disabled(可选):标示框是否可选 | |
| 1762 | - * | |
| 1763 | - */ | |
| 1764 | -angular.module('ScheduleApp').directive('saDategroup', [ | |
| 1765 | - '$filter', | |
| 1766 | - function($filter) { | |
| 1767 | - return { | |
| 1768 | - restrict: 'E', | |
| 1769 | - templateUrl: '/pages/scheduleApp/module/common/dts2/dateGroup/saDategroupTemplate.html', | |
| 1770 | - scope: { | |
| 1771 | - model: "=" // 独立作用域,关联外部的模型object | |
| 1772 | - }, | |
| 1773 | - controllerAs: "$saDategroupCtrl", | |
| 1774 | - bindToController: true, | |
| 1775 | - controller: function($scope) { | |
| 1776 | - var self = this; | |
| 1777 | - self.$$data = []; // 内部的数据 | |
| 1778 | - self.$$date_select; // 内部选中的日期 | |
| 1779 | - | |
| 1780 | - //// 测试数据 | |
| 1781 | - //self.$$data = [ | |
| 1782 | - // {datestr: '2011-01-01', ischecked: true}, | |
| 1783 | - // {datestr: '2011-01-01', ischecked: true}, | |
| 1784 | - // {datestr: '2011-01-01', ischecked: true} | |
| 1785 | - //]; | |
| 1786 | - }, | |
| 1787 | - | |
| 1788 | - /** | |
| 1789 | - * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 1790 | - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 1791 | - * @param tElem | |
| 1792 | - * @param tAttrs | |
| 1793 | - * @returns {{pre: Function, post: Function}} | |
| 1794 | - */ | |
| 1795 | - compile: function(tElem, tAttrs) { | |
| 1796 | - // 获取所有的属性 | |
| 1797 | - var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 1798 | - var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 1799 | - var $disabled_attr = tAttrs["disabled"]; // 是否禁用 | |
| 1800 | - var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名 | |
| 1801 | - | |
| 1802 | - // controlAs名字 | |
| 1803 | - var ctrlAs = '$saDategroupCtrl'; | |
| 1804 | - | |
| 1805 | - // 如果有required属性,添加angularjs required验证 | |
| 1806 | - if ($required_attr != undefined) { | |
| 1807 | - //console.log(tElem.html()); | |
| 1808 | - tElem.find("div").attr("required", ""); | |
| 1809 | - } | |
| 1810 | - // 如果有disabled属性,添加禁用标志 | |
| 1811 | - if ($disabled_attr != undefined) { | |
| 1812 | - tElem.find("input").attr("ng-disabled", "true"); | |
| 1813 | - tElem.find("div").attr("ng-disabled", "true"); | |
| 1814 | - } | |
| 1815 | - | |
| 1816 | - return { | |
| 1817 | - pre: function (scope, element, attr) { | |
| 1818 | - // TODO: | |
| 1819 | - }, | |
| 1820 | - /** | |
| 1821 | - * 相当于link函数。 | |
| 1822 | - * @param scope | |
| 1823 | - * @param element | |
| 1824 | - * @param attr | |
| 1825 | - */ | |
| 1826 | - post: function (scope, element, attr) { | |
| 1827 | - // name属性 | |
| 1828 | - if ($name_attr) { | |
| 1829 | - scope[ctrlAs]["$name_attr"] = $name_attr; | |
| 1830 | - } | |
| 1831 | - | |
| 1832 | - | |
| 1833 | - // 日期open属性,及方法 | |
| 1834 | - scope[ctrlAs].$$specialDateOpen = false; | |
| 1835 | - scope[ctrlAs].$$specialDate_open = function() { | |
| 1836 | - scope[ctrlAs].$$specialDateOpen = true; | |
| 1837 | - }; | |
| 1838 | - | |
| 1839 | - // 监控选择的日期 | |
| 1840 | - scope.$watch( | |
| 1841 | - function() { | |
| 1842 | - return scope[ctrlAs]['$$date_select']; | |
| 1843 | - }, | |
| 1844 | - function(newValue, oldValue) { | |
| 1845 | - if (newValue) { | |
| 1846 | - //console.log("saDategroup--->selectdate:" + newValue); | |
| 1847 | - // 调用内置filter,转换日期到yyyy-MM-dd格式 | |
| 1848 | - var text = $filter('date')(newValue, 'yyyy-MM-dd'); | |
| 1849 | - var i; | |
| 1850 | - var isexist = false; // 日期是否已经选择标识 | |
| 1851 | - for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) { | |
| 1852 | - if (scope[ctrlAs]["$$data"][i].datestr == text) { | |
| 1853 | - isexist = true; | |
| 1854 | - break; | |
| 1855 | - } | |
| 1856 | - } | |
| 1857 | - if (!isexist) { | |
| 1858 | - scope[ctrlAs]["$$data"].push( | |
| 1859 | - { | |
| 1860 | - datestr: text, | |
| 1861 | - ischecked: true | |
| 1862 | - } | |
| 1863 | - ); | |
| 1864 | - } | |
| 1865 | - | |
| 1866 | - } | |
| 1867 | - | |
| 1868 | - } | |
| 1869 | - ); | |
| 1870 | - | |
| 1871 | - /** | |
| 1872 | - * 日期点击事件处理函数。 | |
| 1873 | - * @param $index 索引 | |
| 1874 | - */ | |
| 1875 | - scope[ctrlAs].$$internal_datestr_click = function($index) { | |
| 1876 | - scope[ctrlAs].$$data.splice($index, 1); | |
| 1877 | - }; | |
| 1878 | - | |
| 1879 | - // 测试使用watch监控$$data的变化 | |
| 1880 | - scope.$watch( | |
| 1881 | - function() { | |
| 1882 | - return scope[ctrlAs]['$$data']; | |
| 1883 | - }, | |
| 1884 | - function(newValue, oldValue) { | |
| 1885 | - // 根据$$data生成对应的数据 | |
| 1886 | - var special_days_arr = []; | |
| 1887 | - var i; | |
| 1888 | - for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) { | |
| 1889 | - special_days_arr.push(scope[ctrlAs]["$$data"][i].datestr); | |
| 1890 | - } | |
| 1891 | - | |
| 1892 | - scope[ctrlAs].$$internalmodel = special_days_arr.join(","); | |
| 1893 | - console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel); | |
| 1894 | - | |
| 1895 | - // 更新model | |
| 1896 | - if ($dcname_attr) { | |
| 1897 | - eval("scope[ctrlAs].model" + "." + $dcname_attr + " = special_days_arr.join(',');"); | |
| 1898 | - } | |
| 1899 | - }, | |
| 1900 | - true | |
| 1901 | - ); | |
| 1902 | - | |
| 1903 | - // 监控dcvalue model值变换 | |
| 1904 | - attr.$observe("dcvalue", function(value) { | |
| 1905 | - console.log("saDategroup 监控dc1 model值变换:" + value); | |
| 1906 | - if (value) { | |
| 1907 | - // 根据value值,修改$$data里的值 | |
| 1908 | - var date_array = value.split(","); | |
| 1909 | - var i; | |
| 1910 | - scope[ctrlAs]["$$data"] = []; | |
| 1911 | - for (i = 0; i < date_array.length; i++) { | |
| 1912 | - scope[ctrlAs]["$$data"].push( | |
| 1913 | - { | |
| 1914 | - datestr: date_array[i], | |
| 1915 | - ischecked: true | |
| 1916 | - } | |
| 1917 | - ); | |
| 1918 | - } | |
| 1919 | - | |
| 1920 | - | |
| 1921 | - | |
| 1922 | - | |
| 1923 | - | |
| 1924 | - | |
| 1925 | - | |
| 1926 | - | |
| 1927 | - | |
| 1928 | - } | |
| 1929 | - }); | |
| 1930 | - | |
| 1931 | - } | |
| 1932 | - | |
| 1933 | - }; | |
| 1934 | - } | |
| 1935 | - } | |
| 1936 | - } | |
| 1937 | -]); | |
| 1938 | - | |
| 1939 | - | |
| 1940 | - | |
| 1941 | - | |
| 1942 | -/** | |
| 1943 | - * saGuideboardgroup指令 | |
| 1944 | - * 属性如下: | |
| 1945 | - * name(必须):控件的名字 | |
| 1946 | - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 1947 | - * xlidvalue(必须):绑定的model线路id值,如:xlidvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 1948 | - * lprangevalue(必须):绑定的model路牌名字范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}} | |
| 1949 | - * lprangename(必须):绑定的model路牌名字范围字段名,如:lprangename=lprange | |
| 1950 | - * lpidrangevalue(必须):绑定的model路牌id范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}} | |
| 1951 | - * lpidrangename(必须):绑定的model路牌id范围字段名,如:lprangename=lprange | |
| 1952 | - * lpstartvalue(必须):绑定的model起始路牌值,如:lpstartvalue={{ctrl.employeeInfoForSave.lpstart}} | |
| 1953 | - * lpstartname(必须):绑定的model起始路牌字段名,如:lpstartname=lpstart | |
| 1954 | - * | |
| 1955 | - * required(可选):是否要用required验证 | |
| 1956 | - * | |
| 1957 | - */ | |
| 1958 | -angular.module('ScheduleApp').directive('saGuideboardgroup', [ | |
| 1959 | - 'GuideboardManageService_g', | |
| 1960 | - function(guideboardManageService_g) { | |
| 1961 | - return { | |
| 1962 | - restrict: 'E', | |
| 1963 | - templateUrl: '/pages/scheduleApp/module/common/dts2/guideboardGroup/saGuideboardgroupTemplate.html', | |
| 1964 | - scope: { | |
| 1965 | - model: "=" // 独立作用域,关联外部的模型object | |
| 1966 | - }, | |
| 1967 | - controllerAs: '$saGuideboardgroupCtrl', | |
| 1968 | - bindToController: true, | |
| 1969 | - controller: function($scope) { | |
| 1970 | - var self = this; | |
| 1971 | - self.$$data = []; // 选择线路后,该线路的路牌数据 | |
| 1972 | - | |
| 1973 | - // 测试数据 | |
| 1974 | - //self.$$data = [ | |
| 1975 | - // {lpid: 1, lpname: '路1', isstart: false}, | |
| 1976 | - // {lpid: 2, lpname: '路2', isstart: true}, | |
| 1977 | - // {lpid: 3, lpname: '路3', isstart: false} | |
| 1978 | - //]; | |
| 1979 | - | |
| 1980 | - | |
| 1981 | - self.$$dataSelected = []; // 选中的路牌列表 | |
| 1982 | - self.$$dataSelectedStart = undefined; // 起始路牌 | |
| 1983 | - | |
| 1984 | - //self.$$dataSelected = [ | |
| 1985 | - // {lpid: 11, lpname: '路11', isstart: false}, | |
| 1986 | - // {lpid: 12, lpname: '路12', isstart: true}, | |
| 1987 | - // {lpid: 13, lpname: '路13', isstart: false} | |
| 1988 | - //]; | |
| 1989 | - | |
| 1990 | - // saGuideboardgroup组件的ng-model,用于外部绑定等操作 | |
| 1991 | - self.$$internalmodel = undefined; | |
| 1992 | - | |
| 1993 | - self.$$data_init = false; // *数据源初始化标志 | |
| 1994 | - self.$$data_xl_first_init = false; // 线路是否初始化 | |
| 1995 | - self.$$data_lp_first_init = false; // 路牌名字是否初始化 | |
| 1996 | - self.$$data_lpid_first_init = false; // 路牌id是否初始化 | |
| 1997 | - self.$$data_lpstart_first_init = false; // 起始路牌是否初始化 | |
| 1998 | - | |
| 1999 | - }, | |
| 2000 | - | |
| 2001 | - /** | |
| 2002 | - * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 2003 | - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 2004 | - * @param tElem | |
| 2005 | - * @param tAttrs | |
| 2006 | - * @returns {{pre: Function, post: Function}} | |
| 2007 | - */ | |
| 2008 | - compile: function(tElem, tAttrs) { | |
| 2009 | - // TODO:获取所有的属性 | |
| 2010 | - var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 2011 | - var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 2012 | - var $lprangename_attr = tAttrs["lprangename"]; // 绑定的model路牌名字范围字段名 | |
| 2013 | - var $lpidrangename_attr = tAttrs["lpidrangename"]; // 绑定的model路牌id范围字段名 | |
| 2014 | - var $lpstartname_attr = tAttrs["lpstartname"]; // 绑定的model起始路牌字段名 | |
| 2015 | - | |
| 2016 | - // controlAs名字 | |
| 2017 | - var ctrlAs = '$saGuideboardgroupCtrl'; | |
| 2018 | - | |
| 2019 | - // 如果有required属性,添加angularjs required验证 | |
| 2020 | - if ($required_attr != undefined) { | |
| 2021 | - //console.log(tElem.html()); | |
| 2022 | - tElem.find("div").attr("required", ""); | |
| 2023 | - } | |
| 2024 | - | |
| 2025 | - return { | |
| 2026 | - pre: function(scope, element, attr) { | |
| 2027 | - // TODO: | |
| 2028 | - }, | |
| 2029 | - | |
| 2030 | - /** | |
| 2031 | - * 相当于link函数。 | |
| 2032 | - * @param scope | |
| 2033 | - * @param element | |
| 2034 | - * @param attr | |
| 2035 | - */ | |
| 2036 | - post: function(scope, element, attr) { | |
| 2037 | - // name属性 | |
| 2038 | - if ($name_attr) { | |
| 2039 | - scope[ctrlAs]["$name_attr"] = $name_attr; | |
| 2040 | - } | |
| 2041 | - | |
| 2042 | - // TODO: | |
| 2043 | - | |
| 2044 | - | |
| 2045 | - /** | |
| 2046 | - * 路牌列表点击(路牌列表中选中路牌) | |
| 2047 | - * @param $index | |
| 2048 | - */ | |
| 2049 | - scope[ctrlAs].$$internal_lplist_click = function($index) { | |
| 2050 | - var data_temp = scope[ctrlAs].$$data; | |
| 2051 | - if (data_temp && data_temp.length > $index) { | |
| 2052 | - scope[ctrlAs].$$dataSelected.push({ | |
| 2053 | - lpid: data_temp[$index].lpid, | |
| 2054 | - lpname: data_temp[$index].lpname, | |
| 2055 | - isstart: data_temp[$index].isstart | |
| 2056 | - }); | |
| 2057 | - | |
| 2058 | - // 如果没有指定过初始路牌,默认选择此路牌作为起始路牌 | |
| 2059 | - if (scope[ctrlAs].$$dataSelectedStart == undefined) { | |
| 2060 | - scope[ctrlAs].$$internal_sellplist_click( | |
| 2061 | - scope[ctrlAs].$$dataSelected.length - 1); | |
| 2062 | - } | |
| 2063 | - } | |
| 2064 | - }; | |
| 2065 | - /** | |
| 2066 | - * 选中的路牌单击(初始路牌选择) | |
| 2067 | - * @param $index | |
| 2068 | - */ | |
| 2069 | - scope[ctrlAs].$$internal_sellplist_click = function($index) { | |
| 2070 | - var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2071 | - if (data_temp && data_temp.length > $index) { | |
| 2072 | - for (var i = 0; i < data_temp.length; i++) { | |
| 2073 | - data_temp[i].isstart = false; | |
| 2074 | - } | |
| 2075 | - data_temp[$index].isstart = true; | |
| 2076 | - scope[ctrlAs].$$dataSelectedStart = $index; | |
| 2077 | - } | |
| 2078 | - }; | |
| 2079 | - /** | |
| 2080 | - * 选中的路牌双击(删除选中的路牌) | |
| 2081 | - * @param $index | |
| 2082 | - */ | |
| 2083 | - scope[ctrlAs].$$internal_sellplist_dbclick = function($index) { | |
| 2084 | - var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2085 | - if (data_temp && data_temp.length > $index) { | |
| 2086 | - if (scope[ctrlAs].$$dataSelectedStart == $index) { | |
| 2087 | - scope[ctrlAs].$$dataSelectedStart = undefined; | |
| 2088 | - } | |
| 2089 | - data_temp.splice($index, 1); | |
| 2090 | - } | |
| 2091 | - }; | |
| 2092 | - | |
| 2093 | - | |
| 2094 | - /** | |
| 2095 | - * 验证内部数据,更新外部model | |
| 2096 | - */ | |
| 2097 | - scope[ctrlAs].$$internal_validate_model = function() { | |
| 2098 | - var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2099 | - var data_temp2 = scope[ctrlAs].$$dataSelectedStart; | |
| 2100 | - var lpNames = []; | |
| 2101 | - var lpIds = []; | |
| 2102 | - var lpStart = 0; | |
| 2103 | - var i = 0; | |
| 2104 | - | |
| 2105 | - if (data_temp && | |
| 2106 | - data_temp.length > 0 && | |
| 2107 | - data_temp2 != undefined) { | |
| 2108 | - | |
| 2109 | - for (i = 0; i < data_temp.length; i++) { | |
| 2110 | - lpNames.push(data_temp[i].lpname); | |
| 2111 | - lpIds.push(data_temp[i].lpid) | |
| 2112 | - } | |
| 2113 | - data_temp[data_temp2].isstart = true; | |
| 2114 | - lpStart = data_temp2 + 1; | |
| 2115 | - | |
| 2116 | - // 更新内部model,用于外部验证 | |
| 2117 | - // 内部model的值暂时随意,以后再改 | |
| 2118 | - scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 2119 | - | |
| 2120 | - // 更新外部model字段 | |
| 2121 | - if ($lprangename_attr) { | |
| 2122 | - console.log("lprangename=" + lpNames.join(',')); | |
| 2123 | - eval("scope[ctrlAs].model" + "." + $lprangename_attr + " = lpNames.join(',');"); | |
| 2124 | - } | |
| 2125 | - if ($lpidrangename_attr) { | |
| 2126 | - console.log("lpidrangename=" + lpIds.join(',')); | |
| 2127 | - eval("scope[ctrlAs].model" + "." + $lpidrangename_attr + " = lpIds.join(',');"); | |
| 2128 | - } | |
| 2129 | - if ($lpstartname_attr) { | |
| 2130 | - console.log("lpstartname=" + lpStart); | |
| 2131 | - eval("scope[ctrlAs].model" + "." + $lpstartname_attr + " = lpStart;"); | |
| 2132 | - } | |
| 2133 | - | |
| 2134 | - } else { | |
| 2135 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 2136 | - } | |
| 2137 | - | |
| 2138 | - | |
| 2139 | - }; | |
| 2140 | - | |
| 2141 | - // 监控内部数据,$$data_selected 变化 | |
| 2142 | - scope.$watch( | |
| 2143 | - function() { | |
| 2144 | - return scope[ctrlAs].$$dataSelected; | |
| 2145 | - }, | |
| 2146 | - function(newValue, oldValue) { | |
| 2147 | - scope[ctrlAs].$$internal_validate_model(); | |
| 2148 | - }, | |
| 2149 | - true | |
| 2150 | - ); | |
| 2151 | - | |
| 2152 | - // 监控内部数据,$$data_selected_start 变化 | |
| 2153 | - scope.$watch( | |
| 2154 | - function() { | |
| 2155 | - return scope[ctrlAs].$$dataSelectedStart; | |
| 2156 | - }, | |
| 2157 | - function(newValue, oldValue) { | |
| 2158 | - scope[ctrlAs].$$internal_validate_model(); | |
| 2159 | - }, | |
| 2160 | - true | |
| 2161 | - ); | |
| 2162 | - | |
| 2163 | - /** | |
| 2164 | - * 验证数据是否初始化完成, | |
| 2165 | - * 所谓的初始化就是内部所有的数据被有效设定过一次。 | |
| 2166 | - */ | |
| 2167 | - scope[ctrlAs].$$internal_validate_init = function() { | |
| 2168 | - var self = scope[ctrlAs]; | |
| 2169 | - | |
| 2170 | - if (self.$$data_xl_first_init && | |
| 2171 | - self.$$data_lp_first_init && | |
| 2172 | - self.$$data_lpid_first_init && | |
| 2173 | - self.$$data_lpstart_first_init) { | |
| 2174 | - console.log("数据初始化完毕!"); | |
| 2175 | - self.$$data_init = true; | |
| 2176 | - } | |
| 2177 | - | |
| 2178 | - }; | |
| 2179 | - | |
| 2180 | - // 监控初始化标志,线路,路牌,路牌id,起始路牌 | |
| 2181 | - scope.$watch( | |
| 2182 | - function() { | |
| 2183 | - return scope[ctrlAs].$$data_xl_first_init; | |
| 2184 | - }, | |
| 2185 | - function(newValue, oldValue) { | |
| 2186 | - scope[ctrlAs].$$internal_validate_init(); | |
| 2187 | - } | |
| 2188 | - ); | |
| 2189 | - scope.$watch( | |
| 2190 | - function() { | |
| 2191 | - return scope[ctrlAs].$$data_lp_first_init; | |
| 2192 | - }, | |
| 2193 | - function(newValue, oldValue) { | |
| 2194 | - scope[ctrlAs].$$internal_validate_init(); | |
| 2195 | - } | |
| 2196 | - ); | |
| 2197 | - scope.$watch( | |
| 2198 | - function() { | |
| 2199 | - return scope[ctrlAs].$$data_lpid_first_init; | |
| 2200 | - }, | |
| 2201 | - function(newValue, oldValue) { | |
| 2202 | - scope[ctrlAs].$$internal_validate_init(); | |
| 2203 | - } | |
| 2204 | - ); | |
| 2205 | - scope.$watch( | |
| 2206 | - function() { | |
| 2207 | - return scope[ctrlAs].$$data_lpstart_first_init; | |
| 2208 | - }, | |
| 2209 | - function(newValue, oldValue) { | |
| 2210 | - scope[ctrlAs].$$internal_validate_init(); | |
| 2211 | - } | |
| 2212 | - ); | |
| 2213 | - | |
| 2214 | - | |
| 2215 | - // 监控线路id的变化 | |
| 2216 | - attr.$observe("xlidvalue", function(value) { | |
| 2217 | - if (value && value != "") { | |
| 2218 | - console.log("xlidvalue=" + value); | |
| 2219 | - | |
| 2220 | - guideboardManageService_g.rest.list( | |
| 2221 | - {"xl.id_eq": value, size: 100}, | |
| 2222 | - function(result) { | |
| 2223 | - // 获取值了 | |
| 2224 | - console.log("路牌获取了"); | |
| 2225 | - | |
| 2226 | - scope[ctrlAs].$$data = []; | |
| 2227 | - for (var i = 0; i < result.content.length; i++) { | |
| 2228 | - scope[ctrlAs].$$data.push({ | |
| 2229 | - lpid: result.content[i].id, | |
| 2230 | - lpname: result.content[i].lpName, | |
| 2231 | - isstart: false | |
| 2232 | - }); | |
| 2233 | - } | |
| 2234 | - if (scope[ctrlAs].$$data_init) { | |
| 2235 | - scope[ctrlAs].$$dataSelected = []; | |
| 2236 | - scope[ctrlAs].$$dataSelectedStart = undefined; | |
| 2237 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 2238 | - } | |
| 2239 | - scope[ctrlAs].$$data_xl_first_init = true; | |
| 2240 | - }, | |
| 2241 | - function(result) { | |
| 2242 | - | |
| 2243 | - } | |
| 2244 | - ); | |
| 2245 | - | |
| 2246 | - } | |
| 2247 | - }); | |
| 2248 | - | |
| 2249 | - // 监控路牌名称范围值的变化 | |
| 2250 | - attr.$observe("lprangevalue", function(value) { | |
| 2251 | - if (value && value != "") { | |
| 2252 | - var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2253 | - var lpnames = value.split(","); | |
| 2254 | - var i = 0; | |
| 2255 | - if (data_temp && data_temp.length == 0) { // 初始创建 | |
| 2256 | - console.log("lprangevalue变换了"); | |
| 2257 | - for (i = 0; i < lpnames.length; i++) { | |
| 2258 | - scope[ctrlAs].$$dataSelected.push({ | |
| 2259 | - lpname: lpnames[i], | |
| 2260 | - isstart: false | |
| 2261 | - }); | |
| 2262 | - } | |
| 2263 | - } else { | |
| 2264 | - for (i = 0; i < lpnames.length; i++) { | |
| 2265 | - data_temp[i].lpname = lpnames[i]; | |
| 2266 | - } | |
| 2267 | - } | |
| 2268 | - scope[ctrlAs].$$data_lp_first_init = true; | |
| 2269 | - } | |
| 2270 | - }); | |
| 2271 | - | |
| 2272 | - // 监控路牌id范围值的变化 | |
| 2273 | - attr.$observe("lpidrangevalue", function(value) { | |
| 2274 | - if (value && value != "") { | |
| 2275 | - console.log("lpidrangevalue=" + value); | |
| 2276 | - var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2277 | - var lpids = value.split(","); | |
| 2278 | - var i = 0; | |
| 2279 | - if (data_temp && data_temp.length == 0) { // 初始创建 | |
| 2280 | - console.log("lpidrangevalue"); | |
| 2281 | - for (i = 0; i < lpids.length; i++) { | |
| 2282 | - scope[ctrlAs].$$dataSelected.push({ | |
| 2283 | - lpid: lpids[i], | |
| 2284 | - isstart: false | |
| 2285 | - }); | |
| 2286 | - } | |
| 2287 | - } else { | |
| 2288 | - for (i = 0; i < lpids.length; i++) { | |
| 2289 | - data_temp[i].lpid = lpids[i]; | |
| 2290 | - } | |
| 2291 | - } | |
| 2292 | - scope[ctrlAs].$$data_lpid_first_init = true; | |
| 2293 | - } | |
| 2294 | - }); | |
| 2295 | - | |
| 2296 | - // 监控起始路牌的变化 | |
| 2297 | - attr.$observe("lpstartvalue", function(value) { | |
| 2298 | - if (value && value != "") { | |
| 2299 | - scope[ctrlAs].$$dataSelectedStart = value - 1; | |
| 2300 | - scope[ctrlAs].$$data_lpstart_first_init = true; | |
| 2301 | - } | |
| 2302 | - }); | |
| 2303 | - | |
| 2304 | - | |
| 2305 | - | |
| 2306 | - } | |
| 2307 | - } | |
| 2308 | - | |
| 2309 | - } | |
| 2310 | - } | |
| 2311 | - } | |
| 2312 | -]); | |
| 2313 | - | |
| 2314 | - | |
| 2315 | - | |
| 2316 | - | |
| 2317 | -/** | |
| 2318 | - * saEmployeegroup指令 | |
| 2319 | - * 属性如下: | |
| 2320 | - * name(必须):控件的名字 | |
| 2321 | - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 2322 | - * xlidvalue(必须):绑定的model线路id值,如:xlidvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 2323 | - * dbbmrangevalue(必须):绑定的model搭班编码范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}} | |
| 2324 | - * dbbmrangename(必须):绑定的model搭班编码范围字段名,如:lprangename=lprange | |
| 2325 | - * rycidrangevalue(必须):绑定的model人员配置idid范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}} | |
| 2326 | - * rycidrangename(必须):绑定的model人员配置id范围字段名,如:lprangename=lprange | |
| 2327 | - * rystartvalue(必须):绑定的model起始人员,如:lpstartvalue={{ctrl.employeeInfoForSave.lpstart}} | |
| 2328 | - * rystartname(必须):绑定的model起始人员字段名,如:lpstartname=lpstart | |
| 2329 | - * | |
| 2330 | - * required(可选):是否要用required验证 | |
| 2331 | - * | |
| 2332 | - */ | |
| 2333 | -angular.module('ScheduleApp').directive('saEmployeegroup', [ | |
| 2334 | - 'EmployeeConfigService_g', | |
| 2335 | - function(employeeConfigService_g) { | |
| 2336 | - return { | |
| 2337 | - restrict: 'E', | |
| 2338 | - templateUrl: '/pages/scheduleApp/module/common/dts2/employeeGroup/saEmployeegroupTemplate.html', | |
| 2339 | - scope: { | |
| 2340 | - model: "=" // 独立作用域,关联外部的模型object | |
| 2341 | - }, | |
| 2342 | - controllerAs: '$saEmployeegroupCtrl', | |
| 2343 | - bindToController: true, | |
| 2344 | - controller: function($scope) { | |
| 2345 | - var self = this; | |
| 2346 | - self.$$data = []; // 选择线路后,该线路的人员配置数据 | |
| 2347 | - | |
| 2348 | - // 测试数据 | |
| 2349 | - //self.$$data = [ | |
| 2350 | - // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1'}, | |
| 2351 | - // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2'}, | |
| 2352 | - // {id: 3, dbbm: "3", jsy: '忍3', spy: '守3'} | |
| 2353 | - //]; | |
| 2354 | - | |
| 2355 | - self.$$dataSelected = []; // 选中的人员配置列表 | |
| 2356 | - self.$$dataSelectedStart = undefined; // 起始人员配置 | |
| 2357 | - | |
| 2358 | - //self.$$dataSelected = [ | |
| 2359 | - // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isstart: false}, | |
| 2360 | - // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true}, | |
| 2361 | - // {id: 3, dbbm: "3", jsy: '忍3', spy: '守3', isstart: false} | |
| 2362 | - //]; | |
| 2363 | - | |
| 2364 | - self.$$isFB = false; // 是否分班 | |
| 2365 | - self.$$dataFBSelected = []; // 选中的分班人员组配置列表 | |
| 2366 | - self.$$dataFBInternalSelected = undefined; // 分班组内人员选中标识 | |
| 2367 | - self.$$dataFBSelectedStart = undefined; // 选中的起始分班人员组合 | |
| 2368 | - | |
| 2369 | - //self.$$dataFBSelected = [ | |
| 2370 | - // {isstart: true, group: [ | |
| 2371 | - // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isselected: false}, | |
| 2372 | - // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true} | |
| 2373 | - // ]}, | |
| 2374 | - // {isstart: false, group: [ | |
| 2375 | - // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isselected: false}, | |
| 2376 | - // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true} | |
| 2377 | - // ]} | |
| 2378 | - //]; | |
| 2379 | - | |
| 2380 | - // saGuideboardgroup组件的ng-model,用于外部绑定等操作 | |
| 2381 | - self.$$internalmodel = undefined; | |
| 2382 | - | |
| 2383 | - self.$$data_init = false; // *数据源初始化标志 | |
| 2384 | - self.$$data_xl_first_init = false; // 线路是否初始化 | |
| 2385 | - self.$$data_ry_first_init = false; // 人员配置是否初始化 | |
| 2386 | - self.$$data_ry_first_data = undefined; // 人员配置初始化数据 | |
| 2387 | - self.$$data_rycid_first_init = false; // 人员配置id是否初始化 | |
| 2388 | - self.$$data_rycid_first_data = undefined; // 人员配置id初始化数据 | |
| 2389 | - self.$$data_rystart_first_init = false; // 起始人员是否初始化 | |
| 2390 | - self.$$data_rystart_first_data = undefined; // 起始人员初始化数据 | |
| 2391 | - | |
| 2392 | - }, | |
| 2393 | - | |
| 2394 | - /** | |
| 2395 | - * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 2396 | - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 2397 | - * @param tElem | |
| 2398 | - * @param tAttrs | |
| 2399 | - * @returns {{pre: Function, post: Function}} | |
| 2400 | - */ | |
| 2401 | - compile: function(tElem, tAttrs) { | |
| 2402 | - // TODO:获取所有的属性 | |
| 2403 | - var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 2404 | - var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 2405 | - var $dbbmrangename_attr = tAttrs["dbbmrangename"]; // 绑定的model搭班编码范围字段名 | |
| 2406 | - var rycidrangename_attr = tAttrs["rycidrangename"]; // 绑定的model人员配置id范围字段名 | |
| 2407 | - var $rystartname_attr = tAttrs["rystartname"]; // 绑定的model起始人员字段名 | |
| 2408 | - | |
| 2409 | - // controlAs名字 | |
| 2410 | - var ctrlAs = '$saEmployeegroupCtrl'; | |
| 2411 | - | |
| 2412 | - // 如果有required属性,添加angularjs required验证 | |
| 2413 | - if ($required_attr != undefined) { | |
| 2414 | - //console.log(tElem.html()); | |
| 2415 | - tElem.find("div").attr("required", ""); | |
| 2416 | - } | |
| 2417 | - | |
| 2418 | - return { | |
| 2419 | - pre: function(scope, element, attr) { | |
| 2420 | - // TODO: | |
| 2421 | - }, | |
| 2422 | - | |
| 2423 | - /** | |
| 2424 | - * 相当于link函数。 | |
| 2425 | - * @param scope | |
| 2426 | - * @param element | |
| 2427 | - * @param attr | |
| 2428 | - */ | |
| 2429 | - post: function(scope, element, attr) { | |
| 2430 | - // name属性 | |
| 2431 | - if ($name_attr) { | |
| 2432 | - scope[ctrlAs]["$name_attr"] = $name_attr; | |
| 2433 | - } | |
| 2434 | - | |
| 2435 | - /** | |
| 2436 | - * 人员配置列表点击(人员配置列表中选中路牌) | |
| 2437 | - * @param $index | |
| 2438 | - */ | |
| 2439 | - scope[ctrlAs].$$internal_rylist_click = function($index) { | |
| 2440 | - var data_temp = scope[ctrlAs].$$data; | |
| 2441 | - if (data_temp && data_temp.length > $index) { | |
| 2442 | - if (!scope[ctrlAs].$$isFB) { // 不分班 | |
| 2443 | - scope[ctrlAs].$$dataSelected.push({ | |
| 2444 | - id : data_temp[$index].id, | |
| 2445 | - dbbm: data_temp[$index].dbbm, | |
| 2446 | - jsy: data_temp[$index].jsy, | |
| 2447 | - spy: data_temp[$index].spy, | |
| 2448 | - isstart: false | |
| 2449 | - }); | |
| 2450 | - | |
| 2451 | - // 如果没有指定过初始人员,默认选择此人员作为起始人员 | |
| 2452 | - if (scope[ctrlAs].$$dataSelectedStart == undefined) { | |
| 2453 | - scope[ctrlAs].$$internal_selrylist_click( | |
| 2454 | - scope[ctrlAs].$$dataSelected.length - 1); | |
| 2455 | - } | |
| 2456 | - } else { // 分班 | |
| 2457 | - if (scope[ctrlAs].$$dataFBInternalSelected) { // 替换组内人员 | |
| 2458 | - scope[ctrlAs].$$dataFBSelected | |
| 2459 | - [scope[ctrlAs].$$dataFBInternalSelected.gindex].group | |
| 2460 | - [scope[ctrlAs].$$dataFBInternalSelected.index] = { | |
| 2461 | - id : data_temp[$index].id, | |
| 2462 | - dbbm: data_temp[$index].dbbm, | |
| 2463 | - jsy: data_temp[$index].jsy, | |
| 2464 | - spy: data_temp[$index].spy, | |
| 2465 | - isselected: true | |
| 2466 | - }; | |
| 2467 | - | |
| 2468 | - } else { | |
| 2469 | - scope[ctrlAs].$$dataFBSelected.push({ | |
| 2470 | - isstart: false, | |
| 2471 | - group: [].concat( | |
| 2472 | - { | |
| 2473 | - id : data_temp[$index].id, | |
| 2474 | - dbbm: data_temp[$index].dbbm, | |
| 2475 | - jsy: data_temp[$index].jsy, | |
| 2476 | - spy: data_temp[$index].spy, | |
| 2477 | - isselected: false | |
| 2478 | - }, { | |
| 2479 | - id : data_temp[$index].id, | |
| 2480 | - dbbm: data_temp[$index].dbbm, | |
| 2481 | - jsy: data_temp[$index].jsy, | |
| 2482 | - spy: data_temp[$index].spy, | |
| 2483 | - isselected: false | |
| 2484 | - } | |
| 2485 | - ) | |
| 2486 | - }); | |
| 2487 | - if (scope[ctrlAs].$$dataFBSelectedStart == undefined) { | |
| 2488 | - scope[ctrlAs].$$internal_selrygrouplist_click( | |
| 2489 | - scope[ctrlAs].$$dataFBSelected.length - 1); | |
| 2490 | - } | |
| 2491 | - } | |
| 2492 | - } | |
| 2493 | - | |
| 2494 | - } | |
| 2495 | - }; | |
| 2496 | - | |
| 2497 | - /** | |
| 2498 | - * 选中的人员单击(初始人员选择) | |
| 2499 | - * @param $index | |
| 2500 | - */ | |
| 2501 | - scope[ctrlAs].$$internal_selrylist_click = function($index) { | |
| 2502 | - var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2503 | - if (data_temp && data_temp.length > $index) { | |
| 2504 | - for (var i = 0; i < data_temp.length; i++) { | |
| 2505 | - data_temp[i].isstart = false; | |
| 2506 | - } | |
| 2507 | - data_temp[$index].isstart = true; | |
| 2508 | - scope[ctrlAs].$$dataSelectedStart = $index; | |
| 2509 | - } | |
| 2510 | - }; | |
| 2511 | - /** | |
| 2512 | - * 选中的人员双击(删除选中的人员) | |
| 2513 | - * @param $index | |
| 2514 | - */ | |
| 2515 | - scope[ctrlAs].$$internal_selrylist_dbclick = function($index) { | |
| 2516 | - var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2517 | - if (data_temp && data_temp.length > $index) { | |
| 2518 | - if (scope[ctrlAs].$$dataSelectedStart == $index) { | |
| 2519 | - scope[ctrlAs].$$dataSelectedStart = undefined; | |
| 2520 | - } | |
| 2521 | - data_temp.splice($index, 1); | |
| 2522 | - } | |
| 2523 | - }; | |
| 2524 | - | |
| 2525 | - /** | |
| 2526 | - * 选中的分班组人员单击(初始人员选择) | |
| 2527 | - * @param $index | |
| 2528 | - */ | |
| 2529 | - scope[ctrlAs].$$internal_selrygrouplist_click = function($index) { | |
| 2530 | - var data_temp = scope[ctrlAs].$$dataFBSelected; | |
| 2531 | - if (data_temp && data_temp.length > $index) { | |
| 2532 | - for (var i = 0; i < data_temp.length; i++) { | |
| 2533 | - data_temp[i].isstart = false; | |
| 2534 | - for (var j = 0; j < data_temp[i].group.length; j++) { | |
| 2535 | - data_temp[i].group[j].isselected = false; | |
| 2536 | - } | |
| 2537 | - } | |
| 2538 | - data_temp[$index].isstart = true; | |
| 2539 | - scope[ctrlAs].$$dataFBSelectedStart = $index; | |
| 2540 | - scope[ctrlAs].$$dataFBInternalSelected = undefined; | |
| 2541 | - } | |
| 2542 | - }; | |
| 2543 | - /** | |
| 2544 | - * 分组内部单击(选中分班中的某组人员) | |
| 2545 | - * @param $groupindex 组index | |
| 2546 | - * @param $index 组内部某个index | |
| 2547 | - * @param $event 事件防止冒泡 | |
| 2548 | - */ | |
| 2549 | - scope[ctrlAs].$$internal_selrygroup_click = function($groupindex, $index, $event) { | |
| 2550 | - var data_temp = scope[ctrlAs].$$dataFBSelected; | |
| 2551 | - if (data_temp && data_temp.length > $groupindex) { | |
| 2552 | - if (data_temp[$groupindex].group && data_temp[$groupindex].group.length > $index) { | |
| 2553 | - // $$dataFBInternalSelected的格式如下: | |
| 2554 | - //{gindex: 1, index: 0} | |
| 2555 | - for (var i = 0; i < data_temp.length; i++) { | |
| 2556 | - data_temp[i].isstart = false; | |
| 2557 | - for (var j = 0; j < data_temp[i].group.length; j++) { | |
| 2558 | - data_temp[i].group[j].isselected = false; | |
| 2559 | - } | |
| 2560 | - } | |
| 2561 | - data_temp[$groupindex].group[$index].isselected = true; | |
| 2562 | - scope[ctrlAs].$$dataFBInternalSelected = { | |
| 2563 | - gindex: $groupindex, index: $index | |
| 2564 | - }; | |
| 2565 | - scope[ctrlAs].$$dataFBSelectedStart = undefined; | |
| 2566 | - $event.stopPropagation(); | |
| 2567 | - } | |
| 2568 | - } | |
| 2569 | - | |
| 2570 | - }; | |
| 2571 | - /** | |
| 2572 | - * 选中的分班人员双击(删除选中的人员) | |
| 2573 | - * @param $index | |
| 2574 | - */ | |
| 2575 | - scope[ctrlAs].$$internal_selrygrouplist_dbclick = function($index) { | |
| 2576 | - var data_temp = scope[ctrlAs].$$dataFBSelected; | |
| 2577 | - if (data_temp && data_temp.length > $index) { | |
| 2578 | - if (scope[ctrlAs].$$dataFBSelectedStart == $index) { | |
| 2579 | - scope[ctrlAs].$$dataFBSelectedStart = undefined; | |
| 2580 | - } | |
| 2581 | - if (scope[ctrlAs].$$dataFBInternalSelected && | |
| 2582 | - scope[ctrlAs].$$dataFBInternalSelected.gindex == $index) { | |
| 2583 | - scope[ctrlAs].$$dataFBInternalSelected = undefined; | |
| 2584 | - } | |
| 2585 | - data_temp.splice($index, 1); | |
| 2586 | - } | |
| 2587 | - }; | |
| 2588 | - | |
| 2589 | - /** | |
| 2590 | - * 验证内部数据,更新外部model | |
| 2591 | - */ | |
| 2592 | - scope[ctrlAs].$$internal_validate_model = function() { | |
| 2593 | - var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2594 | - var data_temp2 = scope[ctrlAs].$$dataSelectedStart; | |
| 2595 | - var data_temp3 = scope[ctrlAs].$$dataFBSelected; | |
| 2596 | - var data_temp4 = scope[ctrlAs].$$dataFBSelectedStart; | |
| 2597 | - var ryDbbms = []; | |
| 2598 | - var ryDbbm_group = []; | |
| 2599 | - var ryCids = []; | |
| 2600 | - var ryCid_group = []; | |
| 2601 | - var ryStart = 0; | |
| 2602 | - var i = 0; | |
| 2603 | - var j = 0; | |
| 2604 | - | |
| 2605 | - var isFB = scope[ctrlAs].$$isFB; | |
| 2606 | - | |
| 2607 | - if (isFB) { | |
| 2608 | - if (data_temp3 && | |
| 2609 | - data_temp3.length > 0 && | |
| 2610 | - data_temp4 != undefined) { | |
| 2611 | - | |
| 2612 | - for (i = 0; i < data_temp3.length; i++) { | |
| 2613 | - for (j = 0; j < data_temp3[i].group.length; j++) { | |
| 2614 | - ryDbbm_group.push(data_temp3[i].group[j].dbbm); | |
| 2615 | - ryCid_group.push(data_temp3[i].group[j].id); | |
| 2616 | - } | |
| 2617 | - ryDbbms.push(ryDbbm_group.join("-")); | |
| 2618 | - ryCids.push(ryCid_group.join("-")); | |
| 2619 | - ryDbbm_group = []; | |
| 2620 | - ryCid_group = []; | |
| 2621 | - } | |
| 2622 | - | |
| 2623 | - data_temp3[data_temp4].isstart = true; | |
| 2624 | - ryStart = data_temp4 + 1; | |
| 2625 | - | |
| 2626 | - // 更新内部model,用于外部验证 | |
| 2627 | - // 内部model的值暂时随意,以后再改 | |
| 2628 | - scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 2629 | - | |
| 2630 | - // 更新外部model字段 | |
| 2631 | - if ($dbbmrangename_attr) { | |
| 2632 | - console.log("dbbmrangename=" + ryDbbms.join(',')); | |
| 2633 | - eval("scope[ctrlAs].model" + "." + $dbbmrangename_attr + " = ryDbbms.join(',');"); | |
| 2634 | - } | |
| 2635 | - if (rycidrangename_attr) { | |
| 2636 | - console.log("rycidrangename=" + ryCids.join(',')); | |
| 2637 | - eval("scope[ctrlAs].model" + "." + rycidrangename_attr + " = ryCids.join(',');"); | |
| 2638 | - } | |
| 2639 | - if ($rystartname_attr) { | |
| 2640 | - console.log("rystartname=" + ryStart); | |
| 2641 | - eval("scope[ctrlAs].model" + "." + $rystartname_attr + " = ryStart;"); | |
| 2642 | - } | |
| 2643 | - | |
| 2644 | - } else { | |
| 2645 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 2646 | - } | |
| 2647 | - | |
| 2648 | - } else { | |
| 2649 | - if (data_temp && | |
| 2650 | - data_temp.length > 0 && | |
| 2651 | - data_temp2 != undefined) { | |
| 2652 | - | |
| 2653 | - for (i = 0; i < data_temp.length; i++) { | |
| 2654 | - ryDbbms.push(data_temp[i].dbbm); | |
| 2655 | - ryCids.push(data_temp[i].id); | |
| 2656 | - } | |
| 2657 | - data_temp[data_temp2].isstart = true; | |
| 2658 | - ryStart = data_temp2 + 1; | |
| 2659 | - | |
| 2660 | - // 更新内部model,用于外部验证 | |
| 2661 | - // 内部model的值暂时随意,以后再改 | |
| 2662 | - scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 2663 | - | |
| 2664 | - // 更新外部model字段 | |
| 2665 | - if ($dbbmrangename_attr) { | |
| 2666 | - console.log("dbbmrangename=" + ryDbbms.join(',')); | |
| 2667 | - eval("scope[ctrlAs].model" + "." + $dbbmrangename_attr + " = ryDbbms.join(',');"); | |
| 2668 | - } | |
| 2669 | - if (rycidrangename_attr) { | |
| 2670 | - console.log("rycidrangename=" + ryCids.join(',')); | |
| 2671 | - eval("scope[ctrlAs].model" + "." + rycidrangename_attr + " = ryCids.join(',');"); | |
| 2672 | - } | |
| 2673 | - if ($rystartname_attr) { | |
| 2674 | - console.log("rystartname=" + ryStart); | |
| 2675 | - eval("scope[ctrlAs].model" + "." + $rystartname_attr + " = ryStart;"); | |
| 2676 | - } | |
| 2677 | - | |
| 2678 | - } else { | |
| 2679 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 2680 | - } | |
| 2681 | - } | |
| 2682 | - | |
| 2683 | - }; | |
| 2684 | - | |
| 2685 | - // 监控内部数据,$$dataSelected 变化 | |
| 2686 | - scope.$watch( | |
| 2687 | - function() { | |
| 2688 | - return scope[ctrlAs].$$dataSelected; | |
| 2689 | - }, | |
| 2690 | - function(newValue, oldValue) { | |
| 2691 | - scope[ctrlAs].$$internal_validate_model(); | |
| 2692 | - }, | |
| 2693 | - true | |
| 2694 | - ); | |
| 2695 | - | |
| 2696 | - // 监控内部数据,$$dataSelectedStart 变化 | |
| 2697 | - scope.$watch( | |
| 2698 | - function() { | |
| 2699 | - return scope[ctrlAs].$$dataSelectedStart; | |
| 2700 | - }, | |
| 2701 | - function(newValue, oldValue) { | |
| 2702 | - scope[ctrlAs].$$internal_validate_model(); | |
| 2703 | - }, | |
| 2704 | - true | |
| 2705 | - ); | |
| 2706 | - | |
| 2707 | - | |
| 2708 | - // 监控内部数据,$$dataFBSelected 变化 | |
| 2709 | - scope.$watch( | |
| 2710 | - function() { | |
| 2711 | - return scope[ctrlAs].$$dataFBSelected; | |
| 2712 | - }, | |
| 2713 | - function(newValue, oldValue) { | |
| 2714 | - scope[ctrlAs].$$internal_validate_model(); | |
| 2715 | - }, | |
| 2716 | - true | |
| 2717 | - ); | |
| 2718 | - | |
| 2719 | - // 监控内部数据,$$dataFBSelectedStart 变化 | |
| 2720 | - scope.$watch( | |
| 2721 | - function() { | |
| 2722 | - return scope[ctrlAs].$$dataFBSelectedStart; | |
| 2723 | - }, | |
| 2724 | - function(newValue, oldValue) { | |
| 2725 | - scope[ctrlAs].$$internal_validate_model(); | |
| 2726 | - }, | |
| 2727 | - true | |
| 2728 | - ); | |
| 2729 | - | |
| 2730 | - // 监控内部数据,$$dataFBInternalSelected 变化 | |
| 2731 | - scope.$watch( | |
| 2732 | - function() { | |
| 2733 | - return scope[ctrlAs].$$dataFBInternalSelected; | |
| 2734 | - }, | |
| 2735 | - function(newValue, oldValue) { | |
| 2736 | - scope[ctrlAs].$$internal_validate_model(); | |
| 2737 | - }, | |
| 2738 | - true | |
| 2739 | - ); | |
| 2740 | - | |
| 2741 | - // 监控内部数据,$$isFB 变化 | |
| 2742 | - scope.$watch( | |
| 2743 | - function() { | |
| 2744 | - return scope[ctrlAs].$$isFB; | |
| 2745 | - }, | |
| 2746 | - function(newValue, oldValue) { | |
| 2747 | - scope[ctrlAs].$$internal_validate_model(); | |
| 2748 | - }, | |
| 2749 | - true | |
| 2750 | - ); | |
| 2751 | - | |
| 2752 | - /** | |
| 2753 | - * 验证数据是否初始化完成, | |
| 2754 | - * 所谓的初始化就是内部所有的数据被有效设定过一次。 | |
| 2755 | - */ | |
| 2756 | - scope[ctrlAs].$$internal_validate_init = function() { | |
| 2757 | - var self = scope[ctrlAs]; | |
| 2758 | - var data_temp = self.$$data; | |
| 2759 | - var dataSelect_temp = self.$$dataSelected; | |
| 2760 | - var dataFBSelect_temp = self.$$dataFBSelected; | |
| 2761 | - var dbbmnames = null; | |
| 2762 | - var dbbmnamegroup = null; | |
| 2763 | - var rycids = null; | |
| 2764 | - var rycidgroup = null; | |
| 2765 | - | |
| 2766 | - var i = 0; | |
| 2767 | - var j = 0; | |
| 2768 | - var k = 0; | |
| 2769 | - | |
| 2770 | - if (self.$$data_xl_first_init && | |
| 2771 | - self.$$data_ry_first_init && | |
| 2772 | - self.$$data_rycid_first_init && | |
| 2773 | - self.$$data_rystart_first_init && !self.$$data_init) { | |
| 2774 | - console.log("开始初始化数据"); | |
| 2775 | - | |
| 2776 | - // 判定是否分班,字符串中包含-就是了 | |
| 2777 | - if (self.$$data_ry_first_data.indexOf("-") != -1 && dataFBSelect_temp.length == 0) { // 分班 | |
| 2778 | - self.$$isFB = true; | |
| 2779 | - | |
| 2780 | - // 搭班编码、人员配置id | |
| 2781 | - dbbmnames = self.$$data_ry_first_data.split(","); | |
| 2782 | - rycids = self.$$data_rycid_first_data.split(","); | |
| 2783 | - for (i = 0; i < dbbmnames.length; i++) { | |
| 2784 | - dataFBSelect_temp.push({ | |
| 2785 | - group: [], | |
| 2786 | - isstart: false | |
| 2787 | - }); | |
| 2788 | - dbbmnamegroup = dbbmnames[i].split("-"); | |
| 2789 | - rycidgroup = rycids[i].split("-"); | |
| 2790 | - | |
| 2791 | - for (k = 0; k < dbbmnamegroup.length; k++) { | |
| 2792 | - dataFBSelect_temp[i].group.push({ | |
| 2793 | - id: rycidgroup[k], | |
| 2794 | - dbbm: dbbmnamegroup[k], | |
| 2795 | - isselected: false | |
| 2796 | - }); | |
| 2797 | - | |
| 2798 | - for (j = 0; j < data_temp.length; j++) { | |
| 2799 | - if (dataFBSelect_temp[i].group[k].dbbm == data_temp[j].dbbm) { | |
| 2800 | - dataFBSelect_temp[i].group[k].jsy = data_temp[j].jsy; | |
| 2801 | - dataFBSelect_temp[i].group[k].spy = data_temp[j].spy; | |
| 2802 | - break; | |
| 2803 | - } | |
| 2804 | - } | |
| 2805 | - } | |
| 2806 | - | |
| 2807 | - } | |
| 2808 | - | |
| 2809 | - // 初始人员 | |
| 2810 | - scope[ctrlAs].$$dataFBSelectedStart = self.$$data_rystart_first_data - 1; | |
| 2811 | - | |
| 2812 | - | |
| 2813 | - } else if (dataSelect_temp.length == 0) { | |
| 2814 | - self.$$isFB = false; | |
| 2815 | - | |
| 2816 | - // 搭班编码、人员配置id | |
| 2817 | - dbbmnames = self.$$data_ry_first_data.split(","); | |
| 2818 | - rycids = self.$$data_rycid_first_data.split(","); | |
| 2819 | - for (i = 0; i < dbbmnames.length; i++) { | |
| 2820 | - dataSelect_temp.push({ | |
| 2821 | - id: rycids[i], | |
| 2822 | - dbbm: dbbmnames[i], | |
| 2823 | - isstart: false | |
| 2824 | - }); | |
| 2825 | - for (j = 0; j < data_temp.length; j++) { | |
| 2826 | - if (dataSelect_temp[i].dbbm == data_temp[j].dbbm) { | |
| 2827 | - dataSelect_temp[i].jsy = data_temp[j].jsy; | |
| 2828 | - dataSelect_temp[i].spy = data_temp[j].spy; | |
| 2829 | - break; | |
| 2830 | - } | |
| 2831 | - } | |
| 2832 | - } | |
| 2833 | - // 初始人员 | |
| 2834 | - scope[ctrlAs].$$dataSelectedStart = self.$$data_rystart_first_data - 1; | |
| 2835 | - | |
| 2836 | - } | |
| 2837 | - | |
| 2838 | - console.log("数据初始化完毕!"); | |
| 2839 | - self.$$data_init = true; | |
| 2840 | - } | |
| 2841 | - | |
| 2842 | - }; | |
| 2843 | - | |
| 2844 | - // 监控初始化标志,线路,人员,起始人员 | |
| 2845 | - scope.$watch( | |
| 2846 | - function() { | |
| 2847 | - return scope[ctrlAs].$$data_xl_first_init; | |
| 2848 | - }, | |
| 2849 | - function(newValue, oldValue) { | |
| 2850 | - scope[ctrlAs].$$internal_validate_init(); | |
| 2851 | - } | |
| 2852 | - ); | |
| 2853 | - scope.$watch( | |
| 2854 | - function() { | |
| 2855 | - return scope[ctrlAs].$$data_ry_first_init; | |
| 2856 | - }, | |
| 2857 | - function(newValue, oldValue) { | |
| 2858 | - scope[ctrlAs].$$internal_validate_init(); | |
| 2859 | - } | |
| 2860 | - ); | |
| 2861 | - scope.$watch( | |
| 2862 | - function() { | |
| 2863 | - return scope[ctrlAs].$$data_rycid_first_init; | |
| 2864 | - }, | |
| 2865 | - function(newValue, oldValue) { | |
| 2866 | - scope[ctrlAs].$$internal_validate_init(); | |
| 2867 | - } | |
| 2868 | - ); | |
| 2869 | - scope.$watch( | |
| 2870 | - function() { | |
| 2871 | - return scope[ctrlAs].$$data_rystart_first_init; | |
| 2872 | - }, | |
| 2873 | - function(newValue, oldValue) { | |
| 2874 | - scope[ctrlAs].$$internal_validate_init(); | |
| 2875 | - } | |
| 2876 | - ); | |
| 2877 | - | |
| 2878 | - | |
| 2879 | - // 监控线路id的变化 | |
| 2880 | - attr.$observe("xlidvalue", function(value) { | |
| 2881 | - if (value && value != "") { | |
| 2882 | - console.log("xlidvalue=" + value); | |
| 2883 | - | |
| 2884 | - employeeConfigService_g.rest.list( | |
| 2885 | - {"xl.id_eq": value, "isCancel_eq" : false, size: 100}, | |
| 2886 | - function(result) { | |
| 2887 | - // 获取值了 | |
| 2888 | - console.log("人员配置获取了"); | |
| 2889 | - | |
| 2890 | - scope[ctrlAs].$$data = []; | |
| 2891 | - for (var i = 0; i < result.content.length; i++) { | |
| 2892 | - scope[ctrlAs].$$data.push({ | |
| 2893 | - id: result.content[i].id, | |
| 2894 | - dbbm: result.content[i].dbbm, | |
| 2895 | - jsy: result.content[i].jsy.personnelName, | |
| 2896 | - spy: result.content[i].spy == null ? "" : result.content[i].spy.personnelName | |
| 2897 | - }); | |
| 2898 | - } | |
| 2899 | - if (scope[ctrlAs].$$data_init) { | |
| 2900 | - scope[ctrlAs].$$dataSelected = []; | |
| 2901 | - scope[ctrlAs].$$dataSelectedStart = undefined; | |
| 2902 | - | |
| 2903 | - scope[ctrlAs].$$dataFBSelected = []; | |
| 2904 | - scope[ctrlAs].$$dataFBInternalSelected = undefined; | |
| 2905 | - scope[ctrlAs].$$dataFBSelectedStart = undefined; | |
| 2906 | - | |
| 2907 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 2908 | - } | |
| 2909 | - scope[ctrlAs].$$data_xl_first_init = true; | |
| 2910 | - }, | |
| 2911 | - function(result) { | |
| 2912 | - | |
| 2913 | - } | |
| 2914 | - ); | |
| 2915 | - | |
| 2916 | - } | |
| 2917 | - }); | |
| 2918 | - | |
| 2919 | - // 监控搭班编码范围值的变化 | |
| 2920 | - attr.$observe("dbbmrangevalue", function(value) { | |
| 2921 | - if (value && value != "") { | |
| 2922 | - console.log("dbbmrangevalue变换了"); | |
| 2923 | - scope[ctrlAs].$$data_ry_first_init = true; | |
| 2924 | - scope[ctrlAs].$$data_ry_first_data = value; | |
| 2925 | - } | |
| 2926 | - }); | |
| 2927 | - | |
| 2928 | - // 监控人员配置id范围值的变化 | |
| 2929 | - attr.$observe("rycidrangevalue", function(value) { | |
| 2930 | - if (value && value != "") { | |
| 2931 | - console.log("rycidrangevalue变换了"); | |
| 2932 | - scope[ctrlAs].$$data_rycid_first_init = true; | |
| 2933 | - scope[ctrlAs].$$data_rycid_first_data = value; | |
| 2934 | - } | |
| 2935 | - }); | |
| 2936 | - | |
| 2937 | - // 监控起始人员的变化 | |
| 2938 | - attr.$observe("rystartvalue", function(value) { | |
| 2939 | - if (value && value != "") { | |
| 2940 | - console.log("rystartvalue变换了"); | |
| 2941 | - scope[ctrlAs].$$data_rystart_first_init = true; | |
| 2942 | - scope[ctrlAs].$$data_rystart_first_data = value; | |
| 2943 | - } | |
| 2944 | - }); | |
| 2945 | - | |
| 2946 | - } | |
| 2947 | - } | |
| 2948 | - | |
| 2949 | - } | |
| 2950 | - } | |
| 2951 | - } | |
| 2952 | -]); | |
| 2953 | - | |
| 2954 | - | |
| 2955 | -/** | |
| 2956 | - * saBcgroup指令,用于套跑界面中,从指定线路,指定时刻表,指定路牌的班次列表中选择套跑班次。 | |
| 2957 | - * 属性如下: | |
| 2958 | - * name(必须):控件的名字 | |
| 2959 | - * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 2960 | - * bcttinfoidsvalue(必须):绑定的model班次ids字段值,如:bcttinfoidsvalue={{ctrl.employeeInfoForSave.lprange}} | |
| 2961 | - * bcttinfoidsname(必须):bind的model班次ids字段名,如:bcttinfoidsname=lprange | |
| 2962 | - * dataparams (必须):内部数据关联的查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }} | |
| 2963 | - * required(可选):是否要用required验证 | |
| 2964 | - * | |
| 2965 | - */ | |
| 2966 | -angular.module('ScheduleApp').directive('saBcgroup', [ | |
| 2967 | - 'TimeTableDetailManageService_g', | |
| 2968 | - function(timeTableDetailManageService_g) { | |
| 2969 | - return { | |
| 2970 | - restrict: 'E', | |
| 2971 | - templateUrl: '/pages/scheduleApp/module/common/dts2/bcGroup/saBcgroupTemplate.html', | |
| 2972 | - scope: { | |
| 2973 | - model: "=" // 独立作用域,关联外部的模型object | |
| 2974 | - }, | |
| 2975 | - controllerAs: '$saBcgroupCtrl', | |
| 2976 | - bindToController: true, | |
| 2977 | - controller: function($scope) { | |
| 2978 | - var self = this; | |
| 2979 | - self.$$data = []; // 选择线路,时刻表,路牌后的班次列表 | |
| 2980 | - | |
| 2981 | - // 测试数据 | |
| 2982 | - //self.$$data = [ | |
| 2983 | - // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'}, | |
| 2984 | - // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'}, | |
| 2985 | - // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'} | |
| 2986 | - //]; | |
| 2987 | - | |
| 2988 | - | |
| 2989 | - self.$$dataSelected = []; // 套跑选中的班次列表 | |
| 2990 | - | |
| 2991 | - //self.$$dataSelected = [ | |
| 2992 | - // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'}, | |
| 2993 | - // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'}, | |
| 2994 | - // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'} | |
| 2995 | - //]; | |
| 2996 | - | |
| 2997 | - // saBcgroup组件的ng-model,用于外部绑定等操作 | |
| 2998 | - self.$$internalmodel = undefined; | |
| 2999 | - | |
| 3000 | - self.$$data_bcdata_first_init = false; // 班次数据首次初始化标志 | |
| 3001 | - self.$$data_bcttinfoids_first_init = false; // 班次ids数据首次初始化标志 | |
| 3002 | - self.$$data_bcttinfoids_first_data = undefined; // 班次ids数据首次初始化数据 | |
| 3003 | - | |
| 3004 | - }, | |
| 3005 | - | |
| 3006 | - /** | |
| 3007 | - * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 3008 | - * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 3009 | - * @param tElem | |
| 3010 | - * @param tAttrs | |
| 3011 | - * @returns {{pre: Function, post: Function}} | |
| 3012 | - */ | |
| 3013 | - compile: function(tElem, tAttrs) { | |
| 3014 | - // TODO:获取所有的属性 | |
| 3015 | - var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 3016 | - var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 3017 | - var $bcttinfoidsname_attr = tAttrs["bcttinfoidsname"]; // bind的model班次ids字段名 | |
| 3018 | - | |
| 3019 | - // controlAs名字 | |
| 3020 | - var ctrlAs = '$saBcgroupCtrl'; | |
| 3021 | - | |
| 3022 | - // 如果有required属性,添加angularjs required验证 | |
| 3023 | - if ($required_attr != undefined) { | |
| 3024 | - //console.log(tElem.html()); | |
| 3025 | - tElem.find("div").attr("required", ""); | |
| 3026 | - } | |
| 3027 | - | |
| 3028 | - return { | |
| 3029 | - pre: function(scope, element, attr) { | |
| 3030 | - // TODO: | |
| 3031 | - }, | |
| 3032 | - | |
| 3033 | - /** | |
| 3034 | - * 相当于link函数。 | |
| 3035 | - * @param scope | |
| 3036 | - * @param element | |
| 3037 | - * @param attr | |
| 3038 | - */ | |
| 3039 | - post: function(scope, element, attr) { | |
| 3040 | - // name属性 | |
| 3041 | - if ($name_attr) { | |
| 3042 | - scope[ctrlAs]["$name_attr"] = $name_attr; | |
| 3043 | - } | |
| 3044 | - | |
| 3045 | - // TODO: | |
| 3046 | - | |
| 3047 | - | |
| 3048 | - /** | |
| 3049 | - * 班次列表点击(班次列表中选中班次) | |
| 3050 | - * @param $index | |
| 3051 | - */ | |
| 3052 | - scope[ctrlAs].$$internal_bclist_click = function($index) { | |
| 3053 | - var data_temp = scope[ctrlAs].$$data; | |
| 3054 | - var data_temp2 = scope[ctrlAs].$$dataSelected; | |
| 3055 | - var i = 0; | |
| 3056 | - var isunique = true; // 是否已经选择过 | |
| 3057 | - if (data_temp && data_temp.length > $index) { | |
| 3058 | - for (i = 0; i < data_temp2.length; i++) { | |
| 3059 | - if (data_temp2[i].bcttinfoid == data_temp[$index].bcttinfoid) { | |
| 3060 | - isunique = false; | |
| 3061 | - break; | |
| 3062 | - } | |
| 3063 | - } | |
| 3064 | - if (isunique) { | |
| 3065 | - data_temp2.push({ | |
| 3066 | - bcttinfoid: data_temp[$index].bcttinfoid, | |
| 3067 | - bcfcsj: data_temp[$index].bcfcsj, | |
| 3068 | - bctype: data_temp[$index].bctype | |
| 3069 | - }); | |
| 3070 | - } | |
| 3071 | - | |
| 3072 | - } | |
| 3073 | - }; | |
| 3074 | - /** | |
| 3075 | - * 选中的班次双击(删除选中的班次) | |
| 3076 | - * @param $index | |
| 3077 | - */ | |
| 3078 | - scope[ctrlAs].$$internal_selbclist_dbclick = function($index) { | |
| 3079 | - var data_temp = scope[ctrlAs].$$dataSelected; | |
| 3080 | - if (data_temp && data_temp.length > $index) { | |
| 3081 | - data_temp.splice($index, 1); | |
| 3082 | - } | |
| 3083 | - }; | |
| 3084 | - | |
| 3085 | - | |
| 3086 | - /** | |
| 3087 | - * 验证内部数据,更新外部model | |
| 3088 | - */ | |
| 3089 | - scope[ctrlAs].$$internal_validate_model = function() { | |
| 3090 | - var data_temp = scope[ctrlAs].$$dataSelected; | |
| 3091 | - var bcttinfoIds = []; | |
| 3092 | - var i = 0; | |
| 3093 | - | |
| 3094 | - if (data_temp && | |
| 3095 | - data_temp.length > 0) { | |
| 3096 | - | |
| 3097 | - for (i = 0; i < data_temp.length; i++) { | |
| 3098 | - bcttinfoIds.push(data_temp[i].bcttinfoid); | |
| 3099 | - } | |
| 3100 | - | |
| 3101 | - // 更新外部model字段 | |
| 3102 | - if ($bcttinfoidsname_attr) { | |
| 3103 | - console.log("bcttinfoidsname=" + bcttinfoIds.join(',')); | |
| 3104 | - eval("scope[ctrlAs].model" + "." + $bcttinfoidsname_attr + " = bcttinfoIds.join(',');"); | |
| 3105 | - } | |
| 3106 | - | |
| 3107 | - // 更新内部model,用于外部验证 | |
| 3108 | - // 内部model的值暂时随意,以后再改 | |
| 3109 | - scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 3110 | - | |
| 3111 | - scope[ctrlAs].$$data_bcdata_first_init = true; | |
| 3112 | - scope[ctrlAs].$$data_bcttinfoids_first_init = true; | |
| 3113 | - | |
| 3114 | - } else { | |
| 3115 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 3116 | - } | |
| 3117 | - | |
| 3118 | - }; | |
| 3119 | - | |
| 3120 | - // 监控内部数据,$$data_selected 变化 | |
| 3121 | - scope.$watch( | |
| 3122 | - function() { | |
| 3123 | - console.log("长度:" + scope[ctrlAs].$$dataSelected.length); | |
| 3124 | - return scope[ctrlAs].$$dataSelected; | |
| 3125 | - }, | |
| 3126 | - function(newValue, oldValue) { | |
| 3127 | - scope[ctrlAs].$$internal_validate_model(); | |
| 3128 | - }, | |
| 3129 | - true | |
| 3130 | - ); | |
| 3131 | - | |
| 3132 | - /** | |
| 3133 | - * 验证数据是否初始化完成, | |
| 3134 | - * 所谓的初始化就是内部所有的数据被有效设定过一次。 | |
| 3135 | - */ | |
| 3136 | - scope[ctrlAs].$$internal_validate_init = function() { | |
| 3137 | - var self = scope[ctrlAs]; | |
| 3138 | - | |
| 3139 | - var data_temp = self.$$data; | |
| 3140 | - var dataSelect_temp = self.$$dataSelected; | |
| 3141 | - var bcttinfoids = null; | |
| 3142 | - | |
| 3143 | - var i = 0; | |
| 3144 | - var j = 0; | |
| 3145 | - | |
| 3146 | - if (self.$$data_bcdata_first_init && | |
| 3147 | - self.$$data_bcttinfoids_first_init) { | |
| 3148 | - console.log("开始初始化数据"); | |
| 3149 | - | |
| 3150 | - bcttinfoids = self.$$data_bcttinfoids_first_data ? self.$$data_bcttinfoids_first_data.split(",") : []; | |
| 3151 | - | |
| 3152 | - for (i = 0; i < bcttinfoids.length; i++) { | |
| 3153 | - dataSelect_temp.push({ | |
| 3154 | - bcttinfoid: bcttinfoids[i] | |
| 3155 | - }); | |
| 3156 | - for (j = 0; j < data_temp.length; j++) { | |
| 3157 | - if (dataSelect_temp[i].bcttinfoid == data_temp[j].bcttinfoid) { | |
| 3158 | - dataSelect_temp[i].bcfcsj = data_temp[j].bcfcsj; | |
| 3159 | - dataSelect_temp[i].bctype = data_temp[j].bctype; | |
| 3160 | - break; | |
| 3161 | - } | |
| 3162 | - } | |
| 3163 | - } | |
| 3164 | - | |
| 3165 | - console.log("数据初始化完毕!"); | |
| 3166 | - } | |
| 3167 | - | |
| 3168 | - }; | |
| 3169 | - | |
| 3170 | - // 监控初始化标志 | |
| 3171 | - scope.$watch( | |
| 3172 | - function() { | |
| 3173 | - return scope[ctrlAs].$$data_bcdata_first_init; | |
| 3174 | - }, | |
| 3175 | - function(newValue, oldValue) { | |
| 3176 | - scope[ctrlAs].$$internal_validate_init(); | |
| 3177 | - } | |
| 3178 | - ); | |
| 3179 | - scope.$watch( | |
| 3180 | - function() { | |
| 3181 | - return scope[ctrlAs].$$data_bcttinfoids_first_init; | |
| 3182 | - }, | |
| 3183 | - function(newValue, oldValue) { | |
| 3184 | - scope[ctrlAs].$$internal_validate_init(); | |
| 3185 | - } | |
| 3186 | - ); | |
| 3187 | - | |
| 3188 | - // 监控内部数据的变化 | |
| 3189 | - attr.$observe("dataparams", function(value) { | |
| 3190 | - if (value && value != "") { | |
| 3191 | - if (value == '{}') { | |
| 3192 | - return; | |
| 3193 | - } | |
| 3194 | - | |
| 3195 | - console.log("bcgroup observe 监控 dataparams=" + value); | |
| 3196 | - | |
| 3197 | - timeTableDetailManageService_g.bcdetails.list( | |
| 3198 | - JSON.parse(value), | |
| 3199 | - function(result) { | |
| 3200 | - // 获取值了 | |
| 3201 | - console.log("内部班次数据获取了"); | |
| 3202 | - | |
| 3203 | - scope[ctrlAs].$$data = []; | |
| 3204 | - for (var i = 0; i < result.length; i++) { | |
| 3205 | - scope[ctrlAs].$$data.push({ | |
| 3206 | - bcttinfoid: result[i].id, | |
| 3207 | - bcfcsj: result[i].fcsj, | |
| 3208 | - bctype: result[i].bcType | |
| 3209 | - }); | |
| 3210 | - } | |
| 3211 | - if (scope[ctrlAs].$$data_bcdata_first_init && | |
| 3212 | - scope[ctrlAs].$$data_bcttinfoids_first_init) { | |
| 3213 | - | |
| 3214 | - scope[ctrlAs].$$dataSelected = []; | |
| 3215 | - scope[ctrlAs].$$internalmodel = undefined; | |
| 3216 | - } | |
| 3217 | - scope[ctrlAs].$$data_bcdata_first_init = true; | |
| 3218 | - }, | |
| 3219 | - function(result) { | |
| 3220 | - | |
| 3221 | - } | |
| 3222 | - ); | |
| 3223 | - } | |
| 3224 | - }); | |
| 3225 | - // 监控班次ids数据的变化 | |
| 3226 | - attr.$observe("bcttinfoidsvalue", function(value) { | |
| 3227 | - if (value && value != "") { | |
| 3228 | - console.log("observe 监控 bcttinfoidsvalue=" + value); | |
| 3229 | - scope[ctrlAs].$$data_bcttinfoids_first_init = true; | |
| 3230 | - scope[ctrlAs].$$data_bcttinfoids_first_data = value; | |
| 3231 | - } | |
| 3232 | - }); | |
| 3233 | - | |
| 3234 | - } | |
| 3235 | - } | |
| 3236 | - | |
| 3237 | - } | |
| 3238 | - } | |
| 3239 | - } | |
| 1611 | + | |
| 1612 | +/** | |
| 1613 | + * saRadiogroup指令 | |
| 1614 | + * 属性如下: | |
| 1615 | + * model(必须):独立作用域,外部绑定的一个值,如:ctrl.timeTableManageForForm.isEnableDisTemplate | |
| 1616 | + * dicgroup(必须):关联的字典数据type(TODO:以后增加其他数据源) | |
| 1617 | + * name(必须):控件的名字 | |
| 1618 | + * required(可选):是否要用required验证 | |
| 1619 | + * disabled(可选):标示单选框是否可选 | |
| 1620 | + * | |
| 1621 | + */ | |
| 1622 | +angular.module('ScheduleApp').directive("saRadiogroup", [function() { | |
| 1623 | + /** | |
| 1624 | + * 使用字典数据的单选按钮组的指令。 | |
| 1625 | + * 指令名称:truefalse-Dic | |
| 1626 | + */ | |
| 1627 | + return { | |
| 1628 | + restrict: 'E', | |
| 1629 | + templateUrl: '/pages/scheduleApp/module/common/dts1/radioButton/saRadiogroupTemplate.html', | |
| 1630 | + scope: { | |
| 1631 | + model: "=" | |
| 1632 | + }, | |
| 1633 | + controllerAs: "$saRadiogroupCtrl", | |
| 1634 | + bindToController: true, | |
| 1635 | + controller: function($scope) { | |
| 1636 | + //$scope["model"] = {selectedOption: null}; | |
| 1637 | + //console.log("controller"); | |
| 1638 | + //console.log("controller:" + $scope["model"]); | |
| 1639 | + | |
| 1640 | + var self = this; | |
| 1641 | + self.$$data = null; // 内部数据 | |
| 1642 | + }, | |
| 1643 | + | |
| 1644 | + /** | |
| 1645 | + * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 1646 | + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 1647 | + * @param tElem | |
| 1648 | + * @param tAttrs | |
| 1649 | + * @returns {{pre: Function, post: Function}} | |
| 1650 | + */ | |
| 1651 | + compile: function(tElem, tAttrs) { | |
| 1652 | + // 获取属性 | |
| 1653 | + var $dicgroup_attr = tAttrs["dicgroup"]; // 关联的字典数据type | |
| 1654 | + var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 1655 | + var $required_attr = tAttrs["required"]; // 是否要用required验证 | |
| 1656 | + var $disabled_attr = tAttrs["disabled"]; // 标示单选框是否可选 | |
| 1657 | + | |
| 1658 | + // controlAs名字 | |
| 1659 | + var ctrlAs = "$saRadiogroupCtrl"; | |
| 1660 | + | |
| 1661 | + // 如果有required属性,添加angularjs required验证 | |
| 1662 | + if ($required_attr != undefined) { | |
| 1663 | + tElem.find("input").attr("required", ""); | |
| 1664 | + } | |
| 1665 | + | |
| 1666 | + return { | |
| 1667 | + pre: function(scope, element, attr) { | |
| 1668 | + | |
| 1669 | + }, | |
| 1670 | + | |
| 1671 | + /** | |
| 1672 | + * 相当于link函数。 | |
| 1673 | + * @param scope | |
| 1674 | + * @param element | |
| 1675 | + * @param attr | |
| 1676 | + */ | |
| 1677 | + post: function(scope, element, attr) { | |
| 1678 | + //console.log("link"); | |
| 1679 | + //console.log("link:" + scope.model); | |
| 1680 | + //scope["model"] = {selectedOption: null}; | |
| 1681 | + | |
| 1682 | + if ($name_attr) { | |
| 1683 | + scope[ctrlAs].nv = $name_attr; | |
| 1684 | + } | |
| 1685 | + | |
| 1686 | + if ($disabled_attr) { | |
| 1687 | + scope[ctrlAs].disabled = true; | |
| 1688 | + } | |
| 1689 | + if ($dicgroup_attr) { | |
| 1690 | + var obj = dictionaryUtils.getByGroup($dicgroup_attr); | |
| 1691 | + scope[ctrlAs].$$data = obj; | |
| 1692 | + // 处理 scope["dic"] key值 | |
| 1693 | + scope[ctrlAs].dicvalueCalcu = function(value) { | |
| 1694 | + if (value == "true") { | |
| 1695 | + //console.log(value); | |
| 1696 | + return true; | |
| 1697 | + } else if (value == "false") { | |
| 1698 | + //console.log(value); | |
| 1699 | + return false; | |
| 1700 | + } else { | |
| 1701 | + return value; | |
| 1702 | + } | |
| 1703 | + }; | |
| 1704 | + } | |
| 1705 | + } | |
| 1706 | + }; | |
| 1707 | + } | |
| 1708 | + }; | |
| 1709 | +}]); | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | +/** | |
| 1714 | + * saCheckboxgroup指令 | |
| 1715 | + * 属性如下: | |
| 1716 | + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 1717 | + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 1718 | + * dcname(必须):绑定的model字段名,如:dcname=xl.id | |
| 1719 | + * name(必须):控件的名字 | |
| 1720 | + * required(可选):是否要用required验证 | |
| 1721 | + * disabled(可选):标示框是否可选 | |
| 1722 | + * | |
| 1723 | + */ | |
| 1724 | +angular.module('ScheduleApp').directive('saCheckboxgroup', [ | |
| 1725 | + function() { | |
| 1726 | + return { | |
| 1727 | + restrict: 'E', | |
| 1728 | + templateUrl: '/pages/scheduleApp/module/common/dts1/checkbox/saCheckboxgroupTemplate.html', | |
| 1729 | + scope: { | |
| 1730 | + model: "=" // 独立作用域,关联外部的模型object | |
| 1731 | + }, | |
| 1732 | + controllerAs: "$saCheckboxgroupCtrl", | |
| 1733 | + bindToController: true, | |
| 1734 | + controller: function($scope) { | |
| 1735 | + var self = this; | |
| 1736 | + self.$$data = []; // 内部的数据 | |
| 1737 | + | |
| 1738 | + // TODO:数据写死,周一至周日选择数据,以后有别的数据再议 | |
| 1739 | + self.$$data = [ | |
| 1740 | + {name: "星期一", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1741 | + {name: "星期二", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1742 | + {name: "星期三", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1743 | + {name: "星期四", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1744 | + {name: "星期五", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1745 | + {name: "星期六", checkedvalue: "1", uncheckedvalue: "0", ischecked: false}, | |
| 1746 | + {name: "星期日", checkedvalue: "1", uncheckedvalue: "0", ischecked: false} | |
| 1747 | + ]; | |
| 1748 | + }, | |
| 1749 | + | |
| 1750 | + /** | |
| 1751 | + * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 1752 | + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 1753 | + * @param tElem | |
| 1754 | + * @param tAttrs | |
| 1755 | + * @returns {{pre: Function, post: Function}} | |
| 1756 | + */ | |
| 1757 | + compile: function(tElem, tAttrs) { | |
| 1758 | + // 获取所有的属性 | |
| 1759 | + var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 1760 | + var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 1761 | + var $disabled_attr = tAttrs["disabled"]; // 是否禁用 | |
| 1762 | + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名 | |
| 1763 | + | |
| 1764 | + // controlAs名字 | |
| 1765 | + var ctrlAs = '$saCheckboxgroupCtrl'; | |
| 1766 | + | |
| 1767 | + // 如果有required属性,添加angularjs required验证 | |
| 1768 | + if ($required_attr != undefined) { | |
| 1769 | + //console.log(tElem.html()); | |
| 1770 | + tElem.find("div").attr("required", ""); | |
| 1771 | + } | |
| 1772 | + // 如果有disabled属性,添加禁用标志 | |
| 1773 | + if ($disabled_attr != undefined) { | |
| 1774 | + tElem.find("input").attr("ng-disabled", "true"); | |
| 1775 | + } | |
| 1776 | + | |
| 1777 | + return { | |
| 1778 | + pre: function(scope, element, attr) { | |
| 1779 | + // TODO: | |
| 1780 | + }, | |
| 1781 | + /** | |
| 1782 | + * 相当于link函数。 | |
| 1783 | + * @param scope | |
| 1784 | + * @param element | |
| 1785 | + * @param attr | |
| 1786 | + */ | |
| 1787 | + post: function(scope, element, attr) { | |
| 1788 | + // name属性 | |
| 1789 | + if ($name_attr) { | |
| 1790 | + scope[ctrlAs]["$name_attr"] = $name_attr; | |
| 1791 | + } | |
| 1792 | + | |
| 1793 | + /** | |
| 1794 | + * checkbox选择事件处理函数。 | |
| 1795 | + * @param $d 数据对象,$$data中的元素对象 | |
| 1796 | + */ | |
| 1797 | + scope[ctrlAs].$$internal_updateCheck_fn = function($d) { | |
| 1798 | + $d.ischecked = !$d.ischecked; | |
| 1799 | + console.log($d); | |
| 1800 | + }; | |
| 1801 | + | |
| 1802 | + // 测试使用watch监控$$data的变化 | |
| 1803 | + scope.$watch( | |
| 1804 | + function() { | |
| 1805 | + return scope[ctrlAs]["$$data"]; | |
| 1806 | + }, | |
| 1807 | + function(newValue, oldValue) { | |
| 1808 | + // 根据$$data生成对应的数据 | |
| 1809 | + var rule_days_arr = []; | |
| 1810 | + var i; | |
| 1811 | + for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) { | |
| 1812 | + if (scope[ctrlAs]["$$data"][i].ischecked) | |
| 1813 | + rule_days_arr.push(scope[ctrlAs]["$$data"][i].checkedvalue); | |
| 1814 | + else | |
| 1815 | + rule_days_arr.push(scope[ctrlAs]["$$data"][i].uncheckedvalue); | |
| 1816 | + } | |
| 1817 | + scope[ctrlAs].$$internalmodel = rule_days_arr.join(","); | |
| 1818 | + //scope[ctrlAs].$$internalmodel = undefined; | |
| 1819 | + console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel); | |
| 1820 | + | |
| 1821 | + // 更新model | |
| 1822 | + if ($dcname_attr) { | |
| 1823 | + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = rule_days_arr.join(',');"); | |
| 1824 | + } | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + }, | |
| 1828 | + true | |
| 1829 | + ); | |
| 1830 | + | |
| 1831 | + // TODO: | |
| 1832 | + | |
| 1833 | + // 监控dcvalue model值变换 | |
| 1834 | + attr.$observe("dcvalue", function(value) { | |
| 1835 | + console.log("saCheckboxgroup 监控dc1 model值变换:" + value); | |
| 1836 | + if (value) { | |
| 1837 | + // 根据value值,修改$$data里的值 | |
| 1838 | + var data_array = value.split(","); | |
| 1839 | + var i; | |
| 1840 | + if (data_array.length > scope[ctrlAs]["$$data"].length) { | |
| 1841 | + for (i = 0; i < scope[ctrlAs]["$$data"].length; i ++) { | |
| 1842 | + if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) { | |
| 1843 | + scope[ctrlAs]["$$data"][i].ischecked = true; | |
| 1844 | + } else { | |
| 1845 | + scope[ctrlAs]["$$data"][i].ischecked = false; | |
| 1846 | + } | |
| 1847 | + } | |
| 1848 | + } else { | |
| 1849 | + for (i = 0; i < data_array.length; i ++) { | |
| 1850 | + if (data_array[i] == scope[ctrlAs]["$$data"][i].checkedvalue) { | |
| 1851 | + scope[ctrlAs]["$$data"][i].ischecked = true; | |
| 1852 | + } else { | |
| 1853 | + scope[ctrlAs]["$$data"][i].ischecked = false; | |
| 1854 | + } | |
| 1855 | + } | |
| 1856 | + } | |
| 1857 | + | |
| 1858 | + } | |
| 1859 | + }); | |
| 1860 | + } | |
| 1861 | + | |
| 1862 | + }; | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + } | |
| 1866 | + | |
| 1867 | + }; | |
| 1868 | + } | |
| 1869 | +]); | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | +/** | |
| 1875 | + * saDategroup指令 | |
| 1876 | + * 属性如下: | |
| 1877 | + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 1878 | + * dcvalue(必须):绑定的model字段值,如:dcvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 1879 | + * dcname(必须):绑定的model字段名,如:dcname=xl.id | |
| 1880 | + * name(必须):控件的名字 | |
| 1881 | + * required(可选):是否要用required验证 | |
| 1882 | + * disabled(可选):标示框是否可选 | |
| 1883 | + * | |
| 1884 | + */ | |
| 1885 | +angular.module('ScheduleApp').directive('saDategroup', [ | |
| 1886 | + '$filter', | |
| 1887 | + function($filter) { | |
| 1888 | + return { | |
| 1889 | + restrict: 'E', | |
| 1890 | + templateUrl: '/pages/scheduleApp/module/common/dts2/dateGroup/saDategroupTemplate.html', | |
| 1891 | + scope: { | |
| 1892 | + model: "=" // 独立作用域,关联外部的模型object | |
| 1893 | + }, | |
| 1894 | + controllerAs: "$saDategroupCtrl", | |
| 1895 | + bindToController: true, | |
| 1896 | + controller: function($scope) { | |
| 1897 | + var self = this; | |
| 1898 | + self.$$data = []; // 内部的数据 | |
| 1899 | + self.$$date_select; // 内部选中的日期 | |
| 1900 | + | |
| 1901 | + //// 测试数据 | |
| 1902 | + //self.$$data = [ | |
| 1903 | + // {datestr: '2011-01-01', ischecked: true}, | |
| 1904 | + // {datestr: '2011-01-01', ischecked: true}, | |
| 1905 | + // {datestr: '2011-01-01', ischecked: true} | |
| 1906 | + //]; | |
| 1907 | + }, | |
| 1908 | + | |
| 1909 | + /** | |
| 1910 | + * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 1911 | + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 1912 | + * @param tElem | |
| 1913 | + * @param tAttrs | |
| 1914 | + * @returns {{pre: Function, post: Function}} | |
| 1915 | + */ | |
| 1916 | + compile: function(tElem, tAttrs) { | |
| 1917 | + // 获取所有的属性 | |
| 1918 | + var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 1919 | + var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 1920 | + var $disabled_attr = tAttrs["disabled"]; // 是否禁用 | |
| 1921 | + var $dcname_attr = tAttrs["dcname"]; // 绑定的model字段名 | |
| 1922 | + | |
| 1923 | + // controlAs名字 | |
| 1924 | + var ctrlAs = '$saDategroupCtrl'; | |
| 1925 | + | |
| 1926 | + // 如果有required属性,添加angularjs required验证 | |
| 1927 | + if ($required_attr != undefined) { | |
| 1928 | + //console.log(tElem.html()); | |
| 1929 | + tElem.find("div").attr("required", ""); | |
| 1930 | + } | |
| 1931 | + // 如果有disabled属性,添加禁用标志 | |
| 1932 | + if ($disabled_attr != undefined) { | |
| 1933 | + tElem.find("input").attr("ng-disabled", "true"); | |
| 1934 | + tElem.find("div").attr("ng-disabled", "true"); | |
| 1935 | + } | |
| 1936 | + | |
| 1937 | + return { | |
| 1938 | + pre: function (scope, element, attr) { | |
| 1939 | + // TODO: | |
| 1940 | + }, | |
| 1941 | + /** | |
| 1942 | + * 相当于link函数。 | |
| 1943 | + * @param scope | |
| 1944 | + * @param element | |
| 1945 | + * @param attr | |
| 1946 | + */ | |
| 1947 | + post: function (scope, element, attr) { | |
| 1948 | + // name属性 | |
| 1949 | + if ($name_attr) { | |
| 1950 | + scope[ctrlAs]["$name_attr"] = $name_attr; | |
| 1951 | + } | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + // 日期open属性,及方法 | |
| 1955 | + scope[ctrlAs].$$specialDateOpen = false; | |
| 1956 | + scope[ctrlAs].$$specialDate_open = function() { | |
| 1957 | + scope[ctrlAs].$$specialDateOpen = true; | |
| 1958 | + }; | |
| 1959 | + | |
| 1960 | + // 监控选择的日期 | |
| 1961 | + scope.$watch( | |
| 1962 | + function() { | |
| 1963 | + return scope[ctrlAs]['$$date_select']; | |
| 1964 | + }, | |
| 1965 | + function(newValue, oldValue) { | |
| 1966 | + if (newValue) { | |
| 1967 | + //console.log("saDategroup--->selectdate:" + newValue); | |
| 1968 | + // 调用内置filter,转换日期到yyyy-MM-dd格式 | |
| 1969 | + var text = $filter('date')(newValue, 'yyyy-MM-dd'); | |
| 1970 | + var i; | |
| 1971 | + var isexist = false; // 日期是否已经选择标识 | |
| 1972 | + for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) { | |
| 1973 | + if (scope[ctrlAs]["$$data"][i].datestr == text) { | |
| 1974 | + isexist = true; | |
| 1975 | + break; | |
| 1976 | + } | |
| 1977 | + } | |
| 1978 | + if (!isexist) { | |
| 1979 | + scope[ctrlAs]["$$data"].push( | |
| 1980 | + { | |
| 1981 | + datestr: text, | |
| 1982 | + ischecked: true | |
| 1983 | + } | |
| 1984 | + ); | |
| 1985 | + } | |
| 1986 | + | |
| 1987 | + } | |
| 1988 | + | |
| 1989 | + } | |
| 1990 | + ); | |
| 1991 | + | |
| 1992 | + /** | |
| 1993 | + * 日期点击事件处理函数。 | |
| 1994 | + * @param $index 索引 | |
| 1995 | + */ | |
| 1996 | + scope[ctrlAs].$$internal_datestr_click = function($index) { | |
| 1997 | + scope[ctrlAs].$$data.splice($index, 1); | |
| 1998 | + }; | |
| 1999 | + | |
| 2000 | + // 测试使用watch监控$$data的变化 | |
| 2001 | + scope.$watch( | |
| 2002 | + function() { | |
| 2003 | + return scope[ctrlAs]['$$data']; | |
| 2004 | + }, | |
| 2005 | + function(newValue, oldValue) { | |
| 2006 | + // 根据$$data生成对应的数据 | |
| 2007 | + var special_days_arr = []; | |
| 2008 | + var i; | |
| 2009 | + for (i = 0; i < scope[ctrlAs]["$$data"].length; i++) { | |
| 2010 | + special_days_arr.push(scope[ctrlAs]["$$data"][i].datestr); | |
| 2011 | + } | |
| 2012 | + | |
| 2013 | + scope[ctrlAs].$$internalmodel = special_days_arr.join(","); | |
| 2014 | + console.log("bbbbbbbb--->" + scope[ctrlAs].$$internalmodel); | |
| 2015 | + | |
| 2016 | + // 更新model | |
| 2017 | + if ($dcname_attr) { | |
| 2018 | + eval("scope[ctrlAs].model" + "." + $dcname_attr + " = special_days_arr.join(',');"); | |
| 2019 | + } | |
| 2020 | + }, | |
| 2021 | + true | |
| 2022 | + ); | |
| 2023 | + | |
| 2024 | + // 监控dcvalue model值变换 | |
| 2025 | + attr.$observe("dcvalue", function(value) { | |
| 2026 | + console.log("saDategroup 监控dc1 model值变换:" + value); | |
| 2027 | + if (value) { | |
| 2028 | + // 根据value值,修改$$data里的值 | |
| 2029 | + var date_array = value.split(","); | |
| 2030 | + var i; | |
| 2031 | + scope[ctrlAs]["$$data"] = []; | |
| 2032 | + for (i = 0; i < date_array.length; i++) { | |
| 2033 | + scope[ctrlAs]["$$data"].push( | |
| 2034 | + { | |
| 2035 | + datestr: date_array[i], | |
| 2036 | + ischecked: true | |
| 2037 | + } | |
| 2038 | + ); | |
| 2039 | + } | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + } | |
| 2050 | + }); | |
| 2051 | + | |
| 2052 | + } | |
| 2053 | + | |
| 2054 | + }; | |
| 2055 | + } | |
| 2056 | + } | |
| 2057 | + } | |
| 2058 | +]); | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | +/** | |
| 2064 | + * saGuideboardgroup指令 | |
| 2065 | + * 属性如下: | |
| 2066 | + * name(必须):控件的名字 | |
| 2067 | + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 2068 | + * xlidvalue(必须):绑定的model线路id值,如:xlidvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 2069 | + * lprangevalue(必须):绑定的model路牌名字范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}} | |
| 2070 | + * lprangename(必须):绑定的model路牌名字范围字段名,如:lprangename=lprange | |
| 2071 | + * lpidrangevalue(必须):绑定的model路牌id范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}} | |
| 2072 | + * lpidrangename(必须):绑定的model路牌id范围字段名,如:lprangename=lprange | |
| 2073 | + * lpstartvalue(必须):绑定的model起始路牌值,如:lpstartvalue={{ctrl.employeeInfoForSave.lpstart}} | |
| 2074 | + * lpstartname(必须):绑定的model起始路牌字段名,如:lpstartname=lpstart | |
| 2075 | + * | |
| 2076 | + * required(可选):是否要用required验证 | |
| 2077 | + * | |
| 2078 | + */ | |
| 2079 | +angular.module('ScheduleApp').directive('saGuideboardgroup', [ | |
| 2080 | + 'GuideboardManageService_g', | |
| 2081 | + function(guideboardManageService_g) { | |
| 2082 | + return { | |
| 2083 | + restrict: 'E', | |
| 2084 | + templateUrl: '/pages/scheduleApp/module/common/dts2/guideboardGroup/saGuideboardgroupTemplate.html', | |
| 2085 | + scope: { | |
| 2086 | + model: "=" // 独立作用域,关联外部的模型object | |
| 2087 | + }, | |
| 2088 | + controllerAs: '$saGuideboardgroupCtrl', | |
| 2089 | + bindToController: true, | |
| 2090 | + controller: function($scope) { | |
| 2091 | + var self = this; | |
| 2092 | + self.$$data = []; // 选择线路后,该线路的路牌数据 | |
| 2093 | + | |
| 2094 | + // 测试数据 | |
| 2095 | + //self.$$data = [ | |
| 2096 | + // {lpid: 1, lpname: '路1', isstart: false}, | |
| 2097 | + // {lpid: 2, lpname: '路2', isstart: true}, | |
| 2098 | + // {lpid: 3, lpname: '路3', isstart: false} | |
| 2099 | + //]; | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + self.$$dataSelected = []; // 选中的路牌列表 | |
| 2103 | + self.$$dataSelectedStart = undefined; // 起始路牌 | |
| 2104 | + | |
| 2105 | + //self.$$dataSelected = [ | |
| 2106 | + // {lpid: 11, lpname: '路11', isstart: false}, | |
| 2107 | + // {lpid: 12, lpname: '路12', isstart: true}, | |
| 2108 | + // {lpid: 13, lpname: '路13', isstart: false} | |
| 2109 | + //]; | |
| 2110 | + | |
| 2111 | + // saGuideboardgroup组件的ng-model,用于外部绑定等操作 | |
| 2112 | + self.$$internalmodel = undefined; | |
| 2113 | + | |
| 2114 | + self.$$data_init = false; // *数据源初始化标志 | |
| 2115 | + self.$$data_xl_first_init = false; // 线路是否初始化 | |
| 2116 | + self.$$data_lp_first_init = false; // 路牌名字是否初始化 | |
| 2117 | + self.$$data_lpid_first_init = false; // 路牌id是否初始化 | |
| 2118 | + self.$$data_lpstart_first_init = false; // 起始路牌是否初始化 | |
| 2119 | + | |
| 2120 | + }, | |
| 2121 | + | |
| 2122 | + /** | |
| 2123 | + * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 2124 | + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 2125 | + * @param tElem | |
| 2126 | + * @param tAttrs | |
| 2127 | + * @returns {{pre: Function, post: Function}} | |
| 2128 | + */ | |
| 2129 | + compile: function(tElem, tAttrs) { | |
| 2130 | + // TODO:获取所有的属性 | |
| 2131 | + var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 2132 | + var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 2133 | + var $lprangename_attr = tAttrs["lprangename"]; // 绑定的model路牌名字范围字段名 | |
| 2134 | + var $lpidrangename_attr = tAttrs["lpidrangename"]; // 绑定的model路牌id范围字段名 | |
| 2135 | + var $lpstartname_attr = tAttrs["lpstartname"]; // 绑定的model起始路牌字段名 | |
| 2136 | + | |
| 2137 | + // controlAs名字 | |
| 2138 | + var ctrlAs = '$saGuideboardgroupCtrl'; | |
| 2139 | + | |
| 2140 | + // 如果有required属性,添加angularjs required验证 | |
| 2141 | + if ($required_attr != undefined) { | |
| 2142 | + //console.log(tElem.html()); | |
| 2143 | + tElem.find("div").attr("required", ""); | |
| 2144 | + } | |
| 2145 | + | |
| 2146 | + return { | |
| 2147 | + pre: function(scope, element, attr) { | |
| 2148 | + // TODO: | |
| 2149 | + }, | |
| 2150 | + | |
| 2151 | + /** | |
| 2152 | + * 相当于link函数。 | |
| 2153 | + * @param scope | |
| 2154 | + * @param element | |
| 2155 | + * @param attr | |
| 2156 | + */ | |
| 2157 | + post: function(scope, element, attr) { | |
| 2158 | + // name属性 | |
| 2159 | + if ($name_attr) { | |
| 2160 | + scope[ctrlAs]["$name_attr"] = $name_attr; | |
| 2161 | + } | |
| 2162 | + | |
| 2163 | + // TODO: | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + /** | |
| 2167 | + * 路牌列表点击(路牌列表中选中路牌) | |
| 2168 | + * @param $index | |
| 2169 | + */ | |
| 2170 | + scope[ctrlAs].$$internal_lplist_click = function($index) { | |
| 2171 | + var data_temp = scope[ctrlAs].$$data; | |
| 2172 | + if (data_temp && data_temp.length > $index) { | |
| 2173 | + scope[ctrlAs].$$dataSelected.push({ | |
| 2174 | + lpid: data_temp[$index].lpid, | |
| 2175 | + lpname: data_temp[$index].lpname, | |
| 2176 | + isstart: data_temp[$index].isstart | |
| 2177 | + }); | |
| 2178 | + | |
| 2179 | + // 如果没有指定过初始路牌,默认选择此路牌作为起始路牌 | |
| 2180 | + if (scope[ctrlAs].$$dataSelectedStart == undefined) { | |
| 2181 | + scope[ctrlAs].$$internal_sellplist_click( | |
| 2182 | + scope[ctrlAs].$$dataSelected.length - 1); | |
| 2183 | + } | |
| 2184 | + } | |
| 2185 | + }; | |
| 2186 | + /** | |
| 2187 | + * 选中的路牌单击(初始路牌选择) | |
| 2188 | + * @param $index | |
| 2189 | + */ | |
| 2190 | + scope[ctrlAs].$$internal_sellplist_click = function($index) { | |
| 2191 | + var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2192 | + if (data_temp && data_temp.length > $index) { | |
| 2193 | + for (var i = 0; i < data_temp.length; i++) { | |
| 2194 | + data_temp[i].isstart = false; | |
| 2195 | + } | |
| 2196 | + data_temp[$index].isstart = true; | |
| 2197 | + scope[ctrlAs].$$dataSelectedStart = $index; | |
| 2198 | + } | |
| 2199 | + }; | |
| 2200 | + /** | |
| 2201 | + * 选中的路牌双击(删除选中的路牌) | |
| 2202 | + * @param $index | |
| 2203 | + */ | |
| 2204 | + scope[ctrlAs].$$internal_sellplist_dbclick = function($index) { | |
| 2205 | + var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2206 | + if (data_temp && data_temp.length > $index) { | |
| 2207 | + if (scope[ctrlAs].$$dataSelectedStart == $index) { | |
| 2208 | + scope[ctrlAs].$$dataSelectedStart = undefined; | |
| 2209 | + } | |
| 2210 | + data_temp.splice($index, 1); | |
| 2211 | + } | |
| 2212 | + }; | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + /** | |
| 2216 | + * 验证内部数据,更新外部model | |
| 2217 | + */ | |
| 2218 | + scope[ctrlAs].$$internal_validate_model = function() { | |
| 2219 | + var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2220 | + var data_temp2 = scope[ctrlAs].$$dataSelectedStart; | |
| 2221 | + var lpNames = []; | |
| 2222 | + var lpIds = []; | |
| 2223 | + var lpStart = 0; | |
| 2224 | + var i = 0; | |
| 2225 | + | |
| 2226 | + if (data_temp && | |
| 2227 | + data_temp.length > 0 && | |
| 2228 | + data_temp2 != undefined) { | |
| 2229 | + | |
| 2230 | + for (i = 0; i < data_temp.length; i++) { | |
| 2231 | + lpNames.push(data_temp[i].lpname); | |
| 2232 | + lpIds.push(data_temp[i].lpid) | |
| 2233 | + } | |
| 2234 | + data_temp[data_temp2].isstart = true; | |
| 2235 | + lpStart = data_temp2 + 1; | |
| 2236 | + | |
| 2237 | + // 更新内部model,用于外部验证 | |
| 2238 | + // 内部model的值暂时随意,以后再改 | |
| 2239 | + scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 2240 | + | |
| 2241 | + // 更新外部model字段 | |
| 2242 | + if ($lprangename_attr) { | |
| 2243 | + console.log("lprangename=" + lpNames.join(',')); | |
| 2244 | + eval("scope[ctrlAs].model" + "." + $lprangename_attr + " = lpNames.join(',');"); | |
| 2245 | + } | |
| 2246 | + if ($lpidrangename_attr) { | |
| 2247 | + console.log("lpidrangename=" + lpIds.join(',')); | |
| 2248 | + eval("scope[ctrlAs].model" + "." + $lpidrangename_attr + " = lpIds.join(',');"); | |
| 2249 | + } | |
| 2250 | + if ($lpstartname_attr) { | |
| 2251 | + console.log("lpstartname=" + lpStart); | |
| 2252 | + eval("scope[ctrlAs].model" + "." + $lpstartname_attr + " = lpStart;"); | |
| 2253 | + } | |
| 2254 | + | |
| 2255 | + } else { | |
| 2256 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 2257 | + } | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + }; | |
| 2261 | + | |
| 2262 | + // 监控内部数据,$$data_selected 变化 | |
| 2263 | + scope.$watch( | |
| 2264 | + function() { | |
| 2265 | + return scope[ctrlAs].$$dataSelected; | |
| 2266 | + }, | |
| 2267 | + function(newValue, oldValue) { | |
| 2268 | + scope[ctrlAs].$$internal_validate_model(); | |
| 2269 | + }, | |
| 2270 | + true | |
| 2271 | + ); | |
| 2272 | + | |
| 2273 | + // 监控内部数据,$$data_selected_start 变化 | |
| 2274 | + scope.$watch( | |
| 2275 | + function() { | |
| 2276 | + return scope[ctrlAs].$$dataSelectedStart; | |
| 2277 | + }, | |
| 2278 | + function(newValue, oldValue) { | |
| 2279 | + scope[ctrlAs].$$internal_validate_model(); | |
| 2280 | + }, | |
| 2281 | + true | |
| 2282 | + ); | |
| 2283 | + | |
| 2284 | + /** | |
| 2285 | + * 验证数据是否初始化完成, | |
| 2286 | + * 所谓的初始化就是内部所有的数据被有效设定过一次。 | |
| 2287 | + */ | |
| 2288 | + scope[ctrlAs].$$internal_validate_init = function() { | |
| 2289 | + var self = scope[ctrlAs]; | |
| 2290 | + | |
| 2291 | + if (self.$$data_xl_first_init && | |
| 2292 | + self.$$data_lp_first_init && | |
| 2293 | + self.$$data_lpid_first_init && | |
| 2294 | + self.$$data_lpstart_first_init) { | |
| 2295 | + console.log("数据初始化完毕!"); | |
| 2296 | + self.$$data_init = true; | |
| 2297 | + } | |
| 2298 | + | |
| 2299 | + }; | |
| 2300 | + | |
| 2301 | + // 监控初始化标志,线路,路牌,路牌id,起始路牌 | |
| 2302 | + scope.$watch( | |
| 2303 | + function() { | |
| 2304 | + return scope[ctrlAs].$$data_xl_first_init; | |
| 2305 | + }, | |
| 2306 | + function(newValue, oldValue) { | |
| 2307 | + scope[ctrlAs].$$internal_validate_init(); | |
| 2308 | + } | |
| 2309 | + ); | |
| 2310 | + scope.$watch( | |
| 2311 | + function() { | |
| 2312 | + return scope[ctrlAs].$$data_lp_first_init; | |
| 2313 | + }, | |
| 2314 | + function(newValue, oldValue) { | |
| 2315 | + scope[ctrlAs].$$internal_validate_init(); | |
| 2316 | + } | |
| 2317 | + ); | |
| 2318 | + scope.$watch( | |
| 2319 | + function() { | |
| 2320 | + return scope[ctrlAs].$$data_lpid_first_init; | |
| 2321 | + }, | |
| 2322 | + function(newValue, oldValue) { | |
| 2323 | + scope[ctrlAs].$$internal_validate_init(); | |
| 2324 | + } | |
| 2325 | + ); | |
| 2326 | + scope.$watch( | |
| 2327 | + function() { | |
| 2328 | + return scope[ctrlAs].$$data_lpstart_first_init; | |
| 2329 | + }, | |
| 2330 | + function(newValue, oldValue) { | |
| 2331 | + scope[ctrlAs].$$internal_validate_init(); | |
| 2332 | + } | |
| 2333 | + ); | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + // 监控线路id的变化 | |
| 2337 | + attr.$observe("xlidvalue", function(value) { | |
| 2338 | + if (value && value != "") { | |
| 2339 | + console.log("xlidvalue=" + value); | |
| 2340 | + | |
| 2341 | + guideboardManageService_g.rest.list( | |
| 2342 | + {"xl.id_eq": value, size: 100}, | |
| 2343 | + function(result) { | |
| 2344 | + // 获取值了 | |
| 2345 | + console.log("路牌获取了"); | |
| 2346 | + | |
| 2347 | + scope[ctrlAs].$$data = []; | |
| 2348 | + for (var i = 0; i < result.content.length; i++) { | |
| 2349 | + scope[ctrlAs].$$data.push({ | |
| 2350 | + lpid: result.content[i].id, | |
| 2351 | + lpname: result.content[i].lpName, | |
| 2352 | + isstart: false | |
| 2353 | + }); | |
| 2354 | + } | |
| 2355 | + if (scope[ctrlAs].$$data_init) { | |
| 2356 | + scope[ctrlAs].$$dataSelected = []; | |
| 2357 | + scope[ctrlAs].$$dataSelectedStart = undefined; | |
| 2358 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 2359 | + } | |
| 2360 | + scope[ctrlAs].$$data_xl_first_init = true; | |
| 2361 | + }, | |
| 2362 | + function(result) { | |
| 2363 | + | |
| 2364 | + } | |
| 2365 | + ); | |
| 2366 | + | |
| 2367 | + } | |
| 2368 | + }); | |
| 2369 | + | |
| 2370 | + // 监控路牌名称范围值的变化 | |
| 2371 | + attr.$observe("lprangevalue", function(value) { | |
| 2372 | + if (value && value != "") { | |
| 2373 | + var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2374 | + var lpnames = value.split(","); | |
| 2375 | + var i = 0; | |
| 2376 | + if (data_temp && data_temp.length == 0) { // 初始创建 | |
| 2377 | + console.log("lprangevalue变换了"); | |
| 2378 | + for (i = 0; i < lpnames.length; i++) { | |
| 2379 | + scope[ctrlAs].$$dataSelected.push({ | |
| 2380 | + lpname: lpnames[i], | |
| 2381 | + isstart: false | |
| 2382 | + }); | |
| 2383 | + } | |
| 2384 | + } else { | |
| 2385 | + for (i = 0; i < lpnames.length; i++) { | |
| 2386 | + data_temp[i].lpname = lpnames[i]; | |
| 2387 | + } | |
| 2388 | + } | |
| 2389 | + scope[ctrlAs].$$data_lp_first_init = true; | |
| 2390 | + } | |
| 2391 | + }); | |
| 2392 | + | |
| 2393 | + // 监控路牌id范围值的变化 | |
| 2394 | + attr.$observe("lpidrangevalue", function(value) { | |
| 2395 | + if (value && value != "") { | |
| 2396 | + console.log("lpidrangevalue=" + value); | |
| 2397 | + var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2398 | + var lpids = value.split(","); | |
| 2399 | + var i = 0; | |
| 2400 | + if (data_temp && data_temp.length == 0) { // 初始创建 | |
| 2401 | + console.log("lpidrangevalue"); | |
| 2402 | + for (i = 0; i < lpids.length; i++) { | |
| 2403 | + scope[ctrlAs].$$dataSelected.push({ | |
| 2404 | + lpid: lpids[i], | |
| 2405 | + isstart: false | |
| 2406 | + }); | |
| 2407 | + } | |
| 2408 | + } else { | |
| 2409 | + for (i = 0; i < lpids.length; i++) { | |
| 2410 | + data_temp[i].lpid = lpids[i]; | |
| 2411 | + } | |
| 2412 | + } | |
| 2413 | + scope[ctrlAs].$$data_lpid_first_init = true; | |
| 2414 | + } | |
| 2415 | + }); | |
| 2416 | + | |
| 2417 | + // 监控起始路牌的变化 | |
| 2418 | + attr.$observe("lpstartvalue", function(value) { | |
| 2419 | + if (value && value != "") { | |
| 2420 | + scope[ctrlAs].$$dataSelectedStart = value - 1; | |
| 2421 | + scope[ctrlAs].$$data_lpstart_first_init = true; | |
| 2422 | + } | |
| 2423 | + }); | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + } | |
| 2428 | + } | |
| 2429 | + | |
| 2430 | + } | |
| 2431 | + } | |
| 2432 | + } | |
| 2433 | +]); | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | +/** | |
| 2439 | + * saEmployeegroup指令 | |
| 2440 | + * 属性如下: | |
| 2441 | + * name(必须):控件的名字 | |
| 2442 | + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 2443 | + * xlidvalue(必须):绑定的model线路id值,如:xlidvalue={{ctrl.employeeInfoForSave.xl.id}} | |
| 2444 | + * dbbmrangevalue(必须):绑定的model搭班编码范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}} | |
| 2445 | + * dbbmrangename(必须):绑定的model搭班编码范围字段名,如:lprangename=lprange | |
| 2446 | + * rycidrangevalue(必须):绑定的model人员配置idid范围值,如:lprangevalue={{ctrl.employeeInfoForSave.lprange}} | |
| 2447 | + * rycidrangename(必须):绑定的model人员配置id范围字段名,如:lprangename=lprange | |
| 2448 | + * rystartvalue(必须):绑定的model起始人员,如:lpstartvalue={{ctrl.employeeInfoForSave.lpstart}} | |
| 2449 | + * rystartname(必须):绑定的model起始人员字段名,如:lpstartname=lpstart | |
| 2450 | + * | |
| 2451 | + * required(可选):是否要用required验证 | |
| 2452 | + * | |
| 2453 | + */ | |
| 2454 | +angular.module('ScheduleApp').directive('saEmployeegroup', [ | |
| 2455 | + 'EmployeeConfigService_g', | |
| 2456 | + function(employeeConfigService_g) { | |
| 2457 | + return { | |
| 2458 | + restrict: 'E', | |
| 2459 | + templateUrl: '/pages/scheduleApp/module/common/dts2/employeeGroup/saEmployeegroupTemplate.html', | |
| 2460 | + scope: { | |
| 2461 | + model: "=" // 独立作用域,关联外部的模型object | |
| 2462 | + }, | |
| 2463 | + controllerAs: '$saEmployeegroupCtrl', | |
| 2464 | + bindToController: true, | |
| 2465 | + controller: function($scope) { | |
| 2466 | + var self = this; | |
| 2467 | + self.$$data = []; // 选择线路后,该线路的人员配置数据 | |
| 2468 | + | |
| 2469 | + // 测试数据 | |
| 2470 | + //self.$$data = [ | |
| 2471 | + // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1'}, | |
| 2472 | + // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2'}, | |
| 2473 | + // {id: 3, dbbm: "3", jsy: '忍3', spy: '守3'} | |
| 2474 | + //]; | |
| 2475 | + | |
| 2476 | + self.$$dataSelected = []; // 选中的人员配置列表 | |
| 2477 | + self.$$dataSelectedStart = undefined; // 起始人员配置 | |
| 2478 | + | |
| 2479 | + //self.$$dataSelected = [ | |
| 2480 | + // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isstart: false}, | |
| 2481 | + // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true}, | |
| 2482 | + // {id: 3, dbbm: "3", jsy: '忍3', spy: '守3', isstart: false} | |
| 2483 | + //]; | |
| 2484 | + | |
| 2485 | + self.$$isFB = false; // 是否分班 | |
| 2486 | + self.$$dataFBSelected = []; // 选中的分班人员组配置列表 | |
| 2487 | + self.$$dataFBInternalSelected = undefined; // 分班组内人员选中标识 | |
| 2488 | + self.$$dataFBSelectedStart = undefined; // 选中的起始分班人员组合 | |
| 2489 | + | |
| 2490 | + //self.$$dataFBSelected = [ | |
| 2491 | + // {isstart: true, group: [ | |
| 2492 | + // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isselected: false}, | |
| 2493 | + // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true} | |
| 2494 | + // ]}, | |
| 2495 | + // {isstart: false, group: [ | |
| 2496 | + // {id: 1, dbbm: "1", jsy: '忍1', spy: '守1', isselected: false}, | |
| 2497 | + // {id: 2, dbbm: "2", jsy: '忍2', spy: '守2', isstart: true} | |
| 2498 | + // ]} | |
| 2499 | + //]; | |
| 2500 | + | |
| 2501 | + // saGuideboardgroup组件的ng-model,用于外部绑定等操作 | |
| 2502 | + self.$$internalmodel = undefined; | |
| 2503 | + | |
| 2504 | + self.$$data_init = false; // *数据源初始化标志 | |
| 2505 | + self.$$data_xl_first_init = false; // 线路是否初始化 | |
| 2506 | + self.$$data_ry_first_init = false; // 人员配置是否初始化 | |
| 2507 | + self.$$data_ry_first_data = undefined; // 人员配置初始化数据 | |
| 2508 | + self.$$data_rycid_first_init = false; // 人员配置id是否初始化 | |
| 2509 | + self.$$data_rycid_first_data = undefined; // 人员配置id初始化数据 | |
| 2510 | + self.$$data_rystart_first_init = false; // 起始人员是否初始化 | |
| 2511 | + self.$$data_rystart_first_data = undefined; // 起始人员初始化数据 | |
| 2512 | + | |
| 2513 | + }, | |
| 2514 | + | |
| 2515 | + /** | |
| 2516 | + * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 2517 | + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 2518 | + * @param tElem | |
| 2519 | + * @param tAttrs | |
| 2520 | + * @returns {{pre: Function, post: Function}} | |
| 2521 | + */ | |
| 2522 | + compile: function(tElem, tAttrs) { | |
| 2523 | + // TODO:获取所有的属性 | |
| 2524 | + var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 2525 | + var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 2526 | + var $dbbmrangename_attr = tAttrs["dbbmrangename"]; // 绑定的model搭班编码范围字段名 | |
| 2527 | + var rycidrangename_attr = tAttrs["rycidrangename"]; // 绑定的model人员配置id范围字段名 | |
| 2528 | + var $rystartname_attr = tAttrs["rystartname"]; // 绑定的model起始人员字段名 | |
| 2529 | + | |
| 2530 | + // controlAs名字 | |
| 2531 | + var ctrlAs = '$saEmployeegroupCtrl'; | |
| 2532 | + | |
| 2533 | + // 如果有required属性,添加angularjs required验证 | |
| 2534 | + if ($required_attr != undefined) { | |
| 2535 | + //console.log(tElem.html()); | |
| 2536 | + tElem.find("div").attr("required", ""); | |
| 2537 | + } | |
| 2538 | + | |
| 2539 | + return { | |
| 2540 | + pre: function(scope, element, attr) { | |
| 2541 | + // TODO: | |
| 2542 | + }, | |
| 2543 | + | |
| 2544 | + /** | |
| 2545 | + * 相当于link函数。 | |
| 2546 | + * @param scope | |
| 2547 | + * @param element | |
| 2548 | + * @param attr | |
| 2549 | + */ | |
| 2550 | + post: function(scope, element, attr) { | |
| 2551 | + // name属性 | |
| 2552 | + if ($name_attr) { | |
| 2553 | + scope[ctrlAs]["$name_attr"] = $name_attr; | |
| 2554 | + } | |
| 2555 | + | |
| 2556 | + /** | |
| 2557 | + * 人员配置列表点击(人员配置列表中选中路牌) | |
| 2558 | + * @param $index | |
| 2559 | + */ | |
| 2560 | + scope[ctrlAs].$$internal_rylist_click = function($index) { | |
| 2561 | + var data_temp = scope[ctrlAs].$$data; | |
| 2562 | + if (data_temp && data_temp.length > $index) { | |
| 2563 | + if (!scope[ctrlAs].$$isFB) { // 不分班 | |
| 2564 | + scope[ctrlAs].$$dataSelected.push({ | |
| 2565 | + id : data_temp[$index].id, | |
| 2566 | + dbbm: data_temp[$index].dbbm, | |
| 2567 | + jsy: data_temp[$index].jsy, | |
| 2568 | + spy: data_temp[$index].spy, | |
| 2569 | + isstart: false | |
| 2570 | + }); | |
| 2571 | + | |
| 2572 | + // 如果没有指定过初始人员,默认选择此人员作为起始人员 | |
| 2573 | + if (scope[ctrlAs].$$dataSelectedStart == undefined) { | |
| 2574 | + scope[ctrlAs].$$internal_selrylist_click( | |
| 2575 | + scope[ctrlAs].$$dataSelected.length - 1); | |
| 2576 | + } | |
| 2577 | + } else { // 分班 | |
| 2578 | + if (scope[ctrlAs].$$dataFBInternalSelected) { // 替换组内人员 | |
| 2579 | + scope[ctrlAs].$$dataFBSelected | |
| 2580 | + [scope[ctrlAs].$$dataFBInternalSelected.gindex].group | |
| 2581 | + [scope[ctrlAs].$$dataFBInternalSelected.index] = { | |
| 2582 | + id : data_temp[$index].id, | |
| 2583 | + dbbm: data_temp[$index].dbbm, | |
| 2584 | + jsy: data_temp[$index].jsy, | |
| 2585 | + spy: data_temp[$index].spy, | |
| 2586 | + isselected: true | |
| 2587 | + }; | |
| 2588 | + | |
| 2589 | + } else { | |
| 2590 | + scope[ctrlAs].$$dataFBSelected.push({ | |
| 2591 | + isstart: false, | |
| 2592 | + group: [].concat( | |
| 2593 | + { | |
| 2594 | + id : data_temp[$index].id, | |
| 2595 | + dbbm: data_temp[$index].dbbm, | |
| 2596 | + jsy: data_temp[$index].jsy, | |
| 2597 | + spy: data_temp[$index].spy, | |
| 2598 | + isselected: false | |
| 2599 | + }, { | |
| 2600 | + id : data_temp[$index].id, | |
| 2601 | + dbbm: data_temp[$index].dbbm, | |
| 2602 | + jsy: data_temp[$index].jsy, | |
| 2603 | + spy: data_temp[$index].spy, | |
| 2604 | + isselected: false | |
| 2605 | + } | |
| 2606 | + ) | |
| 2607 | + }); | |
| 2608 | + if (scope[ctrlAs].$$dataFBSelectedStart == undefined) { | |
| 2609 | + scope[ctrlAs].$$internal_selrygrouplist_click( | |
| 2610 | + scope[ctrlAs].$$dataFBSelected.length - 1); | |
| 2611 | + } | |
| 2612 | + } | |
| 2613 | + } | |
| 2614 | + | |
| 2615 | + } | |
| 2616 | + }; | |
| 2617 | + | |
| 2618 | + /** | |
| 2619 | + * 选中的人员单击(初始人员选择) | |
| 2620 | + * @param $index | |
| 2621 | + */ | |
| 2622 | + scope[ctrlAs].$$internal_selrylist_click = function($index) { | |
| 2623 | + var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2624 | + if (data_temp && data_temp.length > $index) { | |
| 2625 | + for (var i = 0; i < data_temp.length; i++) { | |
| 2626 | + data_temp[i].isstart = false; | |
| 2627 | + } | |
| 2628 | + data_temp[$index].isstart = true; | |
| 2629 | + scope[ctrlAs].$$dataSelectedStart = $index; | |
| 2630 | + } | |
| 2631 | + }; | |
| 2632 | + /** | |
| 2633 | + * 选中的人员双击(删除选中的人员) | |
| 2634 | + * @param $index | |
| 2635 | + */ | |
| 2636 | + scope[ctrlAs].$$internal_selrylist_dbclick = function($index) { | |
| 2637 | + var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2638 | + if (data_temp && data_temp.length > $index) { | |
| 2639 | + if (scope[ctrlAs].$$dataSelectedStart == $index) { | |
| 2640 | + scope[ctrlAs].$$dataSelectedStart = undefined; | |
| 2641 | + } | |
| 2642 | + data_temp.splice($index, 1); | |
| 2643 | + } | |
| 2644 | + }; | |
| 2645 | + | |
| 2646 | + /** | |
| 2647 | + * 选中的分班组人员单击(初始人员选择) | |
| 2648 | + * @param $index | |
| 2649 | + */ | |
| 2650 | + scope[ctrlAs].$$internal_selrygrouplist_click = function($index) { | |
| 2651 | + var data_temp = scope[ctrlAs].$$dataFBSelected; | |
| 2652 | + if (data_temp && data_temp.length > $index) { | |
| 2653 | + for (var i = 0; i < data_temp.length; i++) { | |
| 2654 | + data_temp[i].isstart = false; | |
| 2655 | + for (var j = 0; j < data_temp[i].group.length; j++) { | |
| 2656 | + data_temp[i].group[j].isselected = false; | |
| 2657 | + } | |
| 2658 | + } | |
| 2659 | + data_temp[$index].isstart = true; | |
| 2660 | + scope[ctrlAs].$$dataFBSelectedStart = $index; | |
| 2661 | + scope[ctrlAs].$$dataFBInternalSelected = undefined; | |
| 2662 | + } | |
| 2663 | + }; | |
| 2664 | + /** | |
| 2665 | + * 分组内部单击(选中分班中的某组人员) | |
| 2666 | + * @param $groupindex 组index | |
| 2667 | + * @param $index 组内部某个index | |
| 2668 | + * @param $event 事件防止冒泡 | |
| 2669 | + */ | |
| 2670 | + scope[ctrlAs].$$internal_selrygroup_click = function($groupindex, $index, $event) { | |
| 2671 | + var data_temp = scope[ctrlAs].$$dataFBSelected; | |
| 2672 | + if (data_temp && data_temp.length > $groupindex) { | |
| 2673 | + if (data_temp[$groupindex].group && data_temp[$groupindex].group.length > $index) { | |
| 2674 | + // $$dataFBInternalSelected的格式如下: | |
| 2675 | + //{gindex: 1, index: 0} | |
| 2676 | + for (var i = 0; i < data_temp.length; i++) { | |
| 2677 | + data_temp[i].isstart = false; | |
| 2678 | + for (var j = 0; j < data_temp[i].group.length; j++) { | |
| 2679 | + data_temp[i].group[j].isselected = false; | |
| 2680 | + } | |
| 2681 | + } | |
| 2682 | + data_temp[$groupindex].group[$index].isselected = true; | |
| 2683 | + scope[ctrlAs].$$dataFBInternalSelected = { | |
| 2684 | + gindex: $groupindex, index: $index | |
| 2685 | + }; | |
| 2686 | + scope[ctrlAs].$$dataFBSelectedStart = undefined; | |
| 2687 | + $event.stopPropagation(); | |
| 2688 | + } | |
| 2689 | + } | |
| 2690 | + | |
| 2691 | + }; | |
| 2692 | + /** | |
| 2693 | + * 选中的分班人员双击(删除选中的人员) | |
| 2694 | + * @param $index | |
| 2695 | + */ | |
| 2696 | + scope[ctrlAs].$$internal_selrygrouplist_dbclick = function($index) { | |
| 2697 | + var data_temp = scope[ctrlAs].$$dataFBSelected; | |
| 2698 | + if (data_temp && data_temp.length > $index) { | |
| 2699 | + if (scope[ctrlAs].$$dataFBSelectedStart == $index) { | |
| 2700 | + scope[ctrlAs].$$dataFBSelectedStart = undefined; | |
| 2701 | + } | |
| 2702 | + if (scope[ctrlAs].$$dataFBInternalSelected && | |
| 2703 | + scope[ctrlAs].$$dataFBInternalSelected.gindex == $index) { | |
| 2704 | + scope[ctrlAs].$$dataFBInternalSelected = undefined; | |
| 2705 | + } | |
| 2706 | + data_temp.splice($index, 1); | |
| 2707 | + } | |
| 2708 | + }; | |
| 2709 | + | |
| 2710 | + /** | |
| 2711 | + * 验证内部数据,更新外部model | |
| 2712 | + */ | |
| 2713 | + scope[ctrlAs].$$internal_validate_model = function() { | |
| 2714 | + var data_temp = scope[ctrlAs].$$dataSelected; | |
| 2715 | + var data_temp2 = scope[ctrlAs].$$dataSelectedStart; | |
| 2716 | + var data_temp3 = scope[ctrlAs].$$dataFBSelected; | |
| 2717 | + var data_temp4 = scope[ctrlAs].$$dataFBSelectedStart; | |
| 2718 | + var ryDbbms = []; | |
| 2719 | + var ryDbbm_group = []; | |
| 2720 | + var ryCids = []; | |
| 2721 | + var ryCid_group = []; | |
| 2722 | + var ryStart = 0; | |
| 2723 | + var i = 0; | |
| 2724 | + var j = 0; | |
| 2725 | + | |
| 2726 | + var isFB = scope[ctrlAs].$$isFB; | |
| 2727 | + | |
| 2728 | + if (isFB) { | |
| 2729 | + if (data_temp3 && | |
| 2730 | + data_temp3.length > 0 && | |
| 2731 | + data_temp4 != undefined) { | |
| 2732 | + | |
| 2733 | + for (i = 0; i < data_temp3.length; i++) { | |
| 2734 | + for (j = 0; j < data_temp3[i].group.length; j++) { | |
| 2735 | + ryDbbm_group.push(data_temp3[i].group[j].dbbm); | |
| 2736 | + ryCid_group.push(data_temp3[i].group[j].id); | |
| 2737 | + } | |
| 2738 | + ryDbbms.push(ryDbbm_group.join("-")); | |
| 2739 | + ryCids.push(ryCid_group.join("-")); | |
| 2740 | + ryDbbm_group = []; | |
| 2741 | + ryCid_group = []; | |
| 2742 | + } | |
| 2743 | + | |
| 2744 | + data_temp3[data_temp4].isstart = true; | |
| 2745 | + ryStart = data_temp4 + 1; | |
| 2746 | + | |
| 2747 | + // 更新内部model,用于外部验证 | |
| 2748 | + // 内部model的值暂时随意,以后再改 | |
| 2749 | + scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 2750 | + | |
| 2751 | + // 更新外部model字段 | |
| 2752 | + if ($dbbmrangename_attr) { | |
| 2753 | + console.log("dbbmrangename=" + ryDbbms.join(',')); | |
| 2754 | + eval("scope[ctrlAs].model" + "." + $dbbmrangename_attr + " = ryDbbms.join(',');"); | |
| 2755 | + } | |
| 2756 | + if (rycidrangename_attr) { | |
| 2757 | + console.log("rycidrangename=" + ryCids.join(',')); | |
| 2758 | + eval("scope[ctrlAs].model" + "." + rycidrangename_attr + " = ryCids.join(',');"); | |
| 2759 | + } | |
| 2760 | + if ($rystartname_attr) { | |
| 2761 | + console.log("rystartname=" + ryStart); | |
| 2762 | + eval("scope[ctrlAs].model" + "." + $rystartname_attr + " = ryStart;"); | |
| 2763 | + } | |
| 2764 | + | |
| 2765 | + } else { | |
| 2766 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 2767 | + } | |
| 2768 | + | |
| 2769 | + } else { | |
| 2770 | + if (data_temp && | |
| 2771 | + data_temp.length > 0 && | |
| 2772 | + data_temp2 != undefined) { | |
| 2773 | + | |
| 2774 | + for (i = 0; i < data_temp.length; i++) { | |
| 2775 | + ryDbbms.push(data_temp[i].dbbm); | |
| 2776 | + ryCids.push(data_temp[i].id); | |
| 2777 | + } | |
| 2778 | + data_temp[data_temp2].isstart = true; | |
| 2779 | + ryStart = data_temp2 + 1; | |
| 2780 | + | |
| 2781 | + // 更新内部model,用于外部验证 | |
| 2782 | + // 内部model的值暂时随意,以后再改 | |
| 2783 | + scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 2784 | + | |
| 2785 | + // 更新外部model字段 | |
| 2786 | + if ($dbbmrangename_attr) { | |
| 2787 | + console.log("dbbmrangename=" + ryDbbms.join(',')); | |
| 2788 | + eval("scope[ctrlAs].model" + "." + $dbbmrangename_attr + " = ryDbbms.join(',');"); | |
| 2789 | + } | |
| 2790 | + if (rycidrangename_attr) { | |
| 2791 | + console.log("rycidrangename=" + ryCids.join(',')); | |
| 2792 | + eval("scope[ctrlAs].model" + "." + rycidrangename_attr + " = ryCids.join(',');"); | |
| 2793 | + } | |
| 2794 | + if ($rystartname_attr) { | |
| 2795 | + console.log("rystartname=" + ryStart); | |
| 2796 | + eval("scope[ctrlAs].model" + "." + $rystartname_attr + " = ryStart;"); | |
| 2797 | + } | |
| 2798 | + | |
| 2799 | + } else { | |
| 2800 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 2801 | + } | |
| 2802 | + } | |
| 2803 | + | |
| 2804 | + }; | |
| 2805 | + | |
| 2806 | + // 监控内部数据,$$dataSelected 变化 | |
| 2807 | + scope.$watch( | |
| 2808 | + function() { | |
| 2809 | + return scope[ctrlAs].$$dataSelected; | |
| 2810 | + }, | |
| 2811 | + function(newValue, oldValue) { | |
| 2812 | + scope[ctrlAs].$$internal_validate_model(); | |
| 2813 | + }, | |
| 2814 | + true | |
| 2815 | + ); | |
| 2816 | + | |
| 2817 | + // 监控内部数据,$$dataSelectedStart 变化 | |
| 2818 | + scope.$watch( | |
| 2819 | + function() { | |
| 2820 | + return scope[ctrlAs].$$dataSelectedStart; | |
| 2821 | + }, | |
| 2822 | + function(newValue, oldValue) { | |
| 2823 | + scope[ctrlAs].$$internal_validate_model(); | |
| 2824 | + }, | |
| 2825 | + true | |
| 2826 | + ); | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + // 监控内部数据,$$dataFBSelected 变化 | |
| 2830 | + scope.$watch( | |
| 2831 | + function() { | |
| 2832 | + return scope[ctrlAs].$$dataFBSelected; | |
| 2833 | + }, | |
| 2834 | + function(newValue, oldValue) { | |
| 2835 | + scope[ctrlAs].$$internal_validate_model(); | |
| 2836 | + }, | |
| 2837 | + true | |
| 2838 | + ); | |
| 2839 | + | |
| 2840 | + // 监控内部数据,$$dataFBSelectedStart 变化 | |
| 2841 | + scope.$watch( | |
| 2842 | + function() { | |
| 2843 | + return scope[ctrlAs].$$dataFBSelectedStart; | |
| 2844 | + }, | |
| 2845 | + function(newValue, oldValue) { | |
| 2846 | + scope[ctrlAs].$$internal_validate_model(); | |
| 2847 | + }, | |
| 2848 | + true | |
| 2849 | + ); | |
| 2850 | + | |
| 2851 | + // 监控内部数据,$$dataFBInternalSelected 变化 | |
| 2852 | + scope.$watch( | |
| 2853 | + function() { | |
| 2854 | + return scope[ctrlAs].$$dataFBInternalSelected; | |
| 2855 | + }, | |
| 2856 | + function(newValue, oldValue) { | |
| 2857 | + scope[ctrlAs].$$internal_validate_model(); | |
| 2858 | + }, | |
| 2859 | + true | |
| 2860 | + ); | |
| 2861 | + | |
| 2862 | + // 监控内部数据,$$isFB 变化 | |
| 2863 | + scope.$watch( | |
| 2864 | + function() { | |
| 2865 | + return scope[ctrlAs].$$isFB; | |
| 2866 | + }, | |
| 2867 | + function(newValue, oldValue) { | |
| 2868 | + scope[ctrlAs].$$internal_validate_model(); | |
| 2869 | + }, | |
| 2870 | + true | |
| 2871 | + ); | |
| 2872 | + | |
| 2873 | + /** | |
| 2874 | + * 验证数据是否初始化完成, | |
| 2875 | + * 所谓的初始化就是内部所有的数据被有效设定过一次。 | |
| 2876 | + */ | |
| 2877 | + scope[ctrlAs].$$internal_validate_init = function() { | |
| 2878 | + var self = scope[ctrlAs]; | |
| 2879 | + var data_temp = self.$$data; | |
| 2880 | + var dataSelect_temp = self.$$dataSelected; | |
| 2881 | + var dataFBSelect_temp = self.$$dataFBSelected; | |
| 2882 | + var dbbmnames = null; | |
| 2883 | + var dbbmnamegroup = null; | |
| 2884 | + var rycids = null; | |
| 2885 | + var rycidgroup = null; | |
| 2886 | + | |
| 2887 | + var i = 0; | |
| 2888 | + var j = 0; | |
| 2889 | + var k = 0; | |
| 2890 | + | |
| 2891 | + if (self.$$data_xl_first_init && | |
| 2892 | + self.$$data_ry_first_init && | |
| 2893 | + self.$$data_rycid_first_init && | |
| 2894 | + self.$$data_rystart_first_init && !self.$$data_init) { | |
| 2895 | + console.log("开始初始化数据"); | |
| 2896 | + | |
| 2897 | + // 判定是否分班,字符串中包含-就是了 | |
| 2898 | + if (self.$$data_ry_first_data.indexOf("-") != -1 && dataFBSelect_temp.length == 0) { // 分班 | |
| 2899 | + self.$$isFB = true; | |
| 2900 | + | |
| 2901 | + // 搭班编码、人员配置id | |
| 2902 | + dbbmnames = self.$$data_ry_first_data.split(","); | |
| 2903 | + rycids = self.$$data_rycid_first_data.split(","); | |
| 2904 | + for (i = 0; i < dbbmnames.length; i++) { | |
| 2905 | + dataFBSelect_temp.push({ | |
| 2906 | + group: [], | |
| 2907 | + isstart: false | |
| 2908 | + }); | |
| 2909 | + dbbmnamegroup = dbbmnames[i].split("-"); | |
| 2910 | + rycidgroup = rycids[i].split("-"); | |
| 2911 | + | |
| 2912 | + for (k = 0; k < dbbmnamegroup.length; k++) { | |
| 2913 | + dataFBSelect_temp[i].group.push({ | |
| 2914 | + id: rycidgroup[k], | |
| 2915 | + dbbm: dbbmnamegroup[k], | |
| 2916 | + isselected: false | |
| 2917 | + }); | |
| 2918 | + | |
| 2919 | + for (j = 0; j < data_temp.length; j++) { | |
| 2920 | + if (dataFBSelect_temp[i].group[k].dbbm == data_temp[j].dbbm) { | |
| 2921 | + dataFBSelect_temp[i].group[k].jsy = data_temp[j].jsy; | |
| 2922 | + dataFBSelect_temp[i].group[k].spy = data_temp[j].spy; | |
| 2923 | + break; | |
| 2924 | + } | |
| 2925 | + } | |
| 2926 | + } | |
| 2927 | + | |
| 2928 | + } | |
| 2929 | + | |
| 2930 | + // 初始人员 | |
| 2931 | + scope[ctrlAs].$$dataFBSelectedStart = self.$$data_rystart_first_data - 1; | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + } else if (dataSelect_temp.length == 0) { | |
| 2935 | + self.$$isFB = false; | |
| 2936 | + | |
| 2937 | + // 搭班编码、人员配置id | |
| 2938 | + dbbmnames = self.$$data_ry_first_data.split(","); | |
| 2939 | + rycids = self.$$data_rycid_first_data.split(","); | |
| 2940 | + for (i = 0; i < dbbmnames.length; i++) { | |
| 2941 | + dataSelect_temp.push({ | |
| 2942 | + id: rycids[i], | |
| 2943 | + dbbm: dbbmnames[i], | |
| 2944 | + isstart: false | |
| 2945 | + }); | |
| 2946 | + for (j = 0; j < data_temp.length; j++) { | |
| 2947 | + if (dataSelect_temp[i].dbbm == data_temp[j].dbbm) { | |
| 2948 | + dataSelect_temp[i].jsy = data_temp[j].jsy; | |
| 2949 | + dataSelect_temp[i].spy = data_temp[j].spy; | |
| 2950 | + break; | |
| 2951 | + } | |
| 2952 | + } | |
| 2953 | + } | |
| 2954 | + // 初始人员 | |
| 2955 | + scope[ctrlAs].$$dataSelectedStart = self.$$data_rystart_first_data - 1; | |
| 2956 | + | |
| 2957 | + } | |
| 2958 | + | |
| 2959 | + console.log("数据初始化完毕!"); | |
| 2960 | + self.$$data_init = true; | |
| 2961 | + } | |
| 2962 | + | |
| 2963 | + }; | |
| 2964 | + | |
| 2965 | + // 监控初始化标志,线路,人员,起始人员 | |
| 2966 | + scope.$watch( | |
| 2967 | + function() { | |
| 2968 | + return scope[ctrlAs].$$data_xl_first_init; | |
| 2969 | + }, | |
| 2970 | + function(newValue, oldValue) { | |
| 2971 | + scope[ctrlAs].$$internal_validate_init(); | |
| 2972 | + } | |
| 2973 | + ); | |
| 2974 | + scope.$watch( | |
| 2975 | + function() { | |
| 2976 | + return scope[ctrlAs].$$data_ry_first_init; | |
| 2977 | + }, | |
| 2978 | + function(newValue, oldValue) { | |
| 2979 | + scope[ctrlAs].$$internal_validate_init(); | |
| 2980 | + } | |
| 2981 | + ); | |
| 2982 | + scope.$watch( | |
| 2983 | + function() { | |
| 2984 | + return scope[ctrlAs].$$data_rycid_first_init; | |
| 2985 | + }, | |
| 2986 | + function(newValue, oldValue) { | |
| 2987 | + scope[ctrlAs].$$internal_validate_init(); | |
| 2988 | + } | |
| 2989 | + ); | |
| 2990 | + scope.$watch( | |
| 2991 | + function() { | |
| 2992 | + return scope[ctrlAs].$$data_rystart_first_init; | |
| 2993 | + }, | |
| 2994 | + function(newValue, oldValue) { | |
| 2995 | + scope[ctrlAs].$$internal_validate_init(); | |
| 2996 | + } | |
| 2997 | + ); | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + // 监控线路id的变化 | |
| 3001 | + attr.$observe("xlidvalue", function(value) { | |
| 3002 | + if (value && value != "") { | |
| 3003 | + console.log("xlidvalue=" + value); | |
| 3004 | + | |
| 3005 | + employeeConfigService_g.rest.list( | |
| 3006 | + {"xl.id_eq": value, "isCancel_eq" : false, size: 100}, | |
| 3007 | + function(result) { | |
| 3008 | + // 获取值了 | |
| 3009 | + console.log("人员配置获取了"); | |
| 3010 | + | |
| 3011 | + scope[ctrlAs].$$data = []; | |
| 3012 | + for (var i = 0; i < result.content.length; i++) { | |
| 3013 | + scope[ctrlAs].$$data.push({ | |
| 3014 | + id: result.content[i].id, | |
| 3015 | + dbbm: result.content[i].dbbm, | |
| 3016 | + jsy: result.content[i].jsy.personnelName, | |
| 3017 | + spy: result.content[i].spy == null ? "" : result.content[i].spy.personnelName | |
| 3018 | + }); | |
| 3019 | + } | |
| 3020 | + if (scope[ctrlAs].$$data_init) { | |
| 3021 | + scope[ctrlAs].$$dataSelected = []; | |
| 3022 | + scope[ctrlAs].$$dataSelectedStart = undefined; | |
| 3023 | + | |
| 3024 | + scope[ctrlAs].$$dataFBSelected = []; | |
| 3025 | + scope[ctrlAs].$$dataFBInternalSelected = undefined; | |
| 3026 | + scope[ctrlAs].$$dataFBSelectedStart = undefined; | |
| 3027 | + | |
| 3028 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 3029 | + } | |
| 3030 | + scope[ctrlAs].$$data_xl_first_init = true; | |
| 3031 | + }, | |
| 3032 | + function(result) { | |
| 3033 | + | |
| 3034 | + } | |
| 3035 | + ); | |
| 3036 | + | |
| 3037 | + } | |
| 3038 | + }); | |
| 3039 | + | |
| 3040 | + // 监控搭班编码范围值的变化 | |
| 3041 | + attr.$observe("dbbmrangevalue", function(value) { | |
| 3042 | + if (value && value != "") { | |
| 3043 | + console.log("dbbmrangevalue变换了"); | |
| 3044 | + scope[ctrlAs].$$data_ry_first_init = true; | |
| 3045 | + scope[ctrlAs].$$data_ry_first_data = value; | |
| 3046 | + } | |
| 3047 | + }); | |
| 3048 | + | |
| 3049 | + // 监控人员配置id范围值的变化 | |
| 3050 | + attr.$observe("rycidrangevalue", function(value) { | |
| 3051 | + if (value && value != "") { | |
| 3052 | + console.log("rycidrangevalue变换了"); | |
| 3053 | + scope[ctrlAs].$$data_rycid_first_init = true; | |
| 3054 | + scope[ctrlAs].$$data_rycid_first_data = value; | |
| 3055 | + } | |
| 3056 | + }); | |
| 3057 | + | |
| 3058 | + // 监控起始人员的变化 | |
| 3059 | + attr.$observe("rystartvalue", function(value) { | |
| 3060 | + if (value && value != "") { | |
| 3061 | + console.log("rystartvalue变换了"); | |
| 3062 | + scope[ctrlAs].$$data_rystart_first_init = true; | |
| 3063 | + scope[ctrlAs].$$data_rystart_first_data = value; | |
| 3064 | + } | |
| 3065 | + }); | |
| 3066 | + | |
| 3067 | + } | |
| 3068 | + } | |
| 3069 | + | |
| 3070 | + } | |
| 3071 | + } | |
| 3072 | + } | |
| 3073 | +]); | |
| 3074 | + | |
| 3075 | + | |
| 3076 | +/** | |
| 3077 | + * saBcgroup指令,用于套跑界面中,从指定线路,指定时刻表,指定路牌的班次列表中选择套跑班次。 | |
| 3078 | + * 属性如下: | |
| 3079 | + * name(必须):控件的名字 | |
| 3080 | + * model(必须):指定一个外部object,独立作用域,如:model=ctrl.employeeInfoForSave | |
| 3081 | + * bcttinfoidsvalue(必须):绑定的model班次ids字段值,如:bcttinfoidsvalue={{ctrl.employeeInfoForSave.lprange}} | |
| 3082 | + * bcttinfoidsname(必须):bind的model班次ids字段名,如:bcttinfoidsname=lprange | |
| 3083 | + * dataparams (必须):内部数据关联的查询参数,如:{{ {'ttid': ctrl.rerunManageForSave.rerunTtinfo.id} | json }} | |
| 3084 | + * required(可选):是否要用required验证 | |
| 3085 | + * | |
| 3086 | + */ | |
| 3087 | +angular.module('ScheduleApp').directive('saBcgroup', [ | |
| 3088 | + 'TimeTableDetailManageService_g', | |
| 3089 | + function(timeTableDetailManageService_g) { | |
| 3090 | + return { | |
| 3091 | + restrict: 'E', | |
| 3092 | + templateUrl: '/pages/scheduleApp/module/common/dts2/bcGroup/saBcgroupTemplate.html', | |
| 3093 | + scope: { | |
| 3094 | + model: "=" // 独立作用域,关联外部的模型object | |
| 3095 | + }, | |
| 3096 | + controllerAs: '$saBcgroupCtrl', | |
| 3097 | + bindToController: true, | |
| 3098 | + controller: function($scope) { | |
| 3099 | + var self = this; | |
| 3100 | + self.$$data = []; // 选择线路,时刻表,路牌后的班次列表 | |
| 3101 | + | |
| 3102 | + // 测试数据 | |
| 3103 | + //self.$$data = [ | |
| 3104 | + // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'}, | |
| 3105 | + // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'}, | |
| 3106 | + // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'} | |
| 3107 | + //]; | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + self.$$dataSelected = []; // 套跑选中的班次列表 | |
| 3111 | + | |
| 3112 | + //self.$$dataSelected = [ | |
| 3113 | + // {bcttinfoid: 1, bcfcsj: '7:30', bctype: 'out'}, | |
| 3114 | + // {bcttinfoid: 2, bcfcsj: '8:30', bctype: 'normal'}, | |
| 3115 | + // {bcttinfoid: 3, bcfcsj: '9:30', bctype: 'in'} | |
| 3116 | + //]; | |
| 3117 | + | |
| 3118 | + // saBcgroup组件的ng-model,用于外部绑定等操作 | |
| 3119 | + self.$$internalmodel = undefined; | |
| 3120 | + | |
| 3121 | + self.$$data_bcdata_first_init = false; // 班次数据首次初始化标志 | |
| 3122 | + self.$$data_bcttinfoids_first_init = false; // 班次ids数据首次初始化标志 | |
| 3123 | + self.$$data_bcttinfoids_first_data = undefined; // 班次ids数据首次初始化数据 | |
| 3124 | + | |
| 3125 | + }, | |
| 3126 | + | |
| 3127 | + /** | |
| 3128 | + * 此阶段可以改dom结构,此时angular还没扫描指令, | |
| 3129 | + * 这里就可以动态添加其他angularjs的指令字符串,如required指令字符串。 | |
| 3130 | + * @param tElem | |
| 3131 | + * @param tAttrs | |
| 3132 | + * @returns {{pre: Function, post: Function}} | |
| 3133 | + */ | |
| 3134 | + compile: function(tElem, tAttrs) { | |
| 3135 | + // TODO:获取所有的属性 | |
| 3136 | + var $name_attr = tAttrs["name"]; // 控件的名字 | |
| 3137 | + var $required_attr = tAttrs["required"]; // 是否需要required验证 | |
| 3138 | + var $bcttinfoidsname_attr = tAttrs["bcttinfoidsname"]; // bind的model班次ids字段名 | |
| 3139 | + | |
| 3140 | + // controlAs名字 | |
| 3141 | + var ctrlAs = '$saBcgroupCtrl'; | |
| 3142 | + | |
| 3143 | + // 如果有required属性,添加angularjs required验证 | |
| 3144 | + if ($required_attr != undefined) { | |
| 3145 | + //console.log(tElem.html()); | |
| 3146 | + tElem.find("div").attr("required", ""); | |
| 3147 | + } | |
| 3148 | + | |
| 3149 | + return { | |
| 3150 | + pre: function(scope, element, attr) { | |
| 3151 | + // TODO: | |
| 3152 | + }, | |
| 3153 | + | |
| 3154 | + /** | |
| 3155 | + * 相当于link函数。 | |
| 3156 | + * @param scope | |
| 3157 | + * @param element | |
| 3158 | + * @param attr | |
| 3159 | + */ | |
| 3160 | + post: function(scope, element, attr) { | |
| 3161 | + // name属性 | |
| 3162 | + if ($name_attr) { | |
| 3163 | + scope[ctrlAs]["$name_attr"] = $name_attr; | |
| 3164 | + } | |
| 3165 | + | |
| 3166 | + // TODO: | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + /** | |
| 3170 | + * 班次列表点击(班次列表中选中班次) | |
| 3171 | + * @param $index | |
| 3172 | + */ | |
| 3173 | + scope[ctrlAs].$$internal_bclist_click = function($index) { | |
| 3174 | + var data_temp = scope[ctrlAs].$$data; | |
| 3175 | + var data_temp2 = scope[ctrlAs].$$dataSelected; | |
| 3176 | + var i = 0; | |
| 3177 | + var isunique = true; // 是否已经选择过 | |
| 3178 | + if (data_temp && data_temp.length > $index) { | |
| 3179 | + for (i = 0; i < data_temp2.length; i++) { | |
| 3180 | + if (data_temp2[i].bcttinfoid == data_temp[$index].bcttinfoid) { | |
| 3181 | + isunique = false; | |
| 3182 | + break; | |
| 3183 | + } | |
| 3184 | + } | |
| 3185 | + if (isunique) { | |
| 3186 | + data_temp2.push({ | |
| 3187 | + bcttinfoid: data_temp[$index].bcttinfoid, | |
| 3188 | + bcfcsj: data_temp[$index].bcfcsj, | |
| 3189 | + bctype: data_temp[$index].bctype | |
| 3190 | + }); | |
| 3191 | + } | |
| 3192 | + | |
| 3193 | + } | |
| 3194 | + }; | |
| 3195 | + /** | |
| 3196 | + * 选中的班次双击(删除选中的班次) | |
| 3197 | + * @param $index | |
| 3198 | + */ | |
| 3199 | + scope[ctrlAs].$$internal_selbclist_dbclick = function($index) { | |
| 3200 | + var data_temp = scope[ctrlAs].$$dataSelected; | |
| 3201 | + if (data_temp && data_temp.length > $index) { | |
| 3202 | + data_temp.splice($index, 1); | |
| 3203 | + } | |
| 3204 | + }; | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + /** | |
| 3208 | + * 验证内部数据,更新外部model | |
| 3209 | + */ | |
| 3210 | + scope[ctrlAs].$$internal_validate_model = function() { | |
| 3211 | + var data_temp = scope[ctrlAs].$$dataSelected; | |
| 3212 | + var bcttinfoIds = []; | |
| 3213 | + var i = 0; | |
| 3214 | + | |
| 3215 | + if (data_temp && | |
| 3216 | + data_temp.length > 0) { | |
| 3217 | + | |
| 3218 | + for (i = 0; i < data_temp.length; i++) { | |
| 3219 | + bcttinfoIds.push(data_temp[i].bcttinfoid); | |
| 3220 | + } | |
| 3221 | + | |
| 3222 | + // 更新外部model字段 | |
| 3223 | + if ($bcttinfoidsname_attr) { | |
| 3224 | + console.log("bcttinfoidsname=" + bcttinfoIds.join(',')); | |
| 3225 | + eval("scope[ctrlAs].model" + "." + $bcttinfoidsname_attr + " = bcttinfoIds.join(',');"); | |
| 3226 | + } | |
| 3227 | + | |
| 3228 | + // 更新内部model,用于外部验证 | |
| 3229 | + // 内部model的值暂时随意,以后再改 | |
| 3230 | + scope[ctrlAs].$$internalmodel = {desc: "ok"}; | |
| 3231 | + | |
| 3232 | + scope[ctrlAs].$$data_bcdata_first_init = true; | |
| 3233 | + scope[ctrlAs].$$data_bcttinfoids_first_init = true; | |
| 3234 | + | |
| 3235 | + } else { | |
| 3236 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 3237 | + } | |
| 3238 | + | |
| 3239 | + }; | |
| 3240 | + | |
| 3241 | + // 监控内部数据,$$data_selected 变化 | |
| 3242 | + scope.$watch( | |
| 3243 | + function() { | |
| 3244 | + console.log("长度:" + scope[ctrlAs].$$dataSelected.length); | |
| 3245 | + return scope[ctrlAs].$$dataSelected; | |
| 3246 | + }, | |
| 3247 | + function(newValue, oldValue) { | |
| 3248 | + scope[ctrlAs].$$internal_validate_model(); | |
| 3249 | + }, | |
| 3250 | + true | |
| 3251 | + ); | |
| 3252 | + | |
| 3253 | + /** | |
| 3254 | + * 验证数据是否初始化完成, | |
| 3255 | + * 所谓的初始化就是内部所有的数据被有效设定过一次。 | |
| 3256 | + */ | |
| 3257 | + scope[ctrlAs].$$internal_validate_init = function() { | |
| 3258 | + var self = scope[ctrlAs]; | |
| 3259 | + | |
| 3260 | + var data_temp = self.$$data; | |
| 3261 | + var dataSelect_temp = self.$$dataSelected; | |
| 3262 | + var bcttinfoids = null; | |
| 3263 | + | |
| 3264 | + var i = 0; | |
| 3265 | + var j = 0; | |
| 3266 | + | |
| 3267 | + if (self.$$data_bcdata_first_init && | |
| 3268 | + self.$$data_bcttinfoids_first_init) { | |
| 3269 | + console.log("开始初始化数据"); | |
| 3270 | + | |
| 3271 | + bcttinfoids = self.$$data_bcttinfoids_first_data ? self.$$data_bcttinfoids_first_data.split(",") : []; | |
| 3272 | + | |
| 3273 | + for (i = 0; i < bcttinfoids.length; i++) { | |
| 3274 | + dataSelect_temp.push({ | |
| 3275 | + bcttinfoid: bcttinfoids[i] | |
| 3276 | + }); | |
| 3277 | + for (j = 0; j < data_temp.length; j++) { | |
| 3278 | + if (dataSelect_temp[i].bcttinfoid == data_temp[j].bcttinfoid) { | |
| 3279 | + dataSelect_temp[i].bcfcsj = data_temp[j].bcfcsj; | |
| 3280 | + dataSelect_temp[i].bctype = data_temp[j].bctype; | |
| 3281 | + break; | |
| 3282 | + } | |
| 3283 | + } | |
| 3284 | + } | |
| 3285 | + | |
| 3286 | + console.log("数据初始化完毕!"); | |
| 3287 | + } | |
| 3288 | + | |
| 3289 | + }; | |
| 3290 | + | |
| 3291 | + // 监控初始化标志 | |
| 3292 | + scope.$watch( | |
| 3293 | + function() { | |
| 3294 | + return scope[ctrlAs].$$data_bcdata_first_init; | |
| 3295 | + }, | |
| 3296 | + function(newValue, oldValue) { | |
| 3297 | + scope[ctrlAs].$$internal_validate_init(); | |
| 3298 | + } | |
| 3299 | + ); | |
| 3300 | + scope.$watch( | |
| 3301 | + function() { | |
| 3302 | + return scope[ctrlAs].$$data_bcttinfoids_first_init; | |
| 3303 | + }, | |
| 3304 | + function(newValue, oldValue) { | |
| 3305 | + scope[ctrlAs].$$internal_validate_init(); | |
| 3306 | + } | |
| 3307 | + ); | |
| 3308 | + | |
| 3309 | + // 监控内部数据的变化 | |
| 3310 | + attr.$observe("dataparams", function(value) { | |
| 3311 | + if (value && value != "") { | |
| 3312 | + if (value == '{}') { | |
| 3313 | + return; | |
| 3314 | + } | |
| 3315 | + | |
| 3316 | + console.log("bcgroup observe 监控 dataparams=" + value); | |
| 3317 | + | |
| 3318 | + timeTableDetailManageService_g.bcdetails.list( | |
| 3319 | + JSON.parse(value), | |
| 3320 | + function(result) { | |
| 3321 | + // 获取值了 | |
| 3322 | + console.log("内部班次数据获取了"); | |
| 3323 | + | |
| 3324 | + scope[ctrlAs].$$data = []; | |
| 3325 | + for (var i = 0; i < result.length; i++) { | |
| 3326 | + scope[ctrlAs].$$data.push({ | |
| 3327 | + bcttinfoid: result[i].id, | |
| 3328 | + bcfcsj: result[i].fcsj, | |
| 3329 | + bctype: result[i].bcType | |
| 3330 | + }); | |
| 3331 | + } | |
| 3332 | + if (scope[ctrlAs].$$data_bcdata_first_init && | |
| 3333 | + scope[ctrlAs].$$data_bcttinfoids_first_init) { | |
| 3334 | + | |
| 3335 | + scope[ctrlAs].$$dataSelected = []; | |
| 3336 | + scope[ctrlAs].$$internalmodel = undefined; | |
| 3337 | + } | |
| 3338 | + scope[ctrlAs].$$data_bcdata_first_init = true; | |
| 3339 | + }, | |
| 3340 | + function(result) { | |
| 3341 | + | |
| 3342 | + } | |
| 3343 | + ); | |
| 3344 | + } | |
| 3345 | + }); | |
| 3346 | + // 监控班次ids数据的变化 | |
| 3347 | + attr.$observe("bcttinfoidsvalue", function(value) { | |
| 3348 | + if (value && value != "") { | |
| 3349 | + console.log("observe 监控 bcttinfoidsvalue=" + value); | |
| 3350 | + scope[ctrlAs].$$data_bcttinfoids_first_init = true; | |
| 3351 | + scope[ctrlAs].$$data_bcttinfoids_first_data = value; | |
| 3352 | + } | |
| 3353 | + }); | |
| 3354 | + | |
| 3355 | + } | |
| 3356 | + } | |
| 3357 | + | |
| 3358 | + } | |
| 3359 | + } | |
| 3360 | + } | |
| 3240 | 3361 | ]); |
| 3241 | 3362 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/scheduleApp/module/common/prj-common-globalservice.js
| ... | ... | @@ -339,7 +339,7 @@ angular.module('ScheduleApp').factory('TimeTableManageService_g', ['$resource', |
| 339 | 339 | return { |
| 340 | 340 | rest: $resource( |
| 341 | 341 | '/tic/:id', |
| 342 | - {order: 'xl,isCancel,isEnableDisTemplate,qyrq', direction: 'DESC,ASC,DESC,DESC', id: '@id_route'}, | |
| 342 | + {order: 'xl,isCancel,isEnableDisTemplate,qyrq', direction: 'DESC,ASC,DESC,DESC', id: '@id'}, | |
| 343 | 343 | { |
| 344 | 344 | list: { |
| 345 | 345 | method: 'GET', |
| ... | ... | @@ -366,6 +366,25 @@ angular.module('ScheduleApp').factory('TimeTableDetailManageService_g', ['$resou |
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | ), |
| 369 | + import: $resource( | |
| 370 | + '/tidc/importfile', | |
| 371 | + {}, | |
| 372 | + { | |
| 373 | + do: { | |
| 374 | + method: 'POST', | |
| 375 | + headers: { | |
| 376 | + 'Content-Type': 'application/x-www-form-urlencoded' | |
| 377 | + }, | |
| 378 | + transformRequest: function(obj) { | |
| 379 | + var str = []; | |
| 380 | + for (var p in obj) { | |
| 381 | + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); | |
| 382 | + } | |
| 383 | + return str.join("&"); | |
| 384 | + } | |
| 385 | + } | |
| 386 | + } | |
| 387 | + ), | |
| 369 | 388 | edit: $resource( |
| 370 | 389 | '/tidc/edit/:xlid/:ttid', |
| 371 | 390 | {}, |
| ... | ... | @@ -385,6 +404,8 @@ angular.module('ScheduleApp').factory('TimeTableDetailManageService_g', ['$resou |
| 385 | 404 | } |
| 386 | 405 | } |
| 387 | 406 | ) |
| 407 | + | |
| 408 | + // TODO:导入数据 | |
| 388 | 409 | }; |
| 389 | 410 | }]); |
| 390 | 411 | |
| ... | ... | @@ -519,6 +540,16 @@ angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', fun |
| 519 | 540 | } |
| 520 | 541 | } |
| 521 | 542 | ), |
| 543 | + xlinfo: $resource( | |
| 544 | + '/lineInformation/:type', | |
| 545 | + {order: 'line.name', direction: 'ASC'}, | |
| 546 | + { | |
| 547 | + list: { | |
| 548 | + method: 'GET', | |
| 549 | + isArray: true | |
| 550 | + } | |
| 551 | + } | |
| 552 | + ), | |
| 522 | 553 | zd: $resource( |
| 523 | 554 | '/stationroute/stations', |
| 524 | 555 | {order: 'stationCode', direction: 'ASC'}, |
| ... | ... | @@ -689,6 +720,40 @@ angular.module('ScheduleApp').factory('$$SearchInfoService_g', ['$resource', fun |
| 689 | 720 | } |
| 690 | 721 | } |
| 691 | 722 | ) |
| 723 | + }, | |
| 724 | + sheet: { // 时刻表sheet工作区验证 | |
| 725 | + template: {'filename': '', 'sheetname': '', 'lineid': -1, 'linename': ''}, | |
| 726 | + remote: $resource( // $resource封装对象 | |
| 727 | + '/tidc/validate/sheet', | |
| 728 | + {}, | |
| 729 | + { | |
| 730 | + do: { | |
| 731 | + method: 'POST', | |
| 732 | + headers: { | |
| 733 | + 'Content-Type': 'application/x-www-form-urlencoded' | |
| 734 | + }, | |
| 735 | + transformRequest: function(obj) { | |
| 736 | + var str = []; | |
| 737 | + for (var p in obj) { | |
| 738 | + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); | |
| 739 | + } | |
| 740 | + return str.join("&"); | |
| 741 | + } | |
| 742 | + } | |
| 743 | + } | |
| 744 | + ) | |
| 745 | + }, | |
| 746 | + sheetli: { // 时刻表线路标准验证 | |
| 747 | + template: {'lineinfoid': -1}, | |
| 748 | + remote: $resource( // $resource封装对象 | |
| 749 | + '/tidc/validate/lineinfo', | |
| 750 | + {}, | |
| 751 | + { | |
| 752 | + do: { | |
| 753 | + method: 'GET' | |
| 754 | + } | |
| 755 | + } | |
| 756 | + ) | |
| 692 | 757 | } |
| 693 | 758 | } |
| 694 | 759 | ... | ... |
src/main/resources/static/pages/scheduleApp/module/common/prj-common-ui-route-state.js
| ... | ... | @@ -585,6 +585,164 @@ ScheduleApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvi |
| 585 | 585 | } |
| 586 | 586 | }) |
| 587 | 587 | |
| 588 | + // 时刻表管理(新版本) | |
| 589 | + .state("ttInfoManage", { // 时刻表基础信息界面 | |
| 590 | + url: '/ttInfoManage', | |
| 591 | + views: { | |
| 592 | + "": { | |
| 593 | + templateUrl: 'pages/scheduleApp/module/core/ttInfoManage/index.html' | |
| 594 | + }, | |
| 595 | + "ttInfoManage_list@ttInfoManage": { | |
| 596 | + templateUrl: 'pages/scheduleApp/module/core/ttInfoManage/list.html' | |
| 597 | + } | |
| 598 | + }, | |
| 599 | + | |
| 600 | + resolve: { | |
| 601 | + deps: ['$ocLazyLoad', function($ocLazyLoad) { | |
| 602 | + return $ocLazyLoad.load({ | |
| 603 | + name: 'ttInfoManage_module', | |
| 604 | + insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置 | |
| 605 | + files: [ | |
| 606 | + "assets/bower_components/angular-ui-select/dist/select.min.css", | |
| 607 | + "assets/bower_components/angular-ui-select/dist/select.min.js", | |
| 608 | + "pages/scheduleApp/module/core/ttInfoManage/main.js" | |
| 609 | + ] | |
| 610 | + }); | |
| 611 | + }] | |
| 612 | + } | |
| 613 | + }) | |
| 614 | + .state("ttInfoManage_form", { | |
| 615 | + url: '/ttInfoManage_form', | |
| 616 | + views: { | |
| 617 | + "": {templateUrl: 'pages/scheduleApp/module/core/ttInfoManage/form.html'} | |
| 618 | + }, | |
| 619 | + resolve: { | |
| 620 | + deps: ['$ocLazyLoad', function($ocLazyLoad) { | |
| 621 | + return $ocLazyLoad.load({ | |
| 622 | + name: 'ttInfoManage_form_module', | |
| 623 | + insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置 | |
| 624 | + files: [ | |
| 625 | + "assets/bower_components/angular-ui-select/dist/select.min.css", | |
| 626 | + "assets/bower_components/angular-ui-select/dist/select.min.js", | |
| 627 | + "pages/scheduleApp/module/core/ttInfoManage/main.js" | |
| 628 | + ] | |
| 629 | + }); | |
| 630 | + }] | |
| 631 | + } | |
| 632 | + }) | |
| 633 | + .state("ttInfoManage_edit", { | |
| 634 | + url: '/ttInfoManage_edit/:id', | |
| 635 | + views: { | |
| 636 | + "": {templateUrl: 'pages/scheduleApp/module/core/ttInfoManage/edit.html'} | |
| 637 | + }, | |
| 638 | + resolve: { | |
| 639 | + deps: ['$ocLazyLoad', function($ocLazyLoad) { | |
| 640 | + return $ocLazyLoad.load({ | |
| 641 | + name: 'ttInfoManage_edit_module', | |
| 642 | + insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置 | |
| 643 | + files: [ | |
| 644 | + "assets/bower_components/angular-ui-select/dist/select.min.css", | |
| 645 | + "assets/bower_components/angular-ui-select/dist/select.min.js", | |
| 646 | + "pages/scheduleApp/module/core/ttInfoManage/main.js" | |
| 647 | + ] | |
| 648 | + }); | |
| 649 | + }] | |
| 650 | + } | |
| 651 | + }) | |
| 652 | + .state("ttInfoManage_detail", { | |
| 653 | + url: '/ttInfoManage_detail/:id', | |
| 654 | + views: { | |
| 655 | + "": {templateUrl: 'pages/scheduleApp/module/core/ttInfoManage/detail.html'} | |
| 656 | + }, | |
| 657 | + resolve: { | |
| 658 | + deps: ['$ocLazyLoad', function($ocLazyLoad) { | |
| 659 | + return $ocLazyLoad.load({ | |
| 660 | + name: 'ttInfoManage_detail_module', | |
| 661 | + insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置 | |
| 662 | + files: [ | |
| 663 | + "pages/scheduleApp/module/core/ttInfoManage/main.js" | |
| 664 | + ] | |
| 665 | + }); | |
| 666 | + }] | |
| 667 | + } | |
| 668 | + }) | |
| 669 | + .state("ttInfoDetailManage_form", { | |
| 670 | + url: '/ttInfoDetailManage_form/:xlid/:ttid/:xlname/:ttname', | |
| 671 | + views: { | |
| 672 | + "": {templateUrl: 'pages/scheduleApp/module/core/ttInfoDetailManage/form.html'} | |
| 673 | + }, | |
| 674 | + resolve: { | |
| 675 | + deps: ['$ocLazyLoad', function($ocLazyLoad) { | |
| 676 | + return $ocLazyLoad.load({ | |
| 677 | + name: 'ttInfoDetailManage_form_module', | |
| 678 | + insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置 | |
| 679 | + files: [ | |
| 680 | + "assets/bower_components/angular-ui-select/dist/select.min.css", | |
| 681 | + "assets/bower_components/angular-ui-select/dist/select.min.js", | |
| 682 | + "assets/bower_components/angular-file-upload/dist/angular-file-upload.min.js", | |
| 683 | + "pages/scheduleApp/module/core/ttInfoDetailManage/main.js" | |
| 684 | + ] | |
| 685 | + }); | |
| 686 | + }] | |
| 687 | + } | |
| 688 | + }) | |
| 689 | + .state("ttInfoDetailManage_edit", { | |
| 690 | + url: '/ttInfoDetailManage_edit/:xlid/:ttid/:xlname/:ttname', | |
| 691 | + views: { | |
| 692 | + "": {templateUrl: 'pages/scheduleApp/module/core/ttInfoDetailManage/edit.html'} | |
| 693 | + }, | |
| 694 | + resolve: { | |
| 695 | + deps: ['$ocLazyLoad', function($ocLazyLoad) { | |
| 696 | + return $ocLazyLoad.load({ | |
| 697 | + name: 'ttInfoDetailManage_edit_module', | |
| 698 | + insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置 | |
| 699 | + files: [ | |
| 700 | + "pages/scheduleApp/module/core/ttInfoDetailManage/timeTableDetailManage_old.js" | |
| 701 | + ] | |
| 702 | + }); | |
| 703 | + }] | |
| 704 | + } | |
| 705 | + }) | |
| 706 | + .state("ttInfoDetailManage_detail_edit", { | |
| 707 | + url: '/ttInfoDetailManage_detail_edit/:id/:xlid/:ttid/:xlname/:ttname', | |
| 708 | + views: { | |
| 709 | + "": {templateUrl: 'pages/scheduleApp/module/core/ttInfoDetailManage/edit-detail.html'} | |
| 710 | + }, | |
| 711 | + resolve: { | |
| 712 | + deps: ['$ocLazyLoad', function($ocLazyLoad) { | |
| 713 | + return $ocLazyLoad.load({ | |
| 714 | + name: 'ttInfoDetailManage_detail_edit_module', | |
| 715 | + insertBefore: '#ng_load_plugins_before', // 动态载入模块时放置的位置 | |
| 716 | + files: [ | |
| 717 | + "assets/bower_components/angular-ui-select/dist/select.min.css", | |
| 718 | + "assets/bower_components/angular-ui-select/dist/select.min.js", | |
| 719 | + "pages/scheduleApp/module/core/ttInfoDetailManage/timeTableDetailManage_old.js" | |
| 720 | + ] | |
| 721 | + }); | |
| 722 | + }] | |
| 723 | + } | |
| 724 | + }) | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 588 | 746 | // 排班规则管理模块 |
| 589 | 747 | .state("scheduleRuleManage", { |
| 590 | 748 | url: '/scheduleRuleManage', | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/busConfig/list.html
| ... | ... | @@ -69,10 +69,10 @@ |
| 69 | 69 | <td> |
| 70 | 70 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 71 | 71 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 72 | - <a ui-sref="busConfig_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | |
| 73 | - <a ui-sref="busConfig_edit({id: info.id})" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | |
| 74 | - <a ng-click="ctrl.deleteEci(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | |
| 75 | - <a ng-click="ctrl.redoDeleteEci(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | |
| 72 | + <a ui-sref="busConfig_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a> | |
| 73 | + <a ui-sref="busConfig_edit({id: info.id})" class="btn btn-info btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | |
| 74 | + <a ng-click="ctrl.deleteEci(info.id)" class="btn btn-danger btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | |
| 75 | + <a ng-click="ctrl.redoDeleteEci(info.id)" class="btn btn-success btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | |
| 76 | 76 | </td> |
| 77 | 77 | </tr> |
| 78 | 78 | </tbody> | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/employeeConfig/list.html
| ... | ... | @@ -82,10 +82,10 @@ |
| 82 | 82 | <td> |
| 83 | 83 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 84 | 84 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 85 | - <a ui-sref="employeeConfig_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | |
| 86 | - <a ui-sref="employeeConfig_edit({id: info.id})" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | |
| 87 | - <a ng-click="ctrl.deleteEci(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | |
| 88 | - <a ng-click="ctrl.redoDeleteEci(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | |
| 85 | + <a ui-sref="employeeConfig_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a> | |
| 86 | + <a ui-sref="employeeConfig_edit({id: info.id})" class="btn btn-info btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | |
| 87 | + <a ng-click="ctrl.deleteEci(info.id)" class="btn btn-danger btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | |
| 88 | + <a ng-click="ctrl.redoDeleteEci(info.id)" class="btn btn-success btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | |
| 89 | 89 | </td> |
| 90 | 90 | </tr> |
| 91 | 91 | </tbody> | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/rerunManage/list.html
| ... | ... | @@ -74,10 +74,10 @@ |
| 74 | 74 | <td> |
| 75 | 75 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 76 | 76 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 77 | - <a ui-sref="rerunManage_detail({id : info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | |
| 78 | - <a ui-sref="rerunManage_edit({id : info.id})" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | |
| 79 | - <a ng-click="ctrl.toggleRerun(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | |
| 80 | - <a ng-click="ctrl.toggleRerun(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | |
| 77 | + <a ui-sref="rerunManage_detail({id : info.id})" class="btn btn-info btn-sm"> 详细 </a> | |
| 78 | + <a ui-sref="rerunManage_edit({id : info.id})" class="btn btn-info btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | |
| 79 | + <a ng-click="ctrl.toggleRerun(info.id)" class="btn btn-danger btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | |
| 80 | + <a ng-click="ctrl.toggleRerun(info.id)" class="btn btn-success btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | |
| 81 | 81 | </td> |
| 82 | 82 | </tr> |
| 83 | 83 | </tbody> | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/list.html
| ... | ... | @@ -74,17 +74,17 @@ |
| 74 | 74 | </td> |
| 75 | 75 | <td> |
| 76 | 76 | <a ui-sref="timeTableDetailInfoManage({xlid: info.xl.id, ttid : info.id, xlname: info.xl.name, ttname : info.name})" |
| 77 | - class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 编辑 </a> | |
| 78 | - <a ng-click="ctrl.importData($index)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 导入 </a> | |
| 79 | - <a href="javascript:" class="btn default blue-stripe btn-sm"> 导出 </a> | |
| 77 | + class="btn btn-info btn-sm" ng-if="info.isCancel == '0'"> 编辑 </a> | |
| 78 | + <a ng-click="ctrl.importData($index)" class="btn btn-info btn-sm" ng-if="info.isCancel == '0'"> 导入 </a> | |
| 79 | + <a href="javascript:" class="btn btn-info btn-sm"> 导出 </a> | |
| 80 | 80 | </td> |
| 81 | 81 | <td> |
| 82 | 82 | <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> |
| 83 | 83 | <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> |
| 84 | - <a ui-sref="timeTableManage_detail({id: info.id})" class="btn default blue-stripe btn-sm"> 详细 </a> | |
| 85 | - <a ui-sref="timeTableManage_edit({id: info.id})" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | |
| 86 | - <a ng-click="ctrl.toggleTtinfo(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | |
| 87 | - <a ng-click="ctrl.toggleTtinfo(info.id)" class="btn default blue-stripe btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | |
| 84 | + <a ui-sref="timeTableManage_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a> | |
| 85 | + <a ui-sref="timeTableManage_edit({id: info.id})" class="btn btn-info btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | |
| 86 | + <a ng-click="ctrl.toggleTtinfo(info.id)" class="btn btn-danger btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | |
| 87 | + <a ng-click="ctrl.toggleTtinfo(info.id)" class="btn btn-success btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | |
| 88 | 88 | </td> |
| 89 | 89 | </tr> |
| 90 | 90 | </tbody> | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/timeTableManage/timeTableManage2.js deleted
100644 → 0
| 1 | -// 时刻表管理 service controller 等写在一起 | |
| 2 | -angular.module('ScheduleApp').factory('TimeTableManageService', ['TimeTableManageService_g', function(service) { | |
| 3 | - /** 当前的查询条件信息 */ | |
| 4 | - var currentSearchCondition = {}; | |
| 5 | - | |
| 6 | - /** 当前第几页 */ | |
| 7 | - var currentPageNo = 1; | |
| 8 | - | |
| 9 | - return { | |
| 10 | - /** | |
| 11 | - * 获取查询条件信息, | |
| 12 | - * 用于给controller用来和页面数据绑定。 | |
| 13 | - */ | |
| 14 | - getSearchCondition: function() { | |
| 15 | - return currentSearchCondition; | |
| 16 | - }, | |
| 17 | - /** | |
| 18 | - * 重置查询条件信息。 | |
| 19 | - */ | |
| 20 | - resetSearchCondition: function() { | |
| 21 | - var key; | |
| 22 | - for (key in currentSearchCondition) { | |
| 23 | - currentSearchCondition[key] = undefined; | |
| 24 | - } | |
| 25 | - }, | |
| 26 | - /** | |
| 27 | - * 设置当前页码。 | |
| 28 | - * @param cpn 从1开始,后台是从0开始的 | |
| 29 | - */ | |
| 30 | - setCurrentPageNo: function(cpn) { | |
| 31 | - currentPageNo = cpn; | |
| 32 | - }, | |
| 33 | - /** | |
| 34 | - * 组装查询参数,返回一个promise查询结果。 | |
| 35 | - * @param params 查询参数 | |
| 36 | - * @return 返回一个 promise | |
| 37 | - */ | |
| 38 | - getPage: function() { | |
| 39 | - var params = currentSearchCondition; // 查询条件 | |
| 40 | - params.page = currentPageNo - 1; // 服务端页码从0开始 | |
| 41 | - return service.rest.list(params).$promise; | |
| 42 | - }, | |
| 43 | - /** | |
| 44 | - * 获取明细信息。 | |
| 45 | - * @param id 车辆id | |
| 46 | - * @return 返回一个 promise | |
| 47 | - */ | |
| 48 | - getDetail: function(id) { | |
| 49 | - var params = {id: id}; | |
| 50 | - return service.rest.get(params).$promise; | |
| 51 | - }, | |
| 52 | - /** | |
| 53 | - * 保存信息。 | |
| 54 | - * @param obj 车辆详细信息 | |
| 55 | - * @return 返回一个 promise | |
| 56 | - */ | |
| 57 | - saveDetail: function(obj) { | |
| 58 | - return service.rest.save(obj).$promise; | |
| 59 | - }, | |
| 60 | - /** | |
| 61 | - * 删除信息。 | |
| 62 | - * @param id 主键id | |
| 63 | - * @returns {*|Function|promise|n} | |
| 64 | - */ | |
| 65 | - deleteDetail: function(id) { | |
| 66 | - return service.rest.delete({id: id}).$promise; | |
| 67 | - } | |
| 68 | - }; | |
| 69 | - | |
| 70 | -}]); | |
| 71 | - | |
| 72 | -angular.module('ScheduleApp').controller('TimeTableManageCtrl', ['TimeTableManageService', '$state', '$uibModal', function(timeTableManageService, $state, $uibModal) { | |
| 73 | - var self = this; | |
| 74 | - | |
| 75 | - // 切换到form状态 | |
| 76 | - self.goForm = function() { | |
| 77 | - //alert("切换"); | |
| 78 | - $state.go("timeTableManage_form"); | |
| 79 | - }; | |
| 80 | - | |
| 81 | - // 导入excel | |
| 82 | - self.importData = function() { | |
| 83 | - // large方式弹出模态对话框 | |
| 84 | - var modalInstance = $uibModal.open({ | |
| 85 | - templateUrl: '/pages/scheduleApp/module/core/timeTableManage/dataImport.html', | |
| 86 | - size: "lg", | |
| 87 | - animation: true, | |
| 88 | - backdrop: 'static', | |
| 89 | - resolve: { | |
| 90 | - // 可以传值给controller | |
| 91 | - }, | |
| 92 | - windowClass: 'center-modal', | |
| 93 | - controller: "TimeTableManageToolsCtrl", | |
| 94 | - controllerAs: "ctrl", | |
| 95 | - bindToController: true | |
| 96 | - }); | |
| 97 | - modalInstance.result.then( | |
| 98 | - function() { | |
| 99 | - console.log("dataImport.html打开"); | |
| 100 | - }, | |
| 101 | - function() { | |
| 102 | - console.log("dataImport.html消失"); | |
| 103 | - } | |
| 104 | - ); | |
| 105 | - }; | |
| 106 | -}]); | |
| 107 | - | |
| 108 | -angular.module('ScheduleApp').controller('TimeTableManageToolsCtrl', ['$modalInstance', 'FileUploader', function($modalInstance, FileUploader) { | |
| 109 | - var self = this; | |
| 110 | - self.data = "TODO"; | |
| 111 | - | |
| 112 | - // 关闭窗口 | |
| 113 | - self.close = function() { | |
| 114 | - $modalInstance.dismiss("cancel"); | |
| 115 | - }; | |
| 116 | - | |
| 117 | - self.clearInputFile = function() { | |
| 118 | - angular.element("input[type='file']").val(null); | |
| 119 | - }; | |
| 120 | - | |
| 121 | - // 上传文件组件 | |
| 122 | - self.uploader = new FileUploader({ | |
| 123 | - url: "/tic/dataImport", | |
| 124 | - filters: [] // 用于过滤文件,比如只允许导入excel | |
| 125 | - }); | |
| 126 | - self.uploader.onAfterAddingFile = function(fileItem) | |
| 127 | - { | |
| 128 | - console.info('onAfterAddingFile', fileItem); | |
| 129 | - console.log(self.uploader.queue.length); | |
| 130 | - if (self.uploader.queue.length > 1) | |
| 131 | - self.uploader.removeFromQueue(0); | |
| 132 | - }; | |
| 133 | - self.uploader.onSuccessItem = function(fileItem, response, status, headers) | |
| 134 | - { | |
| 135 | - console.info('onSuccessItem', fileItem, response, status, headers); | |
| 136 | - }; | |
| 137 | - self.uploader.onErrorItem = function(fileItem, response, status, headers) | |
| 138 | - { | |
| 139 | - console.info('onErrorItem', fileItem, response, status, headers); | |
| 140 | - }; | |
| 141 | - | |
| 142 | -}]); | |
| 143 | - | |
| 144 | -angular.module('ScheduleApp').controller('TimeTableManageListCtrl', ['TimeTableManageService', '$uibModal', function(timeTableManageService, $uibModal) { | |
| 145 | - var self = this; | |
| 146 | - self.pageInfo = { | |
| 147 | - totalItems : 0, | |
| 148 | - currentPage : 1, | |
| 149 | - infos: [] | |
| 150 | - }; | |
| 151 | - | |
| 152 | - // 初始创建的时候,获取一次列表数据 | |
| 153 | - timeTableManageService.getPage().then( | |
| 154 | - function(result) { | |
| 155 | - self.pageInfo.totalItems = result.totalElements; | |
| 156 | - self.pageInfo.currentPage = result.number + 1; | |
| 157 | - self.pageInfo.infos = result.content; | |
| 158 | - timeTableManageService.setCurrentPageNo(result.number + 1); | |
| 159 | - }, | |
| 160 | - function(result) { | |
| 161 | - alert("出错啦!"); | |
| 162 | - } | |
| 163 | - ); | |
| 164 | - | |
| 165 | - //$scope.$watch("ctrl.pageInfo.currentPage", function() { | |
| 166 | - // alert("dfdfdf"); | |
| 167 | - //}); | |
| 168 | - | |
| 169 | - // 翻页的时候调用 | |
| 170 | - self.pageChanaged = function() { | |
| 171 | - timeTableManageService.setCurrentPageNo(self.pageInfo.currentPage); | |
| 172 | - timeTableManageService.getPage().then( | |
| 173 | - function(result) { | |
| 174 | - self.pageInfo.totalItems = result.totalElements; | |
| 175 | - self.pageInfo.currentPage = result.number + 1; | |
| 176 | - self.pageInfo.infos = result.content; | |
| 177 | - timeTableManageService.setCurrentPageNo(result.number + 1); | |
| 178 | - }, | |
| 179 | - function(result) { | |
| 180 | - alert("出错啦!"); | |
| 181 | - } | |
| 182 | - ); | |
| 183 | - }; | |
| 184 | - // 获取查询条件数据 | |
| 185 | - self.searchCondition = function() { | |
| 186 | - return timeTableManageService.getSearchCondition(); | |
| 187 | - }; | |
| 188 | - // 重置查询条件 | |
| 189 | - self.resetSearchCondition = function() { | |
| 190 | - timeTableManageService.resetSearchCondition(); | |
| 191 | - self.pageInfo.currentPage = 1; | |
| 192 | - self.pageChanaged(); | |
| 193 | - }; | |
| 194 | - | |
| 195 | - // 作废/撤销 | |
| 196 | - self.toggleTtinfo = function(id) { | |
| 197 | - // TODO: | |
| 198 | - timeTableManageService.deleteDetail(id).then( | |
| 199 | - function(result) { | |
| 200 | - if (result.message) { // 暂时这样做,之后全局拦截 | |
| 201 | - alert("失败:" + result.message); | |
| 202 | - } else { | |
| 203 | - alert("成功!"); | |
| 204 | - | |
| 205 | - timeTableManageService.getPage().then( | |
| 206 | - function(result) { | |
| 207 | - self.pageInfo.totalItems = result.totalElements; | |
| 208 | - self.pageInfo.currentPage = result.number + 1; | |
| 209 | - self.pageInfo.infos = result.content; | |
| 210 | - timeTableManageService.setCurrentPageNo(result.number + 1); | |
| 211 | - }, | |
| 212 | - function(result) { | |
| 213 | - alert("出错啦!"); | |
| 214 | - } | |
| 215 | - ); | |
| 216 | - } | |
| 217 | - | |
| 218 | - }, | |
| 219 | - function(result) { | |
| 220 | - alert("出错啦!" + result); | |
| 221 | - } | |
| 222 | - ); | |
| 223 | - }; | |
| 224 | - | |
| 225 | - // 导入excel | |
| 226 | - self.importData = function($index) { | |
| 227 | - // 线路名称 | |
| 228 | - var xlmc = self.pageInfo.infos[$index]["xl"]["name"]; | |
| 229 | - // 时刻表名称 | |
| 230 | - var ttinfoname = self.pageInfo.infos[$index]["name"]; | |
| 231 | - | |
| 232 | - // large方式弹出模态对话框 | |
| 233 | - var modalInstance = $uibModal.open({ | |
| 234 | - templateUrl: '/pages/scheduleApp/module/core/timeTableManage/detailDataImport.html', | |
| 235 | - size: "lg", | |
| 236 | - animation: true, | |
| 237 | - backdrop: 'static', | |
| 238 | - resolve: { | |
| 239 | - // 可以传值给controller | |
| 240 | - r_xlmc : function() {return xlmc}, | |
| 241 | - r_ttinfoname : function() {return ttinfoname;} | |
| 242 | - }, | |
| 243 | - windowClass: 'center-modal', | |
| 244 | - controller: "TimeTableDetailManageToolsCtrl", | |
| 245 | - controllerAs: "ctrl", | |
| 246 | - bindToController: true | |
| 247 | - }); | |
| 248 | - modalInstance.result.then( | |
| 249 | - function() { | |
| 250 | - console.log("dataImport.html打开"); | |
| 251 | - }, | |
| 252 | - function() { | |
| 253 | - console.log("dataImport.html消失"); | |
| 254 | - } | |
| 255 | - ); | |
| 256 | - }; | |
| 257 | - | |
| 258 | -}]); | |
| 259 | - | |
| 260 | -angular.module('ScheduleApp').controller('TimeTableDetailManageToolsCtrl', ['$modalInstance', 'FileUploader', 'r_xlmc', 'r_ttinfoname', function($modalInstance, FileUploader, r_xlmc, r_ttinfoname) { | |
| 261 | - var self = this; | |
| 262 | - | |
| 263 | - self.xlmc = r_xlmc; | |
| 264 | - self.ttinfoname = r_ttinfoname; | |
| 265 | - | |
| 266 | - // 关闭窗口 | |
| 267 | - self.close = function() { | |
| 268 | - $modalInstance.dismiss("cancel"); | |
| 269 | - }; | |
| 270 | - | |
| 271 | - self.clearInputFile = function() { | |
| 272 | - angular.element("input[type='file']").val(null); | |
| 273 | - }; | |
| 274 | - | |
| 275 | - // 上传文件组件 | |
| 276 | - self.uploader = new FileUploader({ | |
| 277 | - url: "/tidc/dataImportExtend", | |
| 278 | - filters: [], // 用于过滤文件,比如只允许导入excel, | |
| 279 | - formData: [{xlmc: self.xlmc, ttinfoname: self.ttinfoname}] | |
| 280 | - }); | |
| 281 | - self.uploader.onAfterAddingFile = function(fileItem) | |
| 282 | - { | |
| 283 | - console.info('onAfterAddingFile', fileItem); | |
| 284 | - console.log(self.uploader.queue.length); | |
| 285 | - if (self.uploader.queue.length > 1) | |
| 286 | - self.uploader.removeFromQueue(0); | |
| 287 | - }; | |
| 288 | - self.uploader.onSuccessItem = function(fileItem, response, status, headers) | |
| 289 | - { | |
| 290 | - console.info('onSuccessItem', fileItem, response, status, headers); | |
| 291 | - }; | |
| 292 | - self.uploader.onErrorItem = function(fileItem, response, status, headers) | |
| 293 | - { | |
| 294 | - console.info('onErrorItem', fileItem, response, status, headers); | |
| 295 | - }; | |
| 296 | - | |
| 297 | -}]); | |
| 298 | - | |
| 299 | -angular.module('ScheduleApp').controller('TimeTableManageFormCtrl', [ | |
| 300 | - 'TimeTableManageService', | |
| 301 | - 'TimeTableManageService_g', | |
| 302 | - '$stateParams', | |
| 303 | - '$state', function(timeTableManageService, timeTableManageService_g, $stateParams, $state) { | |
| 304 | - var self = this; | |
| 305 | - | |
| 306 | - // 启用日期 日期控件开关 | |
| 307 | - self.qyrqOpen = false; | |
| 308 | - self.qyrq_open = function() { | |
| 309 | - self.qyrqOpen = true; | |
| 310 | - }; | |
| 311 | - | |
| 312 | - // 测试 | |
| 313 | - self.timeTableManageForForm = new timeTableManageService_g.rest(); | |
| 314 | - self.timeTableManageForForm.xl = {}; | |
| 315 | - self.submit = function() { | |
| 316 | - self.timeTableManageForForm.$save(function() { | |
| 317 | - $state.go("timeTableManage"); | |
| 318 | - }); | |
| 319 | - }; | |
| 320 | - | |
| 321 | - | |
| 322 | - | |
| 323 | - //// 欲保存的表单信息,双向绑定 | |
| 324 | - //self.timeTableManageForForm= {xl : {}}; | |
| 325 | - // | |
| 326 | - //// 如果是修改,获取传过来的id,从后台获取一份数据,用于绑定页面form值 | |
| 327 | - //var id = $stateParams.id; | |
| 328 | - //if (id) { | |
| 329 | - // self.timeTableManageForForm.id = id; | |
| 330 | - // timeTableManageService.getDetail(id).then( | |
| 331 | - // function(result) { | |
| 332 | - // var key; | |
| 333 | - // for (key in result) { | |
| 334 | - // self.timeTableManageForForm[key] = result[key]; | |
| 335 | - // } | |
| 336 | - // }, | |
| 337 | - // function(result) { | |
| 338 | - // alert("出错啦!"); | |
| 339 | - // } | |
| 340 | - // ); | |
| 341 | - //} | |
| 342 | - // | |
| 343 | - //// form提交方法 | |
| 344 | - //self.submit = function() { | |
| 345 | - // timeTableManageService.saveDetail(self.timeTableManageForForm).then( | |
| 346 | - // function(result) { | |
| 347 | - // if (result.status == 'SUCCESS') { | |
| 348 | - // alert("保存成功!"); | |
| 349 | - // $state.go("timeTableManage"); | |
| 350 | - // } else { | |
| 351 | - // alert("保存异常!"); | |
| 352 | - // } | |
| 353 | - // }, | |
| 354 | - // function(result) { | |
| 355 | - // alert("出错啦!"); | |
| 356 | - // } | |
| 357 | - // ); | |
| 358 | - //}; | |
| 359 | - | |
| 360 | - | |
| 361 | - }]); | |
| 362 | - | |
| 363 | -angular.module('ScheduleApp').controller('TimeTableManageDetailCtrl', ['TimeTableManageService', '$stateParams', function(timeTableManageService, $stateParams) { | |
| 364 | - var self = this; | |
| 365 | - self.title = ""; | |
| 366 | - self.timeTableManageForDetail = {}; | |
| 367 | - | |
| 368 | - timeTableManageService.getDetail($stateParams.id).then( | |
| 369 | - function(result) { | |
| 370 | - angular.copy(result, self.timeTableManageForDetail); | |
| 371 | - | |
| 372 | - self.title = self.timeTableManageForDetail.xl.name + | |
| 373 | - "(" + | |
| 374 | - self.timeTableManageForDetail.name + | |
| 375 | - ")" + | |
| 376 | - "时刻表基础信息"; | |
| 377 | - }, | |
| 378 | - function(result) { | |
| 379 | - alert("出错啦!"); | |
| 380 | - } | |
| 381 | - ); | |
| 382 | - | |
| 383 | - | |
| 384 | -}]); | |
| 385 | - | |
| 386 | - | |
| 387 | - |
src/main/resources/static/pages/scheduleApp/module/core/ttInfoDetailManage/edit-detail.html
0 → 100644
| 1 | +<div ng-controller="TimeTableDetailManageFormCtrl_old as ctrl"> | |
| 2 | + <div class="page-head"> | |
| 3 | + <div class="page-title"> | |
| 4 | + <h1>修改班次信息2</h1> | |
| 5 | + </div> | |
| 6 | + </div> | |
| 7 | + | |
| 8 | + <ul class="page-breadcrumb breadcrumb"> | |
| 9 | + <li> | |
| 10 | + <a href="/pages/home.html" data-pjax>首页</a> | |
| 11 | + <i class="fa fa-circle"></i> | |
| 12 | + </li> | |
| 13 | + <li> | |
| 14 | + <span class="active">运营计划管理</span> | |
| 15 | + <i class="fa fa-circle"></i> | |
| 16 | + </li> | |
| 17 | + <li> | |
| 18 | + <a ui-sref="ttInfoManage">时刻表管理</a> | |
| 19 | + <i class="fa fa-circle"></i> | |
| 20 | + </li> | |
| 21 | + <li> | |
| 22 | + <a ui-sref="ttInfoDetailManage_edit({xlid: ctrl.xlid, ttid : ctrl.ttid, xlname: ctrl.xlname, ttname : ctrl.ttname})"><span ng-bind="ctrl.title1"></span></a> | |
| 23 | + <i class="fa fa-circle"></i> | |
| 24 | + </li> | |
| 25 | + <li> | |
| 26 | + <span class="active">修改班次信息</span> | |
| 27 | + </li> | |
| 28 | + </ul> | |
| 29 | + | |
| 30 | + <div class="portlet light bordered"> | |
| 31 | + <div class="portlet-title"> | |
| 32 | + <div class="caption"> | |
| 33 | + <i class="icon-equalizer font-red-sunglo"></i> <span | |
| 34 | + class="caption-subject font-red-sunglo bold uppercase" ng-bind="ctrl.title2"></span> | |
| 35 | + </div> | |
| 36 | + </div> | |
| 37 | + | |
| 38 | + <div class="portlet-body form"> | |
| 39 | + <form ng-submit="ctrl.submit()" class="form-horizontal" novalidate name="myForm"> | |
| 40 | + <div class="form-body"> | |
| 41 | + <div class="form-group has-success has-feedback"> | |
| 42 | + <label class="col-md-3 control-label">线路*:</label> | |
| 43 | + <div class="col-md-7"> | |
| 44 | + <input type="text" class="form-control" | |
| 45 | + ng-value="ctrl.TimeTableDetailForSave.xl.name" | |
| 46 | + readonly/> | |
| 47 | + </div> | |
| 48 | + | |
| 49 | + </div> | |
| 50 | + <div class="form-group has-success has-feedback"> | |
| 51 | + <label class="col-md-3 control-label">时刻表名称*:</label> | |
| 52 | + <div class="col-md-7"> | |
| 53 | + <input type="text" class="form-control" | |
| 54 | + ng-value="ctrl.TimeTableDetailForSave.ttinfo.name" | |
| 55 | + readonly/> | |
| 56 | + </div> | |
| 57 | + </div> | |
| 58 | + <div class="form-group has-success has-feedback"> | |
| 59 | + <label class="col-md-3 control-label">路牌*:</label> | |
| 60 | + <div class="col-md-7"> | |
| 61 | + <input type="text" class="form-control" | |
| 62 | + ng-value="ctrl.TimeTableDetailForSave.lp.lpName" | |
| 63 | + readonly/> | |
| 64 | + </div> | |
| 65 | + | |
| 66 | + </div> | |
| 67 | + <div class="form-group has-success has-feedback"> | |
| 68 | + <label class="col-md-3 control-label">发车顺序号*:</label> | |
| 69 | + <div class="col-md-7"> | |
| 70 | + <input type="text" class="form-control" | |
| 71 | + ng-value="ctrl.TimeTableDetailForSave.fcno" | |
| 72 | + readonly/> | |
| 73 | + </div> | |
| 74 | + | |
| 75 | + </div> | |
| 76 | + <div class="form-group has-success has-feedback"> | |
| 77 | + <label class="col-md-3 control-label">方向*:</label> | |
| 78 | + <div class="col-md-7"> | |
| 79 | + <sa-Radiogroup model="ctrl.TimeTableDetailForSave.xlDir" dicgroup="LineTrend" name="xlDir" required></sa-Radiogroup> | |
| 80 | + </div> | |
| 81 | + <!-- 隐藏块,显示验证信息 --> | |
| 82 | + <div class="alert alert-danger well-sm" ng-show="myForm.xlDir.$error.required"> | |
| 83 | + 请选择线路上下行 | |
| 84 | + </div> | |
| 85 | + | |
| 86 | + </div> | |
| 87 | + <div class="form-group"> | |
| 88 | + <label class="col-md-3 control-label">起点站:</label> | |
| 89 | + <div class="col-md-7"> | |
| 90 | + <sa-Select3 model="ctrl.TimeTableDetailForSave" | |
| 91 | + name="qdz" | |
| 92 | + placeholder="请输拼音..." | |
| 93 | + dcvalue="{{ctrl.TimeTableDetailForSave.qdz.id}}" | |
| 94 | + dcname="qdz.id" | |
| 95 | + icname="stationid" | |
| 96 | + icnames="stationname" | |
| 97 | + datatype="zd" | |
| 98 | + dataassociate="true" | |
| 99 | + dataparam="{{ {'xlid': ctrl.TimeTableDetailForSave.xl.id, 'xldir': ctrl.TimeTableDetailForSave.xlDir} | json }}" | |
| 100 | + mlp="true" | |
| 101 | + > | |
| 102 | + </sa-Select3> | |
| 103 | + </div> | |
| 104 | + </div> | |
| 105 | + <div class="form-group"> | |
| 106 | + <label class="col-md-3 control-label">终点站:</label> | |
| 107 | + <div class="col-md-7"> | |
| 108 | + <sa-Select3 model="ctrl.TimeTableDetailForSave" | |
| 109 | + name="zdz" | |
| 110 | + placeholder="请输拼音..." | |
| 111 | + dcvalue="{{ctrl.TimeTableDetailForSave.zdz.id}}" | |
| 112 | + dcname="zdz.id" | |
| 113 | + icname="stationid" | |
| 114 | + icnames="stationname" | |
| 115 | + datatype="zd" | |
| 116 | + dataassociate="true" | |
| 117 | + dataparam="{{ {'xlid': ctrl.TimeTableDetailForSave.xl.id, 'xldir': ctrl.TimeTableDetailForSave.xlDir} | json }}" | |
| 118 | + mlp="true" | |
| 119 | + > | |
| 120 | + </sa-Select3> | |
| 121 | + </div> | |
| 122 | + </div> | |
| 123 | + <div class="form-group"> | |
| 124 | + <label class="col-md-3 control-label">停车场:</label> | |
| 125 | + <div class="col-md-7"> | |
| 126 | + <sa-Select3 model="ctrl.TimeTableDetailForSave" | |
| 127 | + name="tcc" | |
| 128 | + placeholder="请输拼音..." | |
| 129 | + dcvalue="{{ctrl.TimeTableDetailForSave.tcc.id}}" | |
| 130 | + dcname="tcc.id" | |
| 131 | + icname="id" | |
| 132 | + icnames="parkName" | |
| 133 | + datatype="tcc" | |
| 134 | + mlp="true" | |
| 135 | + > | |
| 136 | + </sa-Select3> | |
| 137 | + </div> | |
| 138 | + </div> | |
| 139 | + | |
| 140 | + <div class="form-group has-success has-feedback"> | |
| 141 | + <label class="col-md-3 control-label">发车时间*:</label> | |
| 142 | + <div class="col-md-7"> | |
| 143 | + <input type="text" class="form-control" | |
| 144 | + ng-model="ctrl.TimeTableDetailForSave.fcsj" | |
| 145 | + /> | |
| 146 | + </div> | |
| 147 | + | |
| 148 | + </div> | |
| 149 | + <div class="form-group"> | |
| 150 | + <label class="col-md-3 control-label">对应班次数:</label> | |
| 151 | + <div class="col-md-7"> | |
| 152 | + <input type="text" class="form-control" | |
| 153 | + ng-value="ctrl.TimeTableDetailForSave.bcs" | |
| 154 | + readonly/> | |
| 155 | + </div> | |
| 156 | + | |
| 157 | + </div> | |
| 158 | + <div class="form-group"> | |
| 159 | + <label class="col-md-3 control-label">计划里程:</label> | |
| 160 | + <div class="col-md-7"> | |
| 161 | + <input type="text" class="form-control" | |
| 162 | + ng-model="ctrl.TimeTableDetailForSave.jhlc" | |
| 163 | + /> | |
| 164 | + </div> | |
| 165 | + | |
| 166 | + </div> | |
| 167 | + <div class="form-group"> | |
| 168 | + <label class="col-md-3 control-label">班次历时:</label> | |
| 169 | + <div class="col-md-7"> | |
| 170 | + <input type="text" class="form-control" | |
| 171 | + ng-model="ctrl.TimeTableDetailForSave.bcsj" | |
| 172 | + /> | |
| 173 | + </div> | |
| 174 | + | |
| 175 | + </div> | |
| 176 | + <div class="form-group has-success has-feedback"> | |
| 177 | + <label class="col-md-3 control-label">班次类型*:</label> | |
| 178 | + <div class="col-md-7"> | |
| 179 | + <sa-Select3 model="ctrl.TimeTableDetailForSave" | |
| 180 | + name="bcType" | |
| 181 | + placeholder="请选择班次类型..." | |
| 182 | + dcvalue="{{ctrl.TimeTableDetailForSave.bcType}}" | |
| 183 | + dcname="bcType" | |
| 184 | + icname="code" | |
| 185 | + icnames="name" | |
| 186 | + datatype="ScheduleType" | |
| 187 | + required > | |
| 188 | + </sa-Select3> | |
| 189 | + </div> | |
| 190 | + | |
| 191 | + </div> | |
| 192 | + <div class="form-group"> | |
| 193 | + <label class="col-md-3 control-label">备注:</label> | |
| 194 | + <div class="col-md-7"> | |
| 195 | + <textarea class="form-control" | |
| 196 | + ng-model="ctrl.TimeTableDetailForSave.remark" | |
| 197 | + /> | |
| 198 | + </div> | |
| 199 | + | |
| 200 | + </div> | |
| 201 | + | |
| 202 | + </div> | |
| 203 | + | |
| 204 | + <div class="form-actions"> | |
| 205 | + <div class="row"> | |
| 206 | + <div class="col-md-offset-3 col-md-4"> | |
| 207 | + <button type="submit" class="btn green" | |
| 208 | + ng-disabled="!myForm.$valid"><i class="fa fa-check"></i> 提交</button> | |
| 209 | + <a type="button" class="btn default" | |
| 210 | + ui-sref="ttInfoDetailManage_edit({xlid: ctrl.xlid, ttid : ctrl.ttid, xlname: ctrl.xlname, ttname : ctrl.ttname})" ><i class="fa fa-times"></i> 取消</a> | |
| 211 | + </div> | |
| 212 | + </div> | |
| 213 | + </div> | |
| 214 | + </form> | |
| 215 | + | |
| 216 | + </div> | |
| 217 | + </div> | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | +</div> | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/ttInfoDetailManage/edit.html
0 → 100644
| 1 | +<div class="page-head"> | |
| 2 | + <div class="page-title"> | |
| 3 | + <h1>时刻表管理2</h1> | |
| 4 | + </div> | |
| 5 | +</div> | |
| 6 | + | |
| 7 | +<ul class="page-breadcrumb breadcrumb"> | |
| 8 | + <li> | |
| 9 | + <a href="/pages/home.html" data-pjax>首页</a> | |
| 10 | + <i class="fa fa-circle"></i> | |
| 11 | + </li> | |
| 12 | + <li> | |
| 13 | + <span class="active">运营计划管理</span> | |
| 14 | + <i class="fa fa-circle"></i> | |
| 15 | + </li> | |
| 16 | + <li> | |
| 17 | + <a ui-sref="ttInfoManage">时刻表管理</a> | |
| 18 | + <i class="fa fa-circle"></i> | |
| 19 | + </li> | |
| 20 | + <li> | |
| 21 | + <span class="active">编辑时刻表明细信息</span> | |
| 22 | + </li> | |
| 23 | +</ul> | |
| 24 | + | |
| 25 | +<!--<!– loading widget –>--> | |
| 26 | +<!--<div id="loadingWidget" class="flyover mask" loading-widget>--> | |
| 27 | +<!--<div class="alert alert-info">--> | |
| 28 | +<!--<strong>载入中......</strong>--> | |
| 29 | +<!--</div>--> | |
| 30 | +<!--</div>--> | |
| 31 | + | |
| 32 | +<div class="row" id="timeTableDetail" ng-controller="TimeTableDetailManageCtrl_old as ctrl"> | |
| 33 | + <div class="col-md-12"> | |
| 34 | + <div class="portlet light bordered"> | |
| 35 | + <div class="portlet-title"> | |
| 36 | + <div class="caption font-dark"> | |
| 37 | + <i class="fa fa-database font-dark"></i> | |
| 38 | + <span class="caption-subject bold uppercase" ng-bind="ctrl.title"></span> | |
| 39 | + </div> | |
| 40 | + <div class="actions"> | |
| 41 | + <i class="fa fa-arrow-up" aria-hidden="true"></i> | |
| 42 | + <span style="padding-right: 10px;">上行班次</span> | |
| 43 | + <i class="fa fa-arrow-down" aria-hidden="true"></i> | |
| 44 | + <span style="padding-right: 10px;">下行班次</span> | |
| 45 | + <i class="fa fa-circle-o-notch" aria-hidden="true"></i> | |
| 46 | + <span style="padding-right: 10px;">区间班次</span> | |
| 47 | + <i class="fa fa-adjust" aria-hidden="true"></i> | |
| 48 | + <span style="padding-right: 10px;">分班班次</span> | |
| 49 | + | |
| 50 | + <div class="btn-group"> | |
| 51 | + <a href="javascript:" class="btn red btn-outline btn-circle" data-toggle="dropdown"> | |
| 52 | + <i class="fa fa-share"></i> | |
| 53 | + <span>数据工具</span> | |
| 54 | + <i class="fa fa-angle-down"></i> | |
| 55 | + </a> | |
| 56 | + <ul class="dropdown-menu pull-right"> | |
| 57 | + <li> | |
| 58 | + <a href="javascript:" class="tool-action"> | |
| 59 | + <i class="fa fa-file-excel-o"></i> | |
| 60 | + 导出excel | |
| 61 | + </a> | |
| 62 | + </li> | |
| 63 | + <li class="divider"></li> | |
| 64 | + <li> | |
| 65 | + <a href="javascript:" class="tool-action" ng-click="ctrl.refresh()"> | |
| 66 | + <i class="fa fa-refresh"></i> | |
| 67 | + 刷行数据 | |
| 68 | + </a> | |
| 69 | + </li> | |
| 70 | + </ul> | |
| 71 | + </div> | |
| 72 | + | |
| 73 | + </div> | |
| 74 | + </div> | |
| 75 | + | |
| 76 | + <div class="portlet-body"> | |
| 77 | + <!--<div ng-view></div>--> | |
| 78 | + <div class="fixDiv"> | |
| 79 | + <table style="width: 2000px" class="table table-striped table-bordered table-hover table-checkable order-column"> | |
| 80 | + <thead> | |
| 81 | + <tr> | |
| 82 | + <th ng-repeat="head in ctrl.detailHeads track by $index"> | |
| 83 | + <span ng-bind="head"></span> | |
| 84 | + </th> | |
| 85 | + | |
| 86 | + </tr> | |
| 87 | + </thead> | |
| 88 | + <tbody> | |
| 89 | + <tr ng-repeat="info in ctrl.detailInfos"> | |
| 90 | + <td ng-repeat="cell in info track by $index"> | |
| 91 | + | |
| 92 | + <!--<span ng-bind="cell.fcsj"></span>--> | |
| 93 | + <span ng-if="!cell.ttdid" ng-bind="cell.fcsj"></span> | |
| 94 | + | |
| 95 | + <div ng-if="cell.ttdid" class="btn-group"> | |
| 96 | + <a href="javascript:" class="btn blue btn-outline btn-circle" data-toggle="dropdown"> | |
| 97 | + <!-- 上下行图标 --> | |
| 98 | + <i ng-if="cell.xldir == '0'" class="fa fa-arrow-up" aria-hidden="true"></i> | |
| 99 | + <i ng-if="cell.xldir == '1'" class="fa fa-arrow-down" aria-hidden="true"></i> | |
| 100 | + <!-- 班次类型图标(区间班次) --> | |
| 101 | + <i ng-if="cell.bc_type == 'region'" class="fa fa-circle-o-notch" aria-hidden="true"></i> | |
| 102 | + <!-- 分班班次 --> | |
| 103 | + <i ng-if="cell.isfb == true" class="fa fa-adjust" aria-hidden="true"></i> | |
| 104 | + | |
| 105 | + <span ng-bind="cell.fcsj"></span> | |
| 106 | + <i class="fa fa-angle-down"></i> | |
| 107 | + </a> | |
| 108 | + <ul class="dropdown-menu pull-left"> | |
| 109 | + <li> | |
| 110 | + <a href="javascript:" class="tool-action" ui-sref="ttInfoDetailManage_detail_edit({id: cell.ttdid, xlid: ctrl.xlid, ttid: ctrl.ttid, xlname: ctrl.xlname, ttname: ctrl.ttname})"> | |
| 111 | + <i class="fa fa-file-excel-o"></i> | |
| 112 | + 修改 | |
| 113 | + </a> | |
| 114 | + </li> | |
| 115 | + <li> | |
| 116 | + <a href="javascript:" class="tool-action"> | |
| 117 | + <i class="fa fa-refresh"></i> | |
| 118 | + 删除 | |
| 119 | + </a> | |
| 120 | + </li> | |
| 121 | + <li class="divider"></li> | |
| 122 | + <li> | |
| 123 | + <a href="javascript:" class="tool-action" ng-click="ctrl.changeDirect(cell, 0)"> | |
| 124 | + <i class="fa fa-file-excel-o"></i> | |
| 125 | + 设为上行 | |
| 126 | + <i class="fa fa-arrow-up" aria-hidden="true"></i> | |
| 127 | + </a> | |
| 128 | + </li> | |
| 129 | + <li> | |
| 130 | + <a href="javascript:" class="tool-action" ng-click="ctrl.changeDirect(cell, 1)"> | |
| 131 | + <i class="fa fa-file-excel-o"></i> | |
| 132 | + 设为下行 | |
| 133 | + <i class="fa fa-arrow-down" aria-hidden="true"></i> | |
| 134 | + </a> | |
| 135 | + </li> | |
| 136 | + <li> | |
| 137 | + <a href="javascript:" class="tool-action" ng-click="ctrl.changeFB(cell, true)"> | |
| 138 | + <i class="fa fa-file-excel-o"></i> | |
| 139 | + 设置分班 | |
| 140 | + <i class="fa fa-adjust" aria-hidden="true"></i> | |
| 141 | + </a> | |
| 142 | + </li> | |
| 143 | + <li> | |
| 144 | + <a href="javascript:" class="tool-action" ng-click="ctrl.changeFB(cell, false)"> | |
| 145 | + <i class="fa fa-file-excel-o"></i> | |
| 146 | + 取消分班 | |
| 147 | + <i class="fa fa-adjust" aria-hidden="true"></i> | |
| 148 | + </a> | |
| 149 | + </li> | |
| 150 | + <li> | |
| 151 | + <a href="javascript:" class="tool-action" ng-click="ctrl.changeBCType(cell, 'region')"> | |
| 152 | + <i class="fa fa-file-excel-o"></i> | |
| 153 | + 设为区间 | |
| 154 | + <i class="fa fa-circle-o-notch" aria-hidden="true"></i> | |
| 155 | + </a> | |
| 156 | + </li> | |
| 157 | + | |
| 158 | + | |
| 159 | + </ul> | |
| 160 | + </div> | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + </td> | |
| 165 | + </tr> | |
| 166 | + | |
| 167 | + </tbody> | |
| 168 | + </table> | |
| 169 | + </div> | |
| 170 | + | |
| 171 | + | |
| 172 | + </div> | |
| 173 | + </div> | |
| 174 | + </div> | |
| 175 | +</div> | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/ttInfoDetailManage/form.html
0 → 100644
| 1 | +<div class="page-head"> | |
| 2 | + <div class="page-title"> | |
| 3 | + <h1>时刻表管理2</h1> | |
| 4 | + </div> | |
| 5 | +</div> | |
| 6 | + | |
| 7 | +<ul class="page-breadcrumb breadcrumb"> | |
| 8 | + <li> | |
| 9 | + <a href="/pages/home.html" data-pjax>首页</a> | |
| 10 | + <i class="fa fa-circle"></i> | |
| 11 | + </li> | |
| 12 | + <li> | |
| 13 | + <span class="active">运营计划管理</span> | |
| 14 | + <i class="fa fa-circle"></i> | |
| 15 | + </li> | |
| 16 | + <li> | |
| 17 | + <a ui-sref="ttInfoManage">时刻表管理</a> | |
| 18 | + <i class="fa fa-circle"></i> | |
| 19 | + </li> | |
| 20 | + <li> | |
| 21 | + <span class="active">时刻表明细</span> | |
| 22 | + </li> | |
| 23 | + <li> | |
| 24 | + <span class="active">导入时刻表 </span> | |
| 25 | + </li> | |
| 26 | +</ul> | |
| 27 | + | |
| 28 | +<div class="portlet light bordered" ng-controller="TtInfoDetailManageFormCtrl as ctrl"> | |
| 29 | + <div class="portlet-title"> | |
| 30 | + <div class="caption"> | |
| 31 | + <i class="icon-equalizer font-red-sunglo"></i> <span | |
| 32 | + class="caption-subject font-red-sunglo bold uppercase" | |
| 33 | + ng-bind="ctrl.title"> | |
| 34 | + </span> | |
| 35 | + </div> | |
| 36 | + </div> | |
| 37 | + | |
| 38 | + | |
| 39 | + <div class="col-md-6"> | |
| 40 | + <div class="input-group"> | |
| 41 | + <input type="file" class="form-control" nv-file-select="" uploader="ctrl.uploader"/> | |
| 42 | + <span class="input-group-btn"> | |
| 43 | + <button type="button" ng-click="ctrl.clearInputFile()" class="btn btn-default"> | |
| 44 | + <span class="glyphicon glyphicon-trash"></span> | |
| 45 | + </button> | |
| 46 | + </span> | |
| 47 | + </div> | |
| 48 | + </div> | |
| 49 | + <div class="table-scrollable table-scrollable-borderless"> | |
| 50 | + <table class="table table-hover table-light"> | |
| 51 | + <thead> | |
| 52 | + <tr class="uppercase"> | |
| 53 | + <th width="50%">文件名</th> | |
| 54 | + <th ng-show="ctrl.uploader.isHTML5">大小(M)</th> | |
| 55 | + <th ng-show="ctrl.uploader.isHTML5">进度</th> | |
| 56 | + <th>状态</th> | |
| 57 | + <th>操作</th> | |
| 58 | + </tr> | |
| 59 | + </thead> | |
| 60 | + <tbody> | |
| 61 | + <tr ng-repeat="item in ctrl.uploader.queue"> | |
| 62 | + <td> | |
| 63 | + <strong>{{ item.file.name }}</strong> | |
| 64 | + </td> | |
| 65 | + <td ng-show="ctrl.uploader.isHTML5" nowrap>{{ item.file.size/1024/1024|number:2 }} MB</td> | |
| 66 | + <td ng-show="ctrl.uploader.isHTML5"> | |
| 67 | + <div class="progress progress-sm" style="margin-bottom: 0;"> | |
| 68 | + <div class="progress-bar progress-bar-info" role="progressbar" | |
| 69 | + ng-style="{ 'width': item.progress + '%' }"></div> | |
| 70 | + </div> | |
| 71 | + </td> | |
| 72 | + <td class="text-center"> | |
| 73 | + <span ng-show="item.isSuccess" class="text-success"> | |
| 74 | + <i class="glyphicon glyphicon-ok"></i> | |
| 75 | + </span> | |
| 76 | + <span ng-show="item.isCancel" class="text-info"> | |
| 77 | + <i class="glyphicon glyphicon-ban-circle"></i> | |
| 78 | + </span> | |
| 79 | + <span ng-show="item.isError" class="text-danger"> | |
| 80 | + <i class="glyphicon glyphicon-remove"></i> | |
| 81 | + </span> | |
| 82 | + </td> | |
| 83 | + <td nowrap> | |
| 84 | + <button type="button" class="btn btn-success btn-xs" ng-click="item.upload()" | |
| 85 | + ng-disabled="item.isReady || item.isUploading || item.isSuccess"> | |
| 86 | + <span class="glyphicon glyphicon-upload"></span> 上传 | |
| 87 | + </button> | |
| 88 | + <button type="button" class="btn btn-warning btn-xs" ng-click="item.cancel()" | |
| 89 | + ng-disabled="!item.isUploading"> | |
| 90 | + <span class="glyphicon glyphicon-ban-circle"></span> 取消 | |
| 91 | + </button> | |
| 92 | + <button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()"> | |
| 93 | + <span class="glyphicon glyphicon-trash"></span> 删除 | |
| 94 | + </button> | |
| 95 | + </td> | |
| 96 | + </tr> | |
| 97 | + </tbody> | |
| 98 | + </table> | |
| 99 | + </div> | |
| 100 | + | |
| 101 | + | |
| 102 | + <div class="portlet-body form"> | |
| 103 | + <form ng-submit="ctrl.submit()" class="form-horizontal" novalidate name="myForm"> | |
| 104 | + <div class="form-body"> | |
| 105 | + <div class="form-group has-success has-feedback"> | |
| 106 | + <label class="col-md-2 control-label">excel工作区*:</label> | |
| 107 | + <div class="col-md-3"> | |
| 108 | + <sa-Select5 name="sheetname" | |
| 109 | + model="ctrl.ttInfoDetailManageForForm" | |
| 110 | + cmaps="{'sheetname' : 'name'}" | |
| 111 | + dcname="sheetname" | |
| 112 | + icname="name" | |
| 113 | + dsparams="{{ {type: 'local', ldata: ctrl.sheetnames} | json }}" | |
| 114 | + iterobjname="item" | |
| 115 | + iterobjexp="item.name" | |
| 116 | + searchph="请选择..." | |
| 117 | + searchexp="this.name" | |
| 118 | + required > | |
| 119 | + </sa-Select5> | |
| 120 | + <input type="hidden" name="sheetname_h" ng-model="ctrl.ttInfoDetailManageForForm.sheetvaliddesc" | |
| 121 | + remote-Validationt2 | |
| 122 | + remotevtype="sheet" | |
| 123 | + remotevparam="{{ { | |
| 124 | + 'filename': ctrl.ttInfoDetailManageForForm.filename, | |
| 125 | + 'sheetname': ctrl.ttInfoDetailManageForForm.sheetname, | |
| 126 | + 'lineid' : ctrl.ttInfoDetailManageForForm.xlid, | |
| 127 | + 'linename' : ctrl.ttInfoDetailManageForForm.xlname | |
| 128 | + } | json}}"/> | |
| 129 | + </div> | |
| 130 | + <!-- 隐藏块,显示验证信息 --> | |
| 131 | + <div class="alert alert-danger well-sm" ng-show="myForm.sheetname.$error.required"> | |
| 132 | + 工作区必须选择 | |
| 133 | + </div> | |
| 134 | + <div class="alert alert-danger well-sm" ng-show="myForm.sheetname_h.$error.remote"> | |
| 135 | + {{ctrl.ttInfoDetailManageForForm.sheetvaliddesc}} | |
| 136 | + </div> | |
| 137 | + </div> | |
| 138 | + | |
| 139 | + <div class="form-group has-success has-feedback"> | |
| 140 | + <label class="col-md-2 control-label">线路标准*:</label> | |
| 141 | + <div class="col-md-3"> | |
| 142 | + <sa-Select5 name="lineinfo" | |
| 143 | + model="ctrl.ttInfoDetailManageForForm" | |
| 144 | + cmaps="{'lineinfo' : 'id'}" | |
| 145 | + dcname="lineinfo" | |
| 146 | + icname="id" | |
| 147 | + dsparams="{{ {type: 'ajax', param:{'type': 'all', 'line.id_eq': ctrl.ttInfoDetailManageForForm.xlid}, atype:'xlinfo' } | json }}" | |
| 148 | + iterobjname="item" | |
| 149 | + iterobjexp="item.line.name + '-' + (item.descriptions ? item.descriptions : '')" | |
| 150 | + searchph="请输拼音..." | |
| 151 | + searchexp="this.line.name + '-' + (this.descriptions ? this.descriptions : '')" | |
| 152 | + required > | |
| 153 | + </sa-Select5> | |
| 154 | + <input type="hidden" name="lineinfo_h" ng-model="ctrl.ttInfoDetailManageForForm.lineinfo" | |
| 155 | + remote-Validationt2 | |
| 156 | + remotevtype="sheetli" | |
| 157 | + remotevparam="{{ {'lineinfoid': ctrl.ttInfoDetailManageForForm.lineinfo} | json}}"/> | |
| 158 | + </div> | |
| 159 | + <!-- 隐藏块,显示验证信息 --> | |
| 160 | + <div class="alert alert-danger well-sm" ng-show="myForm.lineinfo.$error.required"> | |
| 161 | + 线路标准必须选择 | |
| 162 | + </div> | |
| 163 | + <div class="alert alert-danger well-sm" ng-show="myForm.lineinfo_h.$error.remote"> | |
| 164 | + {{ctrl.ttInfoDetailManageForForm.lineinfovaliddesc}} | |
| 165 | + | |
| 166 | + 上下行出场进场里程时间必须填写,上下行班次里程时间必须填写,停车场必须填写 | |
| 167 | + </div> | |
| 168 | + </div> | |
| 169 | + | |
| 170 | + | |
| 171 | + </div> | |
| 172 | + | |
| 173 | + <div class="form-actions"> | |
| 174 | + <div class="row"> | |
| 175 | + <div class="col-md-offset-3 col-md-4"> | |
| 176 | + <button type="submit" class="btn green" | |
| 177 | + ng-disabled="!myForm.$valid"><i class="fa fa-check"></i> 提交</button> | |
| 178 | + <a type="button" class="btn default" ui-sref="ttInfoManage" ><i class="fa fa-times"></i> 取消</a> | |
| 179 | + </div> | |
| 180 | + </div> | |
| 181 | + </div> | |
| 182 | + | |
| 183 | + </form> | |
| 184 | + | |
| 185 | + </div> | |
| 186 | + | |
| 187 | + | |
| 188 | +</div> | |
| 0 | 189 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/ttInfoDetailManage/main.js
0 → 100644
| 1 | +// 时刻表明晰管理service,包装外部定义的globalservice,并保存一定的操作状态 | |
| 2 | +angular.module('ScheduleApp').factory( | |
| 3 | + 'TtInfoDetailManageService', | |
| 4 | + [ | |
| 5 | + 'TimeTableDetailManageService_g', | |
| 6 | + function(service) { | |
| 7 | + // TODO: | |
| 8 | + | |
| 9 | + return { | |
| 10 | + importDetail: function(param) { | |
| 11 | + return service.import.do(param).$promise; | |
| 12 | + }, | |
| 13 | + /** | |
| 14 | + * 获取编辑用的时刻表明细数据。 | |
| 15 | + * @param ttid 时刻表id | |
| 16 | + */ | |
| 17 | + getEditInfo: function(xlid, ttid) { | |
| 18 | + var params = {xlid : xlid, ttid : ttid}; | |
| 19 | + return service.edit.list(params).$promise; | |
| 20 | + } | |
| 21 | + }; | |
| 22 | + } | |
| 23 | + ] | |
| 24 | +); | |
| 25 | + | |
| 26 | +// form.html控制器 | |
| 27 | +angular.module('ScheduleApp').controller( | |
| 28 | + 'TtInfoDetailManageFormCtrl', | |
| 29 | + [ | |
| 30 | + 'TtInfoDetailManageService', | |
| 31 | + 'FileUploader', | |
| 32 | + '$stateParams', | |
| 33 | + '$state', | |
| 34 | + function(service, FileUploader, $stateParams, $state) { | |
| 35 | + var self = this; | |
| 36 | + var xlid = $stateParams.xlid; | |
| 37 | + var ttid = $stateParams.ttid; | |
| 38 | + var xlname = $stateParams.xlname; | |
| 39 | + var ttname = $stateParams.ttname; | |
| 40 | + | |
| 41 | + self.title = xlname + '(' + ttname + ')' + '时刻表明细信息excel数据导入'; | |
| 42 | + | |
| 43 | + // 欲保存的表单信息,双向绑定 | |
| 44 | + self.ttInfoDetailManageForForm = { | |
| 45 | + xlid: xlid, // 线路id | |
| 46 | + ttid: ttid, // 时刻表id | |
| 47 | + xlname: xlname, // 线路名称 | |
| 48 | + ttname: ttname, // 时刻表名称 | |
| 49 | + filename: undefined, // 上传后的文件名 | |
| 50 | + sheetname: undefined, // sheet名字 | |
| 51 | + sheetvaliddesc: undefined, // sheet验证描述返回 | |
| 52 | + lineinfo: undefined, // 线路标准id | |
| 53 | + lineinfovaliddesc: undefined // 线路标准验证描述返回 | |
| 54 | + }; | |
| 55 | + self.sheetnames = [ | |
| 56 | + //{name: '工作表1'}, {name: '工作表2'} // sheet名字列表 | |
| 57 | + ]; | |
| 58 | + | |
| 59 | + //--------------- 上传文件功能 ---------------// | |
| 60 | + | |
| 61 | + self.clearInputFile = function() { | |
| 62 | + angular.element("input[type='file']").val(null); | |
| 63 | + }; | |
| 64 | + | |
| 65 | + // 上传文件组件 | |
| 66 | + self.uploader = new FileUploader({ | |
| 67 | + url: "/tidc/uploadFile", | |
| 68 | + filters: [], // 用于过滤文件,比如只允许导入excel, | |
| 69 | + formData: [ | |
| 70 | + { | |
| 71 | + xlmc: self.xlmc, | |
| 72 | + ttinfoname: self.ttinfoname | |
| 73 | + } | |
| 74 | + ] | |
| 75 | + }); | |
| 76 | + self.uploader.onAfterAddingFile = function(fileItem) | |
| 77 | + { | |
| 78 | + console.info('onAfterAddingFile', fileItem); | |
| 79 | + console.log(self.uploader.queue.length); | |
| 80 | + if (self.uploader.queue.length > 1) | |
| 81 | + self.uploader.removeFromQueue(0); | |
| 82 | + }; | |
| 83 | + self.uploader.onSuccessItem = function(fileItem, response, status, headers) | |
| 84 | + { | |
| 85 | + self.sheetnames = response.sheetnames; | |
| 86 | + self.ttInfoDetailManageForForm.filename = response.fileName; | |
| 87 | + console.info('onSuccessItem', fileItem, response, status, headers); | |
| 88 | + }; | |
| 89 | + self.uploader.onErrorItem = function(fileItem, response, status, headers) | |
| 90 | + { | |
| 91 | + alert("error"); | |
| 92 | + self.sheetnames = []; | |
| 93 | + console.info('onErrorItem', fileItem, response, status, headers); | |
| 94 | + }; | |
| 95 | + | |
| 96 | + | |
| 97 | + // form提交方法 | |
| 98 | + self.submit = function() { | |
| 99 | + service.importDetail(self.ttInfoDetailManageForForm).then( | |
| 100 | + function(result) { | |
| 101 | + $state.go("ttInfoManage"); | |
| 102 | + }, | |
| 103 | + function(result) { | |
| 104 | + alert("出错啦!"); | |
| 105 | + } | |
| 106 | + ); | |
| 107 | + }; | |
| 108 | + | |
| 109 | + | |
| 110 | + // TODO:edit操作暂时使用旧版本的js文件 | |
| 111 | + | |
| 112 | + // {"timestamp":1478674739246,"status":500,"error":"Internal Server Error","exception":"java.lang.ClassCastException","message":"java.lang.String cannot be cast to java.lang.Long","path":"/tidc/importfile"} | |
| 113 | + } | |
| 114 | + ] | |
| 115 | +); | |
| 0 | 116 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/ttInfoDetailManage/timeTableDetailManage_old.js
0 → 100644
| 1 | + | |
| 2 | +angular.module('ScheduleApp').factory('TimeTableDetailManageService_old', ['TimeTableDetailManageService_g', function(service) { | |
| 3 | + | |
| 4 | + return { | |
| 5 | + /** | |
| 6 | + * 获取明细信息。 | |
| 7 | + * @param id 车辆id | |
| 8 | + * @return 返回一个 promise | |
| 9 | + */ | |
| 10 | + getDetail: function(id) { | |
| 11 | + var params = {id: id}; | |
| 12 | + return service.rest.get(params).$promise; | |
| 13 | + }, | |
| 14 | + /** | |
| 15 | + * 保存信息。 | |
| 16 | + * @param obj 车辆详细信息 | |
| 17 | + * @return 返回一个 promise | |
| 18 | + */ | |
| 19 | + saveDetail: function(obj) { | |
| 20 | + return service.rest.save(obj).$promise; | |
| 21 | + }, | |
| 22 | + /** | |
| 23 | + * 获取编辑用的时刻表明细数据。 | |
| 24 | + * @param ttid 时刻表id | |
| 25 | + */ | |
| 26 | + getEditInfo: function(xlid, ttid) { | |
| 27 | + var params = {xlid : xlid, ttid : ttid}; | |
| 28 | + return service.edit.list(params).$promise; | |
| 29 | + } | |
| 30 | + }; | |
| 31 | + | |
| 32 | +}]); | |
| 33 | + | |
| 34 | +angular.module('ScheduleApp').controller('TimeTableDetailManageCtrl_old', ['TimeTableDetailManageService_old', '$stateParams', '$uibModal', function(service, $stateParams, $uibModal) { | |
| 35 | + var self = this; | |
| 36 | + self.xlid = $stateParams.xlid; // 获取传过来的线路id | |
| 37 | + self.ttid = $stateParams.ttid; // 获取传过来的时刻表id | |
| 38 | + self.xlname = $stateParams.xlname; // 获取传过来的线路名字 | |
| 39 | + self.ttname = $stateParams.ttname; // 获取传过来的时刻表名字 | |
| 40 | + | |
| 41 | + self.title = self.xlname + "(" + self.ttname + ")" + "时刻表明细信息"; | |
| 42 | + | |
| 43 | + // 载入待编辑的时刻表明细数据 | |
| 44 | + service.getEditInfo(self.xlid, self.ttid).then( | |
| 45 | + function(result) { | |
| 46 | + // TODO;获取数据待展示 | |
| 47 | + self.detailHeads = result.header; | |
| 48 | + self.detailInfos = result.contents; | |
| 49 | + }, | |
| 50 | + function(result) { | |
| 51 | + alert("出错啦!"); | |
| 52 | + } | |
| 53 | + ); | |
| 54 | + | |
| 55 | + // 刷新数据 | |
| 56 | + self.refresh = function() { | |
| 57 | + service.getEditInfo(self.xlid, self.ttid).then( | |
| 58 | + function(result) { | |
| 59 | + // TODO;获取数据待展示 | |
| 60 | + self.detailHeads = result.header; | |
| 61 | + self.detailInfos = result.contents; | |
| 62 | + }, | |
| 63 | + function(result) { | |
| 64 | + alert("出错啦!"); | |
| 65 | + } | |
| 66 | + ); | |
| 67 | + }; | |
| 68 | + | |
| 69 | + /** | |
| 70 | + * 反向操作。 | |
| 71 | + * @param cell 明细信息 | |
| 72 | + */ | |
| 73 | + self.changeDirect = function(detailInfo, xldir) { | |
| 74 | + service.getDetail(detailInfo.ttdid).then( | |
| 75 | + function(result) { | |
| 76 | + result.xlDir = xldir; | |
| 77 | + service.saveDetail(result).then( | |
| 78 | + function(result) { | |
| 79 | + detailInfo.xldir = xldir; | |
| 80 | + }, | |
| 81 | + function(result) { | |
| 82 | + alert("出错啦!"); | |
| 83 | + } | |
| 84 | + ); | |
| 85 | + }, | |
| 86 | + function(result) { | |
| 87 | + alert("出错啦!"); | |
| 88 | + } | |
| 89 | + ); | |
| 90 | + }; | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * 更新分班。 | |
| 94 | + * @param detailInfo 明细信息 | |
| 95 | + * @param flag 分班标识 | |
| 96 | + */ | |
| 97 | + self.changeFB = function(detailInfo, flag) { | |
| 98 | + service.getDetail(detailInfo.ttdid).then( | |
| 99 | + function(result) { | |
| 100 | + result.isFB = flag; | |
| 101 | + service.saveDetail(result).then( | |
| 102 | + function(result) { | |
| 103 | + detailInfo.isfb = flag; | |
| 104 | + }, | |
| 105 | + function(result) { | |
| 106 | + alert("出错啦!"); | |
| 107 | + } | |
| 108 | + ); | |
| 109 | + }, | |
| 110 | + function(result) { | |
| 111 | + alert("出错啦!"); | |
| 112 | + } | |
| 113 | + ); | |
| 114 | + }; | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * 改变便次类型。 | |
| 118 | + * @param detailInfo 明细信息 | |
| 119 | + * @param type 班次类型 | |
| 120 | + */ | |
| 121 | + self.changeBCType = function(detailInfo, type) { | |
| 122 | + service.getDetail(detailInfo.ttdid).then( | |
| 123 | + function(result) { | |
| 124 | + result.bcType = type; | |
| 125 | + service.saveDetail(result).then( | |
| 126 | + function(result) { | |
| 127 | + detailInfo.bc_type = type; | |
| 128 | + }, | |
| 129 | + function(result) { | |
| 130 | + alert("出错啦!"); | |
| 131 | + } | |
| 132 | + ); | |
| 133 | + }, | |
| 134 | + function(result) { | |
| 135 | + alert("出错啦!"); | |
| 136 | + } | |
| 137 | + ); | |
| 138 | + }; | |
| 139 | + | |
| 140 | +}]); | |
| 141 | + | |
| 142 | +angular.module('ScheduleApp').controller('TimeTableDetailManageFormCtrl_old', ['TimeTableDetailManageService_old', '$stateParams', '$state', function(service, $stateParams, $state) { | |
| 143 | + var self = this; | |
| 144 | + | |
| 145 | + // 欲保存的busInfo信息,绑定 | |
| 146 | + self.TimeTableDetailForSave = {}; | |
| 147 | + | |
| 148 | + // 获取传过来的id,有的话就是修改,获取一遍数据 | |
| 149 | + var id = $stateParams.id; // 时刻明细班次id | |
| 150 | + self.xlid = $stateParams.xlid; // 获取传过来的线路id | |
| 151 | + self.ttid = $stateParams.ttid; // 获取传过来的时刻表id | |
| 152 | + self.xlname = $stateParams.xlname; // 获取传过来的线路名字 | |
| 153 | + self.ttname = $stateParams.ttname; // 获取传过来的时刻表名字 | |
| 154 | + | |
| 155 | + self.title1 = self.xlname + "(" + self.ttname + ")" + "时刻表明细信息"; | |
| 156 | + | |
| 157 | + if (id) { | |
| 158 | + self.TimeTableDetailForSave.id = id; | |
| 159 | + service.getDetail(id).then( | |
| 160 | + function(result) { | |
| 161 | + var key; | |
| 162 | + for (key in result) { | |
| 163 | + self.TimeTableDetailForSave[key] = result[key]; | |
| 164 | + } | |
| 165 | + | |
| 166 | + self.title2 = | |
| 167 | + self.xlname + "(" + self.ttname + ")" + "时刻表明细信息" + | |
| 168 | + "->路牌" + self.TimeTableDetailForSave.lp.lpName + | |
| 169 | + "->发车顺序号" + self.TimeTableDetailForSave.fcno + | |
| 170 | + "->班次详细信息"; | |
| 171 | + | |
| 172 | + }, | |
| 173 | + function(result) { | |
| 174 | + alert("出错啦!"); | |
| 175 | + } | |
| 176 | + ); | |
| 177 | + } | |
| 178 | + | |
| 179 | + // 提交方法 | |
| 180 | + self.submit = function() { | |
| 181 | + console.log(self.TimeTableDetailForSave); | |
| 182 | + //if (self.busInfoForSave) { | |
| 183 | + // delete $stateParams.id; | |
| 184 | + //} | |
| 185 | + service.saveDetail(self.TimeTableDetailForSave).then( | |
| 186 | + function(result) { | |
| 187 | + // TODO:弹出框方式以后改 | |
| 188 | + if (result.status == 'SUCCESS') { | |
| 189 | + //alert("保存成功!"); | |
| 190 | + $state.go("ttInfoDetailManage_edit", { | |
| 191 | + xlid: self.xlid, | |
| 192 | + ttid: self.ttid, | |
| 193 | + xlname: self.xlname, | |
| 194 | + ttname: self.ttname | |
| 195 | + }); | |
| 196 | + } else { | |
| 197 | + alert("保存异常!"); | |
| 198 | + } | |
| 199 | + }, | |
| 200 | + function(result) { | |
| 201 | + // TODO:弹出框方式以后改 | |
| 202 | + alert("出错啦!"); | |
| 203 | + } | |
| 204 | + ); | |
| 205 | + }; | |
| 206 | + | |
| 207 | +}]); | |
| 0 | 208 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage/detail.html
0 → 100644
| 1 | +<div class="page-head"> | |
| 2 | + <div class="page-title"> | |
| 3 | + <h1>时刻表管理2</h1> | |
| 4 | + </div> | |
| 5 | +</div> | |
| 6 | + | |
| 7 | +<ul class="page-breadcrumb breadcrumb"> | |
| 8 | + <li> | |
| 9 | + <a href="/pages/home.html" data-pjax>首页</a> | |
| 10 | + <i class="fa fa-circle"></i> | |
| 11 | + </li> | |
| 12 | + <li> | |
| 13 | + <span class="active">运营计划管理</span> | |
| 14 | + <i class="fa fa-circle"></i> | |
| 15 | + </li> | |
| 16 | + <li> | |
| 17 | + <a ui-sref="ttInfoManage">时刻表管理</a> | |
| 18 | + <i class="fa fa-circle"></i> | |
| 19 | + </li> | |
| 20 | + <li> | |
| 21 | + <span class="active">时刻表基础信息</span> | |
| 22 | + </li> | |
| 23 | +</ul> | |
| 24 | + | |
| 25 | +<div class="portlet light bordered" ng-controller="TtInfoManageDetailCtrl as ctrl"> | |
| 26 | + <div class="portlet-title"> | |
| 27 | + <div class="caption"> | |
| 28 | + <i class="icon-equalizer font-red-sunglo"></i> <span | |
| 29 | + class="caption-subject font-red-sunglo bold uppercase" | |
| 30 | + ng-bind="ctrl.title"></span> | |
| 31 | + </div> | |
| 32 | + </div> | |
| 33 | + | |
| 34 | + <div class="portlet-body form"> | |
| 35 | + <form class="form-horizontal" novalidate name="myForm"> | |
| 36 | + <!--<div class="alert alert-danger display-hide">--> | |
| 37 | + <!--<button class="close" data-close="alert"></button>--> | |
| 38 | + <!--您的输入有误,请检查下面的输入项--> | |
| 39 | + <!--</div>--> | |
| 40 | + | |
| 41 | + | |
| 42 | + <!-- 其他信息放置在这里 --> | |
| 43 | + <div class="form-body"> | |
| 44 | + <div class="form-group has-success has-feedback"> | |
| 45 | + <label class="col-md-2 control-label">线路*:</label> | |
| 46 | + <div class="col-md-4"> | |
| 47 | + <input type="text" class="form-control" | |
| 48 | + name="xl" ng-model="ctrl.ttInfoManageForDetail.xl.name" readonly/> | |
| 49 | + </div> | |
| 50 | + </div> | |
| 51 | + | |
| 52 | + <div class="form-group has-success has-feedback"> | |
| 53 | + <label class="col-md-2 control-label">线路走向*:</label> | |
| 54 | + <div class="col-md-4"> | |
| 55 | + <sa-Radiogroup model="ctrl.ttInfoManageForDetail.xlDir" dicgroup="LineTrend2" name="xlDir" disabled="true"></sa-Radiogroup> | |
| 56 | + </div> | |
| 57 | + </div> | |
| 58 | + | |
| 59 | + <div class="form-group has-success has-feedback"> | |
| 60 | + <label class="col-md-2 control-label">时刻表名字*:</label> | |
| 61 | + <div class="col-md-4"> | |
| 62 | + <input type="text" class="form-control" | |
| 63 | + name="name" ng-model="ctrl.ttInfoManageForDetail.name" readonly/> | |
| 64 | + </div> | |
| 65 | + </div> | |
| 66 | + | |
| 67 | + <div class="form-group has-success has-feedback"> | |
| 68 | + <label class="col-md-2 control-label">启用日期*:</label> | |
| 69 | + <div class="col-md-4"> | |
| 70 | + <input type="text" class="form-control" | |
| 71 | + name="qyrq" uib-datepicker-popup="yyyy年MM月dd日" | |
| 72 | + ng-model="ctrl.ttInfoManageForDetail.qyrq" readonly/> | |
| 73 | + </div> | |
| 74 | + </div> | |
| 75 | + | |
| 76 | + <div class="form-group has-success has-feedback"> | |
| 77 | + <label class="col-md-2 control-label">是否启用*:</label> | |
| 78 | + <div class="col-md-4"> | |
| 79 | + <sa-Radiogroup model="ctrl.ttInfoManageForDetail.isEnableDisTemplate" dicgroup="truefalseType" name="isEnableDisTemplate" disabled="true"></sa-Radiogroup> | |
| 80 | + </div> | |
| 81 | + | |
| 82 | + </div> | |
| 83 | + | |
| 84 | + <div class="form-group"> | |
| 85 | + <label class="col-md-2 control-label">路牌数量:</label> | |
| 86 | + <div class="col-md-4"> | |
| 87 | + <input type="number" class="form-control" ng-value="ctrl.ttInfoManageForDetail.lpCount" | |
| 88 | + name="lpCount" placeholder="请输入路牌数" min="1" readonly/> | |
| 89 | + </div> | |
| 90 | + </div> | |
| 91 | + | |
| 92 | + <div class="form-group"> | |
| 93 | + <label class="col-md-2 control-label">营运圈数:</label> | |
| 94 | + <div class="col-md-4"> | |
| 95 | + <input type="number" class="form-control" ng-value="ctrl.ttInfoManageForDetail.loopCount" | |
| 96 | + name="loopCount" placeholder="请输入圈数" min="1" readonly/> | |
| 97 | + </div> | |
| 98 | + </div> | |
| 99 | + | |
| 100 | + <div class="form-group"> | |
| 101 | + <label class="col-md-2 control-label">停车场:</label> | |
| 102 | + <div class="col-md-4"> | |
| 103 | + <input type="text" class="form-control" ng-value="ctrl.ttInfoManageForDetail.xl.carParkCode | dict:'CarPark':'未知' " | |
| 104 | + name="carParkCode" readonly/> | |
| 105 | + </div> | |
| 106 | + </div> | |
| 107 | + | |
| 108 | + <div class="form-group"> | |
| 109 | + <label class="col-md-2 control-label">常规有效日:</label> | |
| 110 | + <div class="col-md-6"> | |
| 111 | + <sa-Checkboxgroup model="ctrl.timeTableManageForForm" | |
| 112 | + name="rule_days" | |
| 113 | + dcvalue="{{ctrl.ttInfoManageForDetail.rule_days}}" | |
| 114 | + disabled > | |
| 115 | + </sa-Checkboxgroup> | |
| 116 | + </div> | |
| 117 | + </div> | |
| 118 | + | |
| 119 | + <div class="form-group"> | |
| 120 | + <label class="col-md-2 control-label">特殊有效日:</label> | |
| 121 | + <div class="col-md-6"> | |
| 122 | + <sa-Dategroup model="ctrl.ttInfoManageForDetail" | |
| 123 | + name="special_days" | |
| 124 | + dcvalue="{{ctrl.timeTableManageForDetail.special_days}}" | |
| 125 | + disabled | |
| 126 | + > | |
| 127 | + </sa-Dategroup> | |
| 128 | + </div> | |
| 129 | + </div> | |
| 130 | + | |
| 131 | + <!--<div class="form-group">--> | |
| 132 | + <!--<label class="col-md-2 control-label">备注:</label>--> | |
| 133 | + <!--</div>--> | |
| 134 | + | |
| 135 | + <div class="form-group"> | |
| 136 | + <label class="col-md-2 control-label">创建人:</label> | |
| 137 | + <div class="col-md-4"> | |
| 138 | + <input type="text" class="form-control" ng-value="ctrl.ttInfoManageForDetail.createBy.name" | |
| 139 | + name="createBy" readonly/> | |
| 140 | + </div> | |
| 141 | + </div> | |
| 142 | + | |
| 143 | + <div class="form-group"> | |
| 144 | + <label class="col-md-2 control-label">创建时间:</label> | |
| 145 | + <div class="col-md-4"> | |
| 146 | + <input type="text" class="form-control" ng-model="ctrl.ttInfoManageForDetail.createDate" | |
| 147 | + name="createDate" uib-datepicker-popup="yyyy年MM月dd日 hh:mm:ss" | |
| 148 | + readonly/> | |
| 149 | + </div> | |
| 150 | + </div> | |
| 151 | + | |
| 152 | + <div class="form-group"> | |
| 153 | + <label class="col-md-2 control-label">更新人:</label> | |
| 154 | + <div class="col-md-4"> | |
| 155 | + <input type="text" class="form-control" ng-value="ctrl.ttInfoManageForDetail.updateBy.name" | |
| 156 | + name="updateBy" readonly/> | |
| 157 | + </div> | |
| 158 | + </div> | |
| 159 | + | |
| 160 | + <div class="form-group"> | |
| 161 | + <label class="col-md-2 control-label">更新时间:</label> | |
| 162 | + <div class="col-md-4"> | |
| 163 | + <input type="text" class="form-control" ng-model="ctrl.ttInfoManageForDetail.updateDate" | |
| 164 | + name="updateDate" uib-datepicker-popup="yyyy年MM月dd日 hh:mm:ss" | |
| 165 | + readonly/> | |
| 166 | + </div> | |
| 167 | + </div> | |
| 168 | + | |
| 169 | + <!-- 其他form-group --> | |
| 170 | + | |
| 171 | + </div> | |
| 172 | + | |
| 173 | + </form> | |
| 174 | + | |
| 175 | + </div> | |
| 176 | + | |
| 177 | + | |
| 178 | +</div> | |
| 0 | 179 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage/edit.html
0 → 100644
| 1 | +<div class="page-head"> | |
| 2 | + <div class="page-title"> | |
| 3 | + <h1>时刻表管理2</h1> | |
| 4 | + </div> | |
| 5 | +</div> | |
| 6 | + | |
| 7 | +<ul class="page-breadcrumb breadcrumb"> | |
| 8 | + <li> | |
| 9 | + <a href="/pages/home.html" data-pjax>首页</a> | |
| 10 | + <i class="fa fa-circle"></i> | |
| 11 | + </li> | |
| 12 | + <li> | |
| 13 | + <span class="active">运营计划管理</span> | |
| 14 | + <i class="fa fa-circle"></i> | |
| 15 | + </li> | |
| 16 | + <li> | |
| 17 | + <a ui-sref="ttInfoManage">时刻表管理</a> | |
| 18 | + <i class="fa fa-circle"></i> | |
| 19 | + </li> | |
| 20 | + <li> | |
| 21 | + <span class="active">修改时刻表基础信息</span> | |
| 22 | + </li> | |
| 23 | +</ul> | |
| 24 | + | |
| 25 | +<div class="portlet light bordered" ng-controller="TtInfoManageFormCtrl as ctrl"> | |
| 26 | + <div class="portlet-title"> | |
| 27 | + <div class="caption"> | |
| 28 | + <i class="icon-equalizer font-red-sunglo"></i> <span | |
| 29 | + class="caption-subject font-red-sunglo bold uppercase">表单</span> | |
| 30 | + </div> | |
| 31 | + </div> | |
| 32 | + | |
| 33 | + <div class="portlet-body form"> | |
| 34 | + <form ng-submit="ctrl.submit()" class="form-horizontal" novalidate name="myForm"> | |
| 35 | + <!--<div class="alert alert-danger display-hide">--> | |
| 36 | + <!--<button class="close" data-close="alert"></button>--> | |
| 37 | + <!--您的输入有误,请检查下面的输入项--> | |
| 38 | + <!--</div>--> | |
| 39 | + | |
| 40 | + | |
| 41 | + <!-- 其他信息放置在这里 --> | |
| 42 | + <div class="form-body"> | |
| 43 | + <div class="form-group has-success has-feedback"> | |
| 44 | + <label class="col-md-2 control-label">线路*:</label> | |
| 45 | + <div class="col-md-3"> | |
| 46 | + <sa-Select5 name="xl" | |
| 47 | + model="ctrl.ttInfoManageForForm" | |
| 48 | + cmaps="{'xl.id' : 'id'}" | |
| 49 | + dcname="xl.id" | |
| 50 | + icname="id" | |
| 51 | + dsparams="{{ {type: 'ajax', param:{type: 'all'}, atype:'xl' } | json }}" | |
| 52 | + iterobjname="item" | |
| 53 | + iterobjexp="item.name" | |
| 54 | + searchph="请输拼音..." | |
| 55 | + searchexp="this.name" | |
| 56 | + required > | |
| 57 | + </sa-Select5> | |
| 58 | + </div> | |
| 59 | + <!-- 隐藏块,显示验证信息 --> | |
| 60 | + <div class="alert alert-danger well-sm" ng-show="myForm.xl.$error.required"> | |
| 61 | + 线路必须选择 | |
| 62 | + </div> | |
| 63 | + </div> | |
| 64 | + | |
| 65 | + <div class="form-group has-success has-feedback"> | |
| 66 | + <label class="col-md-2 control-label">线路走向*:</label> | |
| 67 | + <div class="col-md-3"> | |
| 68 | + <sa-Radiogroup model="ctrl.ttInfoManageForForm.xlDir" dicgroup="LineTrend2" name="xlDir" required></sa-Radiogroup> | |
| 69 | + </div> | |
| 70 | + <!-- 隐藏块,显示验证信息 --> | |
| 71 | + <div class="alert alert-danger well-sm" ng-show="myForm.xlDir.$error.required"> | |
| 72 | + 线路走向必须填写 | |
| 73 | + </div> | |
| 74 | + </div> | |
| 75 | + | |
| 76 | + <div class="form-group has-success has-feedback"> | |
| 77 | + <label class="col-md-2 control-label">时刻表名字*:</label> | |
| 78 | + <div class="col-md-3"> | |
| 79 | + <input type="text" class="form-control" ng-model="ctrl.ttInfoManageForForm.name" | |
| 80 | + name="name" placeholder="请输入时刻表名字..." required | |
| 81 | + remote-Validation | |
| 82 | + remotevtype="ttc1" | |
| 83 | + remotevparam="{{ {'xl.id_eq': ctrl.ttInfoManageForForm.xl.id, 'name_eq': ctrl.ttInfoManageForForm.name} | json}}" | |
| 84 | + /> | |
| 85 | + </div> | |
| 86 | + | |
| 87 | + <!-- 隐藏块,显示验证信息 --> | |
| 88 | + <div class="alert alert-danger well-sm" ng-show="myForm.name.$error.required"> | |
| 89 | + 时刻表名字必须填写 | |
| 90 | + </div> | |
| 91 | + <div class="alert alert-danger well-sm" ng-show="myForm.name.$error.remote"> | |
| 92 | + 相同线路下的时刻表不能同名 | |
| 93 | + </div> | |
| 94 | + </div> | |
| 95 | + | |
| 96 | + <div class="form-group has-success has-feedback"> | |
| 97 | + <label class="col-md-2 control-label">启用日期*:</label> | |
| 98 | + <div class="col-md-3"> | |
| 99 | + <div class="input-group"> | |
| 100 | + <input type="text" class="form-control" | |
| 101 | + name="qyrq" placeholder="请选择启用日期..." | |
| 102 | + uib-datepicker-popup="yyyy年MM月dd日" | |
| 103 | + is-open="ctrl.qyrqOpen" | |
| 104 | + ng-model="ctrl.ttInfoManageForForm.qyrq" readonly required/> | |
| 105 | + <span class="input-group-btn"> | |
| 106 | + <button type="button" class="btn btn-default" ng-click="ctrl.qyrq_open()"> | |
| 107 | + <i class="glyphicon glyphicon-calendar"></i> | |
| 108 | + </button> | |
| 109 | + </span> | |
| 110 | + </div> | |
| 111 | + </div> | |
| 112 | + | |
| 113 | + <!-- 隐藏块,显示验证信息 --> | |
| 114 | + <div class="alert alert-danger well-sm" ng-show="myForm.qyrq.$error.required"> | |
| 115 | + 启用日期必须填写 | |
| 116 | + </div> | |
| 117 | + </div> | |
| 118 | + | |
| 119 | + <div class="form-group has-success has-feedback"> | |
| 120 | + <label class="col-md-2 control-label">是否启用*:</label> | |
| 121 | + <div class="col-md-3"> | |
| 122 | + <sa-Radiogroup model="ctrl.ttInfoManageForForm.isEnableDisTemplate" dicgroup="truefalseType" name="isEnableDisTemplate" required></sa-Radiogroup> | |
| 123 | + </div> | |
| 124 | + | |
| 125 | + <!-- 隐藏块,显示验证信息 --> | |
| 126 | + <div class="alert alert-danger well-sm" ng-show="myForm.isEnableDisTemplate.$error.required"> | |
| 127 | + 是否启用必须选择 | |
| 128 | + </div> | |
| 129 | + | |
| 130 | + </div> | |
| 131 | + | |
| 132 | + <div class="form-group"> | |
| 133 | + <label class="col-md-2 control-label">路牌数量:</label> | |
| 134 | + <div class="col-md-3"> | |
| 135 | + <input type="number" class="form-control" ng-model="ctrl.ttInfoManageForForm.lpCount" | |
| 136 | + name="lpCount" placeholder="请输入路牌数..." min="1"/> | |
| 137 | + </div> | |
| 138 | + <div class="alert alert-danger well-sm" ng-show="myForm.lpCount.$error.number"> | |
| 139 | + 必须输入数字 | |
| 140 | + </div> | |
| 141 | + <div class="alert alert-danger well-sm" ng-show="myForm.lpCount.$error.min"> | |
| 142 | + 路爬数量必须大于1 | |
| 143 | + </div> | |
| 144 | + </div> | |
| 145 | + | |
| 146 | + <div class="form-group"> | |
| 147 | + <label class="col-md-2 control-label">营运圈数:</label> | |
| 148 | + <div class="col-md-3"> | |
| 149 | + <input type="number" class="form-control" ng-model="ctrl.ttInfoManageForForm.loopCount" | |
| 150 | + name="loopCount" placeholder="请输入圈数..." min="1"/> | |
| 151 | + </div> | |
| 152 | + <div class="alert alert-danger well-sm" ng-show="myForm.loopCount.$error.number"> | |
| 153 | + 必须输入数字 | |
| 154 | + </div> | |
| 155 | + <div class="alert alert-danger well-sm" ng-show="myForm.loopCount.$error.min"> | |
| 156 | + 营运圈数必须大于1 | |
| 157 | + </div> | |
| 158 | + </div> | |
| 159 | + | |
| 160 | + <div class="form-group"> | |
| 161 | + <label class="col-md-2 control-label">常规有效日:</label> | |
| 162 | + <div class="col-md-6"> | |
| 163 | + <sa-Checkboxgroup model="ctrl.ttInfoManageForForm" | |
| 164 | + name="rule_days" | |
| 165 | + dcvalue="{{ctrl.ttInfoManageForForm.rule_days}}" | |
| 166 | + dcname="rule_days" | |
| 167 | + required > | |
| 168 | + </sa-Checkboxgroup> | |
| 169 | + </div> | |
| 170 | + <div class="alert alert-danger well-sm" ng-show="myForm.rule_days.$error.required"> | |
| 171 | + 请操作一下1 | |
| 172 | + </div> | |
| 173 | + </div> | |
| 174 | + | |
| 175 | + <div class="form-group"> | |
| 176 | + <label class="col-md-2 control-label">特殊有效日:</label> | |
| 177 | + <div class="col-md-6"> | |
| 178 | + <sa-Dategroup model="ctrl.ttInfoManageForForm" | |
| 179 | + name="special_days" | |
| 180 | + dcvalue="{{ctrl.ttInfoManageForForm.special_days}}" | |
| 181 | + dcname="special_days" | |
| 182 | + > | |
| 183 | + </sa-Dategroup> | |
| 184 | + </div> | |
| 185 | + <div class="alert alert-danger well-sm" ng-show="myForm.special_days.$error.required"> | |
| 186 | + 请操作一下2 | |
| 187 | + </div> | |
| 188 | + </div> | |
| 189 | + | |
| 190 | + <!--<div class="form-group">--> | |
| 191 | + <!--<label class="col-md-2 control-label">备注:</label>--> | |
| 192 | + <!--</div>--> | |
| 193 | + | |
| 194 | + <!-- 其他form-group --> | |
| 195 | + | |
| 196 | + </div> | |
| 197 | + | |
| 198 | + <!-- TODO:!myForm.$valid 在这里有点问题,改用以下方法验证 --> | |
| 199 | + <div class="form-actions"> | |
| 200 | + <div class="row"> | |
| 201 | + <div class="col-md-offset-3 col-md-4"> | |
| 202 | + <button type="submit" class="btn green" | |
| 203 | + ng-disabled="!myForm.$valid"><i class="fa fa-check"></i> 提交</button> | |
| 204 | + <a type="button" class="btn default" ui-sref="ttInfoManage" ><i class="fa fa-times"></i> 取消</a> | |
| 205 | + </div> | |
| 206 | + </div> | |
| 207 | + </div> | |
| 208 | + | |
| 209 | + </form> | |
| 210 | + | |
| 211 | + </div> | |
| 212 | + | |
| 213 | + | |
| 214 | +</div> | |
| 0 | 215 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage/form.html
0 → 100644
| 1 | +<div class="page-head"> | |
| 2 | + <div class="page-title"> | |
| 3 | + <h1>时刻表管理2</h1> | |
| 4 | + </div> | |
| 5 | +</div> | |
| 6 | + | |
| 7 | +<ul class="page-breadcrumb breadcrumb"> | |
| 8 | + <li> | |
| 9 | + <a href="/pages/home.html" data-pjax>首页</a> | |
| 10 | + <i class="fa fa-circle"></i> | |
| 11 | + </li> | |
| 12 | + <li> | |
| 13 | + <span class="active">运营计划管理</span> | |
| 14 | + <i class="fa fa-circle"></i> | |
| 15 | + </li> | |
| 16 | + <li> | |
| 17 | + <a ui-sref="ttInfoManage">时刻表管理</a> | |
| 18 | + <i class="fa fa-circle"></i> | |
| 19 | + </li> | |
| 20 | + <li> | |
| 21 | + <span class="active">添加时刻表基础信息</span> | |
| 22 | + </li> | |
| 23 | +</ul> | |
| 24 | + | |
| 25 | +<div class="portlet light bordered" ng-controller="TtInfoManageFormCtrl as ctrl"> | |
| 26 | + <div class="portlet-title"> | |
| 27 | + <div class="caption"> | |
| 28 | + <i class="icon-equalizer font-red-sunglo"></i> <span | |
| 29 | + class="caption-subject font-red-sunglo bold uppercase">表单</span> | |
| 30 | + </div> | |
| 31 | + </div> | |
| 32 | + | |
| 33 | + <div class="portlet-body form"> | |
| 34 | + <form ng-submit="ctrl.submit()" class="form-horizontal" novalidate name="myForm"> | |
| 35 | + <!--<div class="alert alert-danger display-hide">--> | |
| 36 | + <!--<button class="close" data-close="alert"></button>--> | |
| 37 | + <!--您的输入有误,请检查下面的输入项--> | |
| 38 | + <!--</div>--> | |
| 39 | + | |
| 40 | + | |
| 41 | + <!-- 其他信息放置在这里 --> | |
| 42 | + <div class="form-body"> | |
| 43 | + <div class="form-group has-success has-feedback"> | |
| 44 | + <label class="col-md-2 control-label">线路*:</label> | |
| 45 | + <div class="col-md-3"> | |
| 46 | + <sa-Select5 name="xl" | |
| 47 | + model="ctrl.ttInfoManageForForm" | |
| 48 | + cmaps="{'xl.id' : 'id'}" | |
| 49 | + dcname="xl.id" | |
| 50 | + icname="id" | |
| 51 | + dsparams="{{ {type: 'ajax', param:{type: 'all'}, atype:'xl' } | json }}" | |
| 52 | + iterobjname="item" | |
| 53 | + iterobjexp="item.name" | |
| 54 | + searchph="请输拼音..." | |
| 55 | + searchexp="this.name" | |
| 56 | + required > | |
| 57 | + </sa-Select5> | |
| 58 | + </div> | |
| 59 | + <!-- 隐藏块,显示验证信息 --> | |
| 60 | + <div class="alert alert-danger well-sm" ng-show="myForm.xl.$error.required"> | |
| 61 | + 线路必须选择 | |
| 62 | + </div> | |
| 63 | + </div> | |
| 64 | + | |
| 65 | + <div class="form-group has-success has-feedback"> | |
| 66 | + <label class="col-md-2 control-label">线路走向*:</label> | |
| 67 | + <div class="col-md-3"> | |
| 68 | + <sa-Radiogroup model="ctrl.ttInfoManageForForm.xlDir" dicgroup="LineTrend2" name="xlDir" required></sa-Radiogroup> | |
| 69 | + </div> | |
| 70 | + <!-- 隐藏块,显示验证信息 --> | |
| 71 | + <div class="alert alert-danger well-sm" ng-show="myForm.xlDir.$error.required"> | |
| 72 | + 线路走向必须填写 | |
| 73 | + </div> | |
| 74 | + </div> | |
| 75 | + | |
| 76 | + <div class="form-group has-success has-feedback"> | |
| 77 | + <label class="col-md-2 control-label">时刻表名字*:</label> | |
| 78 | + <div class="col-md-3"> | |
| 79 | + <input type="text" class="form-control" ng-model="ctrl.ttInfoManageForForm.name" | |
| 80 | + name="name" placeholder="请输入时刻表名字..." required | |
| 81 | + remote-Validation | |
| 82 | + remotevtype="ttc1" | |
| 83 | + remotevparam="{{ {'xl.id_eq': ctrl.ttInfoManageForForm.xl.id, 'name_eq': ctrl.ttInfoManageForForm.name} | json}}" | |
| 84 | + /> | |
| 85 | + </div> | |
| 86 | + | |
| 87 | + <!-- 隐藏块,显示验证信息 --> | |
| 88 | + <div class="alert alert-danger well-sm" ng-show="myForm.name.$error.required"> | |
| 89 | + 时刻表名字必须填写 | |
| 90 | + </div> | |
| 91 | + <div class="alert alert-danger well-sm" ng-show="myForm.name.$error.remote"> | |
| 92 | + 相同线路下的时刻表不能同名 | |
| 93 | + </div> | |
| 94 | + </div> | |
| 95 | + | |
| 96 | + <div class="form-group has-success has-feedback"> | |
| 97 | + <label class="col-md-2 control-label">启用日期*:</label> | |
| 98 | + <div class="col-md-3"> | |
| 99 | + <div class="input-group"> | |
| 100 | + <input type="text" class="form-control" | |
| 101 | + name="qyrq" placeholder="请选择启用日期..." | |
| 102 | + uib-datepicker-popup="yyyy年MM月dd日" | |
| 103 | + is-open="ctrl.qyrqOpen" | |
| 104 | + ng-model="ctrl.ttInfoManageForForm.qyrq" readonly required/> | |
| 105 | + <span class="input-group-btn"> | |
| 106 | + <button type="button" class="btn btn-default" ng-click="ctrl.qyrq_open()"> | |
| 107 | + <i class="glyphicon glyphicon-calendar"></i> | |
| 108 | + </button> | |
| 109 | + </span> | |
| 110 | + </div> | |
| 111 | + </div> | |
| 112 | + | |
| 113 | + <!-- 隐藏块,显示验证信息 --> | |
| 114 | + <div class="alert alert-danger well-sm" ng-show="myForm.qyrq.$error.required"> | |
| 115 | + 启用日期必须填写 | |
| 116 | + </div> | |
| 117 | + </div> | |
| 118 | + | |
| 119 | + <div class="form-group has-success has-feedback"> | |
| 120 | + <label class="col-md-2 control-label">是否启用*:</label> | |
| 121 | + <div class="col-md-3"> | |
| 122 | + <sa-Radiogroup model="ctrl.ttInfoManageForForm.isEnableDisTemplate" dicgroup="truefalseType" name="isEnableDisTemplate" required></sa-Radiogroup> | |
| 123 | + </div> | |
| 124 | + | |
| 125 | + <!-- 隐藏块,显示验证信息 --> | |
| 126 | + <div class="alert alert-danger well-sm" ng-show="myForm.isEnableDisTemplate.$error.required"> | |
| 127 | + 是否启用必须选择 | |
| 128 | + </div> | |
| 129 | + | |
| 130 | + </div> | |
| 131 | + | |
| 132 | + <div class="form-group"> | |
| 133 | + <label class="col-md-2 control-label">路牌数量:</label> | |
| 134 | + <div class="col-md-3"> | |
| 135 | + <input type="number" class="form-control" ng-model="ctrl.ttInfoManageForForm.lpCount" | |
| 136 | + name="lpCount" placeholder="请输入路牌数..." min="1"/> | |
| 137 | + </div> | |
| 138 | + <div class="alert alert-danger well-sm" ng-show="myForm.lpCount.$error.number"> | |
| 139 | + 必须输入数字 | |
| 140 | + </div> | |
| 141 | + <div class="alert alert-danger well-sm" ng-show="myForm.lpCount.$error.min"> | |
| 142 | + 路爬数量必须大于1 | |
| 143 | + </div> | |
| 144 | + </div> | |
| 145 | + | |
| 146 | + <div class="form-group"> | |
| 147 | + <label class="col-md-2 control-label">营运圈数:</label> | |
| 148 | + <div class="col-md-3"> | |
| 149 | + <input type="number" class="form-control" ng-model="ctrl.ttInfoManageForForm.loopCount" | |
| 150 | + name="loopCount" placeholder="请输入圈数..." min="1"/> | |
| 151 | + </div> | |
| 152 | + <div class="alert alert-danger well-sm" ng-show="myForm.loopCount.$error.number"> | |
| 153 | + 必须输入数字 | |
| 154 | + </div> | |
| 155 | + <div class="alert alert-danger well-sm" ng-show="myForm.loopCount.$error.min"> | |
| 156 | + 营运圈数必须大于1 | |
| 157 | + </div> | |
| 158 | + </div> | |
| 159 | + | |
| 160 | + <div class="form-group"> | |
| 161 | + <label class="col-md-2 control-label">常规有效日:</label> | |
| 162 | + <div class="col-md-6"> | |
| 163 | + <sa-Checkboxgroup model="ctrl.ttInfoManageForForm" | |
| 164 | + name="rule_days" | |
| 165 | + dcvalue="{{ctrl.ttInfoManageForForm.rule_days}}" | |
| 166 | + dcname="rule_days" | |
| 167 | + required > | |
| 168 | + </sa-Checkboxgroup> | |
| 169 | + </div> | |
| 170 | + <div class="alert alert-danger well-sm" ng-show="myForm.rule_days.$error.required"> | |
| 171 | + 请操作一下1 | |
| 172 | + </div> | |
| 173 | + </div> | |
| 174 | + | |
| 175 | + <div class="form-group"> | |
| 176 | + <label class="col-md-2 control-label">特殊有效日:</label> | |
| 177 | + <div class="col-md-6"> | |
| 178 | + <sa-Dategroup model="ctrl.ttInfoManageForForm" | |
| 179 | + name="special_days" | |
| 180 | + dcvalue="{{ctrl.ttInfoManageForForm.special_days}}" | |
| 181 | + dcname="special_days" | |
| 182 | + > | |
| 183 | + </sa-Dategroup> | |
| 184 | + </div> | |
| 185 | + <div class="alert alert-danger well-sm" ng-show="myForm.special_days.$error.required"> | |
| 186 | + 请操作一下2 | |
| 187 | + </div> | |
| 188 | + </div> | |
| 189 | + | |
| 190 | + <!--<div class="form-group">--> | |
| 191 | + <!--<label class="col-md-2 control-label">备注:</label>--> | |
| 192 | + <!--</div>--> | |
| 193 | + | |
| 194 | + <!-- 其他form-group --> | |
| 195 | + | |
| 196 | + </div> | |
| 197 | + | |
| 198 | + <!-- TODO:!myForm.$valid 在这里有点问题,改用以下方法验证 --> | |
| 199 | + <div class="form-actions"> | |
| 200 | + <div class="row"> | |
| 201 | + <div class="col-md-offset-3 col-md-4"> | |
| 202 | + <button type="submit" class="btn green" | |
| 203 | + ng-disabled="!myForm.$valid"><i class="fa fa-check"></i> 提交</button> | |
| 204 | + <a type="button" class="btn default" ui-sref="ttInfoManage" ><i class="fa fa-times"></i> 取消</a> | |
| 205 | + </div> | |
| 206 | + </div> | |
| 207 | + </div> | |
| 208 | + | |
| 209 | + </form> | |
| 210 | + | |
| 211 | + </div> | |
| 212 | + | |
| 213 | + | |
| 214 | +</div> | |
| 0 | 215 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage/index.html
0 → 100644
| 1 | +<div class="page-head"> | |
| 2 | + <div class="page-title"> | |
| 3 | + <h1>时刻表管理2</h1> | |
| 4 | + </div> | |
| 5 | +</div> | |
| 6 | + | |
| 7 | +<ul class="page-breadcrumb breadcrumb"> | |
| 8 | + <li> | |
| 9 | + <a href="/pages/home.html" data-pjax>首页</a> | |
| 10 | + <i class="fa fa-circle"></i> | |
| 11 | + </li> | |
| 12 | + <li> | |
| 13 | + <span class="active">运营计划管理</span> | |
| 14 | + <i class="fa fa-circle"></i> | |
| 15 | + </li> | |
| 16 | + <li> | |
| 17 | + <span class="active">时刻表管理</span> | |
| 18 | + </li> | |
| 19 | +</ul> | |
| 20 | + | |
| 21 | +<div class="row"> | |
| 22 | + <div class="col-md-12" ng-controller="TtInfoManageIndexCtrl as ctrl"> | |
| 23 | + <div class="portlet light bordered"> | |
| 24 | + <div class="portlet-title"> | |
| 25 | + <div class="caption font-dark"> | |
| 26 | + <i class="fa fa-database font-dark"></i> | |
| 27 | + <span class="caption-subject bold uppercase">时刻表</span> | |
| 28 | + </div> | |
| 29 | + <div class="actions"> | |
| 30 | + <a href="javascirpt:" class="btn btn-circle blue" ng-click="ctrl.toTtInfoManageForm()"> | |
| 31 | + <i class="fa fa-plus"></i> | |
| 32 | + 添加时刻表 | |
| 33 | + </a> | |
| 34 | + | |
| 35 | + </div> | |
| 36 | + </div> | |
| 37 | + | |
| 38 | + <div class="portlet-body"> | |
| 39 | + <div ui-view="ttInfoManage_list"></div> | |
| 40 | + </div> | |
| 41 | + </div> | |
| 42 | + </div> | |
| 43 | +</div> | |
| 0 | 44 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage/list.html
0 → 100644
| 1 | +<!-- ui-route employeeInfoManage.list --> | |
| 2 | +<div ng-controller="TtInfoManageListCtrl as ctrl"> | |
| 3 | + <div class="fixDiv"> | |
| 4 | + <table class="fixTable table table-striped table-bordered table-hover table-checkable order-column"> | |
| 5 | + <thead> | |
| 6 | + <tr role="row" class="heading"> | |
| 7 | + <th style="width: 50px;">序号</th> | |
| 8 | + <th style="width: 150px;">线路</th> | |
| 9 | + <th style="width: 180px;">时刻表名称</th> | |
| 10 | + <th style="width: 100px">路牌数/圈数</th> | |
| 11 | + <th style="width: 80px">上下行</th> | |
| 12 | + <th style="width: 50px;">启用</th> | |
| 13 | + <th style="width: 120px">启用日期</th> | |
| 14 | + <th style="width: 50%">时刻表明细</th> | |
| 15 | + <th style="width: 50%">操作</th> | |
| 16 | + </tr> | |
| 17 | + <tr role="row" class="filter"> | |
| 18 | + <td></td> | |
| 19 | + <td> | |
| 20 | + <sa-Select3 model="ctrl.searchCondition()" | |
| 21 | + name="xl" | |
| 22 | + placeholder="请输拼音..." | |
| 23 | + dcvalue="{{ctrl.searchCondition()['xl.id_eq']}}" | |
| 24 | + dcname="xl.id_eq" | |
| 25 | + icname="id" | |
| 26 | + icnames="name" | |
| 27 | + datatype="xl"> | |
| 28 | + </sa-Select3> | |
| 29 | + </td> | |
| 30 | + <td> | |
| 31 | + <input type="text" class="form-control form-filter input-sm" ng-model="ctrl.searchCondition().name_like" placeholder="输入时刻表名称..."/> | |
| 32 | + </td> | |
| 33 | + <td></td> | |
| 34 | + <td></td> | |
| 35 | + <td></td> | |
| 36 | + <td></td> | |
| 37 | + <td></td> | |
| 38 | + <td> | |
| 39 | + <button class="btn btn-sm green btn-outline filter-submit margin-bottom" | |
| 40 | + ng-click="ctrl.doPage()"> | |
| 41 | + <i class="fa fa-search"></i> 搜索</button> | |
| 42 | + | |
| 43 | + <button class="btn btn-sm red btn-outline filter-cancel" | |
| 44 | + ng-click="ctrl.reset()"> | |
| 45 | + <i class="fa fa-times"></i> 重置</button> | |
| 46 | + </td> | |
| 47 | + </tr> | |
| 48 | + | |
| 49 | + </thead> | |
| 50 | + <tbody> | |
| 51 | + <tr ng-repeat="info in ctrl.page()['content']" ng-class="{odd: true, gradeX: true, danger: info.isCancel}"> | |
| 52 | + <td> | |
| 53 | + <span ng-bind="$index + 1"></span> | |
| 54 | + </td> | |
| 55 | + <td> | |
| 56 | + <span ng-bind="info.xl.name"></span> | |
| 57 | + </td> | |
| 58 | + <td> | |
| 59 | + <span ng-bind="info.name" title="{{info.name}}"></span> | |
| 60 | + </td> | |
| 61 | + <td> | |
| 62 | + <span ng-bind="info.lpCount"></span> | |
| 63 | + / | |
| 64 | + <span ng-bind="info.loopCount"></span> | |
| 65 | + </td> | |
| 66 | + <td> | |
| 67 | + <span ng-bind="info.xlDir | dict:'LineTrend2':'未知' "></span> | |
| 68 | + </td> | |
| 69 | + <td> | |
| 70 | + <span ng-bind="info.isEnableDisTemplate | dict:'truefalseType':'未知' "></span> | |
| 71 | + </td> | |
| 72 | + <td> | |
| 73 | + <span ng-bind="info.qyrq | date: 'yyyy-MM-dd'"></span> | |
| 74 | + </td> | |
| 75 | + <td> | |
| 76 | + <a ui-sref="ttInfoDetailManage_edit({xlid: info.xl.id, ttid : info.id, xlname: info.xl.name, ttname : info.name})" | |
| 77 | + class="btn btn-info btn-sm" ng-if="info.isCancel == '0'"> 编辑 </a> | |
| 78 | + <a ui-sref="ttInfoDetailManage_form({xlid: info.xl.id, ttid : info.id, xlname: info.xl.name, ttname : info.name})" | |
| 79 | + class="btn btn-info btn-sm" ng-if="info.isCancel == '0'"> 导入 </a> | |
| 80 | + <a href="javascript:" class="btn btn-info btn-sm"> 导出 </a> | |
| 81 | + </td> | |
| 82 | + <td> | |
| 83 | + <!--<a href="details.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 详细 </a>--> | |
| 84 | + <!--<a href="edit.html?lineId={{obj.id}}" class="btn default blue-stripe btn-sm"> 修改 </a>--> | |
| 85 | + <a ui-sref="ttInfoManage_detail({id: info.id})" class="btn btn-info btn-sm"> 详细 </a> | |
| 86 | + <a ui-sref="ttInfoManage_edit({id: info.id})" class="btn btn-info btn-sm" ng-if="info.isCancel == '0'"> 修改 </a> | |
| 87 | + <a ng-click="ctrl.toggleTtinfo(info.id)" class="btn btn-danger btn-sm" ng-if="info.isCancel == '0'"> 作废 </a> | |
| 88 | + <a ng-click="ctrl.toggleTtinfo(info.id)" class="btn btn-success btn-sm" ng-if="info.isCancel == '1'"> 撤销 </a> | |
| 89 | + </td> | |
| 90 | + </tr> | |
| 91 | + </tbody> | |
| 92 | + </table> | |
| 93 | + </div> | |
| 94 | + | |
| 95 | + <div style="text-align: right;"> | |
| 96 | + <uib-pagination total-items="ctrl.page()['totalElements']" | |
| 97 | + ng-model="ctrl.page()['uiNumber']" | |
| 98 | + ng-change="ctrl.doPage()" | |
| 99 | + rotate="false" | |
| 100 | + max-size="10" | |
| 101 | + boundary-links="true" | |
| 102 | + first-text="首页" | |
| 103 | + previous-text="上一页" | |
| 104 | + next-text="下一页" | |
| 105 | + last-text="尾页"> | |
| 106 | + </uib-pagination> | |
| 107 | + </div> | |
| 108 | +</div> | |
| 0 | 109 | \ No newline at end of file | ... | ... |
src/main/resources/static/pages/scheduleApp/module/core/ttInfoManage/main.js
0 → 100644
| 1 | +// 时刻表管理service,包装外部定义的globalservice,并保存一定的操作状态 | |
| 2 | +angular.module('ScheduleApp').factory( | |
| 3 | + 'TtInfoManageService', | |
| 4 | + [ | |
| 5 | + 'TimeTableManageService_g', | |
| 6 | + function(service) { | |
| 7 | + // 当前查询的内容条件搜索对象 | |
| 8 | + var currentSearchCondition = {page: 0}; | |
| 9 | + // 当前查询返回的信息 | |
| 10 | + var currentPage = { // 后台spring data返回的格式 | |
| 11 | + totalElements: 0, | |
| 12 | + number: 0, // 后台返回的页码,spring返回从0开始 | |
| 13 | + content: [], | |
| 14 | + | |
| 15 | + uiNumber: 1 // 页面绑定的页码 | |
| 16 | + }; | |
| 17 | + | |
| 18 | + // 查询对象类 | |
| 19 | + var queryClass = service.rest; | |
| 20 | + | |
| 21 | + return { | |
| 22 | + getTtInfoQueryClass: function() { | |
| 23 | + return queryClass; | |
| 24 | + }, | |
| 25 | + getSearchCondition: function() { | |
| 26 | + currentSearchCondition.page = currentPage.uiNumber - 1; | |
| 27 | + return currentSearchCondition; | |
| 28 | + }, | |
| 29 | + getPage: function(page) { | |
| 30 | + if (page) { | |
| 31 | + currentPage.totalElements = page.totalElements; | |
| 32 | + currentPage.number = page.number; | |
| 33 | + currentPage.content = page.content; | |
| 34 | + } | |
| 35 | + return currentPage; | |
| 36 | + }, | |
| 37 | + resetStatus: function() { | |
| 38 | + currentSearchCondition = {page: 0}; | |
| 39 | + currentPage = { | |
| 40 | + totalElements: 0, | |
| 41 | + number: 0, | |
| 42 | + content: [], | |
| 43 | + uiNumber: 1 | |
| 44 | + }; | |
| 45 | + } | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + // TODO: | |
| 50 | + } | |
| 51 | + } | |
| 52 | + ] | |
| 53 | +); | |
| 54 | + | |
| 55 | +// index.html控制器 | |
| 56 | +angular.module('ScheduleApp').controller( | |
| 57 | + 'TtInfoManageIndexCtrl', | |
| 58 | + [ | |
| 59 | + '$state', | |
| 60 | + function($state) { | |
| 61 | + var self = this; | |
| 62 | + | |
| 63 | + // 切换到时刻表form界面 | |
| 64 | + self.toTtInfoManageForm = function() { | |
| 65 | + $state.go('ttInfoManage_form'); | |
| 66 | + } | |
| 67 | + } | |
| 68 | + ] | |
| 69 | +); | |
| 70 | + | |
| 71 | +// list.html控制器 | |
| 72 | +angular.module('ScheduleApp').controller( | |
| 73 | + 'TtInfoManageListCtrl', | |
| 74 | + [ | |
| 75 | + 'TtInfoManageService', | |
| 76 | + function(service) { | |
| 77 | + var self = this; | |
| 78 | + var TtInfo = service.getTtInfoQueryClass(); | |
| 79 | + | |
| 80 | + self.page = function() { | |
| 81 | + return service.getPage(); | |
| 82 | + }; | |
| 83 | + | |
| 84 | + self.searchCondition = function() { | |
| 85 | + return service.getSearchCondition(); | |
| 86 | + }; | |
| 87 | + | |
| 88 | + self.doPage = function() { | |
| 89 | + var page = TtInfo.list(self.searchCondition(), function() { | |
| 90 | + service.getPage(page); | |
| 91 | + }); | |
| 92 | + }; | |
| 93 | + self.reset = function() { | |
| 94 | + service.resetStatus(); | |
| 95 | + var page = TtInfo.list(self.searchCondition(), function() { | |
| 96 | + service.getPage(page); | |
| 97 | + }); | |
| 98 | + }; | |
| 99 | + self.toggleTtinfo = function(id) { | |
| 100 | + TtInfo.delete({id: id}, function(result) { | |
| 101 | + if (result.message) { // 暂时这样做,之后全局拦截 | |
| 102 | + alert("失败:" + result.message); | |
| 103 | + } else { | |
| 104 | + self.doPage(); | |
| 105 | + } | |
| 106 | + }); | |
| 107 | + }; | |
| 108 | + | |
| 109 | + self.doPage(); | |
| 110 | + | |
| 111 | + // TODO: | |
| 112 | + } | |
| 113 | + ] | |
| 114 | +); | |
| 115 | + | |
| 116 | +// form.html控制器 | |
| 117 | +angular.module('ScheduleApp').controller( | |
| 118 | + 'TtInfoManageFormCtrl', | |
| 119 | + [ | |
| 120 | + 'TtInfoManageService', | |
| 121 | + '$stateParams', | |
| 122 | + '$state', | |
| 123 | + function(service, $stateParams, $state) { | |
| 124 | + var self = this; | |
| 125 | + var TtInfo = service.getTtInfoQueryClass(); | |
| 126 | + | |
| 127 | + // 启用日期 日期控件开关 | |
| 128 | + self.qyrqOpen = false; | |
| 129 | + self.qyrq_open = function() { | |
| 130 | + self.qyrqOpen = true; | |
| 131 | + }; | |
| 132 | + | |
| 133 | + // 欲保存的表单信息,双向绑定 | |
| 134 | + self.ttInfoManageForForm = new TtInfo; | |
| 135 | + self.ttInfoManageForForm.xl = {}; | |
| 136 | + | |
| 137 | + // 如果是修改,获取传过来的id,从后台获取一份数据,用于绑定页面form值 | |
| 138 | + var id = $stateParams.id; | |
| 139 | + if (id) { | |
| 140 | + TtInfo.get({id: id}, function(value) { | |
| 141 | + self.ttInfoManageForForm = value; | |
| 142 | + }); | |
| 143 | + } | |
| 144 | + // form提交方法 | |
| 145 | + self.submit = function() { | |
| 146 | + self.ttInfoManageForForm.$save(function() { | |
| 147 | + $state.go("ttInfoManage"); | |
| 148 | + }); | |
| 149 | + }; | |
| 150 | + } | |
| 151 | + ] | |
| 152 | +); | |
| 153 | + | |
| 154 | +// detail.html控制器 | |
| 155 | +angular.module('ScheduleApp').controller( | |
| 156 | + 'TtInfoManageDetailCtrl', | |
| 157 | + [ | |
| 158 | + 'TtInfoManageService', | |
| 159 | + '$stateParams', | |
| 160 | + function(service, $stateParams) { | |
| 161 | + var self = this; | |
| 162 | + var TtInfo = service.getTtInfoQueryClass(); | |
| 163 | + var id = $stateParams.id; | |
| 164 | + | |
| 165 | + self.title = ""; | |
| 166 | + self.ttInfoManageForDetail = {}; | |
| 167 | + | |
| 168 | + TtInfo.get({id: id}, function(value) { | |
| 169 | + self.ttInfoManageForDetail = value; | |
| 170 | + self.title = self.ttInfoManageForDetail.xl.name + | |
| 171 | + "(" + | |
| 172 | + self.ttInfoManageForDetail.name + | |
| 173 | + ")" + | |
| 174 | + "时刻表基础信息"; | |
| 175 | + }); | |
| 176 | + } | |
| 177 | + ] | |
| 178 | +); | |
| 0 | 179 | \ No newline at end of file | ... | ... |