php+ajax实现带进度条的大数据排队导出思路以及源(5)

/* AJAX,递归调用 */
function excel_export_ajax(index, num, processnum, tabletype)
{
    $.ajax({
        url: "<?php echo WEB_URL;?>/index.php?q=onlinesea/exportcsv"+search_uri+"/index/"+index+ "/total/" + num + '/tabletype/' + tabletype,
        type: 'GET',
        success: function(data)
        {
            ++processed_count;
            ++index;
            // 更新进度条

var process_num = parseInt((processed_count / processnum) * 100);

if (process_num >= 100)
            {
                process_num = 100;
            }
            update_process(process_num);
            //alert(processed_count+'--'+processnum);
            if (processed_count >= processnum)
            {
                backup_compress();

return 'success';
            }
            if (data == '0'){
                ajaxmark=1;
                return false;
            }

            excel_export_ajax(index, num, processnum, tabletype);
        }
    });
}

/* 更新进度条 */
function update_process(process_num)
{
    win.$('#process_bg').show().width(process_num + '%');
    win.$('#process_num').html(process_num);
}

/* 备份文件执行压缩 */
function backup_compress()
{
    win.$('#progress_info').text('正在生成压缩文件...');

$.ajax({
        url: "<?php echo WEB_URL;?>/index.php?q=onlinesea/compress/event/<?php echo $event;?>",
        success: function(msg){
            win.$('#process_bg').show().width('100%');
            win.$('#process_num').html('100');
            win.$('#progress_info').html('导出数据完成。&nbsp;&nbsp;<a href="' + msg + '">下载文件</a>');
        }
    });
}
function tip()
{
    poptip = $.dialog.through({
        id: 'tip',
        title: '系统消息',
        content: '正在统计总数,请勿关闭窗口&nbsp;&nbsp;<img src="https://images.cnblogs.com/loading_s.gif" />',
        width: 300,
        height: 100,
        icon: 'system',
        lock: true,
        opacity: .1
    },
    function(){
        window.location.reload();
    });

poptip.show();
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wfwwgg.html