Authored by ZhongW

unionType添加

module.exports = function (app){
app.get("/unionType/index", "unionType.index", function (req,res){
this.$extend={
moduleName:"联盟类型管理",
pageName:"联盟类型管理"
}
});
//列表
app.post("/unionType/getUnionTypeList","unionType_getUnionTypeList");
//获取单个
app.post("/unionType/getUnionType","unionType_getUnionType");
//添加
app.post("/unionType/addUnionType","unionType_addUnionType");
//修改
app.post("/unionType/updateUnionType","unionType_updateUnionType");
//列表
app.post("/unionType/getUnionTypeUrls","unionType_getUnionTypeUrls");
}
\ No newline at end of file
... ...
module.exports={
namespace:"unionType",
apis:{
getUnionTypeList:{
title:"联盟列表",
url:"/unionType/getUnionTypeList",
params:[
{name: 'name', type: 'String'},
{name: 'unionType', type: 'Number'},
{name: 'page', type: 'Number'},
{name: 'size', type: 'Number'}
]
},
getUnionType:{
title:"查询联盟",
url:"/unionType/getUnionType",
params:[
{name: 'id', type: 'Number'}
]
},
addUnionType:{
title:"添加联盟",
url:"/unionType/addUnionType",
params:[
{name: 'name', type: 'String'}
]
},
updateUnionType:{
title:"修改联盟",
url:"/unionType/updateUnionType",
params:[
{name: 'id', type: 'Number'},
{name: 'name', type: 'String'}
]
},
getUnionTypeUrls:{
title:"获取链接",
url:"/unionType/getUnionTypeUrls",
params:[
{name: 'id', type: 'Number'}
]
},
}
}
\ No newline at end of file
... ...
<%include '../../common/views/__ui/header'%>
<%include '../../common/views/__partail/ListHeader'%>
<div class="contentpanel">
<div class="panel panel-default" style="margin-bottom:10px;" id="content-head">
<div class="panel-body" style="padding-bottom: 0">
<a id="add-btn" href="javascript:;" class="btn btn-success"><i class="fa fa-plus"></i> 添加联盟</a>
</div>
<div class="panel-body">
<div class="row">
<div class="panel-col">
<input type="text" id="unionTypeName" class="form-control" placeholder="输入联盟名称" />
</div>
<div class="panel-col">
<input type="text" id="unionTypeID" class="form-control" placeholder="输入UNION ID" />
</div>
<div class="panel-col">
<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
<!-- <a id="all-btn" href="" class="btn btn-info">全部</a> -->
</div>
</div>
</div>
</div>
<div class="panel panel-primary-head" id="content-body">
<div id="basicTable_wrapper" class="dataTables_wrapper no-footer">
<div class="dataTables_length" id="basicTable">
</div>
<nav>
<ul id="pagination" class="pagination pagination-lg"></ul>
</nav>
</div>
</div>
<div class="panel panel-primary-head" id="url-detail" style="display:none">
<div style="padding-bottom: 10px">
<a id="return-btn" href="javascript:;" class="btn btn-success"><i class="fa fa-mail-reply"></i> 返回</a>
</div>
<div id="basicTable_wrapper" class="dataTables_wrapper no-footer">
<div class="dataTables_length" id="basicTableForUrl">
</div>
</div>
</div>
</div>
<script type="text/template" id="template">
<div class="form-horizontal unionTypeInfo">
<input type="hidden" value="[[id]]" id="id" class="form-control">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">联盟名称:</label>
<div class="col-sm-offset-1 col-sm-5">
<input type="text" value="[[name]]" id="name" placeholder="联盟名称" required="required" class="form-control">
</div>
<div class="col-sm-2"><label style="color: #ff0000; line-height: 40px"> * 必填</label></div>
</div>
</div>
</script>
... ...
/**
* Created by wangqianjun on 16/3/22.
*/
var $ = require('jquery');
common = require('../../common/common');
var ENUM = {
HotEnum: {
'1': '是',
'0': '否'
},
StatusEnum: {
1: '<b style="color:#5cb85c">开启</b>',
0: '<b style="color:#ff0000">关闭</b>'
}
}
var g = new common.grid({
el: '#basicTable',
size: 10,
parms: function () {
return {
name: common.util.__input('unionTypeName'),
unionType: common.util.__input('unionTypeID')
};
},
columns: [
{display: 'ID', name: "id",
render: function (items) {
return '<a target="_blank" href="JavaScript:;" data-index="'+items.__index+'" class="btn btn-danger btn-xs url-detail">' + items.id + '</a>';
}},
{display: '名称', name: "name"},
{display: '创建人', name: "createId"},
{display: '创建时间', name: "createTimeStr"},
{display: '类型ID', name: "unionType"},
{display: '操作', name: "status", render: function (items) {
var HtmArr = [];
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs info-modify">编辑</a>');
return HtmArr.join('');
}}
]
});
g.init('/unionType/getUnionTypeList');
//==================== 按钮点击事件 =====================//
$("#filter-btn").click(function() {
g.reload(1);
});
//添加
$(document).on('click', '#add-btn', function() {
editUnionType("新增", '/unionType/addUnionType', {});
});
//编辑
$(document).on('click', '.info-modify', function() {
var item = g.rows[$(this).data("index")];
editUnionType("修改", '/unionType/updateUnionType', item);
});
$(document).on('click', '.url-detail', function() {
var item = g.rows[$(this).data("index")];
var gUrl = new common.grid({
el: '#basicTableForUrl',
size: 10,
parms: function () {
return {
id: item.id
};
},
columns: [
{display: '对外提供的链接', name: "url"},
{display: '适配应用市场推广', name: "applicationExtend"},
{display: '适配微信推广', name: "wechatExtend"},
{display: '适配网页推广', name: "webExtend"},
{display: '适配ios推广', name: "iosExtend"},
{display: '适配android推广', name: "androidExtend"},
{display: '优点', name: "pros"},
{display: '缺点', name: "cons"},
{display: '备注', name: "commont"}
]
});
gUrl.init('/unionType/getUnionTypeUrls');
$("#content-body").hide();
$("#content-head").hide();
$("#url-detail").show();
});
//返回
$(document).on('click', '#return-btn', function() {
$("#content-body").show();
$("#content-head").show();
$("#url-detail").hide();
});
function editUnionType(prefix, url, item) {
var a = new common.edit(".unionTypeInfo", {bucket:"articleTags"});
common.dialog.confirm(prefix + '标签', common.util.__template2($("#template").html(), item), function () {
return a.submit(url,function(option){
option.success = function(res){
if(res.code=="200"){
a.$tip("提交成功", function() {
g.reload();
}, 'growl-success');
}else{
a.$tip(res.message);
}
return false;
},
option.error = function(res){
a.$tip(res.message);
}
});
});
a.init();
}
\ No newline at end of file
... ...