Commit 388ad86b authored by wangjiangze's avatar wangjiangze

酒店区域管理更新

parent 2590dcac
...@@ -8,20 +8,18 @@ class RegionAction extends CommonAction{ ...@@ -8,20 +8,18 @@ class RegionAction extends CommonAction{
$model = D("Region"); $model = D("Region");
$userInfo = $_SESSION["_USER_INFO"]; $userInfo = $_SESSION["_USER_INFO"];
$inputs = I(); $inputs = I();
if(I("id")){
$inputs['searchPid'] = I("id");
}
$list = $model->getList("list",$userInfo,$inputs); $list = $model->getList("list",$userInfo,$inputs);
$count = $model->getList("count",$userInfo,$inputs); $count = $model->getList("count",$userInfo,$inputs);
$total = $count[0]["count"]; $total = $count[0]["count"];
foreach ($list as $key=>$value){
foreach ($list as $key=>$value){ if($value['pid']!=0)
if($value['level']!=1)
$list[$key]['_parentId']=$value['pid']; $list[$key]['_parentId']=$value['pid'];
} }
echo "{\"total\":\"".$total."\",\"rows\":".json_encode($list)."}"; echo "{\"total\":\"".$total."\",\"rows\":".json_encode($list)."}";
}else{ }else{
$spModel = D("Sp");
$sp_lists = $spModel->where("`status`=0")->select();
$this->sp_lists = $sp_lists;
$this->display(); $this->display();
} }
} }
...@@ -39,12 +37,8 @@ class RegionAction extends CommonAction{ ...@@ -39,12 +37,8 @@ class RegionAction extends CommonAction{
$info =$model->where("id = $id")->find(); $info =$model->where("id = $id")->find();
$this->info = $info; $this->info = $info;
} }
$sp_lists = $spModel->where("`status`=0")->select(); $region_lists = $regionModel->where("`level` < 4 and pid < 999999")->select();
$region_lists = $regionModel->where("pid = 1 and `status`=0")->select();
$region_city_lists = $regionModel->where("pid > 1 and `status`=0")->select();
$this->sp_lists = $sp_lists;
$this->region_lists = $region_lists; $this->region_lists = $region_lists;
$this->region_city_lists = $region_city_lists;
$this->display(); $this->display();
} }
//添加处理 //添加处理
...@@ -52,10 +46,11 @@ class RegionAction extends CommonAction{ ...@@ -52,10 +46,11 @@ class RegionAction extends CommonAction{
$model = D("Region"); $model = D("Region");
$id = I('id','',int); $id = I('id','',int);
$data['sp_id'] = I("sp_id"); $data['pid'] = I("pid");
$data['region_id'] = I("region_id");
$data['name'] = I("name"); $data['name'] = I("name");
$data['code'] = I("code"); $data['code'] = I("code");
$data['level'] = I("level");
$data['postcode'] = I("postcode");
$data['remark'] = I("remark"); $data['remark'] = I("remark");
$data['status'] = I("status"); $data['status'] = I("status");
...@@ -69,7 +64,7 @@ class RegionAction extends CommonAction{ ...@@ -69,7 +64,7 @@ class RegionAction extends CommonAction{
echo 'false'; echo 'false';
} }
}else{ }else{
$data["addtime"]=date('Y-m-d H:i:s'); // $data["addtime"]=date('Y-m-d H:i:s');
$id = $model->add($data); $id = $model->add($data);
if($id){ if($id){
......
...@@ -4,7 +4,7 @@ class RegionModel extends RelationModel{ ...@@ -4,7 +4,7 @@ class RegionModel extends RelationModel{
public function getList($queryType,$userInfo,$inputs){ public function getList($queryType,$userInfo,$inputs){
$p=$inputs["page"]?$inputs["page"]:1; $p=$inputs["page"]?$inputs["page"]:1;
$n=$inputs["rows"]?$inputs["rows"]:10; $n=$inputs["rows"]?$inputs["rows"]:4000;
$limit = "limit ".($p-1)*$n.",".$n; $limit = "limit ".($p-1)*$n.",".$n;
$sort=""; $sort="";
if($inputs["sort"]) if($inputs["sort"])
...@@ -12,6 +12,7 @@ class RegionModel extends RelationModel{ ...@@ -12,6 +12,7 @@ class RegionModel extends RelationModel{
//============= //=============
$searchField = $inputs["searchField"]?$inputs["searchField"]:'name'; $searchField = $inputs["searchField"]?$inputs["searchField"]:'name';
$searchValue = $inputs["searchValue"]?$inputs["searchValue"]:''; $searchValue = $inputs["searchValue"]?$inputs["searchValue"]:'';
$searchPid = $inputs["searchPid"]?$inputs["searchPid"]:1;
if($searchValue){ if($searchValue){
$where = " and (`name` like '%".$searchValue."%' or `mac` like '%".$searchValue."%') "; $where = " and (`name` like '%".$searchValue."%' or `mac` like '%".$searchValue."%') ";
...@@ -24,9 +25,10 @@ class RegionModel extends RelationModel{ ...@@ -24,9 +25,10 @@ class RegionModel extends RelationModel{
//返回列表(limit分页) //返回列表(limit分页)
if($queryType=="list"){ if($queryType=="list"){
$where .= $sort." ".$limit; $where .= $sort." ".$limit;
$fields = " *,`name` title,case `status` when 1 then '<font color=red>禁用</font>' when 0 then '<font color=green>启用</font>' end as `status` "; $fields = " id,`name` title,`code`,`level`,`status`,postcode,updatetime,if(`level`>1 and `level`<4,'closed','open') as `state`,case pid when 1 then 0 else pid end as `pid` ";
} }
$sql = "select ".$fields." from sh_region where 1=1 and `level`<3 ".$where.";"; $sql = "select ".$fields." from sh_region where 1=1 and pid < 999999 and pid = $searchPid ".$where.";";
// echo $sql;die;
return $model->query($sql); return $model->query($sql);
} }
} }
\ No newline at end of file
...@@ -83,7 +83,7 @@ body{padding:20px} ...@@ -83,7 +83,7 @@ body{padding:20px}
<div class="path_box"> <div class="path_box">
<volist name="storage_list" id="item"> <volist name="storage_list" id="item">
<div class="form-group"> <div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">路径{$key+1}</label> <label for="inputEmail3" class="col-sm-3 control-label">路径{$key+1}</label>
<div class="col-sm-3"> <div class="col-sm-3">
<input type="text" class="form-control" id="inputEmail3" placeholder="存储根路径(例:/data1)" name="path[]" value="{$item.path}"> <input type="text" class="form-control" id="inputEmail3" placeholder="存储根路径(例:/data1)" name="path[]" value="{$item.path}">
</div> </div>
......
...@@ -19,45 +19,34 @@ body{padding:20px} ...@@ -19,45 +19,34 @@ body{padding:20px}
<form class="form-horizontal" role="form" id="ff" action="{:U('/Hotel/Region/addHandle')}" method="POST"> <form class="form-horizontal" role="form" id="ff" action="{:U('/Hotel/Region/addHandle')}" method="POST">
<input name="id" type="hidden" value="{$info.id}"/> <input name="id" type="hidden" value="{$info.id}"/>
<div class="form-group"> <div class="form-group">
<label for="name" class="col-sm-2 control-label">选择合作方</label> <label for="name" class="col-sm-2 control-label">选择上级</label>
<div class="col-sm-6" name="type"> <div class="col-sm-6" name="type">
<select class="form-control" name="sp_id"> <select class="form-control" name="pid">
<option value="0">请选择合作方</option> <option value="0">请选择地区</option>
<volist name="sp_lists" id="item"> <volist name='region_lists' id='item'>
<option value="{$item.id}">{$item.name}</option> <if condition='$item.level eq 2'>
<option value="{$item.id}" pid="{$item.pid}">{$item.name}</option>
</if>
</volist> </volist>
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="name" class="col-sm-2 control-label">选择区域</label> <label for="inputEmail3" class="col-sm-2 control-label">区域名称</label>
<div class="col-sm-3"> <div class="col-sm-6">
<select class="form-control" id="province_select"> <input type="text" class="form-control" id="inputEmail3" placeholder="请输入区域名称" value="{$info.name}" name="name">
<option value="0">请选择省份</option>
<volist name="region_lists" id="item">
<option value="{$item.id}">{$item.name}</option>
</volist>
</select>
</div>
<div class="col-sm-3">
<select class="form-control" id="city_select" name="region_id">
<option value="0" pid="0">请选择城市</option>
<volist name="region_city_lists" id="item">
<option value="{$item.id}" class="hidden" pid="{$item.pid}">{$item.name}</option>
</volist>
</select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">酒店名称</label> <label for="inputEmail3" class="col-sm-2 control-label">区域代码</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input type="text" class="form-control" id="inputEmail3" placeholder="请输入酒店名称" value="{$info.name}" name="name"> <input type="text" class="form-control" id="inputEmail3" placeholder="请输入区域代码" name="code" value="{$info.code}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">合作方酒店标识</label> <label for="inputEmail3" class="col-sm-2 control-label">邮政编码</label>
<div class="col-sm-6"> <div class="col-sm-6">
<input type="text" class="form-control" id="inputEmail3" placeholder="请输入合作方酒店标识" name="code" value="{$info.code}"> <input type="text" class="form-control" id="inputEmail3" placeholder="请输入邮政编码" name="postcode" value="{$info.postcode}">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
...@@ -84,22 +73,10 @@ body{padding:20px} ...@@ -84,22 +73,10 @@ body{padding:20px}
</form> </form>
<script type="text/javascript"> <script type="text/javascript">
function submitForm(){ function submitForm(){
var sp_id = $("select[name='sp_id'] option:selected").val();
var region_id = $("select[name='region_id'] option:selected").val();
var name_v = $("input[name='name']").val(); var name_v = $("input[name='name']").val();
var code_v = $("input[name='code']").val();
if(sp_id==0){
alert("请选择合作方");return;
}
if(region_id==0){
alert("请选择省份/城市");return;
}
if(!name_v){ if(!name_v){
alert("请输入酒店名称");return; alert("请输入区域名称");return;
}
if(!code_v){
alert("请输入合作方酒店标识");return;
} }
$('#ff').form('submit', { $('#ff').form('submit', {
url:'/Hotel/Region/addHandle/', url:'/Hotel/Region/addHandle/',
...@@ -129,13 +106,21 @@ $().ready(function(){ ...@@ -129,13 +106,21 @@ $().ready(function(){
$("select[name='region_id'] option[value='0']").attr("selected",true); $("select[name='region_id'] option[value='0']").attr("selected",true);
$("select[name='region_id'] option[pid='"+province_id+"']").removeClass("hidden"); $("select[name='region_id'] option[pid='"+province_id+"']").removeClass("hidden");
}); });
var region_lists = {$region_lists|json_encode};
$.each(region_lists,function(i,item){
if(item.level==3){
console.log($("select[name='pid'] option[pid='"+item.pid+"']").length);
if($("select[name='pid'] option[pid='"+item.pid+"']").length==0){
//
$("select[name='pid'] option[value='"+item.pid+"']").after('<option value="'+item.id+'" pid="'+item.pid+'">&nbsp;&nbsp;&nbsp;&nbsp;|--'+item.name+'</option>');
}else{
$("select[name='pid'] option[pid='"+item.pid+"']:last").after('<option value="'+item.id+'" pid="'+item.pid+'">&nbsp;&nbsp;&nbsp;&nbsp;|--'+item.name+'</option>');
}
}
});
<if condition="$info"> <if condition="$info">
$("select[name='sp_id'] option[value='{$info.sp_id}']").attr("selected",true); $("select[name='pid'] option[value='{$info.pid}']").attr("selected",true);
var province_id = $("select[name='region_id'] option[value='{$info.region_id}']").attr("pid");
$("select[name='region_id'] option[pid='"+province_id+"']").removeClass("hidden");
$("select[id='province_select'] option[value='"+province_id+"']").attr("selected",true);
$("select[name='region_id'] option[value='{$info.region_id}']").attr("selected",true);
$("input[name='status'][value='{$info.status}']").attr("checked",true); $("input[name='status'][value='{$info.status}']").attr("checked",true);
</if> </if>
}); });
......
...@@ -39,12 +39,12 @@ ...@@ -39,12 +39,12 @@
"> ">
<thead> <thead>
<tr> <tr>
<th data-options="field:'title',width:160,editor:'text'">名称</th> <th data-options="field:'title',width:160,editor:'text'">名称</th>
<th data-options="field:'code',width:160,editor:'text'">代码</th> <th data-options="field:'code',width:160,editor:'text'">代码</th>
<th data-options="field:'postcode',width:160,editor:'text'" formatter="PostcodeAction">邮政编码</th> <th data-options="field:'postcode',width:160,editor:'text'" formatter="PostcodeAction">邮政编码</th>
<th data-options="field:'remark',width:240,align:'left',editor:'text'">备注</th> <th data-options="field:'remark',width:240,align:'left',editor:'text'">备注</th>
<th data-options="field:'updatetime',align:'center'">更新时间</th> <th data-options="field:'updatetime',align:'center'">更新时间</th>
<th data-options="field:'status',align:'center'">状态</th> <th data-options="field:'status',align:'center'" formatter="StatusAction">状态</th>
<th field="action" align="center" formatter="InputAction">操作</th> <th field="action" align="center" formatter="InputAction">操作</th>
</tr> </tr>
</thead> </thead>
...@@ -82,6 +82,13 @@ function PostcodeAction(value, rowData){ ...@@ -82,6 +82,13 @@ function PostcodeAction(value, rowData){
} }
} }
} }
function StatusAction(value, rowData){
if(value==0){
return "<font color=green>启用</font>";
}else{
return "<font color=red>禁用</font>";
}
}
function setSelectRow(rowId) { function setSelectRow(rowId) {
editIndex = undefined; editIndex = undefined;
$('#tg').treegrid('unselectAll'); $('#tg').treegrid('unselectAll');
......
...@@ -42,12 +42,12 @@ ...@@ -42,12 +42,12 @@
</form> </form>
</div><!--hyperchanne end--> </div><!--hyperchanne end-->
<div class=""> <div class="">
<ul class="operationBox"> <!-- <ul class="operationBox">
<li class="add"> <li class="add">
<a href="javascript:;" onclick="add()" class="on"><span></span>新增</a> <a href="javascript:;" onclick="add()" class="on"><span></span>新增</a>
</li> </li>
</ul> </ul>-->
</div><!--mainBox end--> </div><!--mainBox end-->
</div> </div>
</div> </div>
......
...@@ -36,12 +36,12 @@ ...@@ -36,12 +36,12 @@
</form> </form>
</div><!--hyperchanne end--> </div><!--hyperchanne end-->
<div class=""> <div class="">
<ul class="operationBox"> <!-- <ul class="operationBox">
<li class="add"> <li class="add">
<a href="javascript:;" onclick="add()" class="on"><span></span>新增</a> <a href="javascript:;" onclick="add()" class="on"><span></span>新增</a>
</li> </li>
</ul> </ul>-->
</div><!--mainBox end--> </div><!--mainBox end-->
</div> </div>
</div> </div>
......
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