Index.js
3.8 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
/**
* 促销管理
*/
'use strict';
var $ = require('jquery'),
common = require('../../../common/common');
require('../../../common/util/datepicker');
var addEdit=require("./partials/Add");
var g = new common.grid({
el: '#basicTable',
size: 10,
parms: function() {
return {
status: common.util.__input('status'),
is_valid:$("#is_valid").val(),
sort_type:$("#sort_type").val(),
title:common.util.__input('title')
};
},
columns: [{
display: "ID",
name: "id"
}, {
display: "促销名称",
name: "title"
}, {
display: '优先级',
name: "priority"
}, {
display: '开始时间',
name: "startTime",
render: function(item) {
var date = new Date(item.startTime * 1000);
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
}
}, {
display: '结束时间',
name: "endTime",
render: function(item) {
var date = new Date(item.endTime * 1000);
return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
}
}, {
display: '是否启用',
name: "status",
render: function(item) {
var name;
if(item.status===1){
name ="已启用" ;
}else {
name ="未启用" ;
}
return name;
}
}, {
display: '是否展示',
name: "showStatus",
render: function(item) {
var name;
if(item.showStatus===1){
name ="展示" ;
}else {
name ="不展示" ;
}
return name;
}
}, {
display: '优惠券限制使用',
name: "status",
render: function(item) {
var name="否";
if(!item.promotionParams){
return "促销条件未设置";
}
if(item.promotionParams.limitParam
&&item.promotionParams.limitParam==1){
name ="是" ;
}
return name;
}
}, {
display: '操作',
name: "status",
render: function(items) {
//支付类型的促销不允许修改
if(items.promotionParams
&& items.promotionParams.promotionType
&& items.promotionParams.promotionType=="Payment"){
return "";
}
var HtmArr = [];
HtmArr.push('<a href="/promotionInfo/edit/' + items.id + '"" class="btn btn-info btn-xs">编辑</a>');
if(items.isDel==="N"){
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs del-promotion">删除</a>');
}
return HtmArr.join('');
}
}]
})
g.init('/promotionInfo/list');
//查询
$("#filter-btn").click(function() {
g.reload(1);
});
//删除操作
$('tbody').on('click', '.del-promotion', function() {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("温馨提示", "你确定要删除吗?", function () {
common.util.__ajax({
url: '/promotionInfo/delete',
data: {
param: item.id
}
}, function(res) {
if (res.code == 200) {
common.util.__tip('删除成功', 'success');
g.reload();
} else {
common.util.__tip(res.message);
}
}, true);
});
});