发布v2.7.8Beta1 (#1957)
* beta:2.7.8-a 增加自动化创建树形结构 (#1941) * feat: 支持创建树形结构 --------- Co-authored-by: piexlMax(奇淼 <qimiaojiangjizhao@gmail.com> * 优化user store部分写法 * Update user.js * feat: 升级版本号 * Dev 278 beta2 (#1954) * 在关闭详情弹窗后 detailFrom为空对象,arr为undefined 使用slice控制台会报错 * 查询不重置pageSize * 优化主题模式相关内容 * 优化弹窗手机端显示 * bugfix:PostgreSQL initdb (#1953) * bugfix:postgresql增加显示指定template --------- Co-authored-by: PiexlMax(奇淼 <165128580+pixelmaxQm@users.noreply.github.com> --------- Co-authored-by: zayn <972858472@qq.com> Co-authored-by: Azir <2075125282@qq.com> Co-authored-by: Qing Liang <106448173+xue-ding-e@users.noreply.github.com> * docs:调整部分代码注释以及代码格式 * feat: 自动化代码字典支持多选 * fix:调整值接收器和指针接收器 * feat: 支持导出表格复制,优化增加方法页面。 * chore:初始化代码规范化。 --------- Co-authored-by: piexlMax(奇淼 <qimiaojiangjizhao@gmail.com> Co-authored-by: Azir <2075125282@qq.com> Co-authored-by: zayn <972858472@qq.com> Co-authored-by: Qing Liang <106448173+xue-ding-e@users.noreply.github.com> Co-authored-by: cjb <75364055@qq.com>
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "string" }}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-select {{if eq .FieldType "array"}}multiple {{end}}v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
@@ -95,7 +95,7 @@ const {{ $element }}Options = ref([])
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
{{.FieldJson}}: {{- if or .DictType .DataSource}} undefined{{ else }} 0{{- end }},
|
||||
{{.FieldJson}}: {{- if or .DataSource}} undefined{{ else }} 0{{- end }},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
{{.FieldJson}}: new Date(),
|
||||
@@ -148,6 +148,7 @@ const {{ $element }}Options = ref([])
|
||||
{{- if .HasDataSource }}
|
||||
// 请引用
|
||||
get{{.StructName}}DataSource,
|
||||
|
||||
// 获取数据源
|
||||
const dataSource = ref([])
|
||||
const getDataSourceFunc = async()=>{
|
||||
@@ -159,13 +160,27 @@ const getDataSourceFunc = async()=>{
|
||||
getDataSourceFunc()
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
{{- if not .OnlyTemplate}}
|
||||
{{- if not .OnlyTemplate }}
|
||||
<template>
|
||||
<div>
|
||||
<div class="gva-form-box">
|
||||
<el-form :model="formData" ref="elFormRef" label-position="right" :rules="rule" label-width="80px">
|
||||
{{- if .IsTree }}
|
||||
<el-form-item label="父节点:" prop="parentID" >
|
||||
<el-tree-select
|
||||
v-model="formData.parentID"
|
||||
:data="[rootNode,...tableData]"
|
||||
check-strictly
|
||||
:render-after-expand="false"
|
||||
:props="defaultProps"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
placeholder="根节点"
|
||||
/>
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
{{- range .Fields}}
|
||||
{{- if .Form }}
|
||||
{{- if .Form }}
|
||||
<el-form-item label="{{.FieldDesc}}:" prop="{{.FieldJson}}">
|
||||
{{- if .CheckDataSource}}
|
||||
<el-select {{if eq .DataSource.Association 2}} multiple {{ end }} v-model="formData.{{.FieldJson}}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
@@ -177,7 +192,7 @@ getDataSourceFunc()
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "string" }}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-select {{if eq .FieldType "array"}}multiple {{end}}v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
@@ -219,13 +234,13 @@ getDataSourceFunc()
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
<ArrayCtrl v-model="formData.{{ .FieldJson }}" editable/>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="save">保存</el-button>
|
||||
<el-button :loading="btnLoading" type="primary" @click="save">保存</el-button>
|
||||
<el-button type="primary" @click="back">返回</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -238,10 +253,13 @@ import {
|
||||
{{- if .HasDataSource }}
|
||||
get{{.StructName}}DataSource,
|
||||
{{- end }}
|
||||
{{- if .IsTree }}
|
||||
get{{.StructName}}List,
|
||||
{{- end }}
|
||||
create{{.StructName}},
|
||||
update{{.StructName}},
|
||||
find{{.StructName}}
|
||||
} from '@/plugin/{{.Package}}/api/{{.PackageName}}'
|
||||
} from '@/api/{{.Package}}/{{.PackageName}}'
|
||||
|
||||
defineOptions({
|
||||
name: '{{.StructName}}Form'
|
||||
@@ -272,14 +290,47 @@ import RichEdit from '@/components/richtext/rich-edit.vue'
|
||||
import ArrayCtrl from '@/components/arrayCtrl/arrayCtrl.vue'
|
||||
{{- end }}
|
||||
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
{{- if .IsTree }}
|
||||
const tableData = ref([])
|
||||
|
||||
const defaultProps = {
|
||||
children: "children",
|
||||
label: "{{ .TreeJson }}",
|
||||
value: "{{ .PrimaryField.FieldJson }}"
|
||||
}
|
||||
|
||||
const rootNode = {
|
||||
{{ .PrimaryField.FieldJson }}: 0,
|
||||
{{ .TreeJson }}: '根节点',
|
||||
children: []
|
||||
}
|
||||
|
||||
const getTableData = async() => {
|
||||
const table = await get{{.StructName}}List()
|
||||
if (table.code === 0) {
|
||||
tableData.value = table.data || []
|
||||
}
|
||||
}
|
||||
|
||||
getTableData()
|
||||
|
||||
{{- end }}
|
||||
|
||||
// 提交按钮loading
|
||||
const btnLoading = ref(false)
|
||||
|
||||
const type = ref('')
|
||||
{{- range $index, $element := .DictTypes}}
|
||||
const {{ $element }}Options = ref([])
|
||||
{{- end }}
|
||||
const formData = ref({
|
||||
{{- if .IsTree }}
|
||||
parentID: undefined,
|
||||
{{- end }}
|
||||
{{- range .Fields}}
|
||||
{{- if .Form }}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
@@ -292,7 +343,7 @@ const formData = ref({
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
{{.FieldJson}}: {{- if or .DictType .DataSource }} undefined{{ else }} 0{{- end }},
|
||||
{{.FieldJson}}: {{- if or .DataSource }} undefined{{ else }} 0{{- end }},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
{{.FieldJson}}: new Date(),
|
||||
@@ -324,7 +375,6 @@ const formData = ref({
|
||||
// 验证规则
|
||||
const rule = reactive({
|
||||
{{- range .Fields }}
|
||||
{{- if .Form }}
|
||||
{{- if eq .Require true }}
|
||||
{{.FieldJson }} : [{
|
||||
required: true,
|
||||
@@ -332,7 +382,6 @@ const rule = reactive({
|
||||
trigger: ['input','blur'],
|
||||
}],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
})
|
||||
|
||||
@@ -369,8 +418,9 @@ const init = async () => {
|
||||
init()
|
||||
// 保存按钮
|
||||
const save = async() => {
|
||||
btnLoading.value = true
|
||||
elFormRef.value?.validate( async (valid) => {
|
||||
if (!valid) return
|
||||
if (!valid) return btnLoading.value = false
|
||||
let res
|
||||
switch (type.value) {
|
||||
case 'create':
|
||||
@@ -383,6 +433,7 @@ const save = async() => {
|
||||
res = await create{{.StructName}}(formData.value)
|
||||
break
|
||||
}
|
||||
btnLoading.value = false
|
||||
if (res.code === 0) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
|
@@ -1,6 +1,5 @@
|
||||
{{- $global := . }}
|
||||
{{- $templateID := printf "%s_%s" .Package .StructName }}
|
||||
|
||||
{{- if .IsAdd }}
|
||||
// 请在搜索条件中增加如下代码
|
||||
{{- range .Fields}} {{- if .FieldSearchType}} {{- if eq .FieldType "bool" }}
|
||||
@@ -20,7 +19,7 @@
|
||||
</el-form-item>
|
||||
{{- else if .DictType}}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" clearable placeholder="请选择" @clear="()=>{searchInfo.{{.FieldJson}}=undefined}">
|
||||
<el-select {{if eq .FieldType "array"}}multiple {{end}}v-model="searchInfo.{{.FieldJson}}" clearable placeholder="请选择" @clear="()=>{searchInfo.{{.FieldJson}}=undefined}">
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -38,13 +37,7 @@
|
||||
—
|
||||
<el-input v-model.number="searchInfo.end{{.FieldName}}" placeholder="最大值" />
|
||||
{{- else}}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" placeholder="请选择" style="width:100%" :clearable="true" >
|
||||
<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="searchInfo.{{.FieldJson}}" placeholder="搜索条件" />
|
||||
{{- end }}
|
||||
{{- end}}
|
||||
{{- else if eq .FieldType "time.Time"}}
|
||||
{{if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
|
||||
@@ -87,7 +80,11 @@
|
||||
{{- else if .DictType}}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
|
||||
<template #default="scope">
|
||||
{{if eq .FieldType "array"}}
|
||||
<el-tag class="mr-1" v-for="item in scope.row.{{.FieldJson}}" :key="item"> {{"{{"}} filterDict(item,{{.DictType}}Options) {{"}}"}}</el-tag>
|
||||
{{- else }}
|
||||
{{"{{"}} filterDict(scope.row.{{.FieldJson}},{{.DictType}}Options) {{"}}"}}
|
||||
{{end}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "bool" }}
|
||||
@@ -185,8 +182,14 @@
|
||||
{{"{{"}} formData.{{.FieldJson}} {{"}}"}}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
{{- if .DictType}}
|
||||
<el-select multiple v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
<ArrayCtrl v-model="formData.{{ .FieldJson }}" editable/>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
<el-input v-model.number="formData.{{ .FieldJson }}" :clearable="{{.Clearable}}" placeholder="请输入{{.FieldDesc}}" />
|
||||
{{- end }}
|
||||
@@ -272,6 +275,7 @@
|
||||
{{- range $index, $element := .DictTypes}}
|
||||
const {{ $element }}Options = ref([])
|
||||
{{- end }}
|
||||
|
||||
// setOptions方法中增加如下调用
|
||||
|
||||
{{- range $index, $element := .DictTypes }}
|
||||
@@ -291,7 +295,7 @@ const {{ $element }}Options = ref([])
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
{{.FieldJson}}: {{- if or .DictType .DataSource}} undefined{{ else }} 0{{- end }},
|
||||
{{.FieldJson}}: {{- if .DataSource}} undefined{{ else }} 0{{- end }},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
{{.FieldJson}}: new Date(),
|
||||
@@ -341,15 +345,18 @@ const {{ $element }}Options = ref([])
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
|
||||
{{- if .HasDataSource }}
|
||||
// 请引用
|
||||
get{{.StructName}}DataSource,
|
||||
|
||||
// 获取数据源
|
||||
const dataSource = ref({})
|
||||
const getDataSourceFunc = async()=>{
|
||||
const res = await get{{.StructName}}DataSource()
|
||||
if (res.code === 0) {
|
||||
dataSource.value = res.data
|
||||
dataSource.value = res.data || []
|
||||
}
|
||||
}
|
||||
getDataSourceFunc()
|
||||
@@ -360,6 +367,7 @@ getDataSourceFunc()
|
||||
{{- if not .OnlyTemplate}}
|
||||
<template>
|
||||
<div>
|
||||
{{- if not .IsTree }}
|
||||
<div class="gva-search-box">
|
||||
<el-form ref="elSearchFormRef" :inline="true" :model="searchInfo" class="demo-form-inline" :rules="searchRule" @keyup.enter="onSubmit">
|
||||
{{- if .GvaModel }}
|
||||
@@ -394,15 +402,15 @@ getDataSourceFunc()
|
||||
</el-form-item>
|
||||
{{- else if .DictType}}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" clearable placeholder="请选择" @clear="()=>{searchInfo.{{.FieldJson}}=undefined}">
|
||||
<el-select {{if eq .FieldType "array"}} multiple {{end}}v-model="searchInfo.{{.FieldJson}}" clearable placeholder="请选择" @clear="()=>{searchInfo.{{.FieldJson}}=undefined}">
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{- else if .CheckDataSource}}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
<el-select {{if eq .DataSource.Association 2}} multiple {{ end }} v-model="searchInfo.{{.FieldJson}}" placeholder="请选择{{.FieldDesc}}" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in dataSource.{{.FieldJson}}" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else if .CheckDataSource}}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
<el-select {{if eq .DataSource.Association 2}} multiple {{ end }} v-model="searchInfo.{{.FieldJson}}" placeholder="请选择{{.FieldDesc}}" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in dataSource.{{.FieldJson}}" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
{{- else}}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
@@ -412,13 +420,7 @@ getDataSourceFunc()
|
||||
—
|
||||
<el-input v-model.number="searchInfo.end{{.FieldName}}" placeholder="最大值" />
|
||||
{{- else}}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" placeholder="请选择" style="width:100%" :clearable="true" >
|
||||
<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="searchInfo.{{.FieldJson}}" placeholder="搜索条件" />
|
||||
{{- end }}
|
||||
{{- end}}
|
||||
{{- else if eq .FieldType "time.Time"}}
|
||||
{{if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
|
||||
@@ -439,7 +441,6 @@ getDataSourceFunc()
|
||||
{{- else}}
|
||||
<el-input v-model="searchInfo.{{.FieldJson}}" placeholder="搜索条件" />
|
||||
{{- end}}
|
||||
|
||||
</el-form-item>{{ end }}{{ end }}{{ end }}{{ end }}
|
||||
|
||||
<template v-if="showAllQuery">
|
||||
@@ -461,7 +462,7 @@ getDataSourceFunc()
|
||||
</el-form-item>
|
||||
{{- else if .DictType}}
|
||||
<el-form-item label="{{.FieldDesc}}" prop="{{.FieldJson}}">
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" clearable placeholder="请选择" @clear="()=>{searchInfo.{{.FieldJson}}=undefined}">
|
||||
<el-select {{if eq .FieldType "array"}}multiple {{end}}v-model="searchInfo.{{.FieldJson}}" clearable placeholder="请选择" @clear="()=>{searchInfo.{{.FieldJson}}=undefined}">
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -473,13 +474,7 @@ getDataSourceFunc()
|
||||
—
|
||||
<el-input v-model.number="searchInfo.end{{.FieldName}}" placeholder="最大值" />
|
||||
{{- else}}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="searchInfo.{{.FieldJson}}" placeholder="请选择" style="width:100%" :clearable="true" >
|
||||
<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="searchInfo.{{.FieldJson}}" placeholder="搜索条件" />
|
||||
{{- end }}
|
||||
{{- end}}
|
||||
{{- else if eq .FieldType "time.Time"}}
|
||||
{{if eq .FieldSearchType "BETWEEN" "NOT BETWEEN"}}
|
||||
@@ -513,9 +508,10 @@ getDataSourceFunc()
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
{{- end }}
|
||||
<div class="gva-table-box">
|
||||
<div class="gva-btn-list">
|
||||
<el-button {{ if $global.AutoCreateBtnAuth }}v-auth="btnAuth.add"{{ end }} type="primary" icon="plus" @click="openDialog">新增</el-button>
|
||||
<el-button {{ if $global.AutoCreateBtnAuth }}v-auth="btnAuth.add"{{ end }} type="primary" icon="plus" @click="openDialog()">新增</el-button>
|
||||
<el-button {{ if $global.AutoCreateBtnAuth }}v-auth="btnAuth.batchDelete"{{ end }} icon="delete" style="margin-left: 10px;" :disabled="!multipleSelection.length" @click="onDelete">删除</el-button>
|
||||
{{ if .HasExcel -}}
|
||||
<ExportTemplate {{ if $global.AutoCreateBtnAuth }}v-auth="btnAuth.exportTemplate"{{ end }} template-id="{{$templateID}}" />
|
||||
@@ -536,7 +532,7 @@ getDataSourceFunc()
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
{{ if .GvaModel }}
|
||||
<el-table-column align="left" label="日期" prop="createdAt" width="180">
|
||||
<el-table-column align="left" label="日期" prop="createdAt" {{- if .IsTree }} min-{{- end }}width="180">
|
||||
<template #default="scope">{{ "{{ formatDate(scope.row.CreatedAt) }}" }}</template>
|
||||
</el-table-column>
|
||||
{{ end }}
|
||||
@@ -557,7 +553,11 @@ getDataSourceFunc()
|
||||
{{- else if .DictType}}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
|
||||
<template #default="scope">
|
||||
{{"{{"}} filterDict(scope.row.{{.FieldJson}},{{.DictType}}Options) {{"}}"}}
|
||||
{{if eq .FieldType "array"}}
|
||||
<el-tag class="mr-1" v-for="item in scope.row.{{.FieldJson}}" :key="item"> {{"{{"}} filterDict(item,{{.DictType}}Options) {{"}}"}}</el-tag>
|
||||
{{- else }}
|
||||
{{"{{"}} filterDict(scope.row.{{.FieldJson}},{{.DictType}}Options) {{"}}"}}
|
||||
{{end}}
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "bool" }}
|
||||
@@ -614,22 +614,25 @@ getDataSourceFunc()
|
||||
[JSON]
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else if eq .FieldType "array" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
{{- else if eq .FieldType "array" }}
|
||||
<el-table-column label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="200">
|
||||
<template #default="scope">
|
||||
<ArrayCtrl v-model="scope.row.{{ .FieldJson }}"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" />
|
||||
{{- end }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
{{- else }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120" />
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
<el-table-column align="left" label="操作" fixed="right" min-width="240">
|
||||
<template #default="scope">
|
||||
{{- if .IsTree }}
|
||||
<el-button {{ if $global.AutoCreateBtnAuth }}v-auth="btnAuth.add"{{ end }} type="primary" link class="table-button" @click="openDialog(scope.row)"><el-icon style="margin-right: 5px"><InfoFilled /></el-icon>新增子节点</el-button>
|
||||
{{- end }}
|
||||
<el-button {{ if $global.AutoCreateBtnAuth }}v-auth="btnAuth.info"{{ end }} type="primary" link class="table-button" @click="getDetails(scope.row)"><el-icon style="margin-right: 5px"><InfoFilled /></el-icon>查看</el-button>
|
||||
<el-button {{ if $global.AutoCreateBtnAuth }}v-auth="btnAuth.edit"{{ end }} type="primary" link icon="edit" class="table-button" @click="update{{.StructName}}Func(scope.row)">编辑</el-button>
|
||||
<el-button {{ if $global.AutoCreateBtnAuth }}v-auth="btnAuth.delete"{{ end }} type="primary" link icon="delete" @click="deleteRow(scope.row)">删除</el-button>
|
||||
<el-button {{ if .IsTree }}v-if="!scope.row.children?.length"{{ end }} {{ if $global.AutoCreateBtnAuth }}v-auth="btnAuth.delete"{{ end }} type="primary" link icon="delete" @click="deleteRow(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -650,15 +653,29 @@ getDataSourceFunc()
|
||||
<div class="flex justify-between items-center">
|
||||
<span class="text-lg">{{"{{"}}type==='create'?'新增':'编辑'{{"}}"}}</span>
|
||||
<div>
|
||||
<el-button type="primary" @click="enterDialog">确 定</el-button>
|
||||
<el-button :loading="btnLoading" type="primary" @click="enterDialog">确 定</el-button>
|
||||
<el-button @click="closeDialog">取 消</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-form :model="formData" label-position="top" ref="elFormRef" :rules="rule" label-width="80px">
|
||||
{{- if .IsTree }}
|
||||
<el-form-item label="父节点:" prop="parentID" >
|
||||
<el-tree-select
|
||||
v-model="formData.parentID"
|
||||
:data="[rootNode,...tableData]"
|
||||
check-strictly
|
||||
:render-after-expand="false"
|
||||
:props="defaultProps"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
placeholder="根节点"
|
||||
/>
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
{{- range .Fields}}
|
||||
{{- if .Form}}
|
||||
{{- if .Form}}
|
||||
<el-form-item label="{{.FieldDesc}}:" prop="{{.FieldJson}}" >
|
||||
{{- if .CheckDataSource}}
|
||||
<el-select {{if eq .DataSource.Association 2}} multiple {{ end }} v-model="formData.{{.FieldJson}}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
@@ -685,7 +702,13 @@ getDataSourceFunc()
|
||||
{{"{{"}} formData.{{.FieldJson}} {{"}}"}}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
{{- if .DictType}}
|
||||
<el-select multiple v-model="formData.{{ .FieldJson }}" placeholder="请选择{{.FieldDesc}}" style="width:100%" :clearable="{{.Clearable}}" >
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
{{- else }}
|
||||
<ArrayCtrl v-model="formData.{{ .FieldJson }}" editable/>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
<el-input v-model.number="formData.{{ .FieldJson }}" :clearable="{{.Clearable}}" placeholder="请输入{{.FieldDesc}}" />
|
||||
@@ -730,51 +753,70 @@ getDataSourceFunc()
|
||||
</el-form>
|
||||
</el-drawer>
|
||||
|
||||
|
||||
|
||||
<el-drawer destroy-on-close size="800" v-model="detailShow" :show-close="true" :before-close="closeDetailShow" title="查看">
|
||||
<el-descriptions column="1" border>
|
||||
{{- range .Fields}}
|
||||
{{- if .Desc }}
|
||||
<el-descriptions-item label="{{ .FieldDesc }}">
|
||||
{{- if .CheckDataSource }}
|
||||
<template #default="scope">
|
||||
{{- if eq .DataSource.Association 2}}
|
||||
<el-tag v-for="(item,key) in filterDataSource(dataSource.{{.FieldJson}},detailFrom.{{.FieldJson}})" :key="key">
|
||||
{{ "{{ item }}" }}
|
||||
</el-tag>
|
||||
{{- else }}
|
||||
<span>{{"{{"}} filterDataSource(dataSource.{{.FieldJson}},detailFrom.{{.FieldJson}}) {{"}}"}}</span>
|
||||
{{- end }}
|
||||
</template>
|
||||
<el-drawer destroy-on-close size="800" v-model="detailShow" :show-close="true" :before-close="closeDetailShow" title="查看">
|
||||
<el-descriptions :column="1" border>
|
||||
{{- if .IsTree }}
|
||||
<el-descriptions-item label="父节点">
|
||||
<el-tree-select
|
||||
v-model="detailFrom.parentID"
|
||||
:data="[rootNode,...tableData]"
|
||||
check-strictly
|
||||
disabled
|
||||
:render-after-expand="false"
|
||||
:props="defaultProps"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
placeholder="根节点"
|
||||
/>
|
||||
</el-descriptions-item>
|
||||
{{- end }}
|
||||
{{- range .Fields}}
|
||||
{{- if .Desc }}
|
||||
<el-descriptions-item label="{{ .FieldDesc }}">
|
||||
{{- if .CheckDataSource }}
|
||||
<template #default="scope">
|
||||
{{- if eq .DataSource.Association 2}}
|
||||
<el-tag v-for="(item,key) in filterDataSource(dataSource.{{.FieldJson}},detailFrom.{{.FieldJson}})" :key="key">
|
||||
{{ "{{ item }}" }}
|
||||
</el-tag>
|
||||
{{- else }}
|
||||
<span>{{"{{"}} filterDataSource(dataSource.{{.FieldJson}},detailFrom.{{.FieldJson}}) {{"}}"}}</span>
|
||||
{{- end }}
|
||||
</template>
|
||||
{{- else if .DictType}}
|
||||
<template #default="scope">
|
||||
{{if eq .FieldType "array"}}
|
||||
<el-tag class="mr-1" v-for="item in detailFrom.{{.FieldJson}}" :key="item"> {{"{{"}} filterDict(item,{{.DictType}}Options) {{"}}"}}</el-tag>
|
||||
{{- else }}
|
||||
{{"{{"}} filterDict(detailFrom.{{.FieldJson}},{{.DictType}}Options) {{"}}"}}
|
||||
{{end}}
|
||||
</template>
|
||||
{{- else if and (ne .FieldType "picture" ) (ne .FieldType "pictures" ) (ne .FieldType "file" ) (ne .FieldType "array" ) }}
|
||||
{{"{{"}} detailFrom.{{.FieldJson}} {{"}}"}}
|
||||
{{- else }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
<el-image style="width: 50px; height: 50px" :preview-src-list="returnArrImg(detailFrom.{{ .FieldJson }})" :src="getUrl(detailFrom.{{ .FieldJson }})" fit="cover" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
<ArrayCtrl v-model="detailFrom.{{ .FieldJson }}"/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
<el-image style="width: 50px; height: 50px; margin-right: 10px" :preview-src-list="returnArrImg(detailFrom.{{ .FieldJson }})" :initial-index="index" v-for="(item,index) in detailFrom.{{ .FieldJson }}" :key="index" :src="getUrl(item)" fit="cover" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
<div class="fileBtn" v-for="(item,index) in detailFrom.{{ .FieldJson }}" :key="index">
|
||||
<el-button type="primary" text bg @click="onDownloadFile(item.url)">
|
||||
<el-icon style="margin-right: 5px"><Download /></el-icon>
|
||||
{{"{{"}}item.name{{"}}"}}
|
||||
</el-button>
|
||||
</div>
|
||||
{{- end }}
|
||||
{{"{{"}} detailFrom.{{.FieldJson}} {{"}}"}}
|
||||
{{- else }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
<el-image style="width: 50px; height: 50px" :preview-src-list="returnArrImg(detailFrom.{{ .FieldJson }})" :src="getUrl(detailFrom.{{ .FieldJson }})" fit="cover" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "array" }}
|
||||
<ArrayCtrl v-model="detailFrom.{{ .FieldJson }}"/>
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "pictures" }}
|
||||
<el-image style="width: 50px; height: 50px; margin-right: 10px" :preview-src-list="returnArrImg(detailFrom.{{ .FieldJson }})" :initial-index="index" v-for="(item,index) in detailFrom.{{ .FieldJson }}" :key="index" :src="getUrl(item)" fit="cover" />
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "file" }}
|
||||
<div class="fileBtn" v-for="(item,index) in detailFrom.{{ .FieldJson }}" :key="index">
|
||||
<el-button type="primary" text bg @click="onDownloadFile(item.url)">
|
||||
<el-icon style="margin-right: 5px"><Download /></el-icon>
|
||||
{{"{{"}}item.name{{"}}"}}
|
||||
</el-button>
|
||||
</div>
|
||||
{{- end }}
|
||||
</el-descriptions-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-descriptions>
|
||||
</el-drawer>
|
||||
|
||||
|
||||
</el-descriptions-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-descriptions>
|
||||
</el-drawer>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
@@ -805,7 +847,6 @@ import SelectImage from '@/components/selectImage/selectImage.vue'
|
||||
import RichEdit from '@/components/richtext/rich-edit.vue'
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{- if .HasFile }}
|
||||
// 文件选择组件
|
||||
import SelectFile from '@/components/selectFile/selectFile.vue'
|
||||
@@ -844,6 +885,9 @@ defineOptions({
|
||||
const btnAuth = useBtnAuth()
|
||||
{{- end }}
|
||||
|
||||
// 提交按钮loading
|
||||
const btnLoading = ref(false)
|
||||
|
||||
// 控制更多查询条件显示/隐藏状态
|
||||
const showAllQuery = ref(false)
|
||||
|
||||
@@ -852,45 +896,48 @@ const showAllQuery = ref(false)
|
||||
const {{ $element }}Options = ref([])
|
||||
{{- end }}
|
||||
const formData = ref({
|
||||
{{- if .IsTree }}
|
||||
parentID:undefined,
|
||||
{{- 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 }}
|
||||
{{- 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 .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 }}
|
||||
})
|
||||
|
||||
@@ -910,7 +957,7 @@ const formData = ref({
|
||||
// 验证规则
|
||||
const rule = reactive({
|
||||
{{- range .Fields }}
|
||||
{{- if .Form }}
|
||||
{{- if .Form }}
|
||||
{{- if eq .Require true }}
|
||||
{{.FieldJson }} : [{
|
||||
required: true,
|
||||
@@ -926,7 +973,7 @@ const rule = reactive({
|
||||
{{- end }}
|
||||
],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
})
|
||||
|
||||
@@ -978,13 +1025,13 @@ const searchInfo = ref({})
|
||||
const sortChange = ({ prop, order }) => {
|
||||
const sortMap = {
|
||||
{{- range .Fields}}
|
||||
{{- if .Table}}
|
||||
{{- if and .Sort}}
|
||||
{{- if not (eq .ColumnName "")}}
|
||||
{{.FieldJson}}: '{{.ColumnName}}',
|
||||
{{- end}}
|
||||
{{- if .Table}}
|
||||
{{- if and .Sort}}
|
||||
{{- if not (eq .ColumnName "")}}
|
||||
{{.FieldJson}}: '{{.ColumnName}}',
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
}
|
||||
|
||||
@@ -999,6 +1046,7 @@ const sortChange = ({ prop, order }) => {
|
||||
}
|
||||
{{- end}}
|
||||
|
||||
{{- if not .IsTree }}
|
||||
// 重置
|
||||
const onReset = () => {
|
||||
searchInfo.value = {}
|
||||
@@ -1040,6 +1088,28 @@ const getTableData = async() => {
|
||||
pageSize.value = table.data.pageSize
|
||||
}
|
||||
}
|
||||
{{- else }}
|
||||
// 树选择器配置
|
||||
const defaultProps = {
|
||||
children: "children",
|
||||
label: "{{ .TreeJson }}",
|
||||
value: "{{ .PrimaryField.FieldJson }}"
|
||||
}
|
||||
|
||||
const rootNode = {
|
||||
{{ .PrimaryField.FieldJson }}: 0,
|
||||
{{ .TreeJson }}: '根节点',
|
||||
children: []
|
||||
}
|
||||
|
||||
// 查询
|
||||
const getTableData = async() => {
|
||||
const table = await get{{.StructName}}List()
|
||||
if (table.code === 0) {
|
||||
tableData.value = table.data || []
|
||||
}
|
||||
}
|
||||
{{- end }}
|
||||
|
||||
getTableData()
|
||||
|
||||
@@ -1140,8 +1210,11 @@ const delete{{.StructName}}Func = async (row) => {
|
||||
const dialogFormVisible = ref(false)
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = () => {
|
||||
const openDialog = ({{- if .IsTree -}}row{{- end -}}) => {
|
||||
type.value = 'create'
|
||||
{{- if .IsTree }}
|
||||
formData.value.parentID = row ? row.{{.PrimaryField.FieldJson}} : undefined
|
||||
{{- end }}
|
||||
dialogFormVisible.value = true
|
||||
}
|
||||
|
||||
@@ -1161,7 +1234,7 @@ const closeDialog = () => {
|
||||
{{.FieldJson}}: '',
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "int" }}
|
||||
{{.FieldJson}}: {{- if or .DictType .DataSource }} undefined{{ else }} 0{{- end }},
|
||||
{{.FieldJson}}: {{- if .DataSource }} undefined{{ else }} 0{{- end }},
|
||||
{{- end }}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
{{.FieldJson}}: new Date(),
|
||||
@@ -1193,8 +1266,9 @@ const closeDialog = () => {
|
||||
}
|
||||
// 弹窗确定
|
||||
const enterDialog = async () => {
|
||||
btnLoading.value = true
|
||||
elFormRef.value?.validate( async (valid) => {
|
||||
if (!valid) return
|
||||
if (!valid) return btnLoading.value = false
|
||||
let res
|
||||
switch (type.value) {
|
||||
case 'create':
|
||||
@@ -1207,6 +1281,7 @@ const enterDialog = async () => {
|
||||
res = await create{{.StructName}}(formData.value)
|
||||
break
|
||||
}
|
||||
btnLoading.value = false
|
||||
if (res.code === 0) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
@@ -1223,7 +1298,6 @@ const downloadFile = (url) => {
|
||||
}
|
||||
{{end}}
|
||||
|
||||
|
||||
const detailFrom = ref({})
|
||||
|
||||
// 查看详情控制标记
|
||||
@@ -1284,5 +1358,6 @@ defineOptions({
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- end }}
|
||||
|
||||
{{- end }}
|
||||
|
Reference in New Issue
Block a user