Pre Merge pull request !3 from wind/master
This commit is contained in:
66
ruoyi-ui/src/api/tool/gen.js
Normal file
66
ruoyi-ui/src/api/tool/gen.js
Normal file
@ -0,0 +1,66 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询
|
||||
export function listTable(query) {
|
||||
return request({
|
||||
url: '/tool/gen/list',
|
||||
method: 'post',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
// 查询db数据库列表
|
||||
export function listdbTable(query) {
|
||||
return request({
|
||||
url: '/tool/gen/db/list',
|
||||
method: 'post',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
// 导出table
|
||||
export function exportTable(data) {
|
||||
return request({
|
||||
url: '/tool/gen/list/'+data,
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
// 查询更改表信息
|
||||
export function editTableInfo(data) {
|
||||
return request({
|
||||
url: '/tool/gen/edit',
|
||||
method: 'get',
|
||||
params:data
|
||||
})
|
||||
}
|
||||
|
||||
// 更改表请求
|
||||
export function editGenInfo(data) {
|
||||
return request({
|
||||
url: '/tool/gen/edit',
|
||||
method: 'post',
|
||||
data:data
|
||||
})
|
||||
}
|
||||
// 导入表
|
||||
export function importTable(data) {
|
||||
return request({
|
||||
url: '/tool/gen/importTable',
|
||||
method: 'post',
|
||||
params:data
|
||||
})
|
||||
}
|
||||
// 预览
|
||||
export function previewTable(data) {
|
||||
return request({
|
||||
url: '/tool/gen/preview/'+data,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
// 移除tableid
|
||||
export function removeTable(data) {
|
||||
return request({
|
||||
url: '/tool/gen/remove',
|
||||
method: 'post',
|
||||
params:data
|
||||
})
|
||||
}
|
||||
|
@ -1,101 +1,115 @@
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
/* Layout */
|
||||
import Layout from '@/layout'
|
||||
|
||||
/**
|
||||
* Note: 路由配置项
|
||||
*
|
||||
* hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
|
||||
* alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
|
||||
* // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
|
||||
* // 若你想不管路由下面的 children 声明的个数都显示你的根路由
|
||||
* // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
|
||||
* redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
|
||||
* name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
|
||||
* meta : {
|
||||
roles: ['admin','editor'] // 设置该路由进入的权限,支持多个权限叠加
|
||||
title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
|
||||
icon: 'svg-name' // 设置该路由的图标,对应路径src/icons/svg
|
||||
breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
|
||||
}
|
||||
*/
|
||||
|
||||
// 公共路由
|
||||
export const constantRoutes = [
|
||||
{
|
||||
path: '/redirect',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: '/redirect/:path*',
|
||||
component: () => import('@/views/redirect')
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
component: () => import('@/views/login'),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/404',
|
||||
component: () => import('@/views/error/404'),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/401',
|
||||
component: () => import('@/views/error/401'),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
component: Layout,
|
||||
redirect: 'index',
|
||||
children: [
|
||||
{
|
||||
path: 'index',
|
||||
component: () => import('@/views/index'),
|
||||
name: '首页',
|
||||
meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/user',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
redirect: 'noredirect',
|
||||
children: [
|
||||
{
|
||||
path: 'profile',
|
||||
component: () => import('@/views/system/user/profile/index'),
|
||||
name: '个人中心',
|
||||
meta: { title: '个人中心', icon: 'user' }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/dict',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: 'type/data/:dictId(\\d+)',
|
||||
component: () => import('@/views/system/dict/data'),
|
||||
name: '字典数据',
|
||||
meta: { title: '字典数据', icon: '' }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
export default new Router({
|
||||
mode: 'history', // 去掉url中的#
|
||||
scrollBehavior: () => ({ y: 0 }),
|
||||
routes: constantRoutes
|
||||
})
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
/* Layout */
|
||||
import Layout from '@/layout'
|
||||
|
||||
/**
|
||||
* Note: 路由配置项
|
||||
*
|
||||
* hidden: true // 当设置 true 的时候该路由不会再侧边栏出现 如401,login等页面,或者如一些编辑页面/edit/1
|
||||
* alwaysShow: true // 当你一个路由下面的 children 声明的路由大于1个时,自动会变成嵌套的模式--如组件页面
|
||||
* // 只有一个时,会将那个子路由当做根路由显示在侧边栏--如引导页面
|
||||
* // 若你想不管路由下面的 children 声明的个数都显示你的根路由
|
||||
* // 你可以设置 alwaysShow: true,这样它就会忽略之前定义的规则,一直显示根路由
|
||||
* redirect: noRedirect // 当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
|
||||
* name:'router-name' // 设定路由的名字,一定要填写不然使用<keep-alive>时会出现各种问题
|
||||
* meta : {
|
||||
roles: ['admin','editor'] // 设置该路由进入的权限,支持多个权限叠加
|
||||
title: 'title' // 设置该路由在侧边栏和面包屑中展示的名字
|
||||
icon: 'svg-name' // 设置该路由的图标,对应路径src/icons/svg
|
||||
breadcrumb: false // 如果设置为false,则不会在breadcrumb面包屑中显示
|
||||
}
|
||||
*/
|
||||
|
||||
// 公共路由
|
||||
export const constantRoutes = [
|
||||
{
|
||||
path: '/redirect',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: '/redirect/:path*',
|
||||
component: () => import('@/views/redirect')
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
component: () => import('@/views/login'),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/404',
|
||||
component: () => import('@/views/error/404'),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '/401',
|
||||
component: () => import('@/views/error/401'),
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
component: Layout,
|
||||
redirect: 'index',
|
||||
children: [
|
||||
{
|
||||
path: 'index',
|
||||
component: () => import('@/views/index'),
|
||||
name: '首页',
|
||||
meta: { title: '首页', icon: 'dashboard', noCache: true, affix: true }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/user',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
redirect: 'noredirect',
|
||||
children: [
|
||||
{
|
||||
path: 'profile',
|
||||
component: () => import('@/views/system/user/profile/index'),
|
||||
name: '个人中心',
|
||||
meta: { title: '个人中心', icon: 'user' }
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/dict',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: 'type/data/:dictId(\\d+)',
|
||||
component: () => import('@/views/system/dict/data'),
|
||||
name: '字典数据',
|
||||
meta: { title: '字典数据', icon: '' }
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
path: '/gen',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
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
|
||||
})
|
||||
|
@ -1,95 +1,96 @@
|
||||
/**
|
||||
* 通用js方法封装处理
|
||||
* Copyright (c) 2019 ruoyi
|
||||
*/
|
||||
|
||||
const baseURL = process.env.VUE_APP_BASE_API
|
||||
|
||||
// 日期格式化
|
||||
export function parseTime(time, pattern) {
|
||||
if (arguments.length === 0) {
|
||||
return null
|
||||
}
|
||||
const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
|
||||
let date
|
||||
if (typeof time === 'object') {
|
||||
date = time
|
||||
} else {
|
||||
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
|
||||
time = parseInt(time)
|
||||
}
|
||||
if ((typeof time === 'number') && (time.toString().length === 10)) {
|
||||
time = time * 1000
|
||||
}
|
||||
date = new Date(time)
|
||||
}
|
||||
const formatObj = {
|
||||
y: date.getFullYear(),
|
||||
m: date.getMonth() + 1,
|
||||
d: date.getDate(),
|
||||
h: date.getHours(),
|
||||
i: date.getMinutes(),
|
||||
s: date.getSeconds(),
|
||||
a: date.getDay()
|
||||
}
|
||||
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
|
||||
let value = formatObj[key]
|
||||
// Note: getDay() returns 0 on Sunday
|
||||
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
|
||||
if (result.length > 0 && value < 10) {
|
||||
value = '0' + value
|
||||
}
|
||||
return value || 0
|
||||
})
|
||||
return time_str
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
export function resetForm(refName) {
|
||||
if (this.$refs[refName] !== undefined) {
|
||||
this.$refs[refName].resetFields();
|
||||
}
|
||||
}
|
||||
|
||||
// 添加日期范围
|
||||
export function addDateRange(params, dateRange) {
|
||||
var search = params;
|
||||
if (null != dateRange) {
|
||||
search.params = {
|
||||
beginTime: this.dateRange[0],
|
||||
endTime: this.dateRange[1]
|
||||
};
|
||||
}
|
||||
return search;
|
||||
}
|
||||
|
||||
// 回显数据字典
|
||||
export function selectDictLabel(datas, value) {
|
||||
var actions = [];
|
||||
Object.keys(datas).map((key) => {
|
||||
if (datas[key].dictValue == ('' + value)) {
|
||||
actions.push(datas[key].dictLabel);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
return actions.join('');
|
||||
}
|
||||
|
||||
// 通用下载方法
|
||||
export function download(fileName) {
|
||||
window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
|
||||
}
|
||||
|
||||
// 字符串格式化(%s )
|
||||
export function sprintf(str) {
|
||||
var args = arguments, flag = true, i = 1;
|
||||
str = str.replace(/%s/g, function () {
|
||||
var arg = args[i++];
|
||||
if (typeof arg === 'undefined') {
|
||||
flag = false;
|
||||
return '';
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
return flag ? str : '';
|
||||
}
|
||||
/**
|
||||
* 通用js方法封装处理
|
||||
* Copyright (c) 2019 ruoyi
|
||||
*/
|
||||
|
||||
const baseURL = process.env.VUE_APP_BASE_API
|
||||
|
||||
// 日期格式化
|
||||
export function parseTime(time, pattern) {
|
||||
if (arguments.length === 0) {
|
||||
return null
|
||||
}
|
||||
const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
|
||||
let date
|
||||
if (typeof time === 'object') {
|
||||
date = time
|
||||
} else {
|
||||
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
|
||||
time = parseInt(time)
|
||||
}
|
||||
if ((typeof time === 'number') && (time.toString().length === 10)) {
|
||||
time = time * 1000
|
||||
}
|
||||
date = new Date(time)
|
||||
}
|
||||
const formatObj = {
|
||||
y: date.getFullYear(),
|
||||
m: date.getMonth() + 1,
|
||||
d: date.getDate(),
|
||||
h: date.getHours(),
|
||||
i: date.getMinutes(),
|
||||
s: date.getSeconds(),
|
||||
a: date.getDay()
|
||||
}
|
||||
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
|
||||
let value = formatObj[key]
|
||||
// Note: getDay() returns 0 on Sunday
|
||||
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
|
||||
if (result.length > 0 && value < 10) {
|
||||
value = '0' + value
|
||||
}
|
||||
return value || 0
|
||||
})
|
||||
return time_str
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
export function resetForm(refName) {
|
||||
if (this.$refs[refName] !== undefined) {
|
||||
this.$refs[refName].resetFields();
|
||||
}
|
||||
}
|
||||
|
||||
// 添加日期范围
|
||||
export function addDateRange(params, dateRange) {
|
||||
var search = params;
|
||||
search.params=[]
|
||||
if (null != dateRange) {
|
||||
search.params = {
|
||||
beginTime: this.dateRange[0],
|
||||
endTime: this.dateRange[1]
|
||||
};
|
||||
}
|
||||
return search;
|
||||
}
|
||||
|
||||
// 回显数据字典
|
||||
export function selectDictLabel(datas, value) {
|
||||
var actions = [];
|
||||
Object.keys(datas).map((key) => {
|
||||
if (datas[key].dictValue == ('' + value)) {
|
||||
actions.push(datas[key].dictLabel);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
return actions.join('');
|
||||
}
|
||||
|
||||
// 通用下载方法
|
||||
export function download(fileName) {
|
||||
window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
|
||||
}
|
||||
|
||||
// 字符串格式化(%s )
|
||||
export function sprintf(str) {
|
||||
var args = arguments, flag = true, i = 1;
|
||||
str = str.replace(/%s/g, function () {
|
||||
var arg = args[i++];
|
||||
if (typeof arg === 'undefined') {
|
||||
flag = false;
|
||||
return '';
|
||||
}
|
||||
return arg;
|
||||
});
|
||||
return flag ? str : '';
|
||||
}
|
||||
|
40
ruoyi-ui/src/utils/zipdownload.js
Normal file
40
ruoyi-ui/src/utils/zipdownload.js
Normal file
@ -0,0 +1,40 @@
|
||||
import axios from 'axios'
|
||||
import { getToken } from '@/utils/auth'
|
||||
|
||||
const mimeMap = {
|
||||
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
zip: 'application/zip'
|
||||
}
|
||||
|
||||
const baseUrl = process.env.VUE_APP_BASE_API
|
||||
export function downLoadZip(str, filename) {
|
||||
var url = baseUrl + str
|
||||
axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
responseType: 'blob',
|
||||
headers: {'Authorization':'Bearer ' + getToken()}
|
||||
}).then(res => {
|
||||
resolveBlob(res, mimeMap.zip)
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 解析blob响应内容并下载
|
||||
* @param {*} res blob响应内容
|
||||
* @param {String} mimeType MIME类型
|
||||
*/
|
||||
export function resolveBlob (res, mimeType) {
|
||||
const aLink = document.createElement('a')
|
||||
var blob = new Blob([res.data], { type: mimeType })
|
||||
// //从response的headers中获取filename, 后端response.setHeader("Content-disposition", "attachment; filename=xxxx.docx") 设置的文件名;
|
||||
var patt = new RegExp('filename=([^;]+\\.[^\\.;]+);*')
|
||||
var contentDisposition = decodeURI(res.headers['content-disposition'])
|
||||
var result = patt.exec(contentDisposition)
|
||||
var fileName = result[1]
|
||||
fileName=fileName.replace(/\"/g,'')
|
||||
aLink.href = URL.createObjectURL(blob)
|
||||
aLink.setAttribute('download', fileName) // 设置下载文件名称
|
||||
document.body.appendChild(aLink)
|
||||
aLink.click()
|
||||
document.body.appendChild(aLink)
|
||||
}
|
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>
|
141
ruoyi-ui/src/views/tool/gen/dailog/importDailog.vue
Normal file
141
ruoyi-ui/src/views/tool/gen/dailog/importDailog.vue
Normal file
@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<!-- 导入表 -->
|
||||
<el-dialog title="导入表" :visible.sync="visible" width="800px">
|
||||
<el-form :model="queryParams" ref="importQueryForm" :inline="true" label-width="68px">
|
||||
<el-form-item label="表名称" prop="tableName">
|
||||
<el-input
|
||||
v-model="queryParams.tableName"
|
||||
placeholder="请输入表名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="表描述" prop="tableComment">
|
||||
<el-input
|
||||
v-model="queryParams.tableComment"
|
||||
placeholder="请输入表描述"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-button type="text" style="margin-left: 20px" @click="handleImportSearch">搜索</el-button>
|
||||
<el-button type="text" style="margin-left: 20px" @click="handleImportReset">重置</el-button>
|
||||
</el-form>
|
||||
<el-row>
|
||||
<el-table
|
||||
:data="dbTableList"
|
||||
@selection-change="handleSelectionChange"
|
||||
style="width: 100%;">
|
||||
<el-table-column
|
||||
type="selection"
|
||||
width="55"></el-table-column>
|
||||
<el-table-column
|
||||
prop="tableName"
|
||||
label="表名称"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="tableComment"
|
||||
label="表描述"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="createTime"
|
||||
label="创建时间"
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="updateTime"
|
||||
label="更新时间"
|
||||
>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="handleDbList"
|
||||
/>
|
||||
</el-row>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="handleImportTable">确 定</el-button>
|
||||
<el-button @click="handleImportCancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listdbTable,importTable } from '@/api/tool/gen'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
center: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
tables: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
queryParams:
|
||||
{
|
||||
tableName:'',
|
||||
tableComment:'',
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
},
|
||||
dbTableList:[],
|
||||
total:0
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.handleImportSearch()
|
||||
},
|
||||
methods: {
|
||||
show(){
|
||||
this.visible=true
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.tableId)
|
||||
this.tables = selection.map(item => item.tableName)
|
||||
this.single = selection.length!=1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
handleImportSearch()
|
||||
{
|
||||
this.queryParams.pageNum=1
|
||||
this.handleDbList()
|
||||
},
|
||||
handleDbList()
|
||||
{
|
||||
listdbTable(this.queryParams).then(res => {
|
||||
if(res.code===200){
|
||||
this.dbTableList = res.rows
|
||||
this.total=res.total
|
||||
}
|
||||
})
|
||||
},
|
||||
handleImportReset(){
|
||||
this.resetForm("importQueryForm");
|
||||
},
|
||||
handleImportTable()//导入table
|
||||
{
|
||||
importTable({tables:this.tables.join(",")}).then(res => {
|
||||
this.msgSuccess(res.msg);
|
||||
if (res.code === 200) {
|
||||
this.visible=false
|
||||
this.$emit('ok');
|
||||
}
|
||||
})
|
||||
},
|
||||
handleImportCancel(){
|
||||
this.visible=false
|
||||
},
|
||||
}
|
||||
};
|
||||
</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>
|
@ -1,5 +1,244 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
代码生成
|
||||
</div>
|
||||
</template>
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
|
||||
<el-form-item label="表名称" prop="tableName">
|
||||
<el-input
|
||||
v-model="queryParams.tableName"
|
||||
placeholder="请输入表名称"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="表描述" prop="tableComment">
|
||||
<el-input
|
||||
v-model="queryParams.tableComment"
|
||||
placeholder="请输入表描述"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleBatchGenTable"
|
||||
v-hasPermi="['system:post:add']"
|
||||
>生成</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
icon="el-icon-upload"
|
||||
size="mini"
|
||||
@click="handleImport"
|
||||
v-hasPermi="['system:post:add']"
|
||||
>导入</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleEditTable"
|
||||
v-hasPermi="['system:post:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['system:post:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
:data="tableList"
|
||||
style="width: 100% ;margin-top: 10px"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column
|
||||
type="selection"
|
||||
width="30"></el-table-column>
|
||||
<el-table-column label="序号" align="center" prop="tableId" width="50px"/>
|
||||
<el-table-column label="表名称" align="center" prop="tableName" />
|
||||
<el-table-column label="表描述" align="center" prop="tableComment" />
|
||||
<el-table-column label="实体" align="center" prop="className" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
min-width="180px"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button type="text" size="small" icon="el-icon-view" @click="handlepreView(scope.row)">预览</el-button>
|
||||
<el-button type="text" size="small" icon="el-icon-edit" @click="handleEditTable(scope.row)">编辑</el-button>
|
||||
<el-button type="text" size="small" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
<el-button type="text" size="small" icon="el-icon-download"@click="handleGenTable(scope.row.tableName)">生成代码</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
<!-- 预览界面 -->
|
||||
<el-dialog :title="title" :visible.sync="preDialog.open" width="900px" lock-scroll>
|
||||
<el-tabs v-model="vm.activeName" type="card">
|
||||
<el-tab-pane :label="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))" v-for="(value, key) in preDialog.preData" :key="key">
|
||||
<pre>{{ value }}</pre>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-dialog>
|
||||
<import-dailog ref="import" @ok="handleQuery"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listTable,listdbTable,importTable,previewTable,removeTable } from '@/api/tool/gen'
|
||||
import importDailog from './dailog/importDailog';
|
||||
import { downLoadZip } from '@/utils/zipdownload'
|
||||
export default {
|
||||
components: { importDailog },
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
tableNames: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 岗位表格数据
|
||||
tableList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 状态数据字典
|
||||
statusOptions: [],
|
||||
// 日期范围
|
||||
dateRange: '',
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
tableName: undefined,
|
||||
tableComment: undefined
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
vm:{
|
||||
activeName:"0"
|
||||
},
|
||||
preDialog:{
|
||||
open: false,
|
||||
preData:{}
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
/** 查询岗位列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||
this.tableList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
console.log("handleQuery")
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
handleGenTable(tabelname){
|
||||
downLoadZip('tool/gen/genCode/'+tabelname, 'ruoyi')
|
||||
},
|
||||
handleBatchGenTable(tabelname){
|
||||
downLoadZip('tool/gen/batchGenCode?tables='+this.tableNames.join(','), 'ruoyi')
|
||||
},
|
||||
handleImport(){
|
||||
this.$refs.import.show()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRange = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
handlepreView(row){
|
||||
previewTable(row.tableId).then(response => {
|
||||
this.title="代码预览"
|
||||
this.preDialog.preData = response.data
|
||||
this.preDialog.open=true
|
||||
})
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.tableId)
|
||||
this.tableNames = selection.map(item => item.tableName)
|
||||
this.single = selection.length!=1
|
||||
this.multiple = !selection.length
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleEditTable(row) {
|
||||
const tableId = row.tableId || this.ids[0]
|
||||
console.log(tableId)
|
||||
this.$router.push({ path: '/gen/edit',query: { tableId: tableId } });
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const tableIds = row.tableId || this.ids.join(',');
|
||||
this.$confirm('是否确认删除表编号为"' + tableIds + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return removeTable({ids:tableIds});
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
}).catch(function() {});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user