index.php
5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?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 table_search" name="code" size="1" column="6">
<option value="" selected>选择字段</option>
<option value="0">产品名称</option>
<option value="1">还款方式</option>
</select>
</span>
</div>
<div class="col-xs-2">
<input type="text" class="input-text" placeholder="" id="" name="keyword">
</div>
<div>
<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">
<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({
aaSorting: [[1, "desc"]],
serverSide: true,
processing: true,
bSort: false,
searching: false,//是否显示搜索
iDisplayLength: 6,
bLengthChange: false,
ajax: {
url: apiBaseUrl + 'config/products',
dataFilter: function (json) {
var ret = {}, json = jQuery.parseJSON(json);
ret.data = json.data || [];
var draw = getUrlParam('draw');
if (draw) {
ret.draw = draw;
}
ret.recordsTotal = 0;
ret.recordsFiltered = 0;
if (json.page) {
ret.recordsTotal = parseInt(json.page.totalNumber);
ret.recordsFiltered = parseInt(json.page.totalNumber);
}
return JSON.stringify(ret);
},
data: function (data) {
data.pageSize = data.length;
data.currentPage = parseFloat(data.start / data.length) + 1;
return data;
}
},
columns: [
{
data: "id", render: function (data, type, full) {
return '<span class="dropDown dropDown_hover">\
<button class="btn radius size-M">请选择 <i class="Hui-iconfont"></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>