seo_root_add.hbs
6.52 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
<style>
.brand-list {
max-height: 400px;
overflow: auto;
}
.brand-list a{
display:inline-block;
color: #000;
padding: 5px 10px;
margin: 3px 0;
}
.brand-list a.active{
color: #fff;
background: #428bca;
padding: 5px 10px;
}
</style>
<div class="pageheader">
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body">
<ul class="breadcrumb">
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="/seo/tdk">{{title}}</a></li>
<li>{{typeName}}</li>
</ul>
<h4>{{title}}</h4>
</div>
</div>
<!-- media -->
</div>
<!-- pageheader -->
<div class="contentpanel seo-root-page" style="padding-bottom:0;">
<div class="panel panel-default">
<div class="panel-body">
<div class="form-group">
<label for="exampleInputEmail1">词根</label>
<input type="text" name="rootWord" class="form-control" value="" >
</div>
<div class="form-group">
<label >品牌</label>
<ul id="brandTab" class="nav nav-tabs brand-category">
{{#each brand}}
<li {{#if @first}}class="active"{{/if}}><a href="#{{@key}}" data-toggle="tab">{{@key}}</a></li>
{{/each}}
</ul>
<div id="brandTabContent" class="tab-content brand-list">
{{#each brand}}
<div class="tab-pane fade {{#if @first}}in active{{/if}}" id="{{@key}}">
{{# .}}<a data-id="{{id}}"> {{brandName}} </a>{{/ .}}
</div>
{{/each}}
</div>
</div>
<div class="form-group">
<label for="exampleInputEmail1">品类</label>
<div class="row">
<div class="col-md-3">
<select id="msort" class="form-control">
<option class="form-control" value="0">请选择</option>
{{#each sort}}
<option data="{{id}}" value="{{id}}" class="form-control">{{sortName}}</option>
{{/each}}
</select>
</div>
<div class="col-md-3">
<select id="misort" class="form-control">
<option class="form-control" value="0" selected>请选择</option>
</select>
</div>
<div class="col-md-3">
<select id="sort" class="form-control">
<option class="form-control" value="0" selected>请选择</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="exampleInputEmail1">过滤词</label>
<input type="text" name="filterWord" class="form-control" >
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="isKeyword" class="form-control"> 是否是关键词
</label>
</div>
<button type="submit" id="submit" class="btn btn-default">提交</button>
</div>
</div>
</div>
<script>
$(function(){
var $brand = $('.brand-list a');
var $msort = $('#msort'), $misort = $('#misort'), $sort = $('#sort');
var $submit = $('#submit');
var $rootWord = $('input[name=rootWord]');
var $filterWord = $('input[name=filterWord]');
var $isKeyword = $('input[name=isKeyword]');
var rootWord = '', brand = 0, msort = 0, misort = 0, sort = 0, filterWord = '', formData;
// 选择品牌
$brand.on('click', function(){
// $brand.removeClass('active');
if(!$(this).hasClass('active')) {
$brand.removeClass('active');
$(this).addClass('active');
brand = $(this).data('id');
} else {
brand = 0;
$brand.removeClass('active');
}
})
// 切换大分类
$msort.on('change',function() {
selectInit('misort');
selectInit('sort');
getSubSorts($(this).val(), 'misort');
})
// 切换中分类
$misort.on('change',function() {
selectInit('sort');
getSubSorts($(this).val(), 'sort');
})
// 提交
$submit.on('click', function(){
rootWord = $rootWord.val();
filterWord = $filterWord.val();
msort = $msort.val();
misort = $misort.val();
sort = $sort.val();
if (rootWord == '') {
alert('词根必填');
return;
}
if (misort == 0) {
misort = msort;
}
if (sort == 0) {
sort = misort;
}
if (brand == 0 || filterWord == '') {
confirm('确认品牌或筛选词不填?');
}
formData = {
rootWord: rootWord,
brand: brand,
sort: sort,
filterWord: filterWord,
isKeyword: $isKeyword.attr('checked') ? 1 : 0
}
$.ajax({
url: '/seo/rootwords/doadd',
dataType: 'json',
type: 'POST',
data: formData,
success: function(res) {
if (res.code == 200) {
location.href = '/seo/rootwords';
} else {
alert(res.message);
}
},
error: function(err) {
console.log(err);
}
});
})
// 获取子分类数据
function getSubSorts(sortId, id) {
$.ajax({
url: '/seo/rootwords/getsubsorts',
dataType: 'json',
type: 'POST',
data: {
sortId: sortId
},
success: function(data) {
var option = '';
$.each(data, function(key, val) {
option +='<option value="' + val.sort_id + '">' + val.sort_name + '</option>';
});
$('#'+id).append(option);
},
error: function(err) {
console.log(err);
}
});
}
// 清空子分类
function selectInit(id) {
$('#'+id).html('<option class="form-control" value="0">请选择</option>');
}
})
</script>