娄梦宁 3 years ago
parent
commit
7a4f289574
6 changed files with 226 additions and 129 deletions
  1. +191
    -1
      application/admin/controller/CfItem.php
  2. +16
    -1
      application/admin/controller/CfRoomPlan.php
  3. +4
    -4
      application/admin/controller/ReceiptOrder.php
  4. +6
    -57
      application/admin/view/cf_item/add.html
  5. +6
    -57
      application/admin/view/cf_item/edit.html
  6. +3
    -9
      public/assets/js/backend/cf_item.js

+ 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;
}
}


+ 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">


+ 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