contentEdit.js
2.19 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
var $ = require('jquery'),
common = require('../common/common');
var ENUM={};
// common.util.__ajax({
// url:'/guang/article/getEnumList',
// async:false
// },function(res){
// ENUM=res.data;
// });
console.log(ENUM);
$("#panel-body").html(common.util.__template2($("#tempalte1").html(),ENUM));
new common.dropDown({el:"#authorId",ajax:"guangGetAuthorList"});
new common.dropDown({el:"#maxSortId",ajax:"guangGetSort",params:function(){
return {pid:0};
}});
new common.dropDown({el:"#minSortId",ajax:"guangGetSort",params:function(){
return {pid:$("#maxSortId").val()};
}});
var g= new common.grid({
el:"#gird",
columns:[
{display:"选择","type":"checkbox"},
{display:"标签名",name:"tagName"}
]
});
var Url={},Urls=[];
$(document).on("click","#addUrl",function(){
common.dialog.confirm("添加链接",common.util.__template2($("#template2").html(),{}),function(){
Url[$("#goTo").val()]=$("#goToUrl").val();
//todo
Urls=[];
for(var i in Url){
Urls.push({url:i,text:Url[i]});
}
$("#url").val(JSON.stringify(Urls));
});
});
$(document).on("click","#TagsSelectBtn",function(){
common.dialog.confirm("选择标签","<div id='gird'></div>",function(){
$("#taglist").html(common.util.__template2($("#template4").html(),{tags:g.selected}));
});
g.init('/guang/tags/getList');
});
$(document).on("click",".tag a",function(){
g.selected.splice($(this).data("index"),1);
$("#taglist").html(common.util.__template2($("#template4").html(),{tags:g.selected}));
return false;
});
var Brand={},Brands=[];
$(document).on("click","#addBrands",function(){
common.util.__ajax({url:'/goods/brands/queryBrandsByStatus'},function(res){
res.data.forEach(function(item,index){
var brandAlif=item.brandAlif.toUpperCase();
if(/^[0-9]$/.test(item.brandAlif)){
brandAlif="0-9";
}
if(/^\W$/.test(item.brandAlif)){
brandAlif="#";
}
Brand[brandAlif]=Brand[brandAlif]||[];
Brand[brandAlif].push(item);
});
for(var i in Brand){
Brands.push({name:i,items:Brand[i]});
}
console.log(JSON.stringify(Brands));
},true);
});
var e=new common.edit("#panel-body",{});
e.init();
$(document).on("click","#submit",function(){
e.submit($("#panel-body").attr("action"),function(){
});
});