queryCoupon.js
3.4 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
/**
* Created by ty on 2016/5/24.
*/
'use strict';
var $ = require('jquery'),
common=require('../common/common');
var couponId = location.href.substring(location.href.lastIndexOf("/") + 1);
$("#filter-couponId").val(couponId);
//grid
var g = new common.grid({
el: '#content-list',
async:false,
parms:function(){
return {
couponName: common.util.__input("filter-couponName"),
couponCode: common.util.__input("filter-couponCode"),
orderCode: common.util.__input("filter-orderCode"),
uid: common.util.__input("filter-uid")
};
},
columns:[
{display:"UID", name:"uid"},
{display:"优惠券ID",name:"couponId"},
{display:"单券号",name:"couponCode"},
{display:"订单号",name:"orderCode"},
{display:"优惠券名称",name:"couponName"},
{display:"有效期",name:"endTimeStr"},
{display:"状态",render: function(item) {
var status = "";
if(item.status == 0) {
status = "未使用";
} else if(item.status == 1) {
status = "已使用";
}
return '<p class="audit-time">' + status + '</p>';
}},
{display:"是否取消过",render: function (item) {
var isCancel = "";
if(item.isCancel == "Y") {
isCancel = "已取消";
} else if(item.isCancel == "N") {
isCancel = "未取消";
}
return '<p class="audit-time">' + isCancel + '</p>';
}},
{display: '操作', render: function(item) {
var HtmArr=[];
if(item.status == 0) {
HtmArr.push('<a class="btn btn-primary btn-xs delayTime" data-index="' + item.__index + '" href="javascript:;">延长有效期</a>');
} else if(item.status == 1) {
HtmArr.push('<a class="btn btn-primary btn-xs cancelCoupon" data-index="' + item.__index + '" href="javascript:;">手工退券</a>');
}
return HtmArr.join('');
}}
]
});
/**
* 通用对象
* @type {{toast: Bll.toast}}
*/
var Bll = {
toast:function(item, url, title) {
common.dialog.confirm(title,common.util.__template2($("#template-delay").html(), item),function(){
var time = parseInt(new Date($("#delayTime").val()).getTime() / 1000);
common.util.__ajax({
url:'/couponLogs/delayUserCoupon',
data:{id:item.id,endTime:time}
},function(){
g.reload();
});
});
$("#delayTime").fdatepicker({
format: 'yyyy-mm-dd hh:ii:ss',
pickTime: true
}).data("datepicker").setStartDate(item.endTimeStr);
}
};
$(document).on("click", "#filter-btn", function() {
g.init("/couponLogs/queryUserCouponLogsList");
});
//延长有效期
$(document).on("click", ".delayTime", function() {
var item = g.rows[$(this).data("index")];
Bll.toast(item, "/couponLogs/delayUserCoupon", "延长有效期");
});
//手工退券
$(document).on("click", ".cancelCoupon", function() {
var item = g.rows[$(this).data("index")];
common.util.__ajax({
url: "/couponLogs/cancelCouponUse",
data:{id:item.id}
},function() {
g.reload();
});
});
//输入限制
$(document).on("keyup", ".number", function () {
$(this).val($(this).val().replace(/\D/g, ''));
});