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 感谢领导,感谢同事,与其自己百思不得其解,不如一个问题就搞定了. ...
随机推荐
- php的一些小笔记--时间函数
strtotime 返回UNIX时间戳 .这个函数可以用来计算前天,昨天,后天,明天 例如明天:date('Y-m-d H:is',strtotime('+1 day')) day>1是复数 ...
- 重启电脑提示Error:no such partition grub rescue
我的系统是Win7,在使用Ubuntu12.04自带的Wubi.exe安装双系统时,系统提示重新启动计算机,重启后电脑就停留在了黑屏界面并提示: error:no such partition gru ...
- 几种TCP连接中出现RST的情况
http://blog.chinaunix.net/uid-24517549-id-3991141.html http://blog.chinaunix.net/uid-24517549-id-399 ...
- format %x invalid or incompatible with argument问题解决方法
现在还有好多朋友在用Protel 99se来画图,可是在现在的双核或四核电脑上运行Protel出现错误并且弹出对话框:“format '%x' invalid or incompatible with ...
- 《Programming WPF》翻译 第9章 6.我们进行到哪里了?
原文:<Programming WPF>翻译 第9章 6.我们进行到哪里了? 只有当任何内嵌控件都没有提供你需要的底层行为时,你将要写一个自定义控件.当你写一个自定义控件,你将要使用到依赖 ...
- 《Programming WPF》翻译 第8章 4.关键帧动画
原文:<Programming WPF>翻译 第8章 4.关键帧动画 到目前为止,我们只看到简单的点到点的动画.我们使用了To和From属性或者By属性来设计动画--相对于当前的属性值.这 ...
- java获得指定日期的前一天,后一天的代码
/** * 获得指定日期的前一天 * @param specifiedDay * @return * @throws Exception */ public static String getSpec ...
- poj3349(哈希+链地址法)
给出N个六边形的6个边长,问其中是否有完全相同的两个六边形,完全相同包括边的长度和位置都要相同.边给出的顺序是逆时针或者顺时针的. 给每个6边形一个哈希值,方法是对6条边长度的平方和取模 #inclu ...
- pod setup 报CocoaPods was not able to update the `master` repo 错误解决办法
先删除全局的缓存: $ sudo rm -fr ~/Library/Caches/CocoaPods/ $ sudo rm -fr ~/.cocoapods/repos/master/ 还不行的话就把 ...
- redis实现spring-data-redis整合
java之redis篇(spring-data-redis整合) 博客链接网址:http://www.cnblogs.com/yjmyzz/tag/redis/ redis的知识:官网 1,利用sp ...