index.js
13.2 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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/**
* Created by wangqianjun on 16/2/23.
*/
var $ = require('jquery'),
common = require('../common/common');
// 热搜词状态
var StatusEnum = {
ON: 2,// 开启
OFF: 1 // 关闭
};
//界面分类值
var PagEnum = {
DEF_HOT_SEARCH_WORDS: 1, //默认热搜词管理页面
PULL_DOWN_WORDS: 2,//下拉词管理页面
HOT_SEARCH_WORDS: 3,//热搜词管理页面
SYNONYMS_: 4,//同义词管理页面
DISABLE_WORDS: 5//停用词管理页面
};
//界面分类显示
var titles = {
1: {
name1: "默认热搜词列表",
name2: "默认热搜词列表",
title: "默认热搜词",
tips: '注:默认热搜索词是默认显示在前台搜索框里的词或者短语'
},
2: {
name1: "下拉词列表",
name2: "下拉词列表",
title: "下拉词",
tips: '注:下拉词是前台输入框获取焦点之后下拉显示的词'
},
3: {
name1: "热搜词列表",
name2: "热搜词列表",
title: "热搜词",
tips: '注:热搜词是前台搜索框下面的词'
},
4: {
name1: "同义词列表",
name2: "同义词列表",
title: "同义词",
tips: '注:同义词,比如阿迪达斯和三叶草就是一对同义词'
},
5: {
name1: "停用词列表",
name2: "停用词列表",
title: "停用词",
tips: '注:停用词是指搜索引擎不进行拆分检索的词'
}
};
// 下拉框
new common.dropDown({
el: "#status-filter"
});
new common.dropDown({
el: "#channel-ops"
});
// 初始化日期插件
new common.edit("#filter").init();
var edit = new common.edit2(".modal-body");
var Bll = {
module: null,
getQueryString: function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null)return unescape(r[2]);
return null;
},
_render1: function () {
//只有默认热搜词才显示时间选择
if (parseInt(type) == PagEnum.DEF_HOT_SEARCH_WORDS) {
$('#starttime-filter').show();
$('#endtime-filter').show();
$('#channel-ops').show();
} else {
$('#starttime-filter').hide();
$('#endtime-filter').hide();
$('#channel-ops').hide();
}
var tem = common.util.__template2($("#template").html(), titles[parseInt(type)]);
$(".media-body").html(tem);
},
__render: function (selecter, templater, data) {
$(selecter).html(common.util.__template2($("#" + templater).html(), data));
},
//弹框
toast: function (url, module, hint) {
module.tips = titles[module._type].tips;
Bll.module = module;
var d = new common.dialog({
title: hint + titles[module._type].title,
content: common.util.__template2($("#template-content").html(), Bll.module),
width: '30%',
button: [
{
value: "保存",
callback: function () {
if (edit.validate()) {
common.util.__ajax({
url: url,
data: Bll.module
}, function (res) {
if (res.code == '200') {
g.reload();
d.close();
}
else {
common.util.__tip(res.message, "warning");
}
});
}
return false;
},
css: "btn-primary"
},
{
"value": "取消",
"css": "btn-info"
}
]
});
Bll.__editRender();
},
renderDialog: function (templater) {
Bll.__render(".modal-body", templater, Bll.module);
Bll.__editRender();
},
__editRender: function () {
edit.init();
}
};
/**
* 全局变量,当前界面的类型
* @type {*}
*/
var type = Bll.getQueryString("type");
/**
* 加载界面
*/
Bll._render1();
/**
* 界面表格
* @type {common.grid}
*/
var g = new common.grid({
el: '#search-words-list',
parms: function () {
switch (parseInt(type)) {
//默认热搜词管理页面
case PagEnum.DEF_HOT_SEARCH_WORDS :
return {
type: type,
channelIds: $.trim($('#channel-ops').val()),
status: $.trim(common.util.__input("status-filter")),
startTime: $.trim($('#starttime-filter').val()),
endTime: $.trim($('#endtime-filter').val()),
content: $.trim($('#content-filter').val())
};
//热搜词管理页面
case PagEnum.HOT_SEARCH_WORDS :
//下拉词管理页面
case PagEnum.PULL_DOWN_WORDS :
//同义词管理页面
case PagEnum.SYNONYMS_ :
//停用词管理页面
case PagEnum.DISABLE_WORDS :
return {
type: type,
status: $.trim(common.util.__input("status-filter")),
content: $.trim($('#content-filter').val())
};
}
},
columns: (function () {
switch (parseInt(type)) {
//默认热搜词管理页面
case PagEnum.DEF_HOT_SEARCH_WORDS :
return [
{display: "序号", name: "id"},
{display: "内容", name: "content"},
{display: "频道", name: "channelNames"},
{
display: "链接", name: "url", render: function (item) {
var url = item.url ? item.url : "";
return '<a href="' + url + '" target="_blank"> ' + url + '</a>' //'+item.url?item.url:""+'
}
},
{
display: "状态", name: "status", render: function (item) {
if (item.status === StatusEnum.ON) {
return "<span>开启</span>";
} else {
return "<span>关闭</span>";
}
}
},
{display: "开始时间", name: "startTime"},
{display: "结束时间", name: "endTime"},
{display: "添加人", name: "creatorUsrname"},
{display: "添加时间", name: "createdTime"},
{display: "修改人", name: "modifyUsrname"},
{display: "修改时间", name: "modifyTime"},
{
display: "操作", name: "", render: function (item) {
return '<a class="btn btn-info modify" data-index="' + item.__index + '">修改</a>';
}
}
];
//下拉词管理页面
case PagEnum.PULL_DOWN_WORDS :
return [
{display: "序号", name: "id"},
{display: "内容", name: "content"},
{
display: "状态", name: "status", render: function (item) {
if (item.status === StatusEnum.ON) {
return "<span>开启</span>";
} else {
return "<span>关闭</span>";
}
}
},
{display: "排序", name: "sort"},
{display: "商品数", name: "goodsNum"},
{display: "添加人", name: "creatorUsrname"},
{display: "添加时间", name: "createdTime"},
{display: "修改人", name: "modifyUsrname"},
{display: "修改时间", name: "modifyTime"},
{
display: "操作", name: "", render: function (item) {
return '<a class="btn btn-info modify" data-index="' + item.__index + '">修改</a>';
}
}
];
//热搜词管理页面
case PagEnum.HOT_SEARCH_WORDS :
return [
{display: "序号", name: "id"},
{display: "内容", name: "content"},
{display: "频道", name: "channelNames"},
{
display: "链接", name: "url", render: function (item) {
var url = item.url ? item.url : "";
return '<a href="' + url + '" target="_blank"> ' + url + '</a>' //'+item.url?item.url:""+'
}
},
{
display: "状态", name: "status", render: function (item) {
if (item.status === StatusEnum.ON) {
return "<span>开启</span>";
} else {
return "<span>关闭</span>";
}
}
},
{display: "排序", name: "sort"},
{display: "添加人", name: "creatorUsrname"},
{display: "添加时间", name: "createdTime"},
{display: "修改人", name: "modifyUsrname"},
{display: "修改时间", name: "modifyTime"},
{
display: "操作", name: "", render: function (item) {
return '<a class="btn btn-info modify" data-index="' + item.__index + '">修改</a>';
}
}
];
//同义词管理页面
case PagEnum.SYNONYMS_ :
return [
{display: "序号", name: "id"},
{display: "内容", name: "content"},
{
display: "状态", name: "status", render: function (item) {
if (item.status === StatusEnum.ON) {
return "<span>开启</span>";
} else {
return "<span>关闭</span>";
}
}
},
{display: "添加人", name: "creatorUsrname"},
{display: "添加时间", name: "createdTime"},
{display: "修改人", name: "modifyUsrname"},
{display: "修改时间", name: "modifyTime"},
{
display: "操作", name: "", render: function (item) {
return '<a class="btn btn-info modify" data-index="' + item.__index + '">修改</a>';
}
}
];
//停用词管理页面
case PagEnum.DISABLE_WORDS :
return [
{display: "序号", name: "id"},
{display: "内容", name: "content"},
{
display: "状态", name: "status", render: function (item) {
if (item.status === StatusEnum.ON) {
return "<span>开启</span>";
} else {
return "<span>关闭</span>";
}
}
},
{display: "添加人", name: "creatorUsrname"},
{display: "添加时间", name: "createdTime"},
{display: "修改人", name: "modifyUsrname"},
{display: "修改时间", name: "modifyTime"},
{
display: "操作", name: "", render: function (item) {
return '<a class="btn btn-info modify" data-index="' + item.__index + '">修改</a>';
}
}
];
}
})()
});
g.init('/operation/terms/searchWordsList');
/**
* 监听输入框变化
*/
$(document).on("change", ".observe", function () {
var $this = $(this);
var name = $this.data("field");
Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
obj[name1] = $this.val();
});
});
/**
* 查询按钮
*/
$("#filter-btn").click(function () {
g.reload(1);
});
/**
* 添加
*/
$("#filter-add").click(function () {
var item = {
"type": parseInt(type),
"content": "",
"channelIds": "",
"url": "",
"startTime": "",
"endTime": "",
"goodsNum": 0,
"sort": 1
};
item._status = "add";
item._type = parseInt(type);
Bll.toast('/operations/terms/add', item, "添加");
});
/**
* 修改
*/
$(document).on("click", ".modify", function () {
var item = g.rows[$(this).data('index')];
item._status = "update";
item._type = parseInt(type);
Bll.toast('/operations/terms/modify', item, "修改");
});