index.js
12.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
/**
* Created by wangqianjun on 16/2/23.
*/
var $ = require('jquery'),
common = require('../common/common');
//require('../util/datepicker');
// 热搜词状态xxz
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//停用词管理页面
};
// 下拉框
new common.dropDown({el: "#status-filter"});
new common.dropDown({el: "#channel-ops"});
// 初始化日期插件
new common.edit("#filter").init();
var type = GetQueryString("type");
function GetQueryString(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
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.PULL_DOWN_WORDS :
//热搜词管理页面
case PagEnum.HOT_SEARCH_WORDS :
//同义词管理页面
case PagEnum.SYNONYMS_ :
//停用词管理页面
case PagEnum.DISABLE_WORDS :
return {
type:type,
channelIds: $.trim($('#channel-ops').val()),
status: $.trim(common.util.__input("status-filter")),
content: $.trim($('#content-filter').val())
};
}
},
columns:
(function () {
console.log('type = ' + type);
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="'+item.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) {
return '<a href="'+item.url+'">'+item.url+'</a>'
}},
{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($('#route').val());
$("#filter-btn").click(function(){
g.reload(1);
});
$("#filter-add").click(function() {
//初始化弹框的底部红色说明
searchWordOp("添加", '/operations/terms/add', {});
});
$(document).on("click",".modify",function () {
var item = g.rows[$(this).data('index')];
searchWordOp("修改", '/operations/terms/modify', item);
});
function searchWordOp (prefix, url, item) {
var templates = {
1: {
templAdd:['template-channel', 'template-content', 'template-url', 'template-sarttime', 'template-endtime','template-tips'],
title: '默认热搜词',
templModify:['template-channel', 'template-content', 'template-url', 'template-sarttime', 'template-endtime','template-modify','template-tips'],
tips: '注:默认热搜索词是默认显示在前台搜索框里的词或者短语'
},
2: {
templAdd:['template-content', 'template-goodsnum', 'template-sort', 'template-tips'],
templModify:['template-content', 'template-goodsnum', 'template-sort', 'template-modify','template-tips'],
title: '下拉词',
tips: '注:下拉词是前台输入框获取焦点之后下拉显示的词'
},
3: {
templAdd:['template-channel', 'template-content', 'template-url', 'template-sort','template-tips'],
templModify:['template-channel', 'template-content', 'template-url', 'template-sort', 'template-modify','template-tips'],
title: '热搜词',
tips: '注:热搜词是前台搜索框下面的词'
},
4: {
templAdd:['template-content', 'template-tips'],
templModify:['template-content', 'template-modify', 'template-tips'],
title: '同义词',
tips: '注:同义词,比如阿迪达斯和三叶草就是一对同义词'
},
5: {
templAdd:['template-content', 'template-tips'],
templModify:['template-content', 'template-modify', 'template-tips'],
title: '停用词',
tips: '注:停用词是指搜索引擎不进行拆分检索的词'
},
};
var t=[];
var templ = templates[parseInt(type)];
var tmp = (prefix=="添加")? templ.templAdd:templ.templModify;
console.log(tmp);
for(var templID in tmp) {
t.push($('#'+tmp[templID]).html());
}
var a =new common.edit(".confirm");
item.tips = templ.tips;
item.type = type;
common.dialog.confirm(prefix+templ.title, common.util.__template( t.join(""), item), function () {
//
return a.submit(url,function(option){
option.success=function(res){
res=res.data;
if(res.code=="200"){
a.$tip("提交成功", function() {
g.reload();
}, 'growl-success');
}else{
a.$tip(res.message);
}
return false;
},
option.error=function(res){
a.$tip(res.message);
}
});
});
//$('#i-tips').html(templ.tips);
a.init();
}
// 根据type判断显不显示【开始时间】和【结束时间】
(function () {
var titles={
1:{name1:"默认热搜词列表",name2:"默认热搜词列表"},
2:{name1:"下拉词列表",name2:"下拉词列表"},
3:{name1:"热搜词列表",name2:"热搜词列表"},
4:{name1:"同义词列表",name2:"同义词列表"},
5:{name1:"停用词列表",name2:"停用词列表"}
}
//只有默认热搜词才显示时间选择
if (parseInt(type) == PagEnum.DEF_HOT_SEARCH_WORDS) {
$('#starttime-filter').show();
$('#endtime-filter').show();
} else {
$('#starttime-filter').hide();
$('#endtime-filter').hide();
}
var tem=common.util.__template($("#template").html(),titles[parseInt(type)]);
$(".media-body").html(tem);
})()