Commit fa962ba4356132cc0e9dcfdaaec22762f320b43f
1 parent
f1ed06d5
update
Showing
13 changed files
with
178 additions
and
238 deletions
src/main/java/com/bsth/controller/CarsController.java
| @@ -2,7 +2,6 @@ package com.bsth.controller; | @@ -2,7 +2,6 @@ package com.bsth.controller; | ||
| 2 | 2 | ||
| 3 | import com.bsth.common.ResponseCode; | 3 | import com.bsth.common.ResponseCode; |
| 4 | import com.bsth.entity.Cars; | 4 | import com.bsth.entity.Cars; |
| 5 | -import com.bsth.service.CarsService; | ||
| 6 | import com.bsth.service.schedule.utils.DataImportExportService; | 5 | import com.bsth.service.schedule.utils.DataImportExportService; |
| 7 | import com.bsth.service.schedule.utils.DataToolsProperties; | 6 | import com.bsth.service.schedule.utils.DataToolsProperties; |
| 8 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -48,7 +47,8 @@ public class CarsController extends BaseController<Cars, Integer> { | @@ -48,7 +47,8 @@ public class CarsController extends BaseController<Cars, Integer> { | ||
| 48 | */ | 47 | */ |
| 49 | @RequestMapping(value = "/validate/equale", method = RequestMethod.GET) | 48 | @RequestMapping(value = "/validate/equale", method = RequestMethod.GET) |
| 50 | public Map<String, Object> validateData(@RequestParam Map<String, Object> map) { | 49 | public Map<String, Object> validateData(@RequestParam Map<String, Object> map) { |
| 51 | - return ((CarsService) baseService).validateEquale(map); | 50 | + // 一般比较自编号是否重复 |
| 51 | + return baseService.validateEquale(map); | ||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | // 上传图片 | 54 | // 上传图片 |
src/main/java/com/bsth/controller/PersonnelController.java
| 1 | package com.bsth.controller; | 1 | package com.bsth.controller; |
| 2 | 2 | ||
| 3 | import com.bsth.entity.Personnel; | 3 | import com.bsth.entity.Personnel; |
| 4 | -import org.springframework.web.bind.annotation.RequestBody; | ||
| 5 | -import org.springframework.web.bind.annotation.RequestMapping; | ||
| 6 | -import org.springframework.web.bind.annotation.RequestMethod; | ||
| 7 | -import org.springframework.web.bind.annotation.RestController; | 4 | +import org.springframework.web.bind.annotation.*; |
| 8 | 5 | ||
| 9 | import java.util.Map; | 6 | import java.util.Map; |
| 10 | 7 | ||
| @@ -27,4 +24,15 @@ public class PersonnelController extends BaseController<Personnel, Integer> { | @@ -27,4 +24,15 @@ public class PersonnelController extends BaseController<Personnel, Integer> { | ||
| 27 | public Map<String, Object> save(@RequestBody Personnel t){ | 24 | public Map<String, Object> save(@RequestBody Personnel t){ |
| 28 | return baseService.save(t); | 25 | return baseService.save(t); |
| 29 | } | 26 | } |
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 验证。 | ||
| 30 | + * @param map | ||
| 31 | + * @return | ||
| 32 | + */ | ||
| 33 | + @RequestMapping(value = "/validate/equale", method = RequestMethod.GET) | ||
| 34 | + public Map<String, Object> validateData(@RequestParam Map<String, Object> map) { | ||
| 35 | + // 一般比较相同公司下工号是否相同 | ||
| 36 | + return baseService.validateEquale(map); | ||
| 37 | + } | ||
| 30 | } | 38 | } |
src/main/java/com/bsth/entity/Personnel.java
| @@ -51,7 +51,7 @@ public class Personnel { | @@ -51,7 +51,7 @@ public class Personnel { | ||
| 51 | private String icCardCode; | 51 | private String icCardCode; |
| 52 | /** 性别(字典类型sexType) */ | 52 | /** 性别(字典类型sexType) */ |
| 53 | private String personnelType; | 53 | private String personnelType; |
| 54 | - /** 所属岗位/工种(TODO:暂时不使用字典) */ | 54 | + /** 所属岗位/工种(字典类型gzType) */ |
| 55 | private String posts; | 55 | private String posts; |
| 56 | 56 | ||
| 57 | 57 |
src/main/java/com/bsth/service/BaseService.java
| 1 | package com.bsth.service; | 1 | package com.bsth.service; |
| 2 | 2 | ||
| 3 | -import java.io.Serializable; | ||
| 4 | -import java.util.Map; | ||
| 5 | - | ||
| 6 | import org.springframework.data.domain.Page; | 3 | import org.springframework.data.domain.Page; |
| 7 | import org.springframework.data.domain.Pageable; | 4 | import org.springframework.data.domain.Pageable; |
| 8 | 5 | ||
| 6 | +import java.io.Serializable; | ||
| 7 | +import java.util.Map; | ||
| 8 | + | ||
| 9 | /** | 9 | /** |
| 10 | * | 10 | * |
| 11 | * @ClassName: BaseService | 11 | * @ClassName: BaseService |
| @@ -63,4 +63,11 @@ public interface BaseService<T, ID extends Serializable> { | @@ -63,4 +63,11 @@ public interface BaseService<T, ID extends Serializable> { | ||
| 63 | * @throws | 63 | * @throws |
| 64 | */ | 64 | */ |
| 65 | Map<String, Object> delete(ID id); | 65 | Map<String, Object> delete(ID id); |
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 后端验证查询数据是否重复。 | ||
| 69 | + * @param params 查询条件 | ||
| 70 | + * @return {status:状态编码,msg:错误描述},状态编码 @see com.bsth.common.ResponseCode | ||
| 71 | + */ | ||
| 72 | + Map<String, Object> validateEquale(Map<String, Object> params); | ||
| 66 | } | 73 | } |
src/main/java/com/bsth/service/CarsService.java
| @@ -2,16 +2,8 @@ package com.bsth.service; | @@ -2,16 +2,8 @@ package com.bsth.service; | ||
| 2 | 2 | ||
| 3 | import com.bsth.entity.Cars; | 3 | import com.bsth.entity.Cars; |
| 4 | 4 | ||
| 5 | -import java.util.Map; | ||
| 6 | - | ||
| 7 | /** | 5 | /** |
| 8 | * Created by xu on 16/5/31. | 6 | * Created by xu on 16/5/31. |
| 9 | */ | 7 | */ |
| 10 | public interface CarsService extends BaseService<Cars, Integer> { | 8 | public interface CarsService extends BaseService<Cars, Integer> { |
| 11 | - /** | ||
| 12 | - * 后端验证查询数据是否重复。 | ||
| 13 | - * @param params 查询条件 | ||
| 14 | - * @return {status:状态编码,msg:错误描述},状态编码 @see com.bsth.common.ResponseCode | ||
| 15 | - */ | ||
| 16 | - Map<String, Object> validateEquale(Map<String, Object> params); | ||
| 17 | } | 9 | } |
src/main/java/com/bsth/service/impl/BaseServiceImpl.java
| 1 | package com.bsth.service.impl; | 1 | package com.bsth.service.impl; |
| 2 | 2 | ||
| 3 | -import java.io.Serializable; | ||
| 4 | -import java.util.HashMap; | ||
| 5 | -import java.util.Map; | ||
| 6 | - | 3 | +import com.bsth.common.ResponseCode; |
| 4 | +import com.bsth.entity.search.CustomerSpecs; | ||
| 5 | +import com.bsth.repository.BaseRepository; | ||
| 6 | +import com.bsth.service.BaseService; | ||
| 7 | import org.slf4j.Logger; | 7 | import org.slf4j.Logger; |
| 8 | import org.slf4j.LoggerFactory; | 8 | import org.slf4j.LoggerFactory; |
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -11,10 +11,9 @@ import org.springframework.dao.DataIntegrityViolationException; | @@ -11,10 +11,9 @@ import org.springframework.dao.DataIntegrityViolationException; | ||
| 11 | import org.springframework.data.domain.Page; | 11 | import org.springframework.data.domain.Page; |
| 12 | import org.springframework.data.domain.Pageable; | 12 | import org.springframework.data.domain.Pageable; |
| 13 | 13 | ||
| 14 | -import com.bsth.common.ResponseCode; | ||
| 15 | -import com.bsth.entity.search.CustomerSpecs; | ||
| 16 | -import com.bsth.repository.BaseRepository; | ||
| 17 | -import com.bsth.service.BaseService; | 14 | +import java.io.Serializable; |
| 15 | +import java.util.HashMap; | ||
| 16 | +import java.util.Map; | ||
| 18 | 17 | ||
| 19 | public class BaseServiceImpl<T, ID extends Serializable> implements BaseService<T, ID>{ | 18 | public class BaseServiceImpl<T, ID extends Serializable> implements BaseService<T, ID>{ |
| 20 | 19 | ||
| @@ -70,4 +69,31 @@ public class BaseServiceImpl<T, ID extends Serializable> implements BaseService< | @@ -70,4 +69,31 @@ public class BaseServiceImpl<T, ID extends Serializable> implements BaseService< | ||
| 70 | } | 69 | } |
| 71 | return map; | 70 | return map; |
| 72 | } | 71 | } |
| 72 | + | ||
| 73 | + @Override | ||
| 74 | + public Map<String, Object> validateEquale(Map<String, Object> params) { | ||
| 75 | + Map<String, Object> returnMap = new HashMap<>(); | ||
| 76 | + | ||
| 77 | + try { | ||
| 78 | + if (params == null || params.size() == 0) { | ||
| 79 | + returnMap.put("status", ResponseCode.SUCCESS); | ||
| 80 | + returnMap.put("msg", "此时没有重复"); | ||
| 81 | + } else { | ||
| 82 | + Iterable<T> iterable = list(params); | ||
| 83 | + if (iterable.iterator().hasNext()) { | ||
| 84 | + returnMap.put("status", ResponseCode.ERROR); | ||
| 85 | + returnMap.put("msg", "数据重复"); | ||
| 86 | + } else { | ||
| 87 | + returnMap.put("status", ResponseCode.SUCCESS); | ||
| 88 | + returnMap.put("msg", "没有重复"); | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + } catch (Exception exp) { | ||
| 92 | + logger.error("validateEquale error", exp); | ||
| 93 | + returnMap.put("status", ResponseCode.ERROR); | ||
| 94 | + returnMap.put("msg", exp.getLocalizedMessage()); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + return returnMap; | ||
| 98 | + } | ||
| 73 | } | 99 | } |
src/main/java/com/bsth/service/impl/CarsServiceImpl.java
| 1 | package com.bsth.service.impl; | 1 | package com.bsth.service.impl; |
| 2 | 2 | ||
| 3 | -import com.bsth.common.ResponseCode; | ||
| 4 | import com.bsth.entity.Cars; | 3 | import com.bsth.entity.Cars; |
| 5 | import com.bsth.service.CarsService; | 4 | import com.bsth.service.CarsService; |
| 6 | import org.springframework.stereotype.Service; | 5 | import org.springframework.stereotype.Service; |
| 7 | 6 | ||
| 8 | -import java.util.HashMap; | ||
| 9 | -import java.util.Map; | ||
| 10 | - | ||
| 11 | /** | 7 | /** |
| 12 | * Created by xu on 16/5/31. | 8 | * Created by xu on 16/5/31. |
| 13 | */ | 9 | */ |
| 14 | @Service | 10 | @Service |
| 15 | public class CarsServiceImpl extends BaseServiceImpl<Cars, Integer> implements CarsService { | 11 | public class CarsServiceImpl extends BaseServiceImpl<Cars, Integer> implements CarsService { |
| 16 | - @Override | ||
| 17 | - public Map<String, Object> validateEquale(Map<String, Object> params) { | ||
| 18 | - Map<String, Object> returnMap = new HashMap<>(); | ||
| 19 | - | ||
| 20 | - try { | ||
| 21 | - if (params == null || params.size() == 0) { | ||
| 22 | - returnMap.put("status", ResponseCode.SUCCESS); | ||
| 23 | - returnMap.put("msg", "此时没有重复"); | ||
| 24 | - } else { | ||
| 25 | - Iterable<Cars> iterable = this.list(params); | ||
| 26 | - if (iterable.iterator().hasNext()) { | ||
| 27 | - returnMap.put("status", ResponseCode.ERROR); | ||
| 28 | - returnMap.put("msg", "自编号重复"); | ||
| 29 | - } else { | ||
| 30 | - returnMap.put("status", ResponseCode.SUCCESS); | ||
| 31 | - returnMap.put("msg", "此时没有重复"); | ||
| 32 | - } | ||
| 33 | - } | ||
| 34 | - } catch (Exception exp) { | ||
| 35 | - logger.error("validateZbh error", exp); | ||
| 36 | - returnMap.put("status", ResponseCode.ERROR); | ||
| 37 | - returnMap.put("msg", exp.getLocalizedMessage()); | ||
| 38 | - } | ||
| 39 | - | ||
| 40 | - return returnMap; | ||
| 41 | - } | ||
| 42 | } | 12 | } |
src/main/resources/static/pages/scheduleApp/module/basicInfo/employeeInfoManage/detail.html
| @@ -86,7 +86,7 @@ | @@ -86,7 +86,7 @@ | ||
| 86 | <label class="col-md-2 control-label">工种:</label> | 86 | <label class="col-md-2 control-label">工种:</label> |
| 87 | <div class="col-md-4"> | 87 | <div class="col-md-4"> |
| 88 | <input type="text" class="form-control" name="posts" | 88 | <input type="text" class="form-control" name="posts" |
| 89 | - ng-model="ctrl.employeeInfoForDetail.posts" readonly/> | 89 | + ng-value="ctrl.employeeInfoForDetail.posts | dict:'gzType':'未知'" readonly/> |
| 90 | </div> | 90 | </div> |
| 91 | </div> | 91 | </div> |
| 92 | 92 |
src/main/resources/static/pages/scheduleApp/module/basicInfo/employeeInfoManage/edit.html
| @@ -36,21 +36,14 @@ | @@ -36,21 +36,14 @@ | ||
| 36 | <div class="form-group has-success has-feedback"> | 36 | <div class="form-group has-success has-feedback"> |
| 37 | <label class="col-md-2 control-label">所属公司*:</label> | 37 | <label class="col-md-2 control-label">所属公司*:</label> |
| 38 | <div class="col-md-3"> | 38 | <div class="col-md-3"> |
| 39 | - <div class="input-group"> | ||
| 40 | - <ui-select ng-model="ctrl.employeeInfoForSave.gs_selected" | ||
| 41 | - on-select="ctrl.gs_selected_change($item, $model)" | ||
| 42 | - theme="bootstrap" name="gs" required> | ||
| 43 | - <ui-select-match placeholder="请选择所属公司...">{{$select.selected.gsmc}}</ui-select-match> | ||
| 44 | - <ui-select-choices repeat="item in ctrl.gses"> | ||
| 45 | - <span ng-bind="item.gsmc"></span> | ||
| 46 | - </ui-select-choices> | ||
| 47 | - </ui-select> | ||
| 48 | - <span class="input-group-btn"> | ||
| 49 | - <button type="button" ng-click="ctrl.gs_selected_remove()" class="btn btn-default"> | ||
| 50 | - <span class="glyphicon glyphicon-trash"></span> | ||
| 51 | - </button> | ||
| 52 | - </span> | ||
| 53 | - </div> | 39 | + <sa-Select model="ctrl.employeeInfoForSave" |
| 40 | + dicgroup="gsType" | ||
| 41 | + placeholder="请选择所属公司..." | ||
| 42 | + name="gs" | ||
| 43 | + codename="companyCode" | ||
| 44 | + dicname="company" | ||
| 45 | + required="true"> | ||
| 46 | + </sa-Select> | ||
| 54 | </div> | 47 | </div> |
| 55 | <!-- 隐藏块,显示验证信息 --> | 48 | <!-- 隐藏块,显示验证信息 --> |
| 56 | <div class="alert alert-danger well-sm" ng-show="myForm.gs.$error.required"> | 49 | <div class="alert alert-danger well-sm" ng-show="myForm.gs.$error.required"> |
| @@ -77,12 +70,16 @@ | @@ -77,12 +70,16 @@ | ||
| 77 | <div class="col-md-3"> | 70 | <div class="col-md-3"> |
| 78 | <input type="text" class="form-control" | 71 | <input type="text" class="form-control" |
| 79 | name="jobCode" ng-model="ctrl.employeeInfoForSave.jobCode" | 72 | name="jobCode" ng-model="ctrl.employeeInfoForSave.jobCode" |
| 73 | + remote-Validaton rvtype="jobCode" rv1="{{ctrl.employeeInfoForSave.companyCode}}" | ||
| 80 | required placeholder="请输入工号"/> | 74 | required placeholder="请输入工号"/> |
| 81 | </div> | 75 | </div> |
| 82 | <!-- 隐藏块,显示验证信息 --> | 76 | <!-- 隐藏块,显示验证信息 --> |
| 83 | <div class="alert alert-danger well-sm" ng-show="myForm.jobCode.$error.required"> | 77 | <div class="alert alert-danger well-sm" ng-show="myForm.jobCode.$error.required"> |
| 84 | 工号必须填写 | 78 | 工号必须填写 |
| 85 | </div> | 79 | </div> |
| 80 | + <div class="alert alert-danger well-sm" ng-show="myForm.jobCode.$error.remote"> | ||
| 81 | + 选择公司并且相同公司工号不能重复 | ||
| 82 | + </div> | ||
| 86 | </div> | 83 | </div> |
| 87 | 84 | ||
| 88 | <div class="form-group has-success has-feedback"> | 85 | <div class="form-group has-success has-feedback"> |
| @@ -124,21 +121,12 @@ | @@ -124,21 +121,12 @@ | ||
| 124 | <div class="form-group"> | 121 | <div class="form-group"> |
| 125 | <label class="col-md-2 control-label">工种:</label> | 122 | <label class="col-md-2 control-label">工种:</label> |
| 126 | <div class="col-md-4"> | 123 | <div class="col-md-4"> |
| 127 | - <div class="input-group"> | ||
| 128 | - <ui-select ng-model="ctrl.employeeInfoForSave.posts_selected" | ||
| 129 | - on-select="ctrl.posts_selected_change($item, $model)" | ||
| 130 | - theme="bootstrap" name="posts"> | ||
| 131 | - <ui-select-match placeholder="请选择工种...">{{$select.selected.type}}</ui-select-match> | ||
| 132 | - <ui-select-choices repeat="item in ctrl.postes"> | ||
| 133 | - <span ng-bind="item.type"></span> | ||
| 134 | - </ui-select-choices> | ||
| 135 | - </ui-select> | ||
| 136 | - <span class="input-group-btn"> | ||
| 137 | - <button type="button" ng-click="ctrl.posts_selected_remove()" class="btn btn-default"> | ||
| 138 | - <span class="glyphicon glyphicon-trash"></span> | ||
| 139 | - </button> | ||
| 140 | - </span> | ||
| 141 | - </div> | 124 | + <sa-Select model="ctrl.employeeInfoForSave" |
| 125 | + dicgroup="gzType" | ||
| 126 | + placeholder="请选择工种..." | ||
| 127 | + name="posts" | ||
| 128 | + codename="posts" > | ||
| 129 | + </sa-Select> | ||
| 142 | </div> | 130 | </div> |
| 143 | </div> | 131 | </div> |
| 144 | 132 |
src/main/resources/static/pages/scheduleApp/module/basicInfo/employeeInfoManage/employeeInfoManage.js
| 1 | // 人员信息管理 service controller等写在一起 | 1 | // 人员信息管理 service controller等写在一起 |
| 2 | 2 | ||
| 3 | angular.module('ScheduleApp').factory('EmployeeInfoManageService', ['EmployeeInfoManageService_g', function(service) { | 3 | angular.module('ScheduleApp').factory('EmployeeInfoManageService', ['EmployeeInfoManageService_g', function(service) { |
| 4 | - /** 公司字典 */ | ||
| 5 | - var gses = [ | ||
| 6 | - {gsdm: "55", gsmc: "上南公司"}, | ||
| 7 | - {gsdm: "22", gsmc: "金高公司"}, | ||
| 8 | - {gsdm: "05", gsmc: "杨高公司"}, | ||
| 9 | - {gsdm: "26", gsmc: "南汇公司"} | ||
| 10 | - ]; | ||
| 11 | - /** 工种类型字典 */ | ||
| 12 | - var postes = [ | ||
| 13 | - {type: "公共汽电车驾驶员"}, | ||
| 14 | - {type: "公共汽电车调度员"}, | ||
| 15 | - {type: "公共汽电车售票员"}, | ||
| 16 | - {type: "站员"}, | ||
| 17 | - {type: "管理员"}, | ||
| 18 | - {type: "安检员"}, | ||
| 19 | - {type: "机务"}, | ||
| 20 | - {type: "引导员"}, | ||
| 21 | - {type: "乘务员"}, | ||
| 22 | - {type: "车队长(线长、主"}, | ||
| 23 | - {type: "公司管理人员"}, | ||
| 24 | - {type: "警消人员"}, | ||
| 25 | - {type: "票务人员"}, | ||
| 26 | - {type: "其他服务人员"} | ||
| 27 | - ]; | ||
| 28 | 4 | ||
| 29 | /** 当前的查询条件信息 */ | 5 | /** 当前的查询条件信息 */ |
| 30 | var currentSearchCondition = { | 6 | var currentSearchCondition = { |
| @@ -39,18 +15,6 @@ angular.module('ScheduleApp').factory('EmployeeInfoManageService', ['EmployeeInf | @@ -39,18 +15,6 @@ angular.module('ScheduleApp').factory('EmployeeInfoManageService', ['EmployeeInf | ||
| 39 | 15 | ||
| 40 | return { | 16 | return { |
| 41 | /** | 17 | /** |
| 42 | - * 获取公司字典。 | ||
| 43 | - */ | ||
| 44 | - getGses: function() { | ||
| 45 | - return gses; | ||
| 46 | - }, | ||
| 47 | - /** | ||
| 48 | - * 获取工种类型字典。 | ||
| 49 | - */ | ||
| 50 | - getPostes: function() { | ||
| 51 | - return postes; | ||
| 52 | - }, | ||
| 53 | - /** | ||
| 54 | * 获取查询条件信息, | 18 | * 获取查询条件信息, |
| 55 | * 用于给controller用来和页面数据绑定。 | 19 | * 用于给controller用来和页面数据绑定。 |
| 56 | */ | 20 | */ |
| @@ -81,7 +45,7 @@ angular.module('ScheduleApp').factory('EmployeeInfoManageService', ['EmployeeInf | @@ -81,7 +45,7 @@ angular.module('ScheduleApp').factory('EmployeeInfoManageService', ['EmployeeInf | ||
| 81 | getPage: function() { | 45 | getPage: function() { |
| 82 | var params = currentSearchCondition; // 查询条件 | 46 | var params = currentSearchCondition; // 查询条件 |
| 83 | params.page = currentPageNo - 1; // 服务端页码从0开始 | 47 | params.page = currentPageNo - 1; // 服务端页码从0开始 |
| 84 | - return service.list(params).$promise; | 48 | + return service.rest.list(params).$promise; |
| 85 | }, | 49 | }, |
| 86 | /** | 50 | /** |
| 87 | * 获取明细信息。 | 51 | * 获取明细信息。 |
| @@ -90,7 +54,7 @@ angular.module('ScheduleApp').factory('EmployeeInfoManageService', ['EmployeeInf | @@ -90,7 +54,7 @@ angular.module('ScheduleApp').factory('EmployeeInfoManageService', ['EmployeeInf | ||
| 90 | */ | 54 | */ |
| 91 | getDetail: function(id) { | 55 | getDetail: function(id) { |
| 92 | var params = {id: id}; | 56 | var params = {id: id}; |
| 93 | - return service.get(params).$promise; | 57 | + return service.rest.get(params).$promise; |
| 94 | }, | 58 | }, |
| 95 | /** | 59 | /** |
| 96 | * 保存信息。 | 60 | * 保存信息。 |
| @@ -98,7 +62,7 @@ angular.module('ScheduleApp').factory('EmployeeInfoManageService', ['EmployeeInf | @@ -98,7 +62,7 @@ angular.module('ScheduleApp').factory('EmployeeInfoManageService', ['EmployeeInf | ||
| 98 | * @return 返回一个 promise | 62 | * @return 返回一个 promise |
| 99 | */ | 63 | */ |
| 100 | saveDetail: function(obj) { | 64 | saveDetail: function(obj) { |
| 101 | - return service.save(obj).$promise; | 65 | + return service.rest.save(obj).$promise; |
| 102 | } | 66 | } |
| 103 | } | 67 | } |
| 104 | 68 | ||
| @@ -170,30 +134,6 @@ angular.module('ScheduleApp').controller('EmployeeInfoManageFormCtrl', ['Employe | @@ -170,30 +134,6 @@ angular.module('ScheduleApp').controller('EmployeeInfoManageFormCtrl', ['Employe | ||
| 170 | // 欲保存的busInfo信息,绑定 | 134 | // 欲保存的busInfo信息,绑定 |
| 171 | self.employeeInfoForSave = {}; | 135 | self.employeeInfoForSave = {}; |
| 172 | 136 | ||
| 173 | - // 公司 selectedItem | ||
| 174 | - self.employeeInfoForSave.gs_selected = null; | ||
| 175 | - self.gses = employeeInfoManageService.getGses(); | ||
| 176 | - self.gs_selected_change = function($item, $model) { | ||
| 177 | - self.employeeInfoForSave.companyCode = $item.gsdm; | ||
| 178 | - self.employeeInfoForSave.company = $item.gsmc; | ||
| 179 | - }; | ||
| 180 | - self.gs_selected_remove = function() { | ||
| 181 | - self.employeeInfoForSave.gs_selected = null; | ||
| 182 | - self.employeeInfoForSave.companyCode = null; | ||
| 183 | - self.employeeInfoForSave.company = null; | ||
| 184 | - }; | ||
| 185 | - | ||
| 186 | - // 工种 selectedItem | ||
| 187 | - self.employeeInfoForSave.posts_selected = null; | ||
| 188 | - self.postes = employeeInfoManageService.getPostes(); | ||
| 189 | - self.posts_selected_change = function($item, $model) { | ||
| 190 | - self.employeeInfoForSave.posts = $item.type; | ||
| 191 | - }; | ||
| 192 | - self.posts_selected_remove = function() { | ||
| 193 | - self.employeeInfoForSave.posts_selected = null; | ||
| 194 | - self.employeeInfoForSave.posts = null; | ||
| 195 | - }; | ||
| 196 | - | ||
| 197 | // 获取传过来的id,有的话就是修改,获取一遍数据 | 137 | // 获取传过来的id,有的话就是修改,获取一遍数据 |
| 198 | var id = $stateParams.id; | 138 | var id = $stateParams.id; |
| 199 | if (id) { | 139 | if (id) { |
| @@ -204,24 +144,6 @@ angular.module('ScheduleApp').controller('EmployeeInfoManageFormCtrl', ['Employe | @@ -204,24 +144,6 @@ angular.module('ScheduleApp').controller('EmployeeInfoManageFormCtrl', ['Employe | ||
| 204 | for (key in result) { | 144 | for (key in result) { |
| 205 | self.employeeInfoForSave[key] = result[key]; | 145 | self.employeeInfoForSave[key] = result[key]; |
| 206 | } | 146 | } |
| 207 | - // 填写所有的 select 控件选中框数据 | ||
| 208 | - // 公司字典 | ||
| 209 | - if (self.employeeInfoForSave.companyCode) { | ||
| 210 | - angular.forEach(self.gses, function(data) { | ||
| 211 | - if (self.employeeInfoForSave.companyCode == data.gsdm) { | ||
| 212 | - self.employeeInfoForSave.gs_selected = data; | ||
| 213 | - } | ||
| 214 | - }); | ||
| 215 | - } | ||
| 216 | - // 工种字典 | ||
| 217 | - if (self.employeeInfoForSave.posts) { | ||
| 218 | - angular.forEach(self.postes, function(data) { | ||
| 219 | - if (self.employeeInfoForSave.posts == data.type) { | ||
| 220 | - self.employeeInfoForSave.posts_selected = data; | ||
| 221 | - } | ||
| 222 | - }); | ||
| 223 | - } | ||
| 224 | - | ||
| 225 | }, | 147 | }, |
| 226 | function(result) { | 148 | function(result) { |
| 227 | alert("出错啦!"); | 149 | alert("出错啦!"); |
src/main/resources/static/pages/scheduleApp/module/basicInfo/employeeInfoManage/form.html
| @@ -36,21 +36,14 @@ | @@ -36,21 +36,14 @@ | ||
| 36 | <div class="form-group has-success has-feedback"> | 36 | <div class="form-group has-success has-feedback"> |
| 37 | <label class="col-md-2 control-label">所属公司*:</label> | 37 | <label class="col-md-2 control-label">所属公司*:</label> |
| 38 | <div class="col-md-3"> | 38 | <div class="col-md-3"> |
| 39 | - <div class="input-group"> | ||
| 40 | - <ui-select ng-model="ctrl.employeeInfoForSave.gs_selected" | ||
| 41 | - on-select="ctrl.gs_selected_change($item, $model)" | ||
| 42 | - theme="bootstrap" name="gs" required> | ||
| 43 | - <ui-select-match placeholder="请选择所属公司...">{{$select.selected.gsmc}}</ui-select-match> | ||
| 44 | - <ui-select-choices repeat="item in ctrl.gses"> | ||
| 45 | - <span ng-bind="item.gsmc"></span> | ||
| 46 | - </ui-select-choices> | ||
| 47 | - </ui-select> | ||
| 48 | - <span class="input-group-btn"> | ||
| 49 | - <button type="button" ng-click="ctrl.gs_selected_remove()" class="btn btn-default"> | ||
| 50 | - <span class="glyphicon glyphicon-trash"></span> | ||
| 51 | - </button> | ||
| 52 | - </span> | ||
| 53 | - </div> | 39 | + <sa-Select model="ctrl.employeeInfoForSave" |
| 40 | + dicgroup="gsType" | ||
| 41 | + placeholder="请选择所属公司..." | ||
| 42 | + name="gs" | ||
| 43 | + codename="companyCode" | ||
| 44 | + dicname="company" | ||
| 45 | + required="true"> | ||
| 46 | + </sa-Select> | ||
| 54 | </div> | 47 | </div> |
| 55 | <!-- 隐藏块,显示验证信息 --> | 48 | <!-- 隐藏块,显示验证信息 --> |
| 56 | <div class="alert alert-danger well-sm" ng-show="myForm.gs.$error.required"> | 49 | <div class="alert alert-danger well-sm" ng-show="myForm.gs.$error.required"> |
| @@ -77,12 +70,16 @@ | @@ -77,12 +70,16 @@ | ||
| 77 | <div class="col-md-3"> | 70 | <div class="col-md-3"> |
| 78 | <input type="text" class="form-control" | 71 | <input type="text" class="form-control" |
| 79 | name="jobCode" ng-model="ctrl.employeeInfoForSave.jobCode" | 72 | name="jobCode" ng-model="ctrl.employeeInfoForSave.jobCode" |
| 73 | + remote-Validaton rvtype="jobCode" rv1="{{ctrl.employeeInfoForSave.companyCode}}" | ||
| 80 | required placeholder="请输入工号"/> | 74 | required placeholder="请输入工号"/> |
| 81 | </div> | 75 | </div> |
| 82 | <!-- 隐藏块,显示验证信息 --> | 76 | <!-- 隐藏块,显示验证信息 --> |
| 83 | <div class="alert alert-danger well-sm" ng-show="myForm.jobCode.$error.required"> | 77 | <div class="alert alert-danger well-sm" ng-show="myForm.jobCode.$error.required"> |
| 84 | 工号必须填写 | 78 | 工号必须填写 |
| 85 | </div> | 79 | </div> |
| 80 | + <div class="alert alert-danger well-sm" ng-show="myForm.jobCode.$error.remote"> | ||
| 81 | + 选择公司并且相同公司工号不能重复 | ||
| 82 | + </div> | ||
| 86 | </div> | 83 | </div> |
| 87 | 84 | ||
| 88 | <div class="form-group has-success has-feedback"> | 85 | <div class="form-group has-success has-feedback"> |
| @@ -124,21 +121,12 @@ | @@ -124,21 +121,12 @@ | ||
| 124 | <div class="form-group"> | 121 | <div class="form-group"> |
| 125 | <label class="col-md-2 control-label">工种:</label> | 122 | <label class="col-md-2 control-label">工种:</label> |
| 126 | <div class="col-md-4"> | 123 | <div class="col-md-4"> |
| 127 | - <div class="input-group"> | ||
| 128 | - <ui-select ng-model="ctrl.employeeInfoForSave.posts_selected" | ||
| 129 | - on-select="ctrl.posts_selected_change($item, $model)" | ||
| 130 | - theme="bootstrap" name="posts"> | ||
| 131 | - <ui-select-match placeholder="请选择工种...">{{$select.selected.type}}</ui-select-match> | ||
| 132 | - <ui-select-choices repeat="item in ctrl.postes"> | ||
| 133 | - <span ng-bind="item.type"></span> | ||
| 134 | - </ui-select-choices> | ||
| 135 | - </ui-select> | ||
| 136 | - <span class="input-group-btn"> | ||
| 137 | - <button type="button" ng-click="ctrl.posts_selected_remove()" class="btn btn-default"> | ||
| 138 | - <span class="glyphicon glyphicon-trash"></span> | ||
| 139 | - </button> | ||
| 140 | - </span> | ||
| 141 | - </div> | 124 | + <sa-Select model="ctrl.employeeInfoForSave" |
| 125 | + dicgroup="gzType" | ||
| 126 | + placeholder="请选择工种..." | ||
| 127 | + name="posts" | ||
| 128 | + codename="posts" > | ||
| 129 | + </sa-Select> | ||
| 142 | </div> | 130 | </div> |
| 143 | </div> | 131 | </div> |
| 144 | 132 |
src/main/resources/static/pages/scheduleApp/module/basicInfo/employeeInfoManage/list.html
| @@ -115,7 +115,7 @@ | @@ -115,7 +115,7 @@ | ||
| 115 | <span ng-bind="info.brancheCompany"></span> | 115 | <span ng-bind="info.brancheCompany"></span> |
| 116 | </td> | 116 | </td> |
| 117 | <td> | 117 | <td> |
| 118 | - <span ng-bind="info.posts"></span> | 118 | + <span ng-bind="info.posts | dict:'gzType':'未知'"></span> |
| 119 | </td> | 119 | </td> |
| 120 | <td> | 120 | <td> |
| 121 | <span ng-bind="info.icCardCode"></span> | 121 | <span ng-bind="info.icCardCode"></span> |
src/main/resources/static/pages/scheduleApp/module/main.js
| @@ -696,48 +696,38 @@ angular.module('ScheduleApp').factory('BusInfoManageService_g', ['$resource', fu | @@ -696,48 +696,38 @@ angular.module('ScheduleApp').factory('BusInfoManageService_g', ['$resource', fu | ||
| 696 | } | 696 | } |
| 697 | ) | 697 | ) |
| 698 | }; | 698 | }; |
| 699 | - | ||
| 700 | - | ||
| 701 | - | ||
| 702 | - return $resource( | ||
| 703 | - '/cars/:id', | ||
| 704 | - {order: 'carCode', direction: 'ASC', id: '@id_route'}, | ||
| 705 | - { | ||
| 706 | - list: { | ||
| 707 | - method: 'GET', | ||
| 708 | - params: { | ||
| 709 | - page: 0 | ||
| 710 | - } | ||
| 711 | - }, | ||
| 712 | - get: { | ||
| 713 | - method: 'GET' | ||
| 714 | - }, | ||
| 715 | - save: { | ||
| 716 | - method: 'POST' | ||
| 717 | - } | ||
| 718 | - } | ||
| 719 | - ); | ||
| 720 | }]); | 699 | }]); |
| 721 | // 人员信息service | 700 | // 人员信息service |
| 722 | angular.module('ScheduleApp').factory('EmployeeInfoManageService_g', ['$resource', function($resource) { | 701 | angular.module('ScheduleApp').factory('EmployeeInfoManageService_g', ['$resource', function($resource) { |
| 723 | - return $resource( | ||
| 724 | - '/personnel/:id', | ||
| 725 | - {order: 'jobCode', direction: 'ASC', id: '@id_route'}, | ||
| 726 | - { | ||
| 727 | - list: { | ||
| 728 | - method: 'GET', | ||
| 729 | - params: { | ||
| 730 | - page: 0 | 702 | + return { |
| 703 | + rest : $resource( | ||
| 704 | + '/personnel/:id', | ||
| 705 | + {order: 'jobCode', direction: 'ASC', id: '@id_route'}, | ||
| 706 | + { | ||
| 707 | + list: { | ||
| 708 | + method: 'GET', | ||
| 709 | + params: { | ||
| 710 | + page: 0 | ||
| 711 | + } | ||
| 712 | + }, | ||
| 713 | + get: { | ||
| 714 | + method: 'GET' | ||
| 715 | + }, | ||
| 716 | + save: { | ||
| 717 | + method: 'POST' | ||
| 731 | } | 718 | } |
| 732 | - }, | ||
| 733 | - get: { | ||
| 734 | - method: 'GET' | ||
| 735 | - }, | ||
| 736 | - save: { | ||
| 737 | - method: 'POST' | ||
| 738 | } | 719 | } |
| 739 | - } | ||
| 740 | - ); | 720 | + ), |
| 721 | + validate: $resource( | ||
| 722 | + '/personnel/validate/:type', | ||
| 723 | + {}, | ||
| 724 | + { | ||
| 725 | + jobCode: { | ||
| 726 | + method: 'GET' | ||
| 727 | + } | ||
| 728 | + } | ||
| 729 | + ) | ||
| 730 | + }; | ||
| 741 | }]); | 731 | }]); |
| 742 | // 车辆设备信息service | 732 | // 车辆设备信息service |
| 743 | angular.module('ScheduleApp').factory('DeviceInfoManageService_g', ['$resource', function($resource) { | 733 | angular.module('ScheduleApp').factory('DeviceInfoManageService_g', ['$resource', function($resource) { |
| @@ -1099,8 +1089,10 @@ angular.module('ScheduleApp').directive("saRadiogroup", [function() { | @@ -1099,8 +1089,10 @@ angular.module('ScheduleApp').directive("saRadiogroup", [function() { | ||
| 1099 | 1089 | ||
| 1100 | angular.module('ScheduleApp').directive("remoteValidaton", [ | 1090 | angular.module('ScheduleApp').directive("remoteValidaton", [ |
| 1101 | 'BusInfoManageService_g', | 1091 | 'BusInfoManageService_g', |
| 1092 | + 'EmployeeInfoManageService_g', | ||
| 1102 | function( | 1093 | function( |
| 1103 | - busInfoManageService_g | 1094 | + busInfoManageService_g, |
| 1095 | + employeeInfoManageService_g | ||
| 1104 | ) { | 1096 | ) { |
| 1105 | /** | 1097 | /** |
| 1106 | * 远端验证指令,依赖于ngModel | 1098 | * 远端验证指令,依赖于ngModel |
| @@ -1109,14 +1101,17 @@ angular.module('ScheduleApp').directive("remoteValidaton", [ | @@ -1109,14 +1101,17 @@ angular.module('ScheduleApp').directive("remoteValidaton", [ | ||
| 1109 | */ | 1101 | */ |
| 1110 | return { | 1102 | return { |
| 1111 | restrict: "A", | 1103 | restrict: "A", |
| 1112 | - require: "ngModel", | 1104 | + require: "^ngModel", |
| 1113 | link: function(scope, element, attr, ngModelCtrl) { | 1105 | link: function(scope, element, attr, ngModelCtrl) { |
| 1114 | element.bind("keyup", function() { | 1106 | element.bind("keyup", function() { |
| 1115 | var modelValue = ngModelCtrl.$modelValue; | 1107 | var modelValue = ngModelCtrl.$modelValue; |
| 1108 | + var rv1_attr = attr["rv1"]; | ||
| 1116 | if (attr["rvtype"]) { | 1109 | if (attr["rvtype"]) { |
| 1117 | 1110 | ||
| 1118 | // 根据rvtype的值,确定使用那个远端验证的url, | 1111 | // 根据rvtype的值,确定使用那个远端验证的url, |
| 1112 | + // rv1, rv2, rv3是关联比较值,暂时使用rv1 | ||
| 1119 | // 这个貌似没法通用,根据业务变换 | 1113 | // 这个貌似没法通用,根据业务变换 |
| 1114 | + // TODO:暂时有点乱以后改 | ||
| 1120 | if (attr["rvtype"] == "insideCode") { | 1115 | if (attr["rvtype"] == "insideCode") { |
| 1121 | busInfoManageService_g.validate.insideCode( | 1116 | busInfoManageService_g.validate.insideCode( |
| 1122 | {"insideCode_eq": modelValue, type: "equale"}, | 1117 | {"insideCode_eq": modelValue, type: "equale"}, |
| @@ -1133,11 +1128,55 @@ angular.module('ScheduleApp').directive("remoteValidaton", [ | @@ -1133,11 +1128,55 @@ angular.module('ScheduleApp').directive("remoteValidaton", [ | ||
| 1133 | ngModelCtrl.$setValidity('remote', true); | 1128 | ngModelCtrl.$setValidity('remote', true); |
| 1134 | } | 1129 | } |
| 1135 | ); | 1130 | ); |
| 1131 | + } else if (attr["rvtype"] == "jobCode") { | ||
| 1132 | + if (!rv1_attr) { | ||
| 1133 | + ngModelCtrl.$setValidity('remote', false); | ||
| 1134 | + return; | ||
| 1135 | + } | ||
| 1136 | + | ||
| 1137 | + employeeInfoManageService_g.validate.jobCode( | ||
| 1138 | + {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"}, | ||
| 1139 | + function(result) { | ||
| 1140 | + //console.log(result); | ||
| 1141 | + if (result.status == "SUCCESS") { | ||
| 1142 | + ngModelCtrl.$setValidity('remote', true); | ||
| 1143 | + } else { | ||
| 1144 | + ngModelCtrl.$setValidity('remote', false); | ||
| 1145 | + } | ||
| 1146 | + }, | ||
| 1147 | + function(result) { | ||
| 1148 | + //console.log(result); | ||
| 1149 | + ngModelCtrl.$setValidity('remote', true); | ||
| 1150 | + } | ||
| 1151 | + ); | ||
| 1136 | } | 1152 | } |
| 1137 | } else { | 1153 | } else { |
| 1138 | // 没有rvtype,就不用远端验证了 | 1154 | // 没有rvtype,就不用远端验证了 |
| 1139 | ngModelCtrl.$setValidity('remote', true); | 1155 | ngModelCtrl.$setValidity('remote', true); |
| 1140 | } | 1156 | } |
| 1157 | + | ||
| 1158 | + attr.$observe("rv1", function(value) { | ||
| 1159 | + if (!value) { | ||
| 1160 | + ngModelCtrl.$setValidity('remote', false); | ||
| 1161 | + return; | ||
| 1162 | + } | ||
| 1163 | + | ||
| 1164 | + employeeInfoManageService_g.validate.jobCode( | ||
| 1165 | + {"jobCode_eq": modelValue, "companyCode_eq": rv1_attr, type: "equale"}, | ||
| 1166 | + function(result) { | ||
| 1167 | + //console.log(result); | ||
| 1168 | + if (result.status == "SUCCESS") { | ||
| 1169 | + ngModelCtrl.$setValidity('remote', true); | ||
| 1170 | + } else { | ||
| 1171 | + ngModelCtrl.$setValidity('remote', false); | ||
| 1172 | + } | ||
| 1173 | + }, | ||
| 1174 | + function(result) { | ||
| 1175 | + //console.log(result); | ||
| 1176 | + ngModelCtrl.$setValidity('remote', true); | ||
| 1177 | + } | ||
| 1178 | + ); | ||
| 1179 | + }); | ||
| 1141 | }); | 1180 | }); |
| 1142 | } | 1181 | } |
| 1143 | }; | 1182 | }; |