From 9a50a7ea9688a1e777f98713560e9c599d5064ae Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 08 三月 2023 18:01:34 +0800
Subject: [PATCH] 省市区三级联动修改

---
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java            |    6 
 management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOfficeAreaAdd.html                     |    8 
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java |   69 ++++-
 management/guns-admin/src/main/webapp/WEB-INF/view/system/tAgent/tAgentArea.html                                      |    8 
 management/guns-admin/src/main/webapp/static/modular/system/tBranchOffice/tBranchOffice.js                            |   12 
 management/guns-admin/src/main/webapp/static/modular/system/tCoupon/tCoupon_info.js                                   |    4 
 management/guns-admin/src/main/webapp/WEB-INF/view/system/tAgent/tAgent_add.html                                      |   31 --
 management/guns-admin/src/main/webapp/WEB-INF/view/system/tDriver/tDriverAreaUpdate.html                              |   10 
 management/guns-admin/src/main/webapp/static/modular/system/tDriver/tDriver.js                                        |   86 ++++++
 management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOfficeAreaUpdate.html                  |    6 
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TAgentController.java        |   25 +
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java       |   68 ++++-
 management/guns-admin/src/main/webapp/WEB-INF/view/system/tDriver/tDriverAreaAdd.html                                 |   14 
 management/guns-admin/src/main/webapp/WEB-INF/view/system/tCoupon/tCoupon_add.html                                    |  211 ++++++++--------
 management/guns-admin/src/main/webapp/static/modular/system/tCoupon/tCoupon.js                                        |   24 +
 management/guns-admin/src/main/webapp/static/modular/system/tAgent/tAgent.js                                          |   47 +++
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TBranchOfficeServiceImpl.java      |    3 
 management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOffice_add.html                        |    2 
 management/guns-admin/src/main/webapp/static/modular/system/tAgent/tAgent_info.js                                     |   44 +++
 19 files changed, 482 insertions(+), 196 deletions(-)

diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TAgentController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TAgentController.java
index 9d5c098..4cd62ee 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TAgentController.java
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TAgentController.java
@@ -97,9 +97,28 @@
      * 跳转区域页面
      */
     @RequestMapping("/areaDetail")
-    public String areaDetail(Model model) {
+    public String areaDetail(String area,String areaId,Model model) {
+        String[] split1 = areaId.split("/");
         List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
         model.addAttribute("province",tRegions);
+        List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList());
+        // 查询市
+        List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0]));
+        model.addAttribute("cityList",tRegions1);
+        if(StringUtils.hasLength(area) && StringUtils.hasLength(areaId)){
+            String[] split = area.split("/");
+            model.addAttribute("provinceName",split[0]);
+            model.addAttribute("cityName",split[1]);
+
+            model.addAttribute("provinceId",split1[0]);
+            model.addAttribute("cityId",split1[1]);
+        }else {
+            model.addAttribute("provinceName","");
+            model.addAttribute("cityName","");
+
+            model.addAttribute("provinceId","");
+            model.addAttribute("cityId","");
+        }
         return PREFIX + "tAgentArea.html";
     }
 
@@ -131,7 +150,9 @@
     @ResponseBody
     public Object add(TAgent tAgent) {
 
-        int count = tAgentService.selectCount(new EntityWrapper<TAgent>().eq("principalPhone", tAgent.getPrincipalPhone()));
+        String[] split1 = tAgent.getArea().split("/");
+
+        int count = tAgentService.selectCount(new EntityWrapper<TAgent>().eq("provinceName", split1[0]).eq("cityName",split1[1]));
         if(count>0){
             return new SuccessTip(500,"该代理商已存在!");
         }
diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java
index 55f20e3..a4b60b0 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java
@@ -13,6 +13,7 @@
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Controller;
+import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
@@ -115,22 +116,13 @@
      * 跳转区域页面新增
      */
     @RequestMapping("/areaPageAdd")
-    public String areaPageAdd(Model model) {
-        List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
-        model.addAttribute("provinceList",tRegions);
-        return PREFIX + "tBranchOfficeAreaAdd.html";
-    }
-
-    /**
-     * 跳转区域页面编辑
-     */
-    @RequestMapping("/areaPageUpdate")
-    public String areaPageUpdate(String area,String areaId,Model model) {
+    public String areaPageAdd(String area,String areaId,Model model) {
+        String[] split1 = areaId.split("/");
         List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
         model.addAttribute("provinceList",tRegions);
         List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList());
         // 查询市
-        List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", provinceIds));
+        List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0]));
         model.addAttribute("cityList",tRegions1);
 
         // 查询区
@@ -148,7 +140,6 @@
                 model.addAttribute("districtName","");
             }
 
-            String[] split1 = areaId.split("/");
             model.addAttribute("provinceId",split1[0]);
             model.addAttribute("cityId",split1[1]);
             if(split1.length>2) {
@@ -156,7 +147,55 @@
             }else {
                 model.addAttribute("districtId", "");
             }
+        }else {
+            model.addAttribute("provinceName","");
+            model.addAttribute("cityName","split[1]");
+            model.addAttribute("districtName","");
+
+            model.addAttribute("provinceId","");
+            model.addAttribute("cityId","split1[1]");
+            model.addAttribute("districtId", "");
         }
+        return PREFIX + "tBranchOfficeAreaAdd.html";
+    }
+
+    /**
+     * 跳转区域页面编辑
+     */
+    @RequestMapping("/areaPageUpdate")
+    public String areaPageUpdate(String area,String areaId,Model model) {
+
+        String[] split = area.split("/");
+        model.addAttribute("provinceName",split[0]);
+        model.addAttribute("cityName",split[1]);
+        if(split.length>2){
+            model.addAttribute("districtName",split[2]);
+        }else {
+            model.addAttribute("districtName","");
+        }
+
+        String[] split1 = areaId.split("/");
+        String provinceId = split1[0];
+        model.addAttribute("provinceId",split1[0]);
+        model.addAttribute("cityId",split1[1]);
+        if(split1.length>2) {
+            model.addAttribute("districtId", split1[2]);
+        }else {
+            model.addAttribute("districtId", "");
+        }
+
+        List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
+        model.addAttribute("provinceList",tRegions);
+//        List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList());
+        // 查询市
+        List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", provinceId));
+        model.addAttribute("cityList",tRegions1);
+
+        // 查询区
+        List<Integer> cityIds = tRegions1.stream().map(TRegion::getId).collect(Collectors.toList());
+        List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", cityIds));
+        model.addAttribute("districtList",tRegions2);
+
         return PREFIX + "tBranchOfficeAreaUpdate.html";
     }
 
@@ -177,6 +216,10 @@
     @ResponseBody
     public Object areaCity(Integer parentId,Model model) {
         List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", parentId));
+        /*if(CollectionUtils.isEmpty(tRegions) && StringUtils.hasLength(parentName)){
+            TRegion parent = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("name", parentName));
+            tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", parentId));
+        }*/
         model.addAttribute("list",tRegions);
         return tRegions;
     }
diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
index 54fc2f8..ac13512 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java
@@ -211,11 +211,46 @@
      */
     @RequestMapping("/areaPageUpdate")
     public String areaPageUpdate(String area,String areaId,Model model) {
+
+        String[] split = area.split("/");
+        model.addAttribute("provinceName",split[0]);
+        model.addAttribute("cityName",split[1]);
+        model.addAttribute("districtName",split[2]);
+
+        String[] split1 = areaId.split("/");
+        model.addAttribute("provinceId",split1[0]);
+        model.addAttribute("cityId",split1[1]);
+        model.addAttribute("districtId",split1[2]);
+
+
+        List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
+        model.addAttribute("provinceList",tRegions);
+        List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList());
+
+
+        // 查询市
+        List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0]));
+        model.addAttribute("cityList",tRegions1);
+
+        // 查询区
+        List<Integer> cityIds = tRegions1.stream().map(TRegion::getId).collect(Collectors.toList());
+        List<TRegion> tRegions2 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", cityIds));
+        model.addAttribute("districtList",tRegions2);
+
+        return PREFIX + "tDriverAreaUpdate.html";
+    }
+
+    /**
+     * 跳转区域页面新增
+     */
+    @RequestMapping("/areaPageAdd")
+    public String areaPageAdd(String area,String areaId,Model model) {
+        String[] split1 = areaId.split("/");
         List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
         model.addAttribute("provinceList",tRegions);
         List<Integer> provinceIds = tRegions.stream().map(TRegion::getId).collect(Collectors.toList());
         // 查询市
-        List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().in("parent_id", provinceIds));
+        List<TRegion> tRegions1 = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", split1[0]));
         model.addAttribute("cityList",tRegions1);
 
         // 查询区
@@ -227,23 +262,28 @@
             String[] split = area.split("/");
             model.addAttribute("provinceName",split[0]);
             model.addAttribute("cityName",split[1]);
-            model.addAttribute("districtName",split[2]);
+            if(split.length>2){
+                model.addAttribute("districtName",split[2]);
+            }else {
+                model.addAttribute("districtName","");
+            }
 
-            String[] split1 = areaId.split("/");
             model.addAttribute("provinceId",split1[0]);
             model.addAttribute("cityId",split1[1]);
-            model.addAttribute("districtId",split1[2]);
-        }
-        return PREFIX + "tDriverAreaUpdate.html";
-    }
+            if(split1.length>2) {
+                model.addAttribute("districtId", split1[2]);
+            }else {
+                model.addAttribute("districtId", "");
+            }
+        }else {
+            model.addAttribute("provinceName","");
+            model.addAttribute("cityName","split[1]");
+            model.addAttribute("districtName","");
 
-    /**
-     * 跳转区域页面新增
-     */
-    @RequestMapping("/areaPageAdd")
-    public String areaPageAdd(Model model) {
-        List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
-        model.addAttribute("provinceList",tRegions);
+            model.addAttribute("provinceId","");
+            model.addAttribute("cityId","split1[1]");
+            model.addAttribute("districtId", "");
+        }
         return PREFIX + "tDriverAreaAdd.html";
     }
 
diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TBranchOfficeServiceImpl.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TBranchOfficeServiceImpl.java
index 4d5b211..cfa89e7 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TBranchOfficeServiceImpl.java
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TBranchOfficeServiceImpl.java
@@ -218,6 +218,9 @@
             }
             tBranchOffice.setDistrictName(area.getName());
             tBranchOffice.setDistrictCode(area.getCode());
+        }else {
+            tBranchOffice.setDistrictName("");
+            tBranchOffice.setDistrictCode("");
         }
 
         // 通过省市查询代理商
diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java
index 818891c..b580ea6 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java
@@ -109,8 +109,10 @@
             TDriverResp tDriverResp = new TDriverResp();
             BeanUtils.copyProperties(tDriver,tDriverResp);
 
-            // 设置余额
-            tDriverResp.setBalance(tDriver.getBackgroundBalance().add(tDriver.getBalance()));
+            if(Objects.nonNull(tDriver.getBackgroundBalance()) && Objects.nonNull(tDriver.getBalance())){
+                // 设置余额
+                tDriverResp.setBalance(tDriver.getBackgroundBalance().add(tDriver.getBalance()));
+            }
 
             // 所属代理商
             TAgent tAgent = tAgentMapper.selectById(tDriver.getAgentId());
diff --git a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tAgent/tAgentArea.html b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tAgent/tAgentArea.html
index b3989b7..ef237ec 100644
--- a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tAgent/tAgentArea.html
+++ b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tAgent/tAgentArea.html
@@ -8,15 +8,19 @@
                         <div class="col-sm-6 control-label">
                             <label  class="col-sm-1" style="width: 20px;">省:</label>
                             <select class="input-group col-sm-2 " onclick="TAgent.areaProvince()" id="province" style="width: 200px;height: 33px" name="province">
-                                <option value="">请选择省</option>
+                                <option value="">请选择</option>
                                 @for(i in province){
-                                <option id="${i.id}" value="${i.name}">${i.name}</option>
+                                <option id="${i.id}" value="${i.name}"${i.name == provinceName ? 'selected=selected' : ''}>${i.name}</option>
                                 @}
                             </select>
                         </div>
                         <div class="col-sm-6 control-label">
                             <label  class="col-sm-1" style="width: 20px;">市:</label>
                             <select class="input-group col-sm-2" id="city" style="width: 200px;height: 33px" name="city">
+                                <option value="">请选择</option>
+                                @for(city in cityList){
+                                <option id="${city.id}" value="${city.name}"${city.name == cityName ? 'selected=selected' : ''}>${city.name}</option>
+                                @}
                             </select>
                         </div>
                     </div>
diff --git a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tAgent/tAgent_add.html b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tAgent/tAgent_add.html
index ae8f418..7ebef5f 100644
--- a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tAgent/tAgent_add.html
+++ b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tAgent/tAgent_add.html
@@ -3,7 +3,7 @@
     <div class="ibox-content">
         <div class="form-horizontal">
 
-            <div class="row" >
+            <div class="row" id="tAgentInfoForm">
                 <div class="col-sm-12" style="text-align: center">
                     <input hidden id="areaId" value="areaId">
                     <div class="initialLevel col-sm-12 control-label form-group" style="text-align: center">
@@ -13,16 +13,6 @@
                             <input id="principal" name="principal" type="text" style="height: 30px" required>
                         </div>
                     </div>
-                    <!--<div class="col-sm-12">
-                        <div class="form-group">
-                            <span style="color:red">*</span>
-                            <label class="col-sm-3 control-label">负责人姓名:</label>
-                            <div class="col-sm-6">
-                                <input class="form-control" id="principal" name="principal" type="text">
-                            </div>
-                        </div>
-                        <div class="hr-line-dashed"></div>
-                    </div>-->
                     <div class="initialLevel col-sm-12 control-label form-group">
                         <div class="initialLevel col-sm-6 control-label form-group"  >
                             <span style="color:red">*</span>
@@ -34,7 +24,7 @@
                     <div class="initialLevel col-sm-12 control-label form-group">
                         <div class="initialLevel col-sm-6 control-label form-group"  >
                             <label class="control-label" >邮箱:</label>
-                            <input id="email" name="email" type="email" style="height: 30px" required>
+                            <input id="email" name="email" type="email" style="height: 30px">
                         </div>
                     </div>
 
@@ -42,32 +32,21 @@
                         <div class="initialLevel col-sm-6 control-label form-group"  >
                             <span style="color:red">*</span>
                             <label class="control-label" >代理区域:</label>
-                            <input id="area" onclick="TAgent.area()" name="area" placeholder="请选择" style="height: 30px" readonly>
+                            <input id="area" onclick="TAgent.area()" name="area" placeholder="请选择" style="height: 30px" readonly required>
                         </div>
                     </div>
-
-                    <!--<div class="col-sm-12">
-                        <div class="form-group">
-                            <span style="color:red">*</span>
-                            <label class="col-sm-3 control-label">代理区域:</label>
-                            <div class="col-sm-6">
-                                <input class="form-control" id="area" onclick="TAgent.area()" name="area" type="text" placeholder="请选择">
-                            </div>
-                        </div>
-                        <div class="hr-line-dashed"></div>
-                    </div>-->
 
                     <div class="initialLevel col-sm-12 control-label form-group">
                         <div class="initialLevel col-sm-6 control-label form-group"  >
                             <label class="control-label" >开户银行:</label>
-                            <input id="bankDeposit" name="bankDeposit" type="text" style="height: 30px" required>
+                            <input id="bankDeposit" name="bankDeposit" type="text" style="height: 30px">
                         </div>
                     </div>
 
                     <div class="initialLevel col-sm-12 control-label form-group">
                         <div class="initialLevel col-sm-6 control-label form-group"  >
                             <label class="control-label" >银行账户:</label>
-                            <input id="bankAccount" name="bankAccount" type="number" style="height: 30px" required>
+                            <input id="bankAccount" name="bankAccount" type="number" style="height: 30px">
                         </div>
                     </div>
 
diff --git a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOfficeAreaAdd.html b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOfficeAreaAdd.html
index 49ff49c..ed0b7df 100644
--- a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOfficeAreaAdd.html
+++ b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOfficeAreaAdd.html
@@ -11,7 +11,7 @@
                             <select class="input-group col-sm-2 " onclick="TBranchOffice.areaCity()" id="province" style="width: 200px;height: 33px" name="province">
                                 <option value="">请选择</option>
                                 @for(i in provinceList){
-                                <option id="${i.id}" value="${i.name}"}>${i.name}</option>
+                                <option id="${i.id}" value="${i.name}"${i.name == provinceName ? 'selected=selected' : ''}>${i.name}</option>
                                 @}
                             </select>
                         </div>
@@ -19,12 +19,18 @@
                             <label  class="col-sm-1" style="width: 20px;">市:</label>
                             <select class="input-group col-sm-2" onclick="TBranchOffice.areaDistrict()" id="city" style="width: 200px;height: 33px" name="city">
                                 <option value="">请选择</option>
+                                @for(city in cityList){
+                                <option id="${city.id}" value="${city.name}"${city.name == cityName ? 'selected=selected' : ''}>${city.name}</option>
+                                @}
                             </select>
                         </div>
                         <div class="col-sm-4 control-label">
                             <label  class="col-sm-1" style="width: 20px;">区:</label>
                             <select class="input-group col-sm-2" id="district" style="width: 200px;height: 33px" name="district">
                                 <option value="">请选择</option>
+                                @for(district in districtList){
+                                <option id="${district.id}" value="${district.name}"${district.name == districtName ? 'selected=selected' : ''}>${district.name}</option>
+                                @}
                             </select>
                         </div>
                     </div>
diff --git a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOfficeAreaUpdate.html b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOfficeAreaUpdate.html
index a51553e..45d2a7f 100644
--- a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOfficeAreaUpdate.html
+++ b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOfficeAreaUpdate.html
@@ -15,7 +15,7 @@
                         <div class="col-sm-4 control-label">
                             <label  class="col-sm-1" style="width: 20px;">省:</label>
                             <select class="input-group col-sm-2 " onclick="TBranchOffice.areaCity()" id="province" style="width: 200px;height: 33px" name="province">
-                                <option value="">请选择省</option>
+                                <option value="">请选择</option>
                                 @for(i in provinceList){
                                 <option id="${i.id}" value="${i.name}"${i.name == provinceName ? 'selected=selected' : ''}>${i.name}</option>
                                 @}
@@ -24,7 +24,7 @@
                         <div class="col-sm-4 control-label">
                             <label  class="col-sm-1" style="width: 20px;">市:</label>
                             <select class="input-group col-sm-2" onclick="TBranchOffice.areaDistrict()" id="city" style="width: 200px;height: 33px" name="city">
-                                <option>请选择市</option>
+                                <option>请选择</option>
                                 @for(city in cityList){
                                 <option id="${city.id}" value="${city.name}"${city.name == cityName ? 'selected=selected' : ''}>${city.name}</option>
                                 @}
@@ -33,7 +33,7 @@
                         <div class="col-sm-4 control-label">
                             <label  class="col-sm-1" style="width: 20px;">区:</label>
                             <select class="input-group col-sm-2" id="district" style="width: 200px;height: 33px" name="district">
-                                <option>请选择区</option>
+                                <option>请选择</option>
                                 @for(district in districtList){
                                 <option id="${district.id}" value="${district.name}"${district.name == districtName ? 'selected=selected' : ''}>${district.name}</option>
                                 @}
diff --git a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOffice_add.html b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOffice_add.html
index 76755e1..8df3c2e 100644
--- a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOffice_add.html
+++ b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tBranchOffice/tBranchOffice_add.html
@@ -8,7 +8,7 @@
             <div class="ibox-content" id="branchOfficeInfoForm">
                 <div class="row row-lg">
                     <div class="col-sm-12">
-                        <input hidden id="areaId">
+                        <input hidden id="areaId" value="areaId">
 
                         <div class="col-sm-12" style="cursor: pointer;text-align: right;">
                             <div class="initialLevel col-sm-12 control-label form-group"  >
diff --git a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tCoupon/tCoupon_add.html b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tCoupon/tCoupon_add.html
index 7e47f7a..7542e6e 100644
--- a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tCoupon/tCoupon_add.html
+++ b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tCoupon/tCoupon_add.html
@@ -1,118 +1,117 @@
 @layout("/common/_container.html"){
-<div class="ibox float-e-margins">
-    <div class="ibox-content">
-        <div class="form-horizontal" id="couponInfoForm">
-
-            <div class="row">
-                <div class="col-sm-12">
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label">优惠券名称:</label>
-                        <div class="col-sm-6">
-                            <input class="form-control" id="couponName" name="couponName" type="text" required>
-                        </div>
-                    </div>
-                    <div class="hr-line-dashed"></div>
-                </div>
-
-                <div class="col-sm-12">
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label">优惠券类型:</label>
-                        <select class="input-group col-sm-6" id="couponType" name="couponType" required>
-                            <option value="">请选择优惠券类型</option>
-                            <option value="1">活动券</option>
-                            <option value="2">新人券</option>
-                        </select>
-                    </div>
-                    <div class="hr-line-dashed"></div>
-                </div>
-
-                <div class="col-sm-12">
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label">服务类类型:</label>
-                        <select class="input-group col-sm-6" id="couponServiceType" name="couponServiceType" required>
-                            <option value="">请选择服务类型</option>
-                            <option value="1">通用型</option>
-                        </select>
-                    </div>
-                    <div class="hr-line-dashed"></div>
-                </div>
-
-                <div class="col-sm-12">
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label">优惠券限制数量:</label>
-                        <div class="col-sm-6">
-                            <input class="form-control" id="couponCount" name="couponCount" type="number" required>
-                        </div>
-                    </div>
-                    <div class="hr-line-dashed"></div>
-                </div>
-
-                <div class="col-sm-12">
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label">条件金额:订单满</label>
-                        <div class="col-sm-6">
-                            <input class="form-control" id="couponConditionalAmount" name="couponConditionalAmount" type="number" required>
-                        </div>
-                        <label class="col-sm-2 control-label">可使用</label>
-                    </div>
-                    <div class="hr-line-dashed"></div>
-                </div>
-
-                <div class="col-sm-12">
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label">优惠金额:</label>
-                        <div class="col-sm-6">
-                            <input class="form-control" id="couponPreferentialAmount" name="couponPreferentialAmount" type="number" required>
-                        </div>
-                    </div>
-                    <div class="hr-line-dashed"></div>
-                </div>
-
-                <div class="col-sm-12">
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label">有效期:</label>
-                        <div class="col-sm-6">
-                            <input class="form-control" id="couponValidity" name="couponValidity" type="number" required>
-                        </div>
-                        <label class="col-sm-1 control-label">天</label>
-                    </div>
-                    <div class="hr-line-dashed"></div>
-                </div>
-
-                <div class="col-sm-12">
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label">优惠券总量:</label>
-                        <div class="col-sm-6">
-                            <input class="form-control" id="remainingQuantity" name="remainingQuantity" type="number" required>
-                        </div>
-                    </div>
-                    <div class="hr-line-dashed"></div>
-                </div>
-
-                <div class="col-sm-12">
-                    <div class="form-group">
-                        <label class="col-sm-3 control-label">赠送数量:</label>
-                        <div class="col-sm-6">
-                            <input class="form-control" id="couponSendQuantity" name="couponSendQuantity" type="number">
-                        </div>
-                        <label class="col-sm-1 control-label">张</label>
-                    </div>
-                    <div class="hr-line-dashed"></div>
-                </div>
-
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-title">
+                <h5>添加</h5>
             </div>
+            <div class="ibox-content" id="couponInfoForm">
 
-            <div class="row btn-group-m-t">
-                <div class="col-sm-10" style="text-align: center">
-                    <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="TCouponInfoDlg.addSubmit()"/>
-                    <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="TCouponInfoDlg.close()"/>
+                <div class="row row-lg">
+                    <div class="col-sm-12" style="cursor: pointer;text-align: right;">
+
+                        <div class="initialLevel col-sm-12 control-label form-group"  >
+                            <div class="initialLevel col-sm-3 control-label form-group"  >
+                                <span style="color:red">*</span>
+                                <label class="control-label" >优惠券名称:</label>
+                                <input id="couponName" name="couponName" type="text" style="height: 30px" required="required">
+                            </div>
+                        </div>
+
+                        <div class="initialLevel col-sm-12 control-label form-group"  >
+                            <div class="initialLevel col-sm-3 control-label form-group"  >
+                                <span style="color:red">*</span>
+                                <label class="control-label" >优惠券类型:</label>
+                                <select id="couponType" name="couponType" onclick="TCoupon.changeCouponType()" style="height: 30px" required>
+                                    <option value="">请选择优惠券类型</option>
+                                    <option value="1">活动券</option>
+                                    <option value="2">新人券</option>
+                                </select>
+                            </div>
+                        </div>
+
+                        <div class="initialLevel col-sm-12 control-label form-group"  >
+                            <div class="initialLevel col-sm-3 control-label form-group"  >
+                                <span style="color:red">*</span>
+                                <label class=" control-label">服务类类型:</label>
+                                <select id="couponServiceType" name="couponServiceType" style="height: 30px" required>
+                                    <option value="">请选择服务类类型</option>
+                                    <option value="1">通用型</option>
+                                </select>
+                            </div>
+                        </div>
+
+                        <div class="initialLevel col-sm-12 control-label form-group"  >
+                            <div class="initialLevel col-sm-3 control-label form-group"  >
+                                <span style="color:red">*</span>
+                                <label class="control-label">优惠券限制数量:</label>
+                                <input id="couponCount" name="couponCount" type="number" style="height: 30px" required>
+                            </div>
+                        </div>
+
+                        <div class="initialLevel col-sm-12 control-label form-group"  >
+                            <div class="initialLevel col-sm-3 control-label form-group"  >
+                                <span style="color:red">*</span>
+                                <label class="control-label">条件金额:订单满</label>
+                                <input id="couponConditionalAmount" name="couponConditionalAmount" type="number" style="height: 30px" required>
+                            </div>
+                            <div class="initialLevel col-sm-3 control-label form-group" style="text-align: left" >
+                                <label>可使用</label>
+                            </div>
+                        </div>
+
+                        <div class="initialLevel col-sm-12 control-label form-group"  >
+                            <div class="initialLevel col-sm-3 control-label form-group"  >
+                                <span style="color:red">*</span>
+                                <label class="control-label">优惠金额:</label>
+                                <input id="couponPreferentialAmount" name="couponPreferentialAmount" type="number" style="height: 30px" required>
+                            </div>
+                        </div>
+
+                        <div class="initialLevel col-sm-12 control-label form-group"  >
+                            <div class="initialLevel col-sm-3 control-label form-group"  >
+                                <span style="color:red">*</span>
+                                <label class="control-label">有效期:</label>
+                                <input id="couponValidity" name="couponValidity" type="number" style="height: 30px" required>
+                            </div>
+                            <div class="initialLevel col-sm-3 control-label form-group" style="text-align: left" >
+                                <label>天</label>
+                            </div>
+                        </div>
+
+                        <div class="initialLevel col-sm-12 control-label form-group"  >
+                            <div class="initialLevel col-sm-3 control-label form-group"  >
+                                <span style="color:red">*</span>
+                                <label class="control-label">优惠券总量:</label>
+                                <input id="remainingQuantity" name="remainingQuantity" type="number" style="height: 30px" required>
+                            </div>
+                        </div>
+
+                        <div class="initialLevel col-sm-12 control-label form-group" hidden id="changeCouponSendQuantity" >
+                            <div class="initialLevel col-sm-3 control-label form-group"  >
+                                <span style="color:red">*</span>
+                                <label class="control-label">赠送数量:</label>
+                                <input id="couponSendQuantity" name="couponSendQuantity" type="number" style="height: 30px" required>
+                            </div>
+                            <div class="initialLevel col-sm-3 control-label form-group" style="text-align: left" >
+                                <label>张</label>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="row btn-group-m-t">
+                    <div class="col-sm-10" style="text-align: center">
+                        <#button btnCss="info" name="提交" id="ensure" icon="fa-check" clickFun="TCouponInfoDlg.addSubmit()"/>
+                        <#button btnCss="danger" name="取消" id="cancel" icon="fa-eraser" clickFun="TCouponInfoDlg.close()"/>
+                    </div>
                 </div>
             </div>
         </div>
-
     </div>
 </div>
 <script src="${ctxPath}/static/modular/system/tCoupon/tCoupon_info.js"></script>
+<script src="${ctxPath}/static/modular/system/tCoupon/tCoupon.js"></script>
 <script type="text/javascript">
 </script>
 @}
diff --git a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tDriver/tDriverAreaAdd.html b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tDriver/tDriverAreaAdd.html
index 0caa811..f78daf4 100644
--- a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tDriver/tDriverAreaAdd.html
+++ b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tDriver/tDriverAreaAdd.html
@@ -9,22 +9,28 @@
                         <div class="col-sm-4 control-label">
                             <label  class="col-sm-1" style="width: 20px;">省:</label>
                             <select class="input-group col-sm-2 " onclick="TDriver.areaCity()" id="province" style="width: 200px;height: 33px" name="province">
-                                <option value="">请选择省</option>
+                                <option value="">请选择</option>
                                 @for(i in provinceList){
-                                <option id="${i.id}" value="${i.name}"}>${i.name}</option>
+                                <option id="${i.id}" value="${i.name}"${i.name == provinceName ? 'selected=selected' : ''}>${i.name}</option>
                                 @}
                             </select>
                         </div>
                         <div class="col-sm-4 control-label">
                             <label  class="col-sm-1" style="width: 20px;">市:</label>
                             <select class="input-group col-sm-2" onclick="TDriver.areaDistrict()" id="city" style="width: 200px;height: 33px" name="city">
-                                <option>请选择市</option>
+                                <option>请选择</option>
+                                @for(city in cityList){
+                                <option id="${city.id}" value="${city.name}"${city.name == cityName ? 'selected=selected' : ''}>${city.name}</option>
+                                @}
                             </select>
                         </div>
                         <div class="col-sm-4 control-label">
                             <label  class="col-sm-1" style="width: 20px;">区:</label>
                             <select class="input-group col-sm-2" id="district" style="width: 200px;height: 33px" name="district">
-                                <option>请选择区</option>
+                                <option>请选择</option>
+                                @for(district in districtList){
+                                <option id="${district.id}" value="${district.name}"${district.name == districtName ? 'selected=selected' : ''}>${district.name}</option>
+                                @}
                             </select>
                         </div>
                     </div>
diff --git a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tDriver/tDriverAreaUpdate.html b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tDriver/tDriverAreaUpdate.html
index 2876b71..1d53dbf 100644
--- a/management/guns-admin/src/main/webapp/WEB-INF/view/system/tDriver/tDriverAreaUpdate.html
+++ b/management/guns-admin/src/main/webapp/WEB-INF/view/system/tDriver/tDriverAreaUpdate.html
@@ -5,17 +5,17 @@
             <div class="ibox-content">
                 <div class="row row-lg">
                     <div class="col-sm-12" style="height: 100px;">
-                        <input hidden id="provinceName" value="${provinceName}">
+                        <!--<input hidden id="provinceName" value="${provinceName}">
                         <input hidden id="cityName" value="${cityName}">
                         <input hidden id="districtName" value="${districtName}">
                         <input hidden id="provinceId" value="${provinceId}">
                         <input hidden id="cityId" value="${cityId}">
-                        <input hidden id="districtId" value="${districtId}">
+                        <input hidden id="districtId" value="${districtId}">-->
 
                         <div class="col-sm-4 control-label">
                             <label  class="col-sm-1" style="width: 20px;">省:</label>
                             <select class="input-group col-sm-2 " onclick="TDriver.areaCity()" id="province" style="width: 200px;height: 33px" name="province">
-                                <option value="">请选择省</option>
+                                <option value="">请选择</option>
                                 @for(i in provinceList){
                                 <option id="${i.id}" value="${i.name}"${i.name == provinceName ? 'selected=selected' : ''}>${i.name}</option>
                                 @}
@@ -24,7 +24,7 @@
                         <div class="col-sm-4 control-label">
                             <label  class="col-sm-1" style="width: 20px;">市:</label>
                             <select class="input-group col-sm-2" onclick="TDriver.areaDistrict()" id="city" style="width: 200px;height: 33px" name="city">
-                                <option>请选择市</option>
+                                <option>请选择</option>
                                 @for(city in cityList){
                                 <option id="${city.id}" value="${city.name}"${city.name == cityName ? 'selected=selected' : ''}>${city.name}</option>
                                 @}
@@ -33,7 +33,7 @@
                         <div class="col-sm-4 control-label">
                             <label  class="col-sm-1" style="width: 20px;">区:</label>
                             <select class="input-group col-sm-2" id="district" style="width: 200px;height: 33px" name="district">
-                                <option>请选择区</option>
+                                <option>请选择</option>
                                 @for(district in districtList){
                                 <option id="${district.id}" value="${district.name}"${district.name == districtName ? 'selected=selected' : ''}>${district.name}</option>
                                 @}
diff --git a/management/guns-admin/src/main/webapp/static/modular/system/tAgent/tAgent.js b/management/guns-admin/src/main/webapp/static/modular/system/tAgent/tAgent.js
index da37990..044ec4d 100644
--- a/management/guns-admin/src/main/webapp/static/modular/system/tAgent/tAgent.js
+++ b/management/guns-admin/src/main/webapp/static/modular/system/tAgent/tAgent.js
@@ -130,13 +130,17 @@
  * 打开区域选择页面
  */
 TAgent.area = function () {
+
+    var area = $('#area').val();
+    var areaId = $('#areaId').val();
+
     var index = layer.open({
         type: 2,
         title: '区域选择',
         area: ['800px', '270px'], //宽高
         fix: false, //不固定
         maxmin: true,
-        content: Feng.ctxPath + '/tAgent/areaDetail'
+        content: Feng.ctxPath + '/tAgent/areaDetail?area='+area+"&areaId="+areaId
     });
     this.layerIndex = index;
 }
@@ -145,7 +149,32 @@
  * 查询市区
  */
 TAgent.areaProvince = function () {
-    var province = document.getElementById('province');
+
+    //监听第一个下拉菜单的变动操作
+    $("#province").change(function(){
+        //当第一级下拉列表没选择值时,将二级下拉列表和三级同时设置为空
+        if(this.value==""){
+            $("#city").empty();//二级联动设为空设为空
+            $("#city").append('<option value="">请选择</option>');
+        }
+        if(this.value!=""){//第一级下拉菜单选择了值
+            $("#city").empty();//先行置空,防止上次选择留下的元素影响效果
+            $("#city").append('<option value="">请选择</option>')//设置初始选项
+            var province = document.getElementById('province');
+            var index= province.selectedIndex ;
+            var id = province.options[index].id;
+            var ajax = new $ax(Feng.ctxPath + "/tAgent/areaCity?parentId="+id, function (data) {
+                for(var i=0,n=data.length;i<n;i++){//遍历
+                    $("#city").append('<option value="'+data[i].id+'">'+data[i].name+'</option>');//创造元素
+                }
+            }, function (data) {
+                Feng.error("查询失败!" + data.responseJSON.message + "!");
+            });
+            ajax.start();
+        }
+    });
+
+    /*var province = document.getElementById('province');
     var index= province.selectedIndex ;
     var id = province.options[index].id;
     var ajax = new $ax(Feng.ctxPath + "/tAgent/areaCity?parentId="+id, function (data) {
@@ -159,7 +188,7 @@
     }, function (data) {
         Feng.error("查询失败!" + data.responseJSON.message + "!");
     });
-    ajax.start();
+    ajax.start();*/
 }
 /**
  * 选择省市
@@ -169,10 +198,22 @@
     var provinceIndex= province.selectedIndex ;
     var provinceName = province.options[provinceIndex].value;
     var provinceId = province.options[provinceIndex].id;
+
+    if(provinceName == null || provinceName == ''){
+        Feng.error("请选择省份!")
+        return;
+    }
+
     var city = document.getElementById('city');
     var cityIndex= city.selectedIndex ;
     var cityId = city.options[cityIndex].value;
     var cityName = city.options[cityIndex].innerText;
+
+    if(cityName == null || cityName == '' || cityName =='请选择'){
+        Feng.error("请选择市区!")
+        return;
+    }
+
     parent.$("#area").val(provinceName+'/'+cityName)
     parent.$("#areaId").val(provinceId+'/'+cityId)
     TAgentInfoDlg.close();
diff --git a/management/guns-admin/src/main/webapp/static/modular/system/tAgent/tAgent_info.js b/management/guns-admin/src/main/webapp/static/modular/system/tAgent/tAgent_info.js
index 3077a02..77ce37c 100644
--- a/management/guns-admin/src/main/webapp/static/modular/system/tAgent/tAgent_info.js
+++ b/management/guns-admin/src/main/webapp/static/modular/system/tAgent/tAgent_info.js
@@ -2,7 +2,39 @@
  * 初始化详情对话框
  */
 var TAgentInfoDlg = {
-    tAgentInfoData : {}
+    tAgentInfoData : {},
+    validateFields: {
+        principal: {
+            validators: {
+                notEmpty: {
+                    message: '负责人姓名不能为空'
+                }
+            }
+        },
+        principalPhone: {
+            validators: {
+                notEmpty: {
+                    message: '联系电话不能为空'
+                }
+            }
+        },
+        area: {
+            validators: {
+                notEmpty: {
+                    message: '请选择代理区域'
+                }
+            }
+        },
+    }
+};
+
+/**
+ * 验证数据是否为空
+ */
+TAgentInfoDlg.validate = function () {
+    $('#tAgentInfoForm').data("bootstrapValidator").resetForm();
+    $('#tAgentInfoForm').bootstrapValidator('validate');
+    return $("#tAgentInfoForm").data('bootstrapValidator').isValid();
 };
 
 /**
@@ -67,6 +99,10 @@
     this.clearData();
     this.collectData();
 
+    if(!this.validate()){
+        return ;
+    }
+
     //提交信息
     var ajax = new $ax(Feng.ctxPath + "/tAgent/add", function(data){
         if(data.code == 500){
@@ -91,6 +127,10 @@
     this.clearData();
     this.collectData();
 
+    if(!this.validate()){
+        return ;
+    }
+
     //提交信息
     var ajax = new $ax(Feng.ctxPath + "/tAgent/update", function(data){
         Feng.success("修改成功!");
@@ -104,5 +144,5 @@
 }
 
 $(function() {
-
+    Feng.initValidator("tAgentInfoForm", TAgentInfoDlg.validateFields);
 });
diff --git a/management/guns-admin/src/main/webapp/static/modular/system/tBranchOffice/tBranchOffice.js b/management/guns-admin/src/main/webapp/static/modular/system/tBranchOffice/tBranchOffice.js
index df2ae54..c2e71ce 100644
--- a/management/guns-admin/src/main/webapp/static/modular/system/tBranchOffice/tBranchOffice.js
+++ b/management/guns-admin/src/main/webapp/static/modular/system/tBranchOffice/tBranchOffice.js
@@ -189,13 +189,17 @@
  * 打开区域选择页面新增
  */
 TBranchOffice.areaAdd = function () {
+
+    var area = $("#area").val();
+    var areaId = $("#areaId").val();
+
     var index = layer.open({
         type: 2,
         title: '区域选择',
         area: ['1000px', '270px'], //宽高
         fix: false, //不固定
         maxmin: true,
-        content: Feng.ctxPath + '/tBranchOffice/areaPageAdd'
+        content: Feng.ctxPath + '/tBranchOffice/areaPageAdd?area='+area+'&areaId='+areaId
     });
     this.layerIndex = index;
 }
@@ -287,7 +291,10 @@
 
             var city = document.getElementById('city');
             var cityIndex= city.selectedIndex ;
-            var id = city.options[cityIndex].value;
+            var id = city.options[cityIndex].id;
+            if(id == ""){
+                id = city.options[cityIndex].value;
+            }
             var ajax = new $ax(Feng.ctxPath + "/tBranchOffice/areaCity?parentId="+id, function (data) {
                 for(var i=0,n=data.length;i<n;i++){//对区数据进行遍历,动态生成
                     $("#district").append('<option value="'+data[i].id+'">'+data[i].name+'</option>');
@@ -352,7 +359,6 @@
         parent.$("#area").val(provinceName+'/'+cityName+'/'+districtName)
         parent.$("#areaId").val(provinceId+'/'+cityId+'/'+districtId)
     }
-    console.log()
     TBranchOfficeInfoDlg.close();
 }
 
diff --git a/management/guns-admin/src/main/webapp/static/modular/system/tCoupon/tCoupon.js b/management/guns-admin/src/main/webapp/static/modular/system/tCoupon/tCoupon.js
index 43c1631..3d48823 100644
--- a/management/guns-admin/src/main/webapp/static/modular/system/tCoupon/tCoupon.js
+++ b/management/guns-admin/src/main/webapp/static/modular/system/tCoupon/tCoupon.js
@@ -104,7 +104,7 @@
     var index = layer.open({
         type: 2,
         title: '添加',
-        area: ['800px', '420px'], //宽高
+        area: ['100%', '100%'], //宽高
         fix: false, //不固定
         maxmin: true,
         content: Feng.ctxPath + '/tCoupon/tCoupon_add'
@@ -162,6 +162,28 @@
 };
 
 /**
+ * 选择新人券或者活动券时
+ */
+TCoupon.changeCouponType = function (id,couponState) {
+
+    //监听下拉菜单的变动操作
+    $("#couponType").change(function(){
+        // 如果选择活动券,将赠送数量隐藏
+        if(this.value == 1){
+            $("#changeCouponSendQuantity").hide()
+        }
+        if(this.value == ""){
+            $("#changeCouponSendQuantity").hide()
+        }
+        if(this.value == 2){
+            $("#changeCouponSendQuantity").show()
+        }
+
+    })
+
+};
+
+/**
  * 查询列表
  */
 TCoupon.search = function () {
diff --git a/management/guns-admin/src/main/webapp/static/modular/system/tCoupon/tCoupon_info.js b/management/guns-admin/src/main/webapp/static/modular/system/tCoupon/tCoupon_info.js
index 7bab211..dbb7d8b 100644
--- a/management/guns-admin/src/main/webapp/static/modular/system/tCoupon/tCoupon_info.js
+++ b/management/guns-admin/src/main/webapp/static/modular/system/tCoupon/tCoupon_info.js
@@ -14,14 +14,14 @@
         couponType: {
             validators: {
                 notEmpty: {
-                    message: '优惠券类型不能为空'
+                    message: '请选择优惠券类型'
                 }
             }
         },
         couponServiceType: {
             validators: {
                 notEmpty: {
-                    message: '服务类类型不能为空'
+                    message: '请选择服务类类型'
                 }
             }
         },
diff --git a/management/guns-admin/src/main/webapp/static/modular/system/tDriver/tDriver.js b/management/guns-admin/src/main/webapp/static/modular/system/tDriver/tDriver.js
index add7c3d..9bbeebf 100644
--- a/management/guns-admin/src/main/webapp/static/modular/system/tDriver/tDriver.js
+++ b/management/guns-admin/src/main/webapp/static/modular/system/tDriver/tDriver.js
@@ -323,13 +323,16 @@
  * 打开区域选择页面新增
  */
 TDriver.areaAdd = function () {
+
+    var area = $("#area").val();
+    var areaId = $("#areaId").val();
     var index = layer.open({
         type: 2,
         title: '区域选择',
         area: ['1000px', '270px'], //宽高
         fix: false, //不固定
         maxmin: true,
-        content: Feng.ctxPath + '/tDriver/areaPageAdd'
+        content: Feng.ctxPath + '/tDriver/areaPageAdd?area='+area+'&areaId='+areaId
     });
     this.layerIndex = index;
 }
@@ -338,7 +341,36 @@
  * 查询市
  */
 TDriver.areaCity = function () {
-    var province = document.getElementById('province');
+    //监听第一个下拉菜单的变动操作
+    $("#province").change(function(){
+        //当第一级下拉列表没选择值时,将二级下拉列表和三级同时设置为空
+        if(this.value==""){
+            $("#city").empty();//二级联动设为空设为空
+            $("#city").append('<option value="">请选择</option>');
+            //region
+            $("#district").empty();//三级联动设为空设为空
+            $("#district").append('<option value="">请选择</option>');
+
+        }
+        if(this.value!=""){//第一级下拉菜单选择了值
+            $("#city").empty();//先行置空,防止上次选择留下的元素影响效果
+            $("#city").append('<option value="">请选择</option>')//设置初始选项
+            $("#district").empty();//三级联动设为空设为空
+            $("#district").append('<option value="">请选择</option>');
+            var province = document.getElementById('province');
+            var index= province.selectedIndex ;
+            var id = province.options[index].id;
+            var ajax = new $ax(Feng.ctxPath + "/tDriver/areaCity?parentId="+id, function (data) {
+                for(var i=0,n=data.length;i<n;i++){//遍历
+                    $("#city").append('<option value="'+data[i].id+'">'+data[i].name+'</option>');//创造元素
+                }
+            }, function (data) {
+                Feng.error("查询失败!" + data.responseJSON.message + "!");
+            });
+            ajax.start();
+        }
+    });
+    /*var province = document.getElementById('province');
     var index= province.selectedIndex ;
     var id = province.options[index].id;
     var ajax = new $ax(Feng.ctxPath + "/tDriver/areaCity?parentId="+id, function (data) {
@@ -352,14 +384,42 @@
     }, function (data) {
         Feng.error("查询失败!" + data.responseJSON.message + "!");
     });
-    ajax.start();
+    ajax.start();*/
 }
 
 /**
  * 查询区
  */
 TDriver.areaDistrict = function () {
-    var city = document.getElementById('city');
+
+    //监听第二个下拉菜单的变动操作
+    $("#city").change(function(){
+        if(this.value==""){//第二级菜单为空,则将第三级菜单也置为空
+            $("#district").empty();
+            $("#district").append('<option value="">请选择</option>');
+        }
+        if(this.value!=""){//第二级菜单不为空,则将第三级菜单动态生成
+            $("#district").empty();
+            $("#district").append('<option value="">请选择</option>');
+
+            var city = document.getElementById('city');
+            var cityIndex= city.selectedIndex ;
+            var id = city.options[cityIndex].id;
+            if(id == ""){
+                id = city.options[cityIndex].value;
+            }
+            var ajax = new $ax(Feng.ctxPath + "/tDriver/areaCity?parentId="+id, function (data) {
+                for(var i=0,n=data.length;i<n;i++){//对区数据进行遍历,动态生成
+                    $("#district").append('<option value="'+data[i].id+'">'+data[i].name+'</option>');
+                }
+            }, function (data) {
+                Feng.error("查询失败!" + data.responseJSON.message + "!");
+            });
+            ajax.start();
+        }
+    })
+
+    /*var city = document.getElementById('city');
     var cityIndex= city.selectedIndex ;
     var id = city.options[cityIndex].value;
     var ajax = new $ax(Feng.ctxPath + "/tDriver/areaCity?parentId="+id, function (data) {
@@ -373,7 +433,7 @@
     }, function (data) {
         Feng.error("查询失败!" + data.responseJSON.message + "!");
     });
-    ajax.start();
+    ajax.start();*/
 }
 
 /**
@@ -385,19 +445,33 @@
     var provinceName = province.options[provinceIndex].value;
     var provinceId = province.options[provinceIndex].id;
 
+    if(provinceName == null || provinceName == ''){
+        Feng.error("请选择省份!")
+        return;
+    }
+
     var city = document.getElementById('city');
     var cityIndex= city.selectedIndex ;
     var cityId = city.options[cityIndex].value;
     var cityName = city.options[cityIndex].innerText;
+
+    if(cityName == null || cityName == '' || cityName =='请选择'){
+        Feng.error("请选择市区!")
+        return;
+    }
 
     var district = document.getElementById('district');
     var districtIndex= district.selectedIndex ;
     var districtId = district.options[districtIndex].value;
     var districtName = district.options[districtIndex].innerText;
 
+    if(districtName == null || districtName == '' || districtName =='请选择'){
+        Feng.error("请选择区县!")
+        return;
+    }
+
     parent.$("#area").val(provinceName+'/'+cityName+'/'+districtName)
     parent.$("#areaId").val(provinceId+'/'+cityId+'/'+districtId)
-    console.log()
     TDriverInfoDlg.close();
 }
 

--
Gitblit v1.7.1