代码生成补充
This commit is contained in:
parent
035d23078b
commit
b50400af3f
@ -1,101 +1,115 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Router from 'vue-router'
|
import Router from 'vue-router'
|
||||||
|
|
||||||
Vue.use(Router)
|
Vue.use(Router)
|
||||||
|
|
||||||
/* Layout */
|
/* Layout */
|
||||||
import Layout from '@/layout'
|
import Layout from '@/layout'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: 路由配置项
|
* Note: 路由配置项
|
||||||
*
|
*
|
||||||
* hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
|
* hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
|
||||||
* alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
|
* alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
|
||||||
* // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
|
* // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
|
||||||
* // 若你想不管路由下面的 children 声明的个数都显示你的根路由
|
* // 若你想不管路由下面的 children 声明的个数都显示你的根路由
|
||||||
* // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
|
* // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
|
||||||
* redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
|
* redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
|
||||||
* name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
|
* name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
|
||||||
* meta : {
|
* meta : {
|
||||||
roles: ['admin','editor'] // 设置该路由进入的权限,支持多个权限叠加
|
roles: ['admin','editor'] // 设置该路由进入的权限,支持多个权限叠加
|
||||||
title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
|
title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
|
||||||
icon: 'svg-name' // 设置该路由的图标,对应路径src/icons/svg
|
icon: 'svg-name' // 设置该路由的图标,对应路径src/icons/svg
|
||||||
breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
|
breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 公共路由
|
// 公共路由
|
||||||
export const constantRoutes = [
|
export const constantRoutes = [
|
||||||
{
|
{
|
||||||
path: '/redirect',
|
path: '/redirect',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '/redirect/:path*',
|
path: '/redirect/:path*',
|
||||||
component: () => import('@/views/redirect')
|
component: () => import('@/views/redirect')
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/login',
|
path: '/login',
|
||||||
component: () => import('@/views/login'),
|
component: () => import('@/views/login'),
|
||||||
hidden: true
|
hidden: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/404',
|
path: '/404',
|
||||||
component: () => import('@/views/error/404'),
|
component: () => import('@/views/error/404'),
|
||||||
hidden: true
|
hidden: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/401',
|
path: '/401',
|
||||||
component: () => import('@/views/error/401'),
|
component: () => import('@/views/error/401'),
|
||||||
hidden: true
|
hidden: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
redirect: 'index',
|
redirect: 'index',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'index',
|
path: 'index',
|
||||||
component: () => import('@/views/index'),
|
component: () => import('@/views/index'),
|
||||||
name: '首页',
|
name: '首页',
|
||||||
meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true }
|
meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/user',
|
path: '/user',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
redirect: 'noredirect',
|
redirect: 'noredirect',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'profile',
|
path: 'profile',
|
||||||
component: () => import('@/views/system/user/profile/index'),
|
component: () => import('@/views/system/user/profile/index'),
|
||||||
name: '个人中心',
|
name: '个人中心',
|
||||||
meta: { title: '个人中心', icon: 'user' }
|
meta: { title: '个人中心', icon: 'user' }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/dict',
|
path: '/dict',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'type/data/:dictId(\\d+)',
|
path: 'type/data/:dictId(\\d+)',
|
||||||
component: () => import('@/views/system/dict/data'),
|
component: () => import('@/views/system/dict/data'),
|
||||||
name: '字典数据',
|
name: '字典数据',
|
||||||
meta: { title: '字典数据', icon: '' }
|
meta: { title: '字典数据', icon: '' }
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
]
|
|
||||||
|
{
|
||||||
export default new Router({
|
path: '/gen',
|
||||||
mode: 'history', // 去掉url中的#
|
component: Layout,
|
||||||
scrollBehavior: () => ({ y: 0 }),
|
hidden: true,
|
||||||
routes: constantRoutes
|
children: [
|
||||||
})
|
{
|
||||||
|
path: 'edit',
|
||||||
|
component: () => import('@/views/tool/gen/edit'),
|
||||||
|
name: 'genEdit',
|
||||||
|
meta: { title: '修改生成配置' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
export default new Router({
|
||||||
|
mode: 'history', // 去掉url中的#
|
||||||
|
scrollBehavior: () => ({ y: 0 }),
|
||||||
|
routes: constantRoutes
|
||||||
|
})
|
||||||
|
72
ruoyi-ui/src/views/tool/gen/basicInfoForm.vue
Normal file
72
ruoyi-ui/src/views/tool/gen/basicInfoForm.vue
Normal 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>
|
165
ruoyi-ui/src/views/tool/gen/edit.vue
Normal file
165
ruoyi-ui/src/views/tool/gen/edit.vue
Normal 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">></el-option>
|
||||||
|
<el-option value="GTE">>=</el-option>
|
||||||
|
<el-option value="LT">></el-option>
|
||||||
|
<el-option value="LTE">>=</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>
|
84
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
Normal file
84
ruoyi-ui/src/views/tool/gen/genInfoForm.vue
Normal 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>
|
Loading…
x
Reference in New Issue
Block a user