qifengquan 1 tahun lalu
induk
melakukan
0bfe394352

+ 27 - 0
application/admin/controller/Ajax.php

@@ -294,6 +294,33 @@ class Ajax extends Backend
     }
 
     /**
+     * 读取省市区数据,联动列表
+     */
+    public function region_area()
+    {
+        $params = $this->request->get("row/a");
+        if (!empty($params)) {
+            $province = isset($params['region_province']) ? $params['region_province'] : null;
+            $city = isset($params['region_city']) ? $params['region_city'] : null;
+        } else {
+            $province = $this->request->get('region_province');
+            $city = $this->request->get('region_city');
+        }
+        $where = ['pid' => 0, 'level' => 1];
+        $provincelist = null;
+        if ($province !== null) {
+            $where['pid'] = $province;
+            $where['level'] = 2;
+            if ($city !== null) {
+                $where['pid'] = $city;
+                $where['level'] = 3;
+            }
+        }
+        $provincelist = Db::name('area')->where($where)->field('id as value,name')->select();
+        $this->success('', '', $provincelist);
+    }
+
+    /**
      * 生成后缀图标
      */
     public function icon()

+ 28 - 0
application/admin/view/user/user/edit.html

@@ -154,6 +154,34 @@
         </div>
     </div>
     <div class="form-group">
+        <label for="c-max_income" class="control-label col-xs-12 col-sm-2">{:__('家乡所在地区')}:</label>
+        <div class="form-inline" data-toggle="cxselect" data-selects="province,city,area">
+            <select class="province form-control" name="row[region_province]" data-url="ajax/region_area">
+                <option value="{$row.region_province|htmlentities}" selected=""></option>
+            </select>
+            <select class="city form-control" name="row[region_city]" data-url="ajax/region_area">
+                <option value="{$row.region_city|htmlentities}" selected=""></option>
+            </select>
+            <select class="area form-control" name="row[region_area]" data-url="ajax/region_area">
+                <option value="{$row.region_area|htmlentities}" selected=""></option>
+            </select>
+        </div>
+    </div>
+    <div class="form-group">
+        <label for="c-max_income" class="control-label col-xs-12 col-sm-2">{:__('所在城市地区')}:</label>
+        <div class="form-inline" data-toggle="cxselect" data-selects="province,city,area">
+            <select class="province form-control" name="row[province]" data-url="ajax/area">
+                <option value="{$row.province|htmlentities}" selected=""></option>
+            </select>
+            <select class="city form-control" name="row[city]" data-url="ajax/area">
+                <option value="{$row.city|htmlentities}" selected=""></option>
+            </select>
+            <select class="area form-control" name="row[area]" data-url="ajax/area">
+                <option value="{$row.area|htmlentities}" selected=""></option>
+            </select>
+        </div>
+    </div>
+    <div class="form-group">
         <label for="c-marriedtime" class="control-label col-xs-12 col-sm-2">{:__('计划结婚')}:</label>
         <div class="col-xs-12 col-sm-4">
             <input id="c-marriedtime" class="form-control" name="row[marriedtime]" type="text" value="{$row.marriedtime|htmlentities}">