JFinal-layui v1.3.8 optimize online form text field

JFinal-layui speed development of enterprise application management system, based on JFinal + layui as the core enterprise application project structure, use JFinal features combined with layui perfect, achieve the purpose of quick start projects. Make development easier and efficient, even if you do not layui, can easily master the use.

JFinal-layui v1.3.8 mainly optimization and upgrading of the online form, and custom SQL data dictionary function, JFinal-layui not only pay attention to development efficiency, while also focusing on the development experience, so used it say good!

JFinal-layui v1.3.8 update:    

1, online form:

Online forms can edit the HTML code, but before editing the text field experience is not very good, there is no line numbers, time to wrap the cursor position is not good, but the code page display is not very good, so in order to improve the efficiency and development experience, to optimize the online form text field in the text field editing experience to feel good!

This reference text field is very convenient, just a textarea id is to ddlSql, such as:

<textarea id="ddlSql" name="template_view" style="display: none;"></textarea

Because _layout.html defines methods:

<-! Table sql text field ->
#define ddlSql()
<script type="text/javascript">
	var ddlSqlId=document.getElementById("ddlSql");
	if(ddlSqlId){
		/**
	    * Initialization table sql 3
	    */
	   was ddlSql = CodeMirror.fromTextArea (ddlSqlId, {
	       lineNumbers: true,
	       matchBrackets: true,
	       mode: "text/x-sql",
	       lineWrapping:false,
	       readOnly:false,
	       foldGutter: true,
	       gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
	   });
	   ddlSql.setSize('auto','auto');		
	}

// ddlSql.getValue (); // get the value of the text field
// ddlSql.setValue (...); // assign to a text field
</script>
#end

Page preview:

image.png

2, custom SQL:

    Custom SQL also improved SQL editing text fields, SQL keywords will be distinguished by color, so as to open up like in the SQL editor

Application of the content field ddlSql text field, var value = ddlSql.getValue () Gets the value of the text field

<textarea id="ddlSql" name="content" style="display: none;">

image.png

3, the data dictionary function:

    Optimize the data dictionary function selected value, required, disable the function, just before #set cited by command () to: as

// Select the value required, select Disable
#set(value="sys",required="required",disabled="disabled")
# @ GetSelectBySql ( 'query_org', 'org_id', 'Please select the department')

image.png

4, extended select multiple choice and unlimited-level linkage function:

    这个主要是集成了layui扩展的组件到项目中,方便使用,在线体验地址:select 多选和无限极联动

image.png

5、BaseController、BaseService扩展方法:

BaseController扩展三个方法:getAllParamsToJson,getAllParamsToRecord,byKv,应该用在一些特殊的json数据:

        /**
	 * 获取请求参数,转化为JSONObject 
	 * @return
	 */
	@NotAction
    public JSONObject getAllParamsToJson(){
        JSONObject result=new JSONObject();
        Map<String,String[]> map=getParaMap();
        Set<String> keySet=map.keySet();
        for(String key:keySet){
            if(map.get(key) instanceof String[]){
                String[] value=map.get(key);
                if(value.length==0){
                    result.put(key,null);
 
                }else if(value.length==1 && key.indexOf("[]")<0){
                    result.put(key,value[0]);
                }else{
                    result.put(key,value);
                }
            }else{
                result.put(key,map.get(key));
            }
        }
        return result;
    }

 

BaseService扩展自定义SQL查询,方便使用一些SQL模板和多数据源:

        /**
	 * 自定义sql查询,sql定义在sql模板文件中 
	 * @param dbName 数据库配置名称,用于切换多数据源查询,为null时查询主数据源
	 * @param params 查询参数(JSONObject)
	 * @param sqlTemplateName sql唯一名称(命名空间.sql语句名称)
	 * @param orderBygroupBySql 排序语句
	 * @return 
	 */	
	public Grid queryForListBySqlTemplate(String dbName,Integer pageNumber,Integer pageSize,JSONObject params,String sqlTemplateName,String orderBygroupBySql) {
		DbPro dbPro = Db.use();
		//切换数据源
		if(StrKit.notBlank(dbName)) {
			dbPro = Db.use(dbName);
		}
		SqlPara sqlPara = dbPro.getSqlPara(sqlTemplateName,params);
		if(StrKit.notBlank(orderBygroupBySql)) {//如果有排序语句,则追加
			sqlPara.setSql(sqlPara.getSql() + " " + orderBygroupBySql);
		}
		Page<Record> page = dbPro.paginate(pageNumber,pageSize, sqlPara);
		return new Grid(page.getList(),pageNumber,pageSize,page.getTotalRow());
	}	

 

6, the optimization / portal / go public routing method interception process:

       / Portal / go is direct access to a static html page, followed by the full path to HTML, but if it happens to be accessed when logged in as failure to change the route, you will lose view parameters when jumping to the login page, so Login interceptor to change the interface optimized handling, with this interface, a simple page that can pass / portal / go jump the method.

image.png

image.png

Links:

Download Source: JFinal-layui

Open Source China: JFinal-layui Open Source China

System Demonstration: JFinal-layui speed development of enterprise application management system  

Community Exchange: JFinal-layui Official Community

JFInal-layuiQQ group : 970045838

 

Guess you like

Origin www.oschina.net/news/110906/jfinal-layui-1-3-8-released