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的更多相关文章

  1. 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 ...

  2. Export Data from mysql Workbench 6.0

    原文地址:export-data-from-mysql-workbench-6-0 问题描述 I'm trying to export my database, using MySQL Workben ...

  3. How to export data from Thermo-Calc 如何从Thermo-calc导出文本数据

    记录20180510 问题:如何从thermo-calc导出文本数据供origin绘图? 解决: In Thermo-Calc graphical mode, you can just add a ' ...

  4. import downloadjs from 'downloadjs' 如果是自己写的函数 没用默认导出 记得加花括号 例如 import { download } from './data.js'

    import downloadjs from 'downloadjs' 如果是自己写的函数 没用默认导出 记得加花括号 例如 import { download } from './data.js'

  5. 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 ...

  6. 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 ...

  7. asp and javascript: sql server export data to csv and to xls

    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%> <% //塗聚文 //20131021 functio ...

  8. Use excel Macro export data from database

    Sub DownLoadMacro() '定义过程名称 Dim i As Integer, j As Integer, sht As Worksheet 'i,j为整数变量:sht 为excel工作表 ...

  9. C# Note38: Export data into Excel

    Microsoft.Office.Interop.Excel You have to have Excel installed. Add a reference to your project to ...

  10. CASSANDRA How to import and export data

    https://docs.datastax.com/en/cql/3.1/cql/cql_reference/copy_r.html 感谢领导,感谢同事,与其自己百思不得其解,不如一个问题就搞定了. ...

随机推荐

  1. Lonely Integer

    https://www.hackerrank.com/challenges/lonely-integer def main(): n = int(raw_input()) s = dict() a = ...

  2. [0] Tornado Todo 开篇

    参考自: python: tornado例子 Github地址:tornado_todo 开发环境: Python包的安装: 首先安装 pip: sudo apt-get install python ...

  3. memcached在Windows下的安装

    memcached简介详情请谷歌.这里介绍如何在windows下安装. 1.下载     下载地址:http://download.csdn.net/detail/u010562988/9456109 ...

  4. smarty模板执行原理

    为了实现程序的业务逻辑和内容表现页面的分离从而提高开发速度,php 引入了模板引擎的概念,php 模板引擎里面最流行的可以说是smarty了,smarty因其功能强大而且速度快而被广大php web开 ...

  5. visual studio 中GIT的用法

    http://msdn.microsoft.com/zh-cn/library/vstudio/hh850445    Git 使用最新版:Git-1.8.4-preview20130916http: ...

  6. Python与MySQL首次交互

    前两天在工作之余研究了一下Python,对基础有了大致了解,就想拿她很MqSQL交互一下. 一开始就遇到了问题,要import MySQLdb,search发现有人说安装mysql-python,于是 ...

  7. hdu 5640 King's Cake(模拟)

    Problem Description   It is the king's birthday before the military parade . The ministers prepared ...

  8. python爬爬(网友提供学习)

    import urllib2,urllib,os,re def ZZ(url): pathw=os.getcwd() #图片和标题目录 imagetitleregion=r'<div class ...

  9. 45 个非常有用的 Oracle 查询语句(转)

    这里我们介绍的是 40+ 个非常有用的 Oracle 查询语句,主要涵盖了日期操作,获取服务器信息,获取执行状态,计算数据库大小等等方面的查询.这些是所有 Oracle 开发者都必备的技能,所以快快收 ...

  10. uva 310 L--system(隐式图搜索+字符串处理)

     L-system  A D0L (Deterministic Lindenmayer system without interaction) system consists of a finite ...