export-data.js
var timeBtnClick = (function() {
function _todayClick() {
$('.select-time .today').on('click', function() {
$('#export-date-start-time').val(countDate.getDate(0));
$('#export-date-end-time').val(countDate.getDate(-1));
});
} function _yesterdayClick() {
$('.select-time .yesterday').on('click', function(){
$('#export-date-start-time').val(countDate.getDate(1));
$('#export-date-end-time').val(countDate.getDate(0));
});
} function _sevenClick() {
$('.select-time .recent-seven-days').on('click', function(){
$('#export-date-start-time').val(countDate.getDate(7));
$('#export-date-end-time').val(countDate.getDate(0));
});
} function _thirtyClick() {
$('.select-time .recent-thirty-days').on('click', function(){
$('#export-date-start-time').val(countDate.getDate(30));
$('#export-date-end-time').val(countDate.getDate(0));
});
} return {
init: function() {
_todayClick();
_yesterdayClick();
_sevenClick();
_thirtyClick();
}
};
})(); var countDate = (function() {
function getDate(days) {
var now = new Date(),
newDate = new Date(now.getTime() - 86400000 * days),
yyyy = newDate.getFullYear(),
mm = (newDate.getMonth() + 1) < 9 ? '0' + (newDate.getMonth() + 1) : newDate.getMonth() + 1,
dd = newDate.getDate() < 9 ? '0' + newDate.getDate() : newDate.getDate();
return (yyyy + '-' + mm + '-' + dd + ' 00:00');
}
return {
getDate: getDate
};
})(); var inputInit = (function() {
function _initPlaceholder() {
$('.export-date-time').placeholder();
}
function _initTimepicker() {
$('.export-date-time').datetimepicker({
dateFormat : "yy-mm-dd",
timeFormat : "HH:mm"
}).placeholder();
}
return {
init: function() {
_initPlaceholder();
_initTimepicker();
}
};
})(); var exportBtnClick = (function() {
function _initExportBtnClick() {
$('.export-data-container').on('click', ".export-data-btn:not('.disabled-btn')", function(){
$this = $(this);
$('.error-msg').hide();
$this.find('.loading-icon').hide();
var startTime = $('#export-date-start-time').val(),
endTime = $('#export-date-end-time').val(),
dataType = $this.data('type'),
timeErrorMsg = $('.time-error-msg');
if (startTime > endTime) {
timeErrorMsg.html(reminder_message.please_choose_correct_time);
timeErrorMsg.show();
return;
} else {
timeErrorMsg.hide();
} if (!startTime || !endTime) {
timeErrorMsg.html(reminder_message.please_choose_time);
timeErrorMsg.show();
return;
} else {
timeErrorMsg.hide();
}
$('.export-data-btn').addClass('disabled-btn');
$this.find('.loading-icon').css('display', 'inline-block');
ifContinue = true;
check_export($this, dataType, startTime, endTime, ifContinue);
});
}
function check_export($this, dataType, startTime, endTime, ifContinue) {
var taskId = $this.data('task-id') ? $this.data('task-id') : '',
xlsFileLink = $('#xls-file-link'),
loadingIcon = $this.find('.loading-icon'),
exportDataBtn = $('.export-data-btn');
if (ifContinue) {
$.ajax({
type: 'GET',
url: '/export-data?startTime=' + startTime + '&endTime=' + endTime + '&dataType=' + dataType + '&taskId=' + taskId,
dataType: 'JSON',
success: function(data){
if (data.error_msg) {
if_continue = false;
$this.data('task-id', '');
$('.time-error-msg').show();
loadingIcon.hide();
exportDataBtn.removeClass('disabled-btn');
} if (data.xls_name) {
ifContinue = false;
xlsFileLink.attr('href', '/media/' + data.xls_name);
xlsFileLink[0].click();
xlsFileLink.removeAttr('href');
$this.data('task-id', '');
loadingIcon.hide();
exportDataBtn.removeClass('disabled-btn');
} else if (data.task_id) {
$this.data('task-id', data.task_id);
} },
error: function(e){
if_continue = false;
$this.data('task-id', '');
$this.next('.error-msg').show();
loadingIcon.hide();
exportDataBtn.removeClass('disabled-btn');
}
});
t = setTimeout(function(){
console.log("Looping to query.");
check_export($this, dataType, startTime, endTime, ifContinue);
}, 1000);
} }
return {
init: _initExportBtnClick
};
})(); $(document).ready(function(){
timeBtnClick.init();
inputInit.init();
exportBtnClick.init();
});
export-data.js的更多相关文章
- NetSuite SuiteScript 2.0 export data to Excel file(xls)
In NetSuite SuiteScript, We usually do/implement export data to CSV, that's straight forward: Collec ...
- Export Data from mysql Workbench 6.0
原文地址:export-data-from-mysql-workbench-6-0 问题描述 I'm trying to export my database, using MySQL Workben ...
- How to export data from Thermo-Calc 如何从Thermo-calc导出文本数据
记录20180510 问题:如何从thermo-calc导出文本数据供origin绘图? 解决: In Thermo-Calc graphical mode, you can just add a ' ...
- import downloadjs from 'downloadjs' 如果是自己写的函数 没用默认导出 记得加花括号 例如 import { download } from './data.js'
import downloadjs from 'downloadjs' 如果是自己写的函数 没用默认导出 记得加花括号 例如 import { download } from './data.js'
- 1.3 Quick Start中 Step 7: Use Kafka Connect to import/export data官网剖析(博主推荐)
不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 7: Use Kafka Connect to import/export ...
- how to use Sqoop to import/ export data
Sqoop is a tool designed for efficiently transferring data between RDBMS and HDFS, we can import dat ...
- asp and javascript: sql server export data to csv and to xls
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> <% //塗聚文 //20131021 functio ...
- Use excel Macro export data from database
Sub DownLoadMacro() '定义过程名称 Dim i As Integer, j As Integer, sht As Worksheet 'i,j为整数变量:sht 为excel工作表 ...
- C# Note38: Export data into Excel
Microsoft.Office.Interop.Excel You have to have Excel installed. Add a reference to your project to ...
- CASSANDRA How to import and export data
https://docs.datastax.com/en/cql/3.1/cql/cql_reference/copy_r.html 感谢领导,感谢同事,与其自己百思不得其解,不如一个问题就搞定了. ...
随机推荐
- UVA 12169 Disgruntled Judge
我该怎么说这道题呢...说简单其实也简单,就枚举模拟,开始卡了好久,今天看到这题没a又写了遍,看似会超时的代码交上去a了,果然实践是检验真理的唯一标准... #include <iostream ...
- 给div中动态添加节点并设置样式
前端IOS今天需要动态的在图片前面添加一个按钮 主要是在使用 bt.setAttribute("class","aaa"); 可以对创建的节点使用setAttr ...
- [TYVJ] P1003 越野跑
越野跑 背景 Background 成成第一次模拟赛 第二道 描述 Description 为了能在下一次跑步比赛中有好的发挥,贝茜在一条山路上开始了她的训练.贝茜希望能在每次训练中跑 ...
- 安装wampserver2时出现的问题
提示丢失MSVCR100.dll 如果安装其他软件也是同样的提示情况,估计也是这个原因,以下分别是32位与64位的VC10下载地址: VC10 SP1 vcredist_x86.exe 32 bits ...
- Qt基于FFmpeg播放本地 H.264(H264)文件(灿哥哥的博客)
最近在弄H264的硬件编解码,基于DM3730,但是为了调试方便,在小红帽上用FFmpeg实现了H264的软件编解码.现在弄了一个Windows的例子,给需要的同学参考一下,如果大家觉得有帮助,可以小 ...
- 开发反模式 - SQL注入
一.目标:编写SQL动态查询 SQL常常和程序代码一起使用.我们通常所说的SQL动态查询,是指将程序中的变量和基本SQL语句拼接成一个完整的查询语句. string sql = SELECT * FR ...
- UML--建模
建模公式 这种精华的东西,一定是值得研读和实践的! myself:人,事,物,规则. 人,业务主角.业务工人.参与者.如果应用到教务系统中,就是管理员,主任,老师的关系. 事,业务用例,系统用例. 物 ...
- 【转】CTS tests 4.2_r4
原文网址:http://www.xuebuyuan.com/1722006.html Precondition: 1.Get android sdk 2.Set adb to environment ...
- hdu3410-Passing the Message(RMQ,感觉我写的有点多此一举。。。其实可以用单调栈)
What a sunny day! Let’s go picnic and have barbecue! Today, all kids in “Sun Flower” kindergarten ar ...
- FlexComboBoxTree
在我的CSDN资源中有项目工程文件.下载导入工程即可看到效果,下面是地址. http://download.csdn.net/detail/cym_lmy/6326053 MyCombBoxTree1 ...