mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
【修改】template模板
This commit is contained in:
@@ -23,11 +23,19 @@ type {{.ClassName}}Api struct {
|
||||
// @Router /{{.PackageName}}/{{.BusinessName}}/list [get]
|
||||
// @Security
|
||||
func (p *{{.ClassName}}Api) Get{{.ClassName}}List(rc *ctx.ReqCtx) {
|
||||
|
||||
data := entity.{{.ClassName}}{}
|
||||
pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1)
|
||||
pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10)
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsRequired "1" -}}
|
||||
{{- if eq $column.GoType "string" }}
|
||||
data.{{$column.GoField}} = rc.GinCtx.Query("{{$column.JsonField}}")
|
||||
{{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") -}}
|
||||
data.{{$column.GoField}} = ginx.QueryInt(rc.GinCtx, "{{$column.JsonField}}", 0)
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
data := entity.{{.ClassName}}{}
|
||||
list, total := p.{{.ClassName}}App.FindListPage(pageNum, pageSize, data)
|
||||
|
||||
rc.ResData = map[string]interface{}{
|
||||
|
||||
@@ -4,9 +4,14 @@
|
||||
// 生成人:{{.FunctionAuthor}}
|
||||
// ==========================================================================
|
||||
package entity
|
||||
{{$hasGTime:=true}}
|
||||
|
||||
{{if $hasGTime}}import "time"{{end}}
|
||||
{{$hasGTime:=false}}
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.GoType "Time" -}}
|
||||
{{$hasGTime = true}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{if $hasGTime -}}import "time"{{- end }}
|
||||
|
||||
|
||||
type {{.ClassName}} struct {
|
||||
|
||||
@@ -51,10 +51,26 @@ func (m *{{.BusinessName}}ModelImpl) FindListPage(page, pageSize int, data entit
|
||||
offset := pageSize * (page - 1)
|
||||
db := global.Db.Table(m.table)
|
||||
// 此处填写 where参数判断
|
||||
if data.{{.PkGoField}} != 0 {
|
||||
db = db.Where("{{.PkColumn}} = ?", data.{{.PkGoField}})
|
||||
}
|
||||
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsQuery "1" -}}
|
||||
{{ if eq $column.QueryType "LIKE" }}
|
||||
if data.{{$column.GoField}} != "" {
|
||||
db = db.Where("{{$column.ColumnName}} like ?", "%"+data.{{$column.GoField}}+"%")
|
||||
}
|
||||
{{- end -}}
|
||||
{{- if eq $column.QueryType "EQ" -}}
|
||||
{{- if eq $column.GoType "string" }}
|
||||
if data.{{$column.GoField}} != "" {
|
||||
m = m.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
|
||||
}
|
||||
{{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }}
|
||||
if data.{{$column.GoField}} != 0 {
|
||||
m = m.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
|
||||
}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end}}
|
||||
db.Where("delete_time IS NULL")
|
||||
err := db.Count(&total).Error
|
||||
err = db.Order("create_time").Limit(pageSize).Offset(offset).Find(&list).Error
|
||||
@@ -66,10 +82,26 @@ func (m *{{.BusinessName}}ModelImpl) FindList(data entity.{{$model}}) *[]entity.
|
||||
list := make([]entity.{{$model}}, 0)
|
||||
db := global.Db.Table(m.table)
|
||||
// 此处填写 where参数判断
|
||||
if data.{{.PkGoField}} != 0 {
|
||||
db = db.Where("{{.PkColumn}} = ?", data.{{.PkGoField}})
|
||||
}
|
||||
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsQuery "1" -}}
|
||||
{{- if eq $column.QueryType "LIKE" }}
|
||||
if data.{{$column.GoField}} != "" {
|
||||
db = db.Where("{{$column.ColumnName}} like ?", "%"+data.{{$column.GoField}}+"%")
|
||||
}
|
||||
{{- end -}}
|
||||
{{- if eq $column.QueryType "EQ" -}}
|
||||
{{- if eq $column.GoType "string" }}
|
||||
if data.{{$column.GoField}} != "" {
|
||||
db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
|
||||
}
|
||||
{{- else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }}
|
||||
if data.{{$column.GoField}} != 0 {
|
||||
db = db.Where("{{$column.ColumnName}} = ?", data.{{$column.GoField}})
|
||||
}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end}}
|
||||
db.Where("delete_time IS NULL")
|
||||
biz.ErrIsNil(db.Order("create_time").Find(&list).Error, "查询{{.TableComment}}列表失败")
|
||||
return &list
|
||||
|
||||
@@ -10,29 +10,62 @@
|
||||
ref="ruleFormRef"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-row :gutter="35">
|
||||
<el-col :span="24" >
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input
|
||||
v-model="ruleForm.name"
|
||||
placeholder="请输入名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" >
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-radio-group v-model="ruleForm.status">
|
||||
<el-radio
|
||||
v-for="dict in statusOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictValue"
|
||||
>{{"{{"}} dict.dictLabel {{"}}"}}
|
||||
</el-radio>
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if and (eq $column.IsInsert "1") (ne $column.IsPk "1") -}}
|
||||
{{- if eq $column.HtmlType "input" }}
|
||||
el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-input v-model="ruleForm.{{$column.HtmlField}}" placeholder="请输入{{$column.ColumnComment}}" />
|
||||
</el-form-item>
|
||||
{{- else if eq $column.HtmlType "select" }}
|
||||
{{if ne $column.DictType ""}}
|
||||
el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-select v-model="ruleForm.{{$column.JsonField}}" placeholder="请选择{{$column.ColumnComment}}">
|
||||
<el-option
|
||||
v-for="dict in {{$column.JsonField}}Options"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
>{{"{{"}} dict.dictLabel {{"}}"}}</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
{{- else if eq $column.HtmlType "radio" }}
|
||||
{{if ne $column.DictType ""}}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-radio-group v-model="ruleForm.{{$column.JsonField}}">
|
||||
<el-radio
|
||||
v-for="dict in {{$column.JsonField}}Options"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
>{{"{{"}} dict.dictLabel {{"}}"}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
{{- else if eq $column.HtmlType "datetime" }}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-date-picker clearable size="small" style="width: 200px"
|
||||
v-model="ruleForm.{{$column.JsonField}}"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择{{$column.ColumnComment}}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
{{- else if eq $column.HtmlType "textarea" -}}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-input v-model="ruleForm.{{$column.HtmlField}}" type="textarea" placeholder="请输入{{$column.ColumnComment}}" />
|
||||
</el-form-item>
|
||||
{{- else if eq $column.HtmlType "checkbox" }}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.ruleForm}}">
|
||||
<el-checkbox-group v-model="ruleForm.{{$column.ruleForm}}">
|
||||
<el-checkbox
|
||||
v-for="dict in {{$column.ruleForm}}Options"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
>{{"{{"}} dict.dictLabel {{"}}"}}</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
@@ -68,13 +101,14 @@ export default {
|
||||
isShowDialog: false,
|
||||
|
||||
ruleForm: {
|
||||
{{.PkJsonField}}: 0, // ID
|
||||
name: "", // 名称
|
||||
// 更多参数需要遍历,等-等
|
||||
status: "0", //状态
|
||||
|
||||
},
|
||||
// 状态数据字典
|
||||
statusOptions: [],
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if ne $column.DictType "" }}
|
||||
// {{$column.JsonField}}Options字典数据
|
||||
{{$column.JsonField}}Options: [],
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
// 表单校验
|
||||
ruleRules: {
|
||||
|
||||
@@ -91,11 +125,14 @@ export default {
|
||||
}
|
||||
state.isShowDialog = true;
|
||||
|
||||
// 查询状态数据字典
|
||||
proxy.getDicts("sys_normal_disable").then((response: any) => {
|
||||
state.statusOptions = response.data;
|
||||
});
|
||||
};
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if ne $column.DictType "" }}
|
||||
proxy.getDicts("{{$column.DictType}}").then((response: any) => {
|
||||
state.{{$column.JsonField}}Options = response.data;
|
||||
});
|
||||
{{- end -}}
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
// 关闭弹窗
|
||||
const closeDialog = (row?: object) => {
|
||||
|
||||
@@ -8,47 +8,51 @@
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="案例名称" prop="name">
|
||||
<el-input
|
||||
placeholder="请输入案例名称模糊查询"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter="handleQuery"
|
||||
style="width: 240px"
|
||||
v-model="queryParams.name"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select
|
||||
v-model="queryParams.status"
|
||||
placeholder="状态"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in statusOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="mini"
|
||||
@click="handleQuery"
|
||||
>
|
||||
<SvgIcon name="elementSearch" />
|
||||
搜索</el-button>
|
||||
<el-button size="mini" @click="resetQuery">
|
||||
<SvgIcon name="elementRefresh" />
|
||||
重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsRequired "1" -}}
|
||||
{{- if eq $column.HtmlType "input" "textarea" }}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-input
|
||||
v-model="queryParams.{{$column.JsonField}}"
|
||||
placeholder="请输入{{$column.ColumnComment}}"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
{{- else if and (eq $column.HtmlType "select" "radio" "checkbox") (ne $column.DictType "") }}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-select v-model="queryParams.{{$column.JsonField}}" placeholder="请选择{{$column.ColumnComment}}" clearable size="small">
|
||||
<el-option
|
||||
v-for="dict in {{$column.JsonField}}Options"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{- else }}
|
||||
<el-form-item label="{{$column.ColumnComment}}" prop="{{$column.JsonField}}">
|
||||
<el-select v-model="queryParams.{{$column.JsonField}}" placeholder="请选择{{$column.ColumnComment}}" clearable size="small">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
size="mini"
|
||||
@click="handleQuery"
|
||||
>
|
||||
<SvgIcon name="elementSearch" />
|
||||
搜索</el-button>
|
||||
<el-button size="mini" @click="resetQuery">
|
||||
<SvgIcon name="elementRefresh" />
|
||||
重置
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 操作按钮 -->
|
||||
<el-row :gutter="10" class="mb8">
|
||||
@@ -82,19 +86,28 @@
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="编号" align="center" prop="{{.PkJsonField}}" />
|
||||
<el-table-column
|
||||
label="状态"
|
||||
align="center"
|
||||
prop="status"
|
||||
>
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsPk "1"}}
|
||||
<el-table-column label="编号" align="center" prop="{{$column.JsonField}}" />
|
||||
{{- else if and (eq $column.IsList "1") (eq $column.HtmlType "datetime")}}
|
||||
{{- if ne $column.ColumnComment "" }}
|
||||
<el-table-column label="{{$column.ColumnComment}}" align="center" prop="{{$column.JsonField}}" width="180">
|
||||
<template #default="scope">
|
||||
<el-tag
|
||||
:type="scope.row.status === '1' ? 'danger' : 'success'"
|
||||
disable-transitions
|
||||
>{{"{{"}} statusFormat(scope.row){{"}}"}}</el-tag>
|
||||
<span>{{"{{"}} dateStrFormat(scope.row.{{$column.JsonField}}) {{"}}"}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- end -}}
|
||||
{{- else if and (eq $column.IsList "1") (ne $column.DictType "") }}
|
||||
<el-table-column label="{{$column.ColumnComment}}" align="center" prop="{{$column.JsonField}}" >
|
||||
<template #default="scope">
|
||||
<el-tag :type="scope.row.{{$column.JsonField}} === '0' ? 'success': 'warning'" disable-transitions>{{"{{"}} {{$column.JsonField}}Format(scope.row) || '-- --' {{"}}"}}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if and (eq $column.IsList "1") (ne $column.JsonField "") (ne $column.JsonField "createTime") (ne $column.JsonField "updateTime") (ne $column.JsonField "deleteTime") }}
|
||||
{{- if ne $column.ColumnComment "" }}
|
||||
<el-table-column label="{{$column.ColumnComment}}" align="center" prop="{{$column.JsonField}}" />
|
||||
{{- end -}}
|
||||
{{- end -}}{{- end }}
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
@@ -150,7 +163,7 @@ import { list{{.ClassName}}, del{{.ClassName}} } from "/@/api/{{.PackageName}}/{
|
||||
import EditModule from "./component/editModule.vue";
|
||||
|
||||
export default {
|
||||
name: "index",
|
||||
name: "{{.ClassName}}",
|
||||
components: { EditModule },
|
||||
setup() {
|
||||
const { proxy } = getCurrentInstance() as any;
|
||||
@@ -170,8 +183,12 @@ export default {
|
||||
tableData: [],
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 状态数据字典
|
||||
statusOptions: [],
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if ne $column.DictType "" }}
|
||||
// {{$column.JsonField}}Options字典数据
|
||||
{{$column.JsonField}}Options: [],
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
// 页码
|
||||
@@ -179,7 +196,11 @@ export default {
|
||||
// 每页大小
|
||||
pageSize: 10,
|
||||
// 以下为参数
|
||||
// name: undefined,
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if eq $column.IsRequired "1" }}
|
||||
{{$column.JsonField}}: undefined,
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -207,9 +228,13 @@ export default {
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
const statusFormat = (row: any) => {
|
||||
return proxy.selectDictLabel(state.statusOptions, row.status);
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if ne $column.DictType "" }}
|
||||
const {{$column.JsonField}}Format = (row: any) => {
|
||||
return proxy.selectDictLabel(state.{{$column.JsonField}}Options, row.{{$column.JsonField}});
|
||||
};
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
// 打开新增弹窗
|
||||
const onOpenAddModule = (row: object) => {
|
||||
@@ -249,10 +274,14 @@ export default {
|
||||
onMounted(() => {
|
||||
// 查询岗位信息
|
||||
handleQuery();
|
||||
// 查询状态数据字典
|
||||
proxy.getDicts("sys_normal_disable").then((response: any) => {
|
||||
state.statusOptions = response.data;
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if ne $column.DictType "" }}
|
||||
proxy.getDicts("{{$column.DictType}}").then((response: any) => {
|
||||
state.{{$column.JsonField}}Options = response.data;
|
||||
});
|
||||
{{- end -}}
|
||||
{{- end}}
|
||||
|
||||
proxy.mittBus.on("onEdit{{.ClassName}}Module", (res: any) => {
|
||||
handleQuery();
|
||||
});
|
||||
@@ -268,7 +297,11 @@ export default {
|
||||
handleCurrentChange,
|
||||
handleSizeChange,
|
||||
resetQuery,
|
||||
statusFormat,
|
||||
{{- range $index, $column := .Columns -}}
|
||||
{{- if ne $column.DictType "" }}
|
||||
{{$column.JsonField}}Format,
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
onOpenAddModule,
|
||||
onOpenEditModule,
|
||||
onTabelRowDel,
|
||||
|
||||
Reference in New Issue
Block a user