2021-02-11 11:11:40 +08:00
|
|
|
<template>
|
|
|
|
<div class="app-container">
|
2021-02-11 15:44:29 +08:00
|
|
|
|
|
|
|
<!-- 搜索工作栏 -->
|
2022-03-20 22:58:13 +08:00
|
|
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
2021-02-11 11:11:40 +08:00
|
|
|
#foreach($column in $columns)
|
|
|
|
#if ($column.listOperation)
|
|
|
|
#set ($dictType=$column.dictType)
|
2021-02-11 15:44:29 +08:00
|
|
|
#set ($javaField = $column.javaField)
|
2021-02-11 11:11:40 +08:00
|
|
|
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
|
|
#set ($comment=$column.columnComment)
|
|
|
|
#if ($column.htmlType == "input")
|
2021-02-11 15:44:29 +08:00
|
|
|
<el-form-item label="${comment}" prop="${javaField}">
|
2022-03-20 22:46:22 +08:00
|
|
|
<el-input v-model="queryParams.${javaField}" placeholder="请输入${comment}" clearable @keyup.enter.native="handleQuery"/>
|
2021-02-11 11:11:40 +08:00
|
|
|
</el-form-item>
|
|
|
|
#elseif ($column.htmlType == "select" || $column.htmlType == "radio")
|
2021-02-11 15:44:29 +08:00
|
|
|
<el-form-item label="${comment}" prop="${javaField}">
|
|
|
|
<el-select v-model="queryParams.${javaField}" placeholder="请选择${comment}" clearable size="small">
|
|
|
|
#if ("" != $dictType)## 设置了 dictType 数据字典的情况
|
2021-02-11 11:11:40 +08:00
|
|
|
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.$dictType.toUpperCase())"
|
2021-02-12 21:01:45 +08:00
|
|
|
:key="dict.value" :label="dict.label" :value="dict.value"/>
|
2021-02-11 15:44:29 +08:00
|
|
|
#else## 未设置 dictType 数据字典的情况
|
2021-02-11 11:11:40 +08:00
|
|
|
<el-option label="请选择字典生成" value="" />
|
|
|
|
#end
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
#elseif($column.htmlType == "datetime")
|
2021-02-12 21:01:45 +08:00
|
|
|
#if ($column.listOperationCondition != "BETWEEN")## 非范围
|
2021-02-11 15:44:29 +08:00
|
|
|
<el-form-item label="${comment}" prop="${javaField}">
|
2022-03-20 22:46:22 +08:00
|
|
|
<el-date-picker clearable v-model="queryParams.${javaField}" type="date" value-format="yyyy-MM-dd" placeholder="选择${comment}" />
|
2021-02-11 11:11:40 +08:00
|
|
|
</el-form-item>
|
2021-02-11 15:44:29 +08:00
|
|
|
#else## 范围
|
2022-07-22 10:24:59 +08:00
|
|
|
<el-form-item label="${comment}" prop="${javaField}">
|
|
|
|
<el-date-picker v-model="queryParams.${javaField}" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
|
|
|
|
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
|
2021-02-11 11:11:40 +08:00
|
|
|
</el-form-item>
|
|
|
|
#end
|
|
|
|
#end
|
|
|
|
#end
|
|
|
|
#end
|
|
|
|
<el-form-item>
|
2022-03-20 22:46:22 +08:00
|
|
|
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
|
|
|
|
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
|
2021-02-11 11:11:40 +08:00
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
|
2021-02-11 15:44:29 +08:00
|
|
|
<!-- 操作工具栏 -->
|
2021-02-11 11:11:40 +08:00
|
|
|
<el-row :gutter="10" class="mb8">
|
|
|
|
<el-col :span="1.5">
|
2023-11-17 17:03:35 +08:00
|
|
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
|
2021-02-12 12:58:41 +08:00
|
|
|
v-hasPermi="['${permissionPrefix}:create']">新增</el-button>
|
2021-02-11 11:11:40 +08:00
|
|
|
</el-col>
|
|
|
|
<el-col :span="1.5">
|
2022-02-15 21:28:11 +08:00
|
|
|
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
|
2021-02-12 12:58:41 +08:00
|
|
|
v-hasPermi="['${permissionPrefix}:export']">导出</el-button>
|
2021-02-11 11:11:40 +08:00
|
|
|
</el-col>
|
2023-11-21 10:49:43 +08:00
|
|
|
## 特殊:树表专属逻辑
|
2023-11-17 17:03:35 +08:00
|
|
|
#if ( $table.templateType == 2 )
|
|
|
|
<el-col :span="1.5">
|
|
|
|
<el-button type="danger" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">
|
|
|
|
展开/折叠
|
|
|
|
</el-button>
|
|
|
|
</el-col>
|
|
|
|
#end
|
2021-02-11 11:11:40 +08:00
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
|
</el-row>
|
|
|
|
|
2023-11-21 10:49:43 +08:00
|
|
|
## 特殊:主子表专属逻辑
|
2023-11-17 17:03:35 +08:00
|
|
|
#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
|
|
|
|
<el-table
|
|
|
|
v-loading="loading"
|
|
|
|
:data="list"
|
|
|
|
:stripe="true"
|
|
|
|
:highlight-current-row="true"
|
|
|
|
:show-overflow-tooltip="true"
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
>
|
|
|
|
## 特殊:树表专属逻辑
|
|
|
|
#elseif ( $table.templateType == 2 )
|
|
|
|
<el-table
|
|
|
|
v-loading="loading"
|
|
|
|
:data="list"
|
|
|
|
:stripe="true"
|
|
|
|
:show-overflow-tooltip="true"
|
|
|
|
v-if="refreshTable"
|
|
|
|
row-key="id"
|
|
|
|
:default-expand-all="isExpandAll"
|
|
|
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
|
|
|
>
|
|
|
|
#else
|
|
|
|
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
|
|
|
#end
|
2023-11-21 10:49:43 +08:00
|
|
|
## 特殊:主子表专属逻辑
|
2023-11-17 17:03:35 +08:00
|
|
|
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
|
|
|
<!-- 子表的列表 -->
|
|
|
|
<el-table-column type="expand">
|
|
|
|
<template #default="scope">
|
|
|
|
<el-tabs value="$subClassNameVars.get(0)">
|
|
|
|
#foreach ($subTable in $subTables)
|
|
|
|
#set ($index = $foreach.count - 1)
|
|
|
|
#set ($subClassNameVar = $subClassNameVars.get($index))
|
|
|
|
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
|
|
|
#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
|
|
|
|
<el-tab-pane label="${subTable.classComment}" name="$subClassNameVar">
|
|
|
|
<${subSimpleClassName}List :${subJoinColumn_strikeCase}="scope.row.id" />
|
|
|
|
</el-tab-pane>
|
|
|
|
#end
|
|
|
|
</el-tabs>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
#end
|
2021-02-11 11:11:40 +08:00
|
|
|
#foreach($column in $columns)
|
2021-02-11 15:44:29 +08:00
|
|
|
#if ($column.listOperationResult)
|
2021-02-11 11:11:40 +08:00
|
|
|
#set ($dictType=$column.dictType)
|
2021-02-11 15:44:29 +08:00
|
|
|
#set ($javaField = $column.javaField)
|
2021-02-11 11:11:40 +08:00
|
|
|
#set ($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
|
|
#set ($comment=$column.columnComment)
|
2022-11-09 11:14:46 +08:00
|
|
|
#if ($column.javaType == "LocalDateTime")## 时间类型
|
2021-02-11 11:11:40 +08:00
|
|
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
2022-11-08 13:43:39 +08:00
|
|
|
<template v-slot="scope">
|
2021-03-13 13:37:59 +08:00
|
|
|
<span>{{ parseTime(scope.row.${javaField}) }}</span>
|
2021-02-11 11:11:40 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2021-02-11 15:44:29 +08:00
|
|
|
#elseif("" != $column.dictType)## 数据字典
|
|
|
|
<el-table-column label="${comment}" align="center" prop="${javaField}">
|
2022-11-08 13:43:39 +08:00
|
|
|
<template v-slot="scope">
|
2022-02-20 12:24:47 +08:00
|
|
|
<dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" />
|
2021-02-11 15:44:29 +08:00
|
|
|
</template>
|
2021-04-11 21:48:51 +08:00
|
|
|
</el-table-column>
|
2021-02-11 15:44:29 +08:00
|
|
|
#else
|
2021-02-11 11:11:40 +08:00
|
|
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
|
|
|
#end
|
2021-02-11 15:44:29 +08:00
|
|
|
#end
|
2021-02-11 11:11:40 +08:00
|
|
|
#end
|
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
2022-11-08 13:43:39 +08:00
|
|
|
<template v-slot="scope">
|
2023-11-17 17:03:35 +08:00
|
|
|
<el-button size="mini" type="text" icon="el-icon-edit" @click="openForm(scope.row.${primaryColumn.javaField})"
|
2021-02-12 12:58:41 +08:00
|
|
|
v-hasPermi="['${permissionPrefix}:update']">修改</el-button>
|
2021-02-11 15:44:29 +08:00
|
|
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
2021-02-12 12:58:41 +08:00
|
|
|
v-hasPermi="['${permissionPrefix}:delete']">删除</el-button>
|
2021-02-11 11:11:40 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
2023-11-21 10:49:43 +08:00
|
|
|
## 特殊:树表专属逻辑(树不需要分页)
|
|
|
|
#if ( $table.templateType != 2 )
|
2021-02-11 15:44:29 +08:00
|
|
|
<!-- 分页组件 -->
|
|
|
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
|
|
|
@pagination="getList"/>
|
2023-11-21 10:49:43 +08:00
|
|
|
#end
|
2021-02-11 15:44:29 +08:00
|
|
|
<!-- 对话框(添加 / 修改) -->
|
2023-11-17 17:03:35 +08:00
|
|
|
<${simpleClassName}Form ref="formRef" @success="getList" />
|
2023-11-21 10:49:43 +08:00
|
|
|
## 特殊:主子表专属逻辑
|
2023-11-17 17:03:35 +08:00
|
|
|
#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
|
|
|
|
<!-- 子表的列表 -->
|
|
|
|
<el-tabs model-value="$subClassNameVars.get(0)">
|
|
|
|
#foreach ($subTable in $subTables)
|
|
|
|
#set ($index = $foreach.count - 1)
|
|
|
|
#set ($subClassNameVar = $subClassNameVars.get($index))
|
|
|
|
#set ($subSimpleClassName = $subSimpleClassNames.get($index))
|
|
|
|
#set ($subJoinColumn_strikeCase = $subJoinColumn_strikeCases.get($index))
|
|
|
|
<el-tab-pane label="${subTable.classComment}" name="$subClassNameVar">
|
|
|
|
<${subSimpleClassName}List :${subJoinColumn_strikeCase}="currentRow.id" />
|
|
|
|
</el-tab-pane>
|
|
|
|
#end
|
|
|
|
</el-tabs>
|
2021-02-11 15:44:29 +08:00
|
|
|
#end
|
2021-02-11 11:11:40 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-11-17 17:03:35 +08:00
|
|
|
import * as ${simpleClassName}Api from '@/api/${table.moduleName}/${table.businessName}';
|
|
|
|
import ${simpleClassName}Form from './${simpleClassName}Form.vue';
|
2021-02-12 01:36:42 +08:00
|
|
|
#if ($hasImageUploadColumn)
|
2021-02-11 11:11:40 +08:00
|
|
|
import ImageUpload from '@/components/ImageUpload';
|
|
|
|
#end
|
2021-02-12 01:36:42 +08:00
|
|
|
#if ($hasFileUploadColumn)
|
2021-02-11 11:11:40 +08:00
|
|
|
import FileUpload from '@/components/FileUpload';
|
|
|
|
#end
|
2021-02-12 01:36:42 +08:00
|
|
|
#if ($hasEditorColumn)
|
2021-02-11 11:11:40 +08:00
|
|
|
import Editor from '@/components/Editor';
|
|
|
|
#end
|
2023-11-17 17:03:35 +08:00
|
|
|
## 特殊:主子表专属逻辑
|
2023-11-21 10:49:43 +08:00
|
|
|
#if ( $table.templateType != 10 )
|
2023-11-17 17:03:35 +08:00
|
|
|
#if ( $subTables && $subTables.size() > 0 )
|
|
|
|
#foreach ($subSimpleClassName in $subSimpleClassNames)
|
|
|
|
import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vue'
|
|
|
|
#end
|
|
|
|
#end
|
2023-11-21 10:49:43 +08:00
|
|
|
#end
|
2021-02-11 11:11:40 +08:00
|
|
|
export default {
|
2021-02-12 01:36:42 +08:00
|
|
|
name: "${simpleClassName}",
|
2021-02-11 11:11:40 +08:00
|
|
|
components: {
|
2023-11-17 17:03:35 +08:00
|
|
|
${simpleClassName}Form,
|
|
|
|
## 特殊:主子表专属逻辑
|
2023-11-21 10:49:43 +08:00
|
|
|
#if ( $table.templateType != 10 )
|
2023-11-17 17:03:35 +08:00
|
|
|
#if ( $subTables && $subTables.size() > 0 )
|
|
|
|
#foreach ($subSimpleClassName in $subSimpleClassNames)
|
|
|
|
${subSimpleClassName}List,
|
|
|
|
#end
|
|
|
|
#end
|
2023-11-21 10:49:43 +08:00
|
|
|
#end
|
2021-02-12 01:36:42 +08:00
|
|
|
#if ($hasImageUploadColumn)
|
2021-02-11 11:11:40 +08:00
|
|
|
ImageUpload,
|
|
|
|
#end
|
2021-02-12 01:36:42 +08:00
|
|
|
#if ($hasFileUploadColumn)
|
2021-02-11 11:11:40 +08:00
|
|
|
FileUpload,
|
|
|
|
#end
|
2021-02-12 01:36:42 +08:00
|
|
|
#if ($hasEditorColumn)
|
2021-02-11 11:11:40 +08:00
|
|
|
Editor,
|
|
|
|
#end
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
// 遮罩层
|
|
|
|
loading: true,
|
2022-02-15 21:28:11 +08:00
|
|
|
// 导出遮罩层
|
|
|
|
exportLoading: false,
|
2021-02-11 11:11:40 +08:00
|
|
|
// 显示搜索条件
|
|
|
|
showSearch: true,
|
2023-11-17 17:03:35 +08:00
|
|
|
## 特殊:树表专属逻辑(树不需要分页接口)
|
|
|
|
#if ( $table.templateType != 2 )
|
2023-11-21 10:49:43 +08:00
|
|
|
// 总条数
|
2023-11-17 17:03:35 +08:00
|
|
|
total: 0,
|
|
|
|
#end
|
2021-02-12 12:58:41 +08:00
|
|
|
// ${table.classComment}列表
|
2021-02-11 15:44:29 +08:00
|
|
|
list: [],
|
2023-11-17 17:03:35 +08:00
|
|
|
// 是否展开,默认全部展开
|
|
|
|
isExpandAll: true,
|
|
|
|
// 重新渲染表格状态
|
|
|
|
refreshTable: true,
|
|
|
|
// 选中行
|
|
|
|
currentRow: {},
|
2021-02-11 11:11:40 +08:00
|
|
|
// 查询参数
|
|
|
|
queryParams: {
|
2023-11-17 17:03:35 +08:00
|
|
|
## 特殊:树表专属逻辑(树不需要分页接口)
|
|
|
|
#if ( $table.templateType != 2 )
|
|
|
|
pageNo: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
#end
|
2021-02-12 01:36:42 +08:00
|
|
|
#foreach ($column in $columns)
|
2022-07-25 16:53:36 +08:00
|
|
|
#if ($column.listOperation)
|
|
|
|
#if ($column.listOperationCondition != 'BETWEEN')
|
2021-02-12 01:36:42 +08:00
|
|
|
$column.javaField: null,
|
2022-07-25 16:53:36 +08:00
|
|
|
#end
|
2023-11-21 10:49:43 +08:00
|
|
|
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
2022-07-22 10:24:59 +08:00
|
|
|
$column.javaField: [],
|
|
|
|
#end
|
2021-02-12 01:36:42 +08:00
|
|
|
#end
|
|
|
|
#end
|
2021-02-11 11:11:40 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.getList();
|
|
|
|
},
|
|
|
|
methods: {
|
2021-02-12 11:53:32 +08:00
|
|
|
/** 查询列表 */
|
2021-02-11 11:11:40 +08:00
|
|
|
getList() {
|
2023-11-17 17:03:35 +08:00
|
|
|
try {
|
2021-02-11 11:11:40 +08:00
|
|
|
this.loading = true;
|
2023-11-17 17:03:35 +08:00
|
|
|
## 特殊:树表专属逻辑(树不需要分页接口)
|
|
|
|
#if ( $table.templateType == 2 )
|
2023-11-21 10:49:43 +08:00
|
|
|
${simpleClassName}Api.get${simpleClassName}List(this.queryParams).then(response => {
|
2023-11-17 17:03:35 +08:00
|
|
|
this.list = this.handleTree(response.data, 'id', '${treeParentColumn.javaField}');
|
|
|
|
})
|
|
|
|
#else
|
|
|
|
${simpleClassName}Api.get${simpleClassName}Page(this.queryParams).then(response => {
|
2021-02-12 11:53:32 +08:00
|
|
|
this.list = response.data.list;
|
|
|
|
this.total = response.data.total;
|
2021-02-11 11:11:40 +08:00
|
|
|
});
|
2023-11-17 17:03:35 +08:00
|
|
|
#end
|
|
|
|
} finally {
|
|
|
|
this.loading = false;
|
|
|
|
}
|
2021-02-11 11:11:40 +08:00
|
|
|
},
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
handleQuery() {
|
2021-02-11 15:44:29 +08:00
|
|
|
this.queryParams.pageNo = 1;
|
2021-02-11 11:11:40 +08:00
|
|
|
this.getList();
|
|
|
|
},
|
|
|
|
/** 重置按钮操作 */
|
|
|
|
resetQuery() {
|
|
|
|
this.resetForm("queryForm");
|
|
|
|
this.handleQuery();
|
|
|
|
},
|
2023-11-17 17:03:35 +08:00
|
|
|
/** 添加/修改操作 */
|
|
|
|
openForm(id) {
|
|
|
|
this.#[[$]]#refs["formRef"].open(id)
|
2021-02-11 11:11:40 +08:00
|
|
|
},
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
handleDelete(row) {
|
2023-11-17 17:03:35 +08:00
|
|
|
const that = this;
|
|
|
|
try {
|
2021-02-12 11:53:32 +08:00
|
|
|
const ${primaryColumn.javaField} = row.${primaryColumn.javaField};
|
2023-11-17 17:03:35 +08:00
|
|
|
this.#[[$modal]]#.confirm('是否确认删除${table.classComment}编号为"' + ${primaryColumn.javaField} + '"的数据项?').then(()=>{
|
|
|
|
return ${simpleClassName}Api.delete${simpleClassName}(${primaryColumn.javaField});
|
2021-02-11 11:11:40 +08:00
|
|
|
}).then(() => {
|
2023-11-17 17:03:35 +08:00
|
|
|
that.getList();
|
|
|
|
that.#[[$modal]]#.msgSuccess("删除成功");
|
2022-02-15 21:51:24 +08:00
|
|
|
}).catch(() => {});
|
2023-11-17 17:03:35 +08:00
|
|
|
} catch {}
|
2021-02-11 11:11:40 +08:00
|
|
|
},
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
handleExport() {
|
2023-11-17 17:03:35 +08:00
|
|
|
const that = this;
|
|
|
|
try {
|
|
|
|
this.#[[$modal]]#.confirm('是否确认导出所有${table.classComment}数据项?').then(() => {
|
|
|
|
that.exportLoading = true;
|
|
|
|
return ${simpleClassName}Api.export${simpleClassName}Excel(params);
|
|
|
|
}).then(response => {
|
|
|
|
that.#[[$]]#download.excel(response, '${table.classComment}.xls');
|
2023-11-21 10:49:43 +08:00
|
|
|
});
|
2023-11-17 17:03:35 +08:00
|
|
|
} catch {
|
|
|
|
} finally {
|
|
|
|
that.exportLoading = false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
## 特殊:主子表专属逻辑
|
2023-11-21 10:49:43 +08:00
|
|
|
#if ( $table.templateType == 11 )
|
2023-11-17 17:03:35 +08:00
|
|
|
/** 选中行操作 */
|
|
|
|
handleCurrentChange(row) {
|
|
|
|
this.currentRow = row
|
|
|
|
},
|
|
|
|
#end
|
|
|
|
## 特殊:树表专属逻辑
|
|
|
|
#if ( $table.templateType == 2 )
|
|
|
|
/** 展开/折叠操作 */
|
|
|
|
toggleExpandAll() {
|
|
|
|
this.refreshTable = false
|
|
|
|
this.isExpandAll = !this.isExpandAll
|
|
|
|
this.$nextTick(function () {
|
|
|
|
this.refreshTable = true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
#end
|
2021-02-11 11:11:40 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|