Commit 40f94ece authored by Eddie.Wu's avatar Eddie.Wu

Merge branch 'dev_wzk' into 'dev_mysql'

机构地区三级联动选到区县展示问题

See merge request root/atms!361
parents 03c90c29 2b6738a8
...@@ -51,6 +51,14 @@ public class AreaRegionController { ...@@ -51,6 +51,14 @@ public class AreaRegionController {
return areaRegionService.getCities(parentId); return areaRegionService.getCities(parentId);
} }
// @ApiOperation(value = "Get cities")
@RequestMapping(value = "getProvincesByCityID", method = RequestMethod.GET)
public @ResponseBody
AreaRegionDto getProvincesByCityID(@RequestParam(name = "cityID") String cityID) {
logger.info("/api/v1/areaRegion/getProvincesByCityID");
return areaRegionService.getProvincesByCityID(cityID);
}
// @ApiOperation(value = "Get Provinces") // @ApiOperation(value = "Get Provinces")
@RequestMapping(value = "getProvinces", method = RequestMethod.GET) @RequestMapping(value = "getProvinces", method = RequestMethod.GET)
public @ResponseBody public @ResponseBody
......
...@@ -246,6 +246,21 @@ public class AreaRegionServiceImpl { ...@@ -246,6 +246,21 @@ public class AreaRegionServiceImpl {
} }
public AreaRegionDto getProvincesByCityID(String cityId) {
Region region = regionMapper.selectByPrimaryKey(cityId);
if(region != null){
Region region1 = regionMapper.selectByPrimaryKey(region.getParentId());
if(region1!=null){
return rotateRegion(region1);
}else{
return null;
}
}else{
return null;
}
}
public List<AreaRegionDto> getDistricts(String parentId) { public List<AreaRegionDto> getDistricts(String parentId) {
List<AreaRegionDto> districts = getRegions(CommonConstants.REGION_LEVELTYPE_DISTRICT); List<AreaRegionDto> districts = getRegions(CommonConstants.REGION_LEVELTYPE_DISTRICT);
List<AreaRegionDto> query = districts.stream().filter(s -> s.getRegionParentId().equals(parentId)) List<AreaRegionDto> query = districts.stream().filter(s -> s.getRegionParentId().equals(parentId))
......
...@@ -126,6 +126,17 @@ public class OrganizationDto { ...@@ -126,6 +126,17 @@ public class OrganizationDto {
public List<OrganizationDto> sameVehicleroutinglocationList; public List<OrganizationDto> sameVehicleroutinglocationList;
public List<TaxControlDiskDto> taxControlDiskList; public List<TaxControlDiskDto> taxControlDiskList;
@JsonProperty("levelType")
private Integer levelType;
public Integer getLevelType() {
return levelType;
}
public void setLevelType(Integer levelType) {
this.levelType = levelType;
}
public String getId() { public String getId() {
return this.id; return this.id;
} }
......
...@@ -558,6 +558,7 @@ ...@@ -558,6 +558,7 @@
<result column="PARENT_REGION_ID" jdbcType="VARCHAR" property="parentRegionId"/> <result column="PARENT_REGION_ID" jdbcType="VARCHAR" property="parentRegionId"/>
<result column="AREA_NAME" jdbcType="VARCHAR" property="areaName"/> <result column="AREA_NAME" jdbcType="VARCHAR" property="areaName"/>
<result column="BUSINESS_UNIT_NAME" jdbcType="VARCHAR" property="businessUnitName"/> <result column="BUSINESS_UNIT_NAME" jdbcType="VARCHAR" property="businessUnitName"/>
<result column="level_type" jdbcType="INTEGER" property="levelType" />
</resultMap> </resultMap>
<select id="getSingleOrgByOrgIdToOrgDto" parameterType="map" resultMap="OrgDtoForGetSingleOrgByOrgID"> <select id="getSingleOrgByOrgIdToOrgDto" parameterType="map" resultMap="OrgDtoForGetSingleOrgByOrgID">
...@@ -565,6 +566,7 @@ ...@@ -565,6 +566,7 @@
M.*, M.*,
N.name AS INDUSTRY_NAME, N.name AS INDUSTRY_NAME,
CONCAT(PREGION.name,T.name) AS REGION_NAME, CONCAT(PREGION.name,T.name) AS REGION_NAME,
T.level_type AS level_type,
S.name AS STRUCTURE_NAME, S.name AS STRUCTURE_NAME,
T.parent_id AS PARENT_REGION_ID, T.parent_id AS PARENT_REGION_ID,
AR.name AS AREA_NAME, AR.name AS AREA_NAME,
......
...@@ -303,8 +303,8 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', ' ...@@ -303,8 +303,8 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', '
} }
// 区域是必填项 // 区域是必填项
if ($scope.selectProvince && $scope.selectRegionID) { if ($scope.selectProvince && ($scope.selectCity || $scope.selectRegionID)) {
editModel.regionID = $scope.selectRegionID; editModel.regionID = $scope.selectRegionID || $scope.selectCity.regionID;
} }
var pId = editModel.parentID; var pId = editModel.parentID;
...@@ -669,16 +669,26 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', ' ...@@ -669,16 +669,26 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', '
// 获取省市 // 获取省市
var loadProvinceList = function () { var loadProvinceList = function () {
areaRegionService.getProvinces().success(function (data) { areaRegionService.getProvinces().success(function (data) {
if (data && data.length > 0) { if (data && data.length > 0) {
$scope.ProvinceList = data; $scope.ProvinceList = data;
//根据当前机构的父级(即市的层级)获取对应的省的regionID
//目前情况为省市区三级联动,参数为$scope.editOrgModel.parentRegionID,若为省市两级联动,参数改为$scope.editOrgModel.regionID即可
var cityIDTemp = $scope.editOrgModel.regionID;
if($scope.editOrgModel.levelType == 3){
cityIDTemp = $scope.editOrgModel.parentRegionID;
}
areaRegionService.getProvincesByCityID(cityIDTemp).success(function (resp) {
if(resp){
$scope.selectProvince = _.find($scope.ProvinceList, function (num) { $scope.selectProvince = _.find($scope.ProvinceList, function (num) {
return num.regionID === $scope.editOrgModel.parentRegionID; return num.regionID === resp.regionID;
}); });
if ($scope.selectProvince) { if ($scope.selectProvince) {
loadCityList($scope.selectProvince.regionID); loadCityList($scope.selectProvince.regionID);
} }
}
});
} else { } else {
data = null; data = null;
...@@ -690,26 +700,21 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', ' ...@@ -690,26 +700,21 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', '
// 加载城市信息 // 加载城市信息
var loadCityList = function (regionID) { var loadCityList = function (regionID) {
regionID = $scope.selectProvince.regionID;
if (regionID !== undefined && regionID !== null) { if (regionID !== undefined && regionID !== null) {
areaRegionService.getCities(regionID).success(function (data) { areaRegionService.getCities(regionID).success(function (data) {
if (data && data.length > 0) { if (data && data.length > 0) {
$scope.CityList = data; $scope.CityList = data;
$scope.selectCity = _.find($scope.CityList, function (num) { $scope.selectCity = _.find($scope.CityList, function (num) {
return num.regionID === $scope.selectProvince.regionID || num.regionID === $scope.editOrgModel.parentRegionID; if($scope.editOrgModel.levelType == 3){
return num.regionID === $scope.editOrgModel.parentRegionID;
}else if($scope.editOrgModel.levelType == 2){
return num.regionID === $scope.editOrgModel.regionID;
}
}); });
if ($scope.selectCity) { if ($scope.selectCity) {
$scope.selectCityID = $scope.selectCity.regionID;
$scope.selectProvince = _.find($scope.ProvinceList, function (num) {
return num.regionID === $scope.selectCity.parentRegionID;
});
loadDistrictList($scope.selectCity.regionID); loadDistrictList($scope.selectCity.regionID);
}else{
$scope.selectCityID = data[0].regionID;
} }
} else { } else {
...@@ -717,7 +722,6 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', ' ...@@ -717,7 +722,6 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', '
$scope.CityList = data; $scope.CityList = data;
$scope.selectCity = data; $scope.selectCity = data;
} }
}); });
} }
}; };
...@@ -731,21 +735,24 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', ' ...@@ -731,21 +735,24 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', '
$scope.DistrictList = data; $scope.DistrictList = data;
var target = _.find($scope.DistrictList, function (num) { var target = _.find($scope.DistrictList, function (num) {
return num.regionID === $scope.selectCity; return num.regionID === $scope.editOrgModel.regionID;
}); });
if (target) { if (target) {
$scope.selectRegionID = $scope.editOrgModel.regionID; $scope.selectRegionID = $scope.editOrgModel.regionID;
} else { }else{
$scope.selectRegionID = data[0].regionID; $scope.selectRegionID = "";
} }
} else { } else {
data = null; data = null;
$scope.DistrictList = data; $scope.DistrictList = data;
$scope.selectRegionID = null; $scope.selectRegionID = "";
} }
}); });
}else {
$scope.DistrictList = null;
$scope.selectRegionID = "";
} }
}; };
......
...@@ -436,35 +436,35 @@ ...@@ -436,35 +436,35 @@
<div class="form-group" ng-show="isLocal"> <div class="form-group" ng-show="isLocal">
<label class="col-sm-3 control-label"><span <label class="col-sm-3 control-label"><span
class="must-input">*</span>{{'AdministrativeRegion' | translate}}:</label> class="must-input">*</span>{{'AdministrativeRegion' | translate}}:</label>
<div class="col-sm-9 row"> <div class="col-sm-9" style="width: 69%;left: -3%;">
<div class="col-sm-5" style="padding-left: 0px;" <div class="col-sm-3" style="width: 31%"
ng-class="{'has-error':orgControlForm.selectProvince.$invalid && (orgControlForm.selectProvince.$dirty || orgControlForm.$submitted)}"> ng-class="{'has-error':orgControlForm.selectProvince.$invalid && (orgControlForm.selectProvince.$dirty || orgControlForm.$submitted)}">
<select class="form-control localRequired" name="selectProvince" <select class="form-control localRequired" style="width: 90px;" name="selectProvince"
style="width: 120px; " ng-change="populateCities()" ng-change="populateCities()"
ng-model="selectProvince" ng-model="selectProvince"
ng-options="x.regionName for x in ProvinceList"> ng-options="x.regionName for x in ProvinceList">
<option value="">{{pleaseSelect}}</option> <option value="">{{pleaseSelect}}</option>
</select> </select>
<p ng-show="orgControlForm.selectProvince.$error.required && (orgControlForm.selectProvince.$dirty || orgControlForm.$submitted)" <!--<p ng-show="orgControlForm.selectProvince.$error.required && (orgControlForm.selectProvince.$dirty || orgControlForm.$submitted)"-->
class="has-error label" style="margin-left: -16px"> <!--class="has-error label" style="margin-left: -16px">-->
{{resources.OrganizationMsgProvinceRequired}}</p> <!--{{resources.OrganizationMsgProvinceRequired}}</p>-->
</div> </div>
<div class="col-sm-5" style="padding-left: 10px;" <div class="col-sm-3" style="width: 31%"
ng-class="{'has-error':orgControlForm.selectCity.$invalid && (orgControlForm.selectCity.$dirty || orgControlForm.$submitted)}"> ng-class="{'has-error':orgControlForm.selectCity.$invalid && (orgControlForm.selectCity.$dirty || orgControlForm.$submitted)}">
<select class="form-control localRequired" name="selectCity" <select class="form-control localRequired" name="selectCity"
style="width: 120px; " ng-change="populateDistricts()" ng-change="populateDistricts()" style="width: 90px;"
ng-model="selectCity" ng-model="selectCity"
ng-options="x.regionName for x in CityList"> ng-options="x.regionName for x in CityList">
<option value="">{{pleaseSelect}}</option> <option value="">{{pleaseSelect}}</option>
</select> </select>
<p ng-show="orgControlForm.selectCity.$error.required && (orgControlForm.selectCity.$dirty || orgControlForm.$submitted)" <!--<p ng-show="orgControlForm.selectCity.$error.required && (orgControlForm.selectCity.$dirty || orgControlForm.$submitted)"-->
class="has-error label" style="margin-left: 30px"> <!--class="has-error label" style="margin-left: 30px">-->
{{resources.OrganizationMsgCityRequired}}</p> <!--{{resources.OrganizationMsgCityRequired}}</p>-->
</div> </div>
<div class="col-sm-5" style="padding-left: 10px;" <div class="col-sm-3" style="width: 31%"
ng-class="{'has-error':orgControlForm.selectDistrict.$invalid && (orgControlForm.selectDistrict.$dirty || orgControlForm.$submitted)}"> ng-class="{'has-error':orgControlForm.selectDistrict.$invalid && (orgControlForm.selectDistrict.$dirty || orgControlForm.$submitted)}">
<select class="form-control localRequired" name="selectDistrict" <select class="form-control" name="selectDistrict" style="width: 90px;"
id="selectDistrict" style="width: 119px; " id="selectDistrict"
ng-model="selectRegionID"> ng-model="selectRegionID">
<option value="">{{pleaseSelect}}</option> <option value="">{{pleaseSelect}}</option>
<option ng-repeat="x in DistrictList" value="{{x.regionID}}" <option ng-repeat="x in DistrictList" value="{{x.regionID}}"
...@@ -472,9 +472,9 @@ ...@@ -472,9 +472,9 @@
limitString:10}} limitString:10}}
</option> </option>
</select> </select>
<p ng-show="orgControlForm.selectDistrict.$error.required && (orgControlForm.selectDistrict.$dirty || orgControlForm.$submitted)" <!--<p ng-show="orgControlForm.selectDistrict.$error.required && (orgControlForm.selectDistrict.$dirty || orgControlForm.$submitted)"-->
class="has-error label" style="margin-left: 30px"> <!--class="has-error label" style="margin-left: 30px">-->
{{resources.OrganizationMsgCityRequired}}</p> <!--{{resources.OrganizationMsgCityRequired}}</p>-->
</div> </div>
</div> </div>
</div> </div>
......
...@@ -11,10 +11,18 @@ function ($http, apiConfig, httpCacheService) { ...@@ -11,10 +11,18 @@ function ($http, apiConfig, httpCacheService) {
//return $http.get('/areaRegion/getProvinces', apiConfig.create()); //return $http.get('/areaRegion/getProvinces', apiConfig.create());
return httpCacheService.get('/areaRegion/getProvinces'); return httpCacheService.get('/areaRegion/getProvinces');
}, },
getProvincesByCityID: function (cityID) {
//return $http.get('/areaRegion/getCities?parentID=' + parentID, apiConfig.create());
return $http.get('/areaRegion/getProvincesByCityID?cityID=' + cityID, apiConfig.create());
},
getCities: function (parentID) { getCities: function (parentID) {
//return $http.get('/areaRegion/getCities?parentID=' + parentID, apiConfig.create()); //return $http.get('/areaRegion/getCities?parentID=' + parentID, apiConfig.create());
return httpCacheService.get('/areaRegion/getCities?parentID=' + parentID); return httpCacheService.get('/areaRegion/getCities?parentID=' + parentID);
}, },
getCitiesNoCache: function (parentID) {
//return $http.get('/areaRegion/getCities?parentID=' + parentID, apiConfig.create());
return $http.get('/areaRegion/getCities?parentID=' + parentID);
},
getDistricts: function (parentID) { getDistricts: function (parentID) {
//return $http.get('/areaRegion/getCities?parentID=' + parentID, apiConfig.create()); //return $http.get('/areaRegion/getCities?parentID=' + parentID, apiConfig.create());
return httpCacheService.get('/areaRegion/getDistricts?parentID=' + parentID); return httpCacheService.get('/areaRegion/getDistricts?parentID=' + parentID);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment