index.php 4.58 KB
<?php $this->load->view('common/header'); ?>

<body>
<div class="page-container">
    <form class="" onreset="resetHandler()">
        <div class="row cl mb-20">
            <div class="col-xs-2">
                <span class="select-box">
                    <select class="select" name="code" size="1" id="file">
                        <option value="" selected>选择字段</option>
                        <option value="productName">产品名称</option>
                        <option value="repaymentMode">还款方式</option>
                    </select>
                </span>
            </div>
            <div class="col-xs-2">
                <input type="text" class="input-text"  placeholder="" id="keywork" name="keyword">
            </div>
        <div>
            <button class="btn btn-primary radius" type="button" onclick="$('#table').DataTable().draw()">搜索</button>
            <input class="btn btn-warning radius" type="reset" value="重置">
            <button class="btn btn-primary radius" type="button" onclick="layer_show('添加', '<?= site_url('/config/add') ?>')">添加</button>
        </div>
            <!--<div>
                <button class="btn btn-primary radius" onclick="layer_show('添加', '<?/*= site_url('/config/add') */?>')">添加</button>
            </div>-->
    </form>

    <div class="body mt-20">
        <table class="table table-border table-bordered table-bg" id="table" url="config/products">
            <thead class="text-c">
            <tr>
                <th width="68px">操作</th>
                <th>产品名称</th>
                <th>年化利率%</th>
                <th>罚息(利率*n%)</th>
                <th>滞纳金</th>
                <th>还款方式</th>
                <th>借款期限(月)</th>
                <th>授额上限(元)</th>
                <th>录入时间</th>
                <th>备注</th>
            </tr>
            </thead>
            <tbody class="text-c">
            </tbody>
        </table>
    </div>
</div>
<?php $this->load->view('common/footer'); ?>

<script>
    var table = $('#table').dataTable({
        fnServerParams: function (aoData) {
            delete aoData.columns;

            file = $('#file').val();
            if(file)
                aoData[file] = $('#keywork').val();
        },
        columns: [
            {
                data: "id", render: function (data, type, full) {
                    return '<span class="dropDown dropDown_hover">\
                            <button class="btn radius size-M">请选择 <i class="Hui-iconfont">&#xe6d5;</i></button>\
                            <ul class="dropDown-menu menu radius box-shadow">\
                                <li><a href="javascript:;" onclick="layer_show(\'编辑\', \'/index.php/config/edit/' + data + '\')">编辑</a></li>\
                                <li><a href="javascript:;del(' + data + ')">删除</a></li>\
                            </ul></span>';
                }
            },
            {data: "productName"},//产品名称
            {data: "annualInterestRate"},//年化利率
            {data: "interestPenalty"},//罚息
            {data: "overdueFine"},//滞纳金
            {data: "repaymentMode"},//还款方式
            {data: "loanDeadline"},//借款期限
            {data: "loanLimit"},//授额上限
            {data: "createTime"},//录入时间
            {data: "remark"},//备注
        ]
    });

    function del(id) {
        layer.confirm('确认删除', {
            btn: ['确认', '取消'],
            title: '删除产品',
            icon: 3
        }, function () {
            $.ajax({
                type: 'delete',
                url: apiBaseUrl + 'config/product/' + id,
                cache: false,
                dataType: 'json',
                contentType: "application/json; charset=UTF-8",
                success: function (data) {
                    if (data.msg) {
                        layer.alert(data.msg);
                    } else if (data.code != 0) {
                        layer.alert('操作失败');
                    } else {
                        layer.msg('删除成功');
                    }
                    setTimeout(function () {
                        if (!data.code) {
                            window.reload();
                            layer_close();
                        }
                    }, 500);
                },
                error: function () {
                    layer.alert("操作失败")
                }
            })

        });
    }

    function reload() {
        table.fnDraw();
    }
</script>
</body>
<html>