继续完善 index.vue.vm 模板 = = 睡觉~~~

This commit is contained in:
YunaiV 2021-02-12 01:36:42 +08:00
parent eb3d0386ee
commit 0b25eb1c2a
5 changed files with 121 additions and 152 deletions

View File

@ -1,53 +0,0 @@
import request from '@/utils/request'
// 查询${functionName}列表
export function list${BusinessName}(query) {
return request({
url: '/${moduleName}/${businessName}/list',
method: 'get',
params: query
})
}
// 查询${functionName}详细
export function get${BusinessName}(${pkColumn.javaField}) {
return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
method: 'get'
})
}
// 新增${functionName}
export function add${BusinessName}(data) {
return request({
url: '/${moduleName}/${businessName}',
method: 'post',
data: data
})
}
// 修改${functionName}
export function update${BusinessName}(data) {
return request({
url: '/${moduleName}/${businessName}',
method: 'put',
data: data
})
}
// 删除${functionName}
export function del${BusinessName}(${pkColumn.javaField}) {
return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
method: 'delete'
})
}
// 导出${functionName}
export function export${BusinessName}(query) {
return request({
url: '/${moduleName}/${businessName}/export',
method: 'get',
params: query
})
}

View File

@ -0,0 +1,55 @@
import request from '@/utils/request'
// 创建字典类型
export function createTestDemo(data) {
return request({
url: '/tool/test-demo/create',
method: 'post',
data: data
})
}
// 更新字典类型
export function updateTestDemo(data) {
return request({
url: '/tool/test-demo/update',
method: 'put',
data: data
})
}
// 删除字典类型
export function deleteTestDemo(id) {
return request({
url: '/tool/test-demo/delelte?id=' + id,
method: 'delete'
})
}
// 获得字典类型
export function getTestDemo(id) {
return request({
url: '/tool/test-demo/get?id=' + id,
method: 'get'
})
}
// 获得字典类型分页
export function getTestDemoPage(query) {
return request({
url: '/tool/test-demo/page',
method: 'get',
params: query
})
}
// 导出字典类型 Excel
export function exportTestDemoExcel(query) {
return request({
url: '/tool/test-demo/export-excel',
method: 'get',
params: query,
reponseBody: 'blob'
})
}

View File

@ -81,6 +81,8 @@ public class ToolCodegenEngine {
// Vue // Vue
.put(vueTemplatePath("views/index.vue"), .put(vueTemplatePath("views/index.vue"),
vueFilePath("views/${table.moduleName}/${table.businessName}/index.vue")) vueFilePath("views/${table.moduleName}/${table.businessName}/index.vue"))
.put(vueTemplatePath("api/api.js"),
vueFilePath("api/${table.moduleName}/${classNameVar}.js"))
// SQL // SQL
.build(); .build();
@ -163,6 +165,7 @@ public class ToolCodegenEngine {
filePath = StrUtil.replace(filePath, "${table.moduleName}", table.getModuleName()); filePath = StrUtil.replace(filePath, "${table.moduleName}", table.getModuleName());
filePath = StrUtil.replace(filePath, "${table.businessName}", table.getBusinessName()); filePath = StrUtil.replace(filePath, "${table.businessName}", table.getBusinessName());
filePath = StrUtil.replace(filePath, "${table.className}", table.getClassName()); filePath = StrUtil.replace(filePath, "${table.className}", table.getClassName());
filePath = StrUtil.replace(filePath, "${classNameVar}", (String) bindingMap.get("classNameVar"));
return filePath; return filePath;
} }

View File

@ -1,53 +1,56 @@
import request from '@/utils/request' import request from '@/utils/request'
#set ($baseURL = "/${table.moduleName}/${simpleClassName_strikeCase}")
// 查询${functionName}列表 // 创建${table.classComment}
export function list${BusinessName}(query) { export function create${simpleClassName}(data) {
return request({ return request({
url: '/${moduleName}/${businessName}/list', url: '${baseURL}/create',
method: 'get',
params: query
})
}
// 查询${functionName}详细
export function get${BusinessName}(${pkColumn.javaField}) {
return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
method: 'get'
})
}
// 新增${functionName}
export function add${BusinessName}(data) {
return request({
url: '/${moduleName}/${businessName}',
method: 'post', method: 'post',
data: data data: data
}) })
} }
// 修改${functionName} // 更新${table.classComment}
export function update${BusinessName}(data) { export function update${simpleClassName}(data) {
return request({ return request({
url: '/${moduleName}/${businessName}', url: '${baseURL}/update',
method: 'put', method: 'put',
data: data data: data
}) })
} }
// 删除${functionName}
export function del${BusinessName}(${pkColumn.javaField}) { // 删除${table.classComment}
export function delete${simpleClassName}(id) {
return request({ return request({
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField}, url: '${baseURL}/delelte?id=' + id,
method: 'delete' method: 'delete'
}) })
} }
// 导出${functionName} // 获得${table.classComment}
export function export${BusinessName}(query) { export function get${simpleClassName}(id) {
return request({ return request({
url: '/${moduleName}/${businessName}/export', url: '${baseURL}/get?id=' + id,
method: 'get'
})
}
// 获得${table.classComment}分页
export function get${simpleClassName}Page(query) {
return request({
url: '${baseURL}/page',
method: 'get', method: 'get',
params: query params: query
}) })
} }
// 导出${table.classComment} Excel
export function export${simpleClassName}Excel(query) {
return request({
url: '${baseURL}/export-excel',
method: 'get',
params: query,
reponseBody: 'blob'
})
}

View File

@ -111,14 +111,17 @@
</el-form-item> </el-form-item>
#end #end
#elseif($column.htmlType == "imageUpload")## 图片上传 #elseif($column.htmlType == "imageUpload")## 图片上传
#set ($hasImageUploadColumn = true)
<el-form-item label="${comment}"> <el-form-item label="${comment}">
<imageUpload v-model="form.${javaField}"/> <imageUpload v-model="form.${javaField}"/>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "fileUpload")## 文件上传 #elseif($column.htmlType == "fileUpload")## 文件上传
#set ($hasFileUploadColumn = true)
<el-form-item label="${comment}"> <el-form-item label="${comment}">
<fileUpload v-model="form.${javaField}"/> <fileUpload v-model="form.${javaField}"/>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "editor")## 文本编辑器 #elseif($column.htmlType == "editor")## 文本编辑器
#set ($hasEditorColumn = true)
<el-form-item label="${comment}"> <el-form-item label="${comment}">
<editor v-model="form.${javaField}" :min-height="192"/> <editor v-model="form.${javaField}" :min-height="192"/>
</el-form-item> </el-form-item>
@ -176,46 +179,28 @@
</template> </template>
<script> <script>
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}"; import { create${simpleClassName}, update${simpleClassName}, delete${simpleClassName}, get${simpleClassName}, get${simpleClassName}Page, export${simpleClassName}Excel } from "@/api/${table.moduleName}/${classNameVar}";
#foreach($column in $columns) #if ($hasImageUploadColumn)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
import ImageUpload from '@/components/ImageUpload'; import ImageUpload from '@/components/ImageUpload';
#break
#end #end
#end #if ($hasFileUploadColumn)
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
import FileUpload from '@/components/FileUpload'; import FileUpload from '@/components/FileUpload';
#break
#end #end
#end #if ($hasEditorColumn)
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
import Editor from '@/components/Editor'; import Editor from '@/components/Editor';
#break
#end
#end #end
export default { export default {
name: "${BusinessName}", name: "${simpleClassName}",
components: { components: {
#foreach($column in $columns) #if ($hasImageUploadColumn)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "imageUpload")
ImageUpload, ImageUpload,
#break
#end #end
#end #if ($hasFileUploadColumn)
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "fileUpload")
FileUpload, FileUpload,
#break
#end #end
#end #if ($hasEditorColumn)
#foreach($column in $columns)
#if($column.insert && !$column.superColumn && !$column.pk && $column.htmlType == "editor")
Editor, Editor,
#break
#end
#end #end
}, },
data() { data() {
@ -232,63 +217,37 @@ export default {
title: "", title: "",
// 是否显示弹出层 // 是否显示弹出层
open: false, open: false,
#foreach ($column in $columns) #foreach ($column in $columns)## 时间范围
#set($parentheseIndex=$column.columnComment.indexOf("")) #if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
#if($parentheseIndex != -1) #set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
#else
#set($comment=$column.columnComment)
#end
#if(${column.dictType} != '')
// $comment字典
${column.javaField}Options: [],
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
// $comment时间范围
dateRange${AttrName}: [], dateRange${AttrName}: [],
#end #end
#end #end
// 查询参数 // 查询参数
queryParams: { queryParams: {
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.query) #if ($column.listOperation && $column.listOperationCondition != 'BETWEEN')
$column.javaField: null#if($velocityCount != $columns.size()),#end $column.javaField: null,
#end
#end #end
#end
}, },
// 表单参数 // 表单参数
form: {}, form: {},
// 表单校验 // 表单校验
rules: { rules: {
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.required) #if (($column.createOperation || $column.updateOperation) && !$column.nullable && !${column.primaryKey})## 创建或者更新操作 && 要求非空 && 非主键
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($comment=$column.columnComment)
#if($parentheseIndex != -1) $column.javaField: [{ required: true, message: "${comment}不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }],
#set($comment=$column.columnComment.substring(0, $parentheseIndex)) #end
#else #end
#set($comment=$column.columnComment)
#end
$column.javaField: [
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
]#if($velocityCount != $columns.size()),#end
#end
#end
} }
}; };
}, },
created() { created() {
this.getList(); this.getList();
#foreach ($column in $columns)
#if(${column.dictType} != '')
this.getDicts("${column.dictType}").then(response => {
this.${column.javaField}Options = response.data;
});
#end
#end
}, },
methods: { methods: {
/** 查询${functionName}列表 */ /** 查询${functionName}列表 */
@ -379,6 +338,8 @@ export default {
submitForm() { submitForm() {
this.#[[$]]#refs["form"].validate(valid => { this.#[[$]]#refs["form"].validate(valid => {
if (valid) { if (valid) {
return;
}
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
this.form.$column.javaField = this.form.${column.javaField}.join(","); this.form.$column.javaField = this.form.${column.javaField}.join(",");
@ -402,7 +363,7 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids; const ${pkColumn.javaField}s = row.${pkColumn.javaField};
this.$confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?', "警告", { this.$confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?', "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",