作者 曹东东

工位审核

@@ -77,9 +77,9 @@ class Building extends Frontend @@ -77,9 +77,9 @@ class Building extends Frontend
77 if(!isset($params['room_id']) || empty($params['room_id'])){ 77 if(!isset($params['room_id']) || empty($params['room_id'])){
78 $this->error('请选择房间'); 78 $this->error('请选择房间');
79 } 79 }
80 - if(strtotime($params['start_time']) <= time()) {  
81 - $this->error('请选择未来时间');  
82 - } 80 +// if(strtotime($params['start_time']) <= time()) {
  81 +// $this->error('请选择未来时间');
  82 +// }
83 $startTime = strtotime($params['apply_date'].$params['start_time']); 83 $startTime = strtotime($params['apply_date'].$params['start_time']);
84 $endTime = strtotime($params['apply_date'].$params['end_time']); 84 $endTime = strtotime($params['apply_date'].$params['end_time']);
85 85
  1 +<?php
  2 +
  3 +namespace app\school\controller;
  4 +
  5 +use app\common\controller\DoubleBase;
  6 +use think\Db;
  7 +use app\common\model\StationAppointment as AppointmentModel;
  8 +
  9 +/**
  10 + * 工位审核
  11 + */
  12 +class StationAppointment extends DoubleBase
  13 +{
  14 +
  15 + protected $noNeedRight = ['*'];
  16 + protected $model = null;
  17 + public function _initialize()
  18 + {
  19 + parent::_initialize();
  20 + $this->model = new AppointmentModel();
  21 + }
  22 +
  23 + /**
  24 + * 预约审核index
  25 + * @return array|\think\response\Json
  26 + * @author cdd
  27 + */
  28 + public function index()
  29 + {
  30 + //设置过滤方法
  31 + $this->request->filter(['strip_tags', 'trim']);
  32 + if ($this->request->isAjax()) {
  33 + list($where, $sort, $order, $offset, $limit) = $this->buildparams(null,true);
  34 + $params = json_decode($this->request->get('filter'),true);
  35 + $newwhere = [];
  36 + if(isset($params['room_name'])) {
  37 + $newwhere['s.station_name'] = ['like',"%".$params['station_name']."%"];
  38 + }
  39 + if(isset($params['username']) && !empty($params['username'])) {
  40 + $newwhere['u.username'] = ['like',"%".$params['username']."%"];
  41 + }
  42 + $list = $this->model
  43 + ->alias('a')
  44 + ->field('a.*,s.station_name,u.username')
  45 + ->join('station s','a.station_id = s.id','inner')
  46 + ->join('user u','a.user_id = u.id','left')
  47 + ->where(['s.school_id' => SCHOOL_ID])
  48 + ->where($newwhere)
  49 + ->order('a.createtime', $order)
  50 + ->paginate($limit);
  51 + $result = array("total" => $list->total(), "rows" => $list->items());
  52 + return json($result);
  53 + }
  54 + return $this->view->fetch();
  55 + }
  56 +
  57 + public function verify()
  58 + {
  59 + $params = $this->request->param();
  60 + $info = $this->model->find($params['id']);
  61 + $info->status = $params['status'];
  62 + if(!$info->save()) {
  63 + $this->error('审核失败');
  64 + }
  65 + $this->success('成功');
  66 + }
  67 +
  68 +
  69 +}
@@ -41,13 +41,16 @@ class RoomOrder extends DoubleBase @@ -41,13 +41,16 @@ class RoomOrder extends DoubleBase
41 $params = json_decode($this->request->get('filter'),true); 41 $params = json_decode($this->request->get('filter'),true);
42 $newwhere = []; 42 $newwhere = [];
43 if(isset($params['room_name'])) { 43 if(isset($params['room_name'])) {
44 -  
45 $newwhere['r.room_name'] = ['like',"%".$params['room_name']."%"]; 44 $newwhere['r.room_name'] = ['like',"%".$params['room_name']."%"];
46 } 45 }
  46 + if(isset($params['username']) && !empty($params['username'])) {
  47 + $newwhere['u.username'] = ['like',"%".$params['username']."%"];
  48 + }
47 $list = $this->model 49 $list = $this->model
48 - ->field('o.*,r.room_name') 50 + ->field('o.*,r.room_name,u.username')
49 ->alias('o') 51 ->alias('o')
50 ->join('project_room r','o.room_id = r.id','inner') 52 ->join('project_room r','o.room_id = r.id','inner')
  53 + ->join('user u','o.user_id = u.id','left')
51 ->where(['r.school_id' => SCHOOL_ID]) 54 ->where(['r.school_id' => SCHOOL_ID])
52 ->where($newwhere) 55 ->where($newwhere)
53 ->order('o.createtime', $order) 56 ->order('o.createtime', $order)
1 <div class="panel panel-default panel-intro"> 1 <div class="panel panel-default panel-intro">
2 - {:build_heading()} 2 + <div class="panel-heading">
  3 + <ul class="nav nav-tabs">
  4 + <li class="active"><a href="#first" data-toggle="tab">场地预约审核</a></li>
  5 + <li><a href="#second" data-toggle="tab">工位预约审核</a></li>
  6 + </ul>
  7 + </div>
3 <div class="panel-body"> 8 <div class="panel-body">
4 <div id="myTabContent" class="tab-content"> 9 <div id="myTabContent" class="tab-content">
5 - <div class="tab-pane fade active in" id="one">  
6 - <div class="widget-body no-padding">  
7 - <div id="toolbar" class="toolbar">  
8 - {:build_toolbar('refresh')}  
9 - </div>  
10 - <table id="table" class="table table-striped table-bordered table-hover"  
11 - data-operate-auth="{:$auth->check('auth/manystore/edit')}"  
12 -  
13 - width="100%">  
14 - </table> 10 + <div class="tab-pane fade active in" id="first">
  11 + <div id="toolbar1" class="toolbar">
  12 + {:build_toolbar('refresh')}
  13 + </div>
  14 + <table id="table1" class="table table-striped table-bordered table-hover" width="100%">
  15 + </table>
  16 + </div>
  17 + <div class="tab-pane fade" id="second">
  18 + <div id="toolbar2" class="toolbar">
  19 + {:build_toolbar('refresh')}
15 </div> 20 </div>
  21 + <table id="table2" class="table table-striped table-bordered table-hover" width="100%">
  22 + </table>
16 </div> 23 </div>
17 -  
18 </div> 24 </div>
19 </div> 25 </div>
20 -</div> 26 +</div>
1 define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($, undefined, Backend, Table, Form,Layer) { 1 define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($, undefined, Backend, Table, Form,Layer) {
2 2
3 var Controller = { 3 var Controller = {
4 - index: function () {  
5 - //修改弹框大小  
6 - // $(".btn-add").data("area",["100%","100%"]);  
7 - // $(".btn-edit").data("area",["100%","100%"]); 4 + index: function() {
8 // 初始化表格参数配置 5 // 初始化表格参数配置
9 - Table.api.init({  
10 - extend: {  
11 - index_url: 'project_appointment/room_order/index' + location.search,  
12 - auth_url: 'project_appointment/room_order/verify',  
13 - table: 'room', 6 + Table.api.init();
  7 +
  8 + //绑定事件
  9 + $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  10 + var panel = $($(this).attr("href"));
  11 + if (panel.size() > 0) {
  12 + Controller.table[panel.attr("id")].call(this);
  13 + $(this).on('click', function (e) {
  14 + $($(this).attr("href")).find(".btn-refresh").trigger("click");
  15 + });
14 } 16 }
  17 + //移除绑定的事件
  18 + $(this).unbind('shown.bs.tab');
15 }); 19 });
16 20
17 - var table = $("#table");  
18 - // 初始化表格  
19 - table.bootstrapTable({  
20 - url: $.fn.bootstrapTable.defaults.extend.index_url,  
21 - pk: 'id',  
22 - sortName: 'id',  
23 - pageSize:10,  
24 - columns: [  
25 - [  
26 - {checkbox: true},  
27 - {field: 'id', title: __('Id'),operate: false},  
28 - {field: 'apply_name', title: __('申请人'),operate: 'LIKE'},  
29 - {field: 'room_name', title: __('房间名称'),operate: 'LIKE'},  
30 - {field: 'apply_date', title: __('预约日期'),operate: false},  
31 - {field: 'start_time', title: __('预约结束时间'),operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},  
32 - {field: 'end_time', title: __('预约结束时间'),operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},  
33 - {field: 'use_count', title: __('使用人数'),operate: false},  
34 - {field: 'apply_desc', title: __('预约说明'),operate: false},  
35 - {field: 'status_text', title: __('审核状态'),operate: false},  
36 - {field: 'createtime', title: __('创建时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},  
37 - {  
38 - field: 'operate',  
39 - title: __('Operate'),  
40 - table: table,  
41 - events: Table.api.events.operate,  
42 - formatter: Table.api.formatter.operate,  
43 - buttons:[  
44 - {  
45 - name: 'btn',  
46 - text: '审核',  
47 - title: '审核',  
48 - classname: 'btn btn-xs btn-success btn-click',  
49 - click: function (val, row) {  
50 - var id = row.id;  
51 - var row_index = val.rowIndex;  
52 - layer.confirm('您想?', {  
53 - btn: ['通过审核','驳回审核'] //按钮  
54 - }, function(){  
55 - $.ajax({  
56 - type:'post',  
57 - url:'project_appointment/room_order/verify',  
58 - data:{id:id,status:2},  
59 - dataType:'json',  
60 - success:function(res){  
61 - if(parseInt(res.code) !=0){  
62 - $('#table').bootstrapTable('updateRow', {  
63 - index: row_index,  
64 - row: {  
65 - status_text: '审核通过',  
66 - }  
67 - }); 21 + //必须默认触发shown.bs.tab事件
  22 + $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
  23 + },
  24 + table: {
  25 + first: function () {
  26 + // 表格1
  27 + var table1 = $("#table1");
  28 + table1.bootstrapTable({
  29 + url: 'project_appointment/room_order/index' + location.search,
  30 + toolbar: '#toolbar1',
  31 + sortName: 'id',
  32 + search: false,
  33 + columns: [
  34 + [
  35 + {checkbox: true},
  36 + {field: 'id', title: __('Id'),operate: false},
  37 + {field: 'username', title: __('申请人'),operate: 'LIKE'},
  38 + {field: 'room_name', title: __('房间名称'),operate: 'LIKE'},
  39 + {field: 'apply_date', title: __('预约日期'),operate: false},
  40 + {field: 'start_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  41 + {field: 'end_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  42 + {field: 'use_count', title: __('使用人数'),operate: false},
  43 + {field: 'apply_desc', title: __('预约说明'),operate: false},
  44 + {field: 'status_text', title: __('审核状态'),operate: false},
  45 + {field: 'createtime', title: __('创建时间'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  46 + {
  47 + field: 'operate',
  48 + title: __('Operate'),
  49 + table: table1,
  50 + events: Table.api.events.operate,
  51 + formatter: Table.api.formatter.operate,
  52 + buttons:[
  53 + {
  54 + name: 'btn',
  55 + text: '审核',
  56 + title: '审核',
  57 + classname: 'btn btn-xs btn-success btn-click',
  58 + click: function (val, row) {
  59 + var id = row.id;
  60 + var row_index = val.rowIndex;
  61 + layer.confirm('您想?', {
  62 + btn: ['通过审核','驳回审核'] //按钮
  63 + }, function(){
  64 + $.ajax({
  65 + type:'post',
  66 + url:'project_appointment/room_order/verify',
  67 + data:{id:id,status:2},
  68 + dataType:'json',
  69 + success:function(res){
  70 + if(parseInt(res.code) !=0){
  71 + $('.btn-refresh').click();
  72 + }
  73 +
  74 + layer.msg(res.msg, {icon: 1});
  75 + },
  76 + error:function(error){
  77 + console.log(error);
  78 + }
  79 + });
  80 +
  81 + }, function(){
  82 + $.ajax({
  83 + type:'post',
  84 + url:'project_appointment/room_order/verify',
  85 + data:{id:id,status:3},
  86 + dataType:'json',
  87 + success:function(res){
  88 + if(parseInt(res.code) !=0){
  89 + $('.btn-refresh').click();
  90 + }
  91 + layer.msg(res.msg, {icon: 1});
  92 + },
  93 + error:function(error){
  94 + console.log(error);
68 } 95 }
  96 + });
69 97
70 - layer.msg(res.msg, {icon: 1});  
71 - },  
72 - error:function(error){  
73 - console.log(error);  
74 - }  
75 }); 98 });
  99 + },
  100 + visible: function (val) {
  101 + if(val.status == 1) {
  102 + return true;
  103 + }
  104 + }
  105 + },
  106 + ]
  107 + },
  108 +
  109 + ]
  110 + ],
  111 + });
  112 +
  113 + // 为表格1绑定事件
  114 + Table.api.bindevent(table1);
  115 + },
  116 + second: function () {
  117 + // 表格2
  118 + var table2 = $("#table2");
  119 + table2.bootstrapTable({
  120 + url: 'station_appointment/index' + location.search,
  121 + toolbar: '#toolbar2',
  122 + sortName: 'id',
  123 + search: false,
  124 + columns: [
  125 + [
  126 + {checkbox: true},
  127 + {field: 'id', title: __('Id'),operate: false},
  128 + {field: 'username', title: __('申请人'),operate: 'LIKE'},
  129 + {field: 'station_name', title: __('工位名称'),operate: 'LIKE'},
  130 + {field: 'station_date', title: __('预约日期'),operate: false},
  131 + {field: 'station_start_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  132 + {field: 'station_end_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  133 + {field: 'station_user_count', title: __('使用人数'),operate: false},
  134 + {field: 'station_desc', title: __('预约说明'),operate: false},
  135 + {field: 'status_text', title: __('审核状态'),operate: false},
  136 + {field: 'createtime', title: __('创建时间'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  137 + {
  138 + field: 'operate',
  139 + title: __('Operate'),
  140 + table: table2,
  141 + events: Table.api.events.operate,
  142 + formatter: Table.api.formatter.operate,
  143 + buttons:[
  144 + {
  145 + name: 'btn',
  146 + text: '审核',
  147 + title: '审核',
  148 + classname: 'btn btn-xs btn-success btn-click',
  149 + click: function (val, row) {
  150 + var id = row.id;
  151 + layer.confirm('您想?', {
  152 + btn: ['通过审核','驳回审核'] //按钮
  153 + }, function(){
  154 + $.ajax({
  155 + type:'post',
  156 + url:'station_appointment/verify',
  157 + data:{id:id,status:1},
  158 + dataType:'json',
  159 + success:function(res){
  160 + if(parseInt(res.code) !=0){
  161 + $('.btn-refresh').click();
  162 + }
76 163
77 - }, function(){  
78 - $.ajax({  
79 - type:'post',  
80 - url:'project_appointment/room_order/verify',  
81 - data:{id:id,status:3},  
82 - dataType:'json',  
83 - success:function(res){  
84 - if(parseInt(res.code) !=0){  
85 - $('#table').bootstrapTable('updateRow', {  
86 - index: row_index,  
87 - row: {  
88 - status_text: '已驳回',  
89 - }  
90 - }); 164 + layer.msg(res.msg, {icon: 1});
  165 + },
  166 + error:function(error){
  167 + console.log(error);
91 } 168 }
92 - layer.msg(res.msg, {icon: 1});  
93 - },  
94 - error:function(error){  
95 - console.log(error);  
96 - }  
97 - }); 169 + });
98 170
99 - });  
100 - },  
101 - /* visible: function (val) {  
102 - if(val.status != 1) {  
103 - return false;  
104 - }else{  
105 - return true; 171 + }, function(){
  172 + $.ajax({
  173 + type:'post',
  174 + url:'station_appointment/verify',
  175 + data:{id:id,status:2},
  176 + dataType:'json',
  177 + success:function(res){
  178 + if(parseInt(res.code) !=0){
  179 + $('.btn-refresh').click();
  180 + }
  181 + layer.msg(res.msg, {icon: 1});
  182 + },
  183 + error:function(error){
  184 + console.log(error);
  185 + }
  186 + });
  187 +
  188 + });
  189 + },
  190 + visible: function (val) {
  191 + if(val.status == 0) {
  192 + return true;
  193 + }
106 } 194 }
107 - }*/  
108 - },  
109 - ]  
110 - }, 195 + },
  196 + ]
  197 + },
111 198
112 - ]  
113 - ],  
114 - }); 199 + ]
  200 + ],
  201 + });
115 202
116 - $('.search input').attr('placeholder','搜索');  
117 - // 为表格绑定事件  
118 - Table.api.bindevent(table); 203 + // 为表格2绑定事件
  204 + Table.api.bindevent(table2);
  205 + }
119 }, 206 },
120 add: function () { 207 add: function () {
121 Controller.api.bindevent(); 208 Controller.api.bindevent();