作者 曹东东

工位审核

... ... @@ -77,9 +77,9 @@ class Building extends Frontend
if(!isset($params['room_id']) || empty($params['room_id'])){
$this->error('请选择房间');
}
if(strtotime($params['start_time']) <= time()) {
$this->error('请选择未来时间');
}
// if(strtotime($params['start_time']) <= time()) {
// $this->error('请选择未来时间');
// }
$startTime = strtotime($params['apply_date'].$params['start_time']);
$endTime = strtotime($params['apply_date'].$params['end_time']);
... ...
<?php
namespace app\school\controller;
use app\common\controller\DoubleBase;
use think\Db;
use app\common\model\StationAppointment as AppointmentModel;
/**
* 工位审核
*/
class StationAppointment extends DoubleBase
{
protected $noNeedRight = ['*'];
protected $model = null;
public function _initialize()
{
parent::_initialize();
$this->model = new AppointmentModel();
}
/**
* 预约审核index
* @return array|\think\response\Json
* @author cdd
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax()) {
list($where, $sort, $order, $offset, $limit) = $this->buildparams(null,true);
$params = json_decode($this->request->get('filter'),true);
$newwhere = [];
if(isset($params['room_name'])) {
$newwhere['s.station_name'] = ['like',"%".$params['station_name']."%"];
}
if(isset($params['username']) && !empty($params['username'])) {
$newwhere['u.username'] = ['like',"%".$params['username']."%"];
}
$list = $this->model
->alias('a')
->field('a.*,s.station_name,u.username')
->join('station s','a.station_id = s.id','inner')
->join('user u','a.user_id = u.id','left')
->where(['s.school_id' => SCHOOL_ID])
->where($newwhere)
->order('a.createtime', $order)
->paginate($limit);
$result = array("total" => $list->total(), "rows" => $list->items());
return json($result);
}
return $this->view->fetch();
}
public function verify()
{
$params = $this->request->param();
$info = $this->model->find($params['id']);
$info->status = $params['status'];
if(!$info->save()) {
$this->error('审核失败');
}
$this->success('成功');
}
}
... ...
... ... @@ -41,13 +41,16 @@ class RoomOrder extends DoubleBase
$params = json_decode($this->request->get('filter'),true);
$newwhere = [];
if(isset($params['room_name'])) {
$newwhere['r.room_name'] = ['like',"%".$params['room_name']."%"];
}
if(isset($params['username']) && !empty($params['username'])) {
$newwhere['u.username'] = ['like',"%".$params['username']."%"];
}
$list = $this->model
->field('o.*,r.room_name')
->field('o.*,r.room_name,u.username')
->alias('o')
->join('project_room r','o.room_id = r.id','inner')
->join('user u','o.user_id = u.id','left')
->where(['r.school_id' => SCHOOL_ID])
->where($newwhere)
->order('o.createtime', $order)
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<div class="panel-heading">
<ul class="nav nav-tabs">
<li class="active"><a href="#first" data-toggle="tab">场地预约审核</a></li>
<li><a href="#second" data-toggle="tab">工位预约审核</a></li>
</ul>
</div>
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
{:build_toolbar('refresh')}
</div>
<table id="table" class="table table-striped table-bordered table-hover"
data-operate-auth="{:$auth->check('auth/manystore/edit')}"
width="100%">
</table>
<div class="tab-pane fade active in" id="first">
<div id="toolbar1" class="toolbar">
{:build_toolbar('refresh')}
</div>
<table id="table1" class="table table-striped table-bordered table-hover" width="100%">
</table>
</div>
<div class="tab-pane fade" id="second">
<div id="toolbar2" class="toolbar">
{:build_toolbar('refresh')}
</div>
<table id="table2" class="table table-striped table-bordered table-hover" width="100%">
</table>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
... ...
define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($, undefined, Backend, Table, Form,Layer) {
var Controller = {
index: function () {
//修改弹框大小
// $(".btn-add").data("area",["100%","100%"]);
// $(".btn-edit").data("area",["100%","100%"]);
index: function() {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'project_appointment/room_order/index' + location.search,
auth_url: 'project_appointment/room_order/verify',
table: 'room',
Table.api.init();
//绑定事件
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var panel = $($(this).attr("href"));
if (panel.size() > 0) {
Controller.table[panel.attr("id")].call(this);
$(this).on('click', function (e) {
$($(this).attr("href")).find(".btn-refresh").trigger("click");
});
}
//移除绑定的事件
$(this).unbind('shown.bs.tab');
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
pageSize:10,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id'),operate: false},
{field: 'apply_name', title: __('申请人'),operate: 'LIKE'},
{field: 'room_name', title: __('房间名称'),operate: 'LIKE'},
{field: 'apply_date', title: __('预约日期'),operate: false},
{field: 'start_time', title: __('预约结束时间'),operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'end_time', title: __('预约结束时间'),operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'use_count', title: __('使用人数'),operate: false},
{field: 'apply_desc', title: __('预约说明'),operate: false},
{field: 'status_text', title: __('审核状态'),operate: false},
{field: 'createtime', title: __('创建时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{
field: 'operate',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons:[
{
name: 'btn',
text: '审核',
title: '审核',
classname: 'btn btn-xs btn-success btn-click',
click: function (val, row) {
var id = row.id;
var row_index = val.rowIndex;
layer.confirm('您想?', {
btn: ['通过审核','驳回审核'] //按钮
}, function(){
$.ajax({
type:'post',
url:'project_appointment/room_order/verify',
data:{id:id,status:2},
dataType:'json',
success:function(res){
if(parseInt(res.code) !=0){
$('#table').bootstrapTable('updateRow', {
index: row_index,
row: {
status_text: '审核通过',
}
});
//必须默认触发shown.bs.tab事件
$('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
},
table: {
first: function () {
// 表格1
var table1 = $("#table1");
table1.bootstrapTable({
url: 'project_appointment/room_order/index' + location.search,
toolbar: '#toolbar1',
sortName: 'id',
search: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id'),operate: false},
{field: 'username', title: __('申请人'),operate: 'LIKE'},
{field: 'room_name', title: __('房间名称'),operate: 'LIKE'},
{field: 'apply_date', title: __('预约日期'),operate: false},
{field: 'start_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'end_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'use_count', title: __('使用人数'),operate: false},
{field: 'apply_desc', title: __('预约说明'),operate: false},
{field: 'status_text', title: __('审核状态'),operate: false},
{field: 'createtime', title: __('创建时间'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{
field: 'operate',
title: __('Operate'),
table: table1,
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons:[
{
name: 'btn',
text: '审核',
title: '审核',
classname: 'btn btn-xs btn-success btn-click',
click: function (val, row) {
var id = row.id;
var row_index = val.rowIndex;
layer.confirm('您想?', {
btn: ['通过审核','驳回审核'] //按钮
}, function(){
$.ajax({
type:'post',
url:'project_appointment/room_order/verify',
data:{id:id,status:2},
dataType:'json',
success:function(res){
if(parseInt(res.code) !=0){
$('.btn-refresh').click();
}
layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
});
}, function(){
$.ajax({
type:'post',
url:'project_appointment/room_order/verify',
data:{id:id,status:3},
dataType:'json',
success:function(res){
if(parseInt(res.code) !=0){
$('.btn-refresh').click();
}
layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
});
layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
});
},
visible: function (val) {
if(val.status == 1) {
return true;
}
}
},
]
},
]
],
});
// 为表格1绑定事件
Table.api.bindevent(table1);
},
second: function () {
// 表格2
var table2 = $("#table2");
table2.bootstrapTable({
url: 'station_appointment/index' + location.search,
toolbar: '#toolbar2',
sortName: 'id',
search: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id'),operate: false},
{field: 'username', title: __('申请人'),operate: 'LIKE'},
{field: 'station_name', title: __('工位名称'),operate: 'LIKE'},
{field: 'station_date', title: __('预约日期'),operate: false},
{field: 'station_start_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'station_end_time', title: __('预约结束时间'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'station_user_count', title: __('使用人数'),operate: false},
{field: 'station_desc', title: __('预约说明'),operate: false},
{field: 'status_text', title: __('审核状态'),operate: false},
{field: 'createtime', title: __('创建时间'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{
field: 'operate',
title: __('Operate'),
table: table2,
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons:[
{
name: 'btn',
text: '审核',
title: '审核',
classname: 'btn btn-xs btn-success btn-click',
click: function (val, row) {
var id = row.id;
layer.confirm('您想?', {
btn: ['通过审核','驳回审核'] //按钮
}, function(){
$.ajax({
type:'post',
url:'station_appointment/verify',
data:{id:id,status:1},
dataType:'json',
success:function(res){
if(parseInt(res.code) !=0){
$('.btn-refresh').click();
}
}, function(){
$.ajax({
type:'post',
url:'project_appointment/room_order/verify',
data:{id:id,status:3},
dataType:'json',
success:function(res){
if(parseInt(res.code) !=0){
$('#table').bootstrapTable('updateRow', {
index: row_index,
row: {
status_text: '已驳回',
}
});
layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
});
});
});
},
/* visible: function (val) {
if(val.status != 1) {
return false;
}else{
return true;
}, function(){
$.ajax({
type:'post',
url:'station_appointment/verify',
data:{id:id,status:2},
dataType:'json',
success:function(res){
if(parseInt(res.code) !=0){
$('.btn-refresh').click();
}
layer.msg(res.msg, {icon: 1});
},
error:function(error){
console.log(error);
}
});
});
},
visible: function (val) {
if(val.status == 0) {
return true;
}
}
}*/
},
]
},
},
]
},
]
],
});
]
],
});
$('.search input').attr('placeholder','搜索');
// 为表格绑定事件
Table.api.bindevent(table);
// 为表格2绑定事件
Table.api.bindevent(table2);
}
},
add: function () {
Controller.api.bindevent();
... ...