sknRebateList.html
10.9 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Yoho!Buy运营平台</title>
<script src="/union/js/include.js"></script>
<script src="/union/js/ajaxfileupload.js"></script>
</head>
<body class="easyui-layout" fit="true">
<div region="north" style="padding-bottom: 35px; height: auto;">
<script>
document.write(addHead('CPS联盟管理', 'CPS商品返佣比例设置'));
</script>
<div style="margin-left: 15px;margin-top: 10px">
<input class="easyui-textbox" id="skn" style="width: 200px;" data-options="prompt:'SKN'">
<input class="easyui-combobox" id="brand" sytle="width: 200px">
<input class="easyui-combobox" id="state" style="width:150px;" data-options="editable:false"/>
<a id="searchBtn" class="easyui-linkbutton btn-info" >查询</a>
<a id="addBtn" class="easyui-linkbutton btn-primary" >新增</a>
<a id="exportBtn" class="easyui-linkbutton btn-success" >导出</a>
<a id="batchImportBtn" class="easyui-linkbutton btn-success">批量导入</a>
</div>
</div>
<div region="center">
<table id="shareRebateSknTable"></table>
</div>
</body>
</html>
<script>
$(function() {
var sknTextBox = $("#skn");
var brandCombobox = $("#brand");
var stateCombobox = $("#state");
var table = $("#shareRebateSknTable");
sknTextBox.textbox('textbox').bind('keyup', function () {
sknTextBox.textbox('setValue', $(this).val().replace(/[^\d]/g, ""));
});
stateCombobox.myCombobox({
prompt: "状态",
width: 200,
panelHeight : 90,
data: [
{"id":"1", "text":"开启"},
{"id":"2", "text":"关闭"}
],
valueField: "id",
textField: "text"
});
$("#searchBtn").linkbutton({
iconCls: "icon-search",
onClick: function () {
table.datagrid("load", {
skn: sknTextBox.textbox("getValue"),
brand: brandCombobox.combobox("getValue"),
state: sknTextBox.combobox("getValue")
});
}
});
$("#addBtn").linkbutton({
iconCls: "icon-search",
onClick: function () {
saveShareRebateSkn(0);
window.self.paramObject.brandRebateData = null;
}
});
brandCombobox.myCombobox({
editable: false,
valueField: "value",
textField: "text",
required: false,
prompt: "选择品牌",
url: contextPath + "/UnionShareRebateBrandRest/queryAllBrand",
panelHeight: 200,
loadFilter: function (data) {
return defaultLoadFilter(data);
}
});
table.myDatagrid({
fit: true,
fitColumns: true,
nowrap: false,
url: contextPath + "/UnionRebateRest/querySknList",
method: 'POST',
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp = null == temp ? [] : temp;
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "SKN",
field: "skn",
width: "20%",
align: "center",
}, {
title: "商品名称",
field: "name",
width: "15%",
align: "center"
}, {
title: "当前销售价",
field: "priceStr",
width: "15%",
align: "center",
}, {
title: "商品返佣比例",
field: "rebate",
width: "20%",
align: "center",
formatter(value, data) {
if (data.type == 1) {
return "品牌比例";
} else {
return value / 100 + "%";
}
}
}, {
title: "商品返佣状态",
field: "state",
width: "15%",
align: "center",
formatter(value, data) {
if (value == 1) {
return "品牌状态";
} else if (value == 2) {
return "开启";
} else {
return "关闭";
}
}
}, {
title: "操作",
field: "ddg",
width: "15%",
align: "center",
formatter: function (value, rowData, rowIndex) {
return "<a role='edit' style='margin-left:10px;' dataId='" + rowData.id + "' index='" + rowIndex + "'>修改</a>"
}
}
]],
cache: false,
pagination: true,
pageSize: 10,
idField: "id",
singleSelect: false,
onLoadSuccess: function () {
$(this).myDatagrid("getPanel").find("a[role='edit']").linkbutton({
iconCls: "icon-more",
onClick: function () {
saveShareRebateSkn($(this).attr("dataId"));
}
});
}
});
function saveShareRebateSkn(id) {
var rowData;
if (id != 0) {
var index = table.myDatagrid("getRowIndex", id);
rowData = table.datagrid('getData').rows[index];
window.self.paramObject.sknRebateData = rowData;
}
var div = $("<div>").appendTo($(window.self.document.body));
var action = id != 0 ? "修改" : "新增";
var title = "商品结算比例";
var url = "";
if (id == 0) {
url = contextPath + "/UnionRebateRest/addSkn";
} else {
url = contextPath + "/UnionRebateRest/updateSkn";
}
window.self.$(div).myDialog({
title: action + title,
width: "40%",
height: "50%",
resizable: false,
buttons: [{
id: "saveBtn",
text: '保存',
iconCls: "icon-save",
handler: function () {
window.self.$("#sknRebateEditForm").form("submit", {
url: url,
onSubmit: function (param) {
var skn = $("#sknRebateEditForm #skn").textbox("getValue");
if (skn == "") {
window.self.$.messager.alert("失败", "请输入skn", "error");
return false;
}
var type = $("input[name='type']:checked").val();
var rebate = $("#sknRebateEditForm #rebateStr").textbox("getValue");
if (type == 2) {
if(rebate == ""){
window.self.$.messager.alert("失败", "请填写自定义比例", "error");
return false;
}
if(parseFloat(rebate) > 25){
window.self.$.messager.alert("失败", "返佣比例不能超过25%", "error");
return false;
}
if(parseFloat(rebate) === 0.0){
window.self.$.messager.alert("失败", "返佣比例必须大于0%", "error");
return false;
}
}
if (id != 0) {
param.name = rowData.name;
param.id = id;
}
param.rebatePercentStr = rebate;
return true;
},
success: function (data) {
window.self.$.messager.progress("close");
window.self.$(div).dialog('close');
table.datagrid("reload");
window.self.$.messager.show({
title: "提示",
msg: title + JSON.parse(data).message
});
}
});
}
}, {
text: '取消',
id: "closeBtn",
iconCls: "icon-cancel",
handler: function () {
window.self.$(div).dialog('close');
}
}],
modal: true,
href: contextPath + "/html/shareRebate/sknRebateEdit.html",
onOpen: function () {
window.setTimeout(function () {
$("#saveBtn").addClass("btn-success");
$("#closeBtn").addClass("btn-danger");
}, 100);
}
});
}
$("#batchImportBtn").linkbutton({
text: "批量导入",
iconCls: "icon-add",
onClick: function () {
var div = $("<div id='batchImportDialogDiv'>").appendTo($(document.body));
$(div).myDialog({
title: "批量导入",
width: "600px",
height: "50%",
href: contextPath + "/html/shareRebate/sknRebateImport.html",
modal: true,
collapsible: true,
cache: false
});
}
});
$("#exportBtn").linkbutton({
onClick: function () {
window.open(contextPath + "/batch/export.do?type=unionShareRebateSkn&queryConf=" + JSON.stringify(getParams()));
}
});
function getParams() {
var params = {};
var skn = sknTextBox.textbox("getValue");
if (skn != "") {
params["skn"] = skn;
}
var brand = brandCombobox.combobox("getValue");
if (brand != "") {
params["brand"] = brand;
}
var state = sknTextBox.combobox("getValue");
if (state != "") {
params["state"] = state;
}
return params;
}
})
</script>