From 34656e756c7e70c37d4dbf62e13ba911b3fff843 Mon Sep 17 00:00:00 2001 From: keyuan <912114781@qq.com> Date: Fri, 16 Apr 2021 12:01:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=82=B9=E5=87=BB=E9=97=AE=E5=8D=B7=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E8=8F=9C=E5=8D=95=E5=90=8E=E5=85=B6=E5=AE=83=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E9=A1=B9=E6=98=BE=E7=A4=BA=EF=BC=8C=E6=9B=B4=E6=8D=A2?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=97=B6=E9=97=B4=E6=8E=A7=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/web/JsonDateValueProcessor.java | 40 +++++++++++++ .../action/survey/MySurveyAction.java | 21 ++++--- .../action/survey/MySurveyStyleAction.java | 9 +-- .../webapp/WEB-INF/page/layouts/default.jsp | 13 +++-- src/main/webapp/js/dw/collect.js | 57 ++++++++++--------- src/main/webapp/js/dw/html/collectset.html | 6 +- src/main/webapp/js/dw/responsive-width.js | 22 ++++--- 7 files changed, 111 insertions(+), 57 deletions(-) create mode 100644 src/main/java/com/key/common/utils/web/JsonDateValueProcessor.java diff --git a/src/main/java/com/key/common/utils/web/JsonDateValueProcessor.java b/src/main/java/com/key/common/utils/web/JsonDateValueProcessor.java new file mode 100644 index 0000000..c026a72 --- /dev/null +++ b/src/main/java/com/key/common/utils/web/JsonDateValueProcessor.java @@ -0,0 +1,40 @@ +package com.key.common.utils.web; + +import net.sf.json.JsonConfig; +import net.sf.json.processors.JsonValueProcessor; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +public class JsonDateValueProcessor implements JsonValueProcessor { + + private String format = "yyyy-MM-dd HH:mm:ss"; + + public JsonDateValueProcessor() { + super(); + } + + public JsonDateValueProcessor(String format) { // 自己需要的格式 + super(); + this.format = format; + } + + @Override + public Object processArrayValue(Object value, JsonConfig paramJsonConfig) { + return process(value); + } + + @Override + public Object processObjectValue(String key, Object value, JsonConfig paramJsonConfig) { + return process(value); + } + + private Object process(Object value) { + if (value instanceof Date) { + SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA); + return sdf.format(value); + } + return value == null ? "" : value.toString(); + } +} diff --git a/src/main/java/com/key/dwsurvey/action/survey/MySurveyAction.java b/src/main/java/com/key/dwsurvey/action/survey/MySurveyAction.java index 3d0a9e2..2a86f88 100755 --- a/src/main/java/com/key/dwsurvey/action/survey/MySurveyAction.java +++ b/src/main/java/com/key/dwsurvey/action/survey/MySurveyAction.java @@ -3,6 +3,7 @@ package com.key.dwsurvey.action.survey; import com.key.common.base.action.CrudActionSupport; import com.key.common.base.entity.User; import com.key.common.base.service.AccountManager; +import com.key.common.utils.web.JsonDateValueProcessor; import com.key.common.utils.web.Struts2Utils; import com.key.dwsurvey.entity.SurveyDirectory; import com.key.dwsurvey.service.SurveyDirectoryManager; @@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.Date; /** * 我的问卷 action @@ -30,7 +32,7 @@ import javax.servlet.http.HttpServletResponse; }) @AllowedMethods({"surveyState","attrs"}) public class MySurveyAction extends CrudActionSupport{ - + @Autowired private SurveyDirectoryManager surveyDirectoryManager; @Autowired @@ -46,7 +48,7 @@ public class MySurveyAction extends CrudActionSupport{ page=surveyDirectoryManager.findByUser(page,entity); return SUCCESS; } - + public String delete() throws Exception { HttpServletResponse response=Struts2Utils.getResponse(); String result="false"; @@ -66,7 +68,7 @@ public class MySurveyAction extends CrudActionSupport{ response.getWriter().write(result); return null; } - + //问卷壮态设置 public String surveyState() throws Exception{ HttpServletResponse resp=Struts2Utils.getResponse(); @@ -89,7 +91,7 @@ public class MySurveyAction extends CrudActionSupport{ resp.getWriter().write(result); return null; } - + public String attrs() throws Exception { @@ -98,21 +100,24 @@ public class MySurveyAction extends CrudActionSupport{ try{ SurveyDirectory survey=surveyDirectoryManager.getSurvey(id); JsonConfig cfg = new JsonConfig(); + cfg.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor()); cfg.setExcludes(new String[]{"handler","hibernateLazyInitializer"}); JSONObject jsonObject=JSONObject.fromObject(survey,cfg); + + response.getWriter().write(jsonObject.toString()); }catch(Exception e){ e.printStackTrace(); } return null; } - - + + @Override protected void prepareModel() throws Exception { entity=surveyDirectoryManager.getModel(id); } - + public void prepareSurveyState() throws Exception { prepareModel(); } @@ -120,5 +125,5 @@ public class MySurveyAction extends CrudActionSupport{ public void prepareExecute() throws Exception { prepareModel(); } - + } diff --git a/src/main/java/com/key/dwsurvey/action/survey/MySurveyStyleAction.java b/src/main/java/com/key/dwsurvey/action/survey/MySurveyStyleAction.java index 26487a4..20e0e50 100644 --- a/src/main/java/com/key/dwsurvey/action/survey/MySurveyStyleAction.java +++ b/src/main/java/com/key/dwsurvey/action/survey/MySurveyStyleAction.java @@ -30,7 +30,7 @@ import java.util.Date; @InterceptorRefs({ @InterceptorRef("paramsPrepareParamsStack")}) @Results({}) public class MySurveyStyleAction extends CrudActionSupport{ - + private String surveyId; @Autowired private SurveyStyleManager surveyStyleManager; @@ -38,14 +38,15 @@ public class MySurveyStyleAction extends CrudActionSupport{ private SurveyDirectoryManager surveyDirectoryManager; @Autowired private AccountManager accountManager; - + public String save() throws Exception { + return NONE; } - + public String ajaxGetStyle() throws Exception { return null; } - + } diff --git a/src/main/webapp/WEB-INF/page/layouts/default.jsp b/src/main/webapp/WEB-INF/page/layouts/default.jsp index 9092434..9791da9 100755 --- a/src/main/webapp/WEB-INF/page/layouts/default.jsp +++ b/src/main/webapp/WEB-INF/page/layouts/default.jsp @@ -11,7 +11,8 @@ - +<%----%> + @@ -21,8 +22,8 @@ <%@ include file="/WEB-INF/page/layouts/header.jsp"%> - - + +
<%@ include file="/WEB-INF/page/layouts/footer-1.jsp"%> @@ -34,12 +35,12 @@
- - + + <%@ include file="/WEB-INF/page/layouts/other.jsp"%> - \ No newline at end of file + diff --git a/src/main/webapp/js/dw/collect.js b/src/main/webapp/js/dw/collect.js index 41f3593..f155fd0 100644 --- a/src/main/webapp/js/dw/collect.js +++ b/src/main/webapp/js/dw/collect.js @@ -61,34 +61,35 @@ $(document).ready(function(){ $("#myDialogRoot").remove(); } }); - + } - - + + //设置收集规则 $(".sur_collectSet").unbind(); $(".sur_collectSet").click(function(){ var url=ctx+"/js/dw/html/collectset.html"; - + $.ajax({ url:url, type:"get", dataType:"html", success:function(data){ - + //$("body").append("
"); $("body").append("
"+data+"
"); $("#myDialogRoot .mailOnlyItem").hide(); - + url=ctx+"/design/my-survey!attrs.action"; var data="id="+$("#id").val(); - + $.ajax({ url:url, data:data, type:'post', success:function(msg){ - + // console.debug(msg); + var survey=eval("("+msg+")"); $("#myDialogRoot input[name='effective'][value='"+survey.surveyDetail.effective+"']").attr("checked",true); $("#myDialogRoot input[name='effectiveIp'][value='"+survey.surveyDetail.effectiveIp+"']").attr("checked",true); @@ -99,16 +100,14 @@ $(document).ready(function(){ $("#myDialogRoot input[name='ynEndNum'][value='"+survey.surveyDetail.ynEndNum+"']").attr("checked",true); $("#myDialogRoot input[name='endNum']").val(survey.surveyDetail.endNum); $("#myDialogRoot input[name='ynEndTime'][value='"+survey.surveyDetail.ynEndTime+"']").attr("checked",true); - if(survey.surveyDetail.endTime!="null"){ - $("#myDialogRoot input[name='endTime']").val(survey.surveyDetail.endTime); - } + $("#myDialogRoot input[name='endTime']").val(survey.surveyDetail.endTime); $("#myDialogRoot input[name='showShareSurvey'][value='"+survey.surveyDetail.showShareSurvey+"']").attr("checked",true); $("#myDialogRoot input[name='showAnswerDa'][value='"+survey.surveyDetail.showAnswerDa+"']").attr("checked",true); - + } }); - - + + var myDialog=$( "#myDialogRoot" ).dialog({ width:550, height:490, @@ -140,6 +139,10 @@ $(document).ready(function(){ } }, open:function(event,ui){ + laydate.render({ + elem: '#surveyEndTime' //指定元素 + ,type: 'datetime' + }); $(".ui-dialog-titlebar-close").hide(); }, close:function(event,ui){ @@ -148,16 +151,16 @@ $(document).ready(function(){ }); } }); - + }); - - + + function saveAttrs(){ - var url=ctx+"/design/my-survey-style!save.action"; + var url=ctx+"/design/my-survey-design!ajaxSave.action"; var surveyId=$("#id").val(); var data="surveyId="+surveyId; - //收集规则 + //收集规则 var effective=$("#myDialogRoot input[name='effective']:checked")[0]?"4":"0"; var effectiveIp=$("#myDialogRoot input[name='effectiveIp']:checked")[0]?"1":"0"; var rule=$("#myDialogRoot input[name='rule']:checked")[0]?"3":"0"; @@ -170,11 +173,11 @@ $(document).ready(function(){ var endNum=$("#myDialogRoot input[name='endNum']").val(); var showShareSurvey=$("#myDialogRoot input[name='showShareSurvey']:checked")[0]?"1":"0"; var showAnswerDa=$("#myDialogRoot input[name='showAnswerDa']:checked")[0]?"1":"0"; - + data+="&effective="+effective+"&effectiveIp="+effectiveIp+"&rule="+rule+"&refresh="+refresh+"&ruleCode="+ruleCode+"&mailOnly="+mailOnly; data+="&ynEndNum="+ynEndNum+"&ynEndTime="+ynEndTime+"&endTime="+endTime+"&endNum="+endNum; data+="&showShareSurvey="+showShareSurvey+"&showAnswerDa="+showAnswerDa; - + $.ajax({ url : url, data : data, @@ -186,12 +189,12 @@ $(document).ready(function(){ }); return false; } - + // $(".sur_edit").unbind(); $(".sur_edit").click(function(){ //${ctx }/design/my-survey-design.action?surveyId=${surveyId} - + $("body").append("
您问卷已经发布,确认要重新编辑使问卷回到设计状态。
是否确认返回设计状态!
"); var myDialog=$( "#myDialogRoot" ).dialog({ width:500, @@ -229,10 +232,10 @@ $(document).ready(function(){ $("#myDialogRoot").remove(); } }); - + return false; }); - + $(".surveyStateBtn").unbind(); $(".surveyStateBtn").click(function(){ //var thVal=$("#surveyState").val(); @@ -272,7 +275,7 @@ $(document).ready(function(){ }); return false; }); - + }); function notify(msg,delayHid) { @@ -301,4 +304,4 @@ function notify(msg,delayHid) { }, function() { $( this ).remove(); }); -} \ No newline at end of file +} diff --git a/src/main/webapp/js/dw/html/collectset.html b/src/main/webapp/js/dw/html/collectset.html index 91547c7..a85eb18 100644 --- a/src/main/webapp/js/dw/html/collectset.html +++ b/src/main/webapp/js/dw/html/collectset.html @@ -16,8 +16,8 @@
何时结束
-
-
+
+
@@ -29,4 +29,4 @@ - \ No newline at end of file + diff --git a/src/main/webapp/js/dw/responsive-width.js b/src/main/webapp/js/dw/responsive-width.js index a884f5f..841b44f 100755 --- a/src/main/webapp/js/dw/responsive-width.js +++ b/src/main/webapp/js/dw/responsive-width.js @@ -12,7 +12,7 @@ $(document).ready(function(){ // $(".createSsUl li").unbind(); -// +// // $(".createSsUl li").hover(function(){ // if(toggleTag){ // toggleTag=false; @@ -32,10 +32,10 @@ $(document).ready(function(){ // $(".a-w-sel").slideUp("slow",function(){ // toggleTag=true; // }); -// +// // return false; // }); - + var toggleTag=true; $(".clickHideUserMenu,.clickHideMenu").unbind(); $(".clickHideUserMenu,.clickHideMenu").click(function(){ @@ -52,22 +52,26 @@ $(document).ready(function(){ }); $(".a-w-sel").not(stepLi.find(".a-w-sel")).slideUp(); */ - stepLi.find(".a-w-sel").slideToggle(0,function(){ + if(stepLi.find(".a-w-sel")[0]){ + stepLi.find(".a-w-sel").slideToggle(0,function(){ + toggleTag=true; + }); + }else{ toggleTag=true; - }); + } //$(".a-w-sel").not(stepLi.find(".a-w-sel")).slideUp(); $(".a-w-sel").not(stepLi.find(".a-w-sel")).hide(); } return false; - + }); - + $(document).click(function(){ //$(".a-w-sel").slideUp("slow"); $(".a-w-sel").hide(); }); }); - + var browseWidth=$(window).width(); var browseHeight=$(window).height(); @@ -99,4 +103,4 @@ function refreshAutoCode(codeImgId){ function currentMenu(menuId){ $(".dw-menu-a").removeClass("active"); $("#"+menuId).addClass("active"); -} \ No newline at end of file +}