Commit 2d1d9c74 authored by wangjiangze's avatar wangjiangze

酒店管理、合作方管理功能完成

parent c84f5129
......@@ -21,7 +21,7 @@ return array(
'APP_STATUS' => 'debug',
//分组
'APP_GROUP_LIST'=>'System', //项目分组列表(配置即表示开启分组)
'APP_GROUP_LIST'=>'System,Hotel,Sp', //项目分组列表(配置即表示开启分组)
'DEFAULT_GROUP'=>'',
//多语言
......
<?php
class HotelAction extends CommonAction{
//管理
public function index(){
$op = I('op');
if($op=="getjson"){
$model = D("Hotel");
$userInfo = $_SESSION["_USER_INFO"];
$inputs = I();
$list = $model->getList("list",$userInfo,$inputs);
$count = $model->getList("count",$userInfo,$inputs);
$total = $count[0]["count"];
echo "{\"total\":\"".$total."\",\"rows\":".json_encode($list)."}";
}else{
$spModel = D("Sp");
$sp_lists = $spModel->where("`status`=0")->select();
$this->sp_lists = $sp_lists;
$this->display();
}
}
//添加
public function add(){
$userInfo = $_SESSION["_USER_INFO"];
$id = I('id','',int)?I('id','',int):0;
$model = D("Hotel");
$spModel = D("Sp");
$regionModel = D("Region");
if($id){
$info =$model->where("id = $id")->find();
$this->info = $info;
}
$sp_lists = $spModel->where("`status`=0")->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_city_lists = $region_city_lists;
$this->display();
}
//添加处理
public function addHandle(){
$model = D("Hotel");
$id = I('id','',int);
$data['sp_id'] = I("sp_id");
$data['region_id'] = I("region_id");
$data['name'] = I("name");
$data['code'] = I("code");
$data['remark'] = I("remark");
$data['status'] = I("status");
if($id){
$data['id'] = $id;
$data["updatetime"]=date('Y-m-d H:i:s');
$r = $model->save($data);
if($r){
echo 'true';
}else{
echo 'false';
}
}else{
$data["addtime"]=date('Y-m-d H:i:s');
$id = $model->add($data);
if($id){
echo 'true';
}else{
echo 'false';
}
}
}
//删除处理
public function deleteHandle(){
if(D("Hotel")->where("id=".I("id","",int))->delete()){
echo 'true';
}else{
echo 'false';
}
}
//ajax修改状态
public function updateStatusAjaxHandle(){
$model = D("Hotel");
$data = $_POST;
$data['updatetime'] = date('Y-m-d H:i:s');
if($model->save($data)){
echo 'true';
}else{
echo 'false';
}
}
}
<?php
class SpAction extends CommonAction{
//管理
public function index(){
$op = I('op');
if($op=="getjson"){
$model = D("Sp");
$userInfo = $_SESSION["_USER_INFO"];
$inputs = I();
$list = $model->getList("list",$userInfo,$inputs);
$count = $model->getList("count",$userInfo,$inputs);
$total = $count[0]["count"];
echo "{\"total\":\"".$total."\",\"rows\":".json_encode($list)."}";
}else{
$spModel = D("Sp");
$sp_lists = $spModel->where("`status`=0")->select();
$this->sp_lists = $sp_lists;
$this->display();
}
}
//添加
public function add(){
$userInfo = $_SESSION["_USER_INFO"];
$id = I('id','',int)?I('id','',int):0;
$model = D("Sp");
$spModel = D("Sp");
$regionModel = D("Region");
if($id){
$info =$model->where("id = $id")->find();
$this->info = $info;
}
$sp_lists = $spModel->where("`status`=0")->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_city_lists = $region_city_lists;
$this->display();
}
//添加处理
public function addHandle(){
$model = D("Sp");
$id = I('id','',int);
$data['name'] = I("name");
$data['code'] = I("code");
$data['email'] = I("email");
$data['mobile'] = I("mobile");
$data['remark'] = I("remark");
$data['status'] = I("status");
if($id){
$data['id'] = $id;
$data["updatetime"]=date('Y-m-d H:i:s');
$r = $model->save($data);
if($r){
echo 'true';
}else{
echo 'false';
}
}else{
$data["addtime"]=date('Y-m-d H:i:s');
$id = $model->add($data);
if($id){
echo 'true';
}else{
echo 'false';
}
}
}
//删除处理
public function deleteHandle(){
if(D("Sp")->where("id=".I("id","",int))->delete()){
echo 'true';
}else{
echo 'false';
}
}
//ajax修改状态
public function updateStatusAjaxHandle(){
$model = D("Sp");
$data = $_POST;
$data['updatetime'] = date('Y-m-d H:i:s');
if($model->save($data)){
echo 'true';
}else{
echo 'false';
}
}
}
<?php
class HotelModel extends RelationModel{
protected $tableName = 'sh_hotel'; //重新定义表名
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"]:'name';
$searchValue = $inputs["searchValue"]?$inputs["searchValue"]:'';
$searchSp = $inputs["searchSp"]?$inputs["searchSp"]:0;
$searchRegion = $inputs["searchRegion"]?$inputs["searchRegion"]:0;
if($searchValue){
$where = " and (A.`name` like '%".$searchValue."%' or A.`code` like '%".$searchValue."%') ";
}
$model = new Model();
//======================
$fields = "count(A.id) count";
//返回列表(limit分页)
if($queryType=="list"){
$where .= $sort." ".$limit;
$fields = "A.*,B.`name` sp_name,C.`name` region_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 A join sh_sp B on A.sp_id=B.id join sh_region C on A.region_id=C.id where 1=1 ".$where.";";
// echo $sql;
return $model->query($sql);
}
}
\ No newline at end of file
<?php
class RegionModel extends RelationModel{
protected $tableName = 'sh_region'; //重新定义表名
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"]:'name';
$searchValue = $inputs["searchValue"]?$inputs["searchValue"]:'';
$searchType = $inputs["searchType"]?$inputs["searchType"]:0;
$searchZone = $inputs["searchZone"]?$inputs["searchZone"]:0;
if($searchValue){
$where = " and (`name` like '%".$searchValue."%' or `ip_addr` like '%".$searchValue."%' or `mac` like '%".$searchValue."%') ";
}
if($searchType){
$where .= " and `type` = ".$searchType." ";
}
$model = new Model();
//======================
$fields = "count(pb.id) count";
//返回列表(limit分页)
if($queryType=="list"){
$where .= $sort." ".$limit;
$fields = "A.*,FROM_UNIXTIME(A.addtime) addtime,FROM_UNIXTIME(A.updatetime) updatetime,B.`name` sp_name,C.`name` region_name,case A.status when 0 then '<font color=red>禁用</font>' when 1 then '<font color=green>启用</font>' end as status";
}
$sql = "select ".$fields." from sh_hotel A join sh_sp B on A.sp_id=B.id join sh_region C on A.region_id=C.id where 1=1 ".$where.";";
return $model->query($sql);
}
}
\ No newline at end of file
<?php
class SpModel extends RelationModel{
protected $tableName = 'sh_sp'; //重新定义表名
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"]:'name';
$searchValue = $inputs["searchValue"]?$inputs["searchValue"]:'';
if($searchValue){
$where = " and (`name` like '%".$searchValue."%' or `code` like '%".$searchValue."%') ";
}
$model = new Model();
//======================
$fields = "count(id) count";
//返回列表(limit分页)
if($queryType=="list"){
$where .= $sort." ".$limit;
$fields = "*,case `status` when 1 then '<font color=red>禁用</font>' when 0 then '<font color=green>启用</font>' end as `status`";
}
$sql = "select ".$fields." from sh_sp where 1=1 ".$where.";";
return $model->query($sql);
}
}
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>酒店添加/修改</title>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap3.3.7/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap3.3.7/bootstrap.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery-easyui-1.3.4/plugins/jquery.validatebox.extend.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery-easyui-1.3.4/locale/easyui-lang-{$language}.js"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery-easyui-1.3.4/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery-easyui-1.3.4/themes/icon.css">
<link rel="stylesheet" href="__PUBLIC__/js/bootstrap3.3.7/bootstrap.min.css">
<style>
body{padding:20px}
</style>
</head>
<body>
<form class="form-horizontal" role="form" id="ff" action="{:U('/Hotel/Hotel/addHandle')}" method="POST">
<input name="id" type="hidden" value="{$info.id}"/>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">选择合作方</label>
<div class="col-sm-6" name="type">
<select class="form-control" name="sp_id">
<option value="0">请选择合作方</optoin>
<volist name="sp_lists" id="item">
<option value="{$item.id}">{$item.name}</optoin>
</volist>
</select>
</div>
</div>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">选择区域</label>
<div class="col-sm-3">
<select class="form-control" id="province_select">
<option value="0">请选择省份</optoin>
<volist name="region_lists" id="item">
<option value="{$item.id}">{$item.name}</optoin>
</volist>
</select>
</div>
<div class="col-sm-3">
<select class="form-control" id="city_select" name="region_id">
<option value="0" pid="0">请选择城市</optoin>
<volist name="region_city_lists" id="item">
<option value="{$item.id}" class="hidden" pid="{$item.pid}">{$item.name}</optoin>
</volist>
</select>
</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="请输入酒店名称" value="{$info.name}" name="name">
</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="code" value="{$info.code}">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">备注</label>
<div class="col-sm-9">
<textarea class="form-control" rows="3" name="remark">{$info.remark}</textarea>
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">状态</label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" name="status" id="optionsRadios4" value="1"> 禁用
</label>
<label class="radio-inline">
<input type="radio" name="status" id="optionsRadios4" value="0" checked="checked"> 启用
</label>
</div>
</div>
<div class="btnHotel col-sm-5 control-label">
<input name="" type="button" class="btn btn-success" value="确定" onclick="submitForm()" {:buttonAuth('Hotel','Hotel','addhandle')}/>  
<input name="" type="reset" class="btn btn-warning" value="取消" onclick="parentDialog.close();"/>  
</div>
</form>
<script type="text/javascript">
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 code_v = $("input[name='code']").val();
if(sp_id==0){
alert("请选择合作方");return;
}
if(region_id==0){
alert("请选择省份/城市");return;
}
if(!name_v){
alert("请输入酒店名称");return;
}
if(!code_v){
alert("请输入合作方酒店标识");return;
}
$('#ff').form('submit', {
url:'/Hotel/Hotel/addHandle/',
onSubmit: function(){
var isValid = $(this).form('validate');//触发form内的所有validatebox验证,并返回true/false
if(!isValid)
$('#tab').tabs('select',0);
return isValid;
},
success:function(data){
if(data=='true'){
$.messager.confirm('友情提示', '操作成功! 是否关闭窗口?', function(r){
if (r){
parentDialog.CancelEvent();
}
});
}else
$.messager.alert('友情提示','操作失败','info');
}
});
}
$().ready(function(){
$("select[id='province_select']").bind("change",function(){
var province_id = $(this).val();
$("select[name='region_id'] option").addClass("hidden");
$("select[name='region_id'] option[pid='0']").removeClass("hidden");
$("select[name='region_id'] option[value='0']").attr("selected",true);
$("select[name='region_id'] option[pid='"+province_id+"']").removeClass("hidden");
});
<if condition="$info">
$("select[name='sp_id'] option[value='{$info.sp_id}']").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);
</if>
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>酒店管理</title>
<link href="__PUBLIC__/css/style_frame.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery-easyui-1.3.4/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery-easyui-1.3.4/themes/icon.css">
<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery-easyui-1.3.4/locale/easyui-lang-{$language}.js"></script>
<script type="text/javascript" src="__PUBLIC__/newVsdn/js/zDialog/zDrag.js"></script>
<script type="text/javascript" src="__PUBLIC__/newVsdn/js/zDialog/zDialog.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common/functions.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common/md5.js"></script>
<link href="__PUBLIC__/newVsdn/css/style_frame.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!--搜索和按钮 开始 -->
<div class="searchHotel clearfix">
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<div class="hyperchanne clearfix">
<form name="searchform" method="post" action="" id ="searchform">
<input type="hidden" name="op" value="getjson">
<div class="inputBox">
<select class="select" name="searchType">
<option value="0">合作方</option>
<volist name="sp_lists" id="item">
<option value="{$item.id}">{$item.name}</optoin>
</volist>
</select>
<select class="select" name="searchRegion">
<option value="0">区域</option>
</select>
<input class="input" type="text" placeholder="酒店名称/合作方酒店标识" name="searchValue">
</div>
<input id="submit_search" name="" type="button" value="查询" class="btn_go_s btn_orange" />
</form>
</div><!--hyperchanne end-->
<div class="">
<ul class="operationBox">
<li class="add">
<a href="javascript:;" onclick="add()" class="on"><span></span>新增</a>
</li>
</ul>
</div><!--mainBox end-->
</div>
</div>
</div>
<!--搜索和按钮 结束-->
<table id="dg" title=""
data-options="
iconCls: 'icon-edit',
singleSelect: true,
url: '/Hotel/Hotel/index/',
method: 'post',
pagination: true,
pageList:[15,30,45,60],
rownumbers: true,
sortName:'id',
sortOrder:'asc',
queryParams: form2Json('searchform'),
fitColumns: true,
height:'auto',
onRowContextMenu : onRowContextMenu
">
<thead>
<tr>
<th data-options="field:'sp_name',width:20" sortable="true">合作方</th>
<th data-options="field:'region_name',width:30" sortable="true">区域</th>
<th data-options="field:'name',width:30">酒店名称</th>
<th data-options="field:'code',width:20">合作方酒店标识</th>
<th data-options="field:'remark',width:40">备注</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:'status'" sortable="true" align="center">状态</th>
<th field="action" align="center" formatter="InputAction">操作</th>
</tr>
</thead>
</table>
<div id="mm1" class="easyui-menu" style="width:120px;display: none">
<div iconCls="icon-edit" id="menuEdit" onclick="edit()" {:buttonAuth('Hotel','Hotel','add')}>编辑</div>
<div iconCls="icon-cancel" id="menuDel" onclick="del()" {:buttonAuth('Hotel','Hotel','deletehandle')}>删除</div>
<div class="menu-sep"></div>
<div iconCls="icon-stop" id="menuStop" onclick="enable(1)" {:buttonAuth('Hotel','Hotel','updateStatusAjaxHandle')}>禁用</div>
<div iconCls="icon-start" id="menuStart" onclick="enable(0)" {:buttonAuth('Hotel','Hotel','updateStatusAjaxHandle')}>启用</div>
</div>
<div id="mm2" class="easyui-menu" style="width:120px;display: none">
<div iconCls="icon-edit" id="menuEdit" onclick="edit()" {:buttonAuth('Hotel','Hotel','add')}>编辑</div>
<div iconCls="icon-cancel" id="menuDel" onclick="del()" {:buttonAuth('Hotel','Hotel','deletehandle')}>删除</div>
<div class="menu-sep"></div>
<div iconCls="icon-stop" id="menuStop" onclick="enable(1)" {:buttonAuth('Hotel','Hotel','updateStatusAjaxHandle')}>禁用</div>
<div iconCls="icon-start" id="menuStart" onclick="enable(0)" {:buttonAuth('Hotel','Hotel','updateStatusAjaxHandle')}>启用</div>
</div>
<script type="text/javascript">
function onRowContextMenu(e, rowIndex, rowData){
e.preventDefault();
$('#dg').datagrid('unselectAll');
$('#dg').datagrid('selectRow', rowIndex);
$('#mm2').menu('show', {
left:e.pageX,
top:e.pageY
});
}
function InputAction(value, row, index) {
return'<a href="javascript:void(0)" id="mb' + index + '" class="easyui-menubutton" menu="#mm1" iconCls="icon-list" onmouseover="setSelectRow(' + index + ')">'+this.title+'</a>';
}
function setSelectRow(index) {
$('#dg').datagrid('unselectAll');
$('#dg').datagrid('selectRow', index);
}
//初始化菜单按钮
$(function(){
$('#dg').datagrid({
onLoadSuccess: function (data) {
for (i = 0; i < $('#dg').datagrid('getRows').length; i++) {
$('#mb' + i).menubutton();
}
}
})
});
//禁用启用
function enable(status){
var row = $('#dg').datagrid('getSelected');
if (row){
var msg='启用';
if(status==1)
msg='禁用'
$.messager.confirm('操作确认', '确认['+msg+']该记录?', function(r){
if (r){
$.post("/Hotel/Hotel/updateStatusAjaxHandle/", {id:row.id,status:status},
function(data){
$('#dg').datagrid('reload');
});
}
});
}else{
$.messager.alert('提示', '请选择要操作的记录!','info');
}
}
function add(){
pop(800,450,true,'dg','datagrid','/Hotel/Hotel/add/')
}
function edit(){
var row = $('#dg').datagrid('getSelected');
if (row){
pop(800,450,true,'dg','datagrid','/Hotel/Hotel/add/id/'+row.id);
}else{
$.messager.alert('提示', '请选择要操作的记录!','info');
}
}
function del(){
var row = $('#dg').datagrid('getSelected');
if (row){
$.messager.confirm('操作确认', '确认[删除]该记录?', function(r){
if (r){
$.post("/Hotel/Hotel/deleteHandle/", {id:row.id},
function(data){
$('#dg').datagrid('reload');
});
}
});
}else{
$.messager.alert('提示', '请选择要操作的记录!','info');
}
}
$("#submit_search").click(function () {
$('#dg').datagrid({ queryParams: form2Json("searchform") }); //点击搜索
});
/**
* JQuery扩展方法,用户对JQuery EasyUI的DataGrid控件进行操作。
*/
$.fn.extend({
/**
* 修改DataGrid对象的默认大小,以适应页面宽度。
*
* @param heightMargin
* 高度对页内边距的距离。
* @param widthMargin
* 宽度对页内边距的距离。
* @param minHeight
* 最小高度。
* @param minWidth
* 最小宽度。
*
*/
resizeDataGrid : function(heightMargin, widthMargin, minHeight, minWidth) {
var height = $(document.body).height() - heightMargin;
var width = $(document.body).width() - widthMargin;
height = height < minHeight ? minHeight : height;
width = width < minWidth ? minWidth : width;
$(this).datagrid('resize', {
//height : height,
width : width
});
}
});
$(function() {
// datagrid数据表格ID
var datagridId = 'dg';
// 第一次加载时自动变化大小
$('#' + datagridId).resizeDataGrid(0, 10, 0, 0);
// 当窗口大小发生变化时,调整DataGrid的大小
$(window).resize(function() {
$('#' + datagridId).resizeDataGrid(0, 10, 0, 0);
});
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>合作方添加/修改</title>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap3.3.7/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap3.3.7/bootstrap.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery-easyui-1.3.4/plugins/jquery.validatebox.extend.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery-easyui-1.3.4/locale/easyui-lang-{$language}.js"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery-easyui-1.3.4/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery-easyui-1.3.4/themes/icon.css">
<link rel="stylesheet" href="__PUBLIC__/js/bootstrap3.3.7/bootstrap.min.css">
<style>
body{padding:20px}
</style>
</head>
<body>
<form class="form-horizontal" role="form" id="ff" action="{:U('/Sp/Sp/addHandle')}" method="POST">
<input name="id" type="hidden" value="{$info.id}"/>
<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="请输入合作方名称" value="{$info.name}" name="name">
</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="code" value="{$info.code}">
</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="email" value="{$info.email}">
</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="mobile" value="{$info.mobile}">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">备注</label>
<div class="col-sm-9">
<textarea class="form-control" rows="3" name="remark">{$info.remark}</textarea>
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">状态</label>
<div class="col-sm-9">
<label class="radio-inline">
<input type="radio" name="status" id="optionsRadios4" value="1"> 禁用
</label>
<label class="radio-inline">
<input type="radio" name="status" id="optionsRadios4" value="0" checked="checked"> 启用
</label>
</div>
</div>
<div class="btnSp col-sm-5 control-label">
<input name="" type="button" class="btn btn-success" value="确定" onclick="submitForm()" {:buttonAuth('Sp','Sp','addhandle')}/>  
<input name="" type="reset" class="btn btn-warning" value="取消" onclick="parentDialog.close();"/>  
</div>
</form>
<script type="text/javascript">
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 code_v = $("input[name='code']").val();
if(sp_id==0){
alert("请选择合作方");return;
}
if(region_id==0){
alert("请选择省份/城市");return;
}
if(!name_v){
alert("请输入酒店名称");return;
}
if(!code_v){
alert("请输入合作方酒店标识");return;
}
$('#ff').form('submit', {
url:'/Sp/Sp/addHandle/',
onSubmit: function(){
var isValid = $(this).form('validate');//触发form内的所有validatebox验证,并返回true/false
if(!isValid)
$('#tab').tabs('select',0);
return isValid;
},
success:function(data){
if(data=='true'){
$.messager.confirm('友情提示', '操作成功! 是否关闭窗口?', function(r){
if (r){
parentDialog.CancelEvent();
}
});
}else
$.messager.alert('友情提示','操作失败','info');
}
});
}
$().ready(function(){
$("select[id='province_select']").bind("change",function(){
var province_id = $(this).val();
$("select[name='region_id'] option").addClass("hidden");
$("select[name='region_id'] option[pid='0']").removeClass("hidden");
$("select[name='region_id'] option[value='0']").attr("selected",true);
$("select[name='region_id'] option[pid='"+province_id+"']").removeClass("hidden");
});
<if condition="$info">
$("select[name='sp_id'] option[value='{$info.sp_id}']").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);
</if>
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>合作方管理</title>
<link href="__PUBLIC__/css/style_frame.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery-easyui-1.3.4/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/js/jquery-easyui-1.3.4/themes/icon.css">
<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/jquery-easyui-1.3.4/locale/easyui-lang-{$language}.js"></script>
<script type="text/javascript" src="__PUBLIC__/newVsdn/js/zDialog/zDrag.js"></script>
<script type="text/javascript" src="__PUBLIC__/newVsdn/js/zDialog/zDialog.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common/functions.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common/md5.js"></script>
<link href="__PUBLIC__/newVsdn/css/style_frame.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!--搜索和按钮 开始 -->
<div class="searchSp clearfix">
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<div class="hyperchanne clearfix">
<form name="searchform" method="post" action="" id ="searchform">
<input type="hidden" name="op" value="getjson">
<div class="inputBox">
<input class="input" type="text" placeholder="合作方名称/合作方代码" name="searchValue">
</div>
<input id="submit_search" name="" type="button" value="查询" class="btn_go_s btn_orange" />
</form>
</div><!--hyperchanne end-->
<div class="">
<ul class="operationBox">
<li class="add">
<a href="javascript:;" onclick="add()" class="on"><span></span>新增</a>
</li>
</ul>
</div><!--mainBox end-->
</div>
</div>
</div>
<!--搜索和按钮 结束-->
<table id="dg" title=""
data-options="
iconCls: 'icon-edit',
singleSelect: true,
url: '/Sp/Sp/index/',
method: 'post',
pagination: true,
pageList:[15,30,45,60],
rownumbers: true,
sortName:'id',
sortOrder:'asc',
queryParams: form2Json('searchform'),
fitColumns: true,
height:'auto',
onRowContextMenu : onRowContextMenu
">
<thead>
<tr>
<th data-options="field:'name',width:20" sortable="true">合作方名称</th>
<th data-options="field:'code',width:20">合作方代码</th>
<th data-options="field:'email',width:20">邮箱</th>
<th data-options="field:'mobile',width:20">手机号</th>
<th data-options="field:'remark',width:40">备注</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:'status'" sortable="true" align="center">状态</th>
<th field="action" align="center" formatter="InputAction">操作</th>
</tr>
</thead>
</table>
<div id="mm1" class="easyui-menu" style="width:120px;display: none">
<div iconCls="icon-edit" id="menuEdit" onclick="edit()" {:buttonAuth('Sp','Sp','add')}>编辑</div>
<div iconCls="icon-cancel" id="menuDel" onclick="del()" {:buttonAuth('Sp','Sp','deletehandle')}>删除</div>
<div class="menu-sep"></div>
<div iconCls="icon-stop" id="menuStop" onclick="enable(1)" {:buttonAuth('Sp','Sp','updateStatusAjaxHandle')}>禁用</div>
<div iconCls="icon-start" id="menuStart" onclick="enable(0)" {:buttonAuth('Sp','Sp','updateStatusAjaxHandle')}>启用</div>
</div>
<div id="mm2" class="easyui-menu" style="width:120px;display: none">
<div iconCls="icon-edit" id="menuEdit" onclick="edit()" {:buttonAuth('Sp','Sp','add')}>编辑</div>
<div iconCls="icon-cancel" id="menuDel" onclick="del()" {:buttonAuth('Sp','Sp','deletehandle')}>删除</div>
<div class="menu-sep"></div>
<div iconCls="icon-stop" id="menuStop" onclick="enable(1)" {:buttonAuth('Sp','Sp','updateStatusAjaxHandle')}>禁用</div>
<div iconCls="icon-start" id="menuStart" onclick="enable(0)" {:buttonAuth('Sp','Sp','updateStatusAjaxHandle')}>启用</div>
</div>
<script type="text/javascript">
function onRowContextMenu(e, rowIndex, rowData){
e.preventDefault();
$('#dg').datagrid('unselectAll');
$('#dg').datagrid('selectRow', rowIndex);
$('#mm2').menu('show', {
left:e.pageX,
top:e.pageY
});
}
function InputAction(value, row, index) {
return'<a href="javascript:void(0)" id="mb' + index + '" class="easyui-menubutton" menu="#mm1" iconCls="icon-list" onmouseover="setSelectRow(' + index + ')">'+this.title+'</a>';
}
function setSelectRow(index) {
$('#dg').datagrid('unselectAll');
$('#dg').datagrid('selectRow', index);
}
//初始化菜单按钮
$(function(){
$('#dg').datagrid({
onLoadSuccess: function (data) {
for (i = 0; i < $('#dg').datagrid('getRows').length; i++) {
$('#mb' + i).menubutton();
}
}
})
});
//禁用启用
function enable(status){
var row = $('#dg').datagrid('getSelected');
if (row){
var msg='启用';
if(status==1)
msg='禁用'
$.messager.confirm('操作确认', '确认['+msg+']该记录?', function(r){
if (r){
$.post("/Sp/Sp/updateStatusAjaxHandle/", {id:row.id,status:status},
function(data){
$('#dg').datagrid('reload');
});
}
});
}else{
$.messager.alert('提示', '请选择要操作的记录!','info');
}
}
function add(){
pop(800,450,true,'dg','datagrid','/Sp/Sp/add/')
}
function edit(){
var row = $('#dg').datagrid('getSelected');
if (row){
pop(800,450,true,'dg','datagrid','/Sp/Sp/add/id/'+row.id);
}else{
$.messager.alert('提示', '请选择要操作的记录!','info');
}
}
function del(){
var row = $('#dg').datagrid('getSelected');
if (row){
$.messager.confirm('操作确认', '确认[删除]该记录?', function(r){
if (r){
$.post("/Sp/Sp/deleteHandle/", {id:row.id},
function(data){
$('#dg').datagrid('reload');
});
}
});
}else{
$.messager.alert('提示', '请选择要操作的记录!','info');
}
}
$("#submit_search").click(function () {
$('#dg').datagrid({ queryParams: form2Json("searchform") }); //点击搜索
});
/**
* JQuery扩展方法,用户对JQuery EasyUI的DataGrid控件进行操作。
*/
$.fn.extend({
/**
* 修改DataGrid对象的默认大小,以适应页面宽度。
*
* @param heightMargin
* 高度对页内边距的距离。
* @param widthMargin
* 宽度对页内边距的距离。
* @param minHeight
* 最小高度。
* @param minWidth
* 最小宽度。
*
*/
resizeDataGrid : function(heightMargin, widthMargin, minHeight, minWidth) {
var height = $(document.body).height() - heightMargin;
var width = $(document.body).width() - widthMargin;
height = height < minHeight ? minHeight : height;
width = width < minWidth ? minWidth : width;
$(this).datagrid('resize', {
//height : height,
width : width
});
}
});
$(function() {
// datagrid数据表格ID
var datagridId = 'dg';
// 第一次加载时自动变化大小
$('#' + datagridId).resizeDataGrid(0, 10, 0, 0);
// 当窗口大小发生变化时,调整DataGrid的大小
$(window).resize(function() {
$('#' + datagridId).resizeDataGrid(0, 10, 0, 0);
});
});
</script>
</body>
</html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
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