123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace app\admin\controller;
- use app\common\model\MateGoodsLog;
- use think\App;
- use think\Db;
- use think\Exception;
- class MateApply extends Auth
- {
- public function __construct(App $app = null) {
- parent::__construct($app);
- $this->model = new \app\common\model\MateApply();
- $this->table = 'mate_apply';
- }
-
- public function back(){
- if(request()->isAjax()){
-
- $length = input('rows',10,'intval');
- $page = input('page',1,'intval');
- $start = ($page - 1) * $length;
-
- $sortRow = input('sidx','id','trim');
- $sort = input('sord','desc','trim');
- $order = $sortRow.' '.$sort;
- $title = input('title','','trim');
- if($title){
- $map[] = ['sn','like','%'.$title.'%'];
- }
- $enable = input('enable','','trim');
- if($enable != ''){
- $map[] = ['enable','=',$enable];
- }
- $map[] = ['org_id','=',$this->orgId];
- $map[] = ['type','=',2];
- $map= empty($map) ? true: $map;
-
- $lists =db($this->table)
- ->where($map)->limit($start,$length)
- ->order($order)->select();
- foreach ($lists as $k=>$v){
- $lists[$k]['userName'] = db('user')
- ->where('id',$v['user_id'])
- ->value('real_name');
- }
-
- $totalCount = db($this->table)->where($map)->count();
- $totalPage = ceil($totalCount/$length);
- $result['page'] = $page;
- $result['total'] = $totalPage;
- $result['records'] = $totalCount;
- $result['rows'] = $lists;
- return json($result);
- }else{
- $this->assign('meta_title','出库记录');
- return $this->fetch();
- }
- }
-
- public function add(){
- if(request()->isPost()){
- $res = $this->model->updates($this->userId);
- if($res){
- $this->success('操作成功',url('back'));
- }else{
- $this->error($this->model->getError());
- }
- }else{
- $meta_title = '新增出库';
- $this->assign('meta_title',$meta_title);
- return $this->fetch();
- }
- }
-
- public function detail($id){
- $info = (new \app\common\model\MateApply())->getInfo($id);
- if(!$info) $this->error('记录不存在');
- $this->assign('info',$info);
- return $this->fetch();
- }
- }
|