var mmg;
function initGrid(){
var h = WST.pageHeight();
var cols = [
{title:'结算单号', name:'settlementNo', width: 130,sortable:true},
{title:'申请店铺', name:'shopName' ,width:100,sortable:true},
{title:'结算金额', name:'settlementMoney' ,width:100,sortable:true, renderer:function(val,item,rowIndex){
return '¥'+val;
}},
{title:'结算佣金', name:'commissionFee' ,width:60,sortable:true, renderer:function(val,item,rowIndex){
return '¥'+val;
}},
{title:'店铺扣除质保金', name:'cashDeposit' ,width:60,sortable:true, renderer:function(val,item,rowIndex){
if(val==null) val=0
return '¥'+val;
}},
{title:'返还金额', name:'backMoney' ,width:60,sortable:true, renderer:function(val,item,rowIndex){
return '¥'+val;
}},
{title:'支付方式', name:'payName',width:60,sortable:true},
{title:'申请时间', name:'createTime',sortable:true},
{title:'状态', name:'settlementStatus' ,width:60,sortable:true, renderer:function(val,item,rowIndex){
return (val==1)?" 已结算 ":" 未结算 ";
}},
{title:'操作', name:'' ,width:120, align:'center', renderer: function(val,item,rowIndex){
var h = "";
h += "查看 ";
if(item['settlementStatus']==0 && WST.GRANT.JSSQ_04)h += "处理 ";
return h;
}}
];
mmg = $('.mmg').mmGrid({height: h-173,indexCol: true,indexColWidth:50, cols: cols,method:'POST',
url: WST.U('admin/settlements/pageQuery'), fullWidthRows: true, autoLoad: true,remoteSort: true,sortName:'createTime',sortStatus:'desc',
plugins: [
$('#pg').mmPaginator({})
]
});
$('#headTip').WSTTips({width:90,height:35,callback:function(v){
var diff = v?173:128;
mmg.resize({height:h-diff})
}});
}
function toEdit(id){
location.href=WST.U('admin/settlements/toHandle','id='+id);
}
function toView(id){
location.href=WST.U('admin/settlements/toView','id='+id);
}
function loadGrid(){
mmg.load({page:1,settlementNo:$('#settlementNo').val(),settlementStatus:$('#settlementStatus').val(),shopName:$('#shopName').val()});
}
function save(){
if(WST.confirm({content:'您确定提交该结算单吗?',yes:function(){
var params = WST.getParams('.ipt');
var loading = WST.msg('正在提交数据,请稍后...', {icon: 16,time:60000});
$.post(WST.U('admin/settlements/handle'),params,function(data,textStatus){
layer.close(loading);
var json = WST.toAdminJson(data);
if(json.status=='1'){
WST.msg("操作成功",{icon:1});
location.href=WST.U('admin/settlements/index');
}else{
WST.msg(json.msg,{icon:2});
}
});
}}));
}
var flag = false;
function intView(id){
var h = WST.pageHeight();
var element = layui.element;
var isInit = false;
element.on('tab(msgTab)', function(data){
if(data.index==1){
if(!isInit){
isInit = true;
initGoodsGrid(id);
}
}
});
}
function initGoodsGrid(id){
var h = WST.pageHeight();
var cols = [
{title:'订单号', name:'orderNo', width: 60},
{title:'商品名称', name:'goodsName' ,width:200},
{title:'商品规格', name:'goodsSpecNames',width:200, renderer:function(val,item,rowIndex){
if(WST.blank(val)!=''){
val = val.split('@@_@@');
return val.join(',');
}
}},
{title:'商品价格', name:'goodsPrice' ,width:30, renderer:function(val,item,rowIndex){
return '¥'+val;
}},
{title:'购买数量', name:'goodsNum' ,width:20},
{title:'佣金比率', name:'commissionRate',width:20}
];
mmg = $('.mmg').mmGrid({height: h-80,indexCol: true, cols: cols,method:'POST',
url: WST.U('admin/settlements/pageGoodsQuery','id='+id), fullWidthRows: true, autoLoad: true,
plugins: [
$('#pg').mmPaginator({})
]
});
}
function toExport(){
var params = {};
params = WST.getParams('.j-ipt');
var box = WST.confirm({content:"您确定要导出结算记录吗?",yes:function(){
layer.close(box);
location.href=WST.U('admin/settlements/toExport',params);
}});
}