|
@ -0,0 +1,141 @@
|
|
1
|
$(document).ready(function(){
|
|
2
|
var id = $.cookie('orgId');
|
|
3
|
var resourceId;
|
|
4
|
/*资源列表查询*/
|
|
5
|
function getRecourceMe(n,isbind) {
|
|
6
|
var resourceNameVa=$("#resouceName").val();
|
|
7
|
var $info={};
|
|
8
|
$info.orgId=id;
|
|
9
|
$info.pageSize=3;
|
|
10
|
if(resourceNameVa !="") {
|
|
11
|
$info.key=resourceNameVa;
|
|
12
|
}
|
|
13
|
$info.pageNo=n;
|
|
14
|
$.ajax({
|
|
15
|
"url": "/ajax/resource/pqForOrg",
|
|
16
|
"type": "GET",
|
|
17
|
"success": function(data) {
|
|
18
|
console.log(data)
|
|
19
|
if(data.success) {
|
|
20
|
$("#resourceList").html("");
|
|
21
|
if(data.data.data.length==0) {
|
|
22
|
$("#resourceList").html("暂无数据").css("text-align","center");
|
|
23
|
return;
|
|
24
|
}else{
|
|
25
|
$("#resourceList").css("text-align","");
|
|
26
|
}
|
|
27
|
resourceHtml(data.data.data);
|
|
28
|
if(isbind == true) {
|
|
29
|
$(".tcdPageCode").createPage({
|
|
30
|
pageCount: Math.ceil(data.data.total / data.data.pageSize),
|
|
31
|
current: data.data.pageNo,
|
|
32
|
backFn: function(p) {
|
|
33
|
getRecourceMe(p,false);
|
|
34
|
}
|
|
35
|
});
|
|
36
|
}
|
|
37
|
}
|
|
38
|
},
|
|
39
|
"data": $info,
|
|
40
|
dataType: "json",
|
|
41
|
'error': function() {
|
|
42
|
$.MsgBox.Alert('提示', '服务器连接超时!');
|
|
43
|
}
|
|
44
|
});
|
|
45
|
}
|
|
46
|
getRecourceMe(1,true);
|
|
47
|
function resourceHtml($data) {
|
|
48
|
for(var i=0;i<$data.length;i++) {
|
|
49
|
var imgSrc="../images/default-resource.jpg";
|
|
50
|
var oTime,pageview="",draftLable="",oHtml,oLi='';
|
|
51
|
if($data[i].images.length) {
|
|
52
|
imgSrc="/data/resource/"+$data[i].images[0].imageSrc
|
|
53
|
}
|
|
54
|
console.log($data[i].status)
|
|
55
|
if($data[i].status==0) {
|
|
56
|
oTime="修改于 "+timeTran($data[i].modifyTime);
|
|
57
|
draftLable='<span class="draftLable">草稿</span>';
|
|
58
|
oHtml="resourceIssue.html";
|
|
59
|
oLi="class='draftList'"
|
|
60
|
}else{
|
|
61
|
oTime="发布于 "+timeTran($data[i].publishTime);
|
|
62
|
pageview='<li><span>阅读量 '+$data[i].pageViews+'</span></li>';
|
|
63
|
oHtml="resourceShow.html"
|
|
64
|
}
|
|
65
|
var oStr='<li '+oLi+'>'+
|
|
66
|
'<a href="'+oHtml+'?resourceId='+$data[i].resourceId+'" target="_blank">'+
|
|
67
|
'<div class="madiaHead resouseHead" style="background-image: url('+imgSrc+');"></div>' +
|
|
68
|
'<div class="madiaInfo">'+
|
|
69
|
'<p class="h1Font ellipsisSty">'+$data[i].resourceName+'</p>'+
|
|
70
|
'<ul class="h2Font clearfix">'+
|
|
71
|
'<li><span>'+oTime+'</span></li>'+pageview+
|
|
72
|
'</ul>'+draftLable+
|
|
73
|
'</div>'+
|
|
74
|
'</a>'+
|
|
75
|
'<ul class="madiaEdit">'+
|
|
76
|
'<li><span class="deteleThis2" data-id="'+$data[i].resourceId+'"></span></li>'+
|
|
77
|
'<li><span class="editThis" data-id="'+$data[i].resourceId+'"></span></li>'+
|
|
78
|
'</ul>'+
|
|
79
|
'</li>'
|
|
80
|
$("#resourceList").append(oStr);
|
|
81
|
}
|
|
82
|
}
|
|
83
|
/*时间格式转换*/
|
|
84
|
function timeTran(otm) {
|
|
85
|
var month, day, hour, minu;
|
|
86
|
var monFirst = otm.substring(4, 5);
|
|
87
|
var dayFirst = otm.substring(6, 7);
|
|
88
|
if(monFirst == "0") {
|
|
89
|
month = otm.substring(5, 6)
|
|
90
|
} else {
|
|
91
|
month = otm.substring(4, 6)
|
|
92
|
}
|
|
93
|
if(dayFirst == "0") {
|
|
94
|
day = otm.substring(7, 8);
|
|
95
|
} else {
|
|
96
|
day = otm.substring(6, 8);
|
|
97
|
}
|
|
98
|
hour = otm.substring(8, 10);
|
|
99
|
minu = otm.substring(10, 12);
|
|
100
|
return month + "月" + day + "日 " + hour + ":" + minu;
|
|
101
|
}
|
|
102
|
/*点击修改跳转修改页面*/
|
|
103
|
$("#resourceList").on("click",".editThis",function(){
|
|
104
|
location.href="resourceIssue.html?resourceId="+$(this).attr("data-id")
|
|
105
|
})
|
|
106
|
/*点击删除跳转修改页面*/
|
|
107
|
$("#resourceList").on("click",".deteleThis2",function(){
|
|
108
|
resourceId=$(this).attr("data-id");
|
|
109
|
$.MsgBox.Confirm("提示", "确认删除该资源?",deleResource);
|
|
110
|
})
|
|
111
|
/*删除函数*/
|
|
112
|
function deleResource() {
|
|
113
|
$.ajax({
|
|
114
|
"url": "/ajax/resource/delete",
|
|
115
|
"type": "POST",
|
|
116
|
"success": function(data) {
|
|
117
|
if(data.success) {
|
|
118
|
getRecourceMe(1,false);
|
|
119
|
}
|
|
120
|
},
|
|
121
|
"data": {"resourceId":resourceId},
|
|
122
|
"beforeSend": function() { /*console.log(this.data)*/ },
|
|
123
|
"contentType": "application/x-www-form-urlencoded",
|
|
124
|
dataType: "json"
|
|
125
|
});
|
|
126
|
}
|
|
127
|
/*输入资源名称限制字数*/
|
|
128
|
$("#resouceName").bind({
|
|
129
|
keyup: function() {
|
|
130
|
if($(this).val().length > 30) {
|
|
131
|
$(this).val($(this).val().substr(0, 30));
|
|
132
|
}
|
|
133
|
}
|
|
134
|
});
|
|
135
|
/*点击搜索*/
|
|
136
|
$(".searchSpan").click(function(){
|
|
137
|
$(".tcdPageCode").remove();
|
|
138
|
$(".aboutRes").append('<div class="tcdPageCode"></div>');
|
|
139
|
getRecourceMe(1,true);
|
|
140
|
})
|
|
141
|
})
|