#set(pageTitle="资讯管理") #@layout() #define main() <!-- END PAGE BAR --> <!-- BEGIN PAGE TITLE--> <h1 class="page-title"> 资讯管理 <small>资讯列表</small> </h1> <!-- END PAGE TITLE--> <!-- END PAGE HEADER--> <!-- BEGIN DASHBOARD STATS 1--> #define css() <style> .bootstrap-switch-label { height: 20px !important;vertical-align: bottom; }
#set(pageTitle="资讯管理") #@layout() #define main() <!-- END PAGE BAR --> <!-- BEGIN PAGE TITLE--> <h1 class="page-title"> 资讯管理 <small>新增</small> </h1> <!-- END PAGE TITLE--> <!-- END PAGE HEADER--> <!-- BEGIN DASHBOARD STATS 1--> #define css() <link rel="stylesheet" type="text/css" href="#(context)/assets/css/admin/user.css"> #end <div class="row"> <div class="col-md-12"> <div class="portlet light form-fit bordered"> <div class="portlet-body form"> <!-- BEGIN FORM--> <form id="informationForm2" method="post" action="#(context)/pc/admin/system/information/add" class="form-horizontal form-bordered"> <div class="form-body"> <div class="alert alert-danger display-hide"> <button class="close" data-close="alert"></button> 你有一些数据错误。请检查一下。 </div> <div class="alert alert-success display-hide"> <button class="close" data-close="alert"></button> 您的表单验证成功! </div> <div class="form-group"> <label class="control-label col-md-3">标题<span class="required" aria-required="true"> * </span></label> <div class="col-md-4"> <input type="text" maxlength="25" class="form-control input-medium" name="information.name" required /> </div> </div> <div class="form-group"> <label class="control-label col-md-3">栏目<span class="required" aria-required="true"> * </span></label> <div class="col-md-2"> <select class="form-control" id="types" name="information.columnId" onclick="column();" required> <option value="">请选择</option> #for(col : column) <option value="#(col.id)">#(col.name)</option> #end </select> </div> <div class="col-md-4" style="border: none;"> <label ><a href="#responsive" data-toggle="modal" onclick="columnq(1);"><i class="icon-layers"></i> 栏目管理</a> </label> </div> </div> <div class="form-group"> <label class="control-label col-md-3">图片<span class="required" aria-required="true"> * </span></label> <div class="col-md-4"> #@upload("image","information.image",1,360,null) <font style="text-align: center; color: #999;">尺寸要求:图片比例为2:1(284×142)</font> </div> </div> <div class="form-group"> <label class="control-label col-md-3">内容:</label> <div class="col-md-7"> <textarea id="content" rows="20" name="information.content"></textarea> </div> </div> <div class="form-group"> <label class="control-label col-md-3">摘要<span class="required" aria-required="true"> * </span></label> <div class="col-md-4"> <input type="text" class="form-control input-medium" placeholder="摘要" maxlength="124" name="information.abstract" required /> </div> </div> <div class="form-group"> <label class="control-label col-md-3">关键词(用于SEO):</label> <div class="col-md-3"> <input type="text" class="form-control input-medium" placeholder="关键词" maxlength="255" name="information.keyword" /> </div> <span style="position: relative; top: 20px; color: #999">多个词请用英文逗号隔开(如:关键词1,关键词2)</span> </div> <div class="form-group"> <label class="control-label col-md-3">状态</label> <div class="col-md-9"> <select class="form-control input-small" name="information.state"> #enumSelect("com.jiancai.system.model.key.AdEnum$AdStateEnum") </select> </div> </div> </div> <div class="form-actions"> <div class="row"> <div class="col-md-offset-3 col-md-9"> <button type="submit" class="btn blue"> <i class="fa fa-check"></i> 保存 </button> <button type="button" onClick="javascript:history.back(-1);" class="btn default">返回</button> </div> </div> </div> </form> <!-- END FORM--> </div> </div> </div> </div> <!-- 弹出框 begin --> <div class="modal fade draggable-modal" id="responsive" aria-hidden="true"> <form id="mainTableForm" method="post" action="" class="form-horizontal form-bordered"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" id="ons" class="close" data-dismiss="modal" aria-hidden="false"></button> <h3 class="modal-title" style="text-align: center;">编辑栏目页面</h3> </div> <div class="row"> <div class="modal-body"> <div class="col-md-12"> <div class="table-scrollable text-center"> <table class="table table-bordered" id="columns"> <thead> <tr> <th>栏目名称</th> <th>当前资讯数</th> <th>操作</th> </tr> </thead> <tbody id="attrList"> <script type="text/x-jquery-tmpl" id="chargeBillTemp"> {{each(i,item) list}} <tr> <td style="display:none;"><input type="hidden" name="id" class="form-control add-ids" value="{{= item.id}}" style="100%;" /></td> <td style=" 260px"> <input type="text" name="name" maxlength="8" class="form-control add-name" value="{{= item.name}}" style="100%;" /> </td> <td>{{= item.columnNumder}}</td> <td> {{if i!=0 && item.columnNumder == 0}} <a class="edit-single-price" onclick="deletePrice(this);"><i class="ace-icon fa fa-remove">删除</i></a> {{/if}} </td> </tr> {{/each}} </script> </tbody> </table> </div> </div> <div class="col-sm-9"> <button type="button" id="attrButton" class="add-row-trigger btn-link add-row-one"> <i class="fa fa-plus"></i> 新增栏目 </button> </div> </div> </div> <div class="modal-body"> <h5 class="modal-title" style="text-align: center; color: #999;">温馨提示 :最多只能新增6个栏目!</h5> </div> <div class="modal-footer"> <button type="button" class="btn dark btn-outline" data-dismiss="modal">关闭</button> <button type="button" class="btn green priceListSubmit">提交</button> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </form> </div> #end #define js() <script type="text/javascript" charset="utf-8" src="#(context)/assets/global/plugins/bootbox/bootbox.min.js"></script> <script type="text/javascript" charset="utf-8" src="#(context)/assets/admin/ueditor/ueditor.config.js"></script> <script type="text/javascript" charset="utf-8" src="#(context)/assets/admin/ueditor/ueditor.all.js"></script> <script type="text/javascript" charset="utf-8" src="#(context)/assets/admin/ueditor/lang/zh-cn/zh-cn.js"></script> <script> $(document).ready(function() { var ue = UE.getEditor('content', { initialFrameHeight : 500 }); var informationForm = $('#informationForm2'); var error1 = $('.alert-danger', informationForm); var success1 = $('.alert-success', informationForm); informationForm.validate({ debug : true, errorElement : 'span', errorClass : 'help-block help-block-error', rules : {}, invalidHandler : function(event, validator) { success1.hide(); error1.show(); App.scrollTo(error1, -200); }, errorPlacement : function(error, element) { var cont = $(element).closest('.form-group'); if (cont.length > 0) { error.appendTo(cont); } else { element.after(error); } }, highlight : function(element) { $(element).closest('.form-group').addClass('has-error'); }, unhighlight : function(element) { $(element).closest('.form-group').removeClass('has-error'); }, success : function(label) { label.closest('.form-group').removeClass('has-error'); }, submitHandler : function(form) { error1.hide(); common.postForm($(form)); } }); }); //查看所有栏目 function columnq(id) { //debugger; var url = '#(context)/pc/admin/system/information/column'; $.ajax({ url:url, async:true, success : function(data) { console.log(data); qcUtil.template('chargeBillTemp', { "list" : data.column }, $("#columns tbody"), false); var columns = $('#columns').find("tr").length; if(7==columns){ $("#attrButton").closest("button").css("display","none"); } } }); } //删除栏目 window.deletePrice = function(_this) { $(_this).closest("tr").remove(); var columns = $('#columns').find("tr").length; if(columns<7){ $("#attrButton").closest("button").css("display","block"); } } /** * 持久化新增栏目列表 */ $(".priceListSubmit").click(function() { var ids = new Array(); var names = new Array(); $(".add-ids").each(function(){ ids.push($(this).val()); }); $(".add-name").each(function(){ names.push($(this).val()); }); var s = ","+names.join(",")+","; for(var i=0;i<names.length;i++) { if(s.replace(names[i]+",","").indexOf(","+names[i]+",")>-1) { bootbox.alert({ message:"数组中有空元素/重复元素:" + names[i], buttons: { ok: { label: '确定', className: 'btn-success' } } }); return; } } $.ajax({ url : "#(context)/pc/admin/system/information/addColumn", type : 'POST', data : { "name" : JSON.stringify(names), "id" : JSON.stringify(ids) }, success : function(data) { $("#ons").click(); var url = "#(context)/pc/admin/system/information/toColumn"; $.ajax({ type: "post", url: url, success: function(data) { $("#types option").remove(), $("#types").append("<option value=''>请选择</option>") $.each(data, function(i, obj){ $("#types").append("<option value='"+ obj.id+"'>"+ obj.name +"</option>") }); } }); } }); /* common.commonAjax(url, { "name" : JSON.stringify(names), "id" : JSON.stringify(ids) }, function(data) { $("#ons").click(); window.location.reload(); }); */ }); $("#attrButton") .on( "click", function() { var attrList = $("#attrList"); $("#attrList").append( '<tr class="template kv-table-row"> ' + '<td style="display:none;"></td>' + '<td style="height:30px;text-align:center;"><input type="text" maxlength="8" name="name" class="form-control add-name" value="" style="100%;" required /></td>' + '<td></td>' + '<td class="del-column"> <a class="edit-single-price" onclick="deletePrice(this);"><i class="ace-icon fa fa-remove">删除</i></a></td> ' + '</tr>'); delProduct(); var columns = $('#columns').find("tr").length; if(columns>=7){ $("#attrButton").closest("button").css("display","none"); } }); // function delProduct() { $(".del-row-trigger").on("click", function() { $(this).parents("tr").remove(); }); } </script> #end
#set(pageTitle="资讯管理") #@layout() #define main() <!-- END PAGE BAR --> <!-- BEGIN PAGE TITLE--> <h1 class="page-title"> 资讯管理 <small>新增</small> </h1> <!-- END PAGE TITLE--> <!-- END PAGE HEADER--> <!-- BEGIN DASHBOARD STATS 1--> #define css() <link rel="stylesheet" type="text/css" href="#(context)/assets/css/admin/user.css"> #end <div class="row"> <div class="col-md-12"> <div class="portlet light form-fit bordered"> <div class="portlet-body form"> <!-- BEGIN FORM--> <form id="informationForm2" method="post" action="#(context)/pc/admin/system/information/edit" class="form-horizontal form-bordered"> <input type="hidden" name="information.id" value="#(information.id)"/> <div class="form-body"> <div class="alert alert-danger display-hide"> <button class="close" data-close="alert"></button> 你有一些数据错误。请检查一下。 </div> <div class="alert alert-success display-hide"> <button class="close" data-close="alert"></button> 您的表单验证成功! </div> <div class="form-group"> <label class="control-label col-md-3">标题<span class="required" aria-required="true"> * </span></label> <div class="col-md-4"> <input type="text" maxlength="25" name="information.name"class="form-control" value="#(information.name)" required/> </div> </div> <div class="form-group"> <label class="control-label col-md-3">栏目<span class="required" aria-required="true"> * </span></label> <div class="col-md-2"> <select class="form-control" id="types" name="information.columnId"> <option value="">请选择</option> #for(col : column) <option value="#(col.id)" #(information.columnId==col.id ? 'selected="selected"':'')>#(col.name)</option> #end </select> </div> <div class="col-md-4" style="border: none;"> <label ><a href="#responsive" data-toggle="modal" onclick="columnq(1);"><i class="icon-layers"></i> 栏目管理</a> </label> </div> </div> <div class="form-group"> <label class="control-label col-md-3">图片<span class="required" aria-required="true"> * </span></label> <div class="col-md-4"> #@upload("image","information.image",1,200,information.image) <font style="text-align: center; color: #999;">尺寸要求:图片比例为2:1(284×142)</font> </div> </div> <div class="form-group"> <label class="control-label col-md-3">内容:</label> <div class="col-md-7"> <textarea id="content" rows="20" name="information.content">#(information.content??)</textarea> </div> </div> <div class="form-group"> <label class="control-label col-md-3">摘要<span class="required" aria-required="true"> * </span></label> <div class="col-md-4"> <input type="text" class="form-control input-medium" placeholder="摘要" value="#(information.abstract)" maxlength="124" name="information.abstract" required /> </div> </div> <div class="form-group"> <label class="control-label col-md-3">关键词(用于SEO):</label> <div class="col-md-3"> <input type="text" class="form-control input-medium" placeholder="关键词" maxlength="255" value="#(information.keyword)" name="information.keyword" /> </div> <span style="position: relative; top: 20px; color: #999">多个词请用英文逗号隔开(如:关键词1,关键词2)</span> </div> <div class="form-group"> <label class="control-label col-md-3">状态</label> <div class="col-md-9"> <select class="form-control input-small" name="information.state"> #enumSelect("com.jiancai.system.model.key.AdEnum$AdStateEnum", information.state) </select> </div> </div> </div> <div class="form-actions"> <div class="row"> <div class="col-md-offset-3 col-md-9"> <button type="submit" class="btn blue"> <i class="fa fa-check"></i> 保存 </button> <button type="button" onClick="javascript:history.back(-1);" class="btn default">返回</button> </div> </div> </div> </form> <!-- END FORM--> </div> </div> </div> </div> <!-- 弹出框 begin --> <div class="modal fade draggable-modal" id="responsive" aria-hidden="true"> <form id="mainTableForm" method="post" action="" class="form-horizontal form-bordered"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" id="ons" class="close" data-dismiss="modal" aria-hidden="false"></button> <h3 class="modal-title" style="text-align: center;">编辑栏目页面</h3> </div> <div class="row"> <div class="modal-body"> <div class="col-md-12"> <div class="table-scrollable text-center"> <table class="table table-bordered" id="columns"> <thead> <tr> <th>栏目名称</th> <th>当前资讯数</th> <th>操作</th> </tr> </thead> <tbody id="attrList"> <script type="text/x-jquery-tmpl" id="chargeBillTemp"> {{each(i,item) list}} <tr> <td style="display:none;"><input type="hidden" name="id" class="form-control add-ids" value="{{= item.id}}" style="100%;" /></td> <td style=" 260px"> <input type="text" name="name" maxlength="8" class="form-control add-name" value="{{= item.name}}" style="100%;" /> </td> <td>{{= item.columnNumder}}</td> <td> {{if i!=0 && item.columnNumder == 0}} <a class="edit-single-price" onclick="deletePrice(this);"><i class="ace-icon fa fa-remove">删除</i></a> {{/if}} </td> </tr> {{/each}} </script> </tbody> </table> </div> </div> <div class="col-sm-9"> <button type="button" id="attrButton" class="add-row-trigger btn-link add-row-one"> <i class="fa fa-plus"></i> 新增栏目 </button> </div> </div> </div> <div class="modal-body"> <h5 class="modal-title" style="text-align: center; color: #999;">温馨提示 :最多只能新增6个栏目!</h5> </div> <div class="modal-footer"> <button type="button" class="btn dark btn-outline" data-dismiss="modal">关闭</button> <button type="button" class="btn green priceListSubmit">提交</button> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal-dialog --> </form> </div> #end #define js() <script type="text/javascript" charset="utf-8" src="#(context)/assets/global/plugins/bootbox/bootbox.min.js"></script> <script type="text/javascript" charset="utf-8" src="#(context)/assets/admin/ueditor/ueditor.config.js"></script> <script type="text/javascript" charset="utf-8" src="#(context)/assets/admin/ueditor/ueditor.all.js"> </script> <script type="text/javascript" charset="utf-8" src="#(context)/assets/admin/ueditor/lang/zh-cn/zh-cn.js"></script> <script> $(document).ready(function() { var ue = UE.getEditor('content', { initialFrameHeight : 500 }); var informationForm = $('#informationForm2'); var error1 = $('.alert-danger', informationForm); var success1 = $('.alert-success', informationForm); informationForm.validate({ debug : true, errorElement : 'span', errorClass : 'help-block help-block-error', rules : {}, invalidHandler : function(event, validator) { success1.hide(); error1.show(); App.scrollTo(error1, -200); }, errorPlacement : function(error, element) { var cont = $(element).closest('.form-group'); if (cont.length > 0) { error.appendTo(cont); } else { element.after(error); } }, highlight : function(element) { $(element).closest('.form-group').addClass('has-error'); }, unhighlight : function(element) { $(element).closest('.form-group').removeClass('has-error'); }, success : function(label) { label.closest('.form-group').removeClass('has-error'); }, submitHandler : function(form) { error1.hide(); common.postForm($(form)); } }); }); //查看所有栏目 function columnq(id) { //debugger; var url = '#(context)/pc/admin/system/information/column'; $.ajax({ url:url, async:true, success : function(data) { console.log(data); qcUtil.template('chargeBillTemp', { "list" : data.column }, $("#columns tbody"), false); var columns = $('#columns').find("tr").length; if(7==columns){ $("#attrButton").closest("button").css("display","none"); } } }); } //删除栏目 window.deletePrice = function(_this) { $(_this).closest("tr").remove(); var columns = $('#columns').find("tr").length; if(columns<7){ $("#attrButton").closest("button").css("display","block"); } } /** * 持久化新增栏目列表 */ $(".priceListSubmit").click(function() { var ids = new Array(); var names = new Array(); $(".add-ids").each(function(){ ids.push($(this).val()); }); $(".add-name").each(function(){ names.push($(this).val()); }); var s = ","+names.join(",")+","; for(var i=0;i<names.length;i++) { if(s.replace(names[i]+",","").indexOf(","+names[i]+",")>-1) { bootbox.alert({ message:"数组中有空元素/重复元素:" + names[i], buttons: { ok: { label: '确定', className: 'btn-success' } } }); return; } } $.ajax({ url : "#(context)/pc/admin/system/information/addColumn", type : 'POST', data : { "name" : JSON.stringify(names), "id" : JSON.stringify(ids) }, success : function(data) { $("#ons").click(); var url = "#(context)/pc/admin/system/information/toColumn"; $.ajax({ type: "post", url: url, success: function(data) { $("#types option").remove(), $("#types").append("<option value=''>请选择</option>") $.each(data, function(i, obj){ $("#types").append("<option value='"+ obj.id+"'>"+ obj.name +"</option>") }); } }); } }); /* common.commonAjax(url, { "name" : JSON.stringify(names), "id" : JSON.stringify(ids) }, function(data) { $("#ons").click(); window.location.reload(); }); */ }); $("#attrButton") .on( "click", function() { var attrList = $("#attrList"); $("#attrList").append( '<tr class="template kv-table-row"> ' + '<td style="display:none;"></td>' + '<td style="height:30px;text-align:center;"><input type="text" maxlength="8" name="name" class="form-control add-name" value="" style="100%;" required /></td>' + '<td></td>' + '<td class="del-column"> <a class="edit-single-price" onclick="deletePrice(this);"><i class="ace-icon fa fa-remove">删除</i></a></td> ' + '</tr>'); delProduct(); var columns = $('#columns').find("tr").length; if(columns>=7){ $("#attrButton").closest("button").css("display","none"); } }); // function delProduct() { $(".del-row-trigger").on("click", function() { $(this).parents("tr").remove(); }); } </script> #end
</style> #end <div class="row"> <div class="col-md-12"> <!-- BEGIN SAMPLE TABLE PORTLET--> <div class="portlet light portlet-fit bordered"> <div class="portlet-body" style="display: block;"> <div class="table-toolbar"> <div class="row"> <div class="col-md-6"> <a class="btn sbold green" href="#(context)/pc/admin/system/information/toAdd"> 新 增 <i class="fa fa-plus"></i> </a> </div> <div class="col-md-6"> <div class="pull-right"> <form class="form-inline" action="#(context)/pc/admin/system/information/list"> <div class="form-group"> <select class="form-control input-small" id="types" name="query.columnId"> <option value="">全部栏目</option> #for(col : column) <option value="#(col.id)">#(col.name)</option> #end </select> </div> <div class="form-group"> <input type="search" class="form-control" placeholder="标题" name="query.keyword" value="#(query.keyword??)" title="标题"> </div> <div class="form-group"> <button type="submit" class="btn btn-info">查询</button> </div> </form> </div> </div> <div class="clearfix"></div> </div> </div> <div class="table-scrollable"> <table class="table table-bordered table-hover"> <thead> <tr> <th>序号</th> <th>标题</th> <th>图片</th> <th>所属栏目</th> <th>发布时间</th> <th>最新操作人</th> <th>是否发布</th> <th>操作</th> </tr> </thead> <tbody> #for(item:page.list) <tr> <td>#(item.id??)</td> <td>#(item.name??)</td> <td>#img(item.image,40)</td> <td>#(item.columnName??)</td> <td>#date(item.time??, "yyyy-MM-dd HH:mm:ss")</td> <td>#(item.userName??)</td> <td>#if(item.top == 1)<input type="checkbox" id="ons" class="make-switch" data-size="mini" name="state" tid="#(item.id)" #(item.state==1? "checked='true' ":"") value="#(item.state)" data-on-text="启用" data-off-text="禁止" readonly="readonly"/>#end #if(item.top == 0)<input type="checkbox" id="ons" class="make-switch" data-size="mini" name="state" tid="#(item.id)" #(item.state==1? "checked='true' ":"") value="#(item.state)" data-on-text="启用" data-off-text="禁止" />#end </td> <td>#authorized(system_information_edit) <a href="#(context)/pc/admin/system/information/toEdit/#(item.id)?queryStr=#(queryStr)"> <i class="ace-icon fa fa-pencil">修改</i> </a> #end #authorized(system_information_delete) #if(item.top == 1) <a href="javascript:;" class="block" api-path="#(context)/pc/admin/system/information/top/#(item.id)?top=0&queryStr=#(queryStr)"> <i class="ace-icon fa fa-pencil"><span>取消置顶</span></i> </a> #end #if(item.top == 0 && item.state == 1) <a href="javascript:;" class="block" api-path="#(context)/pc/admin/system/information/top/#(item.id)?top=1&queryStr=#(queryStr)"> <i class="ace-icon fa fa-pencil"><span>置顶</span></i> </a> #end #end #authorized(system_information_delete) #if(item.state == 0 ) <a href="javascript:;" class="red delete" api-path="#(context)/pc/admin/system/information/delete/#(item.id)?queryStr=#(queryStr)"> <i class="ace-icon fa fa-remove"><span>删除</span></i> </a> #end#end </td> </tr> #end </tbody> </table> </div> #@paginate(page) </div> </div> <!-- END SAMPLE TABLE PORTLET--> </div> </div> <!-- END DASHBOARD STATS 1--> #end #define js() <script> $(document).ready(function() { $(".block").each( function() { $(this).click( function() { var delUrl = $(this).attr('api-path'); bootbox.confirm({ message : "确定执行该操作?", buttons : { confirm : { label : '确定', className : 'btn-success' }, cancel : { label : '取消', className : 'btn-danger' } }, callback : function(result) { if (result) { $.post(delUrl,{},function(data) { if (parseInt(data["status"]) === 200) { $.bootstrapGrowl("操作成功", {type : 'success', align : 'center', width : 'auto', allow_dismiss : false, offset : { from : 'top', amount : 80 }, stackup_spacing : 30, delay : 500 }); setTimeout( function() { location.reload(true); },500); } else { $.bootstrapGrowl("操作失败,"+ data["message"], { type : 'danger', align : 'center', width : 'auto', allow_dismiss : false, offset : { from : 'top', amount : 80 }, stackup_spacing : 30, delay : 1500 }); } }); } } }); }); }); //是否发布控制按钮 $(".make-switch").on('switchChange.bootstrapSwitch', function(e, state) { var url = "#(context)/pc/admin/system/information/onOff"; var data = { "tid" : $(this).attr("tid"), "state" : $(this).attr("value") }; common.commonAjax(url, data); window.location.reload(); }); }); </script> #end