publishArticle.html
16.6 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Yoho!Buy运营平台</title>
<script src="/pfcms/js/include.js"></script>
<script src="/pfcms/js/ajaxfileupload.js"></script>
<script src="/pfcms/js/jquery.imageUpload.js"></script>
<style>
.btn-long {
width: 120px;
height: 37px;
line-height: 37px;
font-size: 15px;
color: white;
border-radius: 5px;
display: inline-block;
cursor: pointer;
text-align: center;
}
.btn-long:hover {
opacity: 0.9;
}
</style>
</head>
<body class="easyui-layout" >
<div region="north" style="height: 100px;">
<script>
document.write(addHead('种草社区管理', '种草内容发布'));
</script>
</div>
<div region="center" id="labelGroupList" style="margin-left: 20px">
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
<form name="publishArticleForm" id="publishArticleForm" method="post" >
<div style="margin-top: 20px;margin-left: 30px">
<table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
<tr style="height: 60px">
<td >
<span style="color:red">*</span><label>选择用户</label> <br>
<input id="articleUid" name="authorUid" style="width:60% " class="easyui-combobox" />
</td>
</tr>
<tr style="height: 60px">
<td>
<span style="color:red">*</span><label>文字内容</label> <br>
<textarea rows="2" id="content" style="width:60% " name = "content" class="form-control" placeholder="" required="" maxlength="145"></textarea> </td>
</tr>
<tr style="height: 60px">
<td>
<label>选择标签</label> <br>
<input id="labelId" name="labelId" class="easyui-combobox" style="width:60% "/>
<input id="labelIds" name="labelIds" hidden="hidden"/>
</td>
</tr>
<tr style="height: 20px">
<td >
<span style="color:red">*</span><label>选择图片</label><br>
<!--<a id="addImage" class="btn btn-primary" >选择图片+</a>-->
<input id="imgs" name="articleImages" hidden="hidden"/>
</td>
</tr>
<tr style="height: 60px">
<td id="imgTd">
<div id="imageUpload1">
</div>
</td>
</tr>
<tr style="height: 60px">
<td>
<label>关联商品</label> <br>
<a id="addSkn" class="btn btn-primary" style="font-size: 15px">选择商品+</a>
<input id="skns" name="articleSkns" hidden="hidden"/>
</td>
</tr>
<tr style="height: 60px">
<td id="goodstd">
<div id="good0" style="float: left;margin-left: 30px;width: 150px;">
</div>
</td>
</tr>
<tr>
<td valign="bottom">
<input id="subBotton" class="btn btn-primary" style="font-size: 20px; margin-top: 0px;margin-bottom: 0px;" value="保存"/>
</td>
</tr>
</table>
</div>
</form>
</div>
</div>
</body>
<script>
var count = 1;
var checkedItems = [];
var checkedItemsObj = {};
var searchType = 1;
var checkType = 1;
$(function () {
$("#addImage").linkbutton({
iconCls : "icon-search",
onClick : function() {
}
});
$("#addSkn").linkbutton({
iconCls : "icon-search",
onClick : function() {
getEditDialog();
}
});
$("#articleUid").combobox({
required: true,
editable:false,
missingMessage: "发布用户不能为空",
prompt: "请输入发布用户",
selectOnNavigation : true,
valueField: 'text',
textField: 'value',
url : serverContextPath + "/grassArticle/platPublishUser",
loadFilter: function (data) {
var list = [];
debugger;
for (var i = 0; i < data.data.length; i++) {
var obj = {};
obj['text'] = data.data[i];
obj['value'] = data.data[i];
list.push(obj);
}
return list;
}
});
$("#labelId").combobox({
prompt: "请选择标签",
required: false,
selectOnNavigation : true,
valueField: 'id',
textField: 'labelName',
multiple:true,
url : serverContextPath + "/grassLabelManage/getAllGrassLabelInfo",
loadFilter: function (data) {
return defaultLoadFilter(data);
}
});
$("#subBotton").linkbutton({
iconCls: "icon-save",
width:100,
onClick: function () {
$("#publishArticleForm").form("submit",{
url : serverContextPath+"/grassArticle/publishArticle",
onSubmit : function(param) {
debugger;
if (!$("#publishArticleForm").form("validate")) {
return false;
}
if($("#articleUid").combobox("getValue") == ''){
return false;
}
var imgs = '';
var imageCount = 0;
$("input[name='url']").each(function(j,item){
debugger
var url = item.value;
if(imgs == ''){
imgs = url;
}else{
imgs = imgs + ","+url;
}
imageCount++;
});
$("#imgs").val(imgs);
if(imageCount > 9){
$.messager.alert("保存失败", "最多只能选择9张图片", "error");
return false;
}
var labels = '';
$("input[name='labelId']").each(function(j,item){
debugger
var id = item.value;
if(labels == ''){
labels = id;
}else{
labels = labels + ","+id;
}
});
$("#labelIds").val(labels);
return true;
},
success : function(data) {
if (data) {
data = $.parseJSON(data);
if (data.code == 200) {
$.messager.alert("提示","保存成功", "info", function(){window.location.reload()});
// alert("保存成功");
} else {
$.messager.alert("保存失败", data.message, "error");
}
} else {
$.messager.alert("保存失败", data.message, "error");
}
}
});
}
});
$("#imageUpload1").imageUpload({
width: 171,
height: 120,
realInputName: "url",
uploadInputName: "files",
url: serverContextPath + '/fileupload/uploads',
queryParams: {
bucket: "grassImg"
},
onBeforeSubmit: function () {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
},
filterFileName: function (data) {
debugger;
if (!data || data.code != 200) {
$.messager.progress("close");
$.messager.alert("错误",data.message);
return "";
}
return data.data[0];
},
onLoadSuccess: function (data) {
debugger;
initimg(1,data.data.length);
for (var i= 1; i<= data.data.length; i++){
$("#imageUpload"+i).imageUpload("setValue",data.data[i-1])
}
$.messager.progress("close");
return false;
},
onClose:function(data){
$("#imageUpload1").remove();
}
});
});
// 编辑分组
function getEditDialog(data){
var labelGroupList = $("<div id='labelGroupList'>").appendTo($(document.body));
var title = "选择商品";
var textVar = "确认";
var msgVar = "确认新增吗?";
window.self.paramObject.mkData = data;
$(labelGroupList).myDialog({
title: title,
width: "70%",
height: "80%",
resizable:false,
buttons:[{
id : "saveBtn",
text:textVar,
iconCls : "icon-save",
handler:function(){
debugger;
$("#goodstd").html("<div id=\"good0\" style=\"float: left;margin-left: 30px;width: 300px\">\n" +
" </div>");
var skns = '';
for (var i = 0; i < checkedItems.length; i++) {
buildgood(i,checkedItems[i]);
if( i == checkedItems.length -1){
skns = skns+ checkedItems[i]
}else{
skns = skns+ checkedItems[i] +","
}
}
$("#skns").val(skns);
$(labelGroupList).dialog("close");
}
}, {
text: "关闭",
iconCls: "icon-cancel",
handler: function () {
$.messager.confirm("确认", "确认关闭吗?", function (flag) {
if(flag){
$(labelGroupList).dialog("close");
}
});
}
}],
modal: true,
href: contextPath + "/html/grass/article/chooseSkns.html"
});
}
function oo(num){
// debugger
// if(num >9){
// return
// }
var imageCount = 0;
$("input[name='url']").each(function(j,item){
debugger
var url = item.value;
if(imgs == ''){
imgs = url;
}else{
imgs = imgs + ","+url;
}
imageCount++;
});
if(imageCount > 9 ){
return;
}
$("#imageUpload"+num).imageUpload({
width: 171,
height: 120,
realInputName: "url",
uploadInputName: "files",
url: serverContextPath + '/fileupload/uploads',
queryParams: {
bucket: "grassImg"
},
onBeforeSubmit: function () {
$.messager.progress({
title: "正在执行",
msg: "正在执行,请稍后...",
interval: 500,
text: ""
});
},
filterFileName: function (data) {
debugger;
if (!data || data.code != 200) {
$.messager.progress("close");
$.messager.alert("错误",data.message);
return "";
}
return data.data[0];
},
onLoadSuccess: function (data) {
debugger;
initimg(num,data.data.length);
var c =0;
for (var i= 0; i<= data.data.length; i++){
nnum = num +i;
$("#imageUpload"+nnum).imageUpload("setValue",data.data[c]);
c++;
}
$.messager.progress("close");
return false;
},
onClose:function(data){
$("#imageUpload"+num).remove();
}
});
}
function initimg(m,n) {
for (var i =1 ; i<=n; i++){
debugger
var nnum = m+i;
$("#imageUpload"+(nnum-1)).after('<div id="imageUpload'+nnum+'"> </div>');
count = count+1;
oo(nnum);
}
}
function buildgood(index,obj) {
debugger;
var data = checkedItemsObj[obj];
$("#good"+index).html(gooddiv(data));
$div = $("#good"+(index+1));
$("#good"+index).after('<div id="good'+(index+1)+'"style="float: left;margin-left: 30px;width: 300px"> </div>');
}
function gooddiv(data) {
return " <span>商品图:<img width=\"120\" height=\"60\" src="+getImageUrl(data.default_images)+
" /> </span>" +
"<h5 style=\"margin-top: 0px;margin-bottom: 0px\">商品名:"+ data.product_name +"</h5>\n" +
"<h5 style=\"margin-top: 0px;margin-bottom: 0px\">价格:"+data.sales_price+"</h5>"
}
function getImageUrl(image) {
var result='';
if (image) {
if(image.indexOf('http://') == 0){
result = image.split("?")[0];
}else{
var fileMode = image.substring(15, 17);
if(fileMode=='01'){
result= "http://"+"img11.static.yhbimg.com"+"/goodsimg"+image;
}
if(fileMode=='02'){
result= "http://"+"img12.static.yhbimg.com"+"/goodsimg"+image;
}
}
}
else {
result = ""
}
if (result) {
return result + "?imageMogr2/thumbnail/320x320/extent/320x320/background/d2hpdGU=/position/center/quality/90";
} else {
return "";
}
}
function findCheckedItem(ID) {
for (var i = 0; i < checkedItems.length; i++) {
if (checkedItems[i] == ID) return i;
}
return -1;
}
function addcheckItem() {
if(searchType != checkType && checkedItems.length>0){
checkedItems=[];
}
checkType = searchType;
var i=0;
$("input[type='checkbox'][name='product_skn']:checked").each(function () {
if(i > 4){
alert("最多只能选择五个商品");
return false;
}
var k = findCheckedItem($(this).val());
if (k == -1) {
checkedItems.push($(this).val());
}
i++;
});
}
function removeAllItem(rows) {
$("input[type='checkbox'][name='product_skn']").each(function () {
if (!this.checked) {
var k = findCheckedItem($(this).val());
if (k != -1) {
checkedItems.splice(k, 1);
}
}
});
}
function resetSelectedCheckBox(data){
$("input[type='checkbox'][name='product_skn']").each(function () {
var cb=$(this);
$.each(checkedItems,function(index,value){
if(value==cb.val()){
cb.attr("checked",true);
return false;
}
});
});
}
function removeSingleItem(rowIndex, rowData) {
var k = findCheckedItem(rowData.product_skn);
if (k != -1) {
checkedItems.splice(k, 1);
}
}
</script>
</html>