代码生成:select的表单验证代码生成
This commit is contained in:
@ -1,471 +1,471 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#if($column.query)
|
#if($column.query)
|
||||||
#set($dictType=$column.dictType)
|
#set($dictType=$column.dictType)
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
#if($parentheseIndex != -1)
|
#if($parentheseIndex != -1)
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
#else
|
#else
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
#if($column.htmlType == "input")
|
#if($column.htmlType == "input")
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
placeholder="请输入${comment}"
|
placeholder="请输入${comment}"
|
||||||
clearable
|
clearable
|
||||||
size="small"
|
size="small"
|
||||||
@keyup.enter.native="handleQuery"
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in ${column.javaField}Options"
|
||||||
|
:key="dict.dictValue"
|
||||||
|
:label="dict.dictLabel"
|
||||||
|
:value="dict.dictValue"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType == "datetime")
|
||||||
|
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||||
|
<el-date-picker clearable size="small" style="width: 200px"
|
||||||
|
v-model="queryParams.${column.javaField}"
|
||||||
|
type="date"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
placeholder="选择${comment}">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
#foreach($column in $columns)
|
||||||
|
#set($javaField=$column.javaField)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($column.pk)
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||||
|
#elseif($column.list && $column.htmlType == "datetime")
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif($column.list && "" != $column.dictType)
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
|
||||||
|
#elseif($column.list && "" != $javaField)
|
||||||
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
|
||||||
<el-option
|
|
||||||
v-for="dict in ${column.javaField}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
:label="dict.dictLabel"
|
|
||||||
:value="dict.dictValue"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
|
||||||
<el-option label="请选择字典生成" value="" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "datetime")
|
|
||||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
|
||||||
<el-date-picker clearable size="small" style="width: 200px"
|
|
||||||
v-model="queryParams.${column.javaField}"
|
|
||||||
type="date"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
placeholder="选择${comment}">
|
|
||||||
</el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
||||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<el-row :gutter="10" class="mb8">
|
<!-- 添加或修改${functionName}对话框 -->
|
||||||
<el-col :span="1.5">
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
<el-button
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
type="primary"
|
#foreach($column in $columns)
|
||||||
icon="el-icon-plus"
|
#set($field=$column.javaField)
|
||||||
size="mini"
|
#if($column.insert && !$column.pk)
|
||||||
@click="handleAdd"
|
#if(($column.usableColumn) || (!$column.superColumn))
|
||||||
v-hasPermi="['${moduleName}:${businessName}:add']"
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
>新增</el-button>
|
#if($parentheseIndex != -1)
|
||||||
</el-col>
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
<el-col :span="1.5">
|
#else
|
||||||
<el-button
|
#set($comment=$column.columnComment)
|
||||||
type="success"
|
#end
|
||||||
icon="el-icon-edit"
|
#set($dictType=$column.dictType)
|
||||||
size="mini"
|
#if($column.htmlType == "input")
|
||||||
:disabled="single"
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
@click="handleUpdate"
|
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
||||||
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
</el-form-item>
|
||||||
>修改</el-button>
|
#elseif($column.htmlType == "select" && "" != $dictType)
|
||||||
</el-col>
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-col :span="1.5">
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
<el-button
|
<el-option
|
||||||
type="danger"
|
v-for="dict in ${field}Options"
|
||||||
icon="el-icon-delete"
|
:key="dict.dictValue"
|
||||||
size="mini"
|
:label="dict.dictLabel"
|
||||||
:disabled="multiple"
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.dictValue)"#else:value="dict.dictValue"#end
|
||||||
@click="handleDelete"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="1.5">
|
|
||||||
<el-button
|
|
||||||
type="warning"
|
|
||||||
icon="el-icon-download"
|
|
||||||
size="mini"
|
|
||||||
@click="handleExport"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:export']"
|
|
||||||
>导出</el-button>
|
|
||||||
</el-col>
|
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
|
></el-option>
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
</el-select>
|
||||||
#foreach($column in $columns)
|
</el-form-item>
|
||||||
#set($javaField=$column.javaField)
|
#elseif($column.htmlType == "select" && $dictType)
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
#if($parentheseIndex != -1)
|
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
<el-option label="请选择字典生成" value="" />
|
||||||
#else
|
</el-select>
|
||||||
#set($comment=$column.columnComment)
|
</el-form-item>
|
||||||
#end
|
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
||||||
#if($column.pk)
|
<el-form-item label="${comment}">
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
<el-checkbox-group v-model="form.${field}">
|
||||||
#elseif($column.list && $column.htmlType == "datetime")
|
<el-checkbox
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
v-for="dict in ${field}Options"
|
||||||
<template slot-scope="scope">
|
:key="dict.dictValue"
|
||||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d}') }}</span>
|
:label="dict.dictValue">
|
||||||
</template>
|
{{dict.dictLabel}}
|
||||||
</el-table-column>
|
</el-checkbox>
|
||||||
#elseif($column.list && "" != $column.dictType)
|
</el-checkbox-group>
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
|
</el-form-item>
|
||||||
#elseif($column.list && "" != $javaField)
|
#elseif($column.htmlType == "checkbox" && $dictType)
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
<el-form-item label="${comment}">
|
||||||
#end
|
<el-checkbox-group v-model="form.${field}">
|
||||||
#end
|
<el-checkbox>请选择字典生成</el-checkbox>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
</el-checkbox-group>
|
||||||
<template slot-scope="scope">
|
</el-form-item>
|
||||||
<el-button
|
#elseif($column.htmlType == "radio" && "" != $dictType)
|
||||||
size="mini"
|
<el-form-item label="${comment}">
|
||||||
type="text"
|
<el-radio-group v-model="form.${field}">
|
||||||
icon="el-icon-edit"
|
<el-radio
|
||||||
@click="handleUpdate(scope.row)"
|
v-for="dict in ${field}Options"
|
||||||
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
:key="dict.dictValue"
|
||||||
>修改</el-button>
|
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.dictValue)"#else:label="dict.dictValue"#end
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
icon="el-icon-delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
|
||||||
>删除</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<pagination
|
|
||||||
v-show="total>0"
|
|
||||||
:total="total"
|
|
||||||
:page.sync="queryParams.pageNum"
|
|
||||||
:limit.sync="queryParams.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 添加或修改${functionName}对话框 -->
|
>{{dict.dictLabel}}</el-radio>
|
||||||
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
</el-radio-group>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
</el-form-item>
|
||||||
#foreach($column in $columns)
|
#elseif($column.htmlType == "radio" && $dictType)
|
||||||
#set($field=$column.javaField)
|
<el-form-item label="${comment}">
|
||||||
#if($column.insert && !$column.pk)
|
<el-radio-group v-model="form.${field}">
|
||||||
#if(($column.usableColumn) || (!$column.superColumn))
|
<el-radio label="1">请选择字典生成</el-radio>
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
</el-radio-group>
|
||||||
#if($parentheseIndex != -1)
|
</el-form-item>
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
#elseif($column.htmlType == "datetime")
|
||||||
#else
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
#set($comment=$column.columnComment)
|
<el-date-picker clearable size="small" style="width: 200px"
|
||||||
#end
|
v-model="form.${field}"
|
||||||
#set($dictType=$column.dictType)
|
type="date"
|
||||||
#if($column.htmlType == "input")
|
value-format="yyyy-MM-dd"
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
placeholder="选择${comment}">
|
||||||
<el-input v-model="form.${field}" placeholder="请输入${comment}" />
|
</el-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "select" && "" != $dictType)
|
#elseif($column.htmlType == "textarea")
|
||||||
<el-form-item label="${comment}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
||||||
<el-option
|
</el-form-item>
|
||||||
v-for="dict in ${field}Options"
|
#end
|
||||||
:key="dict.dictValue"
|
#end
|
||||||
:label="dict.dictLabel"
|
#end
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.dictValue)"#else:value="dict.dictValue"#end
|
#end
|
||||||
|
</el-form>
|
||||||
></el-option>
|
<div slot="footer" class="dialog-footer">
|
||||||
</el-select>
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
</el-form-item>
|
<el-button @click="cancel">取 消</el-button>
|
||||||
#elseif($column.htmlType == "select" && $dictType)
|
</div>
|
||||||
<el-form-item label="${comment}">
|
</el-dialog>
|
||||||
<el-select v-model="form.${field}" placeholder="请选择${comment}">
|
</div>
|
||||||
<el-option label="请选择字典生成" value="" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "checkbox" && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-checkbox-group v-model="form.${field}">
|
|
||||||
<el-checkbox
|
|
||||||
v-for="dict in ${field}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
:label="dict.dictValue">
|
|
||||||
{{dict.dictLabel}}
|
|
||||||
</el-checkbox>
|
|
||||||
</el-checkbox-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "checkbox" && $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-checkbox-group v-model="form.${field}">
|
|
||||||
<el-checkbox>请选择字典生成</el-checkbox>
|
|
||||||
</el-checkbox-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "radio" && "" != $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-radio-group v-model="form.${field}">
|
|
||||||
<el-radio
|
|
||||||
v-for="dict in ${field}Options"
|
|
||||||
:key="dict.dictValue"
|
|
||||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.dictValue)"#else:label="dict.dictValue"#end
|
|
||||||
|
|
||||||
>{{dict.dictLabel}}</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "radio" && $dictType)
|
|
||||||
<el-form-item label="${comment}">
|
|
||||||
<el-radio-group v-model="form.${field}">
|
|
||||||
<el-radio label="1">请选择字典生成</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "datetime")
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-date-picker clearable size="small" style="width: 200px"
|
|
||||||
v-model="form.${field}"
|
|
||||||
type="date"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
placeholder="选择${comment}">
|
|
||||||
</el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
#elseif($column.htmlType == "textarea")
|
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
|
||||||
<el-input v-model="form.${field}" type="textarea" placeholder="请输入内容" />
|
|
||||||
</el-form-item>
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
</el-form>
|
|
||||||
<div slot="footer" class="dialog-footer">
|
|
||||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
||||||
<el-button @click="cancel">取 消</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName}, export${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "${BusinessName}",
|
name: "${BusinessName}",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
// 选中数组
|
// 选中数组
|
||||||
ids: [],
|
ids: [],
|
||||||
// 非单个禁用
|
// 非单个禁用
|
||||||
single: true,
|
single: true,
|
||||||
// 非多个禁用
|
// 非多个禁用
|
||||||
multiple: true,
|
multiple: true,
|
||||||
// 显示搜索条件
|
// 显示搜索条件
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
// 总条数
|
// 总条数
|
||||||
total: 0,
|
total: 0,
|
||||||
// ${functionName}表格数据
|
// ${functionName}表格数据
|
||||||
${businessName}List: [],
|
${businessName}List: [],
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "",
|
title: "",
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
#if($parentheseIndex != -1)
|
#if($parentheseIndex != -1)
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
#else
|
#else
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
#if(${column.dictType} != '')
|
#if(${column.dictType} != '')
|
||||||
// $comment字典
|
// $comment字典
|
||||||
${column.javaField}Options: [],
|
${column.javaField}Options: [],
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.query)
|
#if($column.query)
|
||||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
},
|
},
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.required)
|
#if($column.required)
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
#if($parentheseIndex != -1)
|
#if($parentheseIndex != -1)
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
#else
|
#else
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
$column.javaField: [
|
$column.javaField: [
|
||||||
{ required: true, message: "$comment不能为空", trigger: "blur" }
|
{ required: true, message: "$comment不能为空", #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||||
]#if($velocityCount != $columns.size()),#end
|
]#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList();
|
this.getList();
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if(${column.dictType} != '')
|
#if(${column.dictType} != '')
|
||||||
this.getDicts("${column.dictType}").then(response => {
|
this.getDicts("${column.dictType}").then(response => {
|
||||||
this.${column.javaField}Options = response.data;
|
this.${column.javaField}Options = response.data;
|
||||||
});
|
});
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询${functionName}列表 */
|
/** 查询${functionName}列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
list${BusinessName}(this.queryParams).then(response => {
|
list${BusinessName}(this.queryParams).then(response => {
|
||||||
this.${businessName}List = response.rows;
|
this.${businessName}List = response.rows;
|
||||||
this.total = response.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if(${column.dictType} != '')
|
#if(${column.dictType} != '')
|
||||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
#if($parentheseIndex != -1)
|
#if($parentheseIndex != -1)
|
||||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
#else
|
#else
|
||||||
#set($comment=$column.columnComment)
|
#set($comment=$column.columnComment)
|
||||||
#end
|
#end
|
||||||
// $comment字典翻译
|
// $comment字典翻译
|
||||||
${column.javaField}Format(row, column) {
|
${column.javaField}Format(row, column) {
|
||||||
return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField});
|
return this.selectDictLabel#if($column.htmlType == "checkbox")s#end(this.${column.javaField}Options, row.${column.javaField});
|
||||||
},
|
},
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
this.open = false;
|
|
||||||
this.reset();
|
|
||||||
},
|
|
||||||
// 表单重置
|
|
||||||
reset() {
|
|
||||||
this.form = {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "radio")
|
|
||||||
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#elseif($column.htmlType == "checkbox")
|
|
||||||
$column.javaField: []#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#else
|
|
||||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
|
||||||
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
};
|
|
||||||
this.resetForm("form");
|
|
||||||
},
|
|
||||||
/** 搜索按钮操作 */
|
|
||||||
handleQuery() {
|
|
||||||
this.queryParams.pageNum = 1;
|
|
||||||
this.getList();
|
|
||||||
},
|
|
||||||
/** 重置按钮操作 */
|
|
||||||
resetQuery() {
|
|
||||||
this.resetForm("queryForm");
|
|
||||||
this.handleQuery();
|
|
||||||
},
|
|
||||||
// 多选框选中数据
|
|
||||||
handleSelectionChange(selection) {
|
|
||||||
this.ids = selection.map(item => item.${pkColumn.javaField})
|
|
||||||
this.single = selection.length!==1
|
|
||||||
this.multiple = !selection.length
|
|
||||||
},
|
|
||||||
/** 新增按钮操作 */
|
|
||||||
handleAdd() {
|
|
||||||
this.reset();
|
|
||||||
this.open = true;
|
|
||||||
this.title = "添加${functionName}";
|
|
||||||
},
|
|
||||||
/** 修改按钮操作 */
|
|
||||||
handleUpdate(row) {
|
|
||||||
this.reset();
|
|
||||||
const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
|
|
||||||
get${BusinessName}(${pkColumn.javaField}).then(response => {
|
|
||||||
this.form = response.data;
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "checkbox")
|
|
||||||
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
this.open = true;
|
|
||||||
this.title = "修改${functionName}";
|
|
||||||
});
|
|
||||||
},
|
|
||||||
/** 提交按钮 */
|
|
||||||
submitForm() {
|
|
||||||
this.#[[$]]#refs["form"].validate(valid => {
|
|
||||||
if (valid) {
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.htmlType == "checkbox")
|
|
||||||
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
if (this.form.${pkColumn.javaField} != null) {
|
|
||||||
update${BusinessName}(this.form).then(response => {
|
|
||||||
if (response.code === 200) {
|
|
||||||
this.msgSuccess("修改成功");
|
|
||||||
this.open = false;
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "radio")
|
||||||
|
$column.javaField: #if($column.javaType == "Integer" || $column.javaType == "Long")0#else"0"#end#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
|
#elseif($column.htmlType == "checkbox")
|
||||||
|
$column.javaField: []#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
|
#else
|
||||||
|
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
this.getList();
|
this.getList();
|
||||||
}
|
},
|
||||||
});
|
/** 重置按钮操作 */
|
||||||
} else {
|
resetQuery() {
|
||||||
add${BusinessName}(this.form).then(response => {
|
this.resetForm("queryForm");
|
||||||
if (response.code === 200) {
|
this.handleQuery();
|
||||||
this.msgSuccess("新增成功");
|
},
|
||||||
this.open = false;
|
// 多选框选中数据
|
||||||
this.getList();
|
handleSelectionChange(selection) {
|
||||||
}
|
this.ids = selection.map(item => item.${pkColumn.javaField})
|
||||||
});
|
this.single = selection.length!==1
|
||||||
}
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加${functionName}";
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const ${pkColumn.javaField} = row.${pkColumn.javaField} || this.ids
|
||||||
|
get${BusinessName}(${pkColumn.javaField}).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
this.form.$column.javaField = this.form.${column.javaField}.split(",");
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改${functionName}";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.#[[$]]#refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
this.form.$column.javaField = this.form.${column.javaField}.join(",");
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
if (this.form.${pkColumn.javaField} != null) {
|
||||||
|
update${BusinessName}(this.form).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
add${BusinessName}(this.form).then(response => {
|
||||||
|
if (response.code === 200) {
|
||||||
|
this.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids;
|
||||||
|
this.$confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return del${BusinessName}(${pkColumn.javaField}s);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
}).catch(function() {});
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
const queryParams = this.queryParams;
|
||||||
|
this.$confirm('是否确认导出所有${functionName}数据项?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(function() {
|
||||||
|
return export${BusinessName}(queryParams);
|
||||||
|
}).then(response => {
|
||||||
|
this.download(response.msg);
|
||||||
|
}).catch(function() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
},
|
|
||||||
/** 删除按钮操作 */
|
|
||||||
handleDelete(row) {
|
|
||||||
const ${pkColumn.javaField}s = row.${pkColumn.javaField} || this.ids;
|
|
||||||
this.$confirm('是否确认删除${functionName}编号为"' + ${pkColumn.javaField}s + '"的数据项?', "警告", {
|
|
||||||
confirmButtonText: "确定",
|
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning"
|
|
||||||
}).then(function() {
|
|
||||||
return del${BusinessName}(${pkColumn.javaField}s);
|
|
||||||
}).then(() => {
|
|
||||||
this.getList();
|
|
||||||
this.msgSuccess("删除成功");
|
|
||||||
}).catch(function() {});
|
|
||||||
},
|
|
||||||
/** 导出按钮操作 */
|
|
||||||
handleExport() {
|
|
||||||
const queryParams = this.queryParams;
|
|
||||||
this.$confirm('是否确认导出所有${functionName}数据项?', "警告", {
|
|
||||||
confirmButtonText: "确定",
|
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning"
|
|
||||||
}).then(function() {
|
|
||||||
return export${BusinessName}(queryParams);
|
|
||||||
}).then(response => {
|
|
||||||
this.download(response.msg);
|
|
||||||
}).catch(function() {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user