repayment-list.page.js
1.83 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
/**
* 分期还款
* @author: wsl<shuiling.wang@yoho.cn>
* @date: 2016/08/04
*/
var $ = require('yoho-jquery'),
Repayment = require('./repayment'),
tip = require('../plugin/tip');
var CHECKBOX_SELECTOR = '.repay-list input';
var repayment = new Repayment({
onGetSelection: function() {
var ret = [];
$(`${CHECKBOX_SELECTOR}:checked`).each(function(key, item) {
var li = $(item).parents('li');
var data = {
index: li.index(),
orderCode: li.attr('data-billno'),
termNo: li.attr('data-termNo'),
amount: parseFloat(li.attr('data-currNoFeeAmt')),
fee: parseFloat(li.attr('data-currfee')) + 0
};
ret.push(data);
});
return ret;
},
onDeselectAll: function() {
$(`${CHECKBOX_SELECTOR}:checked`).prop('checked', false);
return [];
},
onSelectAll: function() {
$(`${CHECKBOX_SELECTOR}:not(:checked)`).prop('checked', true);
return this.getSelection();
}
});
require('./overdue-notice');
$(CHECKBOX_SELECTOR + ':checkbox').click(function() {
var selection = repayment.getSelection();
var isSkipped = false;
var lastIndex = 0;
var self = this;
selection.forEach(function(sel) {
if ((sel.index + 1) - lastIndex > 1) {
isSkipped = true;
} else {
lastIndex = sel.index + 1;
}
});
if (isSkipped) {
setTimeout(function() {
tip.show($(self).is(':checked') ? '请按时间顺序取消选择,不可以跨期' : '请按时间顺序添加还款,不可以跨期');
}, 0);
return false;
}
repayment.update();
});
// 跳转到还款详情
window.jumpDetail = function(id) {
location.href = '/home/installment/repay/detail?id=' + id;
};