Extjs6增加日历记事本功能

目前在做OA首页的时候,打算增加一个日历记事本功能。要求简单,不占版面,经过努力,终于完成,大家可以参考下。
主要实现功能:前后台交互,新增/修改、获取记录等,删除功能也可以写,时间有限,自己写吧!


1.png
2.png

主要参考:http://bbs.itheima.com/forum.php?mod=viewthread&tid=412056&highlight=layui
采用layui和jquery实现
1、js页面集成,通过iframe嵌入

 {
                        xtype : 'panel',
                        width : 350,
                        margin : '0 5 0 5',
                        cls : 'panelCls',
                        border : false,
                        region : 'east',
                        html : ''
                    }

2、记事本html页面




  
  
  
  


 


3、java端

@Resource(name = "sessionFactoryPrimary")
    private SessionFactory sessionFactory;

    @SuppressWarnings("rawtypes")
    @RequestMapping(params = "method=getDateNote")
    public void getDateNote(HttpServletRequest request, HttpServletResponse response) throws Exception {
        response.setContentType("text/json;charset=utf-8");
        Session session = sessionFactory.getCurrentSession();
        String userName = (String) request.getSession().getAttribute("userName");

        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        List list = session.createQuery("from DateNote where reportMan=:reportMan ")
                .setParameter("reportMan", userName).list();
        StringBuffer sb=new StringBuffer();
        for (Iterator iterator = list.iterator(); iterator.hasNext();) {
            DateNote dn = (DateNote) iterator.next();
            sb.append(",\""+sdf.format(dn.getMarkDate())+"\":\""+dn.getMarkNote()+"\""); 
        }
        String sbStr=sb.toString().replaceAll("\n", "");
        String str ="{"+ sbStr.substring(1,sbStr.length())+"}";   
        response.getWriter().write(str); 
    }

    @SuppressWarnings("rawtypes")
    @RequestMapping(params = "method=setDateNote")
    public void  setDateNote(HttpServletRequest request, HttpServletResponse response,String markDate,String markNote)
            throws Exception {
        response.setContentType("text/json;charset=utf-8");
        Session session = sessionFactory.getCurrentSession();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        String userName = (String) request.getSession().getAttribute("userName");
        Success success=new Success();
        if(StringUtils.isBlank(markDate) || StringUtils.isBlank(markNote)){
            success.setMsg("N");
        }else{
            //1、查询当天是否已经添加记录
            List queryExist=session.createQuery("select d.id from DateNote d where Date(d.markDate) = :mkdate")
                    .setParameter("mkdate", sdf.parse(markDate)).list();
            if(queryExist.size()>0){
                String id=queryExist.get(0).toString();
                DateNote dn=session.get(DateNote.class, id);
                dn.setMarkNote(markNote);
                dn.setUpdateTime(new Date());
                session.update(dn);
            }else{
                DateNote dn=new DateNote();
                dn.setMarkDate(sdf.parse(markDate));
                dn.setMarkNote(markNote);
                dn.setCreateTime(new Date());
                dn.setUpdateTime(new Date());
                dn.setReportMan(userName);
                session.save(dn);
            }
            success.setMsg("Y");
            
        }
        CommonHelper.responseToFront(response, success);
    }

Ok,完工!

你可能感兴趣的:(Extjs6增加日历记事本功能)