sx_basement.js
6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
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;
});