1、升级优化

master
wangbing 5 years ago
parent 7c481a8b3e
commit cf8d1fa9b5

@ -145,6 +145,15 @@ public class SpringBootCallable implements Callable {
System.out.println("生成模块:Response");
generateResponse(new File(modulePath.getAbsolutePath(), "rsp"), module, dataBase, option);
}
{
Module module = new Module();
module.setModuleName("system");
module.setProjectAuthor(project.getProjectAuthor());
module.setProjectBasePackage(project.getProjectBasePackage());
module.setProjectName(project.getProjectName());
generateSystemModule(new File(moduleDir.getAbsolutePath(), "system"), module, dataBase, option);
}
}
//frame
@ -223,6 +232,8 @@ public class SpringBootCallable implements Callable {
freeMarkerManager.outputTemp(new File(control.getAbsolutePath(), "Header.java"), option + "/java/action/control/Header.java", ctx);
freeMarkerManager.outputTemp(new File(system.getAbsolutePath(), "AuthAjax.java"), option + "/java/action/ajax/system/AuthAjax.java", ctx);
freeMarkerManager.outputTemp(new File(system.getAbsolutePath(), "DictAjax.java"), option + "/java/action/ajax/system/DictAjax.java", ctx);
freeMarkerManager.outputTemp(new File(system.getAbsolutePath(), "DictItemAjax.java"), option + "/java/action/ajax/system/DictItemAjax.java", ctx);
for (Module module : project.getModules()) {
@ -472,6 +483,63 @@ public class SpringBootCallable implements Callable {
}
}
public void generateSystemModule(File root, Module md, DataBase dataBase, String option) {
File ent = new File(root.getAbsolutePath(), "ent");
ent.mkdirs();
File mpr = new File(root.getAbsolutePath(), "mpr");
mpr.mkdirs();
File mgr = new File(root.getAbsolutePath(), "mgr");
mgr.mkdirs();
File req = new File(root.getAbsolutePath(), "req");
req.mkdirs();
File rsp = new File(root.getAbsolutePath(), "rsp");
rsp.mkdirs();
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("basePackage", md.getProjectBasePackage());
ctx.put("moduleName", md.getModuleName());
ctx.put("author", md.getProjectAuthor());
ctx.put("date", new Date());
freeMarkerManager.outputTemp(new File(ent.getAbsolutePath(),"Dict.java"), option + "/java/module/system/ent/Dict.java", ctx);
freeMarkerManager.outputTemp(new File(ent.getAbsolutePath(),"DictItem.java"), option + "/java/module/system/ent/DictItem.java", ctx);
freeMarkerManager.outputTemp(new File(mgr.getAbsolutePath(),"DictItemManager.java"), option + "/java/module/system/mgr/DictItemManager.java", ctx);
freeMarkerManager.outputTemp(new File(mgr.getAbsolutePath(),"DictItemManagerImpl.java"), option + "/java/module/system/mgr/DictItemManagerImpl.java", ctx);
freeMarkerManager.outputTemp(new File(mgr.getAbsolutePath(),"DictManager.java"), option + "/java/module/system/mgr/DictManager.java", ctx);
freeMarkerManager.outputTemp(new File(mgr.getAbsolutePath(),"DictManagerImpl.java"), option + "/java/module/system/mgr/DictManagerImpl.java", ctx);
freeMarkerManager.outputTemp(new File(mpr.getAbsolutePath(),"DictItemMapper.java"), option + "/java/module/system/mpr/DictItemMapper.java", ctx);
freeMarkerManager.outputTemp(new File(mpr.getAbsolutePath(),"DictItemMapper.xml"), option + "/java/module/system/mpr/DictItemMapper.xml", ctx);
freeMarkerManager.outputTemp(new File(mpr.getAbsolutePath(),"DictMapper.java"), option + "/java/module/system/mpr/DictMapper.java", ctx);
freeMarkerManager.outputTemp(new File(mpr.getAbsolutePath(),"DictMapper.xml"), option + "/java/module/system/mpr/DictMapper.xml", ctx);
freeMarkerManager.outputTemp(new File(req.getAbsolutePath(),"DictCreateRequest.java"), option + "/java/module/system/req/DictCreateRequest.java", ctx);
freeMarkerManager.outputTemp(new File(req.getAbsolutePath(),"DictDeleteRequest.java"), option + "/java/module/system/req/DictDeleteRequest.java", ctx);
freeMarkerManager.outputTemp(new File(req.getAbsolutePath(),"DictFindRequest.java"), option + "/java/module/system/req/DictFindRequest.java", ctx);
freeMarkerManager.outputTemp(new File(req.getAbsolutePath(),"DictGetRequest.java"), option + "/java/module/system/req/DictGetRequest.java", ctx);
freeMarkerManager.outputTemp(new File(req.getAbsolutePath(),"DictItemCreateRequest.java"), option + "/java/module/system/req/DictItemCreateRequest.java", ctx);
freeMarkerManager.outputTemp(new File(req.getAbsolutePath(),"DictItemDeleteRequest.java"), option + "/java/module/system/req/DictItemDeleteRequest.java", ctx);
freeMarkerManager.outputTemp(new File(req.getAbsolutePath(),"DictItemFindRequest.java"), option + "/java/module/system/req/DictItemFindRequest.java", ctx);
freeMarkerManager.outputTemp(new File(req.getAbsolutePath(),"DictItemGetRequest.java"), option + "/java/module/system/req/DictItemGetRequest.java", ctx);
freeMarkerManager.outputTemp(new File(req.getAbsolutePath(),"DictItemUpdateRequest.java"), option + "/java/module/system/req/DictItemUpdateRequest.java", ctx);
freeMarkerManager.outputTemp(new File(req.getAbsolutePath(),"DictLoadRequest.java"), option + "/java/module/system/req/DictLoadRequest.java", ctx);
freeMarkerManager.outputTemp(new File(req.getAbsolutePath(),"DictUpdateRequest.java"), option + "/java/module/system/req/DictUpdateRequest.java", ctx);
freeMarkerManager.outputTemp(new File(rsp.getAbsolutePath(),"DictCreateResponse.java"), option + "/java/module/system/rsp/DictCreateResponse.java", ctx);
freeMarkerManager.outputTemp(new File(rsp.getAbsolutePath(),"DictDeleteResponse.java"), option + "/java/module/system/rsp/DictDeleteResponse.java", ctx);
freeMarkerManager.outputTemp(new File(rsp.getAbsolutePath(),"DictFindResponse.java"), option + "/java/module/system/rsp/DictFindResponse.java", ctx);
freeMarkerManager.outputTemp(new File(rsp.getAbsolutePath(),"DictGetResponse.java"), option + "/java/module/system/rsp/DictGetResponse.java", ctx);
freeMarkerManager.outputTemp(new File(rsp.getAbsolutePath(),"DictItemCreateResponse.java"), option + "/java/module/system/rsp/DictItemCreateResponse.java", ctx);
freeMarkerManager.outputTemp(new File(rsp.getAbsolutePath(),"DictItemDeleteResponse.java"), option + "/java/module/system/rsp/DictItemDeleteResponse.java", ctx);
freeMarkerManager.outputTemp(new File(rsp.getAbsolutePath(),"DictItemFindResponse.java"), option + "/java/module/system/rsp/DictItemFindResponse.java", ctx);
freeMarkerManager.outputTemp(new File(rsp.getAbsolutePath(),"DictItemGetResponse.java"), option + "/java/module/system/rsp/DictItemGetResponse.java", ctx);
freeMarkerManager.outputTemp(new File(rsp.getAbsolutePath(),"DictItemUpdateResponse.java"), option + "/java/module/system/rsp/DictItemUpdateResponse.java", ctx);
freeMarkerManager.outputTemp(new File(rsp.getAbsolutePath(),"DictLoadResponse.java"), option + "/java/module/system/rsp/DictLoadResponse.java", ctx);
freeMarkerManager.outputTemp(new File(rsp.getAbsolutePath(),"DictUpdateResponse.java"), option + "/java/module/system/rsp/DictUpdateResponse.java", ctx);
}
/**
* frame
*
@ -609,11 +677,20 @@ public class SpringBootCallable implements Callable {
for (Table table : module.getTables()) {
ctx.put("table", table);
freeMarkerManager.outputTemp(new File(tableDir.getAbsolutePath(), table.getTableName() + ".sql"), option + "/resources/table.ftl", ctx);
freeMarkerManager.outputTemp(new File(tableDir.getAbsolutePath(), table.getTableName() + ".sql"), option + "/resources/dbtool/table.ftl", ctx);
}
freeMarkerManager.outputTemp(new File(tableDir.getAbsolutePath(), "ALL_TABLE.sql"), option + "/resources/dbtool/tableAll.ftl", ctx);
}
freeMarkerManager.outputTemp(new File(tableDir.getAbsolutePath(), "ALL_TABLE.sql"), option + "/resources/tableAll.ftl", ctx);
{
File system = new File(dbtool.getAbsolutePath(), "system");
system.mkdirs();
freeMarkerManager.outputTemp(new File(system.getAbsolutePath(), "DICT.sql"), option + "/resources/dbtool/system/DICT.sql", ctx);
freeMarkerManager.outputTemp(new File(system.getAbsolutePath(), "DICT_ITEM.sql"), option + "/resources/dbtool/system/DICT_ITEM.sql", ctx);
}
}
public void generateTestResources(File root, Project project, DataBase dataBase, String option) {
@ -715,6 +792,8 @@ public class SpringBootCallable implements Callable {
layout.mkdirs();
File screen = new File(templates.getAbsolutePath(), "screen");
screen.mkdirs();
File system = new File(screen.getAbsolutePath(), "system");
system.mkdirs();
Tool.outputResource(option + "/resources/templates/control/nav.ftl", new File(control.getAbsolutePath(), "nav.ftl"));
Tool.outputResource(option + "/resources/templates/control/header.ftl", new File(control.getAbsolutePath(), "header.ftl"));
// Tool.outputResource(option + "/resources/templates/control/footer.ftl", new File(control.getAbsolutePath(), "footer.ftl"));
@ -729,6 +808,9 @@ public class SpringBootCallable implements Callable {
Tool.outputResource(option + "/resources/templates/404.ftl", new File(templates.getAbsolutePath(), "404.ftl"));
Tool.outputResource(option + "/resources/templates/500.ftl", new File(templates.getAbsolutePath(), "500.ftl"));
Tool.outputResource(option + "/resources/templates/screen/module/system/dict.ftl", new File(system.getAbsolutePath(), "dict.ftl"));
Tool.outputResource(option + "/resources/templates/screen/module/system/dictItem.ftl", new File(system.getAbsolutePath(), "dictItem.ftl"));
{
HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("basePackage", project.getProjectBasePackage());

@ -254,7 +254,7 @@ public class GlobalController implements ErrorController {
BaseResponse baseResponse = null;
try {
Object ajax = LocalData.getApplicationContext().getBean(ActionConfig.AJAX_PREFIX + module + "." + target);
Object ajax = LocalData.getApplicationContext().getBean(ActionConfig.AJAX_PREFIX + module + "/" + target);
Class ajaxClass = ajax.getClass();
Method methodC = ajaxClass.getMethod(method, String.class);

@ -2,6 +2,7 @@ package ${basePackage}.config;
import ${basePackage}.frame.base.Control;
import ${basePackage}.frame.base.Screen;
import ${basePackage}.frame.utils.LogUtil;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@ -15,6 +16,8 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.TypeFilter;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* ScreenControl
@ -36,10 +39,14 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
String aPackage = this.getClass().getPackage().getName();
int i = registryScreen("${basePackage}.action.screen", beanDefinitionRegistry);
int i1 = registryControl("${basePackage}.action.control", beanDefinitionRegistry);
int i2 = registryAjax("${basePackage}.action.ajax", beanDefinitionRegistry);
System.out.println();
Pattern compile = Pattern.compile("(.*)\\.config");
Matcher matcher = compile.matcher(aPackage);
if (matcher.find()) {
String basePackage = matcher.group(1);
registryScreen(basePackage + ".action.screen", beanDefinitionRegistry);
registryControl(basePackage + ".action.control", beanDefinitionRegistry);
registryAjax(basePackage + ".action.ajax", beanDefinitionRegistry);
}
}
@Override
@ -62,8 +69,12 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
@Override
public String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry beanDefinitionRegistry) {
String beanClassName = beanDefinition.getBeanClassName();
String s = beanClassName.replaceAll(basePackage+ ".", SCREEN_PREFIX);
return s.toLowerCase();
String beamName = beanClassName.replaceAll(basePackage + ".", SCREEN_PREFIX).replaceAll("\\.","/");
char[] chars = beamName.toCharArray();
if (chars[8] >= 65 && chars[8] <= 90) chars[8] += 32;
beamName = String.valueOf(chars);
LogUtil.i("registry screen " + beamName);
return beamName;
}
});
return classPathBeanDefinitionScanner.scan(basePackage);
@ -84,8 +95,9 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
@Override
public String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry beanDefinitionRegistry) {
String beanClassName = beanDefinition.getBeanClassName();
String s = beanClassName.replaceAll(basePackage+ ".", CONTROL_PREFIX);
return s.toLowerCase();
String beamName = beanClassName.replaceAll(basePackage + ".", CONTROL_PREFIX).replaceAll("\\.","/");
LogUtil.i("registry control " + beamName);
return beamName;
}
});
return classPathBeanDefinitionScanner.scan(basePackage);
@ -106,8 +118,9 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
if (beanClassName != null && beanClassName.endsWith("Ajax")) {
beanClassName = beanClassName.substring(0, beanClassName.length() - 4);
}
String s = beanClassName.replaceAll(basePackage+ ".", AJAX_PREFIX);
return s.toLowerCase();
String beamName = beanClassName.replaceAll(basePackage + ".", AJAX_PREFIX).replaceAll("\\.","/");
LogUtil.i("registry ajax " + beamName);
return beamName;
}
});
return classPathBeanDefinitionScanner.scan(basePackage);

@ -0,0 +1,24 @@
/*
Target : MYSQL
Author
Date: 2019-10-08
*/
-- ----------------------------
-- Table structure for DICT - 字典
-- ----------------------------
CREATE TABLE `SYS_DICT` (
`ID` BIGINT(20) NOT NULL COMMENT '主键',
`DICT_NAME` VARCHAR(50) NOT NULL COMMENT '字典名称',
`DICT_CODE` VARCHAR(50) NOT NULL COMMENT '字典代码',
`VERSION` VARCHAR(50) NOT NULL COMMENT '字典版本号',
`VALID` TINYINT(1) NOT NULL COMMENT '是否有效',
`ROW_VERSION` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '行版本',
`IS_DELETED` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已删除',
`CREATE_BY` BIGINT(20) NOT NULL COMMENT '创建用户',
`CREATE_TIME` DATETIME NOT NULL COMMENT '创建时间',
`LAST_UPDATE_BY` BIGINT(20) DEFAULT NULL COMMENT '最后更新用户',
`LAST_UPDATE_TIME` DATETIME DEFAULT NULL COMMENT '最后更新时间',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='字典';

@ -0,0 +1,25 @@
/*
Target : MYSQL
Author
Date: 2019-10-08
*/
-- ----------------------------
-- Table structure for DICT_ITEM - 字典项
-- ----------------------------
CREATE TABLE `SYS_DICT_ITEM` (
`ID` BIGINT(20) NOT NULL COMMENT '主键',
`DICT_ID` BIGINT(20) NOT NULL COMMENT '字典ID',
`KEY` CHAR(10) NOT NULL COMMENT '字典KEY',
`VALUE` VARCHAR(100) NOT NULL COMMENT '字典VALUE',
`SORT` INTEGER(10) NOT NULL COMMENT '排序',
`VALID` TINYINT(1) NOT NULL COMMENT '是否有效',
`ROW_VERSION` BIGINT(20) NOT NULL DEFAULT 0 COMMENT '行版本',
`IS_DELETED` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否已删除',
`CREATE_BY` BIGINT(20) NOT NULL COMMENT '创建用户',
`CREATE_TIME` DATETIME NOT NULL COMMENT '创建时间',
`LAST_UPDATE_BY` BIGINT(20) DEFAULT NULL COMMENT '最后更新用户',
`LAST_UPDATE_TIME` DATETIME DEFAULT NULL COMMENT '最后更新时间',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='字典项';

@ -95,7 +95,7 @@ fileRequest = function (config) {
window.ajax = {
authLogin: function (data) {
return jsonRequest({
url: "/system/auth/login",
url: "/system/Auth/login",
data: JSON.stringify(data),
})
},
@ -106,12 +106,78 @@ window.ajax = {
data: fd
})
},
dictCreate: function (data) {
return jsonRequest({
url: "/system/Dict/create",
data: JSON.stringify(data),
})
},
dictUpdate: function (data) {
return jsonRequest({
url: "/system/Dict/update",
data: JSON.stringify(data),
})
},
dictDelete: function (data) {
return jsonRequest({
url: "/system/Dict/delete",
data: JSON.stringify(data),
})
},
dictFind: function (data) {
return jsonRequest({
url: "/system/Dict/find",
data: JSON.stringify(data),
})
},
dictGet: function (data) {
return jsonRequest({
url: "/system/Dict/get",
data: JSON.stringify(data),
})
},
dictLoad: function (data) {
return jsonRequest({
url: "/system/Dict/load",
data: JSON.stringify(data),
})
},
dictItemCreate: function (data) {
return jsonRequest({
url: "/system/DictItem/create",
data: JSON.stringify(data),
})
},
dictItemUpdate: function (data) {
return jsonRequest({
url: "/system/DictItem/update",
data: JSON.stringify(data),
})
},
dictItemDelete: function (data) {
return jsonRequest({
url: "/system/DictItem/delete",
data: JSON.stringify(data),
})
},
dictItemFind: function (data) {
return jsonRequest({
url: "/system/DictItem/find",
data: JSON.stringify(data),
})
},
dictItemGet: function (data) {
return jsonRequest({
url: "/system/DictItem/get",
data: JSON.stringify(data),
})
},
<#list modules as db>
<#list db.tables as table>
<#if table.getCreate()>
${table.getFName()}Create: function (data) {
return jsonRequest({
url: "/${db.moduleName}/${table.getLName()}/create",
url: "/${db.moduleName}/${table.getCName()}/create",
data: JSON.stringify(data),
})
},
@ -119,7 +185,7 @@ window.ajax = {
<#if table.getDelete()>
${table.getFName()}Delete: function (data) {
return jsonRequest({
url: "/${db.moduleName}/${table.getLName()}/delete",
url: "/${db.moduleName}/${table.getCName()}/delete",
data: JSON.stringify(data),
})
},
@ -127,7 +193,7 @@ window.ajax = {
<#if table.getUpdate()>
${table.getFName()}Update: function (data) {
return jsonRequest({
url: "/${db.moduleName}/${table.getLName()}/update",
url: "/${db.moduleName}/${table.getCName()}/update",
data: JSON.stringify(data),
})
},
@ -135,7 +201,7 @@ window.ajax = {
<#if table.getFind()>
${table.getFName()}Find: function (data) {
return jsonRequest({
url: "/${db.moduleName}/${table.getLName()}/find",
url: "/${db.moduleName}/${table.getCName()}/find",
data: JSON.stringify(data),
})
},
@ -143,7 +209,7 @@ window.ajax = {
<#if table.getGet()>
${table.getFName()}Get: function(data) {
return jsonRequest({
url: "/${db.moduleName}/${table.getLName()}/get",
url: "/${db.moduleName}/${table.getCName()}/get",
data: JSON.stringify(data),
})
},
@ -151,7 +217,7 @@ window.ajax = {
<#if table.getSearch()>
${table.getFName()}Search: function (data) {
return jsonRequest({
url: "/${db.moduleName}/${table.getLName()}/search",
url: "/${db.moduleName}/${table.getCName()}/search",
data: JSON.stringify(data),
})
},
@ -159,7 +225,7 @@ window.ajax = {
<#if table.getGetAll()>
${table.getFName()}GetAll: function (data) {
return jsonRequest({
url: "/${db.moduleName}/${table.getLName()}/getAll",
url: "/${db.moduleName}/${table.getCName()}/getAll",
data: JSON.stringify(data),
})
},

@ -1,42 +0,0 @@
<#if dataBase == 'ORACLE'>
/*
Target : ORACLE
Author
Date: ${date?string("yyyy-MM-dd")}
*/
-- ----------------------------
-- Table structure for ${table.tableName} - ${table.tableComment?default("")}
-- ----------------------------
CREATE TABLE "${module.modulePrefix}${table.tableName}" (
<#list table.fields as field>
${dBmapper.getFieldSql(field)}<#if field_has_next>,</#if>
</#list>
);
COMMENT ON TABLE "${module.modulePrefix?default("")}${table.tableName}" is '${table.tableComment}';
<#list table.fields as field>
COMMENT ON COLUMN "${module.modulePrefix?default("")}${table.tableName}"."${field.fieldName?default("")}" is '${field.fieldComment?default("")}';
</#list>
</#if>
<#if dataBase == 'MYSQL'>
/*
Target : MYSQL
Author
Date: ${date?string("yyyy-MM-dd")}
*/
-- ----------------------------
-- Table structure for ${table.tableName} - ${table.tableComment?default("")}
-- ----------------------------
CREATE TABLE `${module.modulePrefix?default("")}${table.tableName}` (
<#list table.fields as field>
${dBmapper.getFieldSql(field)}<#if field_has_next||module.hasSysFields>,</#if>
</#list>
<#if module.hasSysFields>
PRIMARY KEY (`ID`)
</#if>
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='${table.tableComment?default("")}';
</#if>

@ -1,34 +0,0 @@
<#if dataBase == 'ORACLE'>
<#list module.tables as table>
-- ----------------------------
-- Table structure for ${table.tableName} - ${table.tableComment?default("")}
-- ----------------------------
CREATE TABLE "${module.modulePrefix?default("")}${table.tableName}" (
<#list table.fields as field>
${dBmapper.getFieldSql(field)}<#if field_has_next>,</#if>
</#list>
);
COMMENT ON TABLE "${module.modulePrefix?default("")}${table.tableName}" is '${table.tableComment?default("")}';
<#list table.fields as field>
COMMENT ON COLUMN "${module.modulePrefix?default("")}${table.tableName}"."${field.fieldName?default("")}" is '${field.fieldComment?default("")}';
</#list>
</#list>
</#if>
<#if dataBase == 'MYSQL'>
<#list module.tables as table>
-- ----------------------------
-- Table structure for ${table.tableName} - ${table.tableComment?default("")}
-- ----------------------------
CREATE TABLE `${module.modulePrefix?default("")}${table.tableName}` (
<#list table.fields as field>
${dBmapper.getFieldSql(field)}<#if field_has_next||module.hasSysFields>,</#if>
</#list>
<#if module.hasSysFields>
PRIMARY KEY (`ID`)
</#if>
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='${table.tableComment?default("")}';
</#list>
</#if>

@ -17,7 +17,7 @@
<i class="el-icon-setting"></i>
<span slot="title">系统设置</span>
</template>
<el-menu-item index="${tool.uuid()}" @click="addTab({title: '用户管理', name: 'usersManager', url: 'about:blank'})">用户管理</el-menu-item>
<el-menu-item index="${tool.uuid()}" @click="addTab({title: '字典管理', name: 'dict', url: '${r'${context}'}/system/dict.htm'})">字典管理</el-menu-item>
</el-submenu>
<#list modules as item>
<el-submenu index="${tool.uuid()}">
@ -278,7 +278,6 @@
uniqueOpened: true,//是否保持一个子菜单展开
isCollapse: false,//左侧菜单是否收缩
transition:false,
defaultActive:"1-1",
}
},
methods: {

@ -117,6 +117,7 @@
if (valid) {
this.isLogin = true;
ajax.authLogin(this.form).then(function (response) {
this.isLogin = false;
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {

@ -114,6 +114,11 @@
.form .el-dialog{
width: 700px;
}
.form .el-dialog .el-form-item__content {
width: 220px;
}
</style>
<script>
var app = new Vue({
@ -185,8 +190,13 @@
nav.e("尚未选择数据列");
return;
}
this.$confirm('将删除所有选中项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
this.select.forEach(function (item) {
ajax.user1Delete({id: item.id}).then(function (response) {
ajax.${table.getFName()}Delete({id: item.id}).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
@ -198,6 +208,9 @@
}
}.bind(this))
}.bind(this))
}.bind(this)).catch(function (action) {
});
},
onSelectionChange: function (select) {
this.select = select;

@ -0,0 +1,343 @@
<div id="app" v-cloak>
<el-card class="box-card">
<el-form :inline="true" :model="vm" ref="vm" label-width="90px">
<el-form-item label="字典名称" prop="dictName">
<el-input v-model="vm.dictName" clearable size="small" placeholder=""></el-input>
</el-form-item>
<el-form-item label="字典代码" prop="dictCode">
<el-input v-model="vm.dictCode" clearable size="small" placeholder=""></el-input>
</el-form-item>
<el-form-item label="是否有效" prop="valid">
<el-select v-model="vm.valid" size="small" placeholder="">
<el-option label="所有" value=""></el-option>
<el-option label="有效" value="true"></el-option>
<el-option label="无效" value="false"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" icon="el-icon-search" @click="onSearch">搜索</el-button>
<el-button type="warning" size="small" icon="el-icon-refresh-left" @click="onReset('vm')">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="box-card">
<el-row>
<el-col :span="12">
<el-button type="success" size="small" icon="el-icon-plus" @click="onAction(['create',''])">新增
</el-button>
<el-button type="warning" size="small" icon="el-icon-download">导出</el-button>
<el-dialog class="form" :title="form.title" :visible.sync="form.dialog">
<el-form :model="form" :inline="true" :rules="formRules" ref="form" label-width="90px">
<el-form-item label="字典名称" prop="dictName">
<el-input size="small" v-model="form.dictName"></el-input>
</el-form-item>
<el-form-item label="字典代码" prop="dictCode">
<el-input size="small" v-model="form.dictCode"></el-input>
</el-form-item>
<el-form-item label="字典版本" required>
<el-date-picker size="small"
v-model="form.version"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择日期时间"
align="right">
</el-date-picker>
</el-form-item>
<el-form-item label="是否有效" prop="valid">
<el-switch size="small" v-model="form.valid"></el-switch>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="form.dialog = false">取 消</el-button>
<el-button size="small" type="primary" @click="onAction(['save',''])">保存</el-button>
</span>
</el-dialog>
</el-col>
<el-col :span="12">
<el-button-group style="float: right;">
<el-button size="small" icon="el-icon-delete" @click="onBitchDelete"></el-button>
<el-button size="small" icon="el-icon-refresh" @click="onFind"></el-button>
</el-button-group>
</el-col>
</el-row>
<el-table
style="margin-top: 10px"
@selection-change="onSelectionChange"
empty-text="无数据"
:data="result"
size="small"
style="width: 100%">
<el-table-column
align="center"
type="selection"
width="50">
</el-table-column>
<el-table-column
align="center"
prop="id"
label="主键"
width="140">
</el-table-column>
<el-table-column
align="center"
width="80"
label="是否有效">
<template slot-scope="scope">
<el-tag size="mini" v-if="scope.row.valid">有效</el-tag>
<el-tag size="mini" type="danger" v-if="!scope.row.valid">无效</el-tag>
</template>
</el-table-column>
<el-table-column
align="center"
prop="dictName"
label="字典名称">
</el-table-column>
<el-table-column
align="center"
prop="dictCode"
label="字典代码">
</el-table-column>
<el-table-column
align="center"
prop="version"
label="字典版本">
</el-table-column>
<el-table-column
align="center"
prop="createTime"
label="创建时间">
</el-table-column>
<el-table-column
align="center"
fixed="right"
width="120"
label="操作">
<template slot-scope="scope">
<el-dropdown size="mini" split-button type="primary" @click="onAction(['view',scope.row])"
@command="onAction">
<i class="el-icon-tickets"></i>查看
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="['edit',scope.row]" icon="el-icon-edit">编辑</el-dropdown-item>
<el-dropdown-item :command="['delete',scope.row]" icon="el-icon-delete">删除
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<el-pagination
style="margin-top: 10px"
v-if="vm.totalCount > vm.pageSize"
@current-change="onPage"
:current-page="vm.pageNumber"
:page-size="vm.pageSize"
layout="total, prev, pager, next, jumper"
:total="vm.totalCount">
</el-pagination>
</el-card>
</div>
<style>
#app {
padding: 10px;
}
.box-card {
margin: 10px;
}
.form .el-dialog {
width: 700px;
}
.form .el-dialog .el-form-item__content {
width: 220px;
}
</style>
<script>
var app = new Vue({
el: "#app",
data: {
vm: {
id: '',
dictName: '',
dictCode: '',
valid: "",
pageNumber: 1,
pageSize: 10,
totalCount: 0
},
select: [],
result: [],
form: {
title: "",
dialog: false,
id: '',
dictName: '',
dictCode: '',
version: '',
valid: false,
rowVersion: '',
},
formRules: {
dictName: [
{required: true, message: '请输入字典名称', trigger: 'blur'},
{min: 1, max: 50, message: '长度在 3 到 5 个字符', trigger: 'blur'}
],
dictCode: [
{required: true, message: '请输入字典代码', trigger: 'blur'},
{min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur'}
],
version: [
{type: 'date', required: true, message: '字典版本不能为空', trigger: 'change'}
],
},
},
methods: {
onSearch: function () {
this.vm.pageNumber = 1;
this.onFind();
},
onReset: function (form) {
this.$refs[form].resetFields();
nav.w('重置成功');
},
onFind: function () {
ajax.dictFind(this.vm).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.result = response.result;
this.vm.totalCount = Number(response.totalCount);
}
}.bind(this))
},
onPage: function (pageNumber) {
this.vm.pageNumber = pageNumber;
this.onFind();
},
onSelectionChange: function (select) {
this.select = select;
},
onBitchDelete: function () {
if (this.select.length == 0) {
nav.w("至少选中一项");
} else {
this.$confirm('将删除已选择的项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
for (var i = 0; i < this.select.length; i++) {
var obj = this.select[i];
ajax.dictDelete({id: obj.id}).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
for (var j = 0; j < this.select.length; j++) {
if (this.select[j].id == obj.id) {
this.select.splice(j, 1);
}
}
if (this.select.length == 0) {
nav.s("删除成功")
this.onFind();
}
}
}.bind(this))
}
}.bind(this)).catch(function (action) {
});
}
},
onAction: function (arg) {
const action = arg[0];
const item = arg[1];
switch (action) {
case "create":
this.form.title = '新增字典';
this.form.id = '';
this.form.dictName = '';
this.form.dictCode = '';
this.form.version = '';
this.form.valid = true;
this.form.dialog = true;
break;
case "save":
this.$refs['form'].validate(function (valid) {
if (valid) {
if (this.form.id) {
ajax.dictUpdate(this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.form.dialog = false;
}
}.bind(this))
} else {
ajax.dictCreate(this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.form.dialog = false;
}
}.bind(this))
}
} else {
return false;
}
}.bind(this));
break;
case "view":
parent.index.addTab({
title: "字典项管理",
name: "dictItem" + item.id,
url: "${context}/system/dictItem.htm?dictId=" + item.id
});
break;
case "edit":
this.form.title = '编辑字典';
this.form.id = item.id;
this.form.dictName = item.dictName;
this.form.dictCode = item.dictCode;
this.form.version = item.version;
this.form.valid = item.valid;
this.form.rowVersion = item.rowVersion;
this.form.dialog = true;
break;
case "delete":
this.$confirm('将删除该项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
ajax.dictDelete({id: item.id}).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
nav.s("删除成功");
this.onFind();
}
}.bind(this));
}.bind(this));
break;
}
}
},
filters: {},
created: function () {
},
mounted: function () {
this.onFind();
},
watch: {}
})
</script>

@ -0,0 +1,339 @@
<div id="app" v-cloak>
<el-card class="box-card">
<el-form :inline="true" :model="vm" ref="vm" label-width="90px">
<el-form-item label="字典名称">
<el-input disabled v-model="vm.dictName" clearable size="small"></el-input>
</el-form-item>
<el-form-item label="字典键" prop="key">
<el-input v-model="vm.key" clearable size="small" placeholder=""></el-input>
</el-form-item>
<el-form-item label="字典值" prop="value">
<el-input v-model="vm.value" clearable size="small" placeholder=""></el-input>
</el-form-item>
<el-form-item label="是否有效" prop="valid">
<el-select v-model="vm.valid" size="small" placeholder="">
<el-option label="所有" value=""></el-option>
<el-option label="有效" value="true"></el-option>
<el-option label="无效" value="false"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" icon="el-icon-search" @click="onSearch">搜索</el-button>
<el-button type="warning" size="small" icon="el-icon-refresh-left" @click="onReset('vm')">重置</el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="box-card">
<el-row>
<el-col :span="12">
<el-button type="success" size="small" icon="el-icon-plus" @click="onAction(['create',''])">新增</el-button>
<el-button type="warning" size="small" icon="el-icon-download">导出</el-button>
<el-dialog class="form" :title="form.title" :visible.sync="form.dialog">
<el-form :model="form":inline="true" :rules="formRules" ref="form" label-width="90px">
<el-form-item label="字典键" prop="dictName">
<el-input size="small" v-model="form.key"></el-input>
</el-form-item>
<el-form-item label="字典值" prop="dictCode">
<el-input size="small" v-model="form.value"></el-input>
</el-form-item>
<el-form-item label="排序值" prop="dictCode">
<el-input-number size="small" v-model="form.sort" :min="0" :max="10000"
label="描述文字"></el-input-number>
</el-form-item>
<el-form-item label="是否有效" prop="valid">
<el-switch size="small" v-model="form.valid"></el-switch>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button size="small" @click="form.dialog = false">取消</el-button>
<el-button size="small" type="primary" @click="onAction(['save',''])">保存</el-button>
</span>
</el-dialog>
</el-col>
<el-col :span="12">
<el-button-group style="float: right;">
<el-button size="small" icon="el-icon-delete" @click="onBitchDelete"></el-button>
<el-button size="small" icon="el-icon-refresh" @click="onFind"></el-button>
</el-button-group>
</el-col>
</el-row>
<el-table
@selection-change="onSelectionChange"
empty-text="无数据"
:data="result"
size="small"
style="width: 100%">
<el-table-column
align="center"
type="selection"
width="50">
</el-table-column>
<el-table-column
align="center"
prop="id"
label="主键"
width="140">
</el-table-column>
<el-table-column
align="center"
width="80"
label="是否有效">
<template slot-scope="scope">
<el-tag size="mini" v-if="scope.row.valid">有效</el-tag>
<el-tag size="mini" type="danger" v-if="!scope.row.valid">无效</el-tag>
</template>
</el-table-column>
<el-table-column
align="center"
prop="key"
label="字典键">
</el-table-column>
<el-table-column
align="center"
prop="value"
label="字典值">
</el-table-column>
<el-table-column
align="center"
prop="sort"
label="排序">
</el-table-column>
<el-table-column
align="center"
prop="createTime"
label="创建时间">
</el-table-column>
<el-table-column
align="center"
fixed="right"
width="120"
label="操作">
<template slot-scope="scope">
<el-dropdown size="mini" split-button type="primary" @click="onAction(['edit',scope.row])"
@command="onAction">
<i class="el-icon-edit"></i>编辑
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="['delete',scope.row]" icon="el-icon-delete">删除
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="vm.totalCount > vm.pageSize"
@current-change="onPage"
:current-page="vm.pageNumber"
:page-size="vm.pageSize"
layout="total, prev, pager, next, jumper"
:total="vm.totalCount">
</el-pagination>
</el-card>
</div>
<style>
#app {
padding: 10px;
}
.box-card {
margin: 10px;
}
.form .el-dialog{
width: 700px;
}
.form .el-dialog .el-form-item__content {
width: 220px;
}
</style>
<script>
var app = new Vue({
el: "#app",
data: {
vm: {
id: '',
dictId: location.getParam("dictId"),
dictName: '',
key: '',
value: '',
valid: '',
pageNumber: 1,
pageSize: 10,
totalCount: 0
},
select: [],
result: [],
form: {
title: "",
dialog: false,
id: '',
dictId: location.getParam("dictId"),
key: '',
value: '',
sort: 0,
valid: true
},
formRules: {
key: [
{required: true, message: '请输入字典名称', trigger: 'blur'},
{min: 1, max: 50, message: '长度在 3 到 5 个字符', trigger: 'blur'}
],
value: [
{required: true, message: '请输入字典代码', trigger: 'blur'},
{min: 1, max: 50, message: '长度在 1 到 50 个字符', trigger: 'blur'}
],
},
},
methods: {
onSearch: function () {
this.vm.pageNumber = 1;
this.onFind();
},
onReset: function (form) {
this.$refs[form].resetFields();
nav.w('重置成功');
},
onFind: function () {
ajax.dictItemFind(this.vm).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.result = response.result;
this.vm.totalCount = Number(response.totalCount);
}
}.bind(this))
},
onPage: function (pageNumber) {
this.vm.pageNumber = pageNumber;
this.onFind();
},
onSelectionChange: function (select) {
this.select = select;
},
onBitchDelete: function () {
if (this.select.length == 0) {
nav.w("至少选中一项");
} else {
this.$confirm('将删除已选择的项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
for (var i = 0; i < this.select.length; i++) {
var obj = this.select[i];
ajax.dictItemDelete({id: obj.id}).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
for (var j = 0; j < this.select.length; j++) {
if (this.select[j].id == obj.id) {
this.select.splice(j, 1);
}
}
if (this.select.length == 0) {
nav.s("删除成功")
this.onFind();
}
}
}.bind(this))
}
}.bind(this)).catch(function (action) {
});
}
},
getDict: function () {
ajax.dictGet({id: location.getParam("dictId")}).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.vm.dictName = response.dict.dictName;
}
}.bind(this))
},
onAction: function (arg) {
const action = arg[0];
const item = arg[1];
switch (action) {
case "create":
this.form.title = '新增字典项';
this.form.id = '';
this.form.key = '';
this.form.value = '';
this.form.sort = this.vm.totalCount;
this.form.valid = true;
this.form.dialog = true;
break;
case "save":
this.$refs['form'].validate(function (valid) {
if (valid) {
if (this.form.id) {
ajax.dictItemUpdate(this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.form.dialog = false;
}
}.bind(this))
} else {
ajax.dictItemCreate(this.form).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
this.onFind();
this.form.dialog = false;
}
}.bind(this))
}
} else {
return false;
}
}.bind(this));
break;
case "edit":
this.form.title = '编辑字典项';
this.form.id = item.id;
this.form.key = item.key;
this.form.value = item.value;
this.form.valid = item.valid;
this.form.sort = item.sort;
this.form.rowVersion = item.rowVersion;
this.form.dialog = true;
break;
case "delete":
this.$confirm('将删除该项, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
ajax.dictItemDelete({id: item.id}).then(function (response) {
if (response.errors.length > 0) {
nav.e(response.errors[0].message);
} else {
nav.s("删除成功")
this.onFind();
}
}.bind(this));
}.bind(this));
break;
}
}
},
filters: {},
created: function () {
},
mounted: function () {
this.getDict();
this.onFind();
},
watch: {}
})
</script>
Loading…
Cancel
Save

Powered by TurnKey Linux.