@@ -186,4 +186,20 @@ class CfRoomInfo extends Backend | |||
return json(['list' => $result]); | |||
} | |||
public function getList(){ | |||
$name=$this->request->post('name'); | |||
$keyValue=$this->request->post('keyValue'); | |||
$this->model->field('id,room_name as name'); | |||
if($keyValue){ | |||
$this->model->where(['id'=>$keyValue]); | |||
}elseif($name){ | |||
$this->model->where(['room_name'=>['like','%'.$name.'%']]); | |||
} | |||
$result= $this->model->select(); | |||
if($keyValue){ | |||
return json(['list' => $result]); | |||
} | |||
return json(['list' => $result]); | |||
} | |||
} |
@@ -2,7 +2,11 @@ | |||
namespace app\admin\controller; | |||
use app\admin\model\Area; | |||
use app\common\controller\Backend; | |||
use think\Db; | |||
use think\exception\PDOException; | |||
use think\exception\ValidateException; | |||
/** | |||
* 配置-房型方案 | |||
@@ -18,6 +22,13 @@ class CfRoomPlan extends Backend | |||
*/ | |||
protected $model = null; | |||
private $continuity_type=[ | |||
0=>"无限制", | |||
1=>"连住几晚", | |||
2=>"连住几晚及以上", | |||
3=>"连住几晚及其倍数" | |||
]; | |||
public function _initialize() | |||
{ | |||
parent::_initialize(); | |||
@@ -52,4 +63,145 @@ class CfRoomPlan extends Backend | |||
} | |||
return json(['list' => $result]); | |||
} | |||
/** | |||
* 查看 | |||
*/ | |||
public function index() | |||
{ | |||
//设置过滤方法 | |||
$this->request->filter(['strip_tags', 'trim']); | |||
if ($this->request->isAjax()) { | |||
//如果发送的来源是Selectpage,则转发到Selectpage | |||
if ($this->request->request('keyField')) { | |||
return $this->selectpage(); | |||
} | |||
list($where, $sort, $order, $offset, $limit) = $this->buildparams(); | |||
$group_id=$this->auth->getGroupId(); | |||
$list = $this->model | |||
->alias("a") | |||
->join('hbp_admin c','a.create_id = c.id','left') | |||
->join('hbp_admin d','a.charge_person = d.id','left') | |||
->join('hbp_cf_room_info e','a.room_id = e.id','left') | |||
->join('hbp_cf_hotel_info f','a.hotel_id = f.id','left') | |||
->field("a.*,c.nickname,d.nickname as charge_person_name,e.room_name,f.hotel_name") | |||
->where($where); | |||
if ($group_id){ | |||
$list = $list | |||
->where("group_id","=",$group_id) | |||
->order($sort, $order) | |||
->paginate($limit); | |||
}else{ | |||
$list = $list | |||
->order($sort, $order) | |||
->paginate($limit); | |||
} | |||
$result = array("total" => $list->total(), "rows" => $list->items()); | |||
return json($result); | |||
} | |||
return $this->view->fetch(); | |||
} | |||
/** | |||
* 添加 | |||
*/ | |||
public function add() | |||
{ | |||
if ($this->request->isPost()) { | |||
$params = $this->request->post("row/a"); | |||
if ($params) { | |||
$params = $this->preExcludeFields($params); | |||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | |||
$params[$this->dataLimitField] = $this->auth->id; | |||
} | |||
$result = false; | |||
Db::startTrans(); | |||
try { | |||
//是否采用模型验证 | |||
if ($this->modelValidate) { | |||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | |||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; | |||
$this->model->validateFailException(true)->validate($validate); | |||
} | |||
$params['create_id']=$this->auth->id; | |||
$params['group_id']=$this->auth->getGroupId(); | |||
$result = $this->model->allowField(true)->save($params); | |||
Db::commit(); | |||
} catch (ValidateException $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} catch (PDOException $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} catch (Exception $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} | |||
if ($result !== false) { | |||
$this->success(); | |||
} else { | |||
$this->error(__('No rows were inserted')); | |||
} | |||
} | |||
$this->error(__('Parameter %s can not be empty', '')); | |||
} | |||
$this->view->assign("continuity_type", $this->continuity_type); | |||
return $this->view->fetch(); | |||
} | |||
/** | |||
* 编辑 | |||
*/ | |||
public function edit($ids = null) | |||
{ | |||
$row = $this->model->get($ids); | |||
if (!$row) { | |||
$this->error(__('No Results were found')); | |||
} | |||
$adminIds = $this->getDataLimitAdminIds(); | |||
if (is_array($adminIds)) { | |||
if (!in_array($row[$this->dataLimitField], $adminIds)) { | |||
$this->error(__('You have no permission')); | |||
} | |||
} | |||
if ($this->request->isPost()) { | |||
$params = $this->request->post("row/a"); | |||
if ($params) { | |||
$params = $this->preExcludeFields($params); | |||
$result = false; | |||
Db::startTrans(); | |||
try { | |||
//是否采用模型验证 | |||
if ($this->modelValidate) { | |||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | |||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; | |||
$row->validateFailException(true)->validate($validate); | |||
} | |||
$result = $row->allowField(true)->save($params); | |||
Db::commit(); | |||
} catch (ValidateException $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} catch (PDOException $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} catch (Exception $e) { | |||
Db::rollback(); | |||
$this->error($e->getMessage()); | |||
} | |||
if ($result !== false) { | |||
$this->success(); | |||
} else { | |||
$this->error(__('No rows were updated')); | |||
} | |||
} | |||
$this->error(__('Parameter %s can not be empty', '')); | |||
} | |||
$this->view->assign("continuity_type", $this->continuity_type); | |||
$this->view->assign("row", $row); | |||
return $this->view->fetch(); | |||
} | |||
} |
@@ -304,4 +304,19 @@ class Config extends Backend | |||
$config = \think\Config::get($key); | |||
return json(['data' => json_decode($config)]); | |||
} | |||
public function getList(){ | |||
$key= $this->request->request('key'); | |||
$config = \think\Config::get($key); | |||
$result = json_decode($config,true); | |||
foreach ($result as $key=>$value){ | |||
$res[]=[ | |||
"id"=>$key, | |||
"name"=>$value | |||
]; | |||
} | |||
return json(['list' => $res]); | |||
} | |||
} |
@@ -6,9 +6,9 @@ return [ | |||
'Room_id' => '房型ID', | |||
'Plan_name' => '价格方案名称', | |||
'Breakfast_num' => '早餐数量', | |||
'Book_end_day' => '提前几天预定', | |||
'Book_end_hour' => '提前多少天的几点前预定', | |||
'Continuity_type' => '连续入住类型 0无限制 1连住几晚 2连住几晚及以上 3连住几晚及其倍数', | |||
'Book_end_day' => '提前预定天数', | |||
'Book_end_hour' => '提前预定点数', | |||
'Continuity_type' => '连续入住类型', | |||
'Coutinuity_day' => '连续入住天数', | |||
'Plan_memo' => '方案说明', | |||
'Plan_log' => '日志', | |||
@@ -1,9 +1,15 @@ | |||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | |||
<!-- <div class="form-group">--> | |||
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('Item_type')}:</label>--> | |||
<!-- <div class="col-xs-12 col-sm-8">--> | |||
<!-- <input id="c-item_type" data-rule="required" class="form-control" name="row[item_type]" type="number" value="0">--> | |||
<!-- </div>--> | |||
<!-- </div>--> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Item_type')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-item_type" data-rule="required" class="form-control" name="row[item_type]" type="number" value="0"> | |||
<input id="c-item_type" data-rule="required" data-source="general/config/getList?key=site.item_category" class="form-control selectpage" name="row[item_type]" type="text" value=""> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -3,7 +3,8 @@ | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Item_type')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-item_type" data-rule="required" class="form-control" name="row[item_type]" type="number" value="{$row.item_type|htmlentities}"> | |||
<input id="c-item_type" data-rule="required" data-source="general/config/getList?key=site.item_category" class="form-control selectpage" name="row[item_type]" type="text" value="{$row.item_type|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -3,13 +3,14 @@ | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Hotel_id')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-hotel_id" data-rule="required" data-source="hotel/index" class="form-control selectpage" name="row[hotel_id]" type="text" value=""> | |||
<input id="c-hotel_id" data-rule="required" data-source="cf_hotel_info/getHotelList" class="form-control selectpage" name="row[hotel_id]" type="text" value=""> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Room_id')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-room_id" data-rule="required" data-source="room/index" class="form-control selectpage" name="row[room_id]" type="text" value=""> | |||
<input id="c-room_id" data-rule="required" data-source="cf_room_info/getList" class="form-control selectpage" name="row[room_id]" type="text" value=""> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -39,7 +40,7 @@ | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Continuity_type')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-continuity_type" data-rule="required" class="form-control" name="row[continuity_type]" type="number" value="0"> | |||
{:Form::radios('row[continuity_type]', $continuity_type,0 , ['data-rule'=>'required'])} | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -55,35 +56,12 @@ | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Plan_log')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-plan_log" data-rule="required" class="form-control" name="row[plan_log]" type="text" value=""> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Charge_person')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-charge_person" data-rule="required" class="form-control" name="row[charge_person]" type="text" value=""> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Del_flag')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-del_flag" data-rule="required" class="form-control" name="row[del_flag]" type="number" value="0"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-create_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:date('Y-m-d H:i:s')}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Update_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-update_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[update_time]" type="text" value="{:date('Y-m-d H:i:s')}"> | |||
<input id="c-charge_person" data-rule="required" data-source="auth/admin/getList" class="form-control selectpage" name="row[charge_person]" type="text" value=""> | |||
</div> | |||
</div> | |||
<div class="form-group layer-footer"> | |||
<label class="control-label col-xs-12 col-sm-2"></label> | |||
<div class="col-xs-12 col-sm-8"> | |||
@@ -3,13 +3,13 @@ | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Hotel_id')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-hotel_id" data-rule="required" data-source="hotel/index" class="form-control selectpage" name="row[hotel_id]" type="text" value="{$row.hotel_id|htmlentities}"> | |||
<input id="c-hotel_id" data-rule="required" data-source="cf_hotel_info/getHotelList" class="form-control selectpage" name="row[hotel_id]" type="text" value="{$row.hotel_id|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Room_id')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-room_id" data-rule="required" data-source="room/index" class="form-control selectpage" name="row[room_id]" type="text" value="{$row.room_id|htmlentities}"> | |||
<input id="c-room_id" data-rule="required" data-source="cf_room_info/getList" class="form-control selectpage" name="row[room_id]" type="text" value="{$row.room_id|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -39,7 +39,7 @@ | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Continuity_type')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-continuity_type" data-rule="required" class="form-control" name="row[continuity_type]" type="number" value="{$row.continuity_type|htmlentities}"> | |||
{:Form::radios('row[continuity_type]', $continuity_type, $row.continuity_type, ['data-rule'=>'required'])} | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -55,33 +55,9 @@ | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Plan_log')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-plan_log" data-rule="required" class="form-control" name="row[plan_log]" type="text" value="{$row.plan_log|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Charge_person')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-charge_person" data-rule="required" class="form-control" name="row[charge_person]" type="text" value="{$row.charge_person|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Del_flag')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-del_flag" data-rule="required" class="form-control" name="row[del_flag]" type="number" value="{$row.del_flag|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-create_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:$row.create_time?datetime($row.create_time):''}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Update_time')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-update_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[update_time]" type="text" value="{:$row.update_time?datetime($row.update_time):''}"> | |||
<input id="c-charge_person" data-rule="required" data-source="auth/admin/getList" class="form-control selectpage" name="row[charge_person]" type="text" value="{$row.charge_person|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group layer-footer"> | |||
@@ -24,20 +24,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | |||
sortName: 'id', | |||
columns: [ | |||
[ | |||
{checkbox: true}, | |||
{field: 'id', title: __('Id')}, | |||
{field: 'hotel_id', title: __('Hotel_id')}, | |||
{field: 'room_id', title: __('Room_id')}, | |||
{field: 'hotel_name', title: __('酒店')}, | |||
{field: 'room_name', title: __('房型')}, | |||
{field: 'plan_name', title: __('Plan_name'), operate: 'LIKE'}, | |||
{field: 'breakfast_num', title: __('Breakfast_num')}, | |||
{field: 'book_end_day', title: __('Book_end_day')}, | |||
{field: 'book_end_hour', title: __('Book_end_hour')}, | |||
{field: 'continuity_type', title: __('Continuity_type')}, | |||
{field: 'coutinuity_day', title: __('Coutinuity_day')}, | |||
{field: 'plan_memo', title: __('Plan_memo'), operate: 'LIKE'}, | |||
{field: 'plan_log', title: __('Plan_log'), operate: 'LIKE'}, | |||
{field: 'charge_person', title: __('Charge_person'), operate: 'LIKE'}, | |||
{field: 'del_flag', title: __('Del_flag'), formatter: Table.api.formatter.flag}, | |||
{field: 'charge_person_name', title: __('Charge_person'), operate: 'LIKE'}, | |||
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | |||
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | |||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | |||