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. 更快的方式实现PHP数组去重(转)

    概述 使用PHP的array_unique()函数允许你传递一个数组,然后移除重复的值,返回一个拥有唯一值的数组.这个函数大多数情况下都能工作得很好.但是,如果你尝试在一个大的数组里使用array_u ...

  2. gridview中判断隐藏还是现实

    <asp:TemplateField HeaderText="呼出" HeaderStyle-Width="60px" HeaderStyle-Horiz ...

  3. SpringMVC–SSH -- RESTful -- JSR303

    最近在使用SpringMVC+MyBatis感觉用起来效果很好.我不太明白SpringMVC和SSH的关系,遂搜索了一下.原来使用SpringMVC之后,可以替代之前的SSH这种开发模式. 附上知乎链 ...

  4. IOS 项目问题总结

    把自己项目中遇到的问题总结一下,供大家参考,希望大家多多提出意见!! 在Xcode 6.2中遇到Your build settings specify a provisioning profile w ...

  5. ng-repeat-start ng-repeat-end 的使用

    ng-repeat-start与ng-repeat-end时AngularJS(1.2.x)扩展的, 使用这两个指令可以灵活控制遍历形式. 例如: index.html <div class=& ...

  6. Magento How To Display Product Custom Option On list.phtml

    Some time we need to display custom option of product on category list page to achive this task we o ...

  7. Android_Studio常用插件

    Android studio常用插件,可极大简化开发,增强开发效率. 不懂安装studio插件,看参考博文:android stuido插件安装:http://blog.csdn.net/liang5 ...

  8. Find Successor & Predecessor in BST

    First, we use recursive way. Successor public class Solution { public TreeNode inorderSuccessor(Tree ...

  9. 我为什么放弃Go语言

    有好几次,当我想起来的时候,总是会问自己:我为什么要放弃Go语言?这个决定是正确的吗?是明智和理性的吗?事实上我一直在认真思考这个问题. 开门见山地说,我当初放弃Go语言(golang),就是由于两个 ...

  10. 机房收费系统中的Grid++Report报表设计器的应用

    在进行账单查询功能的时候我应用了Grid++Report报表设计器,下面我就为大家介绍一下,还望大家多多指点. 首先,在Grid++Report报表设计器中进行报表界面的设置.在属性编辑窗口中这里对报 ...