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 {
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")
@RequestMapping(value = "getProvinces", method = RequestMethod.GET)
public @ResponseBody
......
......@@ -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) {
List<AreaRegionDto> districts = getRegions(CommonConstants.REGION_LEVELTYPE_DISTRICT);
List<AreaRegionDto> query = districts.stream().filter(s -> s.getRegionParentId().equals(parentId))
......
......@@ -126,6 +126,17 @@ public class OrganizationDto {
public List<OrganizationDto> sameVehicleroutinglocationList;
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() {
return this.id;
}
......
......@@ -558,6 +558,7 @@
<result column="PARENT_REGION_ID" jdbcType="VARCHAR" property="parentRegionId"/>
<result column="AREA_NAME" jdbcType="VARCHAR" property="areaName"/>
<result column="BUSINESS_UNIT_NAME" jdbcType="VARCHAR" property="businessUnitName"/>
<result column="level_type" jdbcType="INTEGER" property="levelType" />
</resultMap>
<select id="getSingleOrgByOrgIdToOrgDto" parameterType="map" resultMap="OrgDtoForGetSingleOrgByOrgID">
......@@ -565,6 +566,7 @@
M.*,
N.name AS INDUSTRY_NAME,
CONCAT(PREGION.name,T.name) AS REGION_NAME,
T.level_type AS level_type,
S.name AS STRUCTURE_NAME,
T.parent_id AS PARENT_REGION_ID,
AR.name AS AREA_NAME,
......
......@@ -303,8 +303,8 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', '
}
// 区域是必填项
if ($scope.selectProvince && $scope.selectRegionID) {
editModel.regionID = $scope.selectRegionID;
if ($scope.selectProvince && ($scope.selectCity || $scope.selectRegionID)) {
editModel.regionID = $scope.selectRegionID || $scope.selectCity.regionID;
}
var pId = editModel.parentID;
......@@ -669,16 +669,26 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', '
// 获取省市
var loadProvinceList = function () {
areaRegionService.getProvinces().success(function (data) {
if (data && data.length > 0) {
$scope.ProvinceList = data;
$scope.selectProvince = _.find($scope.ProvinceList, function (num) {
return num.regionID === $scope.editOrgModel.parentRegionID;
});
if ($scope.selectProvince) {
loadCityList($scope.selectProvince.regionID);
//根据当前机构的父级(即市的层级)获取对应的省的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) {
return num.regionID === resp.regionID;
});
if ($scope.selectProvince) {
loadCityList($scope.selectProvince.regionID);
}
}
});
} else {
data = null;
......@@ -690,26 +700,21 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', '
// 加载城市信息
var loadCityList = function (regionID) {
regionID = $scope.selectProvince.regionID;
if (regionID !== undefined && regionID !== null) {
areaRegionService.getCities(regionID).success(function (data) {
if (data && data.length > 0) {
$scope.CityList = data;
$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) {
$scope.selectCityID = $scope.selectCity.regionID;
$scope.selectProvince = _.find($scope.ProvinceList, function (num) {
return num.regionID === $scope.selectCity.parentRegionID;
});
loadDistrictList($scope.selectCity.regionID);
}else{
$scope.selectCityID = data[0].regionID;
}
} else {
......@@ -717,7 +722,6 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', '
$scope.CityList = data;
$scope.selectCity = data;
}
});
}
};
......@@ -731,21 +735,24 @@ controller('editOrganizationModalController', ['$scope', '$log', '$translate', '
$scope.DistrictList = data;
var target = _.find($scope.DistrictList, function (num) {
return num.regionID === $scope.selectCity;
return num.regionID === $scope.editOrgModel.regionID;
});
if (target) {
$scope.selectRegionID = $scope.editOrgModel.regionID;
} else {
$scope.selectRegionID = data[0].regionID;
}else{
$scope.selectRegionID = "";
}
} else {
data = null;
$scope.DistrictList = data;
$scope.selectRegionID = null;
$scope.selectRegionID = "";
}
});
}else {
$scope.DistrictList = null;
$scope.selectRegionID = "";
}
};
......
......@@ -436,35 +436,35 @@
<div class="form-group" ng-show="isLocal">
<label class="col-sm-3 control-label"><span
class="must-input">*</span>{{'AdministrativeRegion' | translate}}:</label>
<div class="col-sm-9 row">
<div class="col-sm-5" style="padding-left: 0px;"
<div class="col-sm-9" style="width: 69%;left: -3%;">
<div class="col-sm-3" style="width: 31%"
ng-class="{'has-error':orgControlForm.selectProvince.$invalid && (orgControlForm.selectProvince.$dirty || orgControlForm.$submitted)}">
<select class="form-control localRequired" name="selectProvince"
style="width: 120px; " ng-change="populateCities()"
<select class="form-control localRequired" style="width: 90px;" name="selectProvince"
ng-change="populateCities()"
ng-model="selectProvince"
ng-options="x.regionName for x in ProvinceList">
<option value="">{{pleaseSelect}}</option>
</select>
<p ng-show="orgControlForm.selectProvince.$error.required && (orgControlForm.selectProvince.$dirty || orgControlForm.$submitted)"
class="has-error label" style="margin-left: -16px">
{{resources.OrganizationMsgProvinceRequired}}</p>
<!--<p ng-show="orgControlForm.selectProvince.$error.required && (orgControlForm.selectProvince.$dirty || orgControlForm.$submitted)"-->
<!--class="has-error label" style="margin-left: -16px">-->
<!--{{resources.OrganizationMsgProvinceRequired}}</p>-->
</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)}">
<select class="form-control localRequired" name="selectCity"
style="width: 120px; " ng-change="populateDistricts()"
<select class="form-control localRequired" name="selectCity"
ng-change="populateDistricts()" style="width: 90px;"
ng-model="selectCity"
ng-options="x.regionName for x in CityList">
<option value="">{{pleaseSelect}}</option>
</select>
<p ng-show="orgControlForm.selectCity.$error.required && (orgControlForm.selectCity.$dirty || orgControlForm.$submitted)"
class="has-error label" style="margin-left: 30px">
{{resources.OrganizationMsgCityRequired}}</p>
<!--<p ng-show="orgControlForm.selectCity.$error.required && (orgControlForm.selectCity.$dirty || orgControlForm.$submitted)"-->
<!--class="has-error label" style="margin-left: 30px">-->
<!--{{resources.OrganizationMsgCityRequired}}</p>-->
</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)}">
<select class="form-control localRequired" name="selectDistrict"
id="selectDistrict" style="width: 119px; "
<select class="form-control" name="selectDistrict" style="width: 90px;"
id="selectDistrict"
ng-model="selectRegionID">
<option value="">{{pleaseSelect}}</option>
<option ng-repeat="x in DistrictList" value="{{x.regionID}}"
......@@ -472,9 +472,9 @@
limitString:10}}
</option>
</select>
<p ng-show="orgControlForm.selectDistrict.$error.required && (orgControlForm.selectDistrict.$dirty || orgControlForm.$submitted)"
class="has-error label" style="margin-left: 30px">
{{resources.OrganizationMsgCityRequired}}</p>
<!--<p ng-show="orgControlForm.selectDistrict.$error.required && (orgControlForm.selectDistrict.$dirty || orgControlForm.$submitted)"-->
<!--class="has-error label" style="margin-left: 30px">-->
<!--{{resources.OrganizationMsgCityRequired}}</p>-->
</div>
</div>
</div>
......
......@@ -11,10 +11,18 @@ function ($http, apiConfig, httpCacheService) {
//return $http.get('/areaRegion/getProvinces', apiConfig.create());
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) {
//return $http.get('/areaRegion/getCities?parentID=' + parentID, apiConfig.create());
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) {
//return $http.get('/areaRegion/getCities?parentID=' + parentID, apiConfig.create());
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