完善模板
This commit is contained in:
parent
87684fff27
commit
26395251f8
@ -57,6 +57,7 @@ public class GenerateService {
|
||||
String firstLowerTableName = WStringUtil.firstToLower(tableName);
|
||||
String lowerTableName = tableNameWithoutPrefix.replaceAll("\\_", "").toLowerCase();
|
||||
Map<String, Object> dataModel = new HashMap<>(16);
|
||||
dataModel.put("context", generateVO.getContext());
|
||||
dataModel.put("codePackage", generateVO.getCodePackage());
|
||||
dataModel.put("tableNameWithoutPrefix", tableNameWithoutPrefix);
|
||||
dataModel.put("lowerTableName", lowerTableName);
|
||||
@ -71,39 +72,39 @@ public class GenerateService {
|
||||
initFieldList(tableNameWithoutPrefix, dataModel, tableView.getItems());
|
||||
// 生成API
|
||||
if (generateVO.getHasApi()) {
|
||||
apiCode("/controller/api-controller.ftl", String.format("%s/controller/api/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
apiCode("/normal/controller/api-controller.ftl", String.format("%s/controller/api/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasApi()) {
|
||||
appCode("/controller/app-controller.ftl", String.format("%s/controller/app/api/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
appCode("/normal/controller/app-controller.ftl", String.format("%s/controller/app/api/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasResource()) {
|
||||
resourceCode("/controller/resource-controller.ftl", String.format("%s/controller/resource/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
resourceCode("/normal/controller/resource-controller.ftl", String.format("%s/controller/resource/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasIService()) {
|
||||
iServiceCode("/service/i-service.ftl", String.format("%s/service/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
iServiceCode("/normal/service/i-service.ftl", String.format("%s/service/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasServiceImpl()) {
|
||||
serviceImplCode("/service/service-impl.ftl", String.format("%s/service/%s/impl", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
serviceImplCode("/normal/service/service-impl.ftl", String.format("%s/service/%s/impl", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasIDao()) {
|
||||
iDaoCode("/dao/i-dao.ftl", String.format("%s/dao/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
iDaoCode("/normal/dao/i-dao.ftl", String.format("%s/dao/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasMySQL()) {
|
||||
mySqlMapperCode("/mapper/mysql-mapper.ftl", String.format("%s/mapper/%s", outFolder, tableName), tableName, dataModel);
|
||||
mySqlMapperCode("/normal/mapper/mysql-mapper.ftl", String.format("%s/mapper/%s", outFolder, tableName), tableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasHtml()) {
|
||||
|
||||
htmlCode("/normal/page", String.format("%s/route/%s", outFolder, tableName), tableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasThymeleaf()) {
|
||||
|
||||
thymeleafCode("/normal/page", String.format("%s/route/%s", outFolder, tableName), tableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasRoute()) {
|
||||
|
||||
routeCode("/normal/controller/route-controller.ftl", String.format("%s/controller/route/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
}
|
||||
boCode("/pojo/bo.ftl", String.format("%s/pojo/bos", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
dtoCode("/pojo/dto.ftl", String.format("%s/pojo/dtos", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
poCode("/pojo/po.ftl", String.format("%s/pojo/pos", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
voCode("/pojo/vo.ftl", String.format("%s/pojo/vos", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
boCode("/normal/pojo/bo.ftl", String.format("%s/pojo/bos", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
dtoCode("/normal/pojo/dto.ftl", String.format("%s/pojo/dtos", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
poCode("/normal/pojo/po.ftl", String.format("%s/pojo/pos", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
voCode("/normal/pojo/vo.ftl", String.format("%s/pojo/vos", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -146,6 +147,8 @@ public class GenerateService {
|
||||
fieldMap.put("propertyType", field.getPropertyType());
|
||||
fieldMap.put("columnComment", field.getColumnComment());
|
||||
fieldMap.put("formFieldValue", field.getFormFieldValue());
|
||||
fieldMap.put("columnDefault", field.getColumnDefault());
|
||||
fieldMap.put("propertyLength", field.getPropertyLength());
|
||||
fieldMap.put("formShow", field.getFormShow());
|
||||
fieldMap.put("listShow", field.getListShow());
|
||||
String fieldSplit = "";
|
||||
@ -362,6 +365,68 @@ public class GenerateService {
|
||||
code(templateFtl, String.format("%s/%sVO.java", outFolder, firstUpperTableName), dataModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* html
|
||||
*
|
||||
* @param templateFolder
|
||||
* @param outFolder
|
||||
* @param tableName
|
||||
* @param dataModel
|
||||
* @throws IOException
|
||||
* @throws TemplateException
|
||||
*/
|
||||
private void htmlCode(String templateFolder, String outFolder, String tableName, Map<String, Object> dataModel) throws IOException, TemplateException {
|
||||
File folder = new File(outFolder);
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
dataModel.put("html", true);
|
||||
dataModel.put("thymeleaf", false);
|
||||
code(String.format("%s/list.ftl", templateFolder), String.format("%s/list.html", outFolder), dataModel);
|
||||
code(String.format("%s/save.ftl", templateFolder), String.format("%s/save.html", outFolder), dataModel);
|
||||
code(String.format("%s/update.ftl", templateFolder), String.format("%s/update.html", outFolder), dataModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* thymeleaf
|
||||
*
|
||||
* @param templateFolder
|
||||
* @param outFolder
|
||||
* @param tableName
|
||||
* @param dataModel
|
||||
* @throws IOException
|
||||
* @throws TemplateException
|
||||
*/
|
||||
private void thymeleafCode(String templateFolder, String outFolder, String tableName, Map<String, Object> dataModel) throws IOException, TemplateException {
|
||||
File folder = new File(outFolder);
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
dataModel.put("html", false);
|
||||
dataModel.put("thymeleaf", true);
|
||||
code(String.format("%s/list.ftl", templateFolder), String.format("%s/list.html", outFolder), dataModel);
|
||||
code(String.format("%s/save.ftl", templateFolder), String.format("%s/save.html", outFolder), dataModel);
|
||||
code(String.format("%s/update.ftl", templateFolder), String.format("%s/update.html", outFolder), dataModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* route-controller
|
||||
*
|
||||
* @param templateFtl
|
||||
* @param outFolder
|
||||
* @param firstUpperTableName
|
||||
* @param dataModel
|
||||
* @throws IOException
|
||||
* @throws TemplateException
|
||||
*/
|
||||
private void routeCode(String templateFtl, String outFolder, String firstUpperTableName, Map<String, Object> dataModel) throws IOException, TemplateException {
|
||||
File folder = new File(outFolder);
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
code(templateFtl, String.format("%s/%sRouteController.java", outFolder, firstUpperTableName), dataModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成代码
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ${codePackage}.controller.api.${lowerTableName};
|
||||
|
||||
import com.cm.common.annotation.CheckRequestBodyAnnotation;
|
||||
import com.cm.common.base.AbstractController;
|
||||
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.ErrorResult;
|
||||
@ -31,7 +31,7 @@ import java.util.Map;
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "${tableExplain}接口")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/${lowerTableName}")
|
||||
public class ${firstUpperTableName}Controller extends AbstractController {
|
||||
public class ${firstUpperTableName}Controller extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
private I${firstUpperTableName}Service ${firstLowerTableName}Service;
|
@ -1,7 +1,7 @@
|
||||
package ${codePackage}.controller.app.api.${lowerTableName};
|
||||
|
||||
import com.cm.common.annotation.CheckRequestBodyAnnotation;
|
||||
import com.cm.common.base.AbstractController;
|
||||
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.ErrorResult;
|
||||
@ -29,7 +29,7 @@ import java.util.Map;
|
||||
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "${tableExplain}接口")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.APP_PREFIX + "/${lowerTableName}")
|
||||
public class ${firstUpperTableName}AppController extends AbstractController {
|
||||
public class ${firstUpperTableName}AppController extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
private I${firstUpperTableName}Service ${firstLowerTableName}Service;
|
@ -1,7 +1,7 @@
|
||||
package ${codePackage}.controller.resource.${lowerTableName};
|
||||
|
||||
import com.cm.common.annotation.CheckRequestBodyAnnotation;
|
||||
import com.cm.common.base.AbstractController;
|
||||
import ink.wgink.annotation.CheckRequestBodyAnnotation;
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.ErrorResult;
|
||||
@ -29,7 +29,7 @@ import java.util.Map;
|
||||
@Api(tags = ISystemConstant.API_TAGS_RESOURCE_PREFIX + "${tableExplain}接口")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/${lowerTableName}")
|
||||
public class ${firstUpperTableName}ResourceController extends AbstractController {
|
||||
public class ${firstUpperTableName}ResourceController extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
private I${firstUpperTableName}Service ${firstLowerTableName}Service;
|
@ -0,0 +1,44 @@
|
||||
package ${codePackage}.controller.api.${lowerTableName};
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ${codePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO;
|
||||
import ${codePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO;
|
||||
import ${codePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}BO;
|
||||
import ${codePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}PO;
|
||||
import ${codePackage}.service.${lowerTableName}.I${firstUpperTableName}Service;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName: ${firstUpperTableName}Controller
|
||||
* @Description: ${tableExplain}
|
||||
* @Author: ${author}
|
||||
* @Date: ${date}
|
||||
* @Version: ${version}
|
||||
**/
|
||||
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "${tableExplain}路由")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/${lowerTableName}")
|
||||
public class ${firstUpperTableName}Controller extends DefaultBaseController {
|
||||
|
||||
@GetMapping("save")
|
||||
public ModelAndView save() {
|
||||
return new ModelAndView("${lowerTableName}/save");
|
||||
}
|
||||
|
||||
@GetMapping("update")
|
||||
public ModelAndView update() {
|
||||
return new ModelAndView("${lowerTableName}/update");
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public ModelAndView list() {
|
||||
return new ModelAndView("${lowerTableName}/list");
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package ${codePackage}.dao.${lowerTableName};
|
||||
|
||||
import com.cm.common.exception.RemoveException;
|
||||
import com.cm.common.exception.SaveException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.exception.UpdateException;
|
||||
import ink.wgink.exceptions.RemoveException;
|
||||
import ink.wgink.exceptions.SaveException;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
import ${codePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}BO;
|
||||
import ${codePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}PO;
|
||||
import ${codePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO;
|
258
src/main/resources/template/normal/page/list.ftl
Normal file
258
src/main/resources/template/normal/page/list.ftl
Normal file
@ -0,0 +1,258 @@
|
||||
<!doctype html>
|
||||
<#if html>
|
||||
<html lang="en">
|
||||
</#if>
|
||||
<#if thymeleaf>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
</#if>
|
||||
<head>
|
||||
<#if html>
|
||||
<base href="/${context}/">
|
||||
</#if>
|
||||
<#if thymeleaf>
|
||||
<base th:href="${r"${#request.getContextPath() + '/'}"}">
|
||||
</#if>
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="startTime" class="layui-input search-item" placeholder="开始时间" readonly>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="endTime" class="layui-input search-item" placeholder="结束时间" readonly>
|
||||
</div>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
<!-- 表头按钮组 -->
|
||||
<script type="text/html" id="headerToolBar">
|
||||
<div class="layui-btn-group">
|
||||
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
|
||||
<i class="fa fa-lg fa-plus"></i> 新增
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
|
||||
<i class="fa fa-lg fa-edit"></i> 编辑
|
||||
</button>
|
||||
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
|
||||
<i class="fa fa-lg fa-trash"></i> 删除
|
||||
</button>
|
||||
</div>
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/'
|
||||
}).extend({
|
||||
index: 'lib/index'
|
||||
}).use(['index', 'table', 'laydate', 'common'], function() {
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var table = layui.table;
|
||||
var admin = layui.admin;
|
||||
var laydate = layui.laydate;
|
||||
var common = layui.common;
|
||||
var resizeTimeout = null;
|
||||
var tableUrl = 'api/${lowerTableName}/listpage';
|
||||
|
||||
// 初始化表格
|
||||
function initTable() {
|
||||
table.render({
|
||||
elem: '#dataTable',
|
||||
id: 'dataTable',
|
||||
url: top.restAjax.path(tableUrl, []),
|
||||
width: admin.screen() > 1 ? '100%' : '',
|
||||
height: $win.height() - 90,
|
||||
limit: 20,
|
||||
limits: [20, 40, 60, 80, 100, 200],
|
||||
toolbar: '#headerToolBar',
|
||||
request: {
|
||||
pageName: 'page',
|
||||
limitName: 'rows'
|
||||
},
|
||||
cols: [
|
||||
[
|
||||
{type:'checkbox', fixed: 'left'},
|
||||
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
||||
<#list fieldList! as field>
|
||||
<#if field.listShow>
|
||||
{field: '${field.propertyName}', width: 180, title: '${field.columnComment}', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
<#if field.formFieldValue == "file" || field.formFieldValue == "image" || field.formFieldValue == "video" || field.formFieldValue == "audio">
|
||||
var downloadFile = '';
|
||||
var datas = rowData.split(',');
|
||||
for(var i = 0, item = datas[i]; item = datas[i++];) {
|
||||
if(downloadFile.length > 0) {
|
||||
downloadFile += ' | ';
|
||||
}
|
||||
downloadFile += '<a href="route/file/downloadfile/false/'+ item +'" target="_blank">点击下载</a>'
|
||||
}
|
||||
return downloadFile;
|
||||
<#elseif field.formFieldValue == "date">
|
||||
return rowData;
|
||||
<#elseif field.formFieldValue == "datetime">
|
||||
return rowData;
|
||||
<#else>
|
||||
return rowData;
|
||||
</#if>
|
||||
}
|
||||
},
|
||||
</#if>
|
||||
</#list>
|
||||
]
|
||||
],
|
||||
page: true,
|
||||
parseData: function(data) {
|
||||
return {
|
||||
'code': 0,
|
||||
'msg': '',
|
||||
'count': data.total,
|
||||
'data': data.rows
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
url: top.restAjax.path(tableUrl, []),
|
||||
where: {
|
||||
keywords: $('#keywords').val(),
|
||||
startTime: $('#startTime').val(),
|
||||
endTime: $('#endTime').val()
|
||||
},
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
height: $win.height() - 90,
|
||||
});
|
||||
}
|
||||
// 初始化日期
|
||||
function initDate() {
|
||||
// 日期选择
|
||||
laydate.render({
|
||||
elem: '#startTime',
|
||||
format: 'yyyy-MM-dd'
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#endTime',
|
||||
format: 'yyyy-MM-dd'
|
||||
});
|
||||
}
|
||||
// 删除
|
||||
function removeData(ids) {
|
||||
top.dialog.msg(top.dataMessage.delete, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
shade: 0.3,
|
||||
yes: function (index) {
|
||||
top.dialog.close(index);
|
||||
var layIndex;
|
||||
top.restAjax.delete(top.restAjax.path('api/${lowerTableName}/remove/{ids}', [ids]), {}, null, function (code, data) {
|
||||
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
||||
reloadTable();
|
||||
}, function (code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function () {
|
||||
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function () {
|
||||
top.dialog.close(layIndex);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
initDate();
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(function() {
|
||||
reloadTable();
|
||||
}, 500);
|
||||
});
|
||||
// 事件 - 搜索
|
||||
$(document).on('click', '#search', function() {
|
||||
reloadTable(1);
|
||||
});
|
||||
// 事件 - 增删改
|
||||
table.on('toolbar(dataTable)', function(obj) {
|
||||
var layEvent = obj.event;
|
||||
var checkStatus = table.checkStatus('dataTable');
|
||||
var checkDatas = checkStatus.data;
|
||||
if(layEvent === 'saveEvent') {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: false,
|
||||
closeBtn: 0,
|
||||
area: ['100%', '100%'],
|
||||
shadeClose: true,
|
||||
anim: 2,
|
||||
content: top.restAjax.path('route/${lowerTableName}/save<#if html>.html</#if>', []),
|
||||
end: function() {
|
||||
reloadTable();
|
||||
}
|
||||
});
|
||||
} else if(layEvent === 'updateEvent') {
|
||||
if(checkDatas.length === 0) {
|
||||
top.dialog.msg(top.dataMessage.table.selectEdit);
|
||||
} else if(checkDatas.length > 1) {
|
||||
top.dialog.msg(top.dataMessage.table.selectOneEdit);
|
||||
} else {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: false,
|
||||
closeBtn: 0,
|
||||
area: ['100%', '100%'],
|
||||
shadeClose: true,
|
||||
anim: 2,
|
||||
content: top.restAjax.path('route/${lowerTableName}/update<#if html>.html</#if>?${firstLowerTableName}Id={${firstLowerTableName}Id}', [checkDatas[0].${firstLowerTableName}Id]),
|
||||
end: function() {
|
||||
reloadTable();
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if(layEvent === 'removeEvent') {
|
||||
if(checkDatas.length === 0) {
|
||||
top.dialog.msg(top.dataMessage.table.selectDelete);
|
||||
} else {
|
||||
var ids = '';
|
||||
for(var i = 0, item; item = checkDatas[i++];) {
|
||||
if(i > 1) {
|
||||
ids += '_';
|
||||
}
|
||||
ids += item['${firstLowerTableName}Id'];
|
||||
}
|
||||
removeData(ids);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
770
src/main/resources/template/normal/page/save.ftl
Normal file
770
src/main/resources/template/normal/page/save.ftl
Normal file
@ -0,0 +1,770 @@
|
||||
<!doctype html>
|
||||
<#if html>
|
||||
<html lang="en">
|
||||
</#if>
|
||||
<#if thymeleaf>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
</#if>
|
||||
<head>
|
||||
<#if html>
|
||||
<base href="/${context}/">
|
||||
</#if>
|
||||
<#if thymeleaf>
|
||||
<base th:href="${r"${#request.getContextPath() + '/'}"}">
|
||||
</#if>
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||
<a href="javascript:void(0);"><cite>新增内容</cite></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="layui-card-body" style="padding: 15px;">
|
||||
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
<#if field.formFieldValue == "datetime" || field.formFieldValue == "date">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="${field.propertyName}" name="${field.propertyName}" class="layui-input" value="${field.columnDefault}" placeholder="请选择${field.columnComment}" readonly style="cursor: pointer;" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "number">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" id="${field.propertyName}" name="${field.propertyName}" class="layui-input" value="${field.columnDefault}" placeholder="请输入${field.columnComment}" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "double">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" step="0.01" id="${field.propertyName}" name="${field.propertyName}" class="layui-input" value="${field.columnDefault}" placeholder="请输入${field.columnComment}" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "textarea">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea id="${field.propertyName}" name="${field.propertyName}" class="layui-textarea" placeholder="请输入${field.columnComment}"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "richText">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="${field.propertyName}"></div>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "select">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block layui-form" id="${field.propertyName}SelectTemplateBox" lay-filter="${field.propertyName}SelectTemplateBox"></div>
|
||||
<script id="${field.propertyName}SelectTemplate" type="text/html">
|
||||
<select id="${field.propertyName}" name="${field.propertyName}">
|
||||
<option value="">请选择${field.columnComment}</option>
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<option value="{{item.dictionaryId}}">{{item.dictionaryName}}</option>
|
||||
{{# } }}
|
||||
</select>
|
||||
</script>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "checkbox">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block layui-form" id="${field.propertyName}CheckboxTemplateBox" lay-filter="${field.propertyName}CheckboxTemplateBox"></div>
|
||||
<script id="${field.propertyName}CheckboxTemplate" type="text/html">
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<input type="checkbox" name="${field.propertyName}[{{item.dictionaryId}}]" value="{{item.dictionaryId}}" title="{{item.dictionaryName}}">
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "radio">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block layui-form" id="${field.propertyName}RadioTemplateBox" lay-filter="${field.propertyName}RadioTemplateBox"></div>
|
||||
<script id="${field.propertyName}RadioTemplate" type="text/html">
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<input type="radio" name="${field.propertyName}" value="{{item.dictionaryId}}" title="{{item.dictionaryName}}">
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "file">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}">
|
||||
<div class="layui-btn-container" id="${field.propertyName}FileBox" style="border: 1px solid #e6e6e6;"></div>
|
||||
<script id="${field.propertyName}FileDownload" type="text/html">
|
||||
{{# var fileName = '${field.propertyName}'; }}
|
||||
{{# if(d[fileName] != '') { }}
|
||||
{{# var files = d[fileName];}}
|
||||
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
|
||||
<span class="layui-btn-group">
|
||||
<div class="upload-file-box">
|
||||
<a class="upload-file-a" href="route/file/downloadfile/false/{{item.fileId}}" title="{{item.fileName}} - 点击下载">
|
||||
{{# if(item.fileType == 'doc' || item.fileType == 'docx') { }}
|
||||
<img src="assets/images/filetype/word.png"/>
|
||||
{{# } else if(item.fileType == 'xls' || item.fileType == 'xlsx') { }}
|
||||
<img src="assets/images/filetype/excel.png"/>
|
||||
{{# } else if(item.fileType == 'ppt' || item.fileType == 'pptx') { }}
|
||||
<img src="assets/images/filetype/ppt.png"/>
|
||||
{{# } else if(item.fileType == 'apk') { }}
|
||||
<img src="assets/images/filetype/apk.png"/>
|
||||
{{# } else if(item.fileType == 'pdf') { }}
|
||||
<img src="assets/images/filetype/pdf.png"/>
|
||||
{{# } else if(item.fileType == 'rar') { }}
|
||||
<img src="assets/images/filetype/rar.png"/>
|
||||
{{# } else if(item.fileType == 'zip') { }}
|
||||
<img src="assets/images/filetype/zip.png"/>
|
||||
{{# } else if(item.fileType == 'txt') { }}
|
||||
<img src="assets/images/filetype/txt.png"/>
|
||||
{{# } else { }}
|
||||
<img src="assets/images/filetype/file.png"/>
|
||||
{{# } }}
|
||||
</a>
|
||||
<span class="upload-file-title">{{item.fileName}}</span>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-file" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="${field.propertyName}RemoveFile">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</a>
|
||||
</div>
|
||||
</span>
|
||||
{{# } }}
|
||||
{{# } }}
|
||||
{{# if(d[fileName].length < 9) { }}
|
||||
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
|
||||
<a href="javascript:void(0);" lay-form-button data-explain="${field.columnComment}" data-name="${field.propertyName}" lay-filter="${field.propertyName}UploadFile">
|
||||
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "image">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}">
|
||||
<div class="layui-btn-container" id="${field.propertyName +'FileBox'}" style="border: 1px solid #e6e6e6;"></div>
|
||||
<script id="${field.propertyName}FileDownload" type="text/html">
|
||||
{{# var fileName = '${field.propertyName}'; }}
|
||||
{{# if(d[fileName].length > 0) { }}
|
||||
{{# var files = d[fileName];}}
|
||||
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
|
||||
<div class="upload-image-box">
|
||||
<span class="upload-image-span">
|
||||
<img src="route/file/downloadfile/false/{{item.fileId}}" align="加载失败">
|
||||
</span>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-image" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="${field.propertyName}RemoveFile">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
{{# } }}
|
||||
{{# if(d[fileName].length < 9) { }}
|
||||
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
|
||||
<a href="javascript:void(0);" lay-form-button data-explain="${field.columnComment}" data-name="${field.propertyName}" lay-filter="${field.propertyName}UploadFile">
|
||||
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "video">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}">
|
||||
<div class="layui-btn-container" id="${field.propertyName}FileBox" style="border: 1px solid #e6e6e6;"></div>
|
||||
<script id="${field.propertyName}FileDownload" type="text/html">
|
||||
{{# var fileName = '${field.propertyName}' }}
|
||||
{{# if(d[fileName] != '') { }}
|
||||
{{# var files = d[fileName];}}
|
||||
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
|
||||
<div class="upload-video-box">
|
||||
<div id="{{fileName}}{{i}}" style="width:300px; height:200px;"></div>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-video" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="${field.propertyName}RemoveFile">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
{{# } }}
|
||||
{{# if(d[fileName].length < 1) { }}
|
||||
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
|
||||
<a href="javascript:void(0);" lay-form-button data-explain="${field.columnComment}" data-name="${field.propertyName}" lay-filter="${field.propertyName}UploadFile">
|
||||
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "audio">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}">
|
||||
<div class="layui-btn-container" id="${field.propertyName}FileBox" style="border: 1px solid #e6e6e6;"></div>
|
||||
<script id="${field.propertyName}FileDownload" type="text/html">
|
||||
{{# var fileName = '${field.propertyName}' }}
|
||||
{{# if(d[fileName] != '') { }}
|
||||
{{# var files = d[fileName];}}
|
||||
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
|
||||
<div class="upload-audio-box">
|
||||
<audio src="route/file/downloadfile/true/{{item.fileId}}" controls="controls">您的浏览器不支持 audio 标签。</audio>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-audio" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="${field.propertyName}RemoveFile">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
{{# } }}
|
||||
{{# if(d[fileName].length < 1) { }}
|
||||
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
|
||||
<a href="javascript:void(0);" lay-form-button data-explain="${field.columnComment}" data-name="${field.propertyName}" lay-filter="${field.propertyName}UploadFile">
|
||||
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "selectUser">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}" value="${field.columnDefault}">
|
||||
<input type="text" id="${field.propertyName}SelectUser" class="layui-input" placeholder="请选择${field.columnComment}" data-name="${field.propertyName}" readonly style="cursor:pointer;">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "selectDepartment">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}" value="${field.columnDefault}">
|
||||
<input type="text" id="${field.propertyName}SelectDepartment" class="layui-input" placeholder="请选择${field.columnComment}" data-name="${field.propertyName}" readonly style="cursor:pointer;">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "string">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="${field.propertyName}" name="${field.propertyName}" class="layui-input" value="${field.columnDefault}" placeholder="请输入${field.columnComment}" <#if field.verifyType?? && field.verifyType != "none">lay-verify="<#if field.verifyType == "phone">phone<#elseif field.verifyType == "email">email<#elseif field.verifyType == "url">url<#elseif field.verifyType == "number">number<#elseif field.verifyType == "date">date<#elseif field.verifyType == "identity">identity<#elseif field.verifyType == "custom">${field.propertyName}CustomVerify<#elseif field.verifyType == "required">required</#if>"</#if> <#if field.propertyLength > 0>maxlength="${field.propertyLength}"</#if>>
|
||||
</div>
|
||||
</div>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-footer" style="left: 0;">
|
||||
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
|
||||
<script src="assets/js/vendor/ckplayer/ckplayer/ckplayer.js"></script>
|
||||
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
var laytpl = layui.laytpl;
|
||||
var laydate = layui.laydate;
|
||||
var wangEditor = window.wangEditor;
|
||||
var wangEditorObj = {};
|
||||
var viewerObj = {};
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
function refreshDownloadTemplet(fileName, file) {
|
||||
var dataRander = {};
|
||||
dataRander[fileName] = file;
|
||||
|
||||
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
|
||||
document.getElementById(fileName +'FileBox').innerHTML = html;
|
||||
});
|
||||
}
|
||||
|
||||
// 初始化文件列表
|
||||
function initFileList(fileName, ids, callback) {
|
||||
var dataForm = {};
|
||||
dataForm[fileName] = ids;
|
||||
form.val('dataForm', dataForm);
|
||||
|
||||
if(!ids) {
|
||||
refreshDownloadTemplet(fileName, []);
|
||||
if(callback) {
|
||||
callback(fileName, []);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
top.restAjax.get(top.restAjax.path('api/file/listfilebyfileid', []), {
|
||||
ids: ids
|
||||
}, null, function(code, data) {
|
||||
refreshDownloadTemplet(fileName, data);
|
||||
if(callback) {
|
||||
callback(fileName, data);
|
||||
}
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
// 初始化视频
|
||||
function initVideo(fileName, data) {
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
var player = new ckplayer({
|
||||
container: '#'+ fileName + i,
|
||||
variable: 'player',
|
||||
flashplayer: false,
|
||||
video: {
|
||||
file: 'route/file/downloadfile/true/'+ item.fileId,
|
||||
type: 'video/mp4'
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
<#if field.formFieldValue == "date">
|
||||
// 初始化${field.columnComment}日期
|
||||
function init${field.firstUpperPropertyName}Date() {
|
||||
laydate.render({
|
||||
elem: '#${field.propertyName}',
|
||||
type: 'date',
|
||||
value: new Date(),
|
||||
trigger: 'click'
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "datetime">
|
||||
// 初始化${field.columnComment}时间戳
|
||||
function init${field.firstUpperPropertyName}DateTime() {
|
||||
laydate.render({
|
||||
elem: '#${field.propertyName}',
|
||||
type: 'datetime',
|
||||
value: new Date(),
|
||||
trigger: 'click'
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "richText">
|
||||
// 初始化${field.columnComment}富文本
|
||||
function init${field.firstUpperPropertyName}RichText() {
|
||||
var editor = new wangEditor('#${field.propertyName}');
|
||||
editor.customConfig.zIndex = 1000;
|
||||
editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024;
|
||||
editor.customConfig.uploadImgMaxLength = 1;
|
||||
editor.customConfig.uploadFileName = 'image';
|
||||
editor.customConfig.uploadImgServer = 'api/file/wangeditorimage';
|
||||
editor.customConfig.uploadImgHooks = {
|
||||
fail: function (xhr, editor, result) {
|
||||
top.dialog.msg('系统错误,图片上传失败');
|
||||
},
|
||||
error: function (xhr, editor) {
|
||||
top.dialog.msg('网络异常');
|
||||
},
|
||||
timeout: function (xhr, editor) {
|
||||
top.dialog.msg('网络请求超时');
|
||||
}
|
||||
};
|
||||
editor.create();
|
||||
wangEditorObj['${field.propertyName}'] = editor;
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "select">
|
||||
// 初始化${field.columnComment}下拉选择
|
||||
function init${field.firstUpperPropertyName}Select() {
|
||||
top.restAjax.get(top.restAjax.path('api/url/${field.dictionaryId}', []), {}, null, function(code, data, args) {
|
||||
laytpl(document.getElementById('${field.propertyName}SelectTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('${field.propertyName}SelectTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('select', '${field.propertyName}SelectTemplateBox');
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "checkbox">
|
||||
// 初始化${field.columnComment}复选
|
||||
function init${field.firstUpperPropertyName}Checkbox() {
|
||||
top.restAjax.get(top.restAjax.path('api/url/${field.dictionaryId}', []), {}, null, function(code, data, args) {
|
||||
laytpl(document.getElementById('${field.propertyName}CheckboxTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('${field.propertyName}CheckboxTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('checkbox', '${field.propertyName}CheckboxTemplateBox');
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "radio">
|
||||
// 初始化${field.columnComment}单选
|
||||
function init${field.firstUpperPropertyName}Radio() {
|
||||
top.restAjax.get(top.restAjax.path('api/url/${field.dictionaryId}', []), {}, null, function(code, data, args) {
|
||||
laytpl(document.getElementById('${field.propertyName}RadioTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('${field.propertyName}RadioTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('radio', '${field.propertyName}RadioTemplateBox');
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "file">
|
||||
// 初始化${field.columnComment}文件上传
|
||||
function init${field.firstUpperPropertyName}UploadFile() {
|
||||
var files = $('#${field.propertyName}').val();
|
||||
initFileList('${field.propertyName}', files);
|
||||
|
||||
form.on('button(${field.propertyName}UploadFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var explain = this.dataset.explain;
|
||||
top.dialog.file({
|
||||
type: 'file',
|
||||
title: '上传'+ explain,
|
||||
width: '400px',
|
||||
height: '420px',
|
||||
maxFileCount: '1',
|
||||
onClose: function() {
|
||||
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
|
||||
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
|
||||
var files = $('#'+ name).val();
|
||||
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
|
||||
if(files.length > 0) {
|
||||
files += ',';
|
||||
}
|
||||
files += file.data;
|
||||
}
|
||||
initFileList(name, files, function() {});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
form.on('button(${field.propertyName}RemoveFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var id = this.dataset.id;
|
||||
var files = $('#'+ name).val().replace(id, '');
|
||||
files = files.replace(/\,+/g, ',');
|
||||
if(files.charAt(0) == ',') {
|
||||
files = files.substring(1);
|
||||
}
|
||||
if(files.charAt(files.length - 1) == ',') {
|
||||
files = files.substring(0, files.length - 1);
|
||||
}
|
||||
initFileList(name, files);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "image">
|
||||
// 初始化${field.columnComment}图片上传
|
||||
function init${field.firstUpperPropertyName}UploadFile() {
|
||||
var files = $('#${field.propertyName}').val();
|
||||
initFileList('${field.propertyName}', files, function(fileName) {
|
||||
var viewer = new Viewer(document.getElementById(fileName +'FileBox'), {navbar: false});
|
||||
viewerObj[fileName] = viewer;
|
||||
});
|
||||
|
||||
form.on('button(${field.propertyName}UploadFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var explain = this.dataset.explain;
|
||||
top.dialog.file({
|
||||
type: 'image',
|
||||
title: '上传'+ explain,
|
||||
width: '400px',
|
||||
height: '420px',
|
||||
maxFileCount: '1',
|
||||
onClose: function() {
|
||||
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
|
||||
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
|
||||
var files = $('#'+ name).val();
|
||||
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
|
||||
if(files.length > 0) {
|
||||
files += ',';
|
||||
}
|
||||
files += file.data;
|
||||
}
|
||||
initFileList(name, files, function(fileName) {
|
||||
viewerObj[fileName].update();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.on('button(${field.propertyName}RemoveFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var id = this.dataset.id;
|
||||
var files = $('#'+ name).val().replace(id, '');
|
||||
files = files.replace(/\,+/g, ',');
|
||||
if(files.charAt(0) == ',') {
|
||||
files = files.substring(1);
|
||||
}
|
||||
if(files.charAt(files.length - 1) == ',') {
|
||||
files = files.substring(0, files.length - 1);
|
||||
}
|
||||
initFileList(name, files, function(fileName) {
|
||||
viewerObj[fileName].update();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "video">
|
||||
// 初始化${field.columnComment}视频上传
|
||||
function init${field.firstUpperPropertyName}UploadFile() {
|
||||
var files = $('#${field.propertyName}').val();
|
||||
initFileList('${field.propertyName}', files, initVideo);
|
||||
|
||||
form.on('button(${field.propertyName}UploadFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var explain = this.dataset.explain;
|
||||
top.dialog.file({
|
||||
type: 'video',
|
||||
title: '上传'+ explain,
|
||||
width: '400px',
|
||||
height: '420px',
|
||||
maxFileCount: '1',
|
||||
onClose: function() {
|
||||
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
|
||||
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
|
||||
var files = $('#'+ name).val();
|
||||
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
|
||||
if(files.length > 0) {
|
||||
files += ',';
|
||||
}
|
||||
files += file.data;
|
||||
}
|
||||
initFileList(name, files, initVideo);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.on('button(${field.propertyName}RemoveFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var id = this.dataset.id;
|
||||
var files = $('#'+ name).val().replace(id, '');
|
||||
files = files.replace(/\,+/g, ',');
|
||||
if(files.charAt(0) == ',') {
|
||||
files = files.substring(1);
|
||||
}
|
||||
if(files.charAt(files.length - 1) == ',') {
|
||||
files = files.substring(0, files.length - 1);
|
||||
}
|
||||
initFileList(name, files, initVideo);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "audio">
|
||||
// 初始化${field.columnComment}音频上传
|
||||
function init${field.firstUpperPropertyName}UploadFile() {
|
||||
var files = $('#${field.propertyName}').val();
|
||||
initFileList('${field.propertyName}', files);
|
||||
|
||||
form.on('button(${field.propertyName}UploadFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var explain = this.dataset.explain;
|
||||
top.dialog.file({
|
||||
type: 'audio',
|
||||
title: '上传'+ explain,
|
||||
width: '400px',
|
||||
height: '420px',
|
||||
maxFileCount: '1',
|
||||
onClose: function() {
|
||||
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
|
||||
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
|
||||
var files = $('#'+ name).val();
|
||||
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
|
||||
if(files.length > 0) {
|
||||
files += ',';
|
||||
}
|
||||
files += file.data;
|
||||
}
|
||||
initFileList(name, files);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.on('button(${field.propertyName}RemoveFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var id = this.dataset.id;
|
||||
var files = $('#'+ name).val().replace(id, '');
|
||||
files = files.replace(/\,+/g, ',');
|
||||
if(files.charAt(0) == ',') {
|
||||
files = files.substring(1);
|
||||
}
|
||||
if(files.charAt(files.length - 1) == ',') {
|
||||
files = files.substring(0, files.length - 1);
|
||||
}
|
||||
initFileList(name, files);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "selectUser">
|
||||
// 初始化${field.columnComment}选择人员
|
||||
function init${field.firstUpperPropertyName}SelectUser() {
|
||||
$(document.body).on('click', '#${field.propertyName}SelectUser', function() {
|
||||
var name = this.dataset.name;
|
||||
top.dialog.dialogData.selectedUserIds = $('#'+ name).val();
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/department/user/select-user', []),
|
||||
title: '选择用户',
|
||||
width: '500px',
|
||||
height: '500px',
|
||||
onClose: function() {
|
||||
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
|
||||
// 填写逻辑
|
||||
if(selectedUsers != null && selectedUsers.length > 0) {
|
||||
for (var i = 0, item; item = selectedUsers[i++];) {
|
||||
console.log(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "selectDepartment">
|
||||
// 初始化${field.columnComment}选择部门
|
||||
function init${field.firstUpperPropertyName}SelectDepartment() {
|
||||
$(document.body).on('click', '#${field.propertyName}SelectDepartment', function() {
|
||||
var name = this.dataset.name;
|
||||
var selectedNodes = [];
|
||||
var selectDepartment = $('#'+ name).val().split(',');
|
||||
});
|
||||
}
|
||||
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
|
||||
// 初始化内容
|
||||
function initData() {
|
||||
top.restAjax.get(top.restAjax.path('api/${lowerTableName}/getcurrentuseridinfo', []), {}, null, function(code, data) {
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
<#if field.formFieldValue == "date">
|
||||
init${field.firstUpperPropertyName}Date();
|
||||
<#elseif field.formFieldValue == "datetime">
|
||||
init${field.firstUpperPropertyName}DateTime();
|
||||
<#elseif field.formFieldValue == "richText">
|
||||
init${field.firstUpperPropertyName}RichText();
|
||||
<#elseif field.formFieldValue == "select">
|
||||
init${field.firstUpperPropertyName}Select();
|
||||
<#elseif field.formFieldValue == "checkbox">
|
||||
init${field.firstUpperPropertyName}Checkbox();
|
||||
<#elseif field.formFieldValue == "radio">
|
||||
init${field.firstUpperPropertyName}Radio();
|
||||
<#elseif field.formFieldValue == "file" || field.formFieldValue == "image" || field.formFieldValue == "video" || field.formFieldValue == "audio">
|
||||
init${field.firstUpperPropertyName}UploadFile();
|
||||
<#elseif field.formFieldValue == "selectUser">
|
||||
init${field.firstUpperPropertyName}SelectUser();
|
||||
<#elseif field.formFieldValue == "selectDepartment">
|
||||
init${field.firstUpperPropertyName}SelectDepartment();
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
}
|
||||
initData();
|
||||
|
||||
// 提交表单
|
||||
form.on('submit(submitForm)', function(formData) {
|
||||
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
<#if field.formFieldValue == "checkbox">
|
||||
formData.field['${field.propertyName}'] = top.restAjax.checkBoxToString(formData.field, '${field.propertyName}');
|
||||
<#elseif field.formFieldValue == "richText">
|
||||
formData.field['${field.propertyName}'] = wangEditorObj['${field.propertyName}'].txt.html();
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
top.restAjax.post(top.restAjax.path('api/${lowerTableName}/save${lowerTableName}', []), formData.field, null, function(code, data) {
|
||||
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
shade: 0.3,
|
||||
yes: function(index) {
|
||||
top.dialog.close(index);
|
||||
window.location.reload();
|
||||
},
|
||||
btn2: function() {
|
||||
closeBox();
|
||||
}
|
||||
});
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.close').on('click', function() {
|
||||
closeBox();
|
||||
});
|
||||
|
||||
// 校验
|
||||
form.verify({
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
<#if field.formFieldValue == "string">
|
||||
<#if field.verifyType??>
|
||||
<#if field.verifyType == "custom">
|
||||
${field.propertyName}CustomVerify: function(value, item){
|
||||
if(!new RegExp('${field.verifyRegular}').test(value)){
|
||||
return '${field.columnComment}格式错误';
|
||||
}
|
||||
}
|
||||
</#if>
|
||||
</#if>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
793
src/main/resources/template/normal/page/update.ftl
Normal file
793
src/main/resources/template/normal/page/update.ftl
Normal file
@ -0,0 +1,793 @@
|
||||
<!doctype html>
|
||||
<#if html>
|
||||
<html lang="en">
|
||||
</#if>
|
||||
<#if thymeleaf>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
</#if>
|
||||
<head>
|
||||
<#if html>
|
||||
<base href="/${context}/">
|
||||
</#if>
|
||||
<#if thymeleaf>
|
||||
<base th:href="${r"${#request.getContextPath() + '/'}"}">
|
||||
</#if>
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header">
|
||||
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
|
||||
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
|
||||
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="layui-card-body" style="padding: 15px;">
|
||||
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
<#if field.formFieldValue == "datetime" || field.formFieldValue == "date">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="${field.propertyName}" name="${field.propertyName}" class="layui-input" value="${field.columnDefault}" placeholder="请选择${field.columnComment}" lay-verify="required" readonly style="cursor: pointer;">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "number">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" id="${field.propertyName}" name="${field.propertyName}" class="layui-input" value="${field.columnDefault}" placeholder="请输入${field.columnComment}" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "double">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" step="0.01" id="${field.propertyName}" name="${field.propertyName}" class="layui-input" value="${field.columnDefault}" placeholder="请输入${field.columnComment}" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "textarea">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea id="${field.propertyName}" name="${field.propertyName}" class="layui-textarea" placeholder="请输入${field.columnComment}"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "richText">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label layui-form">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="${field.propertyName}"></div>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "select">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block layui-form" id="${field.propertyName}SelectTemplateBox" lay-filter="${field.propertyName}SelectTemplateBox"></div>
|
||||
<script id="${field.propertyName}SelectTemplate" type="text/html">
|
||||
<select id="${field.propertyName}" name="${field.propertyName}">
|
||||
<option value="">请选择${field.columnComment}</option>
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<option value="{{item.dictionaryId}}">{{item.dictionaryName}}</option>
|
||||
{{# } }}
|
||||
</select>
|
||||
</script>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "checkbox">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block layui-form" id="${field.propertyName}CheckboxTemplateBox" lay-filter="${field.propertyName}CheckboxTemplateBox"></div>
|
||||
<script id="${field.propertyName}CheckboxTemplate" type="text/html">
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<input type="checkbox" name="${field.propertyName}[{{item.dictionaryId}}]" value="{{item.dictionaryId}}" title="{{item.dictionaryName}}">
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "radio">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block" id="${field.propertyName}RadioTemplateBox" lay-filter="${field.propertyName}RadioTemplateBox"></div>
|
||||
<script id="${field.propertyName}RadioTemplate" type="text/html">
|
||||
{{# for(var i = 0, item; item = d[i++];) { }}
|
||||
<input type="radio" name="${field.propertyName}" value="{{item.dictionaryId}}" title="{{item.dictionaryName}}">
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "file">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}">
|
||||
<div class="layui-btn-container" id="${field.propertyName}FileBox" style="border: 1px solid #e6e6e6;"></div>
|
||||
<script id="${field.propertyName}FileDownload" type="text/html">
|
||||
{{# var fileName = '${field.propertyName}'; }}
|
||||
{{# if(d[fileName] != '') { }}
|
||||
{{# var files = d[fileName];}}
|
||||
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
|
||||
<span class="layui-btn-group">
|
||||
<div class="upload-file-box">
|
||||
<a class="upload-file-a" href="route/file/downloadfile/false/{{item.fileId}}" title="{{item.fileName}} - 点击下载">
|
||||
{{# if(item.fileType == 'doc' || item.fileType == 'docx') { }}
|
||||
<img src="assets/images/filetype/word.png"/>
|
||||
{{# } else if(item.fileType == 'xls' || item.fileType == 'xlsx') { }}
|
||||
<img src="assets/images/filetype/excel.png"/>
|
||||
{{# } else if(item.fileType == 'ppt' || item.fileType == 'pptx') { }}
|
||||
<img src="assets/images/filetype/ppt.png"/>
|
||||
{{# } else if(item.fileType == 'apk') { }}
|
||||
<img src="assets/images/filetype/apk.png"/>
|
||||
{{# } else if(item.fileType == 'pdf') { }}
|
||||
<img src="assets/images/filetype/pdf.png"/>
|
||||
{{# } else if(item.fileType == 'rar') { }}
|
||||
<img src="assets/images/filetype/rar.png"/>
|
||||
{{# } else if(item.fileType == 'zip') { }}
|
||||
<img src="assets/images/filetype/zip.png"/>
|
||||
{{# } else if(item.fileType == 'txt') { }}
|
||||
<img src="assets/images/filetype/txt.png"/>
|
||||
{{# } else { }}
|
||||
<img src="assets/images/filetype/file.png"/>
|
||||
{{# } }}
|
||||
</a>
|
||||
<span class="upload-file-title">{{item.fileName}}</span>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-file" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="${field.propertyName}RemoveFile">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</a>
|
||||
</div>
|
||||
</span>
|
||||
{{# } }}
|
||||
{{# } }}
|
||||
{{# if(d[fileName].length < 9) { }}
|
||||
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
|
||||
<a href="javascript:void(0);" lay-form-button data-explain="${field.columnComment}" data-name="${field.propertyName}" lay-filter="${field.propertyName}UploadFile">
|
||||
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "image">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}">
|
||||
<div class="layui-btn-container" id="${field.propertyName +'FileBox'}" style="border: 1px solid #e6e6e6;"></div>
|
||||
<script id="${field.propertyName}FileDownload" type="text/html">
|
||||
{{# var fileName = '${field.propertyName}'; }}
|
||||
{{# if(d[fileName].length > 0) { }}
|
||||
{{# var files = d[fileName];}}
|
||||
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
|
||||
<div class="upload-image-box">
|
||||
<span class="upload-image-span">
|
||||
<img src="route/file/downloadfile/false/{{item.fileId}}" align="加载失败">
|
||||
</span>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-image" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="${field.propertyName}RemoveFile">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
{{# } }}
|
||||
{{# if(d[fileName].length < 9) { }}
|
||||
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
|
||||
<a href="javascript:void(0);" lay-form-button data-explain="${field.columnComment}" data-name="${field.propertyName}" lay-filter="${field.propertyName}UploadFile">
|
||||
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "video">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}">
|
||||
<div class="layui-btn-container" id="${field.propertyName}FileBox" style="border: 1px solid #e6e6e6;"></div>
|
||||
<script id="${field.propertyName}FileDownload" type="text/html">
|
||||
{{# var fileName = '${field.propertyName}' }}
|
||||
{{# if(d[fileName] != '') { }}
|
||||
{{# var files = d[fileName];}}
|
||||
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
|
||||
<div class="upload-video-box">
|
||||
<div id="{{fileName}}{{i}}" style="width:300px; height:200px;"></div>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-video" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="${field.propertyName}RemoveFile">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
{{# } }}
|
||||
{{# if(d[fileName].length < 1) { }}
|
||||
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
|
||||
<a href="javascript:void(0);" lay-form-button data-explain="${field.columnComment}" data-name="${field.propertyName}" lay-filter="${field.propertyName}UploadFile">
|
||||
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "audio">
|
||||
<div class="layui-form-item layui-form-text">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}">
|
||||
<div class="layui-btn-container" id="${field.propertyName}FileBox" style="border: 1px solid #e6e6e6;"></div>
|
||||
<script id="${field.propertyName}FileDownload" type="text/html">
|
||||
{{# var fileName = '${field.propertyName}' }}
|
||||
{{# if(d[fileName] != '') { }}
|
||||
{{# var files = d[fileName];}}
|
||||
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
|
||||
<div class="upload-audio-box">
|
||||
<audio src="route/file/downloadfile/true/{{item.fileId}}" controls="controls">您的浏览器不支持 audio 标签。</audio>
|
||||
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-audio" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="${field.propertyName}RemoveFile">
|
||||
<i class="fa fa-trash-o"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
{{# } }}
|
||||
{{# if(d[fileName].length < 1) { }}
|
||||
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
|
||||
<a href="javascript:void(0);" lay-form-button data-explain="${field.columnComment}" data-name="${field.propertyName}" lay-filter="${field.propertyName}UploadFile">
|
||||
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
|
||||
</a>
|
||||
</div>
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "selectUser">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}" value="${field.columnDefault}">
|
||||
<input type="text" id="${field.propertyName}SelectUser" class="layui-input" placeholder="请选择${field.columnComment}" data-name="${field.propertyName}" readonly style="cursor:pointer;">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "selectDepartment">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" id="${field.propertyName}" name="${field.propertyName}" value="${field.columnDefault}">
|
||||
<input type="text" id="${field.propertyName}SelectDepartment" class="layui-input" placeholder="请选择${field.columnComment}" data-name="${field.propertyName}" readonly style="cursor:pointer;">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "string">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="${field.propertyName}" name="${field.propertyName}" class="layui-input" value="${field.columnDefault}" placeholder="请输入${field.columnComment}" <#if field.verifyType?? && field.verifyType != "none">lay-verify="<#if field.verifyType == "phone">phone<#elseif field.verifyType == "email">email<#elseif field.verifyType == "url">url<#elseif field.verifyType == "number">number<#elseif field.verifyType == "date">date<#elseif field.verifyType == "identity">identity<#elseif field.verifyType == "custom">${field.propertyName}CustomVerify<#elseif field.verifyType == "required">required</#if>"</#if> <#if field.propertyLength > 0>maxlength="${field.propertyLength}"</#if>>
|
||||
</div>
|
||||
</div>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-footer" style="left: 0;">
|
||||
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
|
||||
<script src="assets/js/vendor/ckplayer/ckplayer/ckplayer.js"></script>
|
||||
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
var laytpl = layui.laytpl;
|
||||
var laydate = layui.laydate;
|
||||
var ${firstLowerTableName}Id = top.restAjax.params(window.location.href).${firstLowerTableName}Id;
|
||||
|
||||
var wangEditor = window.wangEditor;
|
||||
var wangEditorObj = {};
|
||||
var viewerObj = {};
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
function refreshDownloadTemplet(fileName, file) {
|
||||
var dataRander = {};
|
||||
dataRander[fileName] = file;
|
||||
|
||||
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
|
||||
document.getElementById(fileName +'FileBox').innerHTML = html;
|
||||
});
|
||||
}
|
||||
|
||||
// 初始化文件列表
|
||||
function initFileList(fileName, ids, callback) {
|
||||
var dataForm = {};
|
||||
dataForm[fileName] = ids;
|
||||
form.val('dataForm', dataForm);
|
||||
|
||||
if(!ids) {
|
||||
refreshDownloadTemplet(fileName, []);
|
||||
if(callback) {
|
||||
callback(fileName, []);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
top.restAjax.get(top.restAjax.path('api/file/listfilebyfileid', []), {
|
||||
ids: ids
|
||||
}, null, function(code, data) {
|
||||
refreshDownloadTemplet(fileName, data);
|
||||
if(callback) {
|
||||
callback(fileName, data);
|
||||
}
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
// 初始化视频
|
||||
function initVideo(fileName, data) {
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
var player = new ckplayer({
|
||||
container: '#'+ fileName + i,
|
||||
variable: 'player',
|
||||
flashplayer: false,
|
||||
video: {
|
||||
file: 'route/file/downloadfile/true/'+ item.fileId,
|
||||
type: 'video/mp4'
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
<#if field.formFieldValue == "date">
|
||||
// 初始化${field.columnComment}日期
|
||||
function init${field.firstUpperPropertyName}Date() {
|
||||
laydate.render({
|
||||
elem: '#${field.propertyName}',
|
||||
type: 'date',
|
||||
value: new Date(),
|
||||
trigger: 'click'
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "datetime">
|
||||
// 初始化${field.columnComment}时间戳
|
||||
function init${field.firstUpperPropertyName}DateTime() {
|
||||
laydate.render({
|
||||
elem: '#${field.propertyName}',
|
||||
type: 'datetime',
|
||||
value: new Date(),
|
||||
trigger: 'click'
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "richText">
|
||||
// 初始化${field.columnComment}富文本
|
||||
function init${field.firstUpperPropertyName}RichText(value) {
|
||||
var editor = new wangEditor('#${field.propertyName}');
|
||||
editor.customConfig.zIndex = 1000;
|
||||
editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024;
|
||||
editor.customConfig.uploadImgMaxLength = 1;
|
||||
editor.customConfig.uploadFileName = 'image';
|
||||
editor.customConfig.uploadImgServer = 'api/file/wangeditorimage';
|
||||
editor.customConfig.uploadImgHooks = {
|
||||
fail: function (xhr, editor, result) {
|
||||
top.dialog.msg('系统错误,图片上传失败');
|
||||
},
|
||||
error: function (xhr, editor) {
|
||||
top.dialog.msg('网络异常');
|
||||
},
|
||||
timeout: function (xhr, editor) {
|
||||
top.dialog.msg('网络请求超时');
|
||||
}
|
||||
};
|
||||
editor.create();
|
||||
editor.txt.html(value);
|
||||
wangEditorObj['${field.propertyName}'] = editor;
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "select">
|
||||
// 初始化${field.columnComment}下拉选择
|
||||
function init${field.firstUpperPropertyName}Select(selectValue) {
|
||||
top.restAjax.get(top.restAjax.path('api/url/${field.dictionaryId}', []), {}, null, function(code, data, args) {
|
||||
laytpl(document.getElementById('${field.propertyName}SelectTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('${field.propertyName}SelectTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('select', '${field.propertyName}SelectTemplateBox');
|
||||
|
||||
var selectObj = {};
|
||||
selectObj['${field.propertyName}'] = selectValue;
|
||||
form.val('dataForm', selectObj);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "checkbox">
|
||||
// 初始化${field.columnComment}复选
|
||||
function init${field.firstUpperPropertyName}Checkbox(selectValues) {
|
||||
top.restAjax.get(top.restAjax.path('api/url/${field.dictionaryId}', []), {}, null, function(code, data, args) {
|
||||
laytpl(document.getElementById('${field.propertyName}CheckboxTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('${field.propertyName}CheckboxTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('checkbox', '${field.propertyName}CheckboxTemplateBox');
|
||||
|
||||
var checkboxValue = selectValues.split(',');
|
||||
var checkboxObj = {};
|
||||
for(var j = 0, checkbox = checkboxValue[j]; checkbox = checkboxValue[j++];) {
|
||||
checkboxObj['${field.propertyName}['+ checkbox +']'] = true;
|
||||
}
|
||||
form.val('dataForm', checkboxObj);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "radio">
|
||||
// 初始化${field.columnComment}单选
|
||||
function init${field.firstUpperPropertyName}Radio(selectValue) {
|
||||
top.restAjax.get(top.restAjax.path('api/url/${field.dictionaryId}', []), {}, null, function(code, data, args) {
|
||||
laytpl(document.getElementById('${field.propertyName}RadioTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('${field.propertyName}RadioTemplateBox').innerHTML = html;
|
||||
});
|
||||
form.render('radio', '${field.propertyName}RadioTemplateBox');
|
||||
|
||||
var radioObj = {};
|
||||
radioObj['${field.propertyName}'] = selectValue;
|
||||
form.val('dataForm', radioObj);
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "file">
|
||||
// 初始化${field.columnComment}文件上传
|
||||
function init${field.firstUpperPropertyName}UploadFile() {
|
||||
var files = $('#${field.propertyName}').val();
|
||||
initFileList('${field.propertyName}', files);
|
||||
|
||||
form.on('button(${field.propertyName}UploadFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var explain = this.dataset.explain;
|
||||
top.dialog.file({
|
||||
type: 'file',
|
||||
title: '上传'+ explain,
|
||||
width: '400px',
|
||||
height: '420px',
|
||||
maxFileCount: '1',
|
||||
onClose: function() {
|
||||
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
|
||||
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
|
||||
var files = $('#'+ name).val();
|
||||
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
|
||||
if(files.length > 0) {
|
||||
files += ',';
|
||||
}
|
||||
files += file.data;
|
||||
}
|
||||
initFileList(name, files, function() {});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
form.on('button(${field.propertyName}RemoveFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var id = this.dataset.id;
|
||||
var files = $('#'+ name).val().replace(id, '');
|
||||
files = files.replace(/\,+/g, ',');
|
||||
if(files.charAt(0) == ',') {
|
||||
files = files.substring(1);
|
||||
}
|
||||
if(files.charAt(files.length - 1) == ',') {
|
||||
files = files.substring(0, files.length - 1);
|
||||
}
|
||||
initFileList(name, files);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "image">
|
||||
// 初始化${field.columnComment}图片上传
|
||||
function init${field.firstUpperPropertyName}UploadFile() {
|
||||
var files = $('#${field.propertyName}').val();
|
||||
initFileList('${field.propertyName}', files, function(fileName) {
|
||||
var viewer = new Viewer(document.getElementById(fileName +'FileBox'), {navbar: false});
|
||||
viewerObj[fileName] = viewer;
|
||||
});
|
||||
|
||||
form.on('button(${field.propertyName}UploadFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var explain = this.dataset.explain;
|
||||
top.dialog.file({
|
||||
type: 'image',
|
||||
title: '上传'+ explain,
|
||||
width: '400px',
|
||||
height: '420px',
|
||||
maxFileCount: '1',
|
||||
onClose: function() {
|
||||
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
|
||||
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
|
||||
var files = $('#'+ name).val();
|
||||
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
|
||||
if(files.length > 0) {
|
||||
files += ',';
|
||||
}
|
||||
files += file.data;
|
||||
}
|
||||
initFileList(name, files, function(fileName) {
|
||||
viewerObj[fileName].update();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.on('button(${field.propertyName}RemoveFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var id = this.dataset.id;
|
||||
var files = $('#'+ name).val().replace(id, '');
|
||||
files = files.replace(/\,+/g, ',');
|
||||
if(files.charAt(0) == ',') {
|
||||
files = files.substring(1);
|
||||
}
|
||||
if(files.charAt(files.length - 1) == ',') {
|
||||
files = files.substring(0, files.length - 1);
|
||||
}
|
||||
initFileList(name, files, function(fileName) {
|
||||
viewerObj[fileName].update();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "video">
|
||||
// 初始化${field.columnComment}视频上传
|
||||
function init${field.firstUpperPropertyName}UploadFile() {
|
||||
var files = $('#${field.propertyName}').val();
|
||||
initFileList('${field.propertyName}', files, initVideo);
|
||||
|
||||
form.on('button(${field.propertyName}UploadFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var explain = this.dataset.explain;
|
||||
top.dialog.file({
|
||||
type: 'video',
|
||||
title: '上传'+ explain,
|
||||
width: '400px',
|
||||
height: '420px',
|
||||
maxFileCount: '1',
|
||||
onClose: function() {
|
||||
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
|
||||
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
|
||||
var files = $('#'+ name).val();
|
||||
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
|
||||
if(files.length > 0) {
|
||||
files += ',';
|
||||
}
|
||||
files += file.data;
|
||||
}
|
||||
initFileList(name, files, initVideo);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.on('button(${field.propertyName}RemoveFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var id = this.dataset.id;
|
||||
var files = $('#'+ name).val().replace(id, '');
|
||||
files = files.replace(/\,+/g, ',');
|
||||
if(files.charAt(0) == ',') {
|
||||
files = files.substring(1);
|
||||
}
|
||||
if(files.charAt(files.length - 1) == ',') {
|
||||
files = files.substring(0, files.length - 1);
|
||||
}
|
||||
initFileList(name, files, initVideo);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "audio">
|
||||
// 初始化${field.columnComment}音频上传
|
||||
function init${field.firstUpperPropertyName}UploadFile() {
|
||||
var files = $('#${field.propertyName}').val();
|
||||
initFileList('${field.propertyName}', files);
|
||||
|
||||
form.on('button(${field.propertyName}UploadFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var explain = this.dataset.explain;
|
||||
top.dialog.file({
|
||||
type: 'audio',
|
||||
title: '上传'+ explain,
|
||||
width: '400px',
|
||||
height: '420px',
|
||||
maxFileCount: '1',
|
||||
onClose: function() {
|
||||
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
|
||||
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
|
||||
var files = $('#'+ name).val();
|
||||
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
|
||||
if(files.length > 0) {
|
||||
files += ',';
|
||||
}
|
||||
files += file.data;
|
||||
}
|
||||
initFileList(name, files);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
form.on('button(${field.propertyName}RemoveFile)', function(obj) {
|
||||
var name = this.dataset.name;
|
||||
var id = this.dataset.id;
|
||||
var files = $('#'+ name).val().replace(id, '');
|
||||
files = files.replace(/\,+/g, ',');
|
||||
if(files.charAt(0) == ',') {
|
||||
files = files.substring(1);
|
||||
}
|
||||
if(files.charAt(files.length - 1) == ',') {
|
||||
files = files.substring(0, files.length - 1);
|
||||
}
|
||||
initFileList(name, files);
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "selectUser">
|
||||
// 初始化${field.columnComment}选择人员
|
||||
function init${field.firstUpperPropertyName}SelectUser() {
|
||||
$(document.body).on('click', '#${field.propertyName}SelectUser', function() {
|
||||
var name = this.dataset.name;
|
||||
top.dialog.dialogData.selectedUserIds = $('#'+ name).val();
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/department/user/select-user', []),
|
||||
title: '选择用户',
|
||||
width: '500px',
|
||||
height: '500px',
|
||||
onClose: function() {
|
||||
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
|
||||
// 填写逻辑
|
||||
if(selectedUsers != null && selectedUsers.length > 0) {
|
||||
for (var i = 0, item; item = selectedUsers[i++];) {
|
||||
console.log(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
<#elseif field.formFieldValue == "selectDepartment">
|
||||
// 初始化${field.columnComment}选择部门
|
||||
function init${field.firstUpperPropertyName}SelectDepartment() {
|
||||
$(document.body).on('click', '#${field.propertyName}SelectDepartment', function() {
|
||||
var name = this.dataset.name;
|
||||
var selectedNodes = [];
|
||||
var selectDepartment = $('#'+ name).val().split(',');
|
||||
});
|
||||
}
|
||||
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
|
||||
// 初始化内容
|
||||
function initData() {
|
||||
var loadLayerIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/${lowerTableName}/get${lowerTableName}byid/{${firstLowerTableName}Id}', [${firstLowerTableName}Id]), {}, null, function(code, data) {
|
||||
var dataFormData = {};
|
||||
for(var i in data) {
|
||||
dataFormData[i] = data[i] +'';
|
||||
}
|
||||
form.val('dataForm', dataFormData);
|
||||
form.render(null, 'dataForm');
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
<#if field.formFieldValue == "date">
|
||||
init${field.firstUpperPropertyName}Date();
|
||||
<#elseif field.formFieldValue == "datetime">
|
||||
init${field.firstUpperPropertyName}DateTime();
|
||||
<#elseif field.formFieldValue == "richText">
|
||||
init${field.firstUpperPropertyName}RichText(data['${field.propertyName}']);
|
||||
<#elseif field.formFieldValue == "select">
|
||||
init${field.firstUpperPropertyName}Select(data['${field.propertyName}']);
|
||||
<#elseif field.formFieldValue == "checkbox">
|
||||
init${field.firstUpperPropertyName}Checkbox(data['${field.propertyName}']);
|
||||
<#elseif field.formFieldValue == "radio">
|
||||
init${field.firstUpperPropertyName}Radio(data['${field.propertyName}']);
|
||||
<#elseif field.formFieldValue == "file" || field.formFieldValue == "image" || field.formFieldValue == "video" || field.formFieldValue == "audio">
|
||||
init${field.firstUpperPropertyName}UploadFile();
|
||||
<#elseif field.formFieldValue == "selectUser">
|
||||
init${field.firstUpperPropertyName}SelectUser();
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
}
|
||||
initData();
|
||||
|
||||
// 提交表单
|
||||
form.on('submit(submitForm)', function(formData) {
|
||||
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
<#if field.formFieldValue == "checkbox">
|
||||
formData.field['${field.propertyName}'] = top.restAjax.checkBoxToString(formData.field, '${field.propertyName}');
|
||||
<#elseif field.formFieldValue == "richText">
|
||||
formData.field['${field.propertyName}'] = wangEditorObj['${field.propertyName}'].txt.html();
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
top.restAjax.put(top.restAjax.path('api/${lowerTableName}/update${lowerTableName}/{${firstLowerTableName}Id}', [${firstLowerTableName}Id]), formData.field, null, function(code, data) {
|
||||
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
shade: 0.3,
|
||||
yes: function(index) {
|
||||
top.dialog.close(index);
|
||||
window.location.reload();
|
||||
},
|
||||
btn2: function() {
|
||||
closeBox();
|
||||
}
|
||||
});
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.close').on('click', function() {
|
||||
closeBox();
|
||||
});
|
||||
|
||||
// 校验
|
||||
form.verify({
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
<#if field.formFieldValue == "string">
|
||||
<#if field.verifyType??>
|
||||
<#if field.verifyType == "custom">
|
||||
${field.propertyName}CustomVerify: function(value, item){
|
||||
if(!new RegExp('${field.verifyRegular}').test(value)){
|
||||
return '${field.columnComment}格式错误';
|
||||
}
|
||||
}
|
||||
</#if>
|
||||
</#if>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,7 +1,7 @@
|
||||
package ${codePackage}.pojo.vos.${lowerTableName};
|
||||
|
||||
import com.cm.common.annotation.CheckEmptyAnnotation;
|
||||
import com.cm.common.annotation.CheckNumberAnnotation;
|
||||
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||
import ink.wgink.annotation.CheckNumberAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ${codePackage}.pojo.vos.${lowerTableName};
|
||||
|
||||
import com.cm.common.annotation.CheckEmptyAnnotation;
|
||||
import com.cm.common.annotation.CheckNumberAnnotation;
|
||||
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||
import ink.wgink.annotation.CheckNumberAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ${codePackage}.pojo.vos.${lowerTableName};
|
||||
|
||||
import com.cm.common.annotation.CheckEmptyAnnotation;
|
||||
import com.cm.common.annotation.CheckNumberAnnotation;
|
||||
import ink.wgink.annotation.CheckEmptyAnnotation;
|
||||
import ink.wgink.annotation.CheckNumberAnnotation;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package ${codePackage}.service.${lowerTableName};
|
||||
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.SuccessResultList;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ${codePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO;
|
||||
import ${codePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO;
|
||||
import ${codePackage}.pojo.bos.${lowerTableName}.${firstUpperTableName}BO;
|
@ -1,11 +1,11 @@
|
||||
package ${codePackage}.service.${lowerTableName}.impl;
|
||||
|
||||
import com.cm.common.base.AbstractService;
|
||||
import com.cm.common.pojo.ListPage;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import com.cm.common.result.SuccessResultList;
|
||||
import com.cm.common.utils.HashMapUtil;
|
||||
import com.cm.common.utils.UUIDUtil;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.pojo.utils.HashMapUtil;
|
||||
import ink.wgink.util.UUIDUtil;
|
||||
import ${codePackage}.dao.${lowerTableName}.I${firstUpperTableName}Dao;
|
||||
import ${codePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO;
|
||||
import ${codePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO;
|
||||
@ -28,7 +28,7 @@ import java.util.*;
|
||||
* @Version: ${version}
|
||||
**/
|
||||
@Service
|
||||
public class ${firstUpperTableName}ServiceImpl extends AbstractService implements I${firstUpperTableName}Service {
|
||||
public class ${firstUpperTableName}ServiceImpl extends DefaultBaseService implements I${firstUpperTableName}Service {
|
||||
|
||||
@Autowired
|
||||
private I${firstUpperTableName}Dao ${firstLowerTableName}Dao;
|
Loading…
Reference in New Issue
Block a user