代码生成补充

This commit is contained in:
wind 2019-11-13 18:41:34 +08:00
parent 035d23078b
commit b50400af3f
4 changed files with 436 additions and 101 deletions

View File

@ -91,6 +91,20 @@ export const constantRoutes = [
meta: { title: '字典数据', icon: '' }
}
]
},
{
path: '/gen',
component: Layout,
hidden: true,
children: [
{
path: 'edit',
component: () => import('@/views/tool/gen/edit'),
name: 'genEdit',
meta: { title: '修改生成配置' }
}
]
}
]

View File

@ -0,0 +1,72 @@
<template>
<el-form :model="info" ref="basicInfoForm" :rules="rules">
<el-row class="form-row" :gutter="24">
<el-col :lg="{span: 6, offset: 6}" :md="12" :sm="24">
<el-form-item label="表名称" prop="tableName">
<el-input placeholder="请输入仓库名称" v-model="info.tableName"/>
</el-form-item>
</el-col>
<el-col :lg="{span: 6, offset: 1}" :md="12" :sm="24">
<el-form-item label="表描述" prop="tableComment">
<el-input placeholder="请输入" v-model="info.tableComment"/>
</el-form-item>
</el-col>
</el-row>
<el-row class="form-row" :gutter="24">
<el-col :lg="{span: 6, offset: 6}" :md="12" :sm="24">
<el-form-item label="实体类名称" prop="className">
<el-input placeholder="请输入" v-model="info.className"/>
</el-form-item>
</el-col>
<el-col :lg="{span: 6, offset: 1}" :md="12" :sm="24">
<el-form-item label="作者" prop="functionAuthor">
<el-input placeholder="请输入" v-model="info.functionAuthor"/>
</el-form-item>
</el-col>
</el-row>
<el-row class="form-row" :gutter="24">
<el-col :lg="{span: 13, offset: 6}" :md="12" :sm="24">
<el-form-item label="备注" prop="remark">
<el-input type="textarea" :rows="3" v-model="info.remark"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
export default {
name: 'BasicInfoForm',
props: {
info: {
type: Object,
default: null
}
},
data () {
return {
visible:false,
mdl: {},
rules: {
tableName: [
{ required: true, message: '请输入表名称', trigger: 'blur' }
],
tableComment: [
{ required: true, message: '请输入表描述', trigger: 'blur' }
],
className: [
{ required: true, message: '请输入实体类名称', trigger: 'blur' }
],
functionAuthor: [
{ required: true, message: '请输入作者', trigger: 'blur' }
]
}
}
},
created(){
},
methods:{
}
}
</script>

View File

@ -0,0 +1,165 @@
<template>
<el-card class="box-card">
<el-tabs v-model="activeName" type="card" @tab-click="handleClick">
<el-tab-pane label="基本信息" name="basic">
<basic-info-form ref="basicInfo" :info="info"/>
</el-tab-pane>
<el-tab-pane label="字段信息" name="cloum">
<el-table
:data="cloumns"
style="width: 100% ;margin-top: 10px"
>
<el-table-column label="序号" type="index" width="50"/>
<el-table-column label="字段列名" align="center" prop="columnName" />
<el-table-column label="字段描述" align="center" prop="columnComment" />
<el-table-column label="物理类型" align="center" prop="columnType" />
<el-table-column label="查询方式" align="center" >
<template slot-scope="scope" >
<el-select v-model="scope.row.javaType" @change="e => handleChange(e, scope.row.columnId, 'javaType')">
<el-option value="Long">Long</el-option>
<el-option value="String">String</el-option>
<el-option value="Ingeter">Ingeter</el-option>
<el-option value="Double">Double</el-option>
<el-option value="BigDecimal">BigDecimal</el-option>
<el-option value="Date">Date</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="Java属性" align="center" prop="javaField" />
<el-table-column label="插入" align="center">
<template slot-scope="scope" width="50">
<el-checkbox :checked="scope.row.isInsert==='1'" @change="e => handleChange(e, scope.row.columnId, 'isInsert')"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="编辑" align="center">
<template slot-scope="scope" width="50">
<el-checkbox :checked="scope.row.isEdit==='1'" @change="e => handleChange(e, scope.row.columnId, 'isEdit')"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="列表" align="center">
<template slot-scope="scope" width="50">
<el-checkbox :checked="scope.row.isList==='1'" @change="e => handleChange(e, scope.row.columnId, 'isList')"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询" align="center">
<template slot-scope="scope" width="50">
<el-checkbox :checked="scope.row.isQuery==='1'" @change="e => handleChange(e, scope.row.columnId, 'isQuery')"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="查询方式" align="center" >
<template slot-scope="scope" >
<el-select v-model="scope.row.queryType" @change="e => handleChange(e, scope.row.columnId, 'queryType')">
<el-option value="EQ">=</el-option>
<el-option value="NE">!=</el-option>
<el-option value="GT">&gt;</el-option>
<el-option value="GTE">&gt;=</el-option>
<el-option value="LT">&gt;</el-option>
<el-option value="LTE">&gt;=</el-option>
<el-option value="LIKE">LIKE</el-option>
<el-option value="BETWEEN">BETWEEN</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="必填" align="center">
<template slot-scope="scope" width="50">
<el-checkbox :checked="scope.row.isRequired==='1'" @change="e => handleChange(e, scope.row.columnId, 'isRequired')"></el-checkbox>
</template>
</el-table-column>
<el-table-column label="显示类型" align="center" >
<template slot-scope="scope" >
<el-select v-model="scope.row.htmlType" @change="e => handleChange(e, scope.row.columnId, 'htmlType')">
<el-option value="input">文本框</el-option>
<el-option value="textarea">文本域</el-option>
<el-option value="select">下拉框</el-option>
<el-option value="radio">单选框</el-option>
<el-option value="checkbox">复选框</el-option>
<el-option value="datetime">日期控件</el-option>
</el-select>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="生成信息" name="genInfo">
<gen-info-form ref="genInfo" :info="info"/>
</el-tab-pane>
</el-tabs>
<el-form label-width="100px">
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
<el-button type="primary" @click="submitForm()">提交</el-button>
<el-button @click="rollback()">返回</el-button>
</el-form-item>
</el-form>
</el-card>
</template>
<script>
import { editTableInfo,editGenInfo } from '@/api/tool/gen'
import basicInfoForm from './basicInfoForm';
import genInfoForm from './genInfoForm';
export default {
components:{
basicInfoForm,
genInfoForm
},
data() {
return {
activeName: 'cloum',
cloumns:[],
info:{},
cloumForm:{}
};
},
beforeCreate(){
const { tableId } = this.$route.query
if (tableId) {
editTableInfo({tableId:tableId}).then(res => {
this.cloumns=res.data.rows
this.info=res.data.info
})
}
},
methods: {
handleChange (value, key, column) {
const newData = [...this.cloumns]
const target = newData.filter(item => key === item.columnId)[0]
if (target) {
target[column] = value
this.cloumns = newData
}
},
submitForm() {
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
const genForm = this.$refs.genInfo.$refs.genInfoForm;
Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => {
const validateResult = res.every(item => !!item);
if (validateResult) {
const genTable = Object.assign({}, basicForm.model, genForm.model)
genTable.columns = this.cloumns
console.log('genTable:',genTable)
editGenInfo(genTable).then(res=>{
console.log('gen edit res:',res)
this.msgSuccess(res.msg);
if(res.code===200){
this.rollback()
}
})
} else {
this.msgError("表单校验未通过,请重新检查提交内容");
}
})
},
getFormPromise(form) {
return new Promise(resolve => {
form.validate(res => {
resolve(res);
})
})
},
handleClick(tab, event) {
// console.log(tab, event);
},
rollback () {
this.$router.push('/tool/server')
}
}
};
</script>

View File

@ -0,0 +1,84 @@
<template>
<el-form :model="info" ref="genInfoForm">
<el-row class="form-row" :gutter="24">
<el-col :lg="{span: 6, offset: 6}" :md="12" :sm="24">
<el-form-item >
<span slot="label">生成模板
</span>
<el-tooltip content="树表没有分页,数据展示为树形表格" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
<br>
<el-select v-model="info.tplCategory" disabled="">
<el-option value="crud">单表增删改查</el-option>
<el-option value="tree">树表增删改查</el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :lg="{span: 6, offset: 1}" :md="12" :sm="24">
<el-form-item>
<span slot="label">生成包路径
</span>
<el-tooltip content="生成在哪个java包下例如 com.ruoyi.system" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
<el-input v-model="info.packageName"/>
</el-form-item>
</el-col>
</el-row>
<el-row class="form-row" :gutter="24">
<el-col :lg="{span: 6, offset: 6}" :md="12" :sm="24">
<el-form-item>
<span slot="label">生成模块名
</span>
<el-tooltip content="可理解为子系统名,例如 system" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
<el-input v-model="info.moduleName"/>
</el-form-item>
</el-col>
<el-col :lg="{span: 6, offset: 1}" :md="12" :sm="24">
<el-form-item>
<span slot="label">生成业务名
</span>
<el-tooltip content="可理解为功能英文名,例如 user" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
<el-input v-model="info.businessName"/>
</el-form-item>
</el-col>
</el-row>
<el-row class="form-row" :gutter="24">
<el-col :lg="{span: 6, offset: 6}" :md="12" :sm="24">
<el-form-item>
<span slot="label">生成功能名
</span>
<el-tooltip content="用作类描述,例如 用户" placement="top">
<i class="el-icon-question"></i>
</el-tooltip>
<el-input v-model="info.functionName"/>
</el-form-item>
</el-col>
</el-row>
</el-form>
</template>
<script>
export default {
name: 'BasicInfoForm',
props: {
info: {
type: Object,
default: null
}
},
data () {
return {
visible:false,
mdl: {}
}
},
created(){
}
}
</script>