add.vm
8.23 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
<script src="/assets/js/jquery.js"></script>
<script src="/assets/js/riotjs/riotjs.js"></script>
<script src="/assets/products/product.search.categroy.js"></script>
<script src="/assets/products/addProductSearchCate.js"></script>
<script type="text/javascript" src="http://static.1n4j.com/static/newStatic/common/js/base/sea.js"></script>
<script type="text/javascript" src="http://static.1n4j.com/static/newStatic/pnr/js/javascript/common/config.js"></script>
<link rel="stylesheet" type="text/css" href="http://static.1n4j.com/static/newStatic/pnr/backstage/css/fancy.css">
<DIV id="navBar" title="productSearchCate">
<li><a href="$!{contextPath}/">首页</a><span class="divider">></span>
<a href="$!{contextPath}/titan/sctop">市场置顶排序</a></li>
</DIV>
<input type="hidden" id="searchCid" value="$!{cid}">
<form class="well form-search" name="productSearchCateForm" action="/titan/sctop" method="POST">
请选择批发市场:<select name="cid" id="scSelect">
<option value="-1">请选择批发市场</option>
</select>
<button type="submit" class="btn btn-sm btn-primary"><i class="icon-search icon-white"></i>搜索</button>
<button type="button" class="btn btn-sm btn-primary btn-clear">清除</button>
<a class="btn btn-sm btn-primary act-fancy" href="#fancyalter" style="float:right">添加市场</a>
</form>
<!-- 表格数据 -->
<table class="table table-striped table-bordered table-condensed grid">
<thead>
<tr>
<th #sorting($!{productSearchSort} "id")>编号</th>
<th #sorting($!{productSearchSort} "categoryName")>市场</th>
<th #sorting($!{productSearchSort} "ProductSearchSortCount")>推荐商品数量</th>
<th>操作</th>
</tr>
</thead>
<tbody>
#foreach(${item} in ${page.result})
<tr>
<td style="width:20%;text-align:center;vertical-align:middle;">$!{item.id}</td>
<td style="width:35%;text-align:center;vertical-align:middle;">$!{item.name}</td>
<td style="width:20%;text-align:center;vertical-align:middle;">$!{item.ProductSearchSortCount}</td>
<td class="textC" style="width:20%;text-align:center;vertical-align:middle;">
<div class="btn-group">
<a href="/titan/sctop/sortlist?cateId=${item.cid}"><i class="icon-eye-open"></i> 添加排序商品</a>
<a href="javascript:void(0)" onclick="deleteSearchCate($!{item.cid})"><i class="icon-pencil"></i> 删除</a>
</div>
</td>
</tr>
#end
</tbody>
</table>
<div class="fancyalter" id="fancyalter">
<h2 class="alterhd">添加市场</h2>
<div class="alterbd">
<div class="fancysearch">
<div class="completethis" id="completethisId" style="width:550px">
<input id="sccid" type="hidden" name="cid" />
<input id="sc" data-provide="typeahead" class="span align-middle input-medium" type="text" name="pickName" style="width: 200px" placeholder="市场名称" autocomplete="off" />
</div>
</div>
<div class="completethis">
<a href="#" class="addsucc" id="addsc">确定添加</a>
</div>
</div>
</div>
<!-- 分页栏 -->
#showPage($!{page})
<script src="/assets/js/underscore.js"></script>
<script>
$(document).ready(function(){
$(".btn-clear").click(function(){
// $("#scSelect").val("-1");
window.location.href="/titan/sctop";
})
//添加市场弹出框中的 搜索市场
var providers;
$('#sc').typeahead({
source: function(query, process) {
var keyword = $("input[id='sc']").val();
$.ajax({
async : false,
type : "post",
url : "/common/searchSc",
data : {keyword : keyword},
dataType : "json",
success : function(data){
providers = new Array();
if(data && data.length > 0){
$.each(data , function(i, n){
if(n){
var obj = new Object();
obj.id = n.id;
obj.pickName = n.pickName;
providers[i]=obj;
}
});
};
},
error : function(){
XUI.window.alert("网络错误,请稍后重试");
}
});
var results = _.map(providers, function(provider) {
return provider.id + "";
});
process(results);
},
matcher: function (item) {
return true;
},
highlighter: function(id) {
var provider = _.find(providers, function(p) {
return p.id == id;
});
return provider.pickName ;
},
updater: function(id) {
var provider = _.find(providers, function(p) {
return p.id == id;
});
$("#sccid").val(id);
return provider.pickName ;
}
});
//获取当前添加的市场
$.ajax({
async : false,
type : "post",
url : "/titan/sctop/getAllSc",
// data : {keyword : keyword},
dataType : "json",
success : function(data){
if(data && data.length > 0){
var searchCid = $("#searchCid").val();
$.each(data , function(i, n){
if(n){
if(searchCid && searchCid== n.id){
$("#scSelect").append("<option selected='selected' value='" + n.id + "'>" + n.pickName + "</option>")
}else {
$("#scSelect").append("<option value='" + n.id + "'>" + n.pickName + "</option>")
}
}
});
};
},
error : function(){
XUI.window.alert("网络错误,请稍后重试");
}
});
//添加市场
$("#addsc").live('click', function(){
var cateStr = $("#sccid").val();
if(cateStr == null || cateStr==""){
XUI.window.alert("请选择需要添加的市场!");
return ;
}
$.ajax({
type : "post",
dataType : "json",
url : "/titan/sctop/save",
data : {"cid" : cateStr},
success : function(data){
if(data.code == "success"){
window.location.href="/titan/sctop";
}else{
XUI.window.alert(data.result);
}
},
error : function(){
XUI.window.alert("网络错误,请稍后重试");
}
});
});
});
function deleteSearchCate(cid){
XUI.window.confirm("确定要删除排序市场吗?", "删除排序市场", function(){
$.ajax({
type : "post",
dataType : "json",
url : "/titan/sctop/delete",
data : {cateId : cid},
success : function(data){
if(data.code == "success"){
//XUI.window.alert(" 排序分类已成功删除,若以后还需要对该分类商品进行排序,请重新添加排序分类!");
window.location.href="/titan/sctop";
}else{
XUI.window.alert(data.result);
}
},
error : function(){
XUI.window.alert("网络错误,请稍后重试");
}
});
});
}
seajs.use(['fancybox'], function(fancybox){
$(".act-fancy").fancybox({
scrolling: 'visible',
afterClose: function(){
$("#sc").val("");
$("#sccid").val("");
// $("#productCategoryId select:first option:first").change();
}
});
});
</script>