新增左树右表和导入导出代码生成模板
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
<template>crud/controller.xml</template>
|
<template>crud/controller.xml</template>
|
||||||
<template>crud/viewList.xml</template>
|
<template>crud/viewList.xml</template>
|
||||||
<template>crud/viewForm.xml</template>
|
<template>crud/viewForm.xml</template>
|
||||||
|
<template>crud/viewIndex.xml</template>
|
||||||
<childTable>
|
<childTable>
|
||||||
<template>category-ref:dao</template>
|
<template>category-ref:dao</template>
|
||||||
</childTable>
|
</childTable>
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
<template>crud_cloud/controller.xml</template>
|
<template>crud_cloud/controller.xml</template>
|
||||||
<template>crud_cloud/viewList.xml</template>
|
<template>crud_cloud/viewList.xml</template>
|
||||||
<template>crud_cloud/viewForm.xml</template>
|
<template>crud_cloud/viewForm.xml</template>
|
||||||
|
<template>crud_cloud/viewIndex.xml</template>
|
||||||
<childTable>
|
<childTable>
|
||||||
<template>crud_cloud/mapper.xml</template>
|
<template>crud_cloud/mapper.xml</template>
|
||||||
<template>crud_cloud/entity.xml</template>
|
<template>crud_cloud/entity.xml</template>
|
||||||
|
|||||||
@@ -9,9 +9,10 @@
|
|||||||
package ${packageName}.${moduleName}.web${isNotEmpty(subModuleName)?'.'+subModuleName:''};
|
package ${packageName}.${moduleName}.web${isNotEmpty(subModuleName)?'.'+subModuleName:''};
|
||||||
|
|
||||||
<% if (table.isTreeEntity){ %>
|
<% if (table.isTreeEntity){ %>
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
<% }else{ %>
|
<% } %>
|
||||||
|
<% if (!table.isTreeEntity || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -27,8 +28,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import com.jeesite.common.config.Global;
|
import com.jeesite.common.config.Global;
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
import com.jeesite.common.collect.ListUtils;
|
import com.jeesite.common.collect.ListUtils;
|
||||||
|
<% } %>
|
||||||
|
<% if(table.isTreeEntity){ %>
|
||||||
import com.jeesite.common.collect.MapUtils;
|
import com.jeesite.common.collect.MapUtils;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.idgen.IdGen;
|
import com.jeesite.common.idgen.IdGen;
|
||||||
@@ -36,6 +39,12 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
|||||||
<% }else{ %>
|
<% }else{ %>
|
||||||
import com.jeesite.common.entity.Page;
|
import com.jeesite.common.entity.Page;
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.lang.DateUtils;
|
||||||
|
import com.jeesite.common.utils.excel.ExcelExport;
|
||||||
|
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
<% } %>
|
||||||
<% if (table.tplCategory == 'crud_select'){ %>
|
<% if (table.tplCategory == 'crud_select'){ %>
|
||||||
import com.alibaba.fastjson.JSONValidator;
|
import com.alibaba.fastjson.JSONValidator;
|
||||||
import com.jeesite.common.codec.EncodeUtils;
|
import com.jeesite.common.codec.EncodeUtils;
|
||||||
@@ -75,6 +84,18 @@ public class ${ClassName}Controller extends BaseController {
|
|||||||
return ${className}Service.getAndValid(${className});
|
return ${className}Service.getAndValid(${className});
|
||||||
<% } %>
|
<% } %>
|
||||||
}
|
}
|
||||||
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableUrl'])){ %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理主页
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("${permissionPrefix}:view")
|
||||||
|
@RequestMapping(value = "index")
|
||||||
|
public String index(${ClassName} ${className}, Model model) {
|
||||||
|
model.addAttribute("${className}", ${className});
|
||||||
|
return "${lastPackageName}/${viewPrefix}Index";
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询列表
|
* 查询列表
|
||||||
@@ -192,6 +213,50 @@ public class ${ClassName}Controller extends BaseController {
|
|||||||
${className}Service.save(${className});
|
${className}Service.save(${className});
|
||||||
return renderResult(Global.TRUE, text("保存${functionNameSimple}成功!"));
|
return renderResult(Global.TRUE, text("保存${functionNameSimple}成功!"));
|
||||||
}
|
}
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("${permissionPrefix}:view")
|
||||||
|
@RequestMapping(value = "exportData")
|
||||||
|
public void exportData(${ClassName} ${className}, HttpServletResponse response) {
|
||||||
|
List<${ClassName}> list = ${className}Service.findList(${className});
|
||||||
|
String fileName = "${functionNameSimple}" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
||||||
|
try(ExcelExport ee = new ExcelExport("${functionNameSimple}", ${ClassName}.class)){
|
||||||
|
ee.setDataList(list).write(response, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载模板
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("${permissionPrefix}:view")
|
||||||
|
@RequestMapping(value = "importTemplate")
|
||||||
|
public void importTemplate(HttpServletResponse response) {
|
||||||
|
${ClassName} ${className} = new ${ClassName}();
|
||||||
|
List<${ClassName}> list = ListUtils.newArrayList(${className});
|
||||||
|
String fileName = "${functionNameSimple}模板.xlsx";
|
||||||
|
try(ExcelExport ee = new ExcelExport("${functionNameSimple}", ${ClassName}.class, Type.IMPORT)){
|
||||||
|
ee.setDataList(list).write(response, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入数据
|
||||||
|
*/
|
||||||
|
@ResponseBody
|
||||||
|
@RequiresPermissions("${permissionPrefix}:edit")
|
||||||
|
@PostMapping(value = "importData")
|
||||||
|
public String importData(MultipartFile file) {
|
||||||
|
try {
|
||||||
|
String message = ${className}Service.importData(file);
|
||||||
|
return renderResult(Global.TRUE, "posfull:"+message);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ import com.jeesite.modules.bpm.entity.BpmTreeEntity;
|
|||||||
import com.jeesite.modules.bpm.entity.BpmEntity;
|
import com.jeesite.modules.bpm.entity.BpmEntity;
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.utils.excel.annotation.ExcelField;
|
||||||
|
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
|
||||||
|
import com.jeesite.common.utils.excel.annotation.ExcelFields;
|
||||||
|
<% } %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Entity
|
* ${functionName}Entity
|
||||||
@@ -210,6 +215,17 @@ public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(tab
|
|||||||
// 生成构造方法
|
// 生成构造方法
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
@ExcelFields({
|
||||||
|
<% for(c in table.columnList){ if(c.optionMap['isImportExport'] == @Global.YES){ %>
|
||||||
|
@ExcelField(title="${c.columnLabel}", attrName="${c.attrName}"${
|
||||||
|
isNotBlank(c.optionMap['dictType'])?', dictType="'+c.optionMap['dictType']+'"':''
|
||||||
|
}, align=Align.CENTER, sort=${c.columnSort}${
|
||||||
|
c.showType == 'date'?', dataFormat="yyyy-MM-dd"':c.showType == 'datetime'?', dataFormat="yyyy-MM-dd hh:mm"':''
|
||||||
|
}),
|
||||||
|
<% } } %>
|
||||||
|
})
|
||||||
|
<% } %>
|
||||||
public ${ClassName}() {
|
public ${ClassName}() {
|
||||||
this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>);
|
this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,11 @@ import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModule
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.collect.MapUtils;
|
import com.jeesite.common.collect.MapUtils;
|
||||||
import com.jeesite.common.service.ServiceException;
|
|
||||||
import com.jeesite.modules.bpm.utils.BpmUtils;
|
import com.jeesite.modules.bpm.utils.BpmUtils;
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isBpmForm']) || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.service.ServiceException;
|
||||||
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %>
|
<% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %>
|
||||||
import com.jeesite.modules.file.utils.FileUploadUtils;
|
import com.jeesite.modules.file.utils.FileUploadUtils;
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -33,6 +35,14 @@ import com.jeesite.modules.file.utils.FileUploadUtils;
|
|||||||
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)};
|
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)};
|
||||||
import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)}Dao;
|
import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)}Dao;
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.config.Global;
|
||||||
|
import com.jeesite.common.validator.ValidatorUtils;
|
||||||
|
import com.jeesite.common.utils.excel.ExcelImport;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
<% } %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Service
|
* ${functionName}Service
|
||||||
@@ -180,6 +190,57 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv
|
|||||||
}
|
}
|
||||||
<% } %>
|
<% } %>
|
||||||
}
|
}
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入数据
|
||||||
|
* @param file 导入的数据文件
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
public String importData(MultipartFile file) {
|
||||||
|
if (file == null){
|
||||||
|
throw new ServiceException(text("请选择导入的数据文件!"));
|
||||||
|
}
|
||||||
|
int successNum = 0; int failureNum = 0;
|
||||||
|
StringBuilder successMsg = new StringBuilder();
|
||||||
|
StringBuilder failureMsg = new StringBuilder();
|
||||||
|
try(ExcelImport ei = new ExcelImport(file, 2, 0)){
|
||||||
|
List<${ClassName}> list = ei.getDataList(${ClassName}.class);
|
||||||
|
for (${ClassName} ${className} : list) {
|
||||||
|
try{
|
||||||
|
ValidatorUtils.validateWithException(${className});
|
||||||
|
this.save(${className});
|
||||||
|
successNum++;
|
||||||
|
successMsg.append("<br/>" + successNum + "、编号 " + ${className}.getId() + " 导入成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
failureNum++;
|
||||||
|
String msg = "<br/>" + failureNum + "、编号 " + ${className}.getId() + " 导入失败:";
|
||||||
|
if (e instanceof ConstraintViolationException){
|
||||||
|
ConstraintViolationException cve = (ConstraintViolationException)e;
|
||||||
|
for (ConstraintViolation<?> violation : cve.getConstraintViolations()) {
|
||||||
|
msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
msg += e.getMessage();
|
||||||
|
}
|
||||||
|
failureMsg.append(msg);
|
||||||
|
logger.error(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
failureMsg.append(e.getMessage());
|
||||||
|
return failureMsg.toString();
|
||||||
|
}
|
||||||
|
if (failureNum > 0) {
|
||||||
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
|
throw new ServiceException(failureMsg.toString());
|
||||||
|
}else{
|
||||||
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||||
|
}
|
||||||
|
return successMsg.toString();
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新状态
|
* 更新状态
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
|
No deletion without permission, or be held responsible to law. -->
|
||||||
|
<template>
|
||||||
|
<name>viewIndex</name>
|
||||||
|
<filePath>src/main/resources/views/${lastPackageName}/${moduleName}/${subModuleName}</filePath>
|
||||||
|
<fileName>${className}Index.html</fileName>
|
||||||
|
<content><![CDATA[
|
||||||
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableUrl'])){ %>
|
||||||
|
\<% layout('/layouts/default.html', {title: '${functionNameSimple}管理', libs: ['layout','zTree']}){ %>
|
||||||
|
<div class="ui-layout-west">
|
||||||
|
<div class="main-content">
|
||||||
|
<div class="box box-main">
|
||||||
|
<div class="box-header">
|
||||||
|
<div class="box-title">
|
||||||
|
<i class="fa icon-grid"></i> \${text('${functionNameSimple}')}
|
||||||
|
</div>
|
||||||
|
<div class="box-tools pull-right">
|
||||||
|
<button type="button" class="btn btn-box-tool" id="btnExpand" title="\${text('展开')}" style="display:none;"><i class="fa fa-chevron-up"></i></button>
|
||||||
|
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="\${text('折叠')}"><i class="fa fa-chevron-down"></i></button>
|
||||||
|
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="\${text('刷新')}"><i class="fa fa-refresh"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ui-layout-content">
|
||||||
|
<div id="tree" class="ztree"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ui-layout-center">
|
||||||
|
<iframe id="mainFrame" name="mainFrame" class="ui-layout-content p0"
|
||||||
|
src="\${ctx}/${urlPrefix}/list"></iframe>
|
||||||
|
</div>
|
||||||
|
\<% } %>
|
||||||
|
<script>
|
||||||
|
// 初始化布局
|
||||||
|
$('body').layout({
|
||||||
|
west__initClosed: $(window).width() <= 767, // 是否默认关闭
|
||||||
|
west__size: 200
|
||||||
|
});
|
||||||
|
// 主页框架
|
||||||
|
var win = $("#mainFrame")[0].contentWindow;
|
||||||
|
// 树结构初始化加载
|
||||||
|
var setting = {view:{selectedMulti:false},data:{key:{title:"title"},simpleData:{enable:true}},
|
||||||
|
async:{enable:true,autoParam:["id=parentCode"],url:"\${ctx}${
|
||||||
|
isNotBlank(table.optionMap['leftTreeRightTableUrl'])
|
||||||
|
?table.optionMap['leftTreeRightTableUrl']
|
||||||
|
:'/'+urlPrefix+'/treeData'}"},
|
||||||
|
callback:{onClick:function(event, treeId, treeNode){
|
||||||
|
tree.expandNode(treeNode);
|
||||||
|
//win.$('button[type=reset]').click();
|
||||||
|
<% if (isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %>
|
||||||
|
win.$('#searchForm [name="${table.optionMap['leftTreeRightTableFk']}"]').val(treeNode.id);
|
||||||
|
<% }else{ %>
|
||||||
|
<% for(pk in table.pkList){ %>
|
||||||
|
win.$('#${pk.attrName}').val(treeNode.id);
|
||||||
|
<% } %>
|
||||||
|
<% } %>
|
||||||
|
win.page();
|
||||||
|
}}
|
||||||
|
}, tree, loadTree = function(){
|
||||||
|
js.ajaxSubmit(setting.async.url+"?___t="+new Date().getTime(), {
|
||||||
|
parentCode:'\${parameter.parentCode!}'}, function(data){
|
||||||
|
tree = $.fn.zTree.init($("#tree"), setting, data);
|
||||||
|
var level = -1, nodes;
|
||||||
|
while (++level <= 1) {
|
||||||
|
nodes = tree.getNodesByParam("level", level);
|
||||||
|
if (nodes.length > 10) { break; }
|
||||||
|
for(var i=0; i<nodes.length; i++) {
|
||||||
|
tree.expandNode(nodes[i], true, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, null, null, js.text('loading.message'));
|
||||||
|
};loadTree();
|
||||||
|
// 工具栏按钮绑定
|
||||||
|
$('#btnExpand').click(function(){
|
||||||
|
tree.expandAll(true);
|
||||||
|
$(this).hide();
|
||||||
|
$('#btnCollapse').show();
|
||||||
|
});
|
||||||
|
$('#btnCollapse').click(function(){
|
||||||
|
tree.expandAll(false);
|
||||||
|
$(this).hide();
|
||||||
|
$('#btnExpand').show();
|
||||||
|
});
|
||||||
|
$('#btnRefresh').click(function(){
|
||||||
|
loadTree();
|
||||||
|
});
|
||||||
|
// 调用子页分页函数
|
||||||
|
function page(){
|
||||||
|
win.page();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<% } %>]]>
|
||||||
|
</content>
|
||||||
|
</template>
|
||||||
@@ -20,7 +20,13 @@
|
|||||||
<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="\${text('展开一级')}"><i class="fa fa-angle-double-down"></i> \${text('展开')}</a>
|
<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="\${text('展开一级')}"><i class="fa fa-angle-double-down"></i> \${text('展开')}</a>
|
||||||
<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="\${text('折叠全部')}"><i class="fa fa-angle-double-up"></i> \${text('折叠')}</a>
|
<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="\${text('折叠全部')}"><i class="fa fa-angle-double-up"></i> \${text('折叠')}</a>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<a href="#" class="btn btn-default" id="btnExport"><i class="glyphicon glyphicon-export"></i> ${text('导出')}</a>
|
||||||
|
<% } %>
|
||||||
\<% if(hasPermi('${permissionPrefix}:edit')){ %>
|
\<% if(hasPermi('${permissionPrefix}:edit')){ %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<a href="#" class="btn btn-default" id="btnImport"><i class="glyphicon glyphicon-import"></i> ${text('导入')}</a>
|
||||||
|
<% } %>
|
||||||
<a href="\${ctx}/${urlPrefix}/form" class="btn btn-default btnTool" title="\${text('新增${functionNameSimple}')}"><i class="fa fa-plus"></i> \${text('新增')}</a>
|
<a href="\${ctx}/${urlPrefix}/form" class="btn btn-default btnTool" title="\${text('新增${functionNameSimple}')}"><i class="fa fa-plus"></i> \${text('新增')}</a>
|
||||||
\<% } %>
|
\<% } %>
|
||||||
<a href="#" class="btn btn-default" id="btnSetting" title="\${text('设置')}"><i class="fa fa-navicon"></i></a>
|
<a href="#" class="btn btn-default" id="btnSetting" title="\${text('设置')}"><i class="fa fa-navicon"></i></a>
|
||||||
@@ -36,6 +42,61 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
\<% } %>
|
\<% } %>
|
||||||
<% include('/templates/modules/gen/include/dataGridScript.html'){} %>]]>
|
<% include('/templates/modules/gen/include/dataGridScript.html'){} %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<script>
|
||||||
|
$('#btnExport').click(function(){
|
||||||
|
js.ajaxSubmitForm($('#searchForm'), {
|
||||||
|
url:'\${ctx}/${urlPrefix}/exportData',
|
||||||
|
downloadFile:true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#btnImport').click(function(){
|
||||||
|
js.layer.open({
|
||||||
|
type: 1,
|
||||||
|
area: ['400px'],
|
||||||
|
title: '\${text("导入${functionNameSimple}")}',
|
||||||
|
resize: false,
|
||||||
|
scrollbar: true,
|
||||||
|
content: js.template('importTpl'),
|
||||||
|
btn: ['<i class="fa fa-check"></i> \${text("导入")}',
|
||||||
|
'<i class="fa fa-remove"></i> \${text("关闭")}'],
|
||||||
|
btn1: function(index, layero){
|
||||||
|
var form = {
|
||||||
|
inputForm: layero.find('#inputForm'),
|
||||||
|
file: layero.find('#file').val()
|
||||||
|
};
|
||||||
|
if (form.file == '' || (!js.endWith(form.file, '.xls') && !js.endWith(form.file, '.xlsx'))){
|
||||||
|
js.showMessage("\${text('文件不正确,请选择后缀为“xls”或“xlsx”的文件。')}", null, 'warning');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
js.ajaxSubmitForm(form.inputForm, function(data){
|
||||||
|
js.showMessage(data.message);
|
||||||
|
if(data.result == Global.TRUE){
|
||||||
|
js.layer.closeAll();
|
||||||
|
}
|
||||||
|
page();
|
||||||
|
}, "json");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script id="importTpl" type="text/template">//<!--
|
||||||
|
<form id="inputForm" action="\${ctx}/${urlPrefix}/importData" method="post" enctype="multipart/form-data"
|
||||||
|
class="form-horizontal mt20 mb10" style="overflow:auto;max-height:200px;">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-xs-offset-1">
|
||||||
|
<input type="file" id="file" name="file" class="form-file"/>
|
||||||
|
<div class="mt10 pt5" style="color:red">
|
||||||
|
\${text('提示:仅允许导入“xls”或“xlsx”格式文件!')}
|
||||||
|
</div>
|
||||||
|
<div class="mt10 pt5">
|
||||||
|
<a href="\${ctx}/${urlPrefix}/importTemplate" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> \${text('下载模板')}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
//--></script><% } %>]]>
|
||||||
</content>
|
</content>
|
||||||
</template>
|
</template>
|
||||||
@@ -9,9 +9,10 @@
|
|||||||
package ${packageName}.${moduleName}.web${isNotEmpty(subModuleName)?'.'+subModuleName:''};
|
package ${packageName}.${moduleName}.web${isNotEmpty(subModuleName)?'.'+subModuleName:''};
|
||||||
|
|
||||||
<% if (table.isTreeEntity){ %>
|
<% if (table.isTreeEntity){ %>
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
<% }else{ %>
|
<% } %>
|
||||||
|
<% if (!table.isTreeEntity || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import java.util.List;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -27,8 +28,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import com.jeesite.common.config.Global;
|
import com.jeesite.common.config.Global;
|
||||||
<% if(table.isTreeEntity){ %>
|
<% if(table.isTreeEntity || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
import com.jeesite.common.collect.ListUtils;
|
import com.jeesite.common.collect.ListUtils;
|
||||||
|
<% } %>
|
||||||
|
<% if(table.isTreeEntity){ %>
|
||||||
import com.jeesite.common.collect.MapUtils;
|
import com.jeesite.common.collect.MapUtils;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.idgen.IdGen;
|
import com.jeesite.common.idgen.IdGen;
|
||||||
@@ -36,6 +39,12 @@ import com.jeesite.modules.sys.utils.UserUtils;
|
|||||||
<% }else{ %>
|
<% }else{ %>
|
||||||
import com.jeesite.common.entity.Page;
|
import com.jeesite.common.entity.Page;
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.lang.DateUtils;
|
||||||
|
import com.jeesite.common.utils.excel.ExcelExport;
|
||||||
|
import com.jeesite.common.utils.excel.annotation.ExcelField.Type;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
<% } %>
|
||||||
<% if (table.tplCategory == 'crud_select'){ %>
|
<% if (table.tplCategory == 'crud_select'){ %>
|
||||||
import com.alibaba.fastjson.JSONValidator;
|
import com.alibaba.fastjson.JSONValidator;
|
||||||
import com.jeesite.common.codec.EncodeUtils;
|
import com.jeesite.common.codec.EncodeUtils;
|
||||||
@@ -75,6 +84,18 @@ public class ${ClassName}Controller extends BaseController {
|
|||||||
return ${className}Service.getAndValid(${className});
|
return ${className}Service.getAndValid(${className});
|
||||||
<% } %>
|
<% } %>
|
||||||
}
|
}
|
||||||
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableUrl'])){ %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理主页
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("${permissionPrefix}:view")
|
||||||
|
@RequestMapping(value = "index")
|
||||||
|
public String index(${ClassName} ${className}, Model model) {
|
||||||
|
model.addAttribute("${className}", ${className});
|
||||||
|
return "${lastPackageName}/${viewPrefix}Index";
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询列表
|
* 查询列表
|
||||||
@@ -192,6 +213,50 @@ public class ${ClassName}Controller extends BaseController {
|
|||||||
${className}Service.save(${className});
|
${className}Service.save(${className});
|
||||||
return renderResult(Global.TRUE, text("保存${functionNameSimple}成功!"));
|
return renderResult(Global.TRUE, text("保存${functionNameSimple}成功!"));
|
||||||
}
|
}
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出数据
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("${permissionPrefix}:view")
|
||||||
|
@RequestMapping(value = "exportData")
|
||||||
|
public void exportData(${ClassName} ${className}, HttpServletResponse response) {
|
||||||
|
List<${ClassName}> list = ${className}Service.findList(${className});
|
||||||
|
String fileName = "${functionNameSimple}" + DateUtils.getDate("yyyyMMddHHmmss") + ".xlsx";
|
||||||
|
try(ExcelExport ee = new ExcelExport("${functionNameSimple}", ${ClassName}.class)){
|
||||||
|
ee.setDataList(list).write(response, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 下载模板
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("${permissionPrefix}:view")
|
||||||
|
@RequestMapping(value = "importTemplate")
|
||||||
|
public void importTemplate(HttpServletResponse response) {
|
||||||
|
${ClassName} ${className} = new ${ClassName}();
|
||||||
|
List<${ClassName}> list = ListUtils.newArrayList(${className});
|
||||||
|
String fileName = "${functionNameSimple}模板.xlsx";
|
||||||
|
try(ExcelExport ee = new ExcelExport("${functionNameSimple}", ${ClassName}.class, Type.IMPORT)){
|
||||||
|
ee.setDataList(list).write(response, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入数据
|
||||||
|
*/
|
||||||
|
@ResponseBody
|
||||||
|
@RequiresPermissions("${permissionPrefix}:edit")
|
||||||
|
@PostMapping(value = "importData")
|
||||||
|
public String importData(MultipartFile file) {
|
||||||
|
try {
|
||||||
|
String message = ${className}Service.importData(file);
|
||||||
|
return renderResult(Global.TRUE, "posfull:"+message);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return renderResult(Global.FALSE, "posfull:"+ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
<% if(toBoolean(table.optionMap['isHaveDisableEnable'])){ %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
<content><![CDATA[
|
<content><![CDATA[
|
||||||
package ${packageName}.${moduleName}.entity${isNotBlank(subModuleName)?'.'+subModuleName:''};
|
package ${packageName}.${moduleName}.entity${isNotBlank(subModuleName)?'.'+subModuleName:''};
|
||||||
|
|
||||||
|
<% if(table.childList.~size > 0){ %>
|
||||||
|
import javax.validation.Valid;
|
||||||
|
<% } %>
|
||||||
<% for(i in table.importList){ %>
|
<% for(i in table.importList){ %>
|
||||||
import ${i};
|
import ${i};
|
||||||
<% } %>
|
<% } %>
|
||||||
@@ -26,6 +29,11 @@ import com.jeesite.modules.bpm.entity.BpmTreeEntity;
|
|||||||
import com.jeesite.modules.bpm.entity.BpmEntity;
|
import com.jeesite.modules.bpm.entity.BpmEntity;
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.utils.excel.annotation.ExcelField;
|
||||||
|
import com.jeesite.common.utils.excel.annotation.ExcelField.Align;
|
||||||
|
import com.jeesite.common.utils.excel.annotation.ExcelFields;
|
||||||
|
<% } %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Entity
|
* ${functionName}Entity
|
||||||
@@ -207,6 +215,17 @@ public class ${ClassName} extends ${toBoolean(table.optionMap['isBpmForm'])?(tab
|
|||||||
// 生成构造方法
|
// 生成构造方法
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
@ExcelFields({
|
||||||
|
<% for(c in table.columnList){ if(c.optionMap['isImportExport'] == @Global.YES){ %>
|
||||||
|
@ExcelField(title="${c.columnLabel}", attrName="${c.attrName}"${
|
||||||
|
isNotBlank(c.optionMap['dictType'])?', dictType="'+c.optionMap['dictType']+'"':''
|
||||||
|
}, align=Align.CENTER, sort=${c.columnSort}${
|
||||||
|
c.showType == 'date'?', dataFormat="yyyy-MM-dd"':c.showType == 'datetime'?', dataFormat="yyyy-MM-dd hh:mm"':''
|
||||||
|
}),
|
||||||
|
<% } } %>
|
||||||
|
})
|
||||||
|
<% } %>
|
||||||
public ${ClassName}() {
|
public ${ClassName}() {
|
||||||
this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>);
|
this(<% for(pk in table.pkList){ %>${pkLP.index!=1?', ':''}null<% } %>);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ import ${packageName}.${moduleName}.api${isNotEmpty(subModuleName)?'.'+subModule
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.collect.MapUtils;
|
import com.jeesite.common.collect.MapUtils;
|
||||||
|
import com.jeesite.modules.bpm.utils.BpmUtils;
|
||||||
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isBpmForm']) || toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
import com.jeesite.common.service.ServiceException;
|
import com.jeesite.common.service.ServiceException;
|
||||||
import com.jeesite.modules.bpm.utils.client.BpmUtils;
|
|
||||||
<% } %>
|
<% } %>
|
||||||
<% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %>
|
<% if(toBoolean(table.optionMap['isImageUpload']) || toBoolean(table.optionMap['isFileUpload'])){ %>
|
||||||
import com.jeesite.modules.file.utils.FileUploadUtils;
|
import com.jeesite.modules.file.utils.FileUploadUtils;
|
||||||
@@ -35,6 +37,14 @@ import com.jeesite.modules.file.utils.FileUploadUtils;
|
|||||||
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)};
|
import ${packageName}.${moduleName}.entity${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)};
|
||||||
import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)}Dao;
|
import ${packageName}.${moduleName}.dao${isNotEmpty(subModuleName)?'.'+subModuleName:''}.${@StringUtils.cap(child.className)}Dao;
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
import com.jeesite.common.config.Global;
|
||||||
|
import com.jeesite.common.validator.ValidatorUtils;
|
||||||
|
import com.jeesite.common.utils.excel.ExcelImport;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
<% } %>
|
||||||
|
|
||||||
import io.seata.spring.annotation.GlobalTransactional;
|
import io.seata.spring.annotation.GlobalTransactional;
|
||||||
|
|
||||||
@@ -115,8 +125,8 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv
|
|||||||
* @param ${className}
|
* @param ${className}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@GlobalTransactional
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@GlobalTransactional
|
||||||
public void save(${ClassName} ${className}) {
|
public void save(${ClassName} ${className}) {
|
||||||
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
<% if(toBoolean(table.optionMap['isBpmForm'])){ %>
|
||||||
// 如果未设置状态,则指定状态为审核状态,以提交审核流程
|
// 如果未设置状态,则指定状态为审核状态,以提交审核流程
|
||||||
@@ -187,14 +197,66 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv
|
|||||||
}
|
}
|
||||||
<% } %>
|
<% } %>
|
||||||
}
|
}
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入数据
|
||||||
|
* @param file 导入的数据文件
|
||||||
|
*/l
|
||||||
|
@Transactional
|
||||||
|
@GlobalTransactiona
|
||||||
|
public String importData(MultipartFile file) {
|
||||||
|
if (file == null){
|
||||||
|
throw new ServiceException(text("请选择导入的数据文件!"));
|
||||||
|
}
|
||||||
|
int successNum = 0; int failureNum = 0;
|
||||||
|
StringBuilder successMsg = new StringBuilder();
|
||||||
|
StringBuilder failureMsg = new StringBuilder();
|
||||||
|
try(ExcelImport ei = new ExcelImport(file, 2, 0)){
|
||||||
|
List<${ClassName}> list = ei.getDataList(${ClassName}.class);
|
||||||
|
for (${ClassName} ${className} : list) {
|
||||||
|
try{
|
||||||
|
ValidatorUtils.validateWithException(${className});
|
||||||
|
this.save(${className});
|
||||||
|
successNum++;
|
||||||
|
successMsg.append("<br/>" + successNum + "、编号 " + ${className}.getId() + " 导入成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
failureNum++;
|
||||||
|
String msg = "<br/>" + failureNum + "、编号 " + ${className}.getId() + " 导入失败:";
|
||||||
|
if (e instanceof ConstraintViolationException){
|
||||||
|
ConstraintViolationException cve = (ConstraintViolationException)e;
|
||||||
|
for (ConstraintViolation<?> violation : cve.getConstraintViolations()) {
|
||||||
|
msg += Global.getText(violation.getMessage()) + " ("+violation.getPropertyPath()+")";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
msg += e.getMessage();
|
||||||
|
}
|
||||||
|
failureMsg.append(msg);
|
||||||
|
logger.error(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
failureMsg.append(e.getMessage());
|
||||||
|
return failureMsg.toString();
|
||||||
|
}
|
||||||
|
if (failureNum > 0) {
|
||||||
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
|
throw new ServiceException(failureMsg.toString());
|
||||||
|
}else{
|
||||||
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||||
|
}
|
||||||
|
return successMsg.toString();
|
||||||
|
}
|
||||||
|
<% } %>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新状态
|
* 更新状态
|
||||||
* @param ${className}
|
* @param ${className}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@GlobalTransactional
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@GlobalTransactional
|
||||||
public void updateStatus(${ClassName} ${className}) {
|
public void updateStatus(${ClassName} ${className}) {
|
||||||
super.updateStatus(${className});
|
super.updateStatus(${className});
|
||||||
}
|
}
|
||||||
@@ -204,8 +266,8 @@ public class ${ClassName}Service extends ${table.isTreeEntity?'Tree':'Crud'}Serv
|
|||||||
* @param ${className}
|
* @param ${className}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@GlobalTransactional
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
@GlobalTransactional
|
||||||
public void delete(${ClassName} ${className}) {
|
public void delete(${ClassName} ${className}) {
|
||||||
super.delete(${className});
|
super.delete(${className});
|
||||||
<% for (child in table.childList) { %>
|
<% for (child in table.childList) { %>
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||||
|
No deletion without permission, or be held responsible to law. -->
|
||||||
|
<template>
|
||||||
|
<name>viewIndex</name>
|
||||||
|
<filePath>src/main/resources/views/${lastPackageName}/${moduleName}/${subModuleName}</filePath>
|
||||||
|
<fileName>${className}Index.html</fileName>
|
||||||
|
<content><![CDATA[
|
||||||
|
<% if(table.isTreeEntity || isNotBlank(table.optionMap['leftTreeRightTableUrl'])){ %>
|
||||||
|
\<% layout('/layouts/default.html', {title: '${functionNameSimple}管理', libs: ['layout','zTree']}){ %>
|
||||||
|
<div class="ui-layout-west">
|
||||||
|
<div class="main-content">
|
||||||
|
<div class="box box-main">
|
||||||
|
<div class="box-header">
|
||||||
|
<div class="box-title">
|
||||||
|
<i class="fa icon-grid"></i> \${text('${functionNameSimple}')}
|
||||||
|
</div>
|
||||||
|
<div class="box-tools pull-right">
|
||||||
|
<button type="button" class="btn btn-box-tool" id="btnExpand" title="\${text('展开')}" style="display:none;"><i class="fa fa-chevron-up"></i></button>
|
||||||
|
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="\${text('折叠')}"><i class="fa fa-chevron-down"></i></button>
|
||||||
|
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="\${text('刷新')}"><i class="fa fa-refresh"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ui-layout-content">
|
||||||
|
<div id="tree" class="ztree"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ui-layout-center">
|
||||||
|
<iframe id="mainFrame" name="mainFrame" class="ui-layout-content p0"
|
||||||
|
src="\${ctx}/${urlPrefix}/list"></iframe>
|
||||||
|
</div>
|
||||||
|
\<% } %>
|
||||||
|
<script>
|
||||||
|
// 初始化布局
|
||||||
|
$('body').layout({
|
||||||
|
west__initClosed: $(window).width() <= 767, // 是否默认关闭
|
||||||
|
west__size: 200
|
||||||
|
});
|
||||||
|
// 主页框架
|
||||||
|
var win = $("#mainFrame")[0].contentWindow;
|
||||||
|
// 树结构初始化加载
|
||||||
|
var setting = {view:{selectedMulti:false},data:{key:{title:"title"},simpleData:{enable:true}},
|
||||||
|
async:{enable:true,autoParam:["id=parentCode"],url:"\${ctx}${
|
||||||
|
isNotBlank(table.optionMap['leftTreeRightTableUrl'])
|
||||||
|
?table.optionMap['leftTreeRightTableUrl']
|
||||||
|
:'/'+urlPrefix+'/treeData'}"},
|
||||||
|
callback:{onClick:function(event, treeId, treeNode){
|
||||||
|
tree.expandNode(treeNode);
|
||||||
|
//win.$('button[type=reset]').click();
|
||||||
|
<% if (isNotBlank(table.optionMap['leftTreeRightTableFk'])) { %>
|
||||||
|
win.$('#searchForm [name="${table.optionMap['leftTreeRightTableFk']}"]').val(treeNode.id);
|
||||||
|
<% }else{ %>
|
||||||
|
<% for(pk in table.pkList){ %>
|
||||||
|
win.$('#${pk.attrName}').val(treeNode.id);
|
||||||
|
<% } %>
|
||||||
|
<% } %>
|
||||||
|
win.page();
|
||||||
|
}}
|
||||||
|
}, tree, loadTree = function(){
|
||||||
|
js.ajaxSubmit(setting.async.url+"?___t="+new Date().getTime(), {
|
||||||
|
parentCode:'\${parameter.parentCode!}'}, function(data){
|
||||||
|
tree = $.fn.zTree.init($("#tree"), setting, data);
|
||||||
|
var level = -1, nodes;
|
||||||
|
while (++level <= 1) {
|
||||||
|
nodes = tree.getNodesByParam("level", level);
|
||||||
|
if (nodes.length > 10) { break; }
|
||||||
|
for(var i=0; i<nodes.length; i++) {
|
||||||
|
tree.expandNode(nodes[i], true, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, null, null, js.text('loading.message'));
|
||||||
|
};loadTree();
|
||||||
|
// 工具栏按钮绑定
|
||||||
|
$('#btnExpand').click(function(){
|
||||||
|
tree.expandAll(true);
|
||||||
|
$(this).hide();
|
||||||
|
$('#btnCollapse').show();
|
||||||
|
});
|
||||||
|
$('#btnCollapse').click(function(){
|
||||||
|
tree.expandAll(false);
|
||||||
|
$(this).hide();
|
||||||
|
$('#btnExpand').show();
|
||||||
|
});
|
||||||
|
$('#btnRefresh').click(function(){
|
||||||
|
loadTree();
|
||||||
|
});
|
||||||
|
// 调用子页分页函数
|
||||||
|
function page(){
|
||||||
|
win.page();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<% } %>]]>
|
||||||
|
</content>
|
||||||
|
</template>
|
||||||
@@ -20,7 +20,13 @@
|
|||||||
<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="\${text('展开一级')}"><i class="fa fa-angle-double-down"></i> \${text('展开')}</a>
|
<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="\${text('展开一级')}"><i class="fa fa-angle-double-down"></i> \${text('展开')}</a>
|
||||||
<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="\${text('折叠全部')}"><i class="fa fa-angle-double-up"></i> \${text('折叠')}</a>
|
<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="\${text('折叠全部')}"><i class="fa fa-angle-double-up"></i> \${text('折叠')}</a>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<a href="#" class="btn btn-default" id="btnExport"><i class="glyphicon glyphicon-export"></i> ${text('导出')}</a>
|
||||||
|
<% } %>
|
||||||
\<% if(hasPermi('${permissionPrefix}:edit')){ %>
|
\<% if(hasPermi('${permissionPrefix}:edit')){ %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<a href="#" class="btn btn-default" id="btnImport"><i class="glyphicon glyphicon-import"></i> ${text('导入')}</a>
|
||||||
|
<% } %>
|
||||||
<a href="\${ctx}/${urlPrefix}/form" class="btn btn-default btnTool" title="\${text('新增${functionNameSimple}')}"><i class="fa fa-plus"></i> \${text('新增')}</a>
|
<a href="\${ctx}/${urlPrefix}/form" class="btn btn-default btnTool" title="\${text('新增${functionNameSimple}')}"><i class="fa fa-plus"></i> \${text('新增')}</a>
|
||||||
\<% } %>
|
\<% } %>
|
||||||
<a href="#" class="btn btn-default" id="btnSetting" title="\${text('设置')}"><i class="fa fa-navicon"></i></a>
|
<a href="#" class="btn btn-default" id="btnSetting" title="\${text('设置')}"><i class="fa fa-navicon"></i></a>
|
||||||
@@ -36,6 +42,61 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
\<% } %>
|
\<% } %>
|
||||||
<% include('/templates/modules/gen/include/dataGridScript.html'){} %>]]>
|
<% include('/templates/modules/gen/include/dataGridScript.html'){} %>
|
||||||
|
<% if(toBoolean(table.optionMap['isImportExport'])){ %>
|
||||||
|
<script>
|
||||||
|
$('#btnExport').click(function(){
|
||||||
|
js.ajaxSubmitForm($('#searchForm'), {
|
||||||
|
url:'\${ctx}/${urlPrefix}/exportData',
|
||||||
|
downloadFile:true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#btnImport').click(function(){
|
||||||
|
js.layer.open({
|
||||||
|
type: 1,
|
||||||
|
area: ['400px'],
|
||||||
|
title: '\${text("导入${functionNameSimple}")}',
|
||||||
|
resize: false,
|
||||||
|
scrollbar: true,
|
||||||
|
content: js.template('importTpl'),
|
||||||
|
btn: ['<i class="fa fa-check"></i> \${text("导入")}',
|
||||||
|
'<i class="fa fa-remove"></i> \${text("关闭")}'],
|
||||||
|
btn1: function(index, layero){
|
||||||
|
var form = {
|
||||||
|
inputForm: layero.find('#inputForm'),
|
||||||
|
file: layero.find('#file').val()
|
||||||
|
};
|
||||||
|
if (form.file == '' || (!js.endWith(form.file, '.xls') && !js.endWith(form.file, '.xlsx'))){
|
||||||
|
js.showMessage("\${text('文件不正确,请选择后缀为“xls”或“xlsx”的文件。')}", null, 'warning');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
js.ajaxSubmitForm(form.inputForm, function(data){
|
||||||
|
js.showMessage(data.message);
|
||||||
|
if(data.result == Global.TRUE){
|
||||||
|
js.layer.closeAll();
|
||||||
|
}
|
||||||
|
page();
|
||||||
|
}, "json");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script id="importTpl" type="text/template">//<!--
|
||||||
|
<form id="inputForm" action="\${ctx}/${urlPrefix}/importData" method="post" enctype="multipart/form-data"
|
||||||
|
class="form-horizontal mt20 mb10" style="overflow:auto;max-height:200px;">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-xs-offset-1">
|
||||||
|
<input type="file" id="file" name="file" class="form-file"/>
|
||||||
|
<div class="mt10 pt5" style="color:red">
|
||||||
|
\${text('提示:仅允许导入“xls”或“xlsx”格式文件!')}
|
||||||
|
</div>
|
||||||
|
<div class="mt10 pt5">
|
||||||
|
<a href="\${ctx}/${urlPrefix}/importTemplate" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> \${text('下载模板')}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
//--></script><% } %>]]>
|
||||||
</content>
|
</content>
|
||||||
</template>
|
</template>
|
||||||
Reference in New Issue
Block a user