|
|
/**
|
|
|
* Created by ty on 2016/3/30.
|
|
|
* 资源管理
|
|
|
*/
|
|
|
|
|
|
var $ = require('jquery'),
|
|
|
common = require('../common/common'),
|
|
|
util = require('../common/util');
|
|
|
|
|
|
/*导航栏筛选*/
|
|
|
common.util.__ajax({
|
|
|
url: "/resources/resourceManage/getResSorts",//获取所有资源
|
|
|
data: {}
|
|
|
},function(res) {
|
|
|
$("#category-content").html(common.util.__template2($("#search-category").html(), res));
|
|
|
new common.dropDown({el: "#choose-category"});
|
|
|
},true);
|
|
|
|
|
|
common.util.__ajax({
|
|
|
url: "/resources/resourceManage/getResPlatforms",//获取所有平台
|
|
|
data: {}
|
|
|
},function(res) {
|
|
|
$("#platform-content").html(common.util.__template2($("#search-platform").html(), res));
|
|
|
new common.dropDown({el: "#choose-platform"});
|
|
|
},true);
|
|
|
|
|
|
var g = new common.grid({
|
|
|
el: "#content-list",
|
|
|
hash: false,
|
|
|
parms: function () {
|
|
|
return {
|
|
|
name: common.util.__input('inputResourceName'),
|
|
|
sortId: common.util.__input('choose-category'),
|
|
|
platformId: common.util.__input('choose-platform')
|
|
|
};
|
|
|
},
|
|
|
columns:[
|
|
|
{display: "ID", name: "id"},
|
|
|
{display: "资源", name: "name"},
|
|
|
{display: "分类", name: "sortName"},
|
|
|
{display: "平台", name: "platformName"},
|
|
|
{display: "位置码", name: "code"},
|
|
|
{display: "匹配码", name: "matchCode"},
|
|
|
{display: "创建时间", name: "", render: function(item) {
|
|
|
return Bll.getLocalTime(item.createTime);
|
|
|
}},
|
|
|
{display: "操作", name: "",render: function(item) {
|
|
|
var arr = [];
|
|
|
arr.push('<a class="btn btn-primary contentManage" data-index="' + item.__index + '">内容管理</a>');
|
|
|
arr.push('<a class="btn btn-primary add2" data-index="' + item.__index + '">编辑</a>');
|
|
|
arr.push('<a class="btn btn-primary delbtn" data-index="' + item.__index + '">删除</a>');
|
|
|
return arr.join("");
|
|
|
}}
|
|
|
]
|
|
|
});
|
|
|
|
|
|
g.init("/resources/resourceManage/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");
|
|
|
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');
|
|
|
Bll.init();
|
|
|
};
|
|
|
option.error=function(res){
|
|
|
dialog.close();
|
|
|
util.__tip(res.data.message);
|
|
|
}
|
|
|
});
|
|
|
return false;
|
|
|
});
|
|
|
//
|
|
|
|
|
|
e.init();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$(document).on("click", "#add-resource", function () {
|
|
|
var item = {};
|
|
|
Bll.toast("11", item, "新增资源");
|
|
|
});
|
|
|
|
|
|
$(document).on("click", "#filter-btn",function() {
|
|
|
g.reload(1);
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|