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 感谢领导,感谢同事,与其自己百思不得其解,不如一个问题就搞定了. ...
随机推荐
- 有关service
在symfony2 服务注入容器的时候参数语法可以是这样: cellcom.twig.menu_extension: class: Cellcom\WebBundle\Twig\Extension\M ...
- c# 高效分页只需一个dll实例
第一.首先下载WebUIControl.dll http://pan.baidu.com/s/1gdkilDh 第二.添加引用 三.应用实例-前台代码 <%@ Register Assembly ...
- window系统查看端口被哪个进程占用
---恢复内容开始--- 1.在cmd窗口运行 netstat -ano | findstr 1099 找到进程PID 8408 杀死进程:taskkill -F -PID 8408 2.另外还找到进 ...
- VC6-Win7下VC++6.0打开多个工程的设置
在Win7操作系统下,如果是以Administrator登陆,则VC6.0打开工程文件的时候,不能同时打开多个工程文件,后打开的工程会将前一个工程close掉,这样,VC6.0只能出现一个进程.在xp ...
- UltraChart画柱状图上面显示数值
http://www.cnblogs.com/kevin-h-wang/archive/2013/06/05/UltraChart.html 1.柱状图上显示数值 ? //第一种方法 this.Ult ...
- Android中ListView嵌套GridView的简单消息流UI(解决宽高问题)
最近搞一个项目,需要用到类似于新浪微博的消息流,即每一项有文字.有九宫格图片,因此这就涉及到ListView或者ScrollView嵌套GridView的问题.其中GridView的高度问题在网上都很 ...
- 【转】(总结)Linux下su与su -命令的本质区别
原文网址:http://www.ha97.com/4001.html 本人以前一直习惯直接使用root,很少使用su,前几天才发现su与su -命令是有着本质区别的! 大部分Linux发行版的默认账户 ...
- UESTC_王之盛宴 2015 UESTC Training for Graph Theory<Problem K>
K - 王之盛宴 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit ...
- 《Java程序员面试笔试宝典》之字符串创建与存储的机制是什么
在Java语言中,字符串起着非常重要的作用,字符串的声明与初始化主要有如下两种情况: (1) 对于String s1=new String("abc")语句与Strin ...
- 【转】ffserver用法小结
我们可以通过ffserver以及ffmpeg做一个简单的视频监控系统,ffserver用于视频的转发调度,ffmpeg用于转码 而对于ffserver最基本也是最重要的就是对它的ffserver.co ...