liche update for admin sys city set area
This commit is contained in:
@@ -35,8 +35,9 @@ class Store extends HD_Controller
|
||||
$page = $this->input->get('page');
|
||||
$status = $this->input->get('status');
|
||||
|
||||
$this->data['province_id'] = $province_id = $this->input->get('province_id', true);
|
||||
$this->data['province_id'] = $province_id = 350;//默认福建城市
|
||||
$this->data['city_id'] = $city_id = intval($this->input->get('city_id', true));
|
||||
$this->data['county_id'] = $county_id = intval($this->input->get('county_id', true));
|
||||
$this->data['bizname'] = $bizname = $this->input->get('bizname');
|
||||
$this->data['brand_id'] = $brand_id = intval($this->input->get('brand_id'));
|
||||
$this->data['content'] = $content = $this->input->get('content');
|
||||
@@ -44,7 +45,19 @@ class Store extends HD_Controller
|
||||
$status_arr = array('del' => -1, 'off' => 0, 'on' => 1);
|
||||
$this->data['provinces'] = $this->area_model->select(array(), '', 0, 0, 'distinct(province_id), province_name');
|
||||
if ($province_id) {
|
||||
$this->data['citys'] = $this->area_model->select(array('province_id' => $province_id), '', 0, 0, 'distinct(city_id), city_name');
|
||||
//获取系统配置的城市
|
||||
$map_city = $this->city_ary();
|
||||
$rows_city = array();
|
||||
foreach($map_city as $k => $v){
|
||||
$rows_city[] = array(
|
||||
'city_id' => $k,
|
||||
'city_name' => $v
|
||||
);
|
||||
}
|
||||
$this->data['citys'] = $rows_city;
|
||||
}
|
||||
if($city_id){
|
||||
$this->data['countys'] = $this->area_model->select(array('city_id' => $city_id));
|
||||
}
|
||||
if (isset($status_arr[$status])) {
|
||||
$this->data['status'] = $status;
|
||||
@@ -59,6 +72,7 @@ class Store extends HD_Controller
|
||||
$brand_id && $where['brand_id'] = $brand_id;
|
||||
$province_id && $where['province_id'] = $province_id;
|
||||
$city_id && $where['city_id'] = $city_id;
|
||||
$county_id && $where['county_id'] = $county_id;
|
||||
|
||||
$biz_lists = $this->biz_model->select($where, 'id desc', $page, $pagesize);
|
||||
$count = $this->biz_model->count();
|
||||
@@ -133,6 +147,18 @@ class Store extends HD_Controller
|
||||
}
|
||||
}
|
||||
|
||||
$this->data['biz'] = $biz;
|
||||
} else {
|
||||
$map_city = $this->city_ary();
|
||||
$rows_city = array();
|
||||
foreach($map_city as $k => $v){
|
||||
$rows_city[] = array(
|
||||
'city_id' => $k,
|
||||
'city_name' => $v
|
||||
);
|
||||
}
|
||||
$this->data['citys'] = $rows_city;
|
||||
$biz = array('province_id' => '350');//默认福建城市
|
||||
$this->data['biz'] = $biz;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class City extends HD_Controller{
|
||||
parent::__construct();
|
||||
$this->load->model("area_model");
|
||||
$this->load->model("sys/sys_city_model");
|
||||
$this->load->model('sys/sys_area_model');
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
@@ -23,26 +24,72 @@ class City extends HD_Controller{
|
||||
}
|
||||
public function lists()
|
||||
{
|
||||
$this->data['bizname'] = $bizname = $this->input->get('bizname');
|
||||
if ($bizname){
|
||||
$where['name like \'%'.$bizname.'%\''] = null;
|
||||
$params = $this->input->get();
|
||||
$where = array();
|
||||
if ($params['keyword']){
|
||||
$where["name like '%{$params['keyword']}%'"] = null;
|
||||
}
|
||||
$page = $this->input->get('page');
|
||||
$page = $params['page'];
|
||||
$page = !$page ? 1 : $page;
|
||||
$size = $this->input->get('size');
|
||||
$size = $params['size'];
|
||||
$size = !$size ? 20 : $size;
|
||||
$lists = $this->sys_city_model->select($where,'id desc',$page,$size);
|
||||
|
||||
$count = $this->sys_city_model->count($where);
|
||||
$lists = array();
|
||||
if($count){
|
||||
$rows = $this->sys_city_model->select($where,'id desc',$page,$size);
|
||||
$map_checked = array();
|
||||
$city_checked = array();
|
||||
if($rows){
|
||||
$city_ids = array_column($rows, 'city_id');
|
||||
$str_ids = implode(',', $city_ids);
|
||||
//获取城市下所有的区域
|
||||
$where = array("city_id in ({$str_ids})" => null);
|
||||
$orderby = 'city_id asc, county_id asc';
|
||||
$select = 'city_id, county_id, county_name';
|
||||
$rows_county = $this->area_model->select($where, $orderby, 0, 0, $select);
|
||||
//获取已经选择的区域
|
||||
$orderby = 'city_id asc, county_id asc';
|
||||
$select = 'county_id, status';
|
||||
$map_county = $this->sys_area_model->map('county_id', 'status', $where, $orderby, 0, 0, $select);
|
||||
if($rows_county){
|
||||
foreach($rows_county as $k => $v){
|
||||
$city_id = $v['city_id'];
|
||||
$county_id = $v['county_id'];
|
||||
$checked = 1==$map_county[$county_id] ? 1 : 0;
|
||||
$map_checked[$city_id][] = array(
|
||||
'county_id' => $county_id,
|
||||
'county_name' => $v['county_name'],
|
||||
'checked' => $checked,
|
||||
);
|
||||
1 == $checked && $city_checked[$city_id] = $checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($rows as $k => $v){
|
||||
$city_id = $v['city_id'];
|
||||
$lists[] = array(
|
||||
'id' => $v['id'],
|
||||
'city_id' => $city_id,
|
||||
'firstchar' => $v['firstchar'],
|
||||
'name' => $v['name'],
|
||||
'checked' => $city_checked[$city_id] ? 1 : 0,
|
||||
'countys' => $map_checked[$city_id] ? $map_checked[$city_id] : array(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->data['params'] = $params;
|
||||
$this->data['lists'] = $lists;
|
||||
$this->data['pager'] = array('count'=>ceil($count/$size),'curr'=>$page,'totle'=>$count);
|
||||
$this->data['_title'] = '城市管理';
|
||||
$this->data['city_lists'] = $lists;
|
||||
$this->data['pager']['total'] = $count;
|
||||
$this->data['status_arr'] = array(1=>'开启',0=>'关闭');
|
||||
$this->show_view('sys/city/lists',true);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
$info = array('province_id' => '350', 'city_id' => '', 'name' => '', 'firstchar' => '',);//默认添加福建城市
|
||||
$this->data['info'] = $info;
|
||||
$this->data['_title'] = '新增城市';
|
||||
$this->show_view('sys/city/edit');
|
||||
}
|
||||
@@ -73,6 +120,13 @@ class City extends HD_Controller{
|
||||
if(!$firstchar || empty($firstchar)){
|
||||
return $this->show_json(SYS_CODE_FAIL, '首字母不能为空');
|
||||
}
|
||||
|
||||
//判断是否重复
|
||||
$row = $this->sys_city_model->get(array('city_id' => $city_id));
|
||||
if($row){
|
||||
return $this->show_json(SYS_CODE_FAIL, '该城市已经添加');
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'city_id' => $city_id,
|
||||
'name' => $name,
|
||||
@@ -85,15 +139,77 @@ class City extends HD_Controller{
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存选中的区域
|
||||
* @return bool
|
||||
*/
|
||||
function edit_areas(){
|
||||
$lists = $this->input->post('lists');
|
||||
$lists = json_decode($lists, true);
|
||||
$add_ids = array();//需要新增选中的区域ID
|
||||
$del_ids = array();//需要删除区域的城市ID
|
||||
foreach($lists as $k => $v){
|
||||
$upd = array('status' => $v['checked'] ? 1 : 0);
|
||||
$where = array('id' => $v['id']);
|
||||
//更新城市的状态
|
||||
$ret = $this->sys_city_model->update($upd, $where);
|
||||
if($ret){
|
||||
$del_ids[] = $v['city_id'];
|
||||
foreach($v['countys'] as $k_county => $v_county){
|
||||
if($v_county['checked']){
|
||||
$add_ids[] = $v_county['county_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($del_ids){
|
||||
//删除旧的选中区域
|
||||
$str_ids = implode(',', $del_ids);
|
||||
$where = array("city_id in ({$str_ids})" => null);
|
||||
$ret = $this->sys_area_model->delete($where);
|
||||
}
|
||||
if($add_ids){
|
||||
//新增选中的区域
|
||||
$adds = array();
|
||||
$str_ids = implode(',', $add_ids);
|
||||
$where = array("county_id in ({$str_ids})" => null);
|
||||
$orderby = 'county_id asc';
|
||||
$select = 'province_id, province_name, city_id, city_name, county_id, county_name';
|
||||
$rows = $this->area_model->select($where, $orderby, 0, 0, $select);
|
||||
foreach($rows as $v){
|
||||
$adds[] = array(
|
||||
'province_id' => $v['province_id'],
|
||||
'province_name' => $v['province_name'],
|
||||
'city_id' => $v['city_id'],
|
||||
'city_name' => $v['city_name'],
|
||||
'county_id' => $v['county_id'],
|
||||
'county_name' => $v['county_name'],
|
||||
'status' => 1,
|
||||
);
|
||||
}
|
||||
if($adds){
|
||||
$ret = $this->sys_area_model->add_batch($adds);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS,'保存成功');
|
||||
}
|
||||
|
||||
public function del()
|
||||
{
|
||||
$id = $this->input->post('id');
|
||||
$stauts = $this->input->post('status');
|
||||
if($id)
|
||||
{
|
||||
$this->sys_city_model->update(array('status' => $stauts), array('id' => $id));
|
||||
$where = array('id' => $id);
|
||||
$row = $this->sys_city_model->get($where);
|
||||
$ret = $this->sys_city_model->delete($where);
|
||||
if($ret){
|
||||
$where = array('city_id' => $row['city_id']);
|
||||
$this->sys_area_model->delete($where);
|
||||
}
|
||||
}
|
||||
return $this->show_json(SYS_CODE_SUCCESS,'保存成功');
|
||||
return $this->show_json(SYS_CODE_SUCCESS,'操作成功');
|
||||
}
|
||||
public function batch()
|
||||
{
|
||||
|
||||
@@ -104,4 +104,25 @@ abstract class HD_Controller extends CI_Controller
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可以管理的城市
|
||||
* @param null $def
|
||||
* @return mixed
|
||||
*/
|
||||
protected function city_ary($def = null){
|
||||
$this->load->model("sys/sys_city_model", 'city_model');
|
||||
|
||||
if(!is_null($def)){
|
||||
return '';
|
||||
}
|
||||
|
||||
$where = array('status' => 1);
|
||||
$orderby = "id desc";
|
||||
$select = "city_id, name";
|
||||
|
||||
$map_city = $this->city_model->map('city_id', 'name', $where, $orderby, 0, 0, $select);
|
||||
|
||||
return $map_city;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -123,7 +123,7 @@
|
||||
min-height: 300px;
|
||||
}
|
||||
</style>
|
||||
<?php if (!empty($biz)){ ?>
|
||||
<?php if ($biz['id']){ ?>
|
||||
<form id="vue-app" class="am-form am-form-horizontal" action="/biz/store/store/edit?id=<?= $biz['id'] ?>"
|
||||
data-auto="true" method="post" style="width: 90%;padding-top: 10px">
|
||||
<input type="hidden" value="<?= $biz['id'] ?>" name="id"/>
|
||||
@@ -161,7 +161,7 @@
|
||||
<label class="am-para-label">商家地址:</label>
|
||||
<div class="am-para-input">
|
||||
<div class="am-form-inline">
|
||||
<div class="am-form-group">
|
||||
<div class="am-form-group" style="display: none">
|
||||
<select name="province_id" style="width: 200px;" data-toggle="next-select"
|
||||
data-refurl="/common/area?key=city&id={value}&url=edit" data-next="#bd-hd-city">
|
||||
<option value="0">省份</option>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w100">商家地址:</label>
|
||||
<div class="am-form-group am-para-inline w150">
|
||||
<div class="am-form-group am-para-inline w150" style="display: none">
|
||||
<select name="province_id" data-toggle="next-select"
|
||||
data-refurl="/common/area?key=city&id={value}&url=search" data-next="#bd-hd-city">
|
||||
<option value="0">省份</option>
|
||||
@@ -56,6 +56,18 @@
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="am-form-group am-para-inline w150">
|
||||
<select id="bd-hd-county" name="county_id" data-toggle="next-select"
|
||||
data-refurl="/common/areas?id={value}" data-next="#bd-hd-area">
|
||||
<option value="0">行政区</option>
|
||||
<?php if ($countys) {
|
||||
foreach ($countys as $value) { ?>
|
||||
<option value="<?= $value['county_id'] ?>"
|
||||
<?= $value['county_id'] == $county_id ? 'selected' : '' ?>><?= $value['county_name'] ?></option>
|
||||
<?php }
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
|
||||
|
||||
@@ -1,13 +1,107 @@
|
||||
<form class="am-form am-form-horizontal" action="/sys/city/city/add" data-auto="true" method="post" style="width: 90%;padding:25px 30px 20px 0;margin: 0 auto">
|
||||
<form id="vue-edit" class="am-form am-form-horizontal" action="/sys/city/city/add" data-auto="true" method="post" style="width: 90%;padding:25px 30px 20px 0;margin: 0 auto">
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label"><span class="com-must-star">*</span>城市名称:</label>
|
||||
<div class="am-para-input"><input type="text" placeholder="请输入城市名称,如:厦门市" name="name" value="" onkeyup="this.value=this.value.replace(/\s+/g,'')"/></div>
|
||||
<div class="am-para-input">
|
||||
<select name="city_id" v-model="info.city_id">
|
||||
<option value="">选择城市</option>
|
||||
<option v-for="(v,i) in citys" :value="i">{{v.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label"><span class="com-must-star">*</span>首字母:</label>
|
||||
<div class="am-para-input"><input type="text" placeholder="请输入首字母" name="firstchar" value="" onkeyup="this.value=this.value.replace(/\s+/g,'')"/></div>
|
||||
<div class="am-para-input"><input type="text" placeholder="请输入首字母" name="firstchar" v-model="info.firstchar" onkeyup="this.value=this.value.replace(/\s+/g,'')" disabled /></div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 2rem">
|
||||
<div class="am-para-input"><button class="am-btn am-btn-secondary" type="submit">提交</button></div>
|
||||
<div class="am-para-input"><button class="am-btn am-btn-secondary" type="button" @click="saveEdit">提交</button></div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
<script>
|
||||
var loading = 0;
|
||||
var vue_obj;
|
||||
$(function(){
|
||||
vue_obj = new Vue({
|
||||
el: '#vue-edit',
|
||||
data: {
|
||||
info:{},
|
||||
citys:[],
|
||||
tourl:''
|
||||
},
|
||||
mounted:function(){
|
||||
var vm = this;
|
||||
vm.info = <?=json_encode($info)?>;
|
||||
vm.init_citys();
|
||||
},
|
||||
methods:{
|
||||
init_citys:function(){
|
||||
var vm = this;
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '/common/area',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
id:vm.info.province_id,
|
||||
key:'city',
|
||||
type:2
|
||||
},
|
||||
success:function(response){
|
||||
if (response.code == 1) {
|
||||
vm.citys = response.data;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
saveEdit:function(){
|
||||
var vm = this;
|
||||
if(1 == loading){
|
||||
return 0;
|
||||
}
|
||||
loading = 1;
|
||||
|
||||
$.ajax({
|
||||
url: '/sys/city/city/add',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: vm.info,
|
||||
beforeSend: function () {
|
||||
layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
},
|
||||
success: function (data) {
|
||||
loading = 0;
|
||||
if (data['code']) {
|
||||
layer.msg(data.msg, {
|
||||
icon: 1,
|
||||
time: 2000
|
||||
}, function () {
|
||||
if(vm.tourl.length > 0){
|
||||
$.form.href(vm.tourl);
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(data.msg, {icon: 2});
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
loading = 0;
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
'info.city_id':function(nv, ov){
|
||||
var vm = this;
|
||||
if('' != nv){
|
||||
var item = vm.citys[nv];
|
||||
vm.info.name = item.name;
|
||||
vm.info.firstchar = item.firstchar;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
+130
-50
@@ -1,56 +1,136 @@
|
||||
|
||||
<div class="coms-table-wrap">
|
||||
<div class="coms-table-hd clearfix no-border">
|
||||
<form action="/sys/city/city/lists" class="form-search" onsubmit="return false">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label">城市名称:</label>
|
||||
<div class="am-para-inline w200">
|
||||
<input type="text" name="bizname" id="input" value="<?=$bizname?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml20">
|
||||
<button type="submit" class="am-btn am-btn-sm am-btn-success w100">搜索</button>
|
||||
<button data-modal="/sys/city/city/get" data-title="新增" type="button" class="am-btn am-btn-success w100 am-btn-sm">新增</button>
|
||||
</div>
|
||||
<div class="am-form-group fr" style="font-size: 15px;padding-right: 20px;padding-top: 6px;">
|
||||
共有<?=$pager['total']?>条数据
|
||||
<div class="coms-table-wrap">
|
||||
<div class="coms-table-hd clearfix no-border">
|
||||
<form action="/sys/city/city/lists" class="form-search" onsubmit="return false">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label">城市名称:</label>
|
||||
<div class="am-para-inline w200">
|
||||
<input type="text" name="keyword" id="input" v-model="params.keyword"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="am-form-group fl ml20">
|
||||
<button type="submit" class="am-btn am-btn-sm am-btn-success w100">搜索</button>
|
||||
<button data-modal="/sys/city/city/get" data-title="新增" type="button" class="am-btn am-btn-success w100 am-btn-sm">新增</button>
|
||||
</div>
|
||||
<div class="am-form-group fr" style="font-size: 15px;padding-right: 20px;padding-top: 6px;">
|
||||
共有<?=$pager['totle']?>条数据
|
||||
</div>
|
||||
</div>
|
||||
<div class="coms-table-bd" style="width: 70%;">
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="15%"><span>城市ID</span></th>
|
||||
<th width="15%"><span>首字母</span></th>
|
||||
<th width="15%"><span>城市名称</span></th>
|
||||
<th width="15%"><span>状态</span></th>
|
||||
<th><span>操作</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($city_lists as $key => $val){?>
|
||||
<tr>
|
||||
<td><?=$val['city_id']?></td>
|
||||
<td><?=$val['firstchar']?></td>
|
||||
<td><?=$val['name']?></td>
|
||||
<td><?=$status_arr[$val['status']]?></td>
|
||||
<td>
|
||||
<?if($val['status']==1){?>
|
||||
<a data-ajax="post" data-action="/sys/city/city/del"
|
||||
data-params-id="<?=$val['id']?>" data-params-status="0" class="am-btn am-btn-danger am-btn-xs">关闭</a>
|
||||
<?}else{?>
|
||||
<a data-ajax="post" data-action="/sys/city/city/del"
|
||||
data-params-id="<?=$val['id']?>" data-params-status="1" class="am-btn am-btn-primary am-btn-xs">开启</a>
|
||||
<?}?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pb50"></div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="coms-table-bd">
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="15%"><span>城市ID</span></th>
|
||||
<th width="10%"><span>首字母</span></th>
|
||||
<th width="15%"><span>城市名称</span></th>
|
||||
<th width="10%"><span>操作</span></th>
|
||||
<th width=""><span class="mr10">区域</span><button data-title="保存" type="button" class="am-btn am-btn-success am-btn-xs" @click="save_area">保存</button></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(v,i) in lists">
|
||||
<td>{{v.city_id}}</td>
|
||||
<td>{{v.firstchar}}</td>
|
||||
<td>{{v.name}}</td>
|
||||
<td>
|
||||
<a data-ajax="post" data-action="/sys/city/city/del" :data-params-id="v.id" class="am-btn am-btn-danger am-btn-xs">删除</a>
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
<span class="mr20">
|
||||
<input type="checkbox" v-model="v.checked" @change="set_city(i)"/>全选
|
||||
</span>
|
||||
<span class="mr5" v-for="(county, j) in v.countys">
|
||||
<input type="checkbox" v-model="county.checked" @change="set_area(i)"/>{{county.county_name}}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pb50"></div>
|
||||
</div>
|
||||
<script>
|
||||
var vue_obj;
|
||||
var loading = 0;
|
||||
$(function(){
|
||||
vue_obj = new Vue({
|
||||
el: '.coms-table-wrap',
|
||||
data: {
|
||||
params:[],
|
||||
lists:[]
|
||||
},
|
||||
mounted:function() {
|
||||
var vm = this;
|
||||
vm.params = <?=json_encode($params)?>;
|
||||
vm.lists = <?=json_encode($lists)?>;
|
||||
},
|
||||
methods:{
|
||||
set_city:function(city_idx){
|
||||
var vm = this;
|
||||
var city = vm.lists[city_idx];
|
||||
var checked = city.checked;
|
||||
for(var i in city.countys){
|
||||
var county = city.countys[i];
|
||||
county.checked = checked;
|
||||
}
|
||||
},
|
||||
set_area:function(city_idx){
|
||||
var vm = this;
|
||||
var city = vm.lists[city_idx];
|
||||
var checked = 0;
|
||||
for(var i in city.countys){
|
||||
var county = city.countys[i];
|
||||
if(1 == county.checked){
|
||||
checked = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
city.checked = checked;
|
||||
},
|
||||
save_area:function(){
|
||||
var vm = this;
|
||||
if(1 == loading){
|
||||
return 0;
|
||||
}
|
||||
loading = 1;
|
||||
|
||||
$.ajax({
|
||||
url: '/sys/city/city/edit_areas',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {lists:JSON.stringify(vm.lists)},
|
||||
beforeSend: function () {
|
||||
layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
},
|
||||
success: function (data) {
|
||||
loading = 0;
|
||||
if (data['code']) {
|
||||
layer.msg(data.msg, {
|
||||
icon: 1,
|
||||
time: 2000
|
||||
}, function () {
|
||||
$.form.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(data.msg, {icon: 2});
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
loading = 0;
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
watch:{}
|
||||
});
|
||||
|
||||
<?php page_script($pager) ?>
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user