新增推广公司导出功能

master
chenzhi 5 years ago
parent 44a34bc89f
commit f507dde70b

@ -19,6 +19,10 @@ class PromoteCompanyController extends ThinkController
public function lists()
{
$model = M($this->modelName, 'tab_');
$is_export= false;
if (isset($_REQUEST['export']) && $_REQUEST['export']==1){
$is_export = true;
}
$map = [];
$promotemap=[];
$company_name = trim(I('company_name'));
@ -45,9 +49,12 @@ class PromoteCompanyController extends ThinkController
//获取分页公司数据
$companyres = $model->field("*")
->where($map)
->order("last_up_time desc")
->page($page,$row)
->select();
->order("last_up_time desc");
if($is_export){
$companyres = $companyres->select();
}else{
$companyres = $companyres->page($page,$row)->select();
}
//获取公司id
$companyids = implode(',', array_column($companyres, 'id'));
//获取所属会长及其游戏分成
@ -175,6 +182,11 @@ class PromoteCompanyController extends ThinkController
}
// dd($companyres);
if($is_export){
$this->assign('listData', $companyres);
$this->display("export");
die();
}
/* 查询记录总数 */
$count = $model
->where($map)

@ -0,0 +1,178 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<title>游戏登陆列表|----软件管理平台</title>
<link href="http://admin.vlcms.com/Public/icon.ico" type="image/x-icon" rel="shortcut icon">
<link rel="stylesheet" type="text/css" href="__CSS__/base.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/common.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/module.css">
<link rel="stylesheet" type="text/css" href="__CSS__/style.css" media="all">
<link rel="stylesheet" type="text/css" href="__CSS__/default_color.css" media="all">
<script type="text/javascript" src="__STATIC__/jquery-2.0.3.min.js"></script>
<script src="__STATIC__/table2excel.js"></script>
</head>
<style>
html {
min-width:100%;
}
body {
padding: 0px;
}
</style>
<body>
<div style="margin:auto;font-size: 20px;color: red;line-height: 3;padding: 20px;">
导出进行中。。。<br/>
如果导出成功你也可以手动关闭此页面
</div>
<table border="1" id="exporttable" style="opacity: 0;">
<!-- 表头 -->
<thead>
<tr>
<th>合作方名称</th>
<th>对应平台</th>
<th>合同期限</th>
<th>开票税点</th>
<th>开户行</th>
<th>银行账号</th>
<th>是否签署合同</th>
<th>备注</th>
<th>会长账号</th>
<th>结算周期</th>
<th>产品类型</th>
<th>游戏名称</th>
<th colspan="2">合作方分成比例</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<empty name ="listData">
<td colspan="99" class="text-center">aOh! 暂时还没有内容!</td>
<else />
<volist name="listData" id="data" key="companykey">
<tr>
<td rowspan="{$data.row}">{$data.company_name}</td>
<td rowspan="{$data.row}">{$data.platform_name}</td>
<td rowspan="{$data.row}">{$data.contact_begin} - {$data.contact_end}</td>
<td rowspan="{$data.row}">{$data.fax_ratio}%</td>
<td rowspan="{$data.row}">{$data.bank_name}</td>
<td rowspan="{$data.row}">{$data.bank_card}</td>
<td rowspan="{$data.row}">{$data.is_sign_contact}</td>
<td rowspan="{$data.row}">{$data.content}</td>
<notempty name="data.list">
<foreach name="data['list']" item="promote" key="promotekey">
<if condition="$promotekey gt 0">
<tr>
<td rowspan="{$promote['row']}"> {$promote['account']}</td>
<td rowspan="{$promote['row']}"> {$promote['settlement_type']}</td>
<foreach name="promote['list']" item="game" key="gamekey">
<if condition="$gamekey gt 0">
<tr>
<td rowspan="{$game['row']}">{$game['game_type_name']}</td>
<td rowspan="{$game['row']}">{$game['relation_game_name']}</td>
<foreach name="game['turnover_ratio']" item="ratio" key="ratiokey">
<if condition="$ratiokey gt 0">
<tr>
<td>{$ratio['name']}</td>
<td>{$ratio['ratio']}</td>
</tr>
<else />
<td>{$ratio['name']}</td>
<td>{$ratio['ratio']}</td>
</if>
</foreach>
</tr>
<else />
<td rowspan="{$game['row']}">{$game['game_type_name']}</td>
<td rowspan="{$game['row']}">{$game['relation_game_name']}</td>
<foreach name="game['turnover_ratio']" item="ratio" key="ratiokey">
<if condition="$ratiokey gt 0">
<tr>
<td>{$ratio['name']}</td>
<td>{$ratio['ratio']}</td>
</tr>
<else />
<td>{$ratio['name']}</td>
<td>{$ratio['ratio']}</td>
</if>
</foreach>
</if>
</foreach>
</tr>
<else />
<td rowspan="{$promote['row']}"> {$promote['account']}</td>
<td rowspan="{$promote['row']}"> {$promote['settlement_type']}</td>
<foreach name="promote['list']" item="game" key="gamekey">
<if condition="$gamekey eq 0">
<td rowspan="{$game['row']}">{$game['game_type_name']}</td>
<td rowspan="{$game['row']}">{$game['relation_game_name']}</td>
<foreach name="game['turnover_ratio']" item="ratio" key="ratiokey">
<if condition="$ratiokey gt 0">
<tr>
<td>{$ratio['name']}</td>
<td>{$ratio['ratio']}</td>
</tr>
<else />
<td>{$ratio['name']}</td>
<td>{$ratio['ratio']}</td>
</if>
</foreach>
<else />
<tr>
<td rowspan="{$game['row']}">{$game['game_type_name']}</td>
<td rowspan="{$game['row']}">{$game['relation_game_name']}</td>
<foreach name="game['turnover_ratio']" item="ratio" key="ratiokey">
<if condition="$ratiokey gt 0">
<tr>
<td>{$ratio['name']}</td>
<td>{$ratio['ratio']}</td>
</tr>
<else />
<td>{$ratio['name']}</td>
<td>{$ratio['ratio']}</td>
</if>
</foreach>
</tr>
</if>
</foreach>
</if>
</foreach>
</notempty>
</tr>
</volist>
</empty>
</tbody>
</table>
<script>
$(function(){
$("#exporttable").table2excel({
filename: "推广公司.xls", // do include extension
preserveColors: false // set to true if you want background colors and font colors preserved
});
//搜索功能
$("#search").click(function(){
console.log(222);
var url = $(this).attr('url');
var query = $('.jssearch').find('input').serialize();
query += "&" + $('.jssearch').find('select').serialize();
query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
query = query.replace(/^&/g,'');
if ( url.indexOf('?')>0 ){
url += '&' + query;
} else {
url += '?' + query;
}
window.parent.reloadIframe(url);
parent.document.getElementsByTagName('iframe').src = url;
});
});
</script>
</body>
</html>

@ -76,6 +76,9 @@
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="search" url="{:U('PromoteCompany/lists','model='.$model['name'].'&row='.I('row'),false)}">搜索</a>
</div>
<div class="input-list">
<a class="sch-btn" href="javascript:;" id="downloadexcel" url="{:U(CONTROLLER_NAME.'/'.ACTION_NAME,array_merge(['export'=>1],I('get.')))}">导出excel</a>
</div>
</div>
</div>
</div>
@ -266,6 +269,19 @@
window.location.href = url;
});
$("#downloadexcel").on("click",function(){
var url = $(this).attr("url");
var title = '推广公司导出';
layer.open({
type: 2,
title: title,
shadeClose: true,
shade: 0.8,
area: ['40%', '60%'],
content: url
});
})
//回车自动提交
$('.jssearch').find('input').keyup(function(event){

@ -0,0 +1 @@
(function($,window,document,undefined){var pluginName="table2excel",defaults={exclude:".noExl",name:"Table2Excel",filename:"table2excel",fileext:".xls",exclude_img:true,exclude_links:true,exclude_inputs:true,preserveColors:false};function Plugin(element,options){this.element=element;this.settings=$.extend({},defaults,options);this._defaults=defaults;this._name=pluginName;this.init()}Plugin.prototype={init:function(){var e=this;var utf8Heading='<meta http-equiv="content-type" content="application/vnd.ms-excel; charset=UTF-8">';e.template={head:'<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">'+utf8Heading+"<head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets>",sheet:{head:"<x:ExcelWorksheet><x:Name>",tail:"</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>"},mid:"</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>",table:{head:"<table>",tail:"</table>"},foot:"</body></html>"};e.tableRows=[];var additionalStyles="";var compStyle=null;$(e.element).each(function(i,o){var tempRows="";$(o).find("tr").not(e.settings.exclude).each(function(i,p){additionalStyles="";if(e.settings.preserveColors){compStyle=getComputedStyle(p);additionalStyles+=(compStyle&&compStyle.backgroundColor?"background-color: "+compStyle.backgroundColor+";":"");additionalStyles+=(compStyle&&compStyle.color?"color: "+compStyle.color+";":"")}tempRows+="<tr style='"+additionalStyles+"'>";$(p).find("td,th").not(e.settings.exclude).each(function(i,q){additionalStyles="";if(e.settings.preserveColors){compStyle=getComputedStyle(q);additionalStyles+=(compStyle&&compStyle.backgroundColor?"background-color: "+compStyle.backgroundColor+";":"");additionalStyles+=(compStyle&&compStyle.color?"color: "+compStyle.color+";":"")}var rc={rows:$(this).attr("rowspan"),cols:$(this).attr("colspan"),flag:$(q).find(e.settings.exclude)};if(rc.flag.length>0){tempRows+="<td> </td>"}else{tempRows+="<td";if(rc.rows>0){tempRows+=" rowspan='"+rc.rows+"' "}if(rc.cols>0){tempRows+=" colspan='"+rc.cols+"' "}if(additionalStyles){tempRows+=" style='"+additionalStyles+"'"}tempRows+=">"+$(q).html()+"</td>"}});tempRows+="</tr>"});if(e.settings.exclude_img){tempRows=exclude_img(tempRows)}if(e.settings.exclude_links){tempRows=exclude_links(tempRows)}if(e.settings.exclude_inputs){tempRows=exclude_inputs(tempRows)}e.tableRows.push(tempRows)});e.tableToExcel(e.tableRows,e.settings.name,e.settings.sheetName)},tableToExcel:function(table,name,sheetName){var e=this,fullTemplate="",i,link,a;e.format=function(s,c){return s.replace(/{(\w+)}/g,function(m,p){return c[p]})};sheetName=typeof sheetName==="undefined"?"Sheet":sheetName;e.ctx={worksheet:name||"Worksheet",table:table,sheetName:sheetName};fullTemplate=e.template.head;if($.isArray(table)){Object.keys(table).forEach(function(i){fullTemplate+=e.template.sheet.head+sheetName+i+e.template.sheet.tail})}fullTemplate+=e.template.mid;if($.isArray(table)){Object.keys(table).forEach(function(i){fullTemplate+=e.template.table.head+"{table"+i+"}"+e.template.table.tail})}fullTemplate+=e.template.foot;for(i in table){e.ctx["table"+i]=table[i]}delete e.ctx.table;var isIE=navigator.appVersion.indexOf("MSIE 10")!==-1||(navigator.userAgent.indexOf("Trident")!==-1&&navigator.userAgent.indexOf("rv:11")!==-1);if(isIE){if(typeof Blob!=="undefined"){fullTemplate=e.format(fullTemplate,e.ctx);fullTemplate=[fullTemplate];var blob1=new Blob(fullTemplate,{type:"text/html"});window.navigator.msSaveBlob(blob1,getFileName(e.settings))}else{txtArea1.document.open("text/html","replace");txtArea1.document.write(e.format(fullTemplate,e.ctx));txtArea1.document.close();txtArea1.focus();sa=txtArea1.document.execCommand("SaveAs",true,getFileName(e.settings))}}else{var blob=new Blob([e.format(fullTemplate,e.ctx)],{type:"application/vnd.ms-excel"});window.URL=window.URL||window.webkitURL;link=window.URL.createObjectURL(blob);a=document.createElement("a");a.download=getFileName(e.settings);a.href=link;document.body.appendChild(a);a.click();document.body.removeChild(a)}return true}};function getFileName(settings){return(settings.filename?settings.filename:"table2excel")}function exclude_img(string){var _patt=/(\s+alt\s*=\s*"([^"]*)"|\s+alt\s*=\s*'([^']*)')/i;return string.replace(/<img[^>]*>/gi,function myFunction(x){var res=_patt.exec(x);if(res!==null&&res.length>=2){return res[2]}else{return""}})}function exclude_links(string){return string.replace(/<a[^>]*>|<\/a>/gi,"")}function exclude_inputs(string){var _patt=/(\s+value\s*=\s*"([^"]*)"|\s+value\s*=\s*'([^']*)')/i;return string.replace(/<input[^>]*>|<\/input>/gi,function myFunction(x){var res=_patt.exec(x);if(res!==null&&res.length>=2){return res[2]}else{return""}})}$.fn[pluginName]=function(options){var e=this;e.each(function(){if(!$.data(e,"plugin_"+pluginName)){$.data(e,"plugin_"+pluginName,new Plugin(this,options))}});return e}})(jQuery,window,document);
Loading…
Cancel
Save