mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-12-24 08:12:55 +08:00
优化模板生成代码
This commit is contained in:
@@ -35,7 +35,8 @@ module.exports = {
|
||||
'prefer-spread': 'off',
|
||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
|
||||
'vue/no-mutating-props': 'off'
|
||||
'vue/no-mutating-props': 'off',
|
||||
'no-empty': 'off'
|
||||
},
|
||||
globals: {
|
||||
module: 'readonly'
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/util"
|
||||
"x_admin/util/excel"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package admin
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"x_admin/core"
|
||||
"x_admin/middleware"
|
||||
"x_admin/admin/{{{ .ModuleName }}}"
|
||||
)
|
||||
|
||||
@@ -111,6 +111,10 @@ func (service {{{ toCamelCase .EntityName }}}Service) Add(addReq {{{ title (toCa
|
||||
var obj model.{{{ title (toCamelCase .EntityName) }}}
|
||||
response.Copy(&obj, addReq)
|
||||
err := service.db.Create(&obj).Error
|
||||
e = response.CheckMysqlErr(err)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
e = response.CheckErr(err, "Add Create err")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -189,17 +189,19 @@ const formRules = {
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
await formRef.value?.validate()
|
||||
const data: any = { ...formData }
|
||||
{{{- range .Columns }}}
|
||||
{{{- if eq .HtmlType "checkbox" }}}
|
||||
data.{{{ (toCamelCase .GoField) }}} = data.{{{ (toCamelCase .GoField) }}}.join(',')
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
mode.value == 'edit' ? await {{{ .ModuleName }}}_edit(data) : await {{{ .ModuleName }}}_add(data)
|
||||
popupRef.value?.close()
|
||||
feedback.msgSuccess('操作成功')
|
||||
emit('success')
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
const data: any = { ...formData }
|
||||
{{{- range .Columns }}}
|
||||
{{{- if eq .HtmlType "checkbox" }}}
|
||||
data.{{{ (toCamelCase .GoField) }}} = data.{{{ (toCamelCase .GoField) }}}.join(',')
|
||||
{{{- end }}}
|
||||
{{{- end }}}
|
||||
mode.value == 'edit' ? await {{{ .ModuleName }}}_edit(data) : await {{{ .ModuleName }}}_add(data)
|
||||
popupRef.value?.close()
|
||||
feedback.msgSuccess('操作成功')
|
||||
emit('success')
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const open = (type = 'add') => {
|
||||
@@ -223,10 +225,12 @@ const setFormData = async (data: Record<string, any>) => {
|
||||
}
|
||||
|
||||
const getDetail = async (row: Record<string, any>) => {
|
||||
const data = await {{{ .ModuleName }}}_detail({
|
||||
{{{ .PrimaryKey }}}: row.{{{ .PrimaryKey }}}
|
||||
})
|
||||
setFormData(data)
|
||||
try {
|
||||
const data = await {{{ .ModuleName }}}_detail({
|
||||
{{{ .PrimaryKey }}}: row.{{{ .PrimaryKey }}}
|
||||
})
|
||||
setFormData(data)
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
{{{- range .Columns }}}
|
||||
{{{- if eq .IsQuery 1 }}}
|
||||
{{{- if eq .HtmlType "datetime" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" class="w-[280px]">
|
||||
<daterange-picker
|
||||
v-model:startTime="queryParams.createTimeStart"
|
||||
v-model:endTime="queryParams.createTimeEnd"
|
||||
/>
|
||||
</el-form-item>
|
||||
{{{- else if or (eq .HtmlType "select") (eq .HtmlType "radio") }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" class="w-[280px]">
|
||||
<el-select
|
||||
v-model="queryParams.{{{ (toCamelCase .GoField) }}}"
|
||||
clearable
|
||||
@@ -31,7 +31,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{{- else if eq .HtmlType "input" }}}
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}">
|
||||
<el-form-item label="{{{ .ColumnComment }}}" prop="{{{ (toCamelCase .GoField) }}}" class="w-[280px]">
|
||||
<el-input v-model="queryParams.{{{ (toCamelCase .GoField) }}}" />
|
||||
</el-form-item>
|
||||
{{{- end }}}
|
||||
|
||||
Reference in New Issue
Block a user