Commit 91c44437 by dqjdda

代码生成器优化完成,剩余:预览,打包下载,关联实体未完成

parent a4d74a3a
import request from '@/utils/request'
// export function getAllTable() {
// return request({
// url: 'api/generator?tableName=' + tableName,
// data,
// method: 'post'
// })
// }
export function getAllTable() {
return request({
url: 'api/generator/tables/all',
method: 'get'
})
}
export function generator(data, tableName) {
export function generator(tableName, type) {
return request({
url: 'api/generator?tableName=' + tableName,
data,
url: 'api/generator/' + tableName + '/' + type,
method: 'post'
})
}
......
......@@ -5,7 +5,7 @@
<el-col style="margin-bottom: 10px">
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">字段配置</span>
<span class="role-span">字段配置{{ tableName }}</span>
<el-button
:loading="columnLoading"
icon="el-icon-check"
......@@ -16,7 +16,6 @@
</div>
<el-form size="small" label-width="90px">
<el-table v-loading="loading" :data="data" :max-height="tableHeight" size="small" style="width: 100%;margin-bottom: 15px">
<el-table-column prop="tableName" label="表名"/>
<el-table-column prop="columnName" label="字段名称"/>
<el-table-column prop="columnType" label="字段类型"/>
<el-table-column prop="remark" label="字段描述">
......@@ -24,17 +23,17 @@
<el-input v-model="data[scope.$index].remark" size="mini" class="edit-input"/>
</template>
</el-table-column>
<el-table-column align="center" label="必填">
<el-table-column align="center" label="必填" width="70px">
<template slot-scope="scope">
<el-checkbox v-model="data[scope.$index].notNull"/>
</template>
</el-table-column>
<el-table-column align="center" label="列表">
<el-table-column align="center" label="列表" width="70px">
<template slot-scope="scope">
<el-checkbox v-model="data[scope.$index].listShow"/>
</template>
</el-table-column>
<el-table-column align="center" label="表单">
<el-table-column align="center" label="表单" width="70px">
<template slot-scope="scope">
<el-checkbox v-model="data[scope.$index].formShow"/>
</template>
......@@ -55,9 +54,6 @@
label="下拉框"
value="Select"/>
<el-option
label="复选框"
value="Checkbox"/>
<el-option
label="日期框"
value="Date"/>
</el-select>
......@@ -81,6 +77,21 @@
<el-option
label="Like"
value="Like"/>
<el-option
label="DateRange"
value="DateRange"/>
</el-select>
</template>
</el-table-column>
<el-table-column label="日期注解">
<template slot-scope="scope">
<el-select v-model="data[scope.$index].dateAnnotation" filterable class="edit-input" clearable size="mini" placeholder="请选择">
<el-option
label="自动创建时间"
value="CreationTimestamp"/>
<el-option
label="自动更新时间"
value="UpdateTimestamp"/>
</el-select>
</template>
</el-table-column>
......@@ -93,13 +104,8 @@
</el-table-column>
<el-table-column label="实体关联">
<template slot-scope="scope">
<el-select v-model="data[scope.$index].joinName" filterable class="edit-input" clearable size="mini" placeholder="请选择">
<el-option
label="模糊查询"
value="1"/>
<el-option
label="精确查询"
value="2"/>
<el-select v-model="data[scope.$index].joinName" filterable class="edit-input" clearable size="mini" placeholder="请选择" @change="toConfig">
<el-option v-for="item in tables" :key="item[0]" :label="item[0]" :value="item[0]"/>
</el-select>
</template>
</el-table-column>
......@@ -149,7 +155,7 @@
<el-radio-button label="true"></el-radio-button>
<el-radio-button label="false"></el-radio-button>
</el-radio-group>
<span style="color: #C0C0C0;margin-left: 10px;">危险选型,请考虑后选择</span>
<span style="color: #C0C0C0;margin-left: 10px;">谨防误操作,请慎重选择</span>
</el-form-item>
</el-form>
</el-card>
......@@ -161,7 +167,7 @@
<script>
import initData from '@/mixins/initData'
import { update, get } from '@/api/genConfig'
import { save } from '@/api/generator'
import { save, getAllTable } from '@/api/generator'
import { getDicts } from '@/api/dict'
export default {
name: 'GeneratorConfig',
......@@ -169,7 +175,7 @@ export default {
mixins: [initData],
data() {
return {
activeName: 'first', tableName: '', tableHeight: 550, columnLoading: false, configLoading: false, dicts: [],
activeName: 'first', tableName: '', tableHeight: 550, columnLoading: false, configLoading: false, dicts: [], tables: [],
form: { id: null, tableName: '', author: '', pack: '', path: '', moduleName: '', cover: 'false', apiPath: '', prefix: '' },
rules: {
author: [
......@@ -202,6 +208,9 @@ export default {
getDicts().then(data => {
this.dicts = data
})
getAllTable().then(data => {
this.tables = data
})
})
},
methods: {
......@@ -244,6 +253,11 @@ export default {
})
}
})
},
toConfig(tableName) {
if (tableName) {
this.$router.push('/sys-tools/generator/config/' + tableName)
}
}
}
}
......
......@@ -29,7 +29,7 @@
编辑
</router-link>
</el-button>
<el-button type="text" style="margin-left: -1px" size="mini">生成</el-button>
<el-button type="text" style="margin-left: -1px" size="mini" @click="toGen(scope.row.tableName)">生成</el-button>
</template>
</el-table-column>
</el-table>
......@@ -47,6 +47,7 @@
<script>
import initData from '@/mixins/initData'
import { parseTime } from '@/utils/index'
import { generator } from '@/api/generator'
export default {
name: 'GeneratorIndex',
mixins: [initData],
......@@ -91,17 +92,14 @@ export default {
if (name) { this.params['name'] = name }
return true
},
cancel() {
this.resetForm()
},
doSubmit() {
this.$refs['form'].validate((valid) => {
if (valid) {
this.loading = true
this.doUpdate()
} else {
return false
}
toGen(tableName) {
// 生成代码
generator(tableName, 0).then(data => {
this.$notify({
title: '生成成功',
type: 'success',
duration: 2500
})
})
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment