resource.resourceManage.Index.js
6.4 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
webpackJsonp([153],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {
/**
* Created by ty on 2016/3/30.
* 资源管理
*/
var $ = __webpack_require__(1),
common = __webpack_require__(2),
util = __webpack_require__(13);
var resSorts = {},
resPlatforms = {};
/*导航栏筛选*/
common.util.__ajax({
url: "/resources/getResSorts",//获取所有资源
data: {}
},function(res) {
$("#category-content").html(common.util.__template2($("#search-category").html(), res));
new common.dropDown({el: "#choose-category"});
resSorts = res.data;
},true);
common.util.__ajax({
url: "/resources/getResPlatforms",//获取所有平台
data: {}
},function(res) {
$("#platform-content").html(common.util.__template2($("#search-platform").html(), res));
new common.dropDown({el: "#choose-platform"});
resPlatforms = res.data;
},true);
var g = new common.grid({
el: "#content-list",
hash: false,
parms: function () {
return {
id: common.util.__input('inputResourceId'),
name: common.util.__input('inputResourceName'),
sortId: common.util.__input('choose-category'),
platformId: common.util.__input('choose-platform'),
code:common.util.__input('inputResourceCode')
};
},
columns:[
{display: "ID", name: "id"},
{display: "资源", name: "name"},
{display: "分类", name: "sortName"},
{display: "平台", name: "platformName"},
{display: "位置码", name: "code"},
{display: "配置说明", name: "", render: function(item) {
if (item.configDesc){
var configDescT = item.configDesc;
return configDescT.substring(0,16)+"......";
}else{
return "";
}
}},
{display: "创建时间", name: "", render: function(item) {
return Bll.getLocalTime(item.createTime);
}},
{display: "锁定人", name: "lockPersonName"},
{display: "锁定时间", name: "",render:function(item){
if(item.lockPersonName !=''){
return Bll.getLocalTime(item.lockTime);
}
}},
{display: "操作", name: "",render: function(item) {
var arr = [];
arr.push('<a target="_blank" class="btn btn-xs btn-info contentManage" data-index="' + item.__index + '" href="/resource/content/index/0/'+'platform_'+item.platformName+'/t_0/' + item.id + '">内容查看</a>');
arr.push('<a target="_blank" class="btn btn-xs btn-primary add" data-index="' + item.__index + '" href="/resource/content/index/0/'+'platform_'+item.platformName+'/t_1/' + item.id + '">内容编辑</a>');
arr.push('<a class="btn btn-xs btn-primary add2" data-index="' + item.__index + '">编辑</a>');
//arr.push('<a class="btn btn-xs btn-danger delbtn" data-index="' + item.__index + '">删除</a>');
if(item.lockPersonName !=''){
arr.push('<a class="btn btn-xs btn-danger updateLockBtn" data-index="' + item.__index + '">解除锁定</a>');
}
return arr.join("");
}}
]
});
g.init("/resources/queryResource");
var Bll = {
getLocalTime:function(nS) {
var date = new Date(parseInt(nS) * 1000);
var mm = date.getMonth() + 1;
var dd = date.getDate();
var h = date.getHours();
var min = date.getMinutes();
var second = date.getSeconds();
return date.getFullYear() + "-" + (mm < 10 ? "0" + mm : mm) + "-" + (dd < 10 ? "0" + dd : dd) + " " + (h < 10 ? "0" + h : h) + ":"
+ (min < 10 ? "0" + min : min) + ":" + (second < 10 ? "0" + second : second);
},
toast: function (url, item, hint) {
var e = new common.edit("#base-form");
item.resSorts = resSorts;
item.resPlatforms = resPlatforms;
var dialog=common.dialog.confirm(hint,
common.util.__template2($("#edit-template").html(), item),
function() {
e.submit(url,function(option){
//option.data;
//console.log(option.data);
option.success=function(res){
dialog.close();
util.__tip(res.data.message, 'success');
g.reload();
};
option.error=function(res){
dialog.close();
util.__tip(res.data.message);
}
});
return false;
});
//
$("#configDesc").val(item.configDesc);
$("#platformId").val(item.platformId);
$("#sortId").val(item.sortId);
e.init();
// new common.dropDown({el: "#sortId"});
// new common.dropDown({el: "#platformId"});
if(hint.indexOf("编辑") != -1) {
$("#code-content").show();
}
}
}
$(document).on("click", "#add-resource", function () {
var item = {};
item.resSorts = resSorts;
item.resPlatforms = resPlatforms;
console.log(item);
Bll.toast("/resources/saveResource", item, "新增资源");
});
$(document).on("click", "#filter-btn",function() {
g.reload(1);
});
$(document).on("click", ".add2", function() {
var item = g.rows[$(this).data("index")];
item.resSorts = resSorts;
item.resPlatforms = resPlatforms;
Bll.toast("/resources/saveResource", item, "编辑资源");
});
/**
* 预发布版本
*/
$(document).on("click", ".delbtn", function() {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("警告", "是否确认删除?",function() {
common.util.__ajax({
url: "/resources/deleteAllResourceByCode",
data: {code: item.code}
}, function () {
g.reload();
});
});
});
/**
* 解除锁定
*/
$(document).on("click", ".updateLockBtn", function() {
var item = g.rows[$(this).data("index")];
common.dialog.confirm("警告", "是否确认解除锁定?",function() {
common.util.__ajax({
url: "/resources/updateLock",
data: {id: item.id,
status:0}
}, function () {
g.reload();
});
});
});
/***/ }
]);