V2.7.2版本发布 (#1853)
* feat: 自动化代码增加json导出和导入功能 * feat: 自动化代码前端可见分为Table和Form分别选中 * feature: 调整代码预览为左边栏模式的tabs。 * feat: 增加方法自动添加前端api * feat: 自动化生成前端支持详情功能 * feat: 增加自动创建可控权限按钮功能 * fixed: 顶栏样式菜单样式细节bug修复 * fixed: 修改视频地址 * fixed: 自动获取表结构和数据库表列结构保持一致 * fixed: casbin 设置空权限无需调用 AddPolicies 方法 (#1850) * feat:对象存储支持配置Cloudflare R2 (#1849) * fixed:设为首页和菜单勾选互为必选 --------- Co-authored-by: SliverHorn <503551462@qq.com> Co-authored-by: 千石 <CN_QianShi@hotmail.com> * feat: 复杂数据类型的查询将不会生成查询语句,会以string形式接收参数,用户自行实现复杂查询逻辑。 * feat: 创建新角色默认携带字典和长传权限。 禁止删除有首页占用的菜单。 不允许切换至无首页的角色。 自动化代码创建失败将返回错误信息。 * feat: 当package或plugin结构异常时候,阻止创建自动化代码。 --------- Co-authored-by: krank <emosick@qq.com> Co-authored-by: SliverHorn <503551462@qq.com> Co-authored-by: 千石 <CN_QianShi@hotmail.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
<div class="gva-form-box">
|
||||
<el-form :model="formData" ref="elFormRef" label-position="right" :rules="rule" label-width="80px">
|
||||
{{- range .Fields}}
|
||||
{{- 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}}" >
|
||||
@@ -56,6 +57,7 @@
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="save">保存</el-button>
|
||||
@@ -106,6 +108,7 @@ const {{ $element }}Options = ref([])
|
||||
{{- end }}
|
||||
const formData = ref({
|
||||
{{- range .Fields}}
|
||||
{{- if .Form }}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
{{.FieldJson}}: false,
|
||||
{{- end }}
|
||||
@@ -142,11 +145,13 @@ const formData = ref({
|
||||
{{- if eq .FieldType "array" }}
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
})
|
||||
// 验证规则
|
||||
const rule = reactive({
|
||||
{{- range .Fields }}
|
||||
{{- if .Form }}
|
||||
{{- if eq .Require true }}
|
||||
{{.FieldJson }} : [{
|
||||
required: true,
|
||||
@@ -154,6 +159,7 @@ const rule = reactive({
|
||||
trigger: ['input','blur'],
|
||||
}],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
})
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
{{- $global := . }}
|
||||
<template>
|
||||
<div>
|
||||
<div class="gva-search-box">
|
||||
@@ -149,8 +150,8 @@
|
||||
</div>
|
||||
<div class="gva-table-box">
|
||||
<div class="gva-btn-list">
|
||||
<el-button type="primary" icon="plus" @click="openDialog">新增</el-button>
|
||||
<el-button icon="delete" style="margin-left: 10px;" :disabled="!multipleSelection.length" @click="onDelete">删除</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>
|
||||
</div>
|
||||
<el-table
|
||||
ref="multipleTable"
|
||||
@@ -169,7 +170,8 @@
|
||||
<template #default="scope">{{ "{{ formatDate(scope.row.CreatedAt) }}" }}</template>
|
||||
</el-table-column>
|
||||
{{ end }}
|
||||
{{- range .FrontFields}}
|
||||
{{- range .Fields}}
|
||||
{{- if .Table}}
|
||||
{{- if .CheckDataSource }}
|
||||
<el-table-column {{- if .Sort}} sortable{{- end}} align="left" label="{{.FieldDesc}}" prop="{{.FieldJson}}" width="120">
|
||||
<template #default="scope">
|
||||
@@ -246,10 +248,12 @@
|
||||
<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">
|
||||
<el-button type="primary" link icon="edit" class="table-button" @click="update{{.StructName}}Func(scope.row)">变更</el-button>
|
||||
<el-button type="primary" link icon="delete" @click="deleteRow(scope.row)">删除</el-button>
|
||||
<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>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -277,7 +281,8 @@
|
||||
</template>
|
||||
|
||||
<el-form :model="formData" label-position="top" ref="elFormRef" :rules="rule" label-width="80px">
|
||||
{{- range .FrontFields}}
|
||||
{{- range .Fields}}
|
||||
{{- 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}}" >
|
||||
@@ -347,8 +352,43 @@
|
||||
{{- end }}
|
||||
</el-form-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-form>
|
||||
</el-drawer>
|
||||
|
||||
|
||||
|
||||
<el-drawer destroy-on-close size="800" v-model="detailShow" :show-close="true" :before-close="closeDetailShow">
|
||||
<el-descriptions column="1" border>
|
||||
{{- range .Fields}}
|
||||
{{- if .Desc }}
|
||||
<el-descriptions-item label="{{ .FieldDesc }}">
|
||||
{{- if and (ne .FieldType "picture" ) (ne .FieldType "pictures" ) (ne .FieldType "file" ) }}
|
||||
{{"{{"}} detailFrom.{{.FieldJson}} {{"}}"}}
|
||||
{{- else }}
|
||||
{{- if eq .FieldType "picture" }}
|
||||
<el-image style="width: 50px; height: 50px" :preview-src-list="ReturnArrImg(detailFrom.{{ .FieldJson }})" :src="getUrl(formData.{{ .FieldJson }})" fit="cover" />
|
||||
{{- 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 formData.{{ .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 }}
|
||||
{{- end }}
|
||||
</el-descriptions-item>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</el-descriptions>
|
||||
</el-drawer>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -388,11 +428,20 @@ import SelectFile from '@/components/selectFile/selectFile.vue'
|
||||
import { getDictFunc, formatDate, formatBoolean, filterDict ,filterDataSource, ReturnArrImg, onDownloadFile } from '@/utils/format'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ref, reactive } from 'vue'
|
||||
{{- if .AutoCreateBtnAuth }}
|
||||
// 引入按钮权限标识
|
||||
import { useBtnAuth } from '@/utils/btnAuth'
|
||||
{{- end }}
|
||||
|
||||
defineOptions({
|
||||
name: '{{.StructName}}'
|
||||
})
|
||||
|
||||
{{- if .AutoCreateBtnAuth }}
|
||||
// 按钮权限实例化
|
||||
const btnAuth = useBtnAuth()
|
||||
{{- end }}
|
||||
|
||||
// 控制更多查询条件显示/隐藏状态
|
||||
const showAllQuery = ref(false)
|
||||
|
||||
@@ -401,7 +450,8 @@ const showAllQuery = ref(false)
|
||||
const {{ $element }}Options = ref([])
|
||||
{{- end }}
|
||||
const formData = ref({
|
||||
{{- range .FrontFields}}
|
||||
{{- range .Fields}}
|
||||
{{- if .Form}}
|
||||
{{- if eq .FieldType "bool" }}
|
||||
{{.FieldJson}}: false,
|
||||
{{- end }}
|
||||
@@ -439,6 +489,7 @@ const formData = ref({
|
||||
{{.FieldJson}}: [],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
})
|
||||
|
||||
{{- if .HasDataSource }}
|
||||
@@ -456,7 +507,8 @@ const formData = ref({
|
||||
|
||||
// 验证规则
|
||||
const rule = reactive({
|
||||
{{- range .FrontFields }}
|
||||
{{- range .Fields }}
|
||||
{{- if .Form }}
|
||||
{{- if eq .Require true }}
|
||||
{{.FieldJson }} : [{
|
||||
required: true,
|
||||
@@ -472,6 +524,7 @@ const rule = reactive({
|
||||
{{- end }}
|
||||
],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
})
|
||||
|
||||
@@ -489,7 +542,7 @@ const searchRule = reactive({
|
||||
}
|
||||
}, trigger: 'change' }
|
||||
],
|
||||
{{- range .FrontFields }}
|
||||
{{- range .Fields }}
|
||||
{{- if .FieldSearchType}}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
{{.FieldJson }} : [{ validator: (rule, value, callback) => {
|
||||
@@ -522,10 +575,12 @@ const searchInfo = ref({})
|
||||
// 排序
|
||||
const sortChange = ({ prop, order }) => {
|
||||
const sortMap = {
|
||||
{{- range .FrontFields}}
|
||||
{{- if and .Sort}}
|
||||
{{- if not (eq .ColumnName "")}}
|
||||
{{.FieldJson}}: '{{.ColumnName}}',
|
||||
{{- range .Fields}}
|
||||
{{- if .Table}}
|
||||
{{- if and .Sort}}
|
||||
{{- if not (eq .ColumnName "")}}
|
||||
{{.FieldJson}}: '{{.ColumnName}}',
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
{{- end}}
|
||||
@@ -554,7 +609,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 +748,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 +783,8 @@ const closeDialog = () => {
|
||||
{{- if eq .FieldType "json" }}
|
||||
{{.FieldJson}}: {},
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
}
|
||||
}
|
||||
// 弹窗确定
|
||||
@@ -761,6 +818,38 @@ const downloadFile = (url) => {
|
||||
window.open(getUrl(url), '_blank')
|
||||
}
|
||||
{{end}}
|
||||
|
||||
|
||||
const detailFrom = ref({})
|
||||
|
||||
// 查看详情控制标记
|
||||
const detailShow = ref(false)
|
||||
|
||||
|
||||
// 打开详情弹窗
|
||||
const openDetailShow = () => {
|
||||
detailShow.value = true
|
||||
}
|
||||
|
||||
|
||||
// 打开详情
|
||||
const getDetails = async (row) => {
|
||||
// 打开弹窗
|
||||
const res = await find{{.StructName}}({ {{.PrimaryField.FieldJson}}: row.{{.PrimaryField.FieldJson}} })
|
||||
if (res.code === 0) {
|
||||
detailFrom.value = res.data
|
||||
openDetailShow()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 关闭详情弹窗
|
||||
const closeDetailShow = () => {
|
||||
detailShow.value = false
|
||||
detailFrom.value = {}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
Reference in New Issue
Block a user