|
|
@@ -7,14 +7,14 @@ use app\common\controller\Backend;
|
|
|
use app\admin\traits\Actions;
|
|
|
use think\annotation\route\Group;
|
|
|
use think\annotation\route\Route;
|
|
|
+use think\facade\Db;
|
|
|
use app\common\model\MoneyLog as MoneyLogModel;
|
|
|
|
|
|
#[Group("user/money_log")]
|
|
|
class MoneyLog extends Backend
|
|
|
{
|
|
|
use Actions{
|
|
|
- index as private _index;
|
|
|
- del as private _del;
|
|
|
+ edit as private _edit;
|
|
|
multi as private _multi;
|
|
|
import as private _import;
|
|
|
}
|
|
|
@@ -23,46 +23,86 @@ class MoneyLog extends Backend
|
|
|
{
|
|
|
parent::_initialize();
|
|
|
$this->model = new MoneyLogModel();
|
|
|
- $this->assign('typeList', site_config('addonsd.bank_account'));
|
|
|
+ //$this->assign('typeList', site_config('addonsd.money_in_type'));
|
|
|
+ $list = site_config('addonsd.money_out_type');
|
|
|
+ //dump( $list);die;
|
|
|
+ $this->assign('bankList', site_config('addonsd.bank_account'));
|
|
|
$this->relationField=['users'];
|
|
|
}
|
|
|
|
|
|
- //查看
|
|
|
- #[Route("GET,JSON","index")]
|
|
|
+ //查看
|
|
|
+ #[Route('GET,JSON','index')]
|
|
|
public function index()
|
|
|
{
|
|
|
- return $this->_index();
|
|
|
- }
|
|
|
-
|
|
|
- //添加
|
|
|
- #[Route("GET,POST","add")]
|
|
|
- public function add()
|
|
|
- {
|
|
|
- //通过定义postParams来增加或覆盖post提交的表单
|
|
|
- $this->postParams=[];
|
|
|
- //通过定义callback回调函数来执行添加后的操作
|
|
|
- $this->callback=function ($model){};
|
|
|
- return $this->_add();
|
|
|
+ if (false === $this->request->isAjax()) {
|
|
|
+ return $this->fetch();
|
|
|
+ }
|
|
|
+ if($this->request->post('selectpage')){
|
|
|
+ return $this->selectpage();
|
|
|
+ }
|
|
|
+ [$where, $order, $limit, $with] = $this->buildparams();
|
|
|
+ $list = $this->model
|
|
|
+ ->withJoin($with,'left')
|
|
|
+ //如果没有使用operate filter过滤的情况下,推荐使用with关联,可以提高查询效率
|
|
|
+ ->where('money_log.status', 1)
|
|
|
+ ->where($where)
|
|
|
+ ->order($order)
|
|
|
+ ->paginate($limit);
|
|
|
+ $result = ['total' => $list->total(), 'rows' => $list->items()];
|
|
|
+ return json($result);
|
|
|
}
|
|
|
+
|
|
|
|
|
|
//修改
|
|
|
#[Route("GET,POST","edit")]
|
|
|
- public function edit()
|
|
|
+ public function edit()
|
|
|
{
|
|
|
- //通过定义postParams来增加或覆盖post提交的表单
|
|
|
- $this->postParams=[];
|
|
|
- //通过定义callback回调函数来执行修改后的操作
|
|
|
- $this->callback=function ($model){};
|
|
|
+ if(!$this->request->isPost()){
|
|
|
+ $catelist= site_config('addonsd.money_in_type');;
|
|
|
+ $this->assign('parentList',$catelist);
|
|
|
+ }
|
|
|
return $this->_edit();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//删除
|
|
|
#[Route("GET,POST","del")]
|
|
|
public function del()
|
|
|
{
|
|
|
- //通过定义callback回调函数来执行删除后的操作
|
|
|
- $this->callback=function ($ids){};
|
|
|
- return $this->_del();
|
|
|
+ $ids = $this->request->param("ids");
|
|
|
+ if (empty($ids)) {
|
|
|
+ $this->error(__('参数%s不能为空', ['s'=>'ids']));
|
|
|
+ }
|
|
|
+ $pk = $this->model->getPk();
|
|
|
+ $list = $this->model->where($pk, 'in', $ids)->select();
|
|
|
+ $count = 0;
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ foreach ($list as $item) {
|
|
|
+ if(count($this->volidateFields)>0){
|
|
|
+ foreach ($this->volidateFields as $field=>$value){
|
|
|
+ if($item[$field]!=$value){
|
|
|
+ $this->error(__('没有操作权限'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $item->status=0;
|
|
|
+ $count += $item->save();
|
|
|
+ }
|
|
|
+ if($this->callback){
|
|
|
+ $callback=$this->callback;
|
|
|
+ $callback($ids);
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Db::rollback();
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if ($count) {
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+ $this->error(__('没有记录被删除'));
|
|
|
}
|
|
|
|
|
|
//更新
|