作者 金洪杰

工位

... ... @@ -89,7 +89,6 @@ class SxBasement extends Frontend
if($endTime <= $startTime) {
$this->error('结束时间不能小于开始时间');
}
$start = $startTime - 1;
$stationInfo = Station::alias('a')
->field('a.id,a.station_name,a.capacity,count(sa.id) as appoint_count')
->join('fa_station_appointment sa','a.id = sa.station_id','LEFT')
... ... @@ -106,9 +105,9 @@ class SxBasement extends Frontend
$this->error("该工位可容纳{$stationInfo['capacity']}人");
}
$res = Db::table('fa_station_appointment')
->whereOr("station_start_time >= {$start} AND station_start_time <= {$endTime}")
->whereOr("station_start_time <= {$start} AND station_end_time >= {$endTime}")
->whereOr("station_end_time >= {$start} AND station_end_time <= {$endTime}")
->whereOr("station_start_time >= {$startTime} AND station_start_time <= {$endTime}")
->whereOr("station_start_time <= {$startTime} AND station_end_time >= {$endTime}")
->whereOr("station_end_time >= {$startTime} AND station_end_time <= {$endTime}")
->having("station_id = {$params['station_id']}")
->select();
if($res) {
... ... @@ -126,4 +125,26 @@ class SxBasement extends Frontend
$this->success('预约成功','/index/sx_basement/index');
}
/**
* 工位列表
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function station(){
$params = $this->request->post();
$startTime = strtotime($params['station_date'].$params['station_start_time']);
$endTime = strtotime($params['station_date'].$params['station_end_time']);
//工位
$stationList = Station::alias('a')
->field('a.id,a.station_name,count(sa.id) as appoint_count')
->join('fa_station_appointment sa','a.id = sa.station_id','LEFT')
->whereOr("station_start_time >= {$startTime} AND station_start_time <= {$endTime}")
->whereOr("station_start_time <= {$startTime} AND station_end_time >= {$endTime}")
->whereOr("station_end_time >= {$startTime} AND station_end_time <= {$endTime}")
->where('a.school_id',$this->auth->school_id)
->group('a.id')
->select();
$this->success('查询成功',$stationList);
}
}
... ...
... ... @@ -190,12 +190,12 @@
}
/*已预约*/
.station_ready_select{
background-color: #ccc;
background-color: #FF6200;
/*background-color: rgb(255, 149, 2);*/
}
/*空闲*/
.station_green_select{
background-color: rgb(52, 199, 88);
background-color: #C2C7CC;
}
/*已选*/
.station_check_select{
... ... @@ -636,13 +636,13 @@
<div class="build_search">
<div class="room_choice"><span>预约信息</span></div>
<div class="info">
<div class="input_control station_block hidden">
<div class="input_control station_block">
<span><span class="required_s">*</span>已选工位</span>
<span class="station_name" style="margin-left: 40px;">A205</span>
<span class="station_name" style="margin-left: 40px;"></span>
</div>
<div class="input_control">
<span><span class="required_s">*</span>预约日期</span>
<input class="datetimepicker form_input" name="station_date" type="text" id="station_date" placeholder="预约日期" />
<input class="datetimepicker form_input station_date" name="station_date" type="text" id="station_date" placeholder="预约日期" />
</div>
<div class="input_control">
<span><span class="required_s">*</span>预约时间</span>
... ...
... ... @@ -132,7 +132,7 @@ define(['jquery', 'bootstrap', 'frontend', 'form', 'template', 'swiper', 'layer'
}
$(this).children('a').children('div').children('div').addClass("station_check_select");
$(this).siblings('li').children('a').children('div').children('div').removeClass("station_check_select");
$('.station_block').removeClass('hidden');
// $('.station_block').removeClass('hidden');
$('.station_name').text(station_name);
});
//房间选择 不需要请求 房间接口
... ... @@ -246,6 +246,30 @@ define(['jquery', 'bootstrap', 'frontend', 'form', 'template', 'swiper', 'layer'
});
});
//选择时间切换工位数据
// $(document).on('change','.station_date,.station_start_time,.station_end_time',function () {
// console.log('time',$(this).val());
// var station_date = $("input[name='station_date']").val(),
// station_start_time = $(".station_start_time option:selected").val(),
// station_end_time = $(".station_end_time option:selected").val();
//
// if(station_date != '' && station_start_time != '' && station_end_time != '') {
// Fast.api.ajax({
// url:'sx_basement/station',
// data:{
// station_date:station_date,
// station_start_time:station_start_time,
// station_end_time:station_end_time,
// }
// },function (i,ret) {
// if(ret.code == 1) {
// console.log('ret',ret);
// }else{
// return false;
// }
// });
// }
// });
$(document).on('click',"#commit_build",function(){
var room_id = $("#room .conditions_select").attr("data-id"),
... ...