Commit c5f63b89 by 吴迪

添加data

parent ac239744
...@@ -48,7 +48,8 @@ public class GenUtils { ...@@ -48,7 +48,8 @@ public class GenUtils {
templates.add("template/Dao.java.vm"); templates.add("template/Dao.java.vm");
templates.add("template/index.vue.vm"); templates.add("template/index.vue.vm");
templates.add("template/add-or-update.vue.vm"); templates.add("template/addui.vue.vm");
templates.add("template/updateui.vue.vm");
if (MongoManager.isMongo()) { if (MongoManager.isMongo()) {
// mongo不需要mapper、sql 实体类需要替换 // mongo不需要mapper、sql 实体类需要替换
templates.remove(0); templates.remove(0);
...@@ -277,7 +278,7 @@ public class GenUtils { ...@@ -277,7 +278,7 @@ public class GenUtils {
public static String tableToJava(String tableName, String[] tablePrefixArray) { public static String tableToJava(String tableName, String[] tablePrefixArray) {
if (null != tablePrefixArray && tablePrefixArray.length > 0) { if (null != tablePrefixArray && tablePrefixArray.length > 0) {
for (String tablePrefix : tablePrefixArray) { for (String tablePrefix : tablePrefixArray) {
if (tableName.startsWith(tablePrefix)){ if (tableName.startsWith(tablePrefix)) {
tableName = tableName.replaceFirst(tablePrefix, ""); tableName = tableName.replaceFirst(tablePrefix, "");
} }
} }
...@@ -305,13 +306,13 @@ public class GenUtils { ...@@ -305,13 +306,13 @@ public class GenUtils {
packagePath += packageName.replace(".", File.separator) + File.separator + moduleName + File.separator; packagePath += packageName.replace(".", File.separator) + File.separator + moduleName + File.separator;
} }
if (template.contains("MongoChildrenEntity.java.vm")) { if (template.contains("MongoChildrenEntity.java.vm")) {
return packagePath + "entity" + File.separator + "inner" + File.separator + currentTableName+ File.separator + splitInnerName(className)+ "InnerEntity.java"; return packagePath + "entity" + File.separator + "inner" + File.separator + currentTableName + File.separator + splitInnerName(className) + "InnerEntity.java";
} }
if (template.contains("Entity.java.vm") || template.contains("MongoEntity.java.vm")) { if (template.contains("Entity.java.vm") || template.contains("MongoEntity.java.vm")) {
return packagePath + "entity" + File.separator + className + "Entity.java"; return packagePath + "entity" + File.separator + className + "Entity.java";
} }
if (template.contains("Form.java.vm") ) { if (template.contains("Form.java.vm")) {
return packagePath + "form" + File.separator + className + "Form.java"; return packagePath + "form" + File.separator + className + "Form.java";
} }
...@@ -341,19 +342,30 @@ public class GenUtils { ...@@ -341,19 +342,30 @@ public class GenUtils {
if (template.contains("index.vue.vm")) { if (template.contains("index.vue.vm")) {
return "main" + File.separator + "resources" + File.separator + "src" + File.separator + "views" + File.separator + "modules" + return "main" + File.separator + "resources" + File.separator + "src" + File.separator + "views" + File.separator + "modules" +
File.separator + moduleName + File.separator + className.toLowerCase() + ".vue"; File.separator + moduleName + File.separator +className.toLowerCase() + File.separator + className.toLowerCase() + ".vue";
} }
//
//if (template.contains("add-or-update.vue.vm")) {
// return "main" + File.separator + "resources" + File.separator + "src" + File.separator + "views" + File.separator + "modules" +
// File.separator + moduleName + File.separator + className.toLowerCase() + "-add-or-update.vue";
//}
if (template.contains("add-or-update.vue.vm")) { if (template.contains("addui.vue.vm")) {
return "main" + File.separator + "resources" + File.separator + "src" + File.separator + "views" + File.separator + "modules" + return "main" + File.separator + "resources" + File.separator + "src" + File.separator + "views" + File.separator + "modules" +
File.separator + moduleName + File.separator + className.toLowerCase() + "-add-or-update.vue"; File.separator + moduleName + File.separator +className.toLowerCase() + File.separator + className.toLowerCase() + "addui.vue";
} }
if (template.contains("updateui.vue.vm")) {
return "main" + File.separator + "resources" + File.separator + "src" + File.separator + "views" + File.separator + "modules" +
File.separator + moduleName + File.separator + className.toLowerCase() + File.separator + className.toLowerCase() + "updateui.vue";
}
return null; return null;
} }
private static String splitInnerName(String name){ private static String splitInnerName(String name) {
name = name.replaceAll("\\.","_"); name = name.replaceAll("\\.", "_");
return name; return name;
} }
} }
<template>
<div>
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
<el-form-item label="${column.comments}" prop="${column.attrname}">
<el-input v-model="dataForm.${column.attrname}" placeholder="${column.comments}"></el-input>
</el-form-item>
#end
#end
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
<el-button @click="visible = false">取消</el-button>
</span>
</div>
</template>
<script>
export default {
data () {
return {
dataForm: {
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
${column.attrname}: 0,
#else
${column.attrname}: ''#if($velocityCount != $columns.size()),#end
#end
#end
},
dataRule: {
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
${column.attrname}: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
]#if($velocityCount != $columns.size()),#end
#end
#end
}
}
},
methods: {
// 表单提交
dataFormSubmit () {
#[[this.$refs['dataForm'].validate((valid) => {]]#
if (valid) {
this.$http({
url: #[[this.$http.adornUrl]]#(`/${moduleName}/${pathName}/${!this.dataForm.${pk.attrname} ? 'save' : 'update'}`),
method: 'post',
#[[data: this.$http.adornData({]]#
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
'${column.attrname}': this.dataForm.${column.attrname} || undefined,
#else
'${column.attrname}': this.dataForm.${column.attrname}#if($velocityCount != $columns.size()),#end
#end
#end
})
}).then(({data}) => {
if (data && data.code === 0) {
#[[this.$message({]]#
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
#[[this.$emit('refreshDataList')]]#
}
})
} else {
#[[this.$message.error(data.msg)]]#
}
})
}
})
}
}
}
</script>
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="getDataList()">查询</el-button> <el-button @click="getDataList()">查询</el-button>
<el-button v-if="isAuth('${moduleName}:${pathName}:save')" type="primary" @click="addOrUpdateHandle()">新增</el-button> <el-button v-if="isAuth('${moduleName}:${pathName}:save')" type="primary" @click="addHandle()">新增</el-button>
<el-button v-if="isAuth('${moduleName}:${pathName}:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button> <el-button v-if="isAuth('${moduleName}:${pathName}:delete')" type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
width="150" width="150"
label="操作"> label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="text" size="small" @click="addOrUpdateHandle(scope.row.${pk.attrname})">修改</el-button> <el-button type="text" size="small" @click="updateHandle(scope.row.${pk.attrname})">修改</el-button>
<el-button type="text" size="small" @click="deleteHandle(scope.row.${pk.attrname})">删除</el-button> <el-button type="text" size="small" @click="deleteHandle(scope.row.${pk.attrname})">删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
...@@ -51,13 +51,10 @@ ...@@ -51,13 +51,10 @@
:total="totalPage" :total="totalPage"
layout="total, sizes, prev, pager, next, jumper"> layout="total, sizes, prev, pager, next, jumper">
</el-pagination> </el-pagination>
<!-- 弹窗, 新增 / 修改 -->
<add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
</div> </div>
</template> </template>
<script> <script>
import AddOrUpdate from './${pathName}-add-or-update'
export default { export default {
data () { data () {
return { return {
...@@ -73,9 +70,6 @@ ...@@ -73,9 +70,6 @@
addOrUpdateVisible: false addOrUpdateVisible: false
} }
}, },
components: {
AddOrUpdate
},
activated () { activated () {
this.getDataList() this.getDataList()
}, },
...@@ -117,15 +111,21 @@ ...@@ -117,15 +111,21 @@
selectionChangeHandle (val) { selectionChangeHandle (val) {
this.dataListSelections = val this.dataListSelections = val
}, },
// 新增 / 修改 // 新增
addOrUpdateHandle (id) { addHandle () {
this.addOrUpdateVisible = true
#[[this.$nextTick(() => {]]# #[[this.$nextTick(() => {]]#
this.$refs.addOrUpdate.init(id) #[[this.$router.push]]#({ name: 'manage-${pathName}-${pathName}addui' })
}) #[[})]]#
},
// 修改
updateHandle (id) {
#[[this.$nextTick(() => {]]#
#[[this.$router.push]]#({ name: 'manage-${pathName}-${pathName}updateui', params: { id: id } })
#[[})]]#
}, },
// 删除 // 删除
deleteHandle (id) { deleteHandle (id) {
// 提示要修改成name,每个表的都不一样,所以做不了通用的,暂时使用id
var ids = id ? [id] : this.dataListSelections.map(item => { var ids = id ? [id] : this.dataListSelections.map(item => {
return item.${pk.attrname} return item.${pk.attrname}
}) })
......
-- 菜单SQL -- 菜单SQL
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('0', '${comments}', '${moduleName}/${pathName}', NULL, '1', 'config', '6'); VALUES ('0', '${comments}', '${moduleName}/${pathName}/${pathName}', NULL, '1', 'config', '6');
-- 按钮父菜单ID -- 按钮父菜单ID
set @parentId = @@identity; set @parentId = @@identity;
...@@ -14,3 +14,12 @@ INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `or ...@@ -14,3 +14,12 @@ INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `or
SELECT @parentId, '修改', null, '${moduleName}:${pathName}:update', '2', null, '6'; SELECT @parentId, '修改', null, '${moduleName}:${pathName}:update', '2', null, '6';
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
SELECT @parentId, '删除', null, '${moduleName}:${pathName}:delete', '2', null, '6'; SELECT @parentId, '删除', null, '${moduleName}:${pathName}:delete', '2', null, '6';
-- 新增的${moduleName}ui菜单
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('53', '${comments}-新增', '${moduleName}/${pathName}/${pathName}addui', '${moduleName}:${pathName}:save', '1', 'config', '6');
-- 修改的${moduleName}ui菜单
INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`)
VALUES ('53', '${comments}-修改', '${moduleName}/${pathName}/${pathName}updateui', '${moduleName}:${pathName}:update', '1', 'config', '6');
<template>
<div>
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
<el-form-item label="${column.comments}" prop="${column.attrname}">
<el-input v-model="dataForm.${column.attrname}" placeholder="${column.comments}"></el-input>
</el-form-item>
#end
#end
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
<el-button @click="visible = false">取消</el-button>
</span>
</div>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
${column.attrname}: 0,
#else
${column.attrname}: ''#if($velocityCount != $columns.size()),#end
#end
#end
},
dataRule: {
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
${column.attrname}: [
{ required: true, message: '${column.comments}不能为空', trigger: 'blur' }
]#if($velocityCount != $columns.size()),#end
#end
#end
}
}
},
mounted () {
this.$nextTick(() => {
this.init(this.$route.params.id)
})
},
methods: {
init (id) {
this.dataForm.${pk.attrname} = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.${pk.attrname}) {
this.$http({
url: #[[this.$http.adornUrl]]#(`/${moduleName}/${pathName}/info/#[[$]]#{this.dataForm.${pk.attrname}}`),
method: 'get',
#[[params: this.$http.adornParams()]]#
}).then(({data}) => {
if (data && data.code === 0) {
#foreach($column in $columns)
#if($column.columnName != $pk.columnName)
this.dataForm.${column.attrname} = data.data.${column.attrname}
#end
#end
}
})
}
})
},
// 表单提交
dataFormSubmit () {
#[[this.$refs['dataForm'].validate((valid) => {]]#
if (valid) {
this.$http({
url: #[[this.$http.adornUrl]]#(`/${moduleName}/${pathName}/${!this.dataForm.${pk.attrname} ? 'save' : 'update'}`),
method: 'post',
#[[data: this.$http.adornData({]]#
#foreach($column in $columns)
#if($column.columnName == $pk.columnName)
'${column.attrname}': this.dataForm.${column.attrname} || undefined,
#else
'${column.attrname}': this.dataForm.${column.attrname}#if($velocityCount != $columns.size()),#end
#end
#end
})
}).then(({data}) => {
if (data && data.code === 0) {
#[[this.$message({]]#
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
#[[this.$emit('refreshDataList')]]#
}
})
} else {
#[[this.$message.error(data.msg)]]#
}
})
}
})
}
}
}
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment