Commit 6736c928 authored by wangjiangze's avatar wangjiangze

update

parent b9ad3da3
...@@ -27,10 +27,13 @@ class FrontAction extends CommonAction{ ...@@ -27,10 +27,13 @@ class FrontAction extends CommonAction{
$model = D("Front"); $model = D("Front");
$hotelModel = D("Hotel"); $hotelModel = D("Hotel");
$deviceStorageModel = D("DeviceStorage");
if($id){ if($id){
$info =$model->where("id = $id")->find(); $info =$model->where("id = $id")->find();
$this->info = $info; $this->info = $info;
$storage_list = $deviceStorageModel->field("id,`path`,`size`")->where("device_id = $id")->select();
$this->storage_list = $storage_list;
} }
$hotel_lists = $hotelModel->where("`status`=0")->select(); $hotel_lists = $hotelModel->where("`status`=0")->select();
$this->hotel_lists = $hotel_lists; $this->hotel_lists = $hotel_lists;
...@@ -39,6 +42,7 @@ class FrontAction extends CommonAction{ ...@@ -39,6 +42,7 @@ class FrontAction extends CommonAction{
//添加处理 //添加处理
public function addHandle(){ public function addHandle(){
$model = D("Front"); $model = D("Front");
$deviceStorageModel = D("DeviceStorage");
$id = I('id','',int); $id = I('id','',int);
$data['hotel_id'] = I("hotel_id"); $data['hotel_id'] = I("hotel_id");
...@@ -47,13 +51,27 @@ class FrontAction extends CommonAction{ ...@@ -47,13 +51,27 @@ class FrontAction extends CommonAction{
$data['code'] = I("code"); $data['code'] = I("code");
$data['ip'] = I("ip"); $data['ip'] = I("ip");
$data['port'] = I("port"); $data['port'] = I("port");
$data['virtual_ip'] = I("virtual_ip");
$data['netcard'] = I("netcard");
$data['remark'] = I("remark"); $data['remark'] = I("remark");
$data['status'] = I("status"); $data['status'] = I("status");
$path_arr = I("post.path");
$size_arr = I("post.size");
if($id){ if($id){
$data['id'] = $id; $data['id'] = $id;
$data["updatetime"]=date('Y-m-d H:i:s'); $data["updatetime"]=date('Y-m-d H:i:s');
$r = $model->save($data); $r = $model->save($data);
if($path_arr){
$deviceStorageModel->where("device_id = ".$id)->delete();
foreach($path_arr as $key => $value){
$storageData[] = array("device_id"=>$id,"path"=>$value,"size"=>$size_arr[$key],"addtime"=>date('Y-m-d H:i:s'));
}
$r = $deviceStorageModel->addAll($storageData);
}
if($r){ if($r){
echo 'true'; echo 'true';
}else{ }else{
...@@ -63,6 +81,13 @@ class FrontAction extends CommonAction{ ...@@ -63,6 +81,13 @@ class FrontAction extends CommonAction{
$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($path_arr){
foreach($path_arr as $key => $value){
$storageData[] = array("device_id"=>$id,"path"=>$value,"size"=>$size_arr[$key],"addtime"=>date('Y-m-d H:i:s'));
}
$r = $deviceStorageModel->addAll($storageData);
}
if($id){ if($id){
echo 'true'; echo 'true';
}else{ }else{
......
<?php
class DeviceStorageModel extends RelationModel{
protected $tableName = 'sh_hotel_device_storage'; //重新定义表名
public function getList($queryType,$userInfo,$inputs){
$p=$inputs["page"]?$inputs["page"]:1;
$n=$inputs["rows"]?$inputs["rows"]:10;
$limit = "limit ".($p-1)*$n.",".$n;
$sort="";
if($inputs["sort"])
$sort = "order by ".$inputs["sort"]." ".$inputs["order"];
//=============
$searchField = $inputs["searchField"]?$inputs["searchField"]:'A.name';
$searchValue = $inputs["searchValue"]?$inputs["searchValue"]:'';
$searchHotel = $inputs["searchHotel"]?$inputs["searchHotel"]:0;
if($searchValue){
$where = " and (A.`name` like '%".$searchValue."%' or A.`code` like '%".$searchValue."%') ";
}
if($searchHotel){
$where .= " and A.hotel_id = $searchHotel ";
}
$model = new Model();
//======================
$fields = "count(A.id) count";
//返回列表(limit分页)
if($queryType=="list"){
$where .= $sort." ".$limit;
$fields = " A.*,B.`name` hotel_name,case A.`status` when 1 then '<font color=red>禁用</font>' when 0 then '<font color=green>启用</font>' end as `status` ";
}
$sql = "select ".$fields." from sh_hotel_device A join sh_hotel B on A.hotel_id = B.id where 1=1 ".$where.";";
return $model->query($sql);
}
}
\ No newline at end of file
...@@ -61,6 +61,40 @@ body{padding:20px} ...@@ -61,6 +61,40 @@ body{padding:20px}
<input type="text" class="form-control" id="inputEmail3" placeholder="端口" name="port" value="{$info.port}"> <input type="text" class="form-control" id="inputEmail3" placeholder="端口" name="port" value="{$info.port}">
</div> </div>
</div> </div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">虚拟IP</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="inputEmail3" placeholder="请输入虚拟IP" name="virtual_ip" value="{$info.virtual_ip}">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">服务网卡名称</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="inputEmail3" placeholder="服务网卡名称" name="netcard" value="{$info.netcard}">
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">存储路径配置</label>
<div class="col-sm-3">
<input id="pathAddBtn" type="button" class="btn btn-success" value="+ 增加"/>  
</div>
</div>
<div class="path_box">
<volist name="storage_list" id="item">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">路径{$key+1}</label>
<div class="col-sm-3">
<input type="text" class="form-control" id="inputEmail3" placeholder="存储根路径(例:/data1)" name="path[]" value="{$item.path}">
</div>
<div class="col-sm-3">
<input type="text" class="form-control" id="inputEmail3" placeholder="存储大小,单位GB" name="size[]" value="{$item.size}">
</div>
<div class="col-sm-2">
<input id="pathDelBtn" type="button" class="btn btn-warning" value="- 删除"/>
</div>
</div>
</volist>
</div>
<div class="form-group"> <div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">备注</label> <label for="inputPassword3" class="col-sm-2 control-label">备注</label>
<div class="col-sm-9"> <div class="col-sm-9">
...@@ -127,6 +161,31 @@ function submitForm(){ ...@@ -127,6 +161,31 @@ function submitForm(){
}); });
} }
$().ready(function(){ $().ready(function(){
$("#pathAddBtn").bind("click",function(){
var n = $(".path_box .form-group").length;
var path_html = '<div class="form-group">'+
'<label for="inputEmail3" class="col-sm-3 control-label">路径'+(n+1)+'</label>'+
'<div class="col-sm-3">'+
'<input type="text" class="form-control" id="inputEmail3" placeholder="存储根路径(例:/data1)" name="path[]" value="{$info.path}">'+
'</div>'+
'<div class="col-sm-3">'+
'<input type="text" class="form-control" id="inputEmail3" placeholder="存储大小,单位GB" name="size[]" value="{$info.size}">'+
'</div>'+
'<div class="col-sm-2">'+
'<input id="pathDelBtn" type="button" class="btn btn-warning" value="- 删除"/>'+
'</div>'+
'</div>';
$(".path_box").append(path_html);
});
$("body").on("click","#pathDelBtn",function(){
$(this).parent().parent().remove();
var n = $(".path_box .form-group").length;
if(n>0){
$(".path_box .form-group").each(function(i,item){
$(this).find(".control-label").text("路径"+(i+1));
});
}
});
<if condition="$info"> <if condition="$info">
$("input[name='type'][value='{$info.type}']").attr("checked",true); $("input[name='type'][value='{$info.type}']").attr("checked",true);
$("input[name='status'][value='{$info.status}']").attr("checked",true); $("input[name='status'][value='{$info.status}']").attr("checked",true);
......
...@@ -71,6 +71,8 @@ onRowContextMenu : onRowContextMenu ...@@ -71,6 +71,8 @@ onRowContextMenu : onRowContextMenu
<th data-options="field:'code',width:20">分前端标识</th> <th data-options="field:'code',width:20">分前端标识</th>
<th data-options="field:'ip',width:30">IP</th> <th data-options="field:'ip',width:30">IP</th>
<th data-options="field:'port',width:20">端口</th> <th data-options="field:'port',width:20">端口</th>
<th data-options="field:'virtual_ip',width:30">虚拟IP</th>
<th data-options="field:'netcard',width:20">服务网卡名称</th>
<th data-options="field:'remark',width:40">备注</th> <th data-options="field:'remark',width:40">备注</th>
<th data-options="field:'addtime',width:30" sortable="true">创建时间</th> <th data-options="field:'addtime',width:30" sortable="true">创建时间</th>
<th data-options="field:'updatetime',width:30" sortable="true">更新时间</th> <th data-options="field:'updatetime',width:30" sortable="true">更新时间</th>
...@@ -149,12 +151,12 @@ function enable(status){ ...@@ -149,12 +151,12 @@ function enable(status){
} }
} }
function add(){ function add(){
pop(800,450,true,'dg','datagrid','/Hotel/Front/add/') pop(800,600,true,'dg','datagrid','/Hotel/Front/add/')
} }
function edit(){ function edit(){
var row = $('#dg').datagrid('getSelected'); var row = $('#dg').datagrid('getSelected');
if (row){ if (row){
pop(800,450,true,'dg','datagrid','/Hotel/Front/add/id/'+row.id); pop(800,600,true,'dg','datagrid','/Hotel/Front/add/id/'+row.id);
}else{ }else{
$.messager.alert('提示', '请选择要操作的记录!','info'); $.messager.alert('提示', '请选择要操作的记录!','info');
} }
......
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