各种优化修复
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package com.jeesite.modules.test.dao;
|
||||
|
||||
import com.jeesite.common.dao.CrudDao;
|
||||
import com.jeesite.common.mybatis.annotation.MyBatisDao;
|
||||
import com.jeesite.modules.test.entity.TestDataChild;
|
||||
|
||||
/**
|
||||
* 测试数据DAO接口
|
||||
* @author ThinkGem
|
||||
* @version 2018-01-30
|
||||
*/
|
||||
@MyBatisDao
|
||||
public interface TestDataChildDao extends CrudDao<TestDataChild> {
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import com.jeesite.modules.test.entity.TestData;
|
||||
/**
|
||||
* 测试数据DAO接口
|
||||
* @author ThinkGem
|
||||
* @version 2018-01-28
|
||||
* @version 2018-01-30
|
||||
*/
|
||||
@MyBatisDao
|
||||
public interface TestDataDao extends CrudDao<TestData> {
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.jeesite.modules.sys.entity.User;
|
||||
import com.jeesite.modules.sys.entity.Office;
|
||||
import com.jeesite.common.entity.Extend;
|
||||
import java.util.List;
|
||||
import com.jeesite.common.collect.ListUtils;
|
||||
|
||||
import com.jeesite.common.entity.DataEntity;
|
||||
import com.jeesite.common.mybatis.annotation.Column;
|
||||
@@ -20,7 +22,7 @@ import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||
/**
|
||||
* 测试数据Entity
|
||||
* @author ThinkGem
|
||||
* @version 2018-01-28
|
||||
* @version 2018-01-30
|
||||
*/
|
||||
@Table(name="test_data", alias="a", columns={
|
||||
@Column(name="id", attrName="id", label="编号", isPK=true),
|
||||
@@ -67,6 +69,7 @@ public class TestData extends DataEntity<TestData> {
|
||||
private String testAreaCode; // 区域选择
|
||||
private String testAreaName; // 区域名称
|
||||
private Extend extend; // 扩展字段
|
||||
private List<TestDataChild> testDataChildList = ListUtils.newArrayList(); // 子表列表
|
||||
|
||||
public TestData() {
|
||||
this(null);
|
||||
@@ -222,4 +225,12 @@ public class TestData extends DataEntity<TestData> {
|
||||
sqlMap.getWhere().and("test_datetime", QueryType.LTE, testDatetime);
|
||||
}
|
||||
|
||||
public List<TestDataChild> getTestDataChildList() {
|
||||
return testDataChildList;
|
||||
}
|
||||
|
||||
public void setTestDataChildList(List<TestDataChild> testDataChildList) {
|
||||
this.testDataChildList = testDataChildList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package com.jeesite.modules.test.entity;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import java.util.Date;
|
||||
import com.jeesite.common.mybatis.annotation.JoinTable;
|
||||
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import com.jeesite.common.entity.DataEntity;
|
||||
import com.jeesite.common.mybatis.annotation.Column;
|
||||
import com.jeesite.common.mybatis.annotation.Table;
|
||||
import com.jeesite.common.mybatis.mapper.query.QueryType;
|
||||
|
||||
/**
|
||||
* 测试数据Entity
|
||||
* @author ThinkGem
|
||||
* @version 2018-01-30
|
||||
*/
|
||||
@Table(name="test_data_child", alias="a", columns={
|
||||
@Column(name="id", attrName="id", label="编号", isPK=true),
|
||||
@Column(name="test_sort", attrName="testSort", label="排序号"),
|
||||
@Column(name="test_data_id", attrName="testData.id", label="父表主键"),
|
||||
@Column(name="test_input", attrName="testInput", label="单行文本"),
|
||||
@Column(name="test_textarea", attrName="testTextarea", label="多行文本"),
|
||||
@Column(name="test_select", attrName="testSelect", label="下拉框"),
|
||||
@Column(name="test_select_multiple", attrName="testSelectMultiple", label="下拉多选"),
|
||||
@Column(name="test_radio", attrName="testRadio", label="单选框"),
|
||||
@Column(name="test_checkbox", attrName="testCheckbox", label="复选框"),
|
||||
@Column(name="test_date", attrName="testDate", label="日期选择"),
|
||||
@Column(name="test_datetime", attrName="testDatetime", label="日期时间"),
|
||||
@Column(name="test_user_code", attrName="testUserCode", label="用户选择"),
|
||||
@Column(name="test_office_code", attrName="testOfficeCode", label="部门选择"),
|
||||
@Column(name="test_area_code", attrName="testAreaCode", label="区域选择"),
|
||||
@Column(name="test_area_name", attrName="testAreaName", label="区域名称", queryType=QueryType.LIKE),
|
||||
}, orderBy="a.id ASC"
|
||||
)
|
||||
public class TestDataChild extends DataEntity<TestDataChild> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Integer testSort; // 排序号
|
||||
private TestData testData; // 父表主键 父类
|
||||
private String testInput; // 单行文本
|
||||
private String testTextarea; // 多行文本
|
||||
private String testSelect; // 下拉框
|
||||
private String testSelectMultiple; // 下拉多选
|
||||
private String testRadio; // 单选框
|
||||
private String testCheckbox; // 复选框
|
||||
private Date testDate; // 日期选择
|
||||
private Date testDatetime; // 日期时间
|
||||
private String testUserCode; // 用户选择
|
||||
private String testOfficeCode; // 部门选择
|
||||
private String testAreaCode; // 区域选择
|
||||
private String testAreaName; // 区域名称
|
||||
|
||||
public TestDataChild() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
|
||||
public TestDataChild(TestData testData){
|
||||
this.testData = testData;
|
||||
}
|
||||
|
||||
public Integer getTestSort() {
|
||||
return testSort;
|
||||
}
|
||||
|
||||
public void setTestSort(Integer testSort) {
|
||||
this.testSort = testSort;
|
||||
}
|
||||
|
||||
@Length(min=0, max=64, message="父表主键长度不能超过 64 个字符")
|
||||
public TestData getTestData() {
|
||||
return testData;
|
||||
}
|
||||
|
||||
public void setTestData(TestData testData) {
|
||||
this.testData = testData;
|
||||
}
|
||||
|
||||
@Length(min=0, max=200, message="单行文本长度不能超过 200 个字符")
|
||||
public String getTestInput() {
|
||||
return testInput;
|
||||
}
|
||||
|
||||
public void setTestInput(String testInput) {
|
||||
this.testInput = testInput;
|
||||
}
|
||||
|
||||
@Length(min=0, max=200, message="多行文本长度不能超过 200 个字符")
|
||||
public String getTestTextarea() {
|
||||
return testTextarea;
|
||||
}
|
||||
|
||||
public void setTestTextarea(String testTextarea) {
|
||||
this.testTextarea = testTextarea;
|
||||
}
|
||||
|
||||
@Length(min=0, max=10, message="下拉框长度不能超过 10 个字符")
|
||||
public String getTestSelect() {
|
||||
return testSelect;
|
||||
}
|
||||
|
||||
public void setTestSelect(String testSelect) {
|
||||
this.testSelect = testSelect;
|
||||
}
|
||||
|
||||
@Length(min=0, max=200, message="下拉多选长度不能超过 200 个字符")
|
||||
public String getTestSelectMultiple() {
|
||||
return testSelectMultiple;
|
||||
}
|
||||
|
||||
public void setTestSelectMultiple(String testSelectMultiple) {
|
||||
this.testSelectMultiple = testSelectMultiple;
|
||||
}
|
||||
|
||||
@Length(min=0, max=10, message="单选框长度不能超过 10 个字符")
|
||||
public String getTestRadio() {
|
||||
return testRadio;
|
||||
}
|
||||
|
||||
public void setTestRadio(String testRadio) {
|
||||
this.testRadio = testRadio;
|
||||
}
|
||||
|
||||
@Length(min=0, max=200, message="复选框长度不能超过 200 个字符")
|
||||
public String getTestCheckbox() {
|
||||
return testCheckbox;
|
||||
}
|
||||
|
||||
public void setTestCheckbox(String testCheckbox) {
|
||||
this.testCheckbox = testCheckbox;
|
||||
}
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
public Date getTestDate() {
|
||||
return testDate;
|
||||
}
|
||||
|
||||
public void setTestDate(Date testDate) {
|
||||
this.testDate = testDate;
|
||||
}
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
public Date getTestDatetime() {
|
||||
return testDatetime;
|
||||
}
|
||||
|
||||
public void setTestDatetime(Date testDatetime) {
|
||||
this.testDatetime = testDatetime;
|
||||
}
|
||||
|
||||
@Length(min=0, max=64, message="用户选择长度不能超过 64 个字符")
|
||||
public String getTestUserCode() {
|
||||
return testUserCode;
|
||||
}
|
||||
|
||||
public void setTestUserCode(String testUserCode) {
|
||||
this.testUserCode = testUserCode;
|
||||
}
|
||||
|
||||
@Length(min=0, max=64, message="部门选择长度不能超过 64 个字符")
|
||||
public String getTestOfficeCode() {
|
||||
return testOfficeCode;
|
||||
}
|
||||
|
||||
public void setTestOfficeCode(String testOfficeCode) {
|
||||
this.testOfficeCode = testOfficeCode;
|
||||
}
|
||||
|
||||
@Length(min=0, max=64, message="区域选择长度不能超过 64 个字符")
|
||||
public String getTestAreaCode() {
|
||||
return testAreaCode;
|
||||
}
|
||||
|
||||
public void setTestAreaCode(String testAreaCode) {
|
||||
this.testAreaCode = testAreaCode;
|
||||
}
|
||||
|
||||
@Length(min=0, max=100, message="区域名称长度不能超过 100 个字符")
|
||||
public String getTestAreaName() {
|
||||
return testAreaName;
|
||||
}
|
||||
|
||||
public void setTestAreaName(String testAreaName) {
|
||||
this.testAreaName = testAreaName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ package com.jeesite.modules.test.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -13,23 +14,34 @@ import com.jeesite.common.service.CrudService;
|
||||
import com.jeesite.modules.test.entity.TestData;
|
||||
import com.jeesite.modules.test.dao.TestDataDao;
|
||||
import com.jeesite.modules.file.utils.FileUploadUtils;
|
||||
import com.jeesite.modules.test.entity.TestDataChild;
|
||||
import com.jeesite.modules.test.dao.TestDataChildDao;
|
||||
|
||||
/**
|
||||
* 测试数据Service
|
||||
* @author ThinkGem
|
||||
* @version 2018-01-28
|
||||
* @version 2018-01-30
|
||||
*/
|
||||
@Service
|
||||
@Transactional(readOnly=true)
|
||||
public class TestDataService extends CrudService<TestDataDao, TestData> {
|
||||
|
||||
@Autowired
|
||||
private TestDataChildDao testDataChildDao;
|
||||
|
||||
/**
|
||||
* 获取单条数据
|
||||
* @param testData
|
||||
* @return
|
||||
*/
|
||||
public TestData get(TestData testData) {
|
||||
return super.get(testData);
|
||||
TestData entity = super.get(testData);
|
||||
if (entity != null){
|
||||
TestDataChild testDataChild = new TestDataChild(entity);
|
||||
testDataChild.setStatus(TestDataChild.STATUS_NORMAL);
|
||||
entity.setTestDataChildList(testDataChildDao.findList(testDataChild));
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,6 +65,21 @@ public class TestDataService extends CrudService<TestDataDao, TestData> {
|
||||
FileUploadUtils.saveFileUpload(testData.getId(), "testData_image");
|
||||
// 保存上传附件
|
||||
FileUploadUtils.saveFileUpload(testData.getId(), "testData_file");
|
||||
// 保存 TestData子表
|
||||
for (TestDataChild testDataChild : testData.getTestDataChildList()){
|
||||
if (!TestDataChild.STATUS_DELETE.equals(testDataChild.getStatus())){
|
||||
testDataChild.setTestData(testData);
|
||||
if (testDataChild.getIsNewRecord()){
|
||||
testDataChild.preInsert();
|
||||
testDataChildDao.insert(testDataChild);
|
||||
}else{
|
||||
testDataChild.preUpdate();
|
||||
testDataChildDao.update(testDataChild);
|
||||
}
|
||||
}else{
|
||||
testDataChildDao.delete(testDataChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,6 +98,9 @@ public class TestDataService extends CrudService<TestDataDao, TestData> {
|
||||
@Transactional(readOnly=false)
|
||||
public void delete(TestData testData) {
|
||||
super.delete(testData);
|
||||
TestDataChild testDataChild = new TestDataChild();
|
||||
testDataChild.setTestData(testData);
|
||||
testDataChildDao.delete(testDataChild);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import com.jeesite.modules.test.service.TestDataService;
|
||||
/**
|
||||
* 测试数据Controller
|
||||
* @author ThinkGem
|
||||
* @version 2018-01-28
|
||||
* @version 2018-01-30
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/test/testData")
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.jeesite.modules.test.dao.TestDataChildDao">
|
||||
|
||||
<!-- 查询数据
|
||||
<select id="findList" resultType="TestDataChild">
|
||||
SELECT ${sqlMap.column.toSql()}
|
||||
FROM ${sqlMap.table.toSql()}
|
||||
<where>
|
||||
${sqlMap.where.toSql()}
|
||||
</where>
|
||||
ORDER BY ${sqlMap.order.toSql()}
|
||||
</select> -->
|
||||
|
||||
</mapper>
|
||||
@@ -1,4 +1,4 @@
|
||||
<% layout('/layouts/default.html', {title: '数据管理', libs: ['validate','fileupload']}){ %>
|
||||
<% layout('/layouts/default.html', {title: '数据管理', libs: ['validate','fileupload','dataGrid']}){ %>
|
||||
<div class="main-content">
|
||||
<div class="box box-main">
|
||||
<div class="box-header with-border">
|
||||
@@ -371,6 +371,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h4 class="form-unit">测试数据子表</h4>
|
||||
<div class="ml10 mr10">
|
||||
<table id="testDataChildDataGrid"></table>
|
||||
<% if (hasPermi('test:testData:edit')){ %>
|
||||
<a href="#" id="testDataChildDataGridAddRowBtn" class="btn btn-primary btn-sm mt10 mb10"><i class="fa fa-plus"></i> 增行</a>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<div class="row">
|
||||
@@ -386,7 +393,57 @@
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<script>
|
||||
<script>//初始化测试数据子表DataGrid对象
|
||||
$("#testDataChildDataGrid").dataGrid({
|
||||
|
||||
data: ${toJson(testData.testDataChildList)},
|
||||
datatype: "local", // 设置本地数据
|
||||
autoGridHeight: function(){return 'auto'}, // 设置自动高度
|
||||
|
||||
// 设置数据表格列
|
||||
columnModel: [
|
||||
{header:'状态', name:'status', editable:true, hidden:false},
|
||||
{header:'主键', name:'id', editable:true, hidden:false},
|
||||
{header:'排序号', name:'testSort', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'10', 'class':'form-control digits'}},
|
||||
{header:'父表主键', name:'testData.id', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'64', 'class':'form-control'}},
|
||||
{header:'单行文本', name:'testInput', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'}},
|
||||
{header:'多行文本', name:'testTextarea', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'}},
|
||||
{header:'下拉框', name:'testSelect', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'10', 'class':'form-control'}},
|
||||
{header:'下拉多选', name:'testSelectMultiple', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'}},
|
||||
{header:'单选框', name:'testRadio', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'10', 'class':'form-control'}},
|
||||
{header:'复选框', name:'testCheckbox', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'}},
|
||||
{header:'日期选择', name:'testDate', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'6', 'class':'form-control'}},
|
||||
{header:'日期时间', name:'testDatetime', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'6', 'class':'form-control'}},
|
||||
{header:'用户选择', name:'testUserCode', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'64', 'class':'form-control'}},
|
||||
{header:'部门选择', name:'testOfficeCode', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'64', 'class':'form-control'}},
|
||||
{header:'区域选择', name:'testAreaCode', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'64', 'class':'form-control'}},
|
||||
{header:'区域名称', name:'testAreaName', width:150, editable:true, edittype:'text', editoptions:{'maxlength':'100', 'class':'form-control'}}, {header:'操作', name:'actions', width:80, sortable:false, fixed:true, formatter: function(val, obj, row, act){
|
||||
var actions = [];
|
||||
if (val == 'new'){
|
||||
actions.push('<a href="#" onclick="js.confirm(\'你确认要删除这条数据吗?\', function(){$(\'#testDataChildDataGrid\').dataGrid(\'delRowData\',\''+obj.rowId+'\')});return false;"><i class="fa fa-trash-o"></i></a> ');
|
||||
}else{
|
||||
actions.push('<a href="#" onclick="js.confirm(\'你确认要删除这条数据吗?\', function(){$(\'#testDataChildDataGrid\').dataGrid(\'setRowData\',\''+obj.rowId+'\',null,{display:\'none\'})});$(\'#'+obj.rowId+'_status\').val(\''+Global.STATUS_DELETE+'\');return false;"><i class="fa fa-trash-o"></i></a> ');
|
||||
}
|
||||
return actions.join('');
|
||||
}, editoptions: {defaultValue: 'new'}}
|
||||
],
|
||||
|
||||
// 编辑表格参数
|
||||
editGrid: true, // 是否是编辑表格
|
||||
editGridInitRowNum: 1, // 编辑表格的初始化新增行数
|
||||
editGridAddRowBtn: $('#testDataChildDataGridAddRowBtn'), // 子表增行按钮
|
||||
editGridAddRowInitData: {id: '', status: Global.STATUS_NORMAL}, // 新增行的时候初始化的数据
|
||||
|
||||
// 编辑表格的提交数据参数
|
||||
editGridInputFormListName: 'testDataChildList', // 提交的数据列表名
|
||||
editGridInputFormListAttrs: 'status,id,testSort,testData.id,testInput,testTextarea,testSelect,testSelectMultiple,testRadio,testCheckbox,testDate,testDatetime,testUserCode,testOfficeCode,testAreaCode,testAreaName,', // 提交数据列表的属性字段
|
||||
|
||||
// 加载成功后执行事件
|
||||
ajaxSuccess: function(data){
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$("#inputForm").validate({
|
||||
submitHandler: function(form){
|
||||
js.ajaxSubmitForm($(form), function(data){
|
||||
|
||||
@@ -21,17 +21,17 @@ public class InitCoreData extends com.jeesite.modules.sys.db.InitCoreData {
|
||||
@Test
|
||||
public void initCoreData() throws Exception{
|
||||
initLog();
|
||||
// initConfig();
|
||||
// initModule();
|
||||
// initDict();
|
||||
// initRole();
|
||||
// initMenu();
|
||||
// initUser();
|
||||
// initArea();
|
||||
// initOffice();
|
||||
// initCompany();
|
||||
// initPost();
|
||||
// initEmpUser();
|
||||
initConfig();
|
||||
initModule();
|
||||
initDict();
|
||||
initRole();
|
||||
initMenu();
|
||||
initUser();
|
||||
initArea();
|
||||
initOffice();
|
||||
initCompany();
|
||||
initPost();
|
||||
initEmpUser();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user