|
|
|
define(['jquery', 'bootstrap', 'frontend', 'form', 'template', 'swiper', 'layer', 'layui'], function ($, undefined, Frontend,
|
|
|
|
Form, Template, Swiper, Layer, layui) {
|
|
|
|
var Controller = {
|
|
|
|
index: function () {
|
|
|
|
require(['upload'], function (Upload) {
|
|
|
|
// console.log(true)
|
|
|
|
var first_swiper = new Swiper('#first_swiper', {
|
|
|
|
loop: true, // 循环模式选项
|
|
|
|
// 如果需要分页器
|
|
|
|
autoplay: true,
|
|
|
|
pagination: {
|
|
|
|
el: '.swiper-pagination',
|
|
|
|
}
|
|
|
|
})
|
|
|
|
Upload.api.upload($('#btn-upload'));
|
|
|
|
$(".defaultOption").click(function(){
|
|
|
|
$(this).parents(".myCollapse").find(".options").toggleClass("optionShow")
|
|
|
|
})
|
|
|
|
$(".options .option").click(function(){
|
|
|
|
$(this).parents(".myCollapse").find(".defaultOption text").text($(this).text())
|
|
|
|
|
|
|
|
$(".options").removeClass("optionShow")
|
|
|
|
})
|
|
|
|
$(".add").click(function () {
|
|
|
|
var len = $(".list").length + 1
|
|
|
|
$(".joiner").append(getPeopleItem(len))
|
|
|
|
})
|
|
|
|
function getPeopleItem(index) {
|
|
|
|
return `<div class="list">
|
|
|
|
<div>
|
|
|
|
<text>姓名</text>
|
|
|
|
<input type="text" />
|
|
|
|
<text>学号</text>
|
|
|
|
<input type="text" />
|
|
|
|
</div>
|
|
|
|
</div>`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
function getBeforeDate(n){//n为你要传入的参数,当前为0,前一天为-1,后一天为1
|
|
|
|
var date = new Date() ;
|
|
|
|
var year,month,day ;
|
|
|
|
date.setDate(date.getDate()+n);
|
|
|
|
year = date.getFullYear();
|
|
|
|
month = date.getMonth()+1;
|
|
|
|
day = date.getDate() ;
|
|
|
|
s = year + '-' + ( month < 10 ? ( '0' + month ) : month ) + '-' + ( day < 10 ? ( '0' + day ) : day) ;
|
|
|
|
return s ;
|
|
|
|
}
|
|
|
|
layui.use('element', function () {
|
|
|
|
var $ = layui.jquery
|
|
|
|
, element = layui.element;
|
|
|
|
});
|
|
|
|
layui.use('laydate', function(){
|
|
|
|
var laydate = layui.laydate;
|
|
|
|
laydate.render({
|
|
|
|
elem: '#apply_date',
|
|
|
|
type: 'date',
|
|
|
|
min:0,
|
|
|
|
max:getBeforeDate(7)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
layui.use('laydate', function(){
|
|
|
|
var laydate = layui.laydate;
|
|
|
|
laydate.render({
|
|
|
|
elem: '#test10'
|
|
|
|
,type: 'datetime'
|
|
|
|
,range: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$(".showdetial").click(function () {
|
|
|
|
$(this).parents(".outter").addClass("detial")
|
|
|
|
$(this).parents(".outter").siblings().removeClass("detial")
|
|
|
|
})
|
|
|
|
$(".change").click(function(){
|
|
|
|
$(this).parents(".inner").addClass("detial")
|
|
|
|
$(this).parents(".inner").siblings().removeClass("detial")
|
|
|
|
})
|
|
|
|
$(".back").click(function(){
|
|
|
|
$(this).parents(".inner").addClass("detial")
|
|
|
|
$(this).parents(".inner").siblings().removeClass("detial")
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 房间预约
|
|
|
|
*/
|
|
|
|
$(document).on('click','#build_type li:not(:first-child)',function(){
|
|
|
|
$(this).children('a').addClass("conditions_select");
|
|
|
|
$(this).siblings('li').children('a').removeClass("conditions_select");
|
|
|
|
|
|
|
|
var $bulidId = $(this).children('a').attr("data-id");
|
|
|
|
if($bulidId != '0') {
|
|
|
|
Fast.api.ajax({
|
|
|
|
url:'building/getFloorList',
|
|
|
|
data:{building_id:$bulidId}
|
|
|
|
},function (ret) {
|
|
|
|
if(ret) {
|
|
|
|
clear_floor();
|
|
|
|
var str = '';
|
|
|
|
$.each(ret,function(i,v) {
|
|
|
|
str +='<li><a title="'+v.floor_name+'" href="javascript:;" data-id="'+v.id+'">'+v.floor_name+'</a></li>';
|
|
|
|
});
|
|
|
|
$("#floor").append(str);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
clear_floor();
|
|
|
|
}
|
|
|
|
get_room();
|
|
|
|
});
|
|
|
|
|
|
|
|
$(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");
|
|
|
|
$(this).siblings('li').children('a').removeClass("conditions_select");
|
|
|
|
get_room();
|
|
|
|
});
|
|
|
|
//房间选择 不需要请求 房间接口
|
|
|
|
$(document).on('click','#room li:not(:first-child)',function(){
|
|
|
|
$(this).children('a').addClass("conditions_select");
|
|
|
|
$(this).siblings('li').children('a').removeClass("conditions_select");
|
|
|
|
})
|
|
|
|
|
|
|
|
//清除所有楼层
|
|
|
|
function clear_floor() {
|
|
|
|
var floor_lis = $("#floor li");
|
|
|
|
$.each(floor_lis,function(i,v) {
|
|
|
|
if(i > 1) {
|
|
|
|
$(this).remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//清除房间
|
|
|
|
function clear_room() {
|
|
|
|
var room_lis = $("#room li");
|
|
|
|
$.each(room_lis,function(i,v) {
|
|
|
|
if(i > 1) {
|
|
|
|
$(this).remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//查看检索条件 搜索可用房间
|
|
|
|
function get_room() {
|
|
|
|
var roomType = $("#room_type .conditions_select").attr("data-id"),
|
|
|
|
buildId = $("#build_type .conditions_select").attr("data-id"),
|
|
|
|
floorId = $("#floor .conditions_select").attr("data-id");
|
|
|
|
Fast.api.ajax({
|
|
|
|
url:'building/getRoomList',
|
|
|
|
data:{room_type:roomType,building_id:buildId,floor_id:floorId}
|
|
|
|
},function (ret) {
|
|
|
|
if(ret) {
|
|
|
|
clear_room();
|
|
|
|
var str = '';
|
|
|
|
$.each(ret,function(i,v) {
|
|
|
|
str +='<li><a title="'+v.room_name+'" href="javascript:;" data-id="'+v.id+'">'+v.room_name+'</a></li>';
|
|
|
|
});
|
|
|
|
$("#room").append(str);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).on('click',"#commit_build",function(){
|
|
|
|
var room_id = $("#room .conditions_select").attr("data-id"),
|
|
|
|
apply_date = $("input[name='apply_date']").val(),
|
|
|
|
use_count = $("input[name='use_count']").val(),
|
|
|
|
start_time = $(".start_time option:selected").val(),
|
|
|
|
end_time = $(".end_time option:selected").val(),
|
|
|
|
apply_desc = $("#apply_desc").val();
|
|
|
|
apply_type = $(".apply_type option:selected").val();
|
|
|
|
if(room_id == '0') {
|
|
|
|
layer.msg('请选择房间');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(apply_date =='') {
|
|
|
|
layer.msg('请选择预约日期');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(start_time == '') {
|
|
|
|
layer.msg('请选择预约开始时间');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(end_time == '') {
|
|
|
|
layer.msg('请选择预约结束时间');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(use_count == '') {
|
|
|
|
layer.msg('使用人数不能为空');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Fast.api.ajax({
|
|
|
|
url:'building/roomApply',
|
|
|
|
data:{room_id:room_id,apply_date:apply_date,start_time:start_time,end_time:end_time,apply_desc:apply_desc,apply_type:apply_type,use_count:use_count}
|
|
|
|
},function (i,ret) {
|
|
|
|
if(ret.code == 1) {
|
|
|
|
setTimeout(function () {
|
|
|
|
location.href = ret.url ? ret.url : "/";
|
|
|
|
}, 1000);
|
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return Controller;
|
|
|
|
}); |
|
|
|
define(['jquery', 'bootstrap', 'frontend', 'form', 'template', 'swiper', 'layer', 'layui'], function ($, undefined, Frontend,
|
|
|
|
Form, Template, Swiper, Layer, layui) {
|
|
|
|
var Controller = {
|
|
|
|
index: function () {
|
|
|
|
require(['upload'], function (Upload) {
|
|
|
|
// console.log(true)
|
|
|
|
var first_swiper = new Swiper('#first_swiper', {
|
|
|
|
loop: true, // 循环模式选项
|
|
|
|
// 如果需要分页器
|
|
|
|
autoplay: true,
|
|
|
|
pagination: {
|
|
|
|
el: '.swiper-pagination',
|
|
|
|
}
|
|
|
|
})
|
|
|
|
Upload.api.upload($('#btn-upload'));
|
|
|
|
$(".defaultOption").click(function(){
|
|
|
|
$(this).parents(".myCollapse").find(".options").toggleClass("optionShow")
|
|
|
|
})
|
|
|
|
$(".options .option").click(function(){
|
|
|
|
$(this).parents(".myCollapse").find(".defaultOption text").text($(this).text())
|
|
|
|
|
|
|
|
$(".options").removeClass("optionShow")
|
|
|
|
})
|
|
|
|
$(".add").click(function () {
|
|
|
|
var len = $(".list").length + 1
|
|
|
|
$(".joiner").append(getPeopleItem(len))
|
|
|
|
})
|
|
|
|
function getPeopleItem(index) {
|
|
|
|
return `<div class="list">
|
|
|
|
<div>
|
|
|
|
<text>姓名</text>
|
|
|
|
<input type="text" />
|
|
|
|
<text>学号</text>
|
|
|
|
<input type="text" />
|
|
|
|
</div>
|
|
|
|
</div>`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
function getBeforeDate(n){//n为你要传入的参数,当前为0,前一天为-1,后一天为1
|
|
|
|
var date = new Date() ;
|
|
|
|
var year,month,day ;
|
|
|
|
date.setDate(date.getDate()+n);
|
|
|
|
year = date.getFullYear();
|
|
|
|
month = date.getMonth()+1;
|
|
|
|
day = date.getDate() ;
|
|
|
|
s = year + '-' + ( month < 10 ? ( '0' + month ) : month ) + '-' + ( day < 10 ? ( '0' + day ) : day) ;
|
|
|
|
return s ;
|
|
|
|
}
|
|
|
|
layui.use('element', function () {
|
|
|
|
var $ = layui.jquery
|
|
|
|
, element = layui.element;
|
|
|
|
});
|
|
|
|
layui.use('laydate', function(){
|
|
|
|
var laydate = layui.laydate;
|
|
|
|
laydate.render({
|
|
|
|
elem: '#apply_date',
|
|
|
|
type: 'date',
|
|
|
|
min:0,
|
|
|
|
max:getBeforeDate(7)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
layui.use('laydate', function(){
|
|
|
|
var laydate = layui.laydate;
|
|
|
|
laydate.render({
|
|
|
|
elem: '#station_date',
|
|
|
|
type: 'date',
|
|
|
|
min:0,
|
|
|
|
max:getBeforeDate(7)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
layui.use('laydate', function(){
|
|
|
|
var laydate = layui.laydate;
|
|
|
|
laydate.render({
|
|
|
|
elem: '#test10'
|
|
|
|
,type: 'datetime'
|
|
|
|
,range: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$(".showdetial").click(function () {
|
|
|
|
$(this).parents(".outter").addClass("detial")
|
|
|
|
$(this).parents(".outter").siblings().removeClass("detial")
|
|
|
|
})
|
|
|
|
$(".change").click(function(){
|
|
|
|
$(this).parents(".inner").addClass("detial")
|
|
|
|
$(this).parents(".inner").siblings().removeClass("detial")
|
|
|
|
})
|
|
|
|
$(".back").click(function(){
|
|
|
|
$(this).parents(".inner").addClass("detial")
|
|
|
|
$(this).parents(".inner").siblings().removeClass("detial")
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 房间预约
|
|
|
|
*/
|
|
|
|
$(document).on('click','#build_type li:not(:first-child)',function(){
|
|
|
|
$(this).children('a').addClass("conditions_select");
|
|
|
|
$(this).siblings('li').children('a').removeClass("conditions_select");
|
|
|
|
|
|
|
|
var $bulidId = $(this).children('a').attr("data-id");
|
|
|
|
if($bulidId != '0') {
|
|
|
|
Fast.api.ajax({
|
|
|
|
url:'building/getFloorList',
|
|
|
|
data:{building_id:$bulidId}
|
|
|
|
},function (ret) {
|
|
|
|
if(ret) {
|
|
|
|
clear_floor();
|
|
|
|
var str = '';
|
|
|
|
$.each(ret,function(i,v) {
|
|
|
|
str +='<li><a title="'+v.floor_name+'" href="javascript:;" data-id="'+v.id+'">'+v.floor_name+'</a></li>';
|
|
|
|
});
|
|
|
|
$("#floor").append(str);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
clear_floor();
|
|
|
|
}
|
|
|
|
get_room();
|
|
|
|
});
|
|
|
|
|
|
|
|
//工位
|
|
|
|
$(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','#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");
|
|
|
|
$(this).siblings('li').children('a').removeClass("conditions_select");
|
|
|
|
get_room();
|
|
|
|
});
|
|
|
|
|
|
|
|
//清除所有楼层
|
|
|
|
function clear_floor() {
|
|
|
|
var floor_lis = $("#floor li");
|
|
|
|
$.each(floor_lis,function(i,v) {
|
|
|
|
if(i > 1) {
|
|
|
|
$(this).remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//清除房间
|
|
|
|
function clear_room() {
|
|
|
|
var room_lis = $("#room li");
|
|
|
|
$.each(room_lis,function(i,v) {
|
|
|
|
if(i > 1) {
|
|
|
|
$(this).remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//查看检索条件 搜索可用房间
|
|
|
|
function get_room() {
|
|
|
|
var roomType = $("#room_type .conditions_select").attr("data-id"),
|
|
|
|
buildId = $("#build_type .conditions_select").attr("data-id"),
|
|
|
|
floorId = $("#floor .conditions_select").attr("data-id");
|
|
|
|
Fast.api.ajax({
|
|
|
|
url:'building/getRoomList',
|
|
|
|
data:{room_type:roomType,building_id:buildId,floor_id:floorId}
|
|
|
|
},function (ret) {
|
|
|
|
if(ret) {
|
|
|
|
clear_room();
|
|
|
|
var str = '';
|
|
|
|
$.each(ret,function(i,v) {
|
|
|
|
str +='<li><a title="'+v.room_name+'" href="javascript:;" data-id="'+v.id+'">'+v.room_name+'</a></li>';
|
|
|
|
});
|
|
|
|
$("#room").append(str);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
$(document).on('click',"#commit_station",function(){
|
|
|
|
var conditions_select = $("#stations .conditions_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();
|
|
|
|
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) {
|
|
|
|
layer.msg('请选择预约日期');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(!station_start_time) {
|
|
|
|
layer.msg('请选择预约开始时间');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(!station_end_time) {
|
|
|
|
layer.msg('请选择预约结束时间');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(station_user_count == '') {
|
|
|
|
layer.msg('使用人数不能为空');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
setTimeout(function () {
|
|
|
|
layer.msg('提交成功');
|
|
|
|
}, 1000);
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('click',"#commit_build",function(){
|
|
|
|
var room_id = $("#room .conditions_select").attr("data-id"),
|
|
|
|
apply_date = $("input[name='apply_date']").val(),
|
|
|
|
use_count = $("input[name='use_count']").val(),
|
|
|
|
start_time = $(".start_time option:selected").val(),
|
|
|
|
end_time = $(".end_time option:selected").val(),
|
|
|
|
apply_desc = $("#apply_desc").val();
|
|
|
|
apply_type = $(".apply_type option:selected").val();
|
|
|
|
if(room_id == '0') {
|
|
|
|
layer.msg('请选择房间');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(apply_date =='') {
|
|
|
|
layer.msg('请选择预约日期');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(start_time == '') {
|
|
|
|
layer.msg('请选择预约开始时间');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(end_time == '') {
|
|
|
|
layer.msg('请选择预约结束时间');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(use_count == '') {
|
|
|
|
layer.msg('使用人数不能为空');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Fast.api.ajax({
|
|
|
|
url:'building/roomApply',
|
|
|
|
data:{room_id:room_id,apply_date:apply_date,start_time:start_time,end_time:end_time,apply_desc:apply_desc,apply_type:apply_type,use_count:use_count}
|
|
|
|
},function (i,ret) {
|
|
|
|
if(ret.code == 1) {
|
|
|
|
setTimeout(function () {
|
|
|
|
location.href = ret.url ? ret.url : "/";
|
|
|
|
}, 1000);
|
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return Controller;
|
|
|
|
}); |
...
|
...
|
|