QM303176530
5 years ago
17 changed files with 234 additions and 815 deletions
-
84QMPlusServer/autoCode/fe/autocode/api/api.js
-
118QMPlusServer/autoCode/te/autocode/api/api.go
-
52QMPlusServer/autoCode/te/autocode/model/model.go
-
18QMPlusServer/autoCode/te/autocode/router/router.go
-
33QMPlusServer/controller/api/sys_autoCode.go
-
3QMPlusServer/init/initRouter/init_router.go
-
2QMPlusServer/main.go
-
188QMPlusServer/model/autoCodeModel/autoCode.go
-
7QMPlusServer/model/autoCodeModel/autoCode_test.go
-
14QMPlusServer/router/sys_autoCode.go
-
57QMPlusServer/tools/zipfiles.go
-
9QMPlusServer/tpl/readme.txt.tpl
-
4QMPlusServer/tpl/te/model.go.tpl
-
182QMPlusVuePage/src/view/superAdmin/autoCode/component/componentDialog.vue
-
167QMPlusVuePage/src/view/superAdmin/autoCode/index.vue
-
1QMPlusVuePage/src/view/superAdmin/menu/menu.vue
-
110QMPlusVuePage/src/view/superAdmin/system/system.vue
@ -1,84 +0,0 @@ |
|||||
import service from '@/utils/request' |
|
||||
|
|
||||
// @Tags Test
|
|
||||
// @Summary 创建Test
|
|
||||
// @Security ApiKeyAuth
|
|
||||
// @accept application/json
|
|
||||
// @Produce application/json
|
|
||||
// @Param data body autocode.Test true "创建Test"
|
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
||||
// @Router /t/createTest [post]
|
|
||||
export const createTest = (data) => { |
|
||||
return service({ |
|
||||
url: "/t/createTest", |
|
||||
method: 'post', |
|
||||
data |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
|
|
||||
// @Tags Test
|
|
||||
// @Summary 删除Test
|
|
||||
// @Security ApiKeyAuth
|
|
||||
// @accept application/json
|
|
||||
// @Produce application/json
|
|
||||
// @Param data body autocode.Test true "删除Test"
|
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
|
||||
// @Router /t/deleteTest [post]
|
|
||||
export const deleteTest = (data) => { |
|
||||
return service({ |
|
||||
url: "/t/deleteTest", |
|
||||
method: 'post', |
|
||||
data |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
// @Tags Test
|
|
||||
// @Summary 更新Test
|
|
||||
// @Security ApiKeyAuth
|
|
||||
// @accept application/json
|
|
||||
// @Produce application/json
|
|
||||
// @Param data body autocode.Test true "更新Test"
|
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
|
||||
// @Router /t/updateTest [post]
|
|
||||
export const updateTest = (data) => { |
|
||||
return service({ |
|
||||
url: "/t/updateTest", |
|
||||
method: 'post', |
|
||||
data |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
|
|
||||
// @Tags Test
|
|
||||
// @Summary 用id查询Test
|
|
||||
// @Security ApiKeyAuth
|
|
||||
// @accept application/json
|
|
||||
// @Produce application/json
|
|
||||
// @Param data body autocode.Test true "用id查询Test"
|
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
|
||||
// @Router /t/findTest [post]
|
|
||||
export const findTest = (data) => { |
|
||||
return service({ |
|
||||
url: "/t/findTest", |
|
||||
method: 'post', |
|
||||
data |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
|
|
||||
// @Tags Test
|
|
||||
// @Summary 分页获取Test列表
|
|
||||
// @Security ApiKeyAuth
|
|
||||
// @accept application/json
|
|
||||
// @Produce application/json
|
|
||||
// @Param data body modelInterface.PageInfo true "分页获取Test列表"
|
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
||||
// @Router /t/getTestList [post]
|
|
||||
export const getTestList = (data) => { |
|
||||
return service({ |
|
||||
url: "/t/getTestList", |
|
||||
method: 'post', |
|
||||
data |
|
||||
}) |
|
||||
} |
|
@ -1,118 +0,0 @@ |
|||||
package api |
|
||||
|
|
||||
import ( |
|
||||
"fmt" |
|
||||
"gin-vue-admin/controller/servers" |
|
||||
"gin-vue-admin/model/modelInterface" |
|
||||
// 请自行引入model路径
|
|
||||
"github.com/gin-gonic/gin" |
|
||||
) |
|
||||
|
|
||||
|
|
||||
// @Tags Test
|
|
||||
// @Summary 创建Test
|
|
||||
// @Security ApiKeyAuth
|
|
||||
// @accept application/json
|
|
||||
// @Produce application/json
|
|
||||
// @Param data body autocode.Test true "创建Test"
|
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
||||
// @Router /t/createTest [post]
|
|
||||
func CreateTest(c *gin.Context) { |
|
||||
var t autocode.Test |
|
||||
_ = c.ShouldBindJSON(&t) |
|
||||
err := t.CreateTest() |
|
||||
if err != nil { |
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{}) |
|
||||
} else { |
|
||||
servers.ReportFormat(c, true, "创建成功", gin.H{}) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
// @Tags Test
|
|
||||
// @Summary 删除Test
|
|
||||
// @Security ApiKeyAuth
|
|
||||
// @accept application/json
|
|
||||
// @Produce application/json
|
|
||||
// @Param data body autocode.Test true "删除Test"
|
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
|
||||
// @Router /t/deleteTest [post]
|
|
||||
func DeleteTest(c *gin.Context) { |
|
||||
var t autocode.Test |
|
||||
_ = c.ShouldBindJSON(&t) |
|
||||
err := t.DeleteTest() |
|
||||
if err != nil { |
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("删除失败:%v", err), gin.H{}) |
|
||||
} else { |
|
||||
servers.ReportFormat(c, true, "创建成功", gin.H{}) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
// @Tags Test
|
|
||||
// @Summary 更新Test
|
|
||||
// @Security ApiKeyAuth
|
|
||||
// @accept application/json
|
|
||||
// @Produce application/json
|
|
||||
// @Param data body autocode.Test true "更新Test"
|
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
|
||||
// @Router /t/updateTest [post]
|
|
||||
func UpdateTest(c *gin.Context) { |
|
||||
var t autocode.Test |
|
||||
_ = c.ShouldBindJSON(&t) |
|
||||
err,ret := t.UpdateTest() |
|
||||
if err != nil { |
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("更新失败:%v", err), gin.H{}) |
|
||||
} else { |
|
||||
servers.ReportFormat(c, true, "更新成功", gin.H{ |
|
||||
"ret":ret, |
|
||||
}) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
// @Tags Test
|
|
||||
// @Summary 用id查询Test
|
|
||||
// @Security ApiKeyAuth
|
|
||||
// @accept application/json
|
|
||||
// @Produce application/json
|
|
||||
// @Param data body autocode.Test true "用id查询Test"
|
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
|
||||
// @Router /t/findTest [post]
|
|
||||
func FindTest(c *gin.Context) { |
|
||||
var t autocode.Test |
|
||||
_ = c.ShouldBindJSON(&t) |
|
||||
err,ret := t.FindById() |
|
||||
if err != nil { |
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("查询失败:%v", err), gin.H{}) |
|
||||
} else { |
|
||||
servers.ReportFormat(c, true, "查询成功", gin.H{ |
|
||||
"ret":ret, |
|
||||
}) |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
|
|
||||
// @Tags Test
|
|
||||
// @Summary 分页获取Test列表
|
|
||||
// @Security ApiKeyAuth
|
|
||||
// @accept application/json
|
|
||||
// @Produce application/json
|
|
||||
// @Param data body modelInterface.PageInfo true "分页获取Test列表"
|
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
|
||||
// @Router /t/getTestList [post]
|
|
||||
func GetTestList(c *gin.Context) { |
|
||||
var pageInfo modelInterface.PageInfo |
|
||||
_ = c.ShouldBindJSON(&pageInfo) |
|
||||
err, list, total := new(autocode.Test).GetInfoList(pageInfo) |
|
||||
if err != nil { |
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{}) |
|
||||
} else { |
|
||||
servers.ReportFormat(c, true, "获取数据成功", gin.H{ |
|
||||
"autocodeList": list, |
|
||||
"total": total, |
|
||||
"page": pageInfo.Page, |
|
||||
"pageSize": pageInfo.PageSize, |
|
||||
}) |
|
||||
} |
|
||||
} |
|
@ -1,52 +0,0 @@ |
|||||
// 自动生成模板Test
|
|
||||
package autocode |
|
||||
|
|
||||
import ( |
|
||||
"gin-vue-admin/controller/servers" |
|
||||
"gin-vue-admin/init/qmsql" |
|
||||
"gin-vue-admin/model/modelInterface" |
|
||||
"github.com/jinzhu/gorm" |
|
||||
) |
|
||||
|
|
||||
type Test struct { |
|
||||
gorm.Model |
|
||||
TestComponent string `json:"testComponent"` |
|
||||
TestBigComponent int `json:"testBigComponent"` |
|
||||
} |
|
||||
|
|
||||
// 创建Test
|
|
||||
func (t *Test)CreateTest()(err error){ |
|
||||
err = qmsql.DEFAULTDB.Create(t).Error |
|
||||
return err |
|
||||
} |
|
||||
|
|
||||
// 删除Test
|
|
||||
func (t *Test)DeleteTest()(err error){ |
|
||||
err = qmsql.DEFAULTDB.Delete(t).Error |
|
||||
return err |
|
||||
} |
|
||||
|
|
||||
// 更新Test
|
|
||||
func (t *Test)UpdateTest()(err error, ret Test){ |
|
||||
err = qmsql.DEFAULTDB.Save(t).Error |
|
||||
return err, *t |
|
||||
} |
|
||||
|
|
||||
// 根据ID查看单条Test
|
|
||||
func (t *Test)FindById()(err error,ret Test){ |
|
||||
err = qmsql.DEFAULTDB.Where("id = ?",t.ID).First(&ret).Error |
|
||||
return err,ret |
|
||||
} |
|
||||
|
|
||||
// 分页获取Test
|
|
||||
func (t *Test)GetInfoList(info modelInterface.PageInfo)(err error, list interface{}, total int){ |
|
||||
// 封装分页方法 调用即可 传入 当前的结构体和分页信息
|
|
||||
err, db, total := servers.PagingServer(t, info) |
|
||||
if err != nil { |
|
||||
return |
|
||||
} else { |
|
||||
var reTestList []Test |
|
||||
err = db.Find(&reTestList).Error |
|
||||
return err, reTestList, total |
|
||||
} |
|
||||
} |
|
@ -1,18 +0,0 @@ |
|||||
package router |
|
||||
|
|
||||
import ( |
|
||||
"gin-vue-admin/controller/api" |
|
||||
"gin-vue-admin/middleware" |
|
||||
"github.com/gin-gonic/gin" |
|
||||
) |
|
||||
|
|
||||
func InitTestRouter(Router *gin.RouterGroup) { |
|
||||
TestRouter := Router.Group("t").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()) |
|
||||
{ |
|
||||
TestRouter.POST("createTest", api.CreateTest) // 新建Test
|
|
||||
TestRouter.POST("deleteTest", api.DeleteTest) //删除Test
|
|
||||
TestRouter.POST("updateTest", api.UpdateTest) //更新Test
|
|
||||
TestRouter.POST("findTest ", api.FindTest) // 根据ID获取Test
|
|
||||
TestRouter.POST("getTestList", api.GetTestList) //获取Test列表
|
|
||||
} |
|
||||
} |
|
@ -0,0 +1,33 @@ |
|||||
|
package api |
||||
|
|
||||
|
import ( |
||||
|
"fmt" |
||||
|
"gin-vue-admin/controller/servers" |
||||
|
"gin-vue-admin/model/autoCodeModel" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
"os" |
||||
|
) |
||||
|
|
||||
|
// @Tags SysApi
|
||||
|
// @Summary 自动代码模板
|
||||
|
// @Security ApiKeyAuth
|
||||
|
// @accept application/json
|
||||
|
// @Produce application/json
|
||||
|
// @Param data body autoCodeModel.AutoCodeStruct true "创建自动代码"
|
||||
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
|
||||
|
// @Router /autoCode/createTemp [post]
|
||||
|
func CreateTemp(c *gin.Context) { |
||||
|
var a autoCodeModel.AutoCodeStruct |
||||
|
_ = c.ShouldBindJSON(&a) |
||||
|
err := a.CreateTemp() |
||||
|
if err != nil { |
||||
|
servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{}) |
||||
|
os.Remove("./ginvueadmin.zip") |
||||
|
} else { |
||||
|
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", "ginvueadmin.zip")) //fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名
|
||||
|
c.Writer.Header().Add("Content-Type", "application/json") |
||||
|
c.Writer.Header().Add("success", "true") |
||||
|
c.File("./ginvueadmin.zip") |
||||
|
os.Remove("./ginvueadmin.zip") |
||||
|
} |
||||
|
} |
@ -1,7 +0,0 @@ |
|||||
package autoCodeModel |
|
||||
|
|
||||
import "testing" |
|
||||
|
|
||||
func TestTemp(t *testing.T) { |
|
||||
Temp() |
|
||||
} |
|
@ -0,0 +1,14 @@ |
|||||
|
package router |
||||
|
|
||||
|
import ( |
||||
|
"gin-vue-admin/controller/api" |
||||
|
"gin-vue-admin/middleware" |
||||
|
"github.com/gin-gonic/gin" |
||||
|
) |
||||
|
|
||||
|
func InitAutoCodeRouter(Router *gin.RouterGroup) { |
||||
|
AutoCodeRouter := Router.Group("autoCode").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()) |
||||
|
{ |
||||
|
AutoCodeRouter.POST("createTemp", api.CreateTemp) //创建自动化代码
|
||||
|
} |
||||
|
} |
@ -0,0 +1,57 @@ |
|||||
|
package tools |
||||
|
|
||||
|
import ( |
||||
|
"archive/zip" |
||||
|
"io" |
||||
|
"os" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
func ZipFiles(filename string, files []string, oldform, newform string) error { |
||||
|
|
||||
|
newZipFile, err := os.Create(filename) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
defer newZipFile.Close() |
||||
|
|
||||
|
zipWriter := zip.NewWriter(newZipFile) |
||||
|
defer zipWriter.Close() |
||||
|
|
||||
|
// 把files添加到zip中
|
||||
|
for _, file := range files { |
||||
|
|
||||
|
zipfile, err := os.Open(file) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
defer zipfile.Close() |
||||
|
|
||||
|
// 获取file的基础信息
|
||||
|
info, err := zipfile.Stat() |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
header, err := zip.FileInfoHeader(info) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
|
||||
|
//使用上面的FileInforHeader() 就可以把文件保存的路径替换成我们自己想要的了,如下面
|
||||
|
header.Name = strings.Replace(file, oldform, newform, -1) |
||||
|
|
||||
|
// 优化压缩
|
||||
|
// 更多参考see http://golang.org/pkg/archive/zip/#pkg-constants
|
||||
|
header.Method = zip.Deflate |
||||
|
|
||||
|
writer, err := zipWriter.CreateHeader(header) |
||||
|
if err != nil { |
||||
|
return err |
||||
|
} |
||||
|
if _, err = io.Copy(writer, zipfile); err != nil { |
||||
|
return err |
||||
|
} |
||||
|
} |
||||
|
return nil |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
代码解压后把fe的api文件内容粘贴进前端api文件夹下并修改为自己想要的名字即可 |
||||
|
|
||||
|
后端代码解压后同理,放到自己想要的 mvc对应路径 并且到 initRouter中注册自动生成的路由 到registTable中注册自动生成的model |
||||
|
|
||||
|
项目github:"https://github.com/piexlmax/gin-vue-admin" |
||||
|
|
||||
|
希望大家给个star多多鼓励 |
||||
|
|
||||
|
暂时不保存大家生成的结构体 只为方便一次性使用 |
@ -1,182 +0,0 @@ |
|||||
<template> |
|
||||
<div> |
|
||||
<el-form :model="dialogMiddle" :inline="true" > |
|
||||
<el-form-item label="组件名称" label-width="80" :span="8"> |
|
||||
<el-input v-model="dialogMiddle.componentName" autocomplete="off"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="组件JSON" label-width="80" :span="8"> |
|
||||
<el-input v-model="dialogMiddle.componentJson" autocomplete="off"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="数据类型" label-width="80" :span="8"> |
|
||||
<el-select v-model="dialogMiddle.componentType" placeholder="请选择活动区域"> |
|
||||
<el-option |
|
||||
v-for="item in typeOptions" |
|
||||
:key="item.value" |
|
||||
:label="item.label" |
|
||||
:value="item.value"> |
|
||||
</el-option> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="展示类型" label-width="80" :span="8"> |
|
||||
<el-select v-model="dialogMiddle.componentShowType" placeholder="请选择活动区域"> |
|
||||
<el-option |
|
||||
v-for="item in showTypeOptions" |
|
||||
:key="item.value" |
|
||||
:label="item.label" |
|
||||
:value="item.value"> |
|
||||
</el-option> |
|
||||
</el-select> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="字典Key" label-width="80" :span="8"> |
|
||||
<el-input v-model="dialogMiddle.dictionaryName" autocomplete="off"></el-input> |
|
||||
</el-form-item> |
|
||||
<div> |
|
||||
<el-form-item label="是否多选" label-width="80"> |
|
||||
<el-switch |
|
||||
v-model="dialogMiddle.isMultiple" |
|
||||
active-text="多选" |
|
||||
inactive-text="单选"> |
|
||||
</el-switch> |
|
||||
</el-form-item> |
|
||||
</div> |
|
||||
<div> |
|
||||
<el-form-item label="是否使用字典" label-width="80"> |
|
||||
<el-switch |
|
||||
v-model="dialogMiddle.nideDictionary" |
|
||||
active-text="使用" |
|
||||
inactive-text="不使用"> |
|
||||
</el-switch> |
|
||||
</el-form-item> |
|
||||
</div> |
|
||||
</el-form> |
|
||||
<div class="button-box clearflex"> |
|
||||
<el-button @click="addDictionary" type="primary">新增字典</el-button> |
|
||||
</div> |
|
||||
<el-table |
|
||||
:data="dialogMiddle.componentDictionary" |
|
||||
stripe |
|
||||
style="width: 100%"> |
|
||||
<el-table-column |
|
||||
label="展示值" |
|
||||
> |
|
||||
<template slot-scope="scope"> |
|
||||
<el-input v-model="scope.row.label"></el-input> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
<el-table-column |
|
||||
label="交互值" |
|
||||
> |
|
||||
<template slot-scope="scope"> |
|
||||
<el-input v-model="scope.row.value"></el-input> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
<el-table-column |
|
||||
label="操作" |
|
||||
> |
|
||||
<template slot-scope="scope"> |
|
||||
<el-popover |
|
||||
placement="top" |
|
||||
width="160" |
|
||||
v-model="scope.row.visible"> |
|
||||
<p>这是一段内容这是一段内容确定删除吗?</p> |
|
||||
<div style="text-align: right; margin: 0"> |
|
||||
<el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button> |
|
||||
<el-button type="primary" size="mini" @click="deleteRow(scope)">确定</el-button> |
|
||||
</div> |
|
||||
<el-button type="text" slot="reference">删除</el-button> |
|
||||
</el-popover> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
</el-table> |
|
||||
</div> |
|
||||
</template> |
|
||||
<script> |
|
||||
const dictionaryTemplate = { |
|
||||
label:"", |
|
||||
value:"", |
|
||||
visible:false |
|
||||
} |
|
||||
export default { |
|
||||
name:"ComponentDialog", |
|
||||
props:{ |
|
||||
dialogMiddle:{ |
|
||||
type:Object, |
|
||||
default:function(){ |
|
||||
return {} |
|
||||
} |
|
||||
} |
|
||||
}, |
|
||||
data(){ |
|
||||
return{ |
|
||||
visible:false, |
|
||||
typeOptions:[ |
|
||||
{ |
|
||||
label:"字符串", |
|
||||
value:"string" |
|
||||
}, |
|
||||
{ |
|
||||
label:"整型", |
|
||||
value:"int" |
|
||||
}, |
|
||||
{ |
|
||||
label:"布尔值", |
|
||||
value:"bool" |
|
||||
}, |
|
||||
{ |
|
||||
label:"浮点型", |
|
||||
value:"float64" |
|
||||
}, |
|
||||
{ |
|
||||
label:"时间", |
|
||||
value:"time.Time" |
|
||||
}, |
|
||||
], |
|
||||
showTypeOptions:[ |
|
||||
{ |
|
||||
label:"单选框", |
|
||||
value:"radio" |
|
||||
}, |
|
||||
{ |
|
||||
label:"多选框", |
|
||||
value:"checkBox" |
|
||||
}, |
|
||||
{ |
|
||||
label:"输入框", |
|
||||
value:"input" |
|
||||
}, |
|
||||
{ |
|
||||
label:"计数器", |
|
||||
value:"inputNumber" |
|
||||
}, |
|
||||
{ |
|
||||
label:"选择器", |
|
||||
value:"select" |
|
||||
}, |
|
||||
{ |
|
||||
label:"级联选择器", |
|
||||
value:"cascader" |
|
||||
}, |
|
||||
{ |
|
||||
label:"开关", |
|
||||
value:"switch" |
|
||||
}, |
|
||||
{ |
|
||||
label:"时间日期选择器", |
|
||||
value:"datePicker" |
|
||||
} |
|
||||
] |
|
||||
} |
|
||||
}, |
|
||||
methods:{ |
|
||||
addDictionary(){ |
|
||||
this.dialogMiddle.componentDictionary.push({...dictionaryTemplate}) |
|
||||
}, |
|
||||
deleteRow(row){ |
|
||||
this.dialogMiddle.componentDictionary.splice(row.$index,1) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
</script> |
|
||||
<style lang="scss"> |
|
||||
|
|
||||
</style> |
|
@ -1,167 +0,0 @@ |
|||||
<template> |
|
||||
<div> |
|
||||
<!-- 开发中功能,若您发现这块代码可以研究,可以无视 --> |
|
||||
<!-- 此版本为简单版 --> |
|
||||
<!-- 结构体基础配置 --> |
|
||||
<!-- develop分支中开发此功能 --> |
|
||||
<el-form ref="form" :model="form" label-width="100px" :inline="true"> |
|
||||
<el-form-item label="Struct名称" :span="8"> |
|
||||
<el-input v-model="form.structName"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="Struct简称" :span="8"> |
|
||||
<el-input v-model="form.structName"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="Package名称" :span="8"> |
|
||||
<el-input v-model="form.packageName"></el-input> |
|
||||
</el-form-item> |
|
||||
<!-- <el-form-item label="结构类型" :span="8"> |
|
||||
<el-select v-model="form.structType" multiple placeholder="请选择结构类型(多选)"> |
|
||||
<el-option |
|
||||
v-for="item in options" |
|
||||
:key="item.value" |
|
||||
:label="item.label" |
|
||||
:value="item.value"> |
|
||||
</el-option> |
|
||||
</el-select> |
|
||||
</el-form-item> --> |
|
||||
</el-form> |
|
||||
<!-- 组件列表 --> |
|
||||
<div class="button-box clearflex"> |
|
||||
<el-button @click="editAndAddComponent()" type="primary">新增Field</el-button> |
|
||||
</div> |
|
||||
<el-table |
|
||||
:data="form.components" |
|
||||
border stripe> |
|
||||
<el-table-column |
|
||||
type="index" |
|
||||
label="序列" |
|
||||
width="180"> |
|
||||
</el-table-column> |
|
||||
<el-table-column |
|
||||
prop="componentName" |
|
||||
label="Field名" |
|
||||
width="180"> |
|
||||
</el-table-column> |
|
||||
<el-table-column |
|
||||
prop="componentType" |
|
||||
label="Field数据类型" |
|
||||
width="180"> |
|
||||
</el-table-column> |
|
||||
<el-table-column |
|
||||
prop="componentShowType" |
|
||||
label="Field展示类型"> |
|
||||
</el-table-column> |
|
||||
<el-table-column |
|
||||
prop="dictionaryName" |
|
||||
label="字典名称(选)"> |
|
||||
</el-table-column> |
|
||||
<el-table-column |
|
||||
label="操作"> |
|
||||
<template slot-scope="scope"> |
|
||||
<el-button @click="editAndAddComponent(scope.row)">编辑</el-button> |
|
||||
<el-popover |
|
||||
placement="top" |
|
||||
width="160" |
|
||||
v-model="scope.row.visible"> |
|
||||
<p>这是一段内容这是一段内容确定删除吗?</p> |
|
||||
<div style="text-align: right; margin: 0"> |
|
||||
<el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button> |
|
||||
<el-button type="primary" size="mini" @click="deleteComponent(scope.$index)">确定</el-button> |
|
||||
</div> |
|
||||
<el-button slot="reference">删除</el-button> |
|
||||
</el-popover> |
|
||||
</template> |
|
||||
</el-table-column> |
|
||||
</el-table> |
|
||||
<!-- 组件列表 --> |
|
||||
<div class="button-box clearflex"> |
|
||||
<el-button @click="enterForm" type="primary">提交</el-button> |
|
||||
</div> |
|
||||
|
|
||||
<!-- 组件弹窗 --> |
|
||||
<el-dialog title="组件内容" :visible.sync="dialogFlag"> |
|
||||
<ComponentDialog :dialogMiddle="dialogMiddle" /> |
|
||||
<div slot="footer" class="dialog-footer"> |
|
||||
<el-button @click="closeDialog">取 消</el-button> |
|
||||
<el-button type="primary" @click="enterDialog">确 定</el-button> |
|
||||
</div> |
|
||||
</el-dialog> |
|
||||
</div> |
|
||||
</template> |
|
||||
<script> |
|
||||
const componentTemplate={ |
|
||||
componentName:"", |
|
||||
componentType:"", |
|
||||
componentShowType:"", |
|
||||
dictionaryName:"", |
|
||||
isMultiple:false, |
|
||||
nideDictionary:false, |
|
||||
visible:false, |
|
||||
componentDictionary:[] |
|
||||
} |
|
||||
|
|
||||
import ComponentDialog from "@/view/superAdmin/autoCode/component/componentDialog.vue" |
|
||||
export default { |
|
||||
name:"autoCode", |
|
||||
data(){ |
|
||||
return{ |
|
||||
addFlag:"", |
|
||||
form:{ |
|
||||
structName:"", |
|
||||
packageName:"", |
|
||||
|
|
||||
components:[] |
|
||||
}, |
|
||||
options:[ |
|
||||
{label:"表格类型",value:"grid"}, |
|
||||
{label:"表单类型",value:"form"} |
|
||||
], |
|
||||
dialogMiddle:{}, |
|
||||
bk:{}, |
|
||||
dialogFlag:false |
|
||||
} |
|
||||
}, |
|
||||
components:{ |
|
||||
ComponentDialog |
|
||||
}, |
|
||||
methods:{ |
|
||||
editAndAddComponent(item){ |
|
||||
this.dialogFlag = true |
|
||||
if(item){ |
|
||||
this.addFlag="edit" |
|
||||
this.bk=JSON.parse(JSON.stringify(item)) |
|
||||
this.dialogMiddle = item |
|
||||
}else{ |
|
||||
this.addFlag="add" |
|
||||
this.dialogMiddle = JSON.parse(JSON.stringify(componentTemplate)) |
|
||||
} |
|
||||
}, |
|
||||
enterDialog(){ |
|
||||
if(this.addFlag=="add"){ |
|
||||
this.form.components.push(this.dialogMiddle) |
|
||||
} |
|
||||
this.dialogFlag = false |
|
||||
}, |
|
||||
closeDialog(){ |
|
||||
if(this.addFlag=="edit"){ |
|
||||
this.dialogMiddle = this.bk |
|
||||
} |
|
||||
this.dialogFlag = false |
|
||||
}, |
|
||||
deleteComponent(index){ |
|
||||
this.form.components.splice(index,1) |
|
||||
}, |
|
||||
enterForm(){ |
|
||||
console.log(this.form) |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
</script> |
|
||||
<style scope lang="scss"> |
|
||||
.button-box { |
|
||||
padding: 10px 20px; |
|
||||
.el-button { |
|
||||
float: right; |
|
||||
} |
|
||||
} |
|
||||
</style> |
|
@ -1,110 +0,0 @@ |
|||||
<template> |
|
||||
<div> |
|
||||
<el-form :model="config" label-width="100px" ref="form" class="system"> |
|
||||
<h2>系统配置</h2> |
|
||||
<el-form-item label="多点登录拦截"> |
|
||||
<el-checkbox v-model="config.system.useMultipoint">开启</el-checkbox> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="环境值"> |
|
||||
<el-input v-model="config.system.env"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="端口值"> |
|
||||
<el-input v-model="config.system.addr"></el-input> |
|
||||
</el-form-item> |
|
||||
<h2>jwt签名</h2> |
|
||||
<el-form-item label="jwt签名"> |
|
||||
<el-input v-model="config.jwt.signingKey"></el-input> |
|
||||
</el-form-item> |
|
||||
<h2>casbin配置</h2> |
|
||||
<el-form-item label="模型地址"> |
|
||||
<el-input v-model="config.casbinConfig.modelPath"></el-input> |
|
||||
</el-form-item> |
|
||||
<h2>mysql admin数据库配置</h2> |
|
||||
<el-form-item label="username"> |
|
||||
<el-input v-model="config.mysqlAdmin.username"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="password"> |
|
||||
<el-input v-model="config.mysqlAdmin.password"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="path"> |
|
||||
<el-input v-model="config.mysqlAdmin.path"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="dbname"> |
|
||||
<el-input v-model="config.mysqlAdmin.dbname"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="config"> |
|
||||
<el-input v-model="config.mysqlAdmin.config"></el-input> |
|
||||
</el-form-item> |
|
||||
<h2>Redis admin数据库配置</h2> |
|
||||
<el-form-item label="addr"> |
|
||||
<el-input v-model="config.redisAdmin.addr"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="password"> |
|
||||
<el-input v-model="config.redisAdmin.password"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="db"> |
|
||||
<el-input v-model="config.redisAdmin.db"></el-input> |
|
||||
</el-form-item> |
|
||||
<h2>七牛密钥配置</h2> |
|
||||
<el-form-item label="accessKey"> |
|
||||
<el-input v-model="config.qiniu.accessKey"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item label="secretKey"> |
|
||||
<el-input v-model="config.qiniu.secretKey"></el-input> |
|
||||
</el-form-item> |
|
||||
<el-form-item> |
|
||||
<el-button @click="update" type="primary">立即更新</el-button> |
|
||||
<el-button @click="reload" type="primary">重启服务(开发中)</el-button> |
|
||||
</el-form-item> |
|
||||
</el-form> |
|
||||
</div> |
|
||||
</template> |
|
||||
|
|
||||
<script> |
|
||||
import { getSystemConfig, setSystemConfig } from '@/api/system' |
|
||||
export default { |
|
||||
name: 'Config', |
|
||||
data() { |
|
||||
return { |
|
||||
config: { |
|
||||
system: {}, |
|
||||
jwt: {}, |
|
||||
casbinConfig: {}, |
|
||||
mysqlAdmin: {}, |
|
||||
redisAdmin: {}, |
|
||||
qiniu: {} |
|
||||
} |
|
||||
} |
|
||||
}, |
|
||||
async created() { |
|
||||
await this.initForm() |
|
||||
}, |
|
||||
methods: { |
|
||||
async initForm() { |
|
||||
const res = await getSystemConfig() |
|
||||
if (res.success) { |
|
||||
this.config = res.data.config |
|
||||
} |
|
||||
}, |
|
||||
reload() {}, |
|
||||
async update() { |
|
||||
const res = await setSystemConfig({ config: this.config }) |
|
||||
if (res.success) { |
|
||||
this.$message({ |
|
||||
type: 'success', |
|
||||
message: '配置文件设置成功' |
|
||||
}) |
|
||||
await this.initForm() |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
</script> |
|
||||
<style lang="scss"> |
|
||||
h2 { |
|
||||
padding: 10px; |
|
||||
margin: 10px 0; |
|
||||
font-size: 16px; |
|
||||
box-shadow:-4px 1px 3px 0px #e7e8e8 |
|
||||
} |
|
||||
</style> |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue