代码生成 web界面

This commit is contained in:
stivepeim
2022-09-08 15:39:41 +08:00
parent 800b1b54a8
commit d3b93d20fd
10 changed files with 152 additions and 47 deletions

View File

@@ -0,0 +1,29 @@
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import request from '@/utils/request'
/**
* 查询待生成代码列表
* @param pram
*/
export function getCodegenList(pram) {
const data = {
page: pram.page,
limit: pram.limit,
tableName: pram.tableName
}
return request({
url: '/codegen/list',
method: 'GET',
params: data
})
}

View File

@@ -29,6 +29,7 @@ import operationRouter from './modules/operation'
import appSettingRouter from './modules/appSetting'
import maintainRouter from './modules/maintain'
import mobileRouter from './modules/mobile'
import codegen from './modules/codegen'
/**
@@ -82,7 +83,9 @@ export const constantRoutes = [
maintainRouter,
//移动端管理
mobileRouter,
// 代码生成
codegen,
{
path: '/404',
component: () => import('@/views/error-page/404'),

View File

@@ -11,45 +11,20 @@
import Layout from '@/layout'
const storeRouter = {
path: '/store',
path: '/codegen',
component: Layout,
redirect: '/store/index',
redirect: '/codegen/codegenList',
name: 'Store',
meta: {
title: '商品',
title: '代码生成',
icon: 'clipboard'
},
children: [
{
path: 'index',
component: () => import('@/views/store/index'),
path: 'codegenList',
component: () => import('@/views/codegen/codegenList'),
name: 'StoreIndex',
meta: { title: '商品管理', icon: '' }
},
{
path: 'sort',
component: () => import('@/views/store/sort/index'),
name: 'Sort',
meta: { title: '商品分类', icon: '' }
},
{
path: 'attr',
component: () => import('@/views/store/storeAttr/index'),
name: 'SortAttr',
meta: { title: '商品规格', icon: '' }
},
{
path: 'comment',
component: () => import('@/views/store/storeComment/index'),
name: 'StoreComment',
meta: { title: '商品评论', icon: '' }
},
{
path: 'list/creatProduct/:id?/:isDisabled?',
component: () => import('@/views/store/creatStore/index'),
name: 'SortCreat',
meta: { title: '商品添加', noCache: true, activeMenu: `/store/index` },
hidden: true
meta: { title: '待生成列表', icon: '' }
}
]
}

View File

@@ -1,10 +1,107 @@
<template>
$END$
<div class="divBox">
<el-card class="box-card">
<div slot="header" class="clearfix">
<div class="container">
<el-form inline size="small" @submit.native.prevent>
<el-form-item label="关键字">
<el-input v-model="codeListData.pram.tableName" placeholder="表名称" clearable size="small">
<el-button slot="append" icon="el-icon-search" size="small" @click="handlerSearch" />
</el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" @click.native="handleGenCode" :disabled="codeListData.selectedTables.length === 0">生成代码</el-button>
</el-form-item>
</el-form>
</div>
</div>
<el-table
ref="codeList"
:data="codeListData.data.list"
:highlight-current-row="true"
size="mini"
class="table"
@selection-change="handleSelectionChange"
:header-cell-style=" {fontWeight:'bold'}">
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column label="表名称" prop="tableName" min-width="180"/>
<el-table-column label="表描述" prop="tableComment" min-width="180"/>
<el-table-column label="创建时间" prop="createTime" min-width="200" />
</el-table>
<el-pagination
:current-page="codeListData.pram.page"
:page-sizes="constants.page.limit"
:layout="constants.page.layout"
:total="codeListData.data.totalCount"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</el-card>
</div>
</template>
<script>
import { getCodegenList } from '@/api/codegen'
import SettingMer from "@/utils/settingMer";
export default {
name: "codegenList"
name: "codegenList",
data(){
return{
constants: this.$constants,
codeListData:{
pram:{
page: 1,
limit: 10,
tableName: ''
},
data:{
list:[],
totalCount:0
},
selectedTables:[]
}
}
},
created(){
},
mounted(){
},
methods: {
handlerSearch(){
this.codeListData.pram.limit = 10;
this.codeListData.pram.page = 1;
this.getList(this.codeListData.pram);
},
getList(pram){
getCodegenList(pram).then(res => {
this.codeListData.data = res;
})
},
handleSizeChange(val) {
this.codeListData.pram.limit = val
this.getList(this.codeListData.pram)
},
handleCurrentChange(val) {
this.codeListData.pram.page = val
this.getList(this.codeListData.pram)
},
handleSelectionChange(selectedRows){
this.codeListData.selectedTables = [];
selectedRows.forEach(row => {
this.codeListData.selectedTables.push(row.tableName);
});
},
handleGenCode(){
window.open(`${SettingMer.apiBaseURL}codegen/code?tables=${this.codeListData.selectedTables.join(",")}`);
}
}
}
</script>