1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\admin\controller;
- use think\Db;
- class BhPhRecord extends Auth {
- public function index() {
- if (request()->isAjax()) {
- //分页参数
- $length = input('rows', 10, 'intval'); //每页条数
- $page = input('page', 1, 'intval'); //第几页
- $start = ($page - 1) * $length; //分页开始位置
- //排序
- $sortRow = input('sidx', 'sort', 'trim'); //排序列
- $sort = input('sord', 'asc', 'trim'); //排序方式
- $order = $sortRow . ' ' . $sort . ' ,id desc';
- $title = input('title', '', 'trim');
- if ($title) {
- $map[] = ['d.content', 'like', '%' . $title . '%'];
- }
- $map[] = ['dr.org_id', '=', $this->orgId];
- $map = empty($map) ? true : $map;
- //数据查询
- $lists = Db::name('ph_record')
- ->alias('dr')
- ->field('dr.*')
- ->where($map)
- ->limit($start, $length)
- ->order($order)
- ->select();
- foreach ($lists as $k => $v) {
- $lists[$k]['user_name'] = Db::name('user')
- ->where('id', $v['user_id'])->value('real_name');
- }
- //数据返回
- $totalCount = Db::name('ph_record')
- ->alias('dr')
- ->field('dr.*')
- ->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 details($id) {
- if (!$id) {
- $this->error('参数错误');
- }
- $ret = Db::name('ph_record')->where('id', $id)->find();
- $ret['images'] = !empty($ret['images'])?explode(',',$ret['images']):[];
- $ret['check_json'] = json_decode($ret['check_json'], true);
- $ret['user_name'] = Db::name('user')->where('id', $ret['user_id'])
- ->value('real_name');
- $this->assign('info', $ret);
- $this->assign('meta_title', '陪护检查记录详情');
- return $this->fetch();
- }
- }
|