EDZ 4 роки тому
батько
коміт
ef552caa62

+ 58 - 3
code/auto/app/src/main/java/com/jzdsh/auto/app/controller/admin/AdminActivityNewsController.java

@@ -2,25 +2,80 @@ package com.jzdsh.auto.app.controller.admin;
 
 import com.jfinal.aop.Inject;
 import com.jfinal.core.Controller;
+import com.jfinal.kit.Ret;
 import com.jfinal.plugin.activerecord.Page;
 import com.jzdsh.auto.biz.ActivityServce;
+import com.jzdsh.auto.biz.BsTypeService;
 import com.jzdsh.auto.model.Activity;
+import com.jzdsh.auto.model.BsType;
+
+import java.util.List;
 
 public class AdminActivityNewsController extends Controller {
 
     @Inject
     ActivityServce activityServce;
 
-    public void index(){
+    @Inject
+    BsTypeService bsTypeService;
 
-        Page<Activity> activityPage = activityServce.activityPaginate(getParaToInt("pageNum",1), 1);
+    public void index(){
+        //查询所有活动资讯并分页
+        Page<Activity> activityPage = activityServce.activityPaginate(getParaToInt("pageNum",1), 2);
         setAttr("activityPage",activityPage);
         render("index.html");
     }
 
 
-
+    /**
+     * 添加 跳转
+     */
     public void toAdd(){
+        //查询活动资讯所有类型
+        List<BsType> allType = bsTypeService.findAllType();
+        setAttr("allType",allType);
+        //查询活动资讯所有标签
+        List<BsType> allTag = bsTypeService.findAllTag();
+        setAttr("allTag",allTag);
+
+        Activity activity = new Activity();
+        activity.setTypeId(0);
+        activity.setTagId(0);
+
+        setAttr("activityNews",activity);
         render("add.html");
     }
+
+    /**
+     * 添加  实现
+     */
+    public void doAdd(){
+        Activity bean = getBean(Activity.class,"activityNews");
+        bean.save();
+        redirect("/admin/activityNews");
+    }
+
+    /**
+     * 修改  跳转
+     */
+    public void toUpdate(){
+        Activity activity = activityServce.findById(getParaToInt(0));
+        setAttr("activityNews",activity);
+        //查询活动资讯所有类型
+        List<BsType> allType = bsTypeService.findAllType();
+        setAttr("allType",allType);
+        //查询活动资讯所有标签
+        List<BsType> allTag = bsTypeService.findAllTag();
+        setAttr("allTag",allTag);
+        setAttr("pageNum",getParaToInt(1));
+        render("edit.html");
+    }
+
+    /**
+     * 删除
+     */
+    public void delete(){
+        Ret ret = activityServce.delete(getParaToInt(0));
+        renderJson(ret);
+    }
 }

+ 20 - 9
code/auto/app/src/main/webapp/_view/_admin/activityNews/activityNews_form.html

@@ -4,16 +4,26 @@
         <label>类型</label>
         <select name="activityNews.typeId" id = "lx"  class="form-control">
             <option value="">请选择</option>
-            <option value="">请选择</option>
-            <option value="">请选择</option>
+            #for(type : allType)
+            #if(activityNews.typeId == type.id)
+            <option value="#(type.id??)" selected>#(type.title)</option>
+            #else
+            <option value="#(type.id??)">#(type.title)</option>
+            #end
+           #end
         </select>
 </div>
 <div class="form-group margin-bottom-20">
     <label>标签</label>
     <select name="activityNews.tagId" id = "bq"  class="form-control">
         <option value="">请选择</option>
-        <option value="">请选择</option>
-        <option value="">请选择</option>
+        #for(tag : allTag)
+        #if(activityNews.tagId == tag.id)
+        <option value="#(tag.id)" selected>#(tag.title)</option>
+        #else
+        <option value="#(tag.id)">#(tag.title)</option>
+        #end
+       #end
     </select>
 </div>
 <div class="form-group margin-bottom-20">
@@ -21,7 +31,7 @@
     <input type="text"  class="form-control" name="activityNews.title" value="#(activityNews.title??)" placeholder="" />
 </div>
 
-<div class="form-group margin-bottom-20">
+#--<div class="form-group margin-bottom-20">
     <label>广告图<span style="color: red">(不超过三张)</span></label>
         <div style="width:100%;height:auto;border:1px solid #DDDDDD;padding:8px 5px 0 0;" class="selfprozslidim">
             <dl>
@@ -29,11 +39,12 @@
                 <dd id="albummore"><a onclick="$('#fileToUpload').click();"><img src="/nvrnetwork/assets/img/addmore.jpg" alt="" id="img"></a></dd>
             </dl>
         </div>
-</div>
+</div>--#
 
 <div class="form-group margin-bottom-20">
     <label>是否置顶</label>
     <select name="activityNews.isTop" id = "zd"  class="form-control">
+
         <option value="0">否</option>
         <option value="1">是</option>
     </select>
@@ -48,18 +59,18 @@
 
 <div class="form-group margin-bottom-20" id="upLineTime">
     <label>上线时间</label>
-        <input type="text"  name="upLine" value="${banner.formatOnlineTime}"  onfocus="WdatePicker({ Date:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })"  class="input-text Wdate" style="width:400px;">
+        <input type="text"  name="activityNews.onlineTime" value=""  onfocus="WdatePicker({ Date:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })"  class="input-text Wdate" style="width:400px;">
         <input type="text" hidden onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })"  class="input-text Wdate" style="width:120px;">
 </div>
 <div class="form-group margin-bottom-20" id="downLineTime">
     <label>下线时间</label>
-        <input type="text"  name="downLine" value="${banner.formatOnlineTime}"  onfocus="WdatePicker({ Date:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })"  class="input-text Wdate" style="width:400px;">
+        <input type="text"  name="activityNews.downlineTime" value=""  onfocus="WdatePicker({ Date:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })"  class="input-text Wdate" style="width:400px;">
         <input type="text" hidden onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" class="input-text Wdate" style="width:120px;">
 </div>
 
 <div class="form-group margin-bottom-20" id="adRankNumber">
     <label>广告排名</label>
-        <input type="text" class="form-control" name="adRank">
+        <input type="text" class="form-control" name="activityNews.adRank">
         <label style="color: red">排名越大广告展示越靠前</label>
 </div>
 

+ 142 - 0
code/auto/app/src/main/webapp/_view/_admin/activityNews/edit.html

@@ -0,0 +1,142 @@
+#@adminLayout()
+
+#define main()
+
+<div class="jfa-header-box" id="jfa-header-box">
+    <div class="jfa-search-box"></div>
+    #include("/_view/_admin/common/_header_right.html")
+</div>
+
+
+<div class="jfa-content-box" id="jfa-content-box">
+    <div class="jfa-content" id="jfa-content">
+        <form class="clearfix margin-top-25"  action="/nvrnetwork/admin/activityNews/doUpdate/#(pageNum)" method="post">
+            #include("activityNews_form.html")
+        </form>
+    </div>
+</div>
+<script type="text/javascript">
+
+
+  ### 百度文本编辑器
+    $(function () {
+        var ue = UE.getEditor('introduction', {
+            //关闭字数统计
+            wordCount: false,
+            toolbars: [['fullscreen', 'source', '|', 'undo', 'redo', '|',
+                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
+                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
+                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
+                'directionalityltr', 'directionalityrtl', 'indent', '|',
+                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
+                'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
+                'insertimage', 'emotion', 'insertvideo', 'attachment', 'map', 'template', 'background', '|',
+                'horizontal', 'date', 'time', 'spechars', 'wordimage', '|',
+                'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
+                'print', 'preview', 'searchreplace', 'help'
+            ]],
+            //关闭elementPath
+            elementPathEnabled: false,
+        });
+    });
+
+
+    var currentBrowserId;
+
+    function browserImage(targetId) {
+        currentBrowserId = targetId;
+        var weboxTemp = $.webox({
+            height: 600,
+            width: 1024,
+            bgvisibel: true,
+            title: '图片管理',
+            iframe: '<%=base%>/admin/image/imgbox.html?' + Math.random()
+        });
+    }
+
+    function setImagepath(imgPath) {
+        $('#' + currentBrowserId).val(imgPath);
+    }
+
+    function closeFrame() {
+        $('#locked .span').click();
+    }
+</script>
+
+### 多图上传
+<script type="text/javascript">
+
+    var isAd = $("#isAd").val();
+    if (isAd.trim() == 1 ){
+        $("#upLineTime").show();
+        $("#downLineTime").show();
+        $("#adRankNumber").show();
+    }else {
+        $("#upLineTime").hide();
+        $("#downLineTime").hide();
+        $("#adRankNumber").hide();
+    }
+
+    function  isAdChange(isAdValue){
+        if (isAdValue.trim() == 1){
+            $("#upLineTime").show();
+            $("#downLineTime").show();
+            $("#adRankNumber").show();
+        } else {
+            $("#upLineTime").hide();
+            $("#downLineTime").hide();
+            $("#adRankNumber").hide();
+        }
+    }
+
+
+
+    $(function(){
+        $("#fileToUpload").change(function(){
+            var f = document.getElementById('fileToUpload').files[0];
+            $.ajaxFileUpload({
+                fileElementId : 'fileToUpload',
+                url : '/nvrnetwork/common/imageUpload',
+                dataType : 'text',
+                data : {},
+                async : true,
+                error : function(data) {
+                    alert("网络异常,请重试");
+                },
+                success : function(message) {
+                    $("#albummore").before('<dd class="del"><img src="'+message+'" width="68" height="68" /><input type="hidden" name="activityimage" value="'+message+'"/><div class="delwarp"><a class="delete" onclick="delalbum(this)">删除</a></div></dd>');
+                    chens();
+
+                }
+            });
+        });
+    });
+    function chens(){
+        $("#fileToUpload").change(function(){
+            var f = document.getElementById('fileToUpload').files[0];
+            $.ajaxFileUpload({
+                fileElementId : 'fileToUpload',
+                url : 'uploadImages.html',
+                dataType : 'text',
+                data : {},
+                async : true,
+                error : function(data) {
+                    alert("网络异常,请重试");
+                },
+                success : function(message) {
+                    $("#albummore").before('<dd class="del"><img src="'+message+'" width="68" height="68" /><input type="hidden" name="activityimage" value="'+message+'"/><div class="delwarp"><a class="delete" onclick="delalbum(this)">删除</a></div></dd>');
+                    chens();
+                }
+            });
+        });
+    }
+
+    function delalbum(obj){
+        $(obj).parents(".del").remove();
+    }
+
+</script>
+
+
+
+#end

+ 2 - 2
code/auto/app/src/main/webapp/_view/_admin/activityNews/index.html

@@ -70,13 +70,13 @@
 
 					<td class="jfa-operation-button">
 
-						<a href="/admin/project/edit?id=#(x.id)&pageNum=#(activityPage.pageNumber)">
+						<a href="/nvrnetwork/admin/activityNews/toUpdate/#(x.id)-#(activityPage.pageNumber)">
 							<i class="fa fa-pencil" title="修改"></i>
 						</a>
 
 						<a data-delete
 						   data-title="#escape(x.title)"
-						   data-action="/admin/project/delete?id=#(x.id)">
+						   data-action="/nvrnetwork/admin/activityNews/delete/#(x.id)">
 							<i class="fa fa-trash" title="删除"></i>
 						</a>
 					</td>