Index.js
3.39 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
/*
*@time: 2016.10.10
*@author: LiQZ
*/
var $ = require('jquery'), common = require('../../../common/common');
require('../../../common/util/datepicker');
//日期插件
$('.hasDatepicker').fdatepicker({
format: 'yyyy-mm-dd hh:ii:ss',
pickTime: true
});
var tableGird = new common.grid({
el: "#table-box",
size: 30,
parms: function() {
var startTime = common.util.__input('starttime');
var endTime = common.util.__input('endtime');
return {
receiveActivityName: common.util.__input('receiveActivityName'),
beginTime: toSeconds(startTime),
endTime: toSeconds(endTime)
};
},
columns: [
{ display: "组合套餐号", name: "id" },
{ display: "SKN", render: function(items) {
return items.productSkn;
}},
{ display: "有效期", render: function(items) {
return common.util.__secondsFormat(items.startTime)
+ " ~ "
+ common.util.__secondsFormat(items.endTime);
}},
{ display: "折扣", render: function(items) {
return items.discount;
}},
{ display: "状态", render: function(items) {
if (items.status != 1) {
return "已终止";
}
var now = Date.parse(new Date())/1000;
// 未开始
if (items.startTime > now) {
return "未开始";
}
// 进行中
if (items.startTime <= now && items.endTime >= now) {
return "进行中";
}
// 已结束
if (items.endTime < now) {
return "已结束";
}
return "时间设置错误";
}},
{ display: "操作信息", render: function(items) {
return items.operator + common.util.__secondsFormat(items.updateTime);
}},
{ display: "操作", render: function(items) {
var now = Date.parse(new Date())/1000;
var HtmArr = [];
if (items.status == 1 && items.startTime > now) {
HtmArr.push('<a href="/product/bundle/' + items.id + '" data-id="' + items.id + '" class="btn btn-primary btn-xs">编辑</a>');
}
if (items.status != 1 && items.endTime < now) {
HtmArr.push('<a href="javascript:void(0);" data-id="' + items.id + '" class="btn btn-danger btn-xs delete">终止</a>');
}
return HtmArr.join('');
}
}]
});
tableGird.init('/product/bundle/list');
$("#filter-btn").click(function() {
tableGird.reload(1);
});
function toSeconds(strDate) {
var seconds = new Date(strDate).getTime() / 1000;
return seconds;
}
function toDate(seconds) {
if (!$.isNumeric(seconds) || seconds <= 0) { return ''; }
var date = new Date(seconds * 1000);
return fixTwo(date.getFullYear()) + '-' + fixTwo((date.getMonth() + 1)) + '-' + fixTwo(date.getDate()) + ' ' + fixTwo(date.getHours()) + ':' + fixTwo(date.getMinutes()) + ':' + fixTwo(date.getSeconds());
}
function fixTwo(number) {
return number < 10? "0" + number: number;
}
/**
* 删除--点击事件
*/
$(document).on('click', '.delete', function () {
var id = $(this).attr("data-id");
common.dialog.confirm("警告",
"确认删除?",
function () {
common.util.__ajax({
url: '/yohoCoinActivity/delYohoCoinActivity',
data: { id: id }
}, function () {
tableGird.reload();
});
});
});