Browse Source

代码生成器最后一步(仅剩传给前端下载)

main
QM303176530 5 years ago
parent
commit
a35e756318
  1. 84
      QMPlusServer/autoCode/fe/autocode/api/api.js
  2. 118
      QMPlusServer/autoCode/te/autocode/api/api.go
  3. 52
      QMPlusServer/autoCode/te/autocode/model/model.go
  4. 18
      QMPlusServer/autoCode/te/autocode/router/router.go
  5. 33
      QMPlusServer/controller/api/sys_autoCode.go
  6. 3
      QMPlusServer/init/initRouter/init_router.go
  7. 2
      QMPlusServer/main.go
  8. 188
      QMPlusServer/model/autoCodeModel/autoCode.go
  9. 7
      QMPlusServer/model/autoCodeModel/autoCode_test.go
  10. 14
      QMPlusServer/router/sys_autoCode.go
  11. 57
      QMPlusServer/tools/zipfiles.go
  12. 9
      QMPlusServer/tpl/readme.txt.tpl
  13. 4
      QMPlusServer/tpl/te/model.go.tpl
  14. 182
      QMPlusVuePage/src/view/superAdmin/autoCode/component/componentDialog.vue
  15. 167
      QMPlusVuePage/src/view/superAdmin/autoCode/index.vue
  16. 1
      QMPlusVuePage/src/view/superAdmin/menu/menu.vue
  17. 110
      QMPlusVuePage/src/view/superAdmin/system/system.vue

84
QMPlusServer/autoCode/fe/autocode/api/api.js

@ -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
})
}

118
QMPlusServer/autoCode/te/autocode/api/api.go

@ -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,
})
}
}

52
QMPlusServer/autoCode/te/autocode/model/model.go

@ -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
}
}

18
QMPlusServer/autoCode/te/autocode/router/router.go

@ -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列表
}
}

33
QMPlusServer/controller/api/sys_autoCode.go

@ -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")
}
}

3
QMPlusServer/init/initRouter/init_router.go

@ -35,7 +35,8 @@ func InitRouter() *gin.Engine {
router.InitCasbinRouter(ApiGroup) // 权限相关路由
router.InitJwtRouter(ApiGroup) // jwt相关路由
router.InitSystemRouter(ApiGroup) // system相关路由
router.InitCustomerRouter(ApiGroup) // 客户路由
router.InitCustomerRouter(ApiGroup) // 客户路由
router.InitAutoCodeRouter(ApiGroup) // 创建自动化代码
log.L.Info("router register success")
return Router
}

2
QMPlusServer/main.go

@ -47,6 +47,8 @@ func main() {
defer qmsql.DEFAULTDB.Close()
// 注册路由
Router := initRouter.InitRouter()
Router.Static("/form-generator", "./static/form-generator")
//Router.RunTLS(":443","ssl.pem", "ssl.key") // https支持 需要添加中间件
//sysType := runtime.GOOS
//

188
QMPlusServer/model/autoCodeModel/autoCode.go

@ -1,7 +1,6 @@
package autoCodeModel
import (
"fmt"
"gin-vue-admin/tools"
"html/template"
"os"
@ -9,21 +8,17 @@ import (
//开发中功能,若您发现这块代码可以研究,可以无视
type AutoCodeStruct struct {
StructName string `json:"structName"`
PackageName string `json:"packageName"`
Abbreviation string `json:"abbreviation"`
Components []Component `json:"components"`
StructName string `json:"structName"`
PackageName string `json:"packageName"`
Abbreviation string `json:"abbreviation"`
Fields []Field `json:"fields"`
}
type Component struct {
ComponentName string `json:"componentName"`
ComponentType string `json:"componentType"`
ComponentJson string `json:"componentJson"`
Ismultiple bool `json:"isMultiple"`
ComponentShowType string `json:"componentShowType"`
NideDictionary bool `json:"nideDictionary"`
DictionaryName string `json:"dictionaryName"`
ComponentDictionary []Dictionary `json:"dictionary"`
type Field struct {
FieldName string `json:"fieldName"`
FieldType string `json:"fieldType"`
FieldJson string `json:"fieldJson"`
ColumnName string `json:"columnName"`
}
type Dictionary struct {
@ -31,68 +26,113 @@ type Dictionary struct {
Value string `json:"value"`
}
func Temp() {
modelTmpl, modelTplErr := template.ParseFiles("../../tpl/te/model.go.tpl")
apiTmpl, apiTplErr := template.ParseFiles("../../tpl/te/api.go.tpl")
routerTmpl, routerTplErr := template.ParseFiles("../../tpl/te/router.go.tpl")
feapiTmpl, feapiTplErr := template.ParseFiles("../../tpl/fe/api.js.tpl")
fmt.Println(modelTplErr,apiTplErr,routerTplErr,feapiTplErr)
a1 := Component{
ComponentName: "TestComponent",
ComponentType: "string",
ComponentJson: "testComponent",
Ismultiple: false,
ComponentShowType: "",
NideDictionary: false,
DictionaryName: "",
ComponentDictionary: nil,
}
a2 := Component{
ComponentName: "TestBigComponent",
ComponentType: "int",
ComponentJson: "testBigComponent",
Ismultiple: false,
ComponentShowType: "",
NideDictionary: false,
DictionaryName: "",
ComponentDictionary: nil,
}
a := AutoCodeStruct{
StructName: "Test",
PackageName: "autocode",
Abbreviation: "t",
Components: []Component{a1, a2},
}
_autoCode := "../../autoCode/"
_te := "../../autoCode/te/"
_dir := "../../autoCode/te/" + a.PackageName
_modeldir := "../../autoCode/te/" + a.PackageName+"/model"
_apidir := "../../autoCode/te/" + a.PackageName+"/api"
_routerdir := "../../autoCode/te/" + a.PackageName+"/router"
_fe := "../../autoCode/fe/"
_fe_dir:="../../autoCode/fe/" + a.PackageName
_fe_apidir:="../../autoCode/fe/" + a.PackageName+"/api"
mkerr := createDir(_autoCode,_te,_dir,_modeldir,_apidir,_routerdir,_fe,_fe_dir,_fe_apidir)
fmt.Print(mkerr)
model, _ := os.OpenFile("../../autoCode/te/"+a.PackageName+"/model/model.go", os.O_CREATE|os.O_WRONLY, 0755)
api, _ := os.OpenFile("../../autoCode/te/"+a.PackageName+"/api/api.go", os.O_CREATE|os.O_WRONLY, 0755)
router, _ := os.OpenFile("../../autoCode/te/"+a.PackageName+"/router/router.go", os.O_CREATE|os.O_WRONLY, 0755)
feapi ,_ := os.OpenFile("../../autoCode/fe/"+a.PackageName+"/api/api.js", os.O_CREATE|os.O_WRONLY, 0755)
modelErr := modelTmpl.Execute(model, a)
apiErr := apiTmpl.Execute(api, a)
routerErr := routerTmpl.Execute(router, a)
feapiErr := feapiTmpl.Execute(feapi, a)
fmt.Println(modelErr,apiErr,routerErr,feapiErr)
func (a *AutoCodeStruct) CreateTemp() (err error) {
basePath := "./tpl"
modelTmpl, err := template.ParseFiles(basePath + "/te/model.go.tpl")
if err != nil {
return err
}
apiTmpl, err := template.ParseFiles(basePath + "/te/api.go.tpl")
if err != nil {
return err
}
routerTmpl, err := template.ParseFiles(basePath + "/te/router.go.tpl")
if err != nil {
return err
}
feapiTmpl, err := template.ParseFiles(basePath + "/fe/api.js.tpl")
if err != nil {
return err
}
readmeTmpl, err := template.ParseFiles(basePath + "/readme.txt.tpl")
if err != nil {
return err
}
//自动化总目录
_autoCode := "./autoCode/"
//自动化后台代码目录
_te := "./autoCode/te/"
_dir := _te + a.PackageName
_modeldir := _te + a.PackageName + "/model"
_apidir := _te + a.PackageName + "/api"
_routerdir := _te + a.PackageName + "/router"
//自动化前台代码目录
_fe := "./autoCode/fe/"
_fe_dir := _fe + a.PackageName
_fe_apidir := _fe + a.PackageName + "/api"
err = createDir(_autoCode, _te, _dir, _modeldir, _apidir, _routerdir, _fe, _fe_dir, _fe_apidir)
if err != nil {
return err
}
model, err := os.OpenFile(_te+a.PackageName+"/model/model.go", os.O_CREATE|os.O_WRONLY, 0755)
if err != nil {
return err
}
api, err := os.OpenFile(_te+a.PackageName+"/api/api.go", os.O_CREATE|os.O_WRONLY, 0755)
if err != nil {
return err
}
router, err := os.OpenFile(_te+a.PackageName+"/router/router.go", os.O_CREATE|os.O_WRONLY, 0755)
if err != nil {
return err
}
feapi, err := os.OpenFile(_fe+a.PackageName+"/api/api.js", os.O_CREATE|os.O_WRONLY, 0755)
if err != nil {
return err
}
readme, err := os.OpenFile(_autoCode+"readme.txt", os.O_CREATE|os.O_WRONLY, 0755)
if err != nil {
return err
}
// 生成代码
{
err = modelTmpl.Execute(model, a)
if err != nil {
return err
}
err = apiTmpl.Execute(api, a)
if err != nil {
return err
}
err = routerTmpl.Execute(router, a)
if err != nil {
return err
}
err = feapiTmpl.Execute(feapi, a)
if err != nil {
return err
}
err = readmeTmpl.Execute(readme, a)
if err != nil {
return err
}
}
model.Close()
api.Close()
router.Close()
feapi.Close()
readme.Close()
fileList := []string{
_te + a.PackageName + "/model/model.go",
_te + a.PackageName + "/api/api.go",
_te + a.PackageName + "/router/router.go",
_fe + a.PackageName + "/api/api.js",
_autoCode + "readme.txt",
}
err = tools.ZipFiles("./ginvueadmin.zip", fileList, ".", ".")
if err != nil {
return err
}
err = os.RemoveAll(_autoCode)
if err != nil {
return err
}
return nil
}
//批量创建文件夹
func createDir(dirs ...string)(err error){
for _,v:=range dirs{
func createDir(dirs ...string) (err error) {
for _, v := range dirs {
exist, err := tools.PathExists(v)
if err != nil {
//log.L.Info(fmt.Sprintf("get dir error![%v]\n", err))
@ -112,4 +152,4 @@ func createDir(dirs ...string)(err error){
}
}
return err
}
}

7
QMPlusServer/model/autoCodeModel/autoCode_test.go

@ -1,7 +0,0 @@
package autoCodeModel
import "testing"
func TestTemp(t *testing.T) {
Temp()
}

14
QMPlusServer/router/sys_autoCode.go

@ -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) //创建自动化代码
}
}

57
QMPlusServer/tools/zipfiles.go

@ -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
}

9
QMPlusServer/tpl/readme.txt.tpl

@ -0,0 +1,9 @@
代码解压后把fe的api文件内容粘贴进前端api文件夹下并修改为自己想要的名字即可
后端代码解压后同理,放到自己想要的 mvc对应路径 并且到 initRouter中注册自动生成的路由 到registTable中注册自动生成的model
项目github:"https://github.com/piexlmax/gin-vue-admin"
希望大家给个star多多鼓励
暂时不保存大家生成的结构体 只为方便一次性使用

4
QMPlusServer/tpl/te/model.go.tpl

@ -9,8 +9,8 @@ import (
)
type {{.StructName}} struct {
gorm.Model {{range .Components}}
{{.ComponentName}} {{.ComponentType}} `json:"{{.ComponentJson}}"` {{ end }}
gorm.Model {{range .Fields}}
{{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}"{{if .ColumnName}} gorm:"column:{{.ColumnName}}"{{end}}`{{ end }}
}
// 创建{{.StructName}}

182
QMPlusVuePage/src/view/superAdmin/autoCode/component/componentDialog.vue

@ -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>

167
QMPlusVuePage/src/view/superAdmin/autoCode/index.vue

@ -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
QMPlusVuePage/src/view/superAdmin/menu/menu.vue

@ -201,6 +201,7 @@ export default {
message: '添加失败!'
})
}
this.initForm()
this.dialogFormVisible = false
}
})

110
QMPlusVuePage/src/view/superAdmin/system/system.vue

@ -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>
Loading…
Cancel
Save