作者 曹东东
... ... @@ -6,7 +6,9 @@ use app\common\controller\Frontend;
use app\school\model\project_appointment\Building as BuildingModel;
use app\school\model\project_appointment\AppointmentRule as AppointmentRuleModel;
use app\school\model\project_appointment\Room as RoomModel;
use app\school\model\project_appointment\Floor as FloorModel;
use app\index\model\BuildingEnter;
use app\school\model\station\Station;
use think\Db;
class SxBasement extends Frontend
{
... ... @@ -25,12 +27,21 @@ class SxBasement extends Frontend
if($enterRules) {
$enterRules['data_url'] = json_decode($enterRules['data_url'],true);
}
$stationList = ['1' => '工位一','2' => '工位二','3' => '工位三','4' => '工位四','5' => '工位五','6' => '工位六','7' => '工位七','8' => '工位八'];
//工位
$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')
->where(['a.school_id'=>$this->auth->school_id])
->group('a.id')
->select();
//入驻公司
$buildingEnter = BuildingEnter::where(['enter_type' => 2,'status' => 2,'school_id'=>$this->auth->school_id,'user_id' => $this->auth->id])->column('id,enter_project_name');
$this->assign('roomTypeList',$roomTypeList);
$this->assign('stationList',$stationList);
$this->assign('enterRules',$enterRules);
$this->assign('buildList',$buildList);
$this->assign('roomList',$roomList);
$this->assign('buildingEnter',$buildingEnter);
}
public function index()
... ... @@ -46,4 +57,94 @@ class SxBasement extends Frontend
downloadFile($file_url,$file_name);
}
/**
* 工位分配提交
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function stationApply()
{
$userInfo = $this->auth->getUser();
if(!$userInfo) {
$this->success('请登入','/index/student_login/index');
}
$params = $this->request->post();
if(!isset($params['station_id']) || empty($params['station_id'])){
$this->error('请选择工位');
}
if(!isset($params['enter_id']) || empty($params['enter_id'])){
$this->error('请选择公司');
}
if(strtotime($params['station_start_time']) <= time()) {
$this->error('开始时间请选择未来时间');
}
$startTime = strtotime($params['station_date'].$params['station_start_time']);
$endTime = strtotime($params['station_date'].$params['station_end_time']);
if($startTime == $endTime) {
$this->error('预约开始时间不能等于结束时间');
}
if($endTime <= $startTime) {
$this->error('结束时间不能小于开始时间');
}
$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')
->where('a.deletetime',NULL)
->where(['a.id' => $params['station_id']])
->find();
if(!$stationInfo) {
$this->error('该工位不存在或已经被下架');
}
if ($stationInfo['appoint_count']){
$this->error('该工位已被预约');
}
if ($stationInfo['capacity'] < $params['station_user_count']){
$this->error("该工位可容纳{$stationInfo['capacity']}人");
}
$res = Db::table('fa_station_appointment')
->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) {
$this->error('该时间存在已经被预约,请重新选择');
}
$params['station_start_time'] = $startTime;
$params['station_end_time'] = $endTime;
$params['user_id'] = $userInfo['id'];
$params['school_id'] = $userInfo['school_id'];
$params['createtime'] = time();
$result = Db::table('fa_station_appointment')->insert($params);
if(!$result) {
$this->error('预约失败,请重新尝试');
}
$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);
}
}
... ...
... ... @@ -28,7 +28,7 @@
}
.build_search {
width: 800px;
/*width: 800px;*/
/* border-top: 1px solid #DEE0ED; */
margin-top: 15px;
}
... ... @@ -64,11 +64,11 @@
font-size: 12px;
}
.screening_conditions ul li:first-child {
text-align: right;
font-weight: bold;
font-size: 15px;
}
/*.screening_conditions ul li:first-child {*/
/* text-align: right;*/
/* font-weight: bold;*/
/* font-size: 15px;*/
/*}*/
.conditions_select {
border: 2px solid #CCE2F8;
... ... @@ -95,7 +95,7 @@
border: 1px solid #c8cccf;
color: #6a6f77;
outline: 0;
width: 35rem;
width: 42rem;
}
.input_control {
... ... @@ -111,14 +111,14 @@
.info .input_control .start_time {
margin-left: 40px;
border: 1px solid #c8cccf;
width: 12rem;
/*width: 12rem;*/
border-radius: 2px;
}
.info .input_control .end_time {
margin-left: 40px;
border: 1px solid #c8cccf;
width: 12rem;
/*width: 12rem;*/
border-radius: 2px;
}
... ... @@ -137,7 +137,7 @@
}
.layui-btn-container {
margin: 3% 0 0 40%;
/*margin: 3% 0 0 40%;*/
}
.rotation {
... ... @@ -168,6 +168,66 @@
color: rgb(139, 138, 138);
padding-left: 7px;
}
.bb{
width: 60px;
height: 60px;
text-align: center;
}
.cc{
height: 28px;
background-color: #fff;
width: 20px;
margin: 0 auto;
}
.cc-txt{
margin-top: 5px;
}
#stations{
display: flex;
justify-content: row;
flex-wrap: wrap;
}
/*已预约*/
.station_ready_select{
background-color: #FF6200;
/*background-color: rgb(255, 149, 2);*/
}
/*空闲*/
.station_green_select{
background-color: #C2C7CC;
}
/*已选*/
.station_check_select{
background-color: rgb(175, 82, 222);
}
.sta-li{
margin: 0px 24px
}
.time{
width: 32.7%;
}
.btn{
background-color: rgb(50, 145, 248);
border-radius: 5px;
}
.sta-li>a, a:visited, a:link, a:hover{
color:black;!important;
}
.bb-block{
display: flex;
justify-content: flex-end;
align-items: center;
margin: 10px 24px -18px 0;
}
.bb-msg{
width: 20px;
height: 20px;
}
.bb-msg-font{
font-size: 14px;
margin: 0 10px 0 10px;
}
</style>
<div class="rotation">
<img src="__CDN__/assets/img/teacherRotation.png" />
... ... @@ -545,28 +605,49 @@
<div class="right_main ">
<div class="build_search">
<span class="room_choice">公共工位座位分布图</span>
<div class="bb-block">
<div class="station_green_select bb-msg"></div>
<span class="bb-msg-font">空闲</span>
<div class="station_ready_select bb-msg"></div>
<span class="bb-msg-font">不可约</span>
<div class="station_check_select bb-msg"></div>
<span class="bb-msg-font">已选</span>
</div>
<div class="screening_conditions">
<div>
<ul id="stations">
{foreach $stationList as $key => $val}
<li><a href="javascript:;" title="{$val}" class="{if $key == 0} conditions_select {/if}" href="javascript:;" data-id="{$key}">{$val}</a></li>
<!-- <li><a href="javascript:;" title="{$val}" class="{if $key == 0} conditions_select {/if}" data-id="{$key}">{$val}</a></li>-->
<li class="sta-li">
<a href="javascript:;" title="{$val}" data-id="{$val.id}" data-station_name="{$val.station_name}" data-appoint_count="{$val.appoint_count}">
<div class="aa">
<div class="bb {if $val.appoint_count == 0} station_green_select {else/} station_ready_select {/if}" data-id="{$val.id}">
<div class="cc"></div>
<div class="cc-txt">
<span>{$val.station_name}</span>
</div>
</div>
</div>
</a>
</li>
{/foreach}
</ul>
</div>
</div>
</div>
<div class="build_search">
<div class="room_choice"><span>预约信息</span></div>
<div class="info">
<div class="input_control station_block">
<span><span class="required_s">*</span>已选工位</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" name="station_date" type="text" id="station_date" class="form_input" 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>
<select class="start_time station_start_time" name="station_start_time">
<option disabled selected >请选择预约开始时间</option>
<select class="start_time station_start_time time" name="station_start_time">
<option value="" disabled selected >请选择预约开始时间</option>
<option value="08:00" >08:00</option>
<option value="08:30" >08:30</option>
<option value="09:00" >09:00</option>
... ... @@ -592,8 +673,8 @@
<option value="20:00" >20:00</option>
<option value="20:30" >20:30</option>
</select>
<select class="end_time station_end_time" name="station_end_time">
<option disabled selected>请选择预约结束时间</option>
<select class="end_time station_end_time time" name="station_end_time">
<option value="" disabled selected>请选择预约结束时间</option>
<option value="08:30" >08:30</option>
<option value="09:00" >09:00</option>
<option value="09:30" >09:30</option>
... ... @@ -622,7 +703,7 @@
</div>
<div class="input_control">
<span><span class="required_s">*</span>预约形式</span>
<select class="apply_type station_type" name="station_type" lay-verify="">
<select class="apply_type station_type" name="station_type" lay-verify="" style="width: 70%;">
<option value="1" selected>个人</option>
<option value="2" >公司</option>
<option value="3" >团队</option>
... ... @@ -633,12 +714,20 @@
<input name="station_user_count" type="text" class="form_input" placeholder="参与人数" />
</div>
<div class="input_control">
<span><span class="required_s">*</span>选择公司</span>
<select class="apply_type enter_id" name="enter_id" lay-verify="" style="width: 70%;">
{foreach name='buildingEnter' item='vo'}
<option value="{$key}" selected>{$vo}</option>
{/foreach}
</select>
</div>
<div class="input_control">
<span>使用设备说明</span>
<textarea name="station_desc" id="station_desc" required lay-verify="required" placeholder="使用设备说明" class="layui-textarea"></textarea>
<textarea style="width: 70%;" name="station_desc" id="station_desc" required lay-verify="required" placeholder="使用设备说明" class="layui-textarea"></textarea>
</div>
<div class="layui-btn-container">
<a type="button" id="commit_station" class="layui-btn layui-btn-sm">提交</a>
<a type="button" href="javascript:history.go(-1);" class="layui-btn layui-btn-sm">取消</a>
<div class="input_control" style="padding-left: 11.5%;">
<a type="button" id="commit_station" class="layui-btn layui-btn-sm btn">提交</a>
<a type="button" href="javascript:history.go(-1);" class="layui-btn layui-btn-sm btn" style="color: #fff">取消</a>
</div>
</div>
... ... @@ -653,10 +742,6 @@
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -121,15 +121,25 @@ define(['jquery', 'bootstrap', 'frontend', 'form', 'template', 'swiper', 'layer'
});
//工位
$(document).on('click','#stations li:not(:first-child),#stations li:not(:first-child) ,#stations li:not(:first-child)',function(){
$(this).children('a').addClass("conditions_select");
$(this).siblings('li').children('a').removeClass("conditions_select");
$(document).on('click','#stations li:first-child, #stations li:not(:first-child),#stations li:not(:first-child),#stations li:not(:first-child)',function(){
// $(this).children('a').children('div').children('div').addClass("conditions_select");
// $(this).siblings('li').children('a').removeClass("conditions_select");
var appoint_count = $(this).children('a').data('appoint_count');
var station_name = $(this).children('a').data('station_name');
if (appoint_count > 0){
layer.msg('此工位不可约');
return false;
}
$(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_name').text(station_name);
});
//房间选择 不需要请求 房间接口
$(document).on('click','#room li:not(:first-child)',function(){
$(this).children('a').addClass("conditions_select");
$(this).siblings('li').children('a').removeClass("conditions_select");
})
});
$(document).on('click','#floor li:not(:first-child),#room_type li:not(:first-child) ,#build_type li:not(:first-child)',function(){
$(this).children('a').addClass("conditions_select");
... ... @@ -175,41 +185,91 @@ define(['jquery', 'bootstrap', 'frontend', 'form', 'template', 'swiper', 'layer'
return false;
});
}
//工位分配提交
$(document).on('click',"#commit_station",function(){
var conditions_select = $("#stations .conditions_select").attr("data-id"),
var conditions_select = $("#stations .station_check_select").attr("data-id"),
station_date = $("input[name='station_date']").val(),
station_user_count = $("input[name='station_user_count']").val(),
station_start_time = $(".station_start_time option:selected").val(),
station_end_time = $(".station_end_time option:selected").val();
station_desc = $("#station_desc").val();
station_end_time = $(".station_end_time option:selected").val(),
station_user_count = $("input[name='station_user_count']").val(),
station_desc = $("#station_desc").val(),
enter_id = $(".enter_id option:selected").val(),
apply_type = $(".station_type option:selected").val();
console.log(station_start_time);
console.log(station_end_time);
if(!conditions_select) {
layer.msg('请选择工位');
return false;
}
if(!station_date) {
if(station_date == '') {
layer.msg('请选择预约日期');
return false;
}
if(!station_start_time) {
if(station_start_time == '') {
layer.msg('请选择预约开始时间');
return false;
}
if(!station_end_time) {
if(station_end_time == '') {
layer.msg('请选择预约结束时间');
return false;
}
if(station_user_count == '') {
layer.msg('使用人数不能为空');
layer.msg('参与人数不能为空');
return false;
}
if (enter_id == ''){
layer.msg('公司不能为空');
return false;
}
// setTimeout(function () {
// layer.msg('提交成功');
// }, 1000);
Fast.api.ajax({
url:'sx_basement/stationApply',
data:{
station_id:conditions_select,
station_date:station_date,
station_start_time:station_start_time,
station_end_time:station_end_time,
station_user_count:station_user_count,
station_desc:station_desc,
station_type:apply_type,
enter_id:enter_id
}
},function (i,ret) {
if(ret.code == 1) {
setTimeout(function () {
layer.msg('提交成功');
location.href = ret.url ? ret.url : "/";
}, 1000);
}else{
return false;
}
});
});
//选择时间切换工位数据
// $(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"),
... ...