@@ -35,6 +35,54 @@ class Deposit 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') | |||
->join('hbp_cf_suplier_info d','a.payee_id = d.id','left') | |||
->field("a.*,c.nickname,d.supplier_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 = $list->items(); | |||
foreach ($result as $k=>$item){ | |||
switch ($item["status"]){ | |||
case 1: | |||
$result[$k]["status"]="已付款"; | |||
break; | |||
case 2: | |||
$result[$k]["status"]="回收中"; | |||
break; | |||
case 3: | |||
$result[$k]["status"]="已回收"; | |||
break; | |||
} | |||
} | |||
$result = array("total" => $list->total(), "rows" => $list->items()); | |||
return json($result); | |||
} | |||
return $this->view->fetch(); | |||
} | |||
} |
@@ -3,6 +3,9 @@ | |||
namespace app\admin\controller; | |||
use app\common\controller\Backend; | |||
use think\Db; | |||
use think\exception\PDOException; | |||
use think\exception\ValidateException; | |||
/** | |||
* 收款账单管理 | |||
@@ -35,6 +38,150 @@ class ReceiptOrder 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); | |||
} | |||
$result = $list->items(); | |||
foreach ($result as $k=>$item){ | |||
switch ($item["status"]){ | |||
case 0: | |||
$result[$k]["status"]="未付款"; | |||
break; | |||
case 1: | |||
$result[$k]["status"]="已付款"; | |||
break; | |||
} | |||
} | |||
$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', '')); | |||
} | |||
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("row", $row); | |||
return $this->view->fetch(); | |||
} | |||
} |
@@ -1,39 +1,21 @@ | |||
<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">{:__('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"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value=""> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('收款状态')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-status" data-rule="required" class="form-control" name="row[status]" type="number" value="0"> | |||
{:Form::radios('row[status]', [0=>"未收款",1=>"已收款"],0, ['data-rule'=>'required'])} | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Order_ids')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-order_ids" data-rule="required" data-source="order/index" data-multiple="true" class="form-control selectpage" name="row[order_ids]" type="text" value=""> | |||
<input id="c-order_ids" data-rule="required" class="form-control" name="row[order_ids]" type="text" value=""> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -1,33 +1,15 @@ | |||
<form id="edit-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">{:__('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"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}"> | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> | |||
<label class="control-label col-xs-12 col-sm-2">{:__('收款状态')}:</label> | |||
<div class="col-xs-12 col-sm-8"> | |||
<input id="c-status" data-rule="required" class="form-control" name="row[status]" type="number" value="{$row.status|htmlentities}"> | |||
{:Form::radios('row[status]', [0=>"未收款",1=>"已收款"],$row.status, ['data-rule'=>'required'])} | |||
</div> | |||
</div> | |||
<div class="form-group"> | |||
@@ -29,7 +29,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | |||
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, | |||
{field: 'payee_id', title: __('Payee_id')}, | |||
{field: 'memo', title: __('Memo'), operate: 'LIKE'}, | |||
{field: 'status', title: __('Status')}, | |||
{field: 'status', title: __('押金状态')}, | |||
{field: 'amount', title: __('Amount'), operate:'BETWEEN'}, | |||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | |||
] | |||
@@ -24,14 +24,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | |||
sortName: 'id', | |||
columns: [ | |||
[ | |||
{checkbox: true}, | |||
{field: 'id', title: __('Id')}, | |||
{field: 'del_flag', title: __('Del_flag'), formatter: Table.api.formatter.flag}, | |||
{field: 'nickname', title: __('创建人')}, | |||
{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: 'name', title: __('Name'), operate: 'LIKE'}, | |||
{field: 'status', title: __('Status')}, | |||
{field: 'order_ids', title: __('Order_ids'), operate: 'LIKE'}, | |||
{field: 'status', title: __('收款状态')}, | |||
{field: 'order_ids', title: __('管理的订单id'), operate: 'LIKE'}, | |||
{field: 'money', title: __('Money'), operate:'BETWEEN'}, | |||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | |||
] | |||