|
|
|
@ -1,26 +1,37 @@
|
|
|
|
|
<form class="management-school-data-form">
|
|
|
|
|
<div style="float: left; margin: 10px 10px 10px 25px;">
|
|
|
|
|
<!-- 数据对比 -->
|
|
|
|
|
<%= hidden_field_tag :contrast_column, params[:contrast_column] %>
|
|
|
|
|
<%= hidden_field_tag :begin_date, params[:begin_date] %>
|
|
|
|
|
<%= hidden_field_tag :end_date, params[:end_date] %>
|
|
|
|
|
<%= hidden_field_tag :other_begin_date, params[:other_begin_date] %>
|
|
|
|
|
<%= hidden_field_tag :other_end_date, params[:other_end_date] %>
|
|
|
|
|
<!-- 新增数据 -->
|
|
|
|
|
<%= hidden_field_tag :grow_begin_date, params[:grow_begin_date] %>
|
|
|
|
|
<%= hidden_field_tag :grow_end_date, params[:grow_end_date] %>
|
|
|
|
|
|
|
|
|
|
<%= text_field_tag :date_input, params[:date_input],
|
|
|
|
|
class: 'date-input winput-200-30', placeholder: '请选择时间段一' %>
|
|
|
|
|
<span>VS</span>
|
|
|
|
|
<%= text_field_tag :other_date_input, params[:other_date_input],
|
|
|
|
|
class: 'other-date-input winput-200-30', placeholder: '请选择时间段二' %>
|
|
|
|
|
<div class="grow-date-container" style="width: 450px;display: <%= params[:data_type] == 'grow' ? 'block' : 'none' %>">
|
|
|
|
|
<%= text_field_tag :grow_date_input, params[:grow_date_input],
|
|
|
|
|
class: 'grow-date-input winput-220-30', placeholder: '请选择时间段',
|
|
|
|
|
style: 'width: 400px;' %>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="contrast-date-container" style="width: 450px;display: <%= params[:data_type] == 'contrast' ? 'block' : 'none' %>">
|
|
|
|
|
<%= text_field_tag :date_input, params[:date_input],
|
|
|
|
|
class: 'date-input winput-200-30', placeholder: '请选择时间段一' %>
|
|
|
|
|
<span>VS</span>
|
|
|
|
|
<%= text_field_tag :other_date_input, params[:other_date_input],
|
|
|
|
|
class: 'other-date-input winput-200-30', placeholder: '请选择时间段二' %>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div style="float: left;">
|
|
|
|
|
<%= hidden_field_tag :data_type, params[:data_type] || 'yesterday' %>
|
|
|
|
|
<%= hidden_field_tag :data_type, params[:data_type] || 'grow' %>
|
|
|
|
|
<% if params[:data_type] == 'contrast' %>
|
|
|
|
|
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 contrast-btn task-btn-orange">时间对比</a>
|
|
|
|
|
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 yesterday-btn">日新增</a>
|
|
|
|
|
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 grow-btn">新增数据</a>
|
|
|
|
|
<% else %>
|
|
|
|
|
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 contrast-btn">时间对比</a>
|
|
|
|
|
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 yesterday-btn task-btn-orange">日新增</a>
|
|
|
|
|
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 grow-btn task-btn-orange">新增数据</a>
|
|
|
|
|
<% end %>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
@ -31,28 +42,36 @@
|
|
|
|
|
</form>
|
|
|
|
|
<script>
|
|
|
|
|
$(function(){
|
|
|
|
|
var yesterdayFormUrl = "<%= school_yesterday_data_managements_path %>";
|
|
|
|
|
var growFormUrl = "<%= school_data_grow_managements_path %>";
|
|
|
|
|
var contrastFormUrl = "<%= school_data_contrast_managements_path %>";
|
|
|
|
|
|
|
|
|
|
var searchForm = $(".management-school-data-form");
|
|
|
|
|
var dataTypeInput = searchForm.find("input[name='data_type']");
|
|
|
|
|
var keywordInput = searchForm.find("input[name='keyword']");
|
|
|
|
|
var contrastBtn = searchForm.find(".contrast-btn");
|
|
|
|
|
var yesterdayBtn = searchForm.find(".yesterday-btn");
|
|
|
|
|
var growBtn = searchForm.find(".grow-btn");
|
|
|
|
|
var contrastDateContainer = searchForm.find('.contrast-date-container');
|
|
|
|
|
var growDateContainer = searchForm.find('.grow-date-container');
|
|
|
|
|
|
|
|
|
|
// 数据对比日期输入框
|
|
|
|
|
var beginDateInput = searchForm.find("input[name='begin_date']");
|
|
|
|
|
var endDateInput = searchForm.find("input[name='end_date']");
|
|
|
|
|
var otherBeginDateInput = searchForm.find("input[name='other_begin_date']");
|
|
|
|
|
var otherEndDateInput = searchForm.find("input[name='other_end_date']");
|
|
|
|
|
|
|
|
|
|
// 数据展示切换: 数据对比、日新增
|
|
|
|
|
// 新增数据日期输入框
|
|
|
|
|
var growBeginDateInput = searchForm.find("input[name='grow_begin_date']");
|
|
|
|
|
var growEndDateInput = searchForm.find("input[name='grow_end_date']");
|
|
|
|
|
|
|
|
|
|
// 数据展示切换: 数据对比、新增数据
|
|
|
|
|
searchForm.on('click', ".contrast-btn", function(){
|
|
|
|
|
if(contrastBtn.hasClass("task-btn-orange")) { return }
|
|
|
|
|
changeDataType("contrast");
|
|
|
|
|
submitForm();
|
|
|
|
|
});
|
|
|
|
|
searchForm.on('click', ".yesterday-btn", function(){
|
|
|
|
|
if(yesterdayBtn.hasClass("task-btn-orange")) { return }
|
|
|
|
|
changeDataType("yesterday");
|
|
|
|
|
searchForm.on('click', ".grow-btn", function(){
|
|
|
|
|
if(growBtn.hasClass("task-btn-orange")) { return }
|
|
|
|
|
changeDataType("grow");
|
|
|
|
|
submitForm();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -74,7 +93,7 @@
|
|
|
|
|
if(!validateFrom()) { return }
|
|
|
|
|
|
|
|
|
|
var form = searchForm;
|
|
|
|
|
var url = dataTypeInput.val() == "contrast" ? contrastFormUrl : yesterdayFormUrl;
|
|
|
|
|
var url = dataTypeInput.val() == "contrast" ? contrastFormUrl : growFormUrl;
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: url,
|
|
|
|
@ -86,12 +105,18 @@
|
|
|
|
|
var validateFrom = function(){
|
|
|
|
|
if (dataTypeInput.val() != "contrast") { return true; }
|
|
|
|
|
|
|
|
|
|
if (beginDateInput.val() == "" || endDateInput.val() == "" ||
|
|
|
|
|
otherBeginDateInput.val() == "" || otherBeginDateInput.val() == "") {
|
|
|
|
|
return false;
|
|
|
|
|
// 全部为空时,需要展示空数据页
|
|
|
|
|
if (beginDateInput.val() == "" && endDateInput.val() == "" &&
|
|
|
|
|
otherBeginDateInput.val() == "" && otherBeginDateInput.val() == "") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (beginDateInput.val() != "" && endDateInput.val() != "" &&
|
|
|
|
|
otherBeginDateInput.val() != "" && otherBeginDateInput.val() != "") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var changeDataType = function(dataType){
|
|
|
|
@ -99,17 +124,29 @@
|
|
|
|
|
|
|
|
|
|
if (dataType == "contrast") {
|
|
|
|
|
contrastBtn.addClass("task-btn-orange");
|
|
|
|
|
yesterdayBtn.removeClass("task-btn-orange");
|
|
|
|
|
growBtn.removeClass("task-btn-orange");
|
|
|
|
|
dataTypeInput.val('contrast');
|
|
|
|
|
growDateContainer.hide();
|
|
|
|
|
contrastDateContainer.show();
|
|
|
|
|
|
|
|
|
|
clearGrowDateInput();
|
|
|
|
|
} else {
|
|
|
|
|
contrastBtn.removeClass("task-btn-orange");
|
|
|
|
|
yesterdayBtn.addClass("task-btn-orange");
|
|
|
|
|
dataTypeInput.val('yesterday');
|
|
|
|
|
growBtn.addClass("task-btn-orange");
|
|
|
|
|
dataTypeInput.val('grow');
|
|
|
|
|
growDateContainer.show();
|
|
|
|
|
contrastDateContainer.hide();
|
|
|
|
|
|
|
|
|
|
clearContrastDateInput();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var clearGrowDateInput = function() {
|
|
|
|
|
searchForm.find("input[name='grow_begin_date']").val('');
|
|
|
|
|
searchForm.find("input[name='grow_end_date']").val('');
|
|
|
|
|
searchForm.find("input[name='grow_date_input']").val('');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var clearContrastDateInput = function(){
|
|
|
|
|
searchForm.find("input[name='begin_date']").val('');
|
|
|
|
|
searchForm.find("input[name='end_date']").val('');
|
|
|
|
@ -152,10 +189,13 @@
|
|
|
|
|
isRTL: false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
var baseOptions = {
|
|
|
|
|
dateFormat: 'yy-mm-dd',
|
|
|
|
|
minDate: new Date('2017-04-01'),
|
|
|
|
|
maxDate: -1,
|
|
|
|
|
maxDate: -1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var contrastDateOptions = {
|
|
|
|
|
onSelect: function(selectedDate) {
|
|
|
|
|
if(!$(this).data().datepicker.first){
|
|
|
|
|
$(this).data().datepicker.inline = true;
|
|
|
|
@ -192,9 +232,6 @@
|
|
|
|
|
// 展示所选时间
|
|
|
|
|
$(this).val(begin_date + " 至 " + end_date);
|
|
|
|
|
$(this).data().datepicker.inline = false;
|
|
|
|
|
|
|
|
|
|
// 切换数据类型
|
|
|
|
|
changeDataType("contrast");
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onClose:function(){
|
|
|
|
@ -216,8 +253,53 @@
|
|
|
|
|
submitForm();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
options = $.extend({}, locale, options);
|
|
|
|
|
searchForm.find(".date-input").datepicker(options);
|
|
|
|
|
searchForm.find(".other-date-input").datepicker(options);
|
|
|
|
|
contrastDateOptions = $.extend({}, locale, baseOptions, contrastDateOptions);
|
|
|
|
|
searchForm.find(".date-input").datepicker(contrastDateOptions);
|
|
|
|
|
searchForm.find(".other-date-input").datepicker(contrastDateOptions);
|
|
|
|
|
|
|
|
|
|
var growOptions = {
|
|
|
|
|
onSelect: function(selectedDate) {
|
|
|
|
|
if(!$(this).data().datepicker.first){
|
|
|
|
|
$(this).data().datepicker.inline = true;
|
|
|
|
|
$(this).data().datepicker.first = selectedDate;
|
|
|
|
|
|
|
|
|
|
growBeginDateInput.val("");
|
|
|
|
|
growEndDateInput.val("");
|
|
|
|
|
}else{
|
|
|
|
|
// 计算时间先后顺序
|
|
|
|
|
var begin_date = null;
|
|
|
|
|
var end_date = null;
|
|
|
|
|
if(selectedDate > $(this).data().datepicker.first){
|
|
|
|
|
begin_date = $(this).data().datepicker.first;
|
|
|
|
|
end_date = selectedDate;
|
|
|
|
|
}else{
|
|
|
|
|
begin_date = selectedDate;
|
|
|
|
|
end_date = $(this).data().datepicker.first;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
growBeginDateInput.val(begin_date);
|
|
|
|
|
growEndDateInput.val(end_date);
|
|
|
|
|
|
|
|
|
|
// 展示所选时间
|
|
|
|
|
$(this).val(begin_date + " 至 " + end_date);
|
|
|
|
|
$(this).data().datepicker.inline = false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onClose:function(){
|
|
|
|
|
var date = $(this).data().datepicker.first;
|
|
|
|
|
|
|
|
|
|
if (date && growBeginDateInput.val() == '') {
|
|
|
|
|
growBeginDateInput.val(date);
|
|
|
|
|
growEndDateInput.val(date);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete $(this).data().datepicker.first;
|
|
|
|
|
$(this).data().datepicker.inline = false;
|
|
|
|
|
|
|
|
|
|
submitForm();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
growOptions = $.extend({}, locale, baseOptions, growOptions)
|
|
|
|
|
searchForm.find(".grow-date-input").datepicker(growOptions);
|
|
|
|
|
});
|
|
|
|
|
</script>
|