<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>积分返利明细</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <style type="text/css">
        /*您可以将下列样式写入自己的样式表中*/
        /*layui 元素样式改写*/
        .layui-btn-sm {
            line-height: normal;
            font-size: 12.5px;
        }

        .layui-table-view .layui-table-body {
            min-height: 256px;
        }

        .layui-table-cell .layui-input.layui-unselect {
            height: 30px;
            line-height: 30px;
        }

        /*设置 layui 表格中单元格内容溢出可见样式*/
        .table-overlay .layui-table-view,
        .table-overlay .layui-table-box,
        .table-overlay .layui-table-body {
            overflow: visible;
        }

        .table-overlay .layui-table-cell {
            height: auto;
            overflow: visible;
        }

        .imgStyle {
            padding-left: 10px;
            width: 80px;
            height: 50px;
        }

        .layui-table-cell {
            font-size: 14px;
            padding: 0 5px;
            height: auto;
            overflow: visible;
            text-overflow: inherit;
            white-space: normal;
            word-break: break-all;
        }
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body">
                <div style="height: 5px"></div>
                <div id="tableRes" class="table-overlay">
                    <table id="dataTable" lay-filter="dataTable" class="layui-hide"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="../../layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'layer',], function () {
        var $ = layui.$
            , admin = layui.admin
            , table = layui.table
            , layer = layui.layer;

        var id = layui.view.getParameterByName('id');
        var editdata = JSON.parse(JSON.stringify(parent.layui.table.editdata)); // 框架有Bug所以这么转换
        var tbWidth = $("#tableRes").width();
        var layTableId = "layTable";
        var tableIns = table.render({
            elem: '#dataTable',
            id: layTableId,
            data: [],
            width: tbWidth,
            page: false,
            limit: 100,
            loading: true,
            even: true, //不开启隔行背景
            cols: [[
                {title: '序号', type: 'numbers'},
                {field: 'customer_name', title: '用户名', width: '30%',},
                {field: 'ratio', title: '返利比例', width: '20%',},
                {field: 'amount', title: '返利', width: '20%',},
            ]]
        });

        admin.req({
            url: '/rebate/' + id + '/point_rebate/',
            done: function (res) {
                if (res.code === 0) {
                    var rows = res.data;
                    var oldData = table.cache[layTableId];
                    for (var k in rows) {
                        oldData.push(
                            {
                                customer_name: rows[k].customer_name,
                                ratio: rows[k].ratio + '%',
                                amount: rows[k].amount
                            }
                        )
                    }
                    tableIns.reload({
                        data: oldData
                    });
                }else{
                    layer.msg('获取积分返利明细失败', {icon: 5});
                }
            }
        });

    });

</script>
</body>
</html>
