Authored by 陶雨

资源管理

/**
* 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
... ...
... ... @@ -68,7 +68,7 @@ var Bll = {
function() {
e.submit(url,function(option){
//option.data;
console.log(option.data);
//console.log(option.data);
option.success=function(res){
dialog.close();
util.__tip(res.data.message, 'success');
... ...
/**
* Created by ty on 2016/3/30.
* 资源管理路由
*/
//exports.domain = require('../config/common.js').domain;
exports.domain = 'http://172.16.6.115:8080/platform';//王伟
//exports.domain = 'http://192.168.102.216:8180/platform'; //测试环境
exports.res = [
{
route: "/resource/index/index1",
method: "GET",
view: "pages/sourceManage/resourceManage",
src: "/sourceManage/resourceManage"
},
{
route: "/resources/resourceManage/queryResource",
method: "POST",
url: "/resources/queryResource",
params: [
{name: "name", type: "string"},
{name: "sortId", type: "number"},
{name: "platformId", type: "number"},
{name: "page", type: "number"}
]
},
{
route: "/resources/resourceManage/getResSorts",
method: "POST",
url: "/resources/getResSorts",
params: []
},
{
route: "/resources/resourceManage/getResPlatforms",
method: "POST",
url: "/resources/getResPlatforms",
params: []
}
];
\ No newline at end of file
... ...
<div class="pageheader">
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body">
<ul class="breadcrumb">
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="">资源管理</a></li>
<li>资源管理</li>
</ul>
<div>
<div style="width: 30%;float: left;">
<h4>资源管理</h4>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default" style="margin-bottom:10px;">
<div class="panel-heading">
<a class="btn btn-success " id="add-resource"><i class="fa fa-plus"></i> 添加资源位</a>
</div>
<div class="panel-body">
<div class="row">
<div class="panel-col">
<input type="text" id="inputResourceName" placeholder="请输入资源名" class="form-control" />
</div>
<div class="panel-col" id="category-content">
</div>
<div class="panel-col" id="platform-content">
</div>
<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
<a id="filter-all" href="/resource/index/index1" class="btn btn-info">全部</a>
</div>
</div>
</div>
<div class="contentpanel">
<div class="panel panel-default" style="margin-bottom: 10px">
<input type="hidden" id="url" value="/runManage/subjectManage/subjectList"/>
<div id="content-list"></div>
</div>
</div>
<script type="text/template" id="search-category">
<select id="choose-category" title="" class="select2-offscreen brandBtn-group">
<option value="">选择分类</option>
[[each data as item index]]
<option value="[[item.sortId]]">[[item.sortName]]</option>
[[/each]]
</select>
</script>
<script type="text/template" id="search-platform">
<select id="choose-platform" title="" class="select2-offscreen brandBtn-group">
<option value="">选择平台</option>
[[each data as item index]]
<option value="[[item.platformId]]">[[item.platformName]]</option>
[[/each]]
</select>
</script>
<script type="text/template" id="edit-template">
<div class="modal-body" id="base-form">
<div class="form-group">
<label class="col-sm-2 control-label">名称</label>
<div class="col-sm-8">
<input type="text" id="name" name="name" value="[[name]]" class="form-control">
</div>
</div><!-- form-group -->
<div class="form-group">
<label class="col-sm-2 control-label">分类</label>
<div class="col-sm-8">
<select id="sortId" name="sortId">
<option value="0">请选择资源分类</option>
</select>
</div>
</div><!-- form-group -->
<div class="form-group">
<label class="col-sm-2 control-label">平台</label>
<div class="col-sm-8">
<select id="platformId" name="platformId">
<option value="0">请选择资源平台</option>
<option selected="" value="1">yohoApp</option>
<option value="5">web</option>
<option value="6">yohoipad</option>
<option value="9">wap</option>
</select>
</div>
</div><!-- form-group -->
<div class="form-group" hidden>
<label class="col-sm-2 control-label">位置码</label>
<div class="col-sm-8">
<input type="text" disabled="disabled" value="[[code]]" class="form-control">
</div>
</div><!-- form-group -->
<div class="form-group">
<label class="col-sm-2 control-label">匹配码</label>
<div class="col-sm-8">
<input type="text" id="matchCode" value="[[matchCode]]" class="form-control">
</div>
</div><!-- form-group -->
<input type="hidden" id="id" value="[[id]]">
</div>
</script>
\ No newline at end of file
... ...