From a0b06dbd0dbe0714679e53b6494983d67cf26664 Mon Sep 17 00:00:00 2001 From: pixelmaxQM Date: Sat, 10 Aug 2024 16:55:12 +0800 Subject: [PATCH 01/20] =?UTF-8?q?feat:=20=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=A2=9E=E5=8A=A0json=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=92=8C=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/server.go | 2 +- server/docs/docs.go | 2 +- server/docs/swagger.json | 2 +- server/docs/swagger.yaml | 2 +- server/main.go | 2 +- web/package.json | 2 +- web/src/core/config.js | 2 +- web/src/core/gin-vue-admin.js | 2 +- web/src/view/systemTools/autoCode/index.vue | 42 +++++++++++++++++++++ 9 files changed, 50 insertions(+), 8 deletions(-) diff --git a/server/core/server.go b/server/core/server.go index 0d1c3797b7..a9139d4983 100644 --- a/server/core/server.go +++ b/server/core/server.go @@ -38,7 +38,7 @@ func RunWindowsServer() { fmt.Printf(` 欢迎使用 gin-vue-admin - 当前版本:v2.7.1 + 当前版本:v2.7.2 加群方式:微信号:shouzi_1994 QQ群:470239250 项目地址:https://github.com/flipped-aurora/gin-vue-admin 插件市场:https://plugin.gin-vue-admin.com diff --git a/server/docs/docs.go b/server/docs/docs.go index f3e8847bf9..18173cfa6b 100644 --- a/server/docs/docs.go +++ b/server/docs/docs.go @@ -8087,7 +8087,7 @@ const docTemplate = `{ // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = &swag.Spec{ - Version: "v2.7.1", + Version: "v2.7.2", Host: "", BasePath: "", Schemes: []string{}, diff --git a/server/docs/swagger.json b/server/docs/swagger.json index d7facd2649..ebc667710d 100644 --- a/server/docs/swagger.json +++ b/server/docs/swagger.json @@ -4,7 +4,7 @@ "description": "使用gin+vue进行极速开发的全栈开发基础平台", "title": "Gin-Vue-Admin Swagger API接口文档", "contact": {}, - "version": "v2.7.1" + "version": "v2.7.2" }, "paths": { "/api/createApi": { diff --git a/server/docs/swagger.yaml b/server/docs/swagger.yaml index ac18f4dbca..5575f9942b 100644 --- a/server/docs/swagger.yaml +++ b/server/docs/swagger.yaml @@ -1634,7 +1634,7 @@ info: contact: {} description: 使用gin+vue进行极速开发的全栈开发基础平台 title: Gin-Vue-Admin Swagger API接口文档 - version: v2.7.1 + version: v2.7.2 paths: /api/createApi: post: diff --git a/server/main.go b/server/main.go index 8375bf6733..76b4130120 100644 --- a/server/main.go +++ b/server/main.go @@ -15,7 +15,7 @@ import ( //go:generate go mod download // @title Gin-Vue-Admin Swagger API接口文档 -// @version v2.7.1 +// @version v2.7.2 // @description 使用gin+vue进行极速开发的全栈开发基础平台 // @securityDefinitions.apikey ApiKeyAuth // @in header diff --git a/web/package.json b/web/package.json index fb4b6719a4..0e2229ee0f 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "gin-vue-admin", - "version": "2.7.1", + "version": "2.7.2", "private": true, "scripts": { "serve": "node openDocument.js && vite --host --mode development", diff --git a/web/src/core/config.js b/web/src/core/config.js index 7d02899328..c1a2bb2b2c 100644 --- a/web/src/core/config.js +++ b/web/src/core/config.js @@ -20,7 +20,7 @@ export const viteLogo = (env) => { ) console.log( chalk.green( - `> 当前版本:v2.7.1` + `> 当前版本:v2.7.2` ) ) console.log( diff --git a/web/src/core/gin-vue-admin.js b/web/src/core/gin-vue-admin.js index 8291bd69db..ccd11062f2 100644 --- a/web/src/core/gin-vue-admin.js +++ b/web/src/core/gin-vue-admin.js @@ -10,7 +10,7 @@ export default { register(app) console.log(` 欢迎使用 Gin-Vue-Admin - 当前版本:v2.7.1 + 当前版本:v2.7.2 加群方式:微信:shouzi_1994 QQ群:622360840 项目地址:https://github.com/flipped-aurora/gin-vue-admin 插件市场:https://plugin.gin-vue-admin.com diff --git a/web/src/view/systemTools/autoCode/index.vue b/web/src/view/systemTools/autoCode/index.vue index 57e1a18696..7288c75991 100644 --- a/web/src/view/systemTools/autoCode/index.vue +++ b/web/src/view/systemTools/autoCode/index.vue @@ -615,6 +615,20 @@
+ + 导出json + + + 导入json + { getCatch() +const exportJson = () => { + const dataStr = JSON.stringify(form.value, null, 2) + const blob = new Blob([dataStr], { type: 'application/json' }) + const url = URL.createObjectURL(blob) + const a = document.createElement('a') + a.href = url + a.download = 'form_data.json' + document.body.appendChild(a) + a.click() + document.body.removeChild(a) + URL.revokeObjectURL(url) +} + +const importJson = (file) =>{ + const reader = new FileReader() + reader.onload = (e) => { + console.log(e) + try { + form.value = JSON.parse(e.target.result) + ElMessage.success('JSON 文件导入成功') + } catch (error) { + ElMessage.error('无效的 JSON 文件') + } + } + reader.readAsText(file) + return false +} + From a96d2fd629bfd54431082a28a5a17461caef8f80 Mon Sep 17 00:00:00 2001 From: pixelmaxQM Date: Sat, 10 Aug 2024 22:13:55 +0800 Subject: [PATCH 02/20] =?UTF-8?q?feat:=20=E8=87=AA=E5=8A=A8=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=89=8D=E7=AB=AF=E5=8F=AF=E8=A7=81=E5=88=86?= =?UTF-8?q?=E4=B8=BATable=E5=92=8CForm=E5=88=86=E5=88=AB=E9=80=89=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/model/system/request/sys_auto_code.go | 29 +++-- server/resource/package/web/view/form.vue.tpl | 4 + .../resource/package/web/view/table.vue.tpl | 106 ++++++++++-------- .../plugin/web/view/view.vue.template | 36 ++++-- .../autoCode/component/fieldDialog.vue | 7 +- web/src/view/systemTools/autoCode/index.vue | 26 +++-- 6 files changed, 124 insertions(+), 84 deletions(-) diff --git a/server/model/system/request/sys_auto_code.go b/server/model/system/request/sys_auto_code.go index 088986dfef..8fe8a46356 100644 --- a/server/model/system/request/sys_auto_code.go +++ b/server/model/system/request/sys_auto_code.go @@ -26,7 +26,6 @@ type AutoCode struct { AutoCreateMenuToSql bool `json:"autoCreateMenuToSql" example:"false"` // 是否自动创建menu Fields []*AutoCodeField `json:"fields"` DictTypes []string `json:"-"` - FrontFields []*AutoCodeField `json:"-"` PrimaryField *AutoCodeField `json:"primaryField"` DataSourceMap map[string]*DataSource `json:"-"` HasPic bool `json:"-"` @@ -114,7 +113,6 @@ func (r *AutoCode) Pretreatment() error { } // test length := len(r.Fields) dict := make(map[string]string, length) - r.FrontFields = make([]*AutoCodeField, 0, length) r.DataSourceMap = make(map[string]*DataSource, length) for i := 0; i < length; i++ { if r.Fields[i].DictType != "" { @@ -123,9 +121,6 @@ func (r *AutoCode) Pretreatment() error { if r.Fields[i].Sort { r.NeedSort = true } - if r.Fields[i].Front { - r.FrontFields = append(r.FrontFields, r.Fields[i]) - } switch r.Fields[i].FieldType { case "file": r.HasFile = true @@ -204,17 +199,19 @@ func (r *AutoCode) History() SysAutoHistoryCreate { } type AutoCodeField struct { - FieldName string `json:"fieldName"` // Field名 - FieldDesc string `json:"fieldDesc"` // 中文名 - FieldType string `json:"fieldType"` // Field数据类型 - FieldJson string `json:"fieldJson"` // FieldJson - DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度 - Comment string `json:"comment"` // 数据库字段描述 - ColumnName string `json:"columnName"` // 数据库字段 - FieldSearchType string `json:"fieldSearchType"` // 搜索条件 - FieldSearchHide bool `json:"fieldSearchHide"` // 是否隐藏查询条件 - DictType string `json:"dictType"` // 字典 - Front bool `json:"front"` // 是否前端可见 + FieldName string `json:"fieldName"` // Field名 + FieldDesc string `json:"fieldDesc"` // 中文名 + FieldType string `json:"fieldType"` // Field数据类型 + FieldJson string `json:"fieldJson"` // FieldJson + DataTypeLong string `json:"dataTypeLong"` // 数据库字段长度 + Comment string `json:"comment"` // 数据库字段描述 + ColumnName string `json:"columnName"` // 数据库字段 + FieldSearchType string `json:"fieldSearchType"` // 搜索条件 + FieldSearchHide bool `json:"fieldSearchHide"` // 是否隐藏查询条件 + DictType string `json:"dictType"` // 字典 + //Front bool `json:"front"` // 是否前端可见 + Form bool `json:"form"` // 是否前端新建/编辑 + Table bool `json:"table"` // 是否前端表格列 Require bool `json:"require"` // 是否必填 DefaultValue string `json:"defaultValue"` // 是否必填 ErrorText string `json:"errorText"` // 校验失败文字 diff --git a/server/resource/package/web/view/form.vue.tpl b/server/resource/package/web/view/form.vue.tpl index 9e7c0f9ab7..0729fed3f8 100644 --- a/server/resource/package/web/view/form.vue.tpl +++ b/server/resource/package/web/view/form.vue.tpl @@ -3,6 +3,7 @@
{{- range .Fields}} + {{- if .Form }} {{- if .CheckDataSource}} @@ -56,6 +57,7 @@ {{- end }} {{- end }} + {{- end }} {{- end }} 保存 @@ -106,6 +108,7 @@ const {{ $element }}Options = ref([]) {{- end }} const formData = ref({ {{- range .Fields}} + {{- if .Form }} {{- if eq .FieldType "bool" }} {{.FieldJson}}: false, {{- end }} @@ -142,6 +145,7 @@ const formData = ref({ {{- if eq .FieldType "array" }} {{.FieldJson}}: [], {{- end }} + {{- end }} {{- end }} }) // 验证规则 diff --git a/server/resource/package/web/view/table.vue.tpl b/server/resource/package/web/view/table.vue.tpl index d7a69e8bae..2243346db1 100644 --- a/server/resource/package/web/view/table.vue.tpl +++ b/server/resource/package/web/view/table.vue.tpl @@ -169,7 +169,8 @@ {{ end }} - {{- range .FrontFields}} + {{- range .Fields}} + {{ -if .Table}} {{- if .CheckDataSource }} - {{- else }} - + {{- else }} + + {{- end }} {{- end }} {{- end }} @@ -277,7 +279,8 @@ - {{- range .FrontFields}} + {{- range .Fields}} + {{ -if .Form}} {{- if .CheckDataSource}} @@ -347,6 +350,7 @@ {{- end }} {{- end }} + {{- end }}
@@ -401,43 +405,45 @@ const showAllQuery = ref(false) const {{ $element }}Options = ref([]) {{- end }} const formData = ref({ - {{- range .FrontFields}} - {{- if eq .FieldType "bool" }} - {{.FieldJson}}: false, - {{- end }} - {{- if eq .FieldType "string" }} - {{.FieldJson}}: '', - {{- end }} - {{- if eq .FieldType "richtext" }} - {{.FieldJson}}: '', - {{- end }} - {{- if eq .FieldType "int" }} - {{.FieldJson}}: {{- if or .DictType .DataSource}} undefined{{ else }} 0{{- end }}, - {{- end }} - {{- if eq .FieldType "time.Time" }} - {{.FieldJson}}: new Date(), - {{- end }} - {{- if eq .FieldType "float64" }} - {{.FieldJson}}: 0, - {{- end }} - {{- if eq .FieldType "picture" }} - {{.FieldJson}}: "", - {{- end }} - {{- if eq .FieldType "video" }} - {{.FieldJson}}: "", - {{- end }} - {{- if eq .FieldType "pictures" }} - {{.FieldJson}}: [], - {{- end }} - {{- if eq .FieldType "file" }} - {{.FieldJson}}: [], - {{- end }} - {{- if eq .FieldType "json" }} - {{.FieldJson}}: {}, - {{- end }} - {{- if eq .FieldType "array" }} - {{.FieldJson}}: [], - {{- end }} + {{- range .Fields}} + {{- if .Form}} + {{- if eq .FieldType "bool" }} + {{.FieldJson}}: false, + {{- end }} + {{- if eq .FieldType "string" }} + {{.FieldJson}}: '', + {{- end }} + {{- if eq .FieldType "richtext" }} + {{.FieldJson}}: '', + {{- end }} + {{- if eq .FieldType "int" }} + {{.FieldJson}}: {{- if or .DictType .DataSource}} undefined{{ else }} 0{{- end }}, + {{- end }} + {{- if eq .FieldType "time.Time" }} + {{.FieldJson}}: new Date(), + {{- end }} + {{- if eq .FieldType "float64" }} + {{.FieldJson}}: 0, + {{- end }} + {{- if eq .FieldType "picture" }} + {{.FieldJson}}: "", + {{- end }} + {{- if eq .FieldType "video" }} + {{.FieldJson}}: "", + {{- end }} + {{- if eq .FieldType "pictures" }} + {{.FieldJson}}: [], + {{- end }} + {{- if eq .FieldType "file" }} + {{.FieldJson}}: [], + {{- end }} + {{- if eq .FieldType "json" }} + {{.FieldJson}}: {}, + {{- end }} + {{- if eq .FieldType "array" }} + {{.FieldJson}}: [], + {{- end }} + {{- end }} {{- end }} }) @@ -456,7 +462,8 @@ const formData = ref({ // 验证规则 const rule = reactive({ - {{- range .FrontFields }} + {{- range .Fields }} + {{- if .From }} {{- if eq .Require true }} {{.FieldJson }} : [{ required: true, @@ -472,6 +479,7 @@ const rule = reactive({ {{- end }} ], {{- end }} + {{- end }} {{- end }} }) @@ -489,7 +497,7 @@ const searchRule = reactive({ } }, trigger: 'change' } ], - {{- range .FrontFields }} + {{- range .Fields }} {{- if .FieldSearchType}} {{- if eq .FieldType "time.Time" }} {{.FieldJson }} : [{ validator: (rule, value, callback) => { @@ -522,12 +530,14 @@ const searchInfo = ref({}) // 排序 const sortChange = ({ prop, order }) => { const sortMap = { - {{- range .FrontFields}} + {{- range .Fields}} + {{- if .Table}} {{- if and .Sort}} {{- if not (eq .ColumnName "")}} {{.FieldJson}}: '{{.ColumnName}}', {{- end}} {{- end}} + {{- end}} {{- end}} } @@ -554,7 +564,7 @@ const onSubmit = () => { if (!valid) return page.value = 1 pageSize.value = 10 - {{- range .FrontFields}}{{- if eq .FieldType "bool" }} + {{- range .Fields}}{{- if eq .FieldType "bool" }} if (searchInfo.value.{{.FieldJson}} === ""){ searchInfo.value.{{.FieldJson}}=null }{{ end }}{{ end }} @@ -693,7 +703,8 @@ const openDialog = () => { const closeDialog = () => { dialogFormVisible.value = false formData.value = { - {{- range .FrontFields}} + {{- range .Fields}} + {{- if .Form}} {{- if eq .FieldType "bool" }} {{.FieldJson}}: false, {{- end }} @@ -727,7 +738,8 @@ const closeDialog = () => { {{- if eq .FieldType "json" }} {{.FieldJson}}: {}, {{- end }} - {{- end }} + {{- end }} + {{- end }} } } // 弹窗确定 diff --git a/server/resource/plugin/web/view/view.vue.template b/server/resource/plugin/web/view/view.vue.template index fd46cf460a..a3b0a0f0e0 100644 --- a/server/resource/plugin/web/view/view.vue.template +++ b/server/resource/plugin/web/view/view.vue.template @@ -169,7 +169,8 @@ {{ end }} - {{- range .FrontFields}} + {{- range .Fields}} + {{- if .Table}} {{- if .CheckDataSource }}