nizongfeng 3 years ago
parent
commit
12214f9543
10 changed files with 267 additions and 144 deletions
  1. +1
    -1
      application/admin/controller/CfChannelInfo.php
  2. +191
    -1
      application/admin/controller/CfItem.php
  3. +16
    -1
      application/admin/controller/CfRoomPlan.php
  4. +4
    -4
      application/admin/controller/ReceiptOrder.php
  5. +18
    -0
      application/admin/controller/auth/Admin.php
  6. +6
    -0
      application/admin/controller/general/Config.php
  7. +6
    -57
      application/admin/view/cf_item/add.html
  8. +6
    -57
      application/admin/view/cf_item/edit.html
  9. +16
    -14
      application/extra/site.php
  10. +3
    -9
      public/assets/js/backend/cf_item.js

+ 1
- 1
application/admin/controller/CfChannelInfo.php View File

@@ -67,7 +67,7 @@ class CfChannelInfo extends Backend
public function getList(){
$name=$this->request->post('name');
$keyValue=$this->request->post('keyValue');
$this->model->field('id,channel_name as name');
$this->model->field('id,channel_name as name,commission_rate');
if($keyValue){
$this->model->where(['id'=>$keyValue]);
}elseif($name){


+ 191
- 1
application/admin/controller/CfItem.php View File

@@ -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;

/**
* 配置-附加项目
@@ -35,6 +39,192 @@ class CfItem extends Backend
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
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')
->field("a.*,c.nickname")
->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);
}

$config = \think\Config::get("site.item_category");
$config = json_decode($config,true);
$res = $list->items();
foreach ($res as $key=>$val){
$res[$key]["item_type_name"]=$config[$val["item_type"]];
}
$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);
}
$area=new Area();
if ($params["area"]){
$params["area_name"]=$area->where("id","=",$params["area"])->value("name");
}
if ($params["province"]){
$params["province_name"]=$area->where("id","=",$params["province"])->value("name");
}
if ($params["city"]){
$params["city_name"]=$area->where("id","=",$params["city"])->value("name");
}
$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', ''));
}
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);
}
$area=new Area();
if ($params["area"]){
$params["area_name"]=$area->where("id","=",$params["area"])->value("name");
}
if ($params["province"]){
$params["province_name"]=$area->where("id","=",$params["province"])->value("name");
}
if ($params["city"]){
$params["city_name"]=$area->where("id","=",$params["city"])->value("name");
}
$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("row", $row);
return $this->view->fetch();
}


public function getList(){
$name=$this->request->post('name');
$keyValue=$this->request->post('keyValue');
$this->model->field('id,item_name as name,item_unit,item_type,item_memo');
if($keyValue){
$this->model->where(['id'=>$keyValue]);
}elseif($name){
$this->model->where(['item_name'=>['like','%'.$name.'%']]);
}
$result= $this->model->select()->toArray();

$config = \think\Config::get("site.item_category");
$config = json_decode($config,true);
foreach ($result as $key=>$value){
$result[$key]["item_type_name"]= $config[$value["item_type"]];
}
if($keyValue){
return json(['list' => $result]);
}
return json(['list' => $result]);
}

}

+ 16
- 1
application/admin/controller/CfRoomPlan.php View File

@@ -35,6 +35,21 @@ class CfRoomPlan extends Backend
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/


public function getList(){
$name=$this->request->post('name');
$keyValue=$this->request->post('keyValue');
$this->model->field('id,plan_name as name');
if($keyValue){
$this->model->where(['id'=>$keyValue]);
}elseif($name){
$this->model->where(['plan_name'=>['like','%'.$name.'%']]);
}
$result= $this->model->select();
if($keyValue){
return json(['list' => $result]);
}
return json(['list' => $result]);
}
}

+ 4
- 4
application/admin/controller/ReceiptOrder.php View File

@@ -69,14 +69,14 @@ class ReceiptOrder extends Backend
->order($sort, $order)
->paginate($limit);
}
$result = $list->items();
foreach ($result as $k=>$item){
$res = $list->items();
foreach ($res as $k=>$item){
switch ($item["status"]){
case 0:
$result[$k]["status"]="未付款";
$res[$k]["status"]="未付款";
break;
case 1:
$result[$k]["status"]="已付款";
$res[$k]["status"]="已付款";
break;
}
}


+ 18
- 0
application/admin/controller/auth/Admin.php View File

@@ -293,4 +293,22 @@ class Admin extends Backend
$this->dataLimitField = 'id';
return parent::selectpage();
}


public function getList(){
$name=$this->request->post('name');
$keyValue=$this->request->post('keyValue');
$this->model->field('id,nickname as name');
if($keyValue){
$this->model->where(['id'=>$keyValue]);
}elseif($name){
$this->model->where(['nickname'=>['like','%'.$name.'%']]);
}
$result= $this->model->select();
// print_r($result);
if($keyValue){
return json(['list' => $result]);
}
return json(['list' => $result]);
}
}

+ 6
- 0
application/admin/controller/general/Config.php View File

@@ -298,4 +298,10 @@ class Config extends Backend
$fieldList = Db::query($sql, [$dbname, $table]);
$this->success("", null, ['fieldList' => $fieldList]);
}

public function getConfig(){
$key= $this->request->request('key');
$config = \think\Config::get($key);
return json(['data' => json_decode($config)]);
}
}

+ 6
- 57
application/admin/view/cf_item/add.html View File

@@ -24,46 +24,12 @@
<input id="c-item_memo" data-rule="required" class="form-control" name="row[item_memo]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Item_log')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-item_log" data-rule="required" class="form-control" name="row[item_log]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Country_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-country_id" data-rule="required" data-source="country/index" class="form-control selectpage" name="row[country_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Country_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-country_name" data-rule="required" class="form-control" name="row[country_name]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Province_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-province_id" data-rule="required" data-source="province/index" class="form-control selectpage" name="row[province_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Province_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-province_name" data-rule="required" class="form-control" name="row[province_name]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('City_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-city_id" data-rule="required" data-source="city/index" class="form-control selectpage" name="row[city_id]" type="text" value="">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('City_name')}:</label>
<div class="form-group" data-toggle="cxselect" data-selects="province,city,area">
<label class="control-label col-xs-12 col-sm-2">{:__('所在区域')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-city_name" data-rule="required" class="form-control" name="row[city_name]" type="text" value="">
<select class="province" name="row[province]" data-url="ajax/area"></select>
<select class="city" name="row[city]" data-url="ajax/area"></select>
<select class="area" name="row[area]" data-url="ajax/area"></select>
</div>
</div>
<div class="form-group">
@@ -72,24 +38,7 @@
<input id="c-detail_address" data-rule="required" class="form-control" name="row[detail_address]" 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')}">
</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">


+ 6
- 57
application/admin/view/cf_item/edit.html View File

@@ -24,72 +24,21 @@
<input id="c-item_memo" data-rule="required" class="form-control" name="row[item_memo]" type="text" value="{$row.item_memo|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Item_log')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-item_log" data-rule="required" class="form-control" name="row[item_log]" type="text" value="{$row.item_log|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Country_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-country_id" data-rule="required" data-source="country/index" class="form-control selectpage" name="row[country_id]" type="text" value="{$row.country_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Country_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-country_name" data-rule="required" class="form-control" name="row[country_name]" type="text" value="{$row.country_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Province_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-province_id" data-rule="required" data-source="province/index" class="form-control selectpage" name="row[province_id]" type="text" value="{$row.province_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Province_name')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-province_name" data-rule="required" class="form-control" name="row[province_name]" type="text" value="{$row.province_name|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('City_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-city_id" data-rule="required" data-source="city/index" class="form-control selectpage" name="row[city_id]" type="text" value="{$row.city_id|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('City_name')}:</label>
<div class="form-group" data-toggle="cxselect" data-selects="province,city,area">
<label class="control-label col-xs-12 col-sm-2">{:__('所在区域')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-city_name" data-rule="required" class="form-control" name="row[city_name]" type="text" value="{$row.city_name|htmlentities}">
<select class="province" name="row[province]" data-value="{$row.province|htmlentities}" data-url="ajax/area"></select>
<select class="city" name="row[city]" data-value="{$row.city|htmlentities}" data-url="ajax/area"></select>
<select class="area" name="row[area]" data-value="{$row.area|htmlentities}" data-url="ajax/area"></select>
</div>
</div>

<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Detail_address')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-detail_address" data-rule="required" class="form-control" name="row[detail_address]" type="text" value="{$row.detail_address|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):''}">
</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">


+ 16
- 14
application/extra/site.php View File

@@ -15,24 +15,19 @@ return array (
'fixedpage' => 'dashboard',
'categorytype' =>
array (
'default' => 'Default',
'page' => 'Page',
'article' => 'Article',
'default' => '默认',
'page' => '单页',
'article' => '文章',
'test' => 'Test',
),
'configgroup' =>
array (
'basic' => 'Basic',
'email' => 'Email',
'dictionary' => 'Dictionary',
'user' => 'User',
'example' => 'Example',
),
'attachmentcategory' =>
array (
'category1' => 'Category1',
'category2' => 'Category2',
'custom' => 'Custom',
'basic' => '基础配置',
'email' => '邮件配置',
'dictionary' => '字典配置',
'user' => '会员配置',
'example' => '示例分组',
'hotel' => '酒店信息配置',
),
'mail_type' => '1',
'mail_smtp_host' => 'smtp.qq.com',
@@ -41,4 +36,11 @@ return array (
'mail_smtp_pass' => 'password',
'mail_verify_type' => '2',
'mail_from' => '10000@qq.com',
'attachmentcategory' =>
array (
'category1' => '分类一',
'category2' => '分类二',
'custom' => '自定义',
),
'item_category' => '{"1":"一日游","2":"交通接驳","3":"租车","4":"门票"}',
);

+ 3
- 9
public/assets/js/backend/cf_item.js View File

@@ -24,21 +24,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'item_type', title: __('Item_type')},
{field: 'item_type_name', title: __('Item_type')},
{field: 'item_name', title: __('Item_name'), operate: 'LIKE'},
{field: 'item_unit', title: __('Item_unit'), operate: 'LIKE'},
{field: 'item_unit', title: __('计价单位'), operate: 'LIKE'},
{field: 'item_memo', title: __('Item_memo'), operate: 'LIKE'},
{field: 'item_log', title: __('Item_log'), operate: 'LIKE'},
{field: 'country_id', title: __('Country_id')},
{field: 'country_name', title: __('Country_name'), operate: 'LIKE'},
{field: 'province_id', title: __('Province_id')},
{field: 'province_name', title: __('Province_name'), operate: 'LIKE'},
{field: 'city_id', title: __('City_id')},
{field: 'city_name', title: __('City_name'), operate: 'LIKE'},
{field: 'area_name', title: __('地区名'), operate: 'LIKE'},
{field: 'detail_address', title: __('Detail_address'), operate: 'LIKE'},
{field: 'del_flag', title: __('Del_flag'), formatter: Table.api.formatter.flag},
{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}


Loading…
Cancel
Save