Revert "Merge remote-tracking branch 'upstream/gva_gormv2_dev' into gva_gormv2_dev"

This reverts commit bb33c312b13577fef786a91e0369468d65364b6f, reversing
changes made to b9b4bc6b8b7a9b23efd4dab4cf38110c142cde76.
This commit is contained in:
songzhibin97
2021-08-21 17:55:06 +08:00
parent ce67438ef0
commit 71605850c2
23 changed files with 981 additions and 1770 deletions

View File

@@ -103,7 +103,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Update{{.StructName}}(c *gin.Con
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query autocode.{{.StructName}} true "用id查询{{.StructName}}"
// @Param data body autocode.{{.StructName}} true "用id查询{{.StructName}}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /{{.Abbreviation}}/find{{.StructName}} [get]
func ({{.Abbreviation}}Api *{{.StructName}}Api) Find{{.StructName}}(c *gin.Context) {
@@ -123,7 +123,7 @@ func ({{.Abbreviation}}Api *{{.StructName}}Api) Find{{.StructName}}(c *gin.Conte
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query autocodeReq.{{.StructName}}Search true "分页获取{{.StructName}}列表"
// @Param data body autocodeReq.{{.StructName}}Search true "分页获取{{.StructName}}列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /{{.Abbreviation}}/get{{.StructName}}List [get]
func ({{.Abbreviation}}Api *{{.StructName}}Api) Get{{.StructName}}List(c *gin.Context) {

View File

@@ -69,7 +69,7 @@ export const update{{.StructName}} = (data) => {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query model.{{.StructName}} true "用id查询{{.StructName}}"
// @Param data body model.{{.StructName}} true "用id查询{{.StructName}}"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /{{.Abbreviation}}/find{{.StructName}} [get]
export const find{{.StructName}} = (params) => {
@@ -85,7 +85,7 @@ export const find{{.StructName}} = (params) => {
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data query request.PageInfo true "分页获取{{.StructName}}列表"
// @Param data body request.PageInfo true "分页获取{{.StructName}}列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /{{.Abbreviation}}/get{{.StructName}}List [get]
export const get{{.StructName}}List = (params) => {
@@ -94,4 +94,4 @@ export const get{{.StructName}}List = (params) => {
method: 'get',
params
})
}
}

View File

@@ -3,35 +3,35 @@
<el-form :model="formData" label-position="right" label-width="80px">
{{- range .Fields}}
<el-form-item label="{{.FieldDesc}}:">
{{- if eq .FieldType "bool" }}
<el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" v-model="formData.{{.FieldJson}}" clearable ></el-switch>
{{- end }}
{{- if eq .FieldType "string" }}
<el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" />
{{- end }}
{{- if eq .FieldType "int" }}
{{- if .DictType }}
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable>
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
</el-select>
{{- else }}
<el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入" />
{{- end }}
{{- end }}
{{- if eq .FieldType "time.Time" }}
<el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable></el-date-picker>
{{- end }}
{{- if eq .FieldType "float64" }}
<el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable></el-input-number>
{{- end }}
{{ if eq .FieldType "bool" -}}
<el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" v-model="formData.{{.FieldJson}}" clearable ></el-switch>
{{ end -}}
{{ if eq .FieldType "string" -}}
<el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" />
{{ end -}}
{{ if eq .FieldType "int" -}}
{{ if .DictType -}}
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable>
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value"></el-option>
</el-select>
{{ else -}}
<el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入"/>
{{ end -}}
{{ end -}}
{{ if eq .FieldType "time.Time" }}
<el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable></el-date-picker>
{{ end -}}
{{ if eq .FieldType "float64" }}
<el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable></el-input-number>
{{ end -}}
</el-form-item>
{{- end }}
{{ end -}}
<el-form-item>
<el-button size="mini" type="primary" @click="save">保存</el-button>
<el-button size="mini" type="primary" @click="back">返回</el-button>
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
@@ -47,29 +47,29 @@ export default {
data() {
return {
type: '',
{{- range .Fields}}
{{range .Fields}}
{{- if .DictType }}
{{ .DictType }}Options: [],
{{- end }}
{{- end }}
{{ end -}}
{{end -}}
formData: {
{{- range .Fields}}
{{- if eq .FieldType "bool" }}
{{.FieldJson}}: false,
{{- end }}
{{- if eq .FieldType "string" }}
{{.FieldJson}}: '',
{{- end }}
{{- if eq .FieldType "int" }}
{{.FieldJson}}: 0,
{{- end }}
{{- if eq .FieldType "time.Time" }}
{{.FieldJson}}: new Date(),
{{- end }}
{{- if eq .FieldType "float64" }}
{{.FieldJson}}: 0,
{{- end }}
{{- end }}
{{range .Fields}}
{{- if eq .FieldType "bool" -}}
{{.FieldJson}}: false,
{{ end -}}
{{- if eq .FieldType "string" -}}
{{.FieldJson}}: '',
{{ end -}}
{{- if eq .FieldType "int" -}}
{{.FieldJson}}: 0,
{{ end -}}
{{- if eq .FieldType "time.Time" -}}
{{.FieldJson}}: new Date(),
{{ end -}}
{{- if eq .FieldType "float64" -}}
{{.FieldJson}}: 0,
{{ end -}}
{{ end }}
}
}
},
@@ -84,10 +84,10 @@ export default {
} else {
this.type = 'create'
}
{{- range .Fields }}
{{ range .Fields -}}
{{- if .DictType }}
await this.getDict('{{.DictType}}')
{{- end }}
await this.getDict("{{.DictType}}")
{{ end -}}
{{- end }}
},
methods: {
@@ -119,4 +119,4 @@ export default {
</script>
<style>
</style>
</style>

View File

@@ -19,8 +19,8 @@
</el-form-item>
{{- else }}
<el-form-item label="{{.FieldDesc}}">
<el-input v-model="searchInfo.{{.FieldJson}}" placeholder="搜索条件" />
</el-form-item>{{ end }}{{ end }}{{ end }}
<el-input placeholder="搜索条件" v-model="searchInfo.{{.FieldJson}}" />
</el-form-item> {{ end }} {{ end }} {{ end }}
<el-form-item>
<el-button size="mini" type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
<el-button size="mini" type="primary" icon="el-icon-plus" @click="openDialog">新增</el-button>
@@ -52,16 +52,15 @@
{{- if .DictType}}
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
<template slot-scope="scope">
{{"{{"}} filterDict(scope.row.{{.FieldJson}},"{{.DictType}}") {{"}}"}}
{{"{{"}}filterDict(scope.row.{{.FieldJson}},"{{.DictType}}"){{"}}"}}
</template>
</el-table-column>
{{- else if eq .FieldType "bool" }}
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
<template slot-scope="scope">{{ "{{scope.row."}}{{.FieldJson}}{{"|formatBoolean}}" }}</template>
</el-table-column> {{- else }}
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" />
{{- end }}
{{- end }}
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" /> {{ end -}}
{{ end -}}
<el-table-column label="按钮组">
<template slot-scope="scope">
<el-button size="small" type="primary" icon="el-icon-edit" class="table-button" @click="update{{.StructName}}(scope.row)">变更</el-button>
@@ -83,30 +82,30 @@
<el-form :model="formData" label-position="right" label-width="80px">
{{- range .Fields}}
<el-form-item label="{{.FieldDesc}}:">
{{- if eq .FieldType "bool" }}
{{ if eq .FieldType "bool" }}
<el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" v-model="formData.{{.FieldJson}}" clearable ></el-switch>
{{- end }}
{{- if eq .FieldType "string" }}
{{ end -}}
{{ if eq .FieldType "string" }}
<el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" />
{{- end }}
{{- if eq .FieldType "int" }}
{{ end -}}
{{ if eq .FieldType "int" }}
{{- if .DictType}}
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable>
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
</el-select>
{{- else }}
{{ else }}
<el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入" />
{{- end }}
{{- end }}
{{- if eq .FieldType "time.Time" }}
{{ end -}}
{{ end -}}
{{ if eq .FieldType "time.Time" }}
<el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable />
{{- end }}
{{- if eq .FieldType "float64" }}
{{ end -}}
{{- if eq .FieldType "float64" }}
<el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable />
{{- end }}
</el-form-item>
{{- end }}
</el-form>
{{ end -}}
</el-form-item>
{{- end }}
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="closeDialog">取 消</el-button>
<el-button type="primary" @click="enterDialog">确 定</el-button>
@@ -128,11 +127,45 @@ import { formatTimeToStr } from '@/utils/date'
import infoList from '@/mixins/infoList'
export default {
name: '{{.StructName}}',
mixins: [infoList],
data() {
return {
listApi: get{{ .StructName }}List,
dialogFormVisible: false,
type: '',
deleteVisible: false,
multipleSelection: [],
{{ range .Fields}}
{{- if .DictType }}
{{ .DictType }}Options: [],
{{ end -}}
{{ end }}
formData: {
{{range .Fields}}
{{- if eq .FieldType "bool" -}}
{{.FieldJson}}: false,
{{ end -}}
{{- if eq .FieldType "string" -}}
{{.FieldJson}}: '',
{{ end -}}
{{- if eq .FieldType "int" -}}
{{.FieldJson}}: 0,
{{ end -}}
{{- if eq .FieldType "time.Time" -}}
{{.FieldJson}}: new Date(),
{{ end -}}
{{- if eq .FieldType "float64" -}}
{{.FieldJson}}: 0,
{{ end -}}
{{ end }}
}
}
},
filters: {
formatDate: function(time) {
if (time !== null && time !== '') {
var date = new Date(time)
return formatTimeToStr(date, 'yyyy-MM-dd hh:mm:ss')
var date = new Date(time);
return formatTimeToStr(date, 'yyyy-MM-dd hh:mm:ss');
} else {
return ''
}
@@ -145,57 +178,23 @@ export default {
}
}
},
mixins: [infoList],
data() {
return {
listApi: get{{ .StructName }}List,
dialogFormVisible: false,
type: '',
deleteVisible: false,
multipleSelection: [],
{{- range .Fields}}
{{- if .DictType }}
{{ .DictType }}Options: [],
{{- end }}
{{- end }}
formData: {
{{- range .Fields}}
{{- if eq .FieldType "bool" }}
{{.FieldJson}}: false,
{{- end }}
{{- if eq .FieldType "string" }}
{{.FieldJson}}: '',
{{- end }}
{{- if eq .FieldType "int" }}
{{.FieldJson}}: 0,
{{- end }}
{{- if eq .FieldType "time.Time" }}
{{.FieldJson}}: new Date(),
{{- end }}
{{- if eq .FieldType "float64" }}
{{.FieldJson}}: 0,
{{- end }}
{{- end }}
}
}
},
async created() {
await this.getTableData()
{{- range .Fields }}
{{- if .DictType }}
{{ range .Fields -}}
{{- if .DictType }}
await this.getDict('{{.DictType}}')
{{- end }}
{{- end }}
{{ end -}}
{{- end }}
},
methods: {
//
onSubmit() {
this.page = 1
this.pageSize = 10
{{- range .Fields}}{{- if eq .FieldType "bool" }}
{{- range .Fields}} {{- if eq .FieldType "bool" }}
if (this.searchInfo.{{.FieldJson}} === ""){
this.searchInfo.{{.FieldJson}}=null
}{{ end }}{{ end }}
} {{ end }} {{ end }}
this.getTableData()
},
handleSelectionChange(val) {
@@ -247,23 +246,23 @@ export default {
closeDialog() {
this.dialogFormVisible = false
this.formData = {
{{- range .Fields}}
{{- if eq .FieldType "bool" }}
{{range .Fields}}
{{- if eq .FieldType "bool" -}}
{{.FieldJson}}: false,
{{- end }}
{{- if eq .FieldType "string" }}
{{ end -}}
{{- if eq .FieldType "string" -}}
{{.FieldJson}}: '',
{{- end }}
{{- if eq .FieldType "int" }}
{{ end -}}
{{- if eq .FieldType "int" -}}
{{.FieldJson}}: 0,
{{- end }}
{{- if eq .FieldType "time.Time" }}
{{ end -}}
{{- if eq .FieldType "time.Time" -}}
{{.FieldJson}}: new Date(),
{{- end }}
{{- if eq .FieldType "float64" }}
{{ end -}}
{{- if eq .FieldType "float64" -}}
{{.FieldJson}}: 0,
{{- end }}
{{- end }}
{{ end -}}
{{ end }}
}
},
async delete{{.StructName}}(row) {
@@ -273,7 +272,7 @@ export default {
type: 'success',
message: '删除成功'
})
if (this.tableData.length === 1 && this.page > 1) {
if (this.tableData.length === 1 && this.page > 1 ) {
this.page--
}
this.getTableData()
@@ -282,10 +281,10 @@ export default {
async enterDialog() {
let res
switch (this.type) {
case 'create':
case "create":
res = await create{{.StructName}}(this.formData)
break
case 'update':
case "update":
res = await update{{.StructName}}(this.formData)
break
default: