正在显示
3 个修改的文件
包含
57 行增加
和
191 行删除
@@ -29,99 +29,30 @@ use think\Db; | @@ -29,99 +29,30 @@ use think\Db; | ||
29 | class AdminFaultController extends AdminBaseController{ | 29 | class AdminFaultController extends AdminBaseController{ |
30 | 30 | ||
31 | public function index(){ | 31 | public function index(){ |
32 | - $param=$this->request->param(); | ||
33 | - $where=array(); | ||
34 | - if (!empty($param['fault_type'])){ | ||
35 | - $where['fault_type']=$param['fault_type']; | ||
36 | - } | ||
37 | - $data=Db::name('fault') | ||
38 | - ->alias('a') | ||
39 | - ->field('a.*,b.serial_number,b.hospital') | 32 | + $Order=new OrderModel(); |
33 | + $data=$Order->alias('a') | ||
34 | + ->field('a.*,count(a.eq_name) as num,sum(a.time) as sumTime') | ||
40 | ->join('equipment b','a.eq_name=b.name') | 35 | ->join('equipment b','a.eq_name=b.name') |
41 | - ->where($where) | ||
42 | - ->order('a.state','ase') | ||
43 | - ->order('a.create_time','desc') | ||
44 | - ->paginate(10); | ||
45 | - | 36 | + ->group('a.eq_name') |
37 | + ->order('start_time','desc') | ||
38 | + ->paginate(10)->each(function ($item){ | ||
39 | + $item['average']=round($item['sumTime']/$item['num']); | ||
40 | + //计费故障次数 | ||
41 | + $item['fault_time']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>1])->count(); | ||
42 | + //锁故障次数 | ||
43 | + $item['fault_lock']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>5])->count(); | ||
44 | + //床故障次数 | ||
45 | + $item['fault_bed']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>['in',[2,3,4]]])->count(); | ||
46 | + //其他故障次数 | ||
47 | + $item['fault_other']=Db::name('fault')->where(['eq_name'=>$item['eq_name'],'fault_type'=>6])->count(); | ||
48 | + //故障总数 | ||
49 | + $item['fault']=Db::name('fault')->where(['eq_name'=>$item['eq_name']])->count(); | ||
50 | + return $item; | ||
51 | + }); | ||
46 | $this->assign('data',$data); | 52 | $this->assign('data',$data); |
47 | - $this->assign('fault_type', isset($param['fault_type']) ? $param['fault_type'] : ''); | ||
48 | return $this->fetch(); | 53 | return $this->fetch(); |
49 | } | 54 | } |
50 | 55 | ||
51 | - //保修 | ||
52 | - public function warranty(){ | ||
53 | - $id=$this->request->param('id'); | ||
54 | - | ||
55 | - $fault=Db::name('fault')->where('id',$id)->find(); | ||
56 | - | ||
57 | - try{ | ||
58 | - Db::startTrans(); | ||
59 | - Db::name('equipment')->where('name',$fault['eq_name'])->update(['state'=>2]); | ||
60 | - Db::name('fault')->where('id',$id)->update(['state'=>2]); | ||
61 | - }catch (\Exception $exception){ | ||
62 | - Db::rollback(); | ||
63 | - $this->error('错误:'.$exception->getMessage()); | ||
64 | - } | ||
65 | - Db::commit(); | ||
66 | - $this->success('处理完成'); | ||
67 | - | ||
68 | - } | ||
69 | - | ||
70 | - //恢复设备 | ||
71 | - public function reply(){ | ||
72 | - $id=$this->request->param('id'); | ||
73 | - | ||
74 | - $fault=Db::name('fault')->where('id',$id)->find(); | ||
75 | - | ||
76 | - try{ | ||
77 | - Db::startTrans(); | ||
78 | - Db::name('equipment')->where('name',$fault['eq_name'])->update(['state'=>1]); | ||
79 | - Db::name('fault')->where('id',$id)->update(['state'=>3]); | ||
80 | - }catch (\Exception $exception){ | ||
81 | - Db::rollback(); | ||
82 | - $this->error('错误:'.$exception->getMessage()); | ||
83 | - } | ||
84 | - Db::commit(); | ||
85 | - $this->success('处理完成'); | ||
86 | - | ||
87 | - } | ||
88 | - | ||
89 | - | ||
90 | - //结束计费 | ||
91 | - public function bill_error(){ | ||
92 | - $id=$this->request->param('id'); | ||
93 | - | ||
94 | - $fault=Db::name('fault')->where('id',$id)->find(); | ||
95 | - | ||
96 | - $order=Db::name('order')->where(['users_id'=>$fault['users_id'],'state'=>1])->find(); | ||
97 | - if (empty($order)){ | ||
98 | - $this->error('没有未完成订单'); | ||
99 | - }else{ | ||
100 | - $time=ceil(($fault['create_time']-$order['start_time'])/3600); | ||
101 | - $getPrice=new OrderController(); | ||
102 | - $price=$getPrice->getPrice($fault['users_id'],$order['start_time'],$fault['create_time']); | ||
103 | - $data=[ | ||
104 | - 'end_time'=>$fault['create_time'], | ||
105 | - 'time'=>$time, | ||
106 | - 'price'=>$price, | ||
107 | - 'state'=>2 | ||
108 | - ]; | ||
109 | - try{ | ||
110 | - Db::startTrans(); | ||
111 | - Db::name('users')->where('id',$fault['users_id'])->update(['is_use'=>0]); | ||
112 | - Db::name('equipment')->where('name',$fault['eq_name'])->update(['use'=>0]); | ||
113 | - Db::name('order')->where('id',$order['id'])->update($data); | ||
114 | - Db::name('fault')->where('id',$id)->update(['state'=>3]); | ||
115 | - }catch (\Exception $exception){ | ||
116 | - Db::rollback(); | ||
117 | - $this->error('错误:'.$exception->getMessage()); | ||
118 | - } | ||
119 | - Db::commit(); | ||
120 | - $this->success('处理完成'); | ||
121 | - } | ||
122 | - } | ||
123 | - | ||
124 | - | ||
125 | 56 | ||
126 | 57 | ||
127 | 58 |
@@ -3,119 +3,59 @@ | @@ -3,119 +3,59 @@ | ||
3 | <body> | 3 | <body> |
4 | <div class="wrap js-check-wrap"> | 4 | <div class="wrap js-check-wrap"> |
5 | <ul class="nav nav-tabs"> | 5 | <ul class="nav nav-tabs"> |
6 | - <li class="active"><a href="javascript:;">故障列表</a></li> | 6 | + <li class="active"><a href="javascript:;">整体统计</a></li> |
7 | </ul> | 7 | </ul> |
8 | <form class="well form-inline margin-top-20" method="post" action="{:url('AdminFault/index')}"> | 8 | <form class="well form-inline margin-top-20" method="post" action="{:url('AdminFault/index')}"> |
9 | - 故障分类: | ||
10 | - <select class="form-control" name="fault_type" style="width: 140px;"> | 9 | + 分类: |
10 | + <select class="form-control" name="category" style="width: 140px;"> | ||
11 | <option value='0'>全部</option> | 11 | <option value='0'>全部</option> |
12 | - <option value='1' <if condition="$fault_type eq 1">selected </if>>计费</option> | ||
13 | - <option value='2' <if condition="$fault_type eq 2">selected </if>>床体</option> | ||
14 | - <option value='3' <if condition="$fault_type eq 3">selected </if>>床锁</option> | ||
15 | - <option value='4' <if condition="$fault_type eq 4">selected </if>>其他</option> | 12 | + {$category_tree|default=''} |
16 | </select> | 13 | </select> |
14 | + 时间: | ||
15 | + <input type="text" class="form-control js-bootstrap-datetime" name="start_time" | ||
16 | + value="{$start_time|default=''}" | ||
17 | + style="width: 140px;" autocomplete="off">- | ||
18 | + <input type="text" class="form-control js-bootstrap-datetime" name="end_time" | ||
19 | + value="{$end_time|default=''}" | ||
20 | + style="width: 140px;" autocomplete="off"> | ||
21 | + 关键字: | ||
22 | + <input type="text" class="form-control" name="keyword" style="width: 200px;" | ||
23 | + value="{$keyword|default=''}" placeholder="请输入关键字..."> | ||
17 | <input type="submit" class="btn btn-primary" value="搜索"/> | 24 | <input type="submit" class="btn btn-primary" value="搜索"/> |
18 | <a class="btn btn-danger" href="{:url('AdminFault/index')}">清空</a> | 25 | <a class="btn btn-danger" href="{:url('AdminFault/index')}">清空</a> |
19 | </form> | 26 | </form> |
20 | <form class="js-ajax-form" action="" method="post"> | 27 | <form class="js-ajax-form" action="" method="post"> |
21 | - <div class="table-actions"> | ||
22 | - <button class="btn btn-primary btn-sm js-ajax-submit" type="submit" | ||
23 | - data-action="{:url('AdminFault/publish',array('yes'=>1))}" data-subcheck="true">批量新增 | ||
24 | - </button> | ||
25 | - </div> | ||
26 | <table class="table table-hover table-bordered table-list"> | 28 | <table class="table table-hover table-bordered table-list"> |
27 | <thead> | 29 | <thead> |
28 | <tr> | 30 | <tr> |
29 | - <th width="15"> | ||
30 | - <label> | ||
31 | - <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x"> | ||
32 | - </label> | ||
33 | - </th> | ||
34 | <th width="50">ID</th> | 31 | <th width="50">ID</th> |
35 | - <th>设备名称</th> | ||
36 | - <th>设备锁编号</th> | ||
37 | - <th>所在医院</th> | ||
38 | - <th>故障类型</th> | ||
39 | - <th>故障描述</th> | ||
40 | - <th>故障状态</th> | ||
41 | - <th>图片</th> | ||
42 | - <th width="150">操作</th> | 32 | + <th width="80">用户ID</th> |
33 | + <th>使用总时长</th> | ||
34 | + <th>使用次数</th> | ||
35 | + <th>平均每次使用时长</th> | ||
36 | + <th>计费故障次数</th> | ||
37 | + <th>锁故障次数</th> | ||
38 | + <th>床故障次数</th> | ||
39 | + <th>其他故障</th> | ||
40 | + <th>故障总数</th> | ||
43 | </tr> | 41 | </tr> |
44 | </thead> | 42 | </thead> |
45 | <foreach name="data" item="vo"> | 43 | <foreach name="data" item="vo"> |
46 | <tr> | 44 | <tr> |
47 | - <td> | ||
48 | - <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" | ||
49 | - value="{$vo.id}" title="ID:{$vo.id}"> | ||
50 | - </td> | ||
51 | <td><b>{$vo.id}</b></td> | 45 | <td><b>{$vo.id}</b></td> |
52 | - <td>{$vo.eq_name}</td> | ||
53 | - <td>{$vo.serial_number}</td> | ||
54 | - <td>{$vo.hospital}</td> | ||
55 | - <td> | ||
56 | - <switch name="$vo.fault_type"> | ||
57 | - <case value="1">计费</case> | ||
58 | - <case value="2">床体</case> | ||
59 | - <case value="3">床锁</case> | ||
60 | - <case value="4">其他</case> | ||
61 | - </switch> | ||
62 | - </td> | ||
63 | - <td>{$vo.fault_describe}</td> | ||
64 | - <td> | ||
65 | - <switch name="$vo.state"> | ||
66 | - <case value="1"><span class="label label-danger">未处理</span></case> | ||
67 | - <case value="2"><span class="label label-warning">处理中</span></case> | ||
68 | - <case value="3"><span class="label label-success">已处理</span></case> | ||
69 | - </switch> | ||
70 | - </td> | ||
71 | - <td> | ||
72 | - <img style="width: 50px;height: 50px" src="{:cmf_get_image_preview_url($vo.img)}"> | ||
73 | - <!--<a href="{:url('AdminFault/edit',array('id'=>$vo['id']))}">查看图片</a>--> | ||
74 | - </td> | ||
75 | - <td> | ||
76 | - <a href="{:url('AdminFault/warranty',array('id'=>$vo['id']))}" class="js-ajax-delete">保修</a><br/> | ||
77 | - <a href="{:url('AdminFault/reply',array('id'=>$vo['id']))}" class="js-ajax-delete">保修完成</a><br/> | ||
78 | - <a href="{:url('AdminFault/bill_error',array('id'=>$vo['id']))}" class="js-ajax-delete">终止订单计费</a><br/> | ||
79 | - </td> | 46 | + <td>{$vo.users_id}</td> |
47 | + <td>{$vo.sumTime}小时</td> | ||
48 | + <td>{$vo.num}次</td> | ||
49 | + <td>{$vo.average}小时</td> | ||
50 | + <td>{$vo.fault_time|default='0'}</td> | ||
51 | + <td>{$vo.fault_lock|default='0'}</td> | ||
52 | + <td>{$vo.fault_bed|default='0'}</td> | ||
53 | + <td>{$vo.fault_other|default='0'}</td> | ||
54 | + <td>{$vo.fault|default='0'}</td> | ||
80 | </tr> | 55 | </tr> |
81 | </foreach> | 56 | </foreach> |
82 | </table> | 57 | </table> |
83 | - <!--<div class="table-actions">--> | ||
84 | - <!--<notempty name="category">--> | ||
85 | - <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"--> | ||
86 | - <!--data-action="{:url('AdminArticle/listOrder')}">{:lang('SORT')}--> | ||
87 | - <!--</button>--> | ||
88 | - <!--</notempty>--> | ||
89 | - <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"--> | ||
90 | - <!--data-action="{:url('AdminArticle/publish',array('yes'=>1))}" data-subcheck="true">发布--> | ||
91 | - <!--</button>--> | ||
92 | - <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"--> | ||
93 | - <!--data-action="{:url('AdminArticle/publish',array('no'=>1))}" data-subcheck="true">取消发布--> | ||
94 | - <!--</button>--> | ||
95 | - <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"--> | ||
96 | - <!--data-action="{:url('AdminArticle/top',array('yes'=>1))}" data-subcheck="true">置顶--> | ||
97 | - <!--</button>--> | ||
98 | - <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"--> | ||
99 | - <!--data-action="{:url('AdminArticle/top',array('no'=>1))}" data-subcheck="true">取消置顶--> | ||
100 | - <!--</button>--> | ||
101 | - <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"--> | ||
102 | - <!--data-action="{:url('AdminArticle/recommend',array('yes'=>1))}" data-subcheck="true">推荐--> | ||
103 | - <!--</button>--> | ||
104 | - <!--<button class="btn btn-primary btn-sm js-ajax-submit" type="submit"--> | ||
105 | - <!--data-action="{:url('AdminArticle/recommend',array('no'=>1))}" data-subcheck="true">取消推荐--> | ||
106 | - <!--</button>--> | ||
107 | - <!--<!–--> | ||
108 | - <!--<notempty name="category">--> | ||
109 | - <!--<button class="btn btn-primary btn-sm js-articles-move" type="button">批量移动</button>--> | ||
110 | - <!--</notempty>--> | ||
111 | - <!--<button class="btn btn-primary btn-sm js-articles-copy" type="button">批量复制</button>--> | ||
112 | - <!--–>--> | ||
113 | - <!--<button class="btn btn-danger btn-sm js-ajax-submit" type="submit"--> | ||
114 | - <!--data-action="{:url('AdminArticle/delete')}" data-subcheck="true" data-msg="您确定删除吗?">--> | ||
115 | - <!--{:lang('DELETE')}--> | ||
116 | - <!--</button>--> | ||
117 | - <!--</div>--> | ||
118 | - <ul class="pagination">{$page|default=''}</ul> | 58 | + <ul style="text-align: center">{$data->render()}</ul> |
119 | </form> | 59 | </form> |
120 | </div> | 60 | </div> |
121 | <script src="__STATIC__/js/admin.js"></script> | 61 | <script src="__STATIC__/js/admin.js"></script> |
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | <ul class="nav nav-tabs"> | 5 | <ul class="nav nav-tabs"> |
6 | <li class="active"><a href="javascript:;">故障列表</a></li> | 6 | <li class="active"><a href="javascript:;">故障列表</a></li> |
7 | </ul> | 7 | </ul> |
8 | - <form class="well form-inline margin-top-20" method="post" action="{:url('AdminFaultAuditController/index')}"> | 8 | + <form class="well form-inline margin-top-20" method="post" action="{:url('AdminFaultAudit/index')}"> |
9 | 故障分类: | 9 | 故障分类: |
10 | <select class="form-control" name="fault_type" style="width: 140px;"> | 10 | <select class="form-control" name="fault_type" style="width: 140px;"> |
11 | <option value='0'>全部</option> | 11 | <option value='0'>全部</option> |
@@ -15,14 +15,9 @@ | @@ -15,14 +15,9 @@ | ||
15 | <option value='4' <if condition="$fault_type eq 4">selected </if>>其他</option> | 15 | <option value='4' <if condition="$fault_type eq 4">selected </if>>其他</option> |
16 | </select> | 16 | </select> |
17 | <input type="submit" class="btn btn-primary" value="搜索"/> | 17 | <input type="submit" class="btn btn-primary" value="搜索"/> |
18 | - <a class="btn btn-danger" href="{:url('AdminFaultAuditController/index')}">清空</a> | 18 | + <a class="btn btn-danger" href="{:url('AdminFaultAudit/index')}">清空</a> |
19 | </form> | 19 | </form> |
20 | <form class="js-ajax-form" action="" method="post"> | 20 | <form class="js-ajax-form" action="" method="post"> |
21 | - <div class="table-actions"> | ||
22 | - <button class="btn btn-primary btn-sm js-ajax-submit" type="submit" | ||
23 | - data-action="{:url('AdminFaultAuditController/publish',array('yes'=>1))}" data-subcheck="true">批量新增 | ||
24 | - </button> | ||
25 | - </div> | ||
26 | <table class="table table-hover table-bordered table-list"> | 21 | <table class="table table-hover table-bordered table-list"> |
27 | <thead> | 22 | <thead> |
28 | <tr> | 23 | <tr> |
@@ -73,9 +68,9 @@ | @@ -73,9 +68,9 @@ | ||
73 | <!--<a href="{:url('AdminFault/edit',array('id'=>$vo['id']))}">查看图片</a>--> | 68 | <!--<a href="{:url('AdminFault/edit',array('id'=>$vo['id']))}">查看图片</a>--> |
74 | </td> | 69 | </td> |
75 | <td> | 70 | <td> |
76 | - <a href="{:url('AdminFaultAuditController/warranty',array('id'=>$vo['id']))}" class="js-ajax-delete">保修</a><br/> | ||
77 | - <a href="{:url('AdminFaultAuditController/reply',array('id'=>$vo['id']))}" class="js-ajax-delete">保修完成</a><br/> | ||
78 | - <a href="{:url('AdminFaultAuditController/bill_error',array('id'=>$vo['id']))}" class="js-ajax-delete">终止订单计费</a><br/> | 71 | + <a href="{:url('AdminFaultAudit/warranty',array('id'=>$vo['id']))}" class="js-ajax-delete">保修</a><br/> |
72 | + <a href="{:url('AdminFaultAudit/reply',array('id'=>$vo['id']))}" class="js-ajax-delete">保修完成</a><br/> | ||
73 | + <a href="{:url('AdminFaultAudit/bill_error',array('id'=>$vo['id']))}" class="js-ajax-delete">终止订单计费</a><br/> | ||
79 | </td> | 74 | </td> |
80 | </tr> | 75 | </tr> |
81 | </foreach> | 76 | </foreach> |
-
请 注册 或 登录 后发表评论