代码生成:vue2 代码模拟格式调整

This commit is contained in:
puhui999 2023-11-27 21:05:41 +08:00
parent 6d228828f4
commit 5ebebf1579
5 changed files with 38 additions and 39 deletions

View File

@ -89,7 +89,7 @@
</template> </template>
<script> <script>
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
#if ($hasImageUploadColumn) #if ($hasImageUploadColumn)
import ImageUpload from '@/components/ImageUpload'; import ImageUpload from '@/components/ImageUpload';
#end #end

View File

@ -8,12 +8,12 @@
<div class="app-container"> <div class="app-container">
#if ( $subTable.subJoinMany )## 情况一一对多table + form #if ( $subTable.subJoinMany )## 情况一一对多table + form
<el-form <el-form
ref="formRef" ref="formRef"
:model="formData" :model="formData"
:rules="formRules" :rules="formRules"
v-loading="formLoading" v-loading="formLoading"
label-width="0px" label-width="0px"
:inline-message="true" :inline-message="true"
> >
<el-table :data="formData" class="-mt-10px"> <el-table :data="formData" class="-mt-10px">
<el-table-column label="序号" type="index" width="100" /> <el-table-column label="序号" type="index" width="100" />
@ -137,11 +137,11 @@
</el-row> </el-row>
#else## 情况二一对一form #else## 情况二一对一form
<el-form <el-form
ref="formRef" ref="formRef"
:model="formData" :model="formData"
:rules="formRules" :rules="formRules"
label-width="100px" label-width="100px"
v-loading="formLoading" v-loading="formLoading"
> >
#foreach($column in $subColumns) #foreach($column in $subColumns)
#if ($column.createOperation || $column.updateOperation) #if ($column.createOperation || $column.updateOperation)
@ -221,7 +221,7 @@
</template> </template>
<script> <script>
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
#if ($hasImageUploadColumn) #if ($hasImageUploadColumn)
import ImageUpload from '@/components/ImageUpload'; import ImageUpload from '@/components/ImageUpload';
#end #end

View File

@ -61,9 +61,9 @@
</template> </template>
<script> <script>
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
#if ($table.templateType == 11) #if ($table.templateType == 11)
import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue' import ${subSimpleClassName}Form from './${subSimpleClassName}Form.vue';
#end #end
export default { export default {
name: "${subSimpleClassName}List", name: "${subSimpleClassName}List",

View File

@ -12,10 +12,10 @@
#if ( $table.templateType == 2 && $column.id == $treeParentColumn.id ) #if ( $table.templateType == 2 && $column.id == $treeParentColumn.id )
<el-form-item label="${comment}" prop="${javaField}"> <el-form-item label="${comment}" prop="${javaField}">
<TreeSelect <TreeSelect
v-model="formData.${javaField}" v-model="formData.${javaField}"
:options="${classNameVar}Tree" :options="${classNameVar}Tree"
:normalizer="normalizer" :normalizer="normalizer"
placeholder="请选择${comment}" placeholder="请选择${comment}"
/> />
</el-form-item> </el-form-item>
#elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里 #elseif ($column.htmlType == "input" && !$column.primaryKey)## 忽略主键,不用在表单里
@ -107,7 +107,7 @@
</template> </template>
<script> <script>
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}' import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
#if ($hasImageUploadColumn) #if ($hasImageUploadColumn)
import ImageUpload from '@/components/ImageUpload'; import ImageUpload from '@/components/ImageUpload';
#end #end
@ -212,7 +212,7 @@
this.title = "新增${table.classComment}"; this.title = "新增${table.classComment}";
## 特殊:树表专属逻辑 ## 特殊:树表专属逻辑
#if ( $table.templateType == 2 ) #if ( $table.templateType == 2 )
this.get${simpleClassName}Tree(); await this.get${simpleClassName}Tree();
#end #end
}, },
/** 提交按钮 */ /** 提交按钮 */
@ -263,7 +263,7 @@
this.#[[$modal]]#.msgSuccess("新增成功"); this.#[[$modal]]#.msgSuccess("新增成功");
this.dialogVisible = false; this.dialogVisible = false;
this.#[[$]]#emit('success'); this.#[[$]]#emit('success');
}finally { } finally {
this.formLoading = false; this.formLoading = false;
} }
}, },

View File

@ -1,6 +1,5 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
#foreach($column in $columns) #foreach($column in $columns)
@ -68,24 +67,24 @@
## 特殊:主子表专属逻辑 ## 特殊:主子表专属逻辑
#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 ) #if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
<el-table <el-table
v-loading="loading" v-loading="loading"
:data="list" :data="list"
:stripe="true" :stripe="true"
:highlight-current-row="true" :highlight-current-row="true"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
@current-change="handleCurrentChange" @current-change="handleCurrentChange"
> >
## 特殊:树表专属逻辑 ## 特殊:树表专属逻辑
#elseif ( $table.templateType == 2 ) #elseif ( $table.templateType == 2 )
<el-table <el-table
v-loading="loading" v-loading="loading"
:data="list" :data="list"
:stripe="true" :stripe="true"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
v-if="refreshTable" v-if="refreshTable"
row-key="id" row-key="id"
:default-expand-all="isExpandAll" :default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
> >
#else #else
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
@ -183,7 +182,7 @@ import Editor from '@/components/Editor';
#if ( $table.templateType != 10 ) #if ( $table.templateType != 10 )
#if ( $subTables && $subTables.size() > 0 ) #if ( $subTables && $subTables.size() > 0 )
#foreach ($subSimpleClassName in $subSimpleClassNames) #foreach ($subSimpleClassName in $subSimpleClassNames)
import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vue' import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vue';
#end #end
#end #end
#end #end
@ -298,7 +297,7 @@ export default {
await this.#[[$modal]]#.confirm('是否确认删除${table.classComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?') await this.#[[$modal]]#.confirm('是否确认删除${table.classComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?')
try { try {
await ${simpleClassName}Api.delete${simpleClassName}(${primaryColumn.javaField}); await ${simpleClassName}Api.delete${simpleClassName}(${primaryColumn.javaField});
this.getList(); await this.getList();
this.#[[$modal]]#.msgSuccess("删除成功"); this.#[[$modal]]#.msgSuccess("删除成功");
} catch {} } catch {}
}, },