fix 代码生成细节修复,树形结构支持导入导出

This commit is contained in:
yxh 2025-06-11 09:26:01 +08:00
parent 60da0c349b
commit bab5948a49
4 changed files with 94 additions and 6 deletions

View File

@ -274,7 +274,9 @@ func (c *{{$structName}}Controller) Export(ctx context.Context, req *{{.table.Mo
linked{{$column.GoField}}[lk] = {{$serviceVal}}.SysDept().GetByDept(ctx, lv)
}
for _, dv := range linked{{$column.GoField}} {
{{$column.HtmlField}}Str += dv.DeptName + ","
if dv != nil {
{{$column.HtmlField}}Str += dv.DeptName + ","
}
}
{{end}}
{{end}}

View File

@ -395,7 +395,7 @@
{{if $column.IsOverflowTooltip}}:show-overflow-tooltip="true"{{end}}
{{if $column.IsFixed}}fixed="left"{{end}}>
<template #default="scope">
{{"{{"}} scope.row.linked{{$column.GoField}}?scope.row.linked{{$column.GoField}}.map((res:any)=>{return res.deptName}).join(''):'' {{"}}"}}
{{"{{"}} scope.row.linked{{$column.GoField}}?scope.row.linked{{$column.GoField}}.map((res:any)=>{return res?.deptName}).join(''):'' {{"}}"}}
</template>
</el-table-column>
{{else if ne $column.LinkTableName ""}}

View File

@ -247,7 +247,6 @@
<el-col :span="1.5">
<el-button
type="success"
:disabled="single"
@click="handleUpdate(null)"
v-auth="'{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/edit'"
@ -256,12 +255,29 @@
<el-col :span="1.5">
<el-button
type="danger"
:disabled="multiple"
@click="handleDelete(null)"
v-auth="'{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/delete'"
><el-icon><ele-Delete /></el-icon>删除</el-button>
</el-col>
{{if .table.ExcelPort }}
<el-col :span="1.5">
<el-button
type="warning"
@click="handleExport()"
v-auth="'{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/export'"
><el-icon><ele-Download /></el-icon>导出Excel</el-button>
</el-col>
{{end}}
{{if .table.ExcelImp }}
<el-col :span="1.5">
<el-button
type="success"
@click="handleImport()"
v-auth="'{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/import'"
><el-icon><ele-Upload /></el-icon>导入Excel</el-button>
</el-col>
{{end}}
</el-row>
</div>
<div style="height: 800px;">
@ -316,6 +332,11 @@
:{{$businessName}}Options="tableData.data"
@{{$businessName}}List="{{$businessName}}List"
></{{.apiVersion|replace "/" "_"|CaseCamel}}{{.modulePath|replace "/" "_"|CaseCamel}}{{.table.ClassName}}Detail>
{{if .table.ExcelImp}}
<loadExcel ref="loadExcel{{.table.ClassName}}Ref" @getList="{{$businessName}}List"
upUrl="{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/import"
tplUrl="/{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/excelTemplate"></loadExcel>
{{end}}
</div>
</template>
@ -379,6 +400,12 @@ import {
import {{.apiVersion|replace "/" "_"|CaseCamel}}{{.modulePath|replace "/" "_"|CaseCamel}}{{.table.ClassName}}Edit from "/@/views/{{.modulePath}}/{{$businessName}}/list/component/edit.vue"
import {{.apiVersion|replace "/" "_"|CaseCamel}}{{.modulePath|replace "/" "_"|CaseCamel}}{{.table.ClassName}}Detail from "/@/views/{{.modulePath}}/{{$businessName}}/list/component/detail.vue"
import _ from 'lodash'
{{if .table.ExcelPort }}
import {downLoadXml} from "/@/utils/zipdownload";
{{end}}
{{if .table.ExcelImp}}
import loadExcel from "/@/components/loadExcel/index.vue"
{{end}}
{{if $selectorUserImp}}
import selectUser from "/@/components/selectUser/index.vue"
{{end}}
@ -391,6 +418,9 @@ const loading = ref(false)
const queryRef = ref()
const editRef = ref();
const detailRef = ref();
{{if .table.ExcelImp}}
const loadExcel{{.table.ClassName}}Ref = ref();
{{end}}
// 是否显示所有搜索选项
const showAll = ref(false)
// 非单个禁用
@ -526,11 +556,13 @@ const {{$businessName}}List = ()=>{
})
{{end}}
{{end}}
{{if ne .table.PkColumn.HtmlField "id"}}
if(list.length > 0 && typeof list[0].id == "undefined"){
list.map((item:any)=>{
item.id = item.{{.table.PkColumn.HtmlField}}
})
}
{{end}}
dataList.value = _.clone(res.data.list)
list = proxy.handleTree(res.data.list||[], "{{$treeCode}}", "{{$treeParentCode}}");
state.tableData.data = list;
@ -760,7 +792,7 @@ const setVrData = (list:{{$.table.ClassName}}TableColumns[])=>{
{{if gt $column.MinWidth 0}}width:{{$column.MinWidth}},{{end}}
{{if $column.IsFixed}}fixed: TableV2FixedDir.LEFT,{{end}}
cellRenderer: ({ cellData: linked{{$column.GoField}} }) => {
return h('span',linked{{$column.GoField}}?linked{{$column.GoField}}.map((res:any)=>{return res.deptName}).join(''):'');
return h('span',linked{{$column.GoField}}?linked{{$column.GoField}}.map((res:any)=>{return res?.deptName}).join(''):'');
}
})
{{else if eq $column.HtmlType "selects" "checkbox" "treeSelects"}}
@ -848,6 +880,17 @@ const onExpandedRowsChange = (
) => {
console.log('expandedKeys:',expandedKeys)
}
{{if .table.ExcelPort }}
//导出excel
const handleExport = ()=>{
downLoadXml('/{{.apiVersion}}/{{.modulePath}}/{{$businessName}}/export',state.tableData.param,'get')
}
{{end}}
{{if .table.ExcelImp}}
const handleImport=()=>{
loadExcel{{$.table.ClassName}}Ref.value.open()
}
{{end}}
</script>
<style lang="scss" scoped>
.colBlock {

View File

@ -260,6 +260,24 @@
v-auth="'{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/delete'"
><el-icon><ele-Delete /></el-icon>删除</el-button>
</el-col>
{{if .table.ExcelPort }}
<el-col :span="1.5">
<el-button
type="warning"
@click="handleExport()"
v-auth="'{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/export'"
><el-icon><ele-Download /></el-icon>导出Excel</el-button>
</el-col>
{{end}}
{{if .table.ExcelImp }}
<el-col :span="1.5">
<el-button
type="success"
@click="handleImport()"
v-auth="'{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/import'"
><el-icon><ele-Upload /></el-icon>导入Excel</el-button>
</el-col>
{{end}}
</el-row>
</div>
<el-table
@ -389,7 +407,7 @@
{{if $column.IsOverflowTooltip}}:show-overflow-tooltip="true"{{end}}
{{if $column.IsFixed}}fixed="left"{{end}}>
<template #default="scope">
{{"{{"}} scope.row.linked{{$column.GoField}}?scope.row.linked{{$column.GoField}}.map((res:any)=>{return res.deptName}).join(''):'' {{"}}"}}
{{"{{"}} scope.row.linked{{$column.GoField}}?scope.row.linked{{$column.GoField}}.map((res:any)=>{return res?.deptName}).join(''):'' {{"}}"}}
</template>
</el-table-column>
{{else if ne $column.LinkTableName ""}}
@ -469,6 +487,11 @@
:{{$businessName}}Options="tableData.data"
@{{$businessName}}List="{{$businessName}}List"
></{{.apiVersion|replace "/" "_"|CaseCamel}}{{.modulePath|replace "/" "_"|CaseCamel}}{{.table.ClassName}}Detail>
{{if .table.ExcelImp}}
<loadExcel ref="loadExcel{{.table.ClassName}}Ref" @getList="{{$businessName}}List"
upUrl="{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/import"
tplUrl="/{{.apiVersion}}/{{.table.ModuleName}}/{{$businessName}}/excelTemplate"></loadExcel>
{{end}}
</div>
</template>
@ -531,6 +554,12 @@ import {
import {{.apiVersion|replace "/" "_"|CaseCamel}}{{.modulePath|replace "/" "_"|CaseCamel}}{{.table.ClassName}}Edit from "/@/views/{{.modulePath}}/{{$businessName}}/list/component/edit.vue"
import {{.apiVersion|replace "/" "_"|CaseCamel}}{{.modulePath|replace "/" "_"|CaseCamel}}{{.table.ClassName}}Detail from "/@/views/{{.modulePath}}/{{$businessName}}/list/component/detail.vue"
import _ from 'lodash'
{{if .table.ExcelPort }}
import {downLoadXml} from "/@/utils/zipdownload";
{{end}}
{{if .table.ExcelImp}}
import loadExcel from "/@/components/loadExcel/index.vue"
{{end}}
{{if $selectorUserImp}}
import selectUser from "/@/components/selectUser/index.vue"
{{end}}
@ -543,6 +572,9 @@ const loading = ref(false)
const queryRef = ref()
const editRef = ref();
const detailRef = ref();
{{if .table.ExcelImp}}
const loadExcel{{.table.ClassName}}Ref = ref();
{{end}}
// 是否显示所有搜索选项
const showAll = ref(false)
// 非单个禁用
@ -763,6 +795,17 @@ const handleDelete = (row: {{$.table.ClassName}}TableColumns) => {
const handleView = (row:{{$.table.ClassName}}TableColumns)=>{
detailRef.value.openDialog(toRaw(row));
}
{{if .table.ExcelPort }}
//导出excel
const handleExport = ()=>{
downLoadXml('/{{.apiVersion}}/{{.modulePath}}/{{$businessName}}/export',state.tableData.param,'get')
}
{{end}}
{{if .table.ExcelImp}}
const handleImport=()=>{
loadExcel{{$.table.ClassName}}Ref.value.open()
}
{{end}}
</script>
<style lang="scss" scoped>
.colBlock {