Account.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace app\admin\controller\qingdongams\finance;
  3. use app\admin\controller\qingdongams\Base;
  4. use addons\qingdongams\model\Account as AccountModel;
  5. /**
  6. * 审批管理
  7. * @icon fa fa-user
  8. */
  9. class Account extends Base {
  10. protected $relationSearch = true;
  11. /**
  12. * @var \addons\qingdongams\model\Account
  13. */
  14. protected $model = null;
  15. public function _initialize() {
  16. parent::_initialize();
  17. $this->model = new AccountModel();
  18. }
  19. /**
  20. * 查看
  21. */
  22. public function index() {
  23. //设置过滤方法
  24. $this->request->filter(['strip_tags', 'trim']);
  25. if ($this->request->isAjax()) {
  26. //如果发送的来源是Selectpage,则转发到Selectpage
  27. if ($this->request->request('keyField')) {
  28. return $this->selectpage();
  29. }
  30. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  31. $list = $this->model->where($where)->where([])->order('id desc')->paginate($limit);
  32. $result = array("total" => $list->total(), "rows" => $list->items());
  33. return json($result);
  34. }
  35. return $this->view->fetch();
  36. }
  37. //添加
  38. public function add() {
  39. if ($this->request->isAjax()) {
  40. $data = $this->request->post('row/a');
  41. $result = $this->model->save($data);
  42. if (!$result) {
  43. $this->error('提交失败');
  44. }
  45. $this->success('提交成功');
  46. }
  47. return $this->view->fetch();
  48. }
  49. //修改
  50. public function edit($ids = null) {
  51. $map['id'] = $ids;
  52. if ($this->request->isAjax()) {
  53. $data = $this->request->post('row/a');
  54. $result = $this->model->save($data, $map);
  55. if (!$result) {
  56. $this->error('修改失败');
  57. }
  58. $this->success('修改成功');
  59. }
  60. $data = AccountModel::where($map)->find();
  61. $this->view->assign("row", $data);
  62. return $this->view->fetch();
  63. }
  64. }