operations.payment.Index.js
6.95 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
webpackJsonp([119],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var ENUM = {
recommendOrderPage: ["否","是"],
displayFirstSight: ["否","是"]
};
var sortNumberList = []; //前端展示排序数组,用于校验前端排序是否重复
var g = new common.grid({
el: '#payment-list',
columns: [
{display: "ID", name: "id"},
{display: '支付方式名称', name: "payName"},
{display: '推荐到确认订单页', render: function (item) {
var rop = ENUM.recommendOrderPage[item.recommendOrderPage];
return item.recommendOrderPage == 1 ? rop+"("+item.recommendWords+")" : rop;
}},
{display: '前端显示', render: function (item) {
var rop = ENUM.displayFirstSight[item.displayFirstSight];
return item.displayFirstSight == 1 ? rop+"("+item.displayFirstSight+")" : rop;
}},
{display: "前端排序", name: "sortNumber"},
{display: "推荐语1", name: "recommendText1"},
{display: "推荐语2", name: "recommendText2"},
{display: '操作', render: function (item) {
var HtmArr = [];
HtmArr.push('<a href="javascript:" class="btn btn-info btn-xs edit-btn" data-index="'+item.__index+'">编辑</a>');
if(item.status == 1){
HtmArr.push('<a href="javascript:" class="btn btn-danger btn-xs close-btn" data-index="'+item.__index+'">关闭</a>');
}else{
HtmArr.push('<a href="javascript:" class="btn btn-success btn-xs open-btn" data-index="'+item.__index+'">开启</a>');
}
return HtmArr.join('');
}}
],
complete: function () {
$.each(g.rows, function (index, item) {
sortNumberList.push(item.sortNumber+'');
});
}
});
g.init("/Payment/findPayManageList");
//编辑
$(document).on("click", ".edit-btn", function () {
var _index = $(this).data("index");
var data = g.rows[_index];
var recommendOrderPage_old = data.recommendOrderPage;
var displayFirstSight_old = data.displayFirstSight;
var d = new common.dialog({
title: "支付方式编辑",
width: "50%",
content: common.util.__template2($("#template").html(), data),
button: [
{value: "确认", css:"btn-primary", callback: function () {
var dataArray = $('#paymentEdit').serializeArray();
var newData = {};
$.each(dataArray, function (index, item) {
newData[item.name] = item.value;
});
if(checkPaymentData(newData, data)){
//更变了推荐到确认订单页情况下,需要二次确认
if(recommendOrderPage_old != newData.recommendOrderPage){
new common.dialog({
title: "温馨提示",
width: "360px",
content:newData.recommendOrderPage == 1 ? "你确认将这个支付方式<font color='#5cb85c'>推荐</font>到确认订单页面么?" : "你确认<font color='#ff0000'>取消</font>将这个支付方式推荐到确认订单页面么?",
zIndex: 52,
button:[
{value: "确认", css:"btn-primary", callback: function () {
savePaymentData(newData);
d.close();
}},
{value: "取消", css:"btn-default"}
]
});
return false;
} else if(displayFirstSight_old != newData.displayFirstSight){
new common.dialog({
title: "温馨提示",
width: "360px",
content:newData.displayFirstSight == 1 ? "你确认将这个支付方式<font color='#5cb85c'>首次显示</font>吗?" : "你确认<font color='#ff0000'>取消</font>将这个支付方式首次显示吗?",
zIndex: 52,
button:[
{value: "确认", css:"btn-primary", callback: function () {
savePaymentData(newData);
d.close();
}},
{value: "取消", css:"btn-default"}
]
});
return false;
} else{
savePaymentData(newData);
}
}else{
return false;
}
}},
{value: "取消", css:"btn-default"}
]
});
new common.edit("#paymentEdit").init();
});
//保存支付方式数据
function savePaymentData(data) {
common.util.__ajax({
url: '/Payment/updatePayInfoById',
data: data
}, function () {
g.reload();
})
}
//校验支付方式数据
function checkPaymentData(data, oldData) {
//前端排序不能重复
if(data.sortNumber != oldData.sortNumber){
if(sortNumberList.indexOf(data.sortNumber) > -1){
common.util.__tip("前端排序已存在,不能重复填写!");
return false;
}
}
//推荐到订单页为'是',推荐文案不能为空!
if(data.recommendOrderPage == 1){
if($.trim(data.recommendWords) == ""){
common.util.__tip("推荐到订单页为'是',推荐文案不能为空!");
return false;
}
}
//提示语2不为空时,需要校验提示语1不能为空
if($.trim(data.recommendText2) != ""){
if($.trim(data.recommendText1) == ""){
common.util.__tip("提示语2填写,则提示语1也必须填写!");
return false;
}
}
return true;
}
//开启
$(document).on("click", ".open-btn", function () {
var _index = $(this).data("index");
var data = g.rows[_index];
common.dialog.confirm("温馨提示", "确认开启当前支付方式么?", function(){
common.util.__ajax({
url: '/Payment/openPayModeById',
data: {id: data.id}
}, function () {
g.reload();
})
});
});
//关闭
$(document).on("click", ".close-btn", function () {
var _index = $(this).data("index");
var data = g.rows[_index];
common.dialog.confirm("温馨提示", "确认关闭当前支付方式么?", function(){
common.util.__ajax({
url: '/Payment/closePayModeById',
data: {id: data.id}
}, function () {
g.reload();
})
});
});
/***/ }
]);