Commit 14f4915b authored by wangjiangze's avatar wangjiangze

播单管理功能提交

parent f7e92bdc
...@@ -29,17 +29,21 @@ class InjectAction extends CommonAction{ ...@@ -29,17 +29,21 @@ class InjectAction extends CommonAction{
$spModel = D("Sp"); $spModel = D("Sp");
$mediaModel = D("Media"); $mediaModel = D("Media");
$hotelModel = D("Hotel"); $hotelModel = D("Hotel");
$spPlaylistModel = D("SpPlaylist");
if($id){ if($id){
$info =$model->where("id = $id")->find(); $info =$model->where("id = $id")->find();
$this->info = $info; $this->info = $info;
} }
$hotel_lists = $hotelModel->where("`status`=0")->select(); $hotel_lists = $hotelModel->where("`status`=0")->select();
$sp_lists = $spModel->select(); $sp_lists = $spModel->field("id,`name`")->select();
$media_lists = $mediaModel->field("id,title")->select(); $media_lists = $mediaModel->field("id,title")->select();
$play_lists = $spPlaylistModel->join(" A join sh_sp_playlist_media_map B on A.id = B.playlist_id ")->field("A.id,A.`name`,A.sp_id,group_concat(B.media_id) media_ids")->group("A.id")->select();
$this->hotel_lists = $hotel_lists; $this->hotel_lists = $hotel_lists;
$this->sp_lists = $sp_lists; $this->sp_lists = $sp_lists;
$this->media_lists = json_encode($media_lists); $this->media_lists = json_encode($media_lists);
$this->play_lists = $play_lists;
$this->display(); $this->display();
} }
//添加处理 //添加处理
......
...@@ -5,7 +5,7 @@ class PlaylistAction extends CommonAction{ ...@@ -5,7 +5,7 @@ class PlaylistAction extends CommonAction{
public function index(){ public function index(){
$op = I('op'); $op = I('op');
if($op=="getjson"){ if($op=="getjson"){
$model = D("Hotel"); $model = D("SpPlaylist");
$userInfo = $_SESSION["_USER_INFO"]; $userInfo = $_SESSION["_USER_INFO"];
$inputs = I(); $inputs = I();
$list = $model->getList("list",$userInfo,$inputs); $list = $model->getList("list",$userInfo,$inputs);
...@@ -14,7 +14,7 @@ class PlaylistAction extends CommonAction{ ...@@ -14,7 +14,7 @@ class PlaylistAction extends CommonAction{
echo "{\"total\":\"".$total."\",\"rows\":".json_encode($list)."}"; echo "{\"total\":\"".$total."\",\"rows\":".json_encode($list)."}";
}else{ }else{
$spModel = D("Sp"); $spModel = D("Sp");
$sp_lists = $spModel->where("`status`=0")->select(); $sp_lists = $spModel->field("id,`name`")->where("`status`=0")->select();
$this->sp_lists = $sp_lists; $this->sp_lists = $sp_lists;
$this->display(); $this->display();
} }
...@@ -25,38 +25,41 @@ class PlaylistAction extends CommonAction{ ...@@ -25,38 +25,41 @@ class PlaylistAction extends CommonAction{
$userInfo = $_SESSION["_USER_INFO"]; $userInfo = $_SESSION["_USER_INFO"];
$id = I('id','',int)?I('id','',int):0; $id = I('id','',int)?I('id','',int):0;
$model = D("Hotel"); $model = D("SpPlaylist");
$spModel = D("Sp"); $spModel = D("Sp");
$regionModel = D("Region"); $mediaModel = D("Media");
if($id){ if($id){
$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(); $sp_lists = $spModel->field("id,`name`")->select();
$region_lists = $regionModel->where("pid = 1 and level = 2 and `status`=0")->select(); $media_lists = $mediaModel->field("id,title")->select();
$region_city_lists = $regionModel->where("pid > 1 and level = 3 and `status`=0")->select(); $play_lists = $model->join(" A join sh_sp_playlist_media_map B on A.id = B.playlist_id ")->field("A.id,A.`name`,A.sp_id,group_concat(B.media_id) media_ids")->group("A.id")->select();
$this->sp_lists = $sp_lists; $this->sp_lists = $sp_lists;
$this->region_lists = $region_lists; $this->media_lists = json_encode($media_lists);
$this->region_city_lists = $region_city_lists; $this->play_lists = $play_lists;
$this->display(); $this->display();
} }
//添加处理 //添加处理
public function addHandle(){ public function addHandle(){
$model = D("Hotel"); $model = D("SpPlaylist");
$mapModel = D("SpPlaylistMediaMap");
$id = I('id','',int); $id = I('id','',int);
$data['sp_id'] = I("sp_id"); $data['sp_id'] = I("sp_id");
$data['region_id'] = I("region_id");
$data['name'] = I("name"); $data['name'] = I("name");
$data['code'] = I("code");
$data['remark'] = I("remark"); $data['remark'] = I("remark");
$data['status'] = I("status"); $data['status'] = I("status");
$media_lists = I("post.media_lists");
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($r){ if($r){
echo 'true'; echo 'true';
}else{ }else{
...@@ -67,6 +70,13 @@ class PlaylistAction extends CommonAction{ ...@@ -67,6 +70,13 @@ class PlaylistAction extends CommonAction{
$id = $model->add($data); $id = $model->add($data);
if($id){ if($id){
$mapData = array();
foreach($media_lists as $key => $value){
$mapData[] = array("media_id"=>$value,"playlist_id"=>$id,"addtime"=>date('Y-m-d H:i:s'));
}
$r = $mapModel->addAll($mapData);
}
if($r){
echo 'true'; echo 'true';
}else{ }else{
echo 'false'; echo 'false';
...@@ -76,7 +86,11 @@ class PlaylistAction extends CommonAction{ ...@@ -76,7 +86,11 @@ class PlaylistAction extends CommonAction{
//删除处理 //删除处理
public function deleteHandle(){ public function deleteHandle(){
if(D("Hotel")->where("id=".I("id","",int))->delete()){ $model = D("SpPlaylist");
$data = $_POST;
$data['status'] = 2;
$data['updatetime'] = date('Y-m-d H:i:s');
if($model->save($data)){
echo 'true'; echo 'true';
}else{ }else{
echo 'false'; echo 'false';
...@@ -85,7 +99,7 @@ class PlaylistAction extends CommonAction{ ...@@ -85,7 +99,7 @@ class PlaylistAction extends CommonAction{
//ajax修改状态 //ajax修改状态
public function updateStatusAjaxHandle(){ public function updateStatusAjaxHandle(){
$model = D("Hotel"); $model = D("SpPlaylist");
$data = $_POST; $data = $_POST;
$data['updatetime'] = date('Y-m-d H:i:s'); $data['updatetime'] = date('Y-m-d H:i:s');
if($model->save($data)){ if($model->save($data)){
......
...@@ -10,12 +10,12 @@ class InjectModel extends RelationModel{ ...@@ -10,12 +10,12 @@ class InjectModel extends RelationModel{
if($inputs["sort"]) if($inputs["sort"])
$sort = "order by ".$inputs["sort"]." ".$inputs["order"]; $sort = "order by ".$inputs["sort"]." ".$inputs["order"];
//============= //=============
$searchField = $inputs["searchField"]?$inputs["searchField"]:'title'; $searchField = $inputs["searchField"]?$inputs["searchField"]:'name';
$searchValue = $inputs["searchValue"]?$inputs["searchValue"]:''; $searchValue = $inputs["searchValue"]?$inputs["searchValue"]:'';
$searchSp = $inputs["searchSp"]?$inputs["searchSp"]:0; $searchSp = $inputs["searchSp"]?$inputs["searchSp"]:0;
if($searchValue){ if($searchValue){
$where = " and (`title` like '%".$searchValue."%' or `code` like '%".$searchValue."%') "; $where = " and (`name` like '%".$searchValue."%') ";
} }
$model = new Model(); $model = new Model();
......
<?php
class SpPlaylistMediaMapModel extends RelationModel{
protected $tableName = 'sh_sp_playlist_media_map'; //重新定义表名
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;
if($searchValue){
$where = " and (A.`name` like '%".$searchValue."%') ";
}
if($searchSp){
$where = " and A.sp_id = $searchSp ";
}
$model = new Model();
//======================
$fields = "count(A.id) count";
//返回列表(limit分页)
if($queryType=="list"){
$where .= $sort." ".$limit;
$fields = " *,B.`name` sp_name,case A.`status` when 0 then '<font color=green>正常</font>' when 1 then '<font color=red>禁用</font>' when 2 then '<font color=red>删除</font>' end as `status` ";
}
$sql = "select ".$fields." from sh_sp_playlist A join sh_sp B on A.sp_id = B.id where 1=1 ".$where.";";
// echo $sql;
return $model->query($sql);
}
}
\ No newline at end of file
<?php
class SpPlaylistModel extends RelationModel{
protected $tableName = 'sh_sp_playlist'; //重新定义表名
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 A.".$inputs["sort"]." ".$inputs["order"];
//=============
$searchField = $inputs["searchField"]?$inputs["searchField"]:'name';
$searchValue = $inputs["searchValue"]?$inputs["searchValue"]:'';
$searchSp = $inputs["searchSp"]?$inputs["searchSp"]:0;
if($searchValue){
$where = " and (A.`name` like '%".$searchValue."%') ";
}
if($searchSp){
$where = " and A.sp_id = $searchSp ";
}
$model = new Model();
//======================
$fields = "count(A.id) count";
//返回列表(limit分页)
if($queryType=="list"){
$where .= $sort." ".$limit;
$fields = " A.`name`,A.addtime,A.updatetime,B.`name` sp_name,case A.`status` when 0 then '<font color=green>正常</font>' when 1 then '<font color=red>禁用</font>' when 2 then '<font color=red>删除</font>' end as `status` ";
}
$sql = "select ".$fields." from sh_sp_playlist A join sh_sp B on A.sp_id = B.id where 1=1 ".$where.";";
// echo $sql;
return $model->query($sql);
}
}
\ No newline at end of file
...@@ -73,7 +73,9 @@ body{padding:20px} ...@@ -73,7 +73,9 @@ body{padding:20px}
<div class="col-sm-3"> <div class="col-sm-3">
<select class="form-control hidden" id="playlist"> <select class="form-control hidden" id="playlist">
<option value="0">请选择播单</option> <option value="0">请选择播单</option>
<option value="1" ids="1,2,3">播单1</option> <volist name="play_lists" id="item">
<option value="{$item.id}" ids="{$item.media_ids}" sp_id="{$item.sp_id}">{$item.name}</option>
</volist>
</select> </select>
</div> </div>
</div> </div>
...@@ -157,6 +159,10 @@ $().ready(function(){ ...@@ -157,6 +159,10 @@ $().ready(function(){
$("select[name='sp']").bind("change",function(){ $("select[name='sp']").bind("change",function(){
var spid = $(this).val(); var spid = $(this).val();
if(spid>0){ if(spid>0){
// $("#playlist option").addClass("hidden");
// $("#playlist option[value='0']").removeClass("hidden");
// $("#playlist option[sp_id='"+spid+"']").removeClass("hidden");
$("#multiselect option").addClass("hidden"); $("#multiselect option").addClass("hidden");
$("#multiselect option[sp_id='"+spid+"']").removeClass("hidden"); $("#multiselect option[sp_id='"+spid+"']").removeClass("hidden");
} }
...@@ -166,6 +172,9 @@ $().ready(function(){ ...@@ -166,6 +172,9 @@ $().ready(function(){
var tmp_val = $(this).val(); var tmp_val = $(this).val();
if(tmp_val=='playlist'){ if(tmp_val=='playlist'){
$("#playlist").removeClass("hidden"); $("#playlist").removeClass("hidden");
// $("#playlist option").addClass("hidden");
// $("#playlist option[value='0']").removeClass("hidden");
// $("#playlist option[sp_id='"+sp_id+"']").removeClass("hidden");
$("#multiselectMedia").empty(); $("#multiselectMedia").empty();
}else if(tmp_val=='cloud'){ }else if(tmp_val=='cloud'){
$("#playlist").addClass("hidden"); $("#playlist").addClass("hidden");
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<form name="searchform" method="post" action="" id ="searchform"> <form name="searchform" method="post" action="" id ="searchform">
<input type="hidden" name="op" value="getjson"> <input type="hidden" name="op" value="getjson">
<div class="inputBox"> <div class="inputBox">
<input class="input" type="text" placeholder="媒资名称/媒资唯一标识" name="searchValue"> <input class="input" type="text" placeholder="任务名称" name="searchValue">
</div> </div>
<input id="submit_search" name="" type="button" value="查询" class="btn_go_s btn_orange" /> <input id="submit_search" name="" type="button" value="查询" class="btn_go_s btn_orange" />
</form> </form>
......
...@@ -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>
......
...@@ -24,16 +24,13 @@ ...@@ -24,16 +24,13 @@
<form name="searchform" method="post" action="" id ="searchform"> <form name="searchform" method="post" action="" id ="searchform">
<input type="hidden" name="op" value="getjson"> <input type="hidden" name="op" value="getjson">
<div class="inputBox"> <div class="inputBox">
<select class="select" name="searchType"> <select class="select" name="searchSp">
<option value="0">合作方</option> <option value="0">合作方</option>
<volist name="sp_lists" id="item"> <volist name="sp_lists" id="item">
<option value="{$item.id}">{$item.name}</option> <option value="{$item.id}">{$item.name}</option>
</volist> </volist>
</select> </select>
<select class="select" name="searchRegion"> <input class="input" type="text" placeholder="播单名称" name="searchValue">
<option value="0">区域</option>
</select>
<input class="input" type="text" placeholder="酒店名称/合作方酒店标识" name="searchValue">
</div> </div>
<input id="submit_search" name="" type="button" value="查询" class="btn_go_s btn_orange" /> <input id="submit_search" name="" type="button" value="查询" class="btn_go_s btn_orange" />
</form> </form>
...@@ -68,11 +65,8 @@ onRowContextMenu : onRowContextMenu ...@@ -68,11 +65,8 @@ onRowContextMenu : onRowContextMenu
"> ">
<thead> <thead>
<tr> <tr>
<th data-options="field:'name',width:30">酒店名称</th> <th data-options="field:'name',width:30">播单名称</th>
<th data-options="field:'sp_name',width:20" sortable="true">合作方</th> <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:'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:'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>
<th data-options="field:'status'" sortable="true" align="center">状态</th> <th data-options="field:'status'" sortable="true" align="center">状态</th>
...@@ -83,14 +77,14 @@ onRowContextMenu : onRowContextMenu ...@@ -83,14 +77,14 @@ onRowContextMenu : onRowContextMenu
<div id="mm1" class="easyui-menu" style="width:120px;display: none"> <div id="mm1" class="easyui-menu" style="width:120px;display: none">
<div iconCls="icon-edit" id="menuEdit" onclick="edit()" {:buttonAuth('Media','Playlist','add')}>编辑</div> <div iconCls="icon-edit" id="menuEdit" onclick="edit()" {:buttonAuth('Media','Playlist','add')}>编辑</div>
<div iconCls="icon-cancel" id="menuDel" onclick="del()" {:buttonAuth('Media','Playlist','deletehandle')}>删除</div> <div iconCls="icon-cancel" id="menuDel" onclick="enable(2)" {:buttonAuth('Media','Playlist','deletehandle')}>删除</div>
<div class="menu-sep"></div> <div class="menu-sep"></div>
<div iconCls="icon-stop" id="menuStop" onclick="enable(1)" {:buttonAuth('Media','Playlist','updateStatusAjaxHandle')}>禁用</div> <div iconCls="icon-stop" id="menuStop" onclick="enable(1)" {:buttonAuth('Media','Playlist','updateStatusAjaxHandle')}>禁用</div>
<div iconCls="icon-start" id="menuStart" onclick="enable(0)" {:buttonAuth('Media','Playlist','updateStatusAjaxHandle')}>启用</div> <div iconCls="icon-start" id="menuStart" onclick="enable(0)" {:buttonAuth('Media','Playlist','updateStatusAjaxHandle')}>启用</div>
</div> </div>
<div id="mm2" class="easyui-menu" style="width:120px;display: none"> <div id="mm2" class="easyui-menu" style="width:120px;display: none">
<div iconCls="icon-edit" id="menuEdit" onclick="edit()" {:buttonAuth('Media','Playlist','add')}>编辑</div> <div iconCls="icon-edit" id="menuEdit" onclick="edit()" {:buttonAuth('Media','Playlist','add')}>编辑</div>
<div iconCls="icon-cancel" id="menuDel" onclick="del()" {:buttonAuth('Media','Playlist','deletehandle')}>删除</div> <div iconCls="icon-cancel" id="menuDel" onclick="enable(2)" {:buttonAuth('Media','Playlist','deletehandle')}>删除</div>
<div class="menu-sep"></div> <div class="menu-sep"></div>
<div iconCls="icon-stop" id="menuStop" onclick="enable(1)" {:buttonAuth('Media','Playlist','updateStatusAjaxHandle')}>禁用</div> <div iconCls="icon-stop" id="menuStop" onclick="enable(1)" {:buttonAuth('Media','Playlist','updateStatusAjaxHandle')}>禁用</div>
<div iconCls="icon-start" id="menuStart" onclick="enable(0)" {:buttonAuth('Media','Playlist','updateStatusAjaxHandle')}>启用</div> <div iconCls="icon-start" id="menuStart" onclick="enable(0)" {:buttonAuth('Media','Playlist','updateStatusAjaxHandle')}>启用</div>
...@@ -131,6 +125,8 @@ function enable(status){ ...@@ -131,6 +125,8 @@ function enable(status){
var msg='启用'; var msg='启用';
if(status==1) if(status==1)
msg='禁用' msg='禁用'
else if(status==2)
msg='删除'
$.messager.confirm('操作确认', '确认['+msg+']该记录?', function(r){ $.messager.confirm('操作确认', '确认['+msg+']该记录?', function(r){
if (r){ if (r){
$.post("/Media/Playlist/updateStatusAjaxHandle/", {id:row.id,status:status}, $.post("/Media/Playlist/updateStatusAjaxHandle/", {id:row.id,status:status},
...@@ -144,12 +140,12 @@ function enable(status){ ...@@ -144,12 +140,12 @@ function enable(status){
} }
} }
function add(){ function add(){
pop(800,450,true,'dg','datagrid','/Media/Playlist/add/') pop('80%',600,true,'dg','datagrid','/Media/Playlist/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','/Media/Playlist/add/id/'+row.id); pop('80%',600,true,'dg','datagrid','/Media/Playlist/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