Commit b27dde27 by guanzhenshan

平台利润统计报表增加导出功能

parent 0aad30ba
......@@ -96,6 +96,7 @@
<div class="form-group">
<label>&nbsp;</label>
<button type="button" class="btn btn-primary" onclick="list();"><i class="fa fa-search"></i>&nbsp;查询</button>
<button type="button" class="btn btn-success" onclick="exportViewTable()">导出当前页面</button>
</div>
</div>
</form>
......@@ -201,6 +202,7 @@
<script src="~/js/jquery.tablesorter.min.js" type="text/javascript"></script>
<script src="~/js/yselect/yselect.js"></script>
<script type="text/javascript">
var objData;
var tb;
$(document).ready(function () {
laydate.render({ elem: '#start' });
......@@ -275,6 +277,7 @@
func: function (result) {
layer.close(lindex);
if (result && result.length > 0) {
objData = result;
$('#tb').html('');
$('#footer').html('');
for (var i = 0; i < result.length - 1; i++) {
......@@ -440,6 +443,7 @@
}
else {
objData = null;
$('#tb').html('');
$('#footer').html('');
layer.alert('没有找到相应数据!');
......@@ -633,6 +637,44 @@
layer_show(title + "的产品分类利润统计",'@Url.Content("~/Reports/Orders/SkuProfitCount?")'+urlparam,'95%','95%');
}
function exportViewTable() {
var explorer = window.navigator.userAgent;
if (explorer.indexOf("MSIE") >= 0) {
alert('该功能仅支持谷歌浏览器');
return;
}
if (objData != null && objData != undefined) {
var str = '平台,订单数,销售额,产品成本,客单价,平台费,FBA费,PayPal费,头程费,尾程费,处理费,平台操作费,广告费,上架费,预收金额,预收订单数,利润,利润率%,退款,退款率%\n';
for (var i = 0; i < objData.length; i++) {
str += (objData[i].platform_type + ',' + objData[i].order_count.replace(',', '') + ',' + objData[i].amount_sales.replace(',', '') + ',' + objData[i].cost_product.replace(',', '') + ',' + objData[i].customerprice.replace(',', '') +
',' + objData[i].cost_platform_fee.replace(',', '') + ',' + objData[i].cost_fba_fee.replace(',', '') + ',' + objData[i].cost_paypal_fee.replace(',', '') + ',' + objData[i].cost_first.replace(',', '') + ',' + objData[i].cost_tail.replace(',', '') +
',' + objData[i].cost_handle_bailun.replace(',', '') + ',' + objData[i].cost_handle_platform.replace(',', '') + ',' + objData[i].adfee.replace(',', '') + ',' + objData[i].putawayfee.replace(',', '') + ',' + objData[i].amount_prepaid.replace(',', '') +
',' + objData[i].noshippingcount.replace(',', '') + ',' + objData[i].profit_total.replace(',', '') + ',' + objData[i].profit_rate.replace(',', '') + ',' + objData[i].amount_refund.replace(',', '') + ',' + objData[i].amount_refund_rate.replace(',', '')
);
str += '\n';
}
// encodeURIComponent解决中文乱码
var uri = 'data:text/csv;charset=utf-8,\ufeff' + encodeURIComponent(str)
// 通过创建a标签实现
var link = document.createElement('a')
link.href = uri
// 对下载的文件命名
link.download = '平台利润统计报表.csv';
document.body.appendChild(link)
link.click()
document.body.removeChild(link);
}
}
</script>
}
......
var baseUrl = 'http://localhost:59628/';//'http://data.bailuntec.com'; //
var baseUrl = 'http://data.bailuntec.com'; //'http://localhost:59628/';//
var globalOrderSort='';
var globalOrderType = '';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment