searchWords.SearchWords.Index.js
20.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
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
webpackJsonp([156],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by wangqianjun on 16/2/23.
*/
var $ = __webpack_require__(1),
common = __webpack_require__(2);
var categoryList = [];
var artTemplate = common.artTemplate;
// 热搜词状态
var StatusEnum = {
ON: 2,// 开启
OFF: 1 // 关闭
};
// 时间状态
var TimeStatusEnum = {
BEFORE : 1,// 未开始
ING: 2,// 进行中
END: 3 // 已过期
};
//界面分类值
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: "#time-status-filter"
});
new common.dropDown({
el: "#channelIds-filter"
});
new common.dropDown({
el: "#channel-ops"
});
// 初始化日期插件
new common.edit("#filter").init();
var edit = new common.edit(".modal-body", {
bucket: "yhb-img01"
});
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 || parseInt(type) == PagEnum.HOT_SEARCH_WORDS){
$('#channelIds-filter').parent().show();
}else{
$('#channelIds-filter').parent().hide();
}
//只有默认搜索词才显示时间选择
if (parseInt(type) == PagEnum.DEF_HOT_SEARCH_WORDS) {
$('#starttime-filter').parent().show();
$('#endtime-filter').parent().show();
// $('#channel-ops').parent().parent().show();
} else {
$('#starttime-filter').parent().hide();
$('#endtime-filter').parent().hide();
$('#channel-ops').parent().parent().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: '40%',
button: [
{
value: "保存",
callback: function () {
if (edit.validate()) {
common.util.__ajax({
url: url,
data: Bll.module
}, function () {
g.reload();
d.close();
});
}
return false;
},
css: "btn-primary"
},
{
"value": "取消",
"css": "btn-info"
}
]
});
common.util.__ajax({
async:false,
url: "/salesCategory/querySCListByLevel",
data: {levelNumber:1}
}, function (res) {
categoryList = res.data;
for(var i=0; i<categoryList.length; i++){
var categoryName = categoryList[i].categoryName;
var categoryId = categoryList[i].categoryId;
html = '<div style="float:left;margin-right: 5px"><input type="checkbox" name="channelIds" class="observe" data-field="channelIds" value="'+categoryId+'">'+categoryName+'</div>';
$("#channelCheckBox").append(html);
}
},true);
Bll.__editRender();
},
renderDialog: function (templater) {
Bll.__render(".modal-body", templater, Bll.module);
Bll.__editRender();
},
editCallbackFn: function(obj) {
if (obj.key.indexOf('file_onComplete') === 0) {
console.log(obj);
var names = obj.field;
console.log(names);
Bll.module = common.util.__buildobj(names, '.', Bll.module, function (o, name) {
o[name] = obj.data;
});
}
},
__editRender: function () {
edit.init();
edit.off('callback', Bll.editCallbackFn);
edit.on('callback', Bll.editCallbackFn);
}
};
/**
* 全局变量,当前界面的类型
* @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,
status: $.trim(common.util.__input("status-filter")),
channelIds: $.trim(common.util.__input("channelIds-filter")),
startTime: $.trim($('#starttime-filter').val()),
endTime: $.trim($('#endtime-filter').val()),
timeStatus: $.trim(common.util.__input("time-status-filter")),
content: $.trim($('#content-filter').val())
};
//热搜词管理页面
case PagEnum.HOT_SEARCH_WORDS :
return {
type: type,
status: $.trim(common.util.__input("status-filter")),
channelIds: $.trim(common.util.__input("channelIds-filter")),
timeStatus: $.trim(common.util.__input("time-status-filter")),
content: $.trim($('#content-filter').val())
};
//下拉词管理页面
case PagEnum.PULL_DOWN_WORDS :
//同义词管理页面
case PagEnum.SYNONYMS_ :
//停用词管理页面
case PagEnum.DISABLE_WORDS :
return {
type: type,
status: $.trim(common.util.__input("status-filter")),
channelIds: $.trim(common.util.__input("channelIds-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: "PC链接", name:"matchPcUrl" },
{ display: "移动端链接", name:"matchAppUrl" },
{
display: "状态", name: "status", render: function (item) {
if (item.status === StatusEnum.ON) {
return "<span>开启</span>";
} else {
return "<span>关闭</span>";
}
}
},
{
display: "时间状态", name: "timeStatus", render: function (item) {
if (item.timeStatus === TimeStatusEnum.BEFORE) {
return "<span>未开始</span>";
}else if (item.timeStatus === TimeStatusEnum.ING) {
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) {
var str = '<a class="btn btn-xs btn-info modify" data-index="' + item.__index + '">修改</a>';
str = str+ '<a class="btn btn-xs btn-danger del-a" data-index="' + item.id + '" data-name="' + item.content + '">删除</a>';
return str;
}
}
];
//下拉词管理页面
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) {
var str = '<a class="btn btn-xs btn-info modify" data-index="' + item.__index + '">修改</a>';
str = str+ '<a class="btn btn-xs btn-danger del-a" data-index="' + item.id + '" data-name="' + item.content + '">删除</a>';
return str;
}
}
];
//热搜词管理页面
case PagEnum.HOT_SEARCH_WORDS :
return [
{display: "序号", name: "id"},
{display: "内容", name: "content"},
{display: "频道", name: "channelNames"},
{ display: "PC链接", name:"matchPcUrl" },
{ display: "移动端链接", name:"matchAppUrl" },
{
display: "状态", name: "status", render: function (item) {
if (item.status === StatusEnum.ON) {
return "<span>开启</span>";
} else {
return "<span>关闭</span>";
}
}
},
{display: "排序", name: "sort"},
{
display: "时间状态", name: "timeStatus", render: function (item) {
if (item.timeStatus === TimeStatusEnum.BEFORE) {
return "<span>未开始</span>";
}else if (item.timeStatus === TimeStatusEnum.ING) {
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) {
var str = '<a class="btn btn-xs btn-info modify" data-index="' + item.__index + '">修改</a>';
str = str+ '<a class="btn btn-xs btn-danger del-a" data-index="' + item.id + '" data-name="' + item.content + '">删除</a>';
return str;
}
}
];
//同义词管理页面
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) {
var str = '<a class="btn btn-xs btn-info modify" data-index="' + item.__index + '">修改</a>';
str = str+ '<a class="btn btn-xs btn-danger del-a" data-index="' + item.id + '" data-name="' + item.content + '">删除</a>';
return str;
}
}
];
//停用词管理页面
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) {
var str = '<a class="btn btn-xs btn-info modify" data-index="' + item.__index + '">修改</a>';
str = str+ '<a class="btn btn-xs btn-danger del-a" data-index="' + item.id + '" data-name="' + item.content + '">删除</a>';
return str;
}
}
];
}
})()
});
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) {
if('channelIds'==name1){
if(obj[name1]){
if(obj[name1].indexOf($this.val()+ ',') != -1){
obj[name1] = obj[name1].replace($this.val()+ ',',"");
}else{
obj[name1] = obj[name1] + $this.val() + ',';
}
}else{
obj[name1] = $this.val()+ ',';
}
}else{
obj[name1] = $this.val();
}
});
});
$(document).on("click", "input[name='searchType']", function() {
var type = $(this).val();
Bll.module["searchType"] = type;
switch (type) {
case "1":
$(".search_type2").hide();
$("#matchPcUrl").removeAttr("required");
$("#matchAppAction").removeAttr("required");
$("#matchAppUrl").removeAttr("required");
break;
case "2":
$(".search_type2").show();
$("#matchPcUrl").attr("required", "required");
$("#matchAppAction").attr("required", "required");
$("#matchAppUrl").attr("required", "required");
break;
}
});
/**
* 查询按钮
*/
$("#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, "添加");
});
/**
* 清理搜索词缓存
*/
$("#filter-clear").click(function () {
common.util.__tip("开始清缓存","success");
common.util.__ajax2({
url: '/hotSearchBrand/clearSearchWordsCache'
}, function(res){
if (res.code == 200) {
// g.reload();
common.util.__tip("清缓存成功!","success");
}else{
common.util.__tip(res.data.message);
}
});
});
/**
* 修改
*/
$(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, "修改");
$(":checkbox").attr("disabled", true);
});
$(function(){
$.ajax({
type: 'POST',
dataType: 'json',
url: "/salesCategory/querySCListByLevel",
data: {levelNumber: '1'},
async: false
}).then(function (data) {
if (data.code === 200) {
categoryList = data.data;
for(var i=0; i<categoryList.length; i++){
var categoryName = categoryList[i].categoryName;
var categoryId = categoryList[i].categoryId;
html = '<option value="'+categoryId+'" >'+categoryName+'</option>';
$("#channelIds-filter").append(html);
}
}
});
});
/**
* 删除图片
*/
$(document).on("click", ".del-btn", function () {
var event = $(this).data('event');
var key = $(this).data('key');
console.log($(this).parent().find("input[name='file']"));
Bll.module = common.util.__buildobj(key, '.', Bll.module, function (obj, name) {
obj[name] = '';
});
$(this).parent().find(".upload-image-list .fileinput-button-icon").html('+');
});
/**
* 删除默认搜索词
*/
$(document).on("click", ".del-a", function () {
var item = $(this).data('index');
var name = $(this).data('name');
common.dialog.confirm("温馨提示", "确定  <b><font color='#ff0000'>删除 </font>【" + name + "】</b> 吗?", function() {
common.util.__ajax2({
url: '/hotSearchBrand/delSearchWords',
data: {
id: item
}
}, function(res){
if (res.code == 200) {
// g.reload();
$("#filter-btn").click();
common.util.__tip("删除成功!","success");
}else{
common.util.__tip(res.data.message);
}
})
});
});
/***/ }
]);