coupon-admin/public/static/manager/js/bill.js

128 lines
5.0 KiB
JavaScript
Raw Normal View History

2021-11-29 05:56:26 +00:00
layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect',"laydate"], function () {
2021-11-25 10:11:50 +00:00
let $ = layui.jquery,
form = layui.form,
table = layui.table,
layer = layui.layer,
xmSelect = layui.xmSelect,
2021-11-29 05:56:26 +00:00
miniTab = layui.miniTab,
laydate = layui.laydate ;
2021-11-25 10:11:50 +00:00
/**** index begin ***/
//index页面
if ($('.location-index-page').length > 0) {
miniTab.listen();
2021-12-20 09:53:03 +00:00
var exportDataTitle=
2022-03-31 06:42:56 +00:00
["用户昵称","核销编码","商家昵称","签到券名称","持有比例(渠道商:平台:消费者)","金额","时间"]
2021-12-20 09:53:03 +00:00
;
var exportData =[];
2021-11-25 10:11:50 +00:00
// 渲染表格
let listUrl = $('#table-container').data('url');
let insTb = table.render({
elem: '#table-container',
toolbar: '#toolbar-tpl',
defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
title: '搜索'
, layEvent: 'search'
, icon: 'layui-icon-search'
}],
url: listUrl,
method: 'post',
even: true,
limits: [10,20,50,100,200,500,1000],
request: {
pageName: 'page',
limitName: 'size',
},
parseData: function (res) {
2021-11-29 05:56:26 +00:00
//console.log(res)
$("#new_agency_money_sum").text(res.data.agency_money_sum?res.data.agency_money_sum:0)
$("#new_admin_money_sum").text(res.data.admin_money_sum?res.data.admin_money_sum:0)
$("#new_consumer_money_sum").text(res.data.consumer_money_sum?res.data.consumer_money_sum:0)
2022-03-16 07:15:54 +00:00
$("#new_distribution_money_sum").text(res.data.distribution_money_sum?res.data.distribution_money_sum:0)
2021-11-25 10:11:50 +00:00
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.data.total, //解析数据长度
"data": res.data.list //解析数据列表
};
},
page: true,
cols: [[
{type: 'checkbox'},
2021-11-30 07:26:38 +00:00
{field: "nick_name",title: '用户昵称'},
2022-03-16 06:50:01 +00:00
{field: "user_coupon_id",width:120,title: '核销编码'},
2021-11-30 07:26:38 +00:00
{field: "business_name", title: '商家名称'},
2022-03-31 06:42:56 +00:00
{field: "coupon_main_name", title: '签到券名称'},
2022-03-16 06:50:01 +00:00
{templet:"#row-commission", title: '持有比例'},
{field: 'deduction_money', width: 200, title: '扣除金额'},
{field: 'create_time', width: 180, title: '时间'},
2021-11-25 10:11:50 +00:00
]],
2021-11-29 05:56:26 +00:00
done: function (res, curr, count) {
2021-11-25 10:11:50 +00:00
Tools.setInsTb(insTb);
2021-12-20 09:53:03 +00:00
var rdata=[];
res.data.forEach(function (d,index) {
2022-03-16 06:50:01 +00:00
let disstr ='';
if (d.is_distribution_coupon == 0) {
disstr = " 渠道商:平台:消费者" +
" 比例: " + d.commission_agency + ":" + d.commission_admin + ":" + d.commission_consumer +
"金额: " + d.agency_money + ":"
d.admin_money + " :" + d.consumer_money;
} else {
2022-03-18 03:37:30 +00:00
disstr = "领券分销者:平台:核销分销者" +
2022-03-16 06:50:01 +00:00
" 比例: " + d.commission_dis_distribution + ":" + d.commission_dis_admin + ":" + d.commission_dis_distributed +
"金额: " + d.distribution_money + ":"
d.admin_money + " :" + d.consumer_money;
}
2021-12-20 09:53:03 +00:00
rdata[index] = [
d.nick_name ,
2022-02-16 09:53:58 +00:00
d.user_coupon_id ,
2021-12-20 09:53:03 +00:00
d.business_name ,
d.coupon_main_name ,
2022-03-16 06:50:01 +00:00
disstr,
// ("比例:"+d.commission_agency +":"+ d.commission_admin+ ":"+ d.commission_consumer +
// "金额:" + d.agency_money+":" + d.admin_money + ":" + d.consumer_money) ,
2021-12-20 09:53:03 +00:00
d.money,
d.create_time,
]
})
2021-12-23 08:56:59 +00:00
exportData=rdata;
$("#exports").on("click",function(){
//console.log(exportData)
table.exportFile(exportDataTitle,exportData, 'xls');
return false;
})
2021-11-25 10:11:50 +00:00
}
});
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
//执行搜索重载
table.reload('table-container', {
page: {curr: 1}
, where: data.field
}, 'data');
return false;
});
2021-11-29 05:56:26 +00:00
//日期时间选择器
laydate.render({
elem: '#start_time'
,type: 'datetime'
});
//日期时间选择器
laydate.render({
elem: '#end_time'
,type: 'datetime'
});
2021-11-25 10:11:50 +00:00
}
/*** index end ***/
});