update ts generator
This commit is contained in:
parent
27be95a15b
commit
7862d58f01
@ -262,7 +262,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
// 获取模板列表
|
// 获取模板列表
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||||
for (String template : templates) {
|
for (String template : templates) {
|
||||||
if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) {
|
if (!StringUtils.containsAny(template, "sql.vm", "api.ts.vm", "types.ts.vm", "index.vue.vm", "index-tree.vue.vm")) {
|
||||||
// 渲染模板
|
// 渲染模板
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
||||||
|
@ -127,7 +127,8 @@ public class VelocityUtils {
|
|||||||
} else {
|
} else {
|
||||||
templates.add("vm/sql/sql.vm");
|
templates.add("vm/sql/sql.vm");
|
||||||
}
|
}
|
||||||
templates.add("vm/js/api.js.vm");
|
templates.add("vm/ts/api.ts.vm");
|
||||||
|
templates.add("vm/ts/types.ts.vm");
|
||||||
if (GenConstants.TPL_CRUD.equals(tplCategory)) {
|
if (GenConstants.TPL_CRUD.equals(tplCategory)) {
|
||||||
templates.add("vm/vue/index.vue.vm");
|
templates.add("vm/vue/index.vue.vm");
|
||||||
} else if (GenConstants.TPL_TREE.equals(tplCategory)) {
|
} else if (GenConstants.TPL_TREE.equals(tplCategory)) {
|
||||||
@ -176,8 +177,10 @@ public class VelocityUtils {
|
|||||||
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
|
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
|
||||||
} else if (template.contains("sql.vm")) {
|
} else if (template.contains("sql.vm")) {
|
||||||
fileName = businessName + "Menu.sql";
|
fileName = businessName + "Menu.sql";
|
||||||
} else if (template.contains("api.js.vm")) {
|
} else if (template.contains("api.ts.vm")) {
|
||||||
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
|
fileName = StringUtils.format("{}/api/{}/{}/index.ts", vuePath, moduleName, businessName);
|
||||||
|
} else if (template.contains("types.ts.vm")) {
|
||||||
|
fileName = StringUtils.format("{}/api/{}/{}/types.ts", vuePath, moduleName, businessName);
|
||||||
} else if (template.contains("index.vue.vm")) {
|
} else if (template.contains("index.vue.vm")) {
|
||||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||||
} else if (template.contains("index-tree.vue.vm")) {
|
} else if (template.contains("index-tree.vue.vm")) {
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
import request from '@/utils/request';
|
||||||
|
import { AxiosPromise } from 'axios';
|
||||||
|
import { ${BusinessName}VO, ${BusinessName}Form, ${BusinessName}Query } from './types';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询${functionName}列表
|
||||||
|
* @param query
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
export const list${BusinessName} = (#if(${treeCode})query?: ${BusinessName}Query#else query: ${BusinessName}Query#end): AxiosPromise<${BusinessName}VO[]> => {
|
||||||
|
return request({
|
||||||
|
url: '/${moduleName}/${businessName}/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询${functionName}详细
|
||||||
|
* @param ${pkColumn.javaField}
|
||||||
|
*/
|
||||||
|
export const get${BusinessName} = (${pkColumn.javaField}: string | number): AxiosPromise<${BusinessName}VO> => {
|
||||||
|
return request({
|
||||||
|
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增${functionName}
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export const add${BusinessName} = (data: ${BusinessName}Form) => {
|
||||||
|
return request({
|
||||||
|
url: '/${moduleName}/${businessName}',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改${functionName}
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
export const update${BusinessName} = (data: ${BusinessName}Form) => {
|
||||||
|
return request({
|
||||||
|
url: '/${moduleName}/${businessName}',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除${functionName}
|
||||||
|
* @param ${pkColumn.javaField}
|
||||||
|
*/
|
||||||
|
export const del${BusinessName} = (${pkColumn.javaField}: string | number | Array<string | number>) => {
|
||||||
|
return request({
|
||||||
|
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||||
|
method: 'delete'
|
||||||
|
});
|
||||||
|
};
|
@ -0,0 +1,44 @@
|
|||||||
|
export interface ${BusinessName}VO {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.insert || $column.edit)
|
||||||
|
/**
|
||||||
|
* $column.columnComment
|
||||||
|
*/
|
||||||
|
$column.javaField:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
|
||||||
|
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
|
||||||
|
#elseif($column.javaType == 'Boolean') boolean;
|
||||||
|
#else string;
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ${BusinessName}Form extends BaseEntity{
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.insert || $column.edit)
|
||||||
|
/**
|
||||||
|
* $column.columnComment
|
||||||
|
*/
|
||||||
|
$column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
|
||||||
|
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
|
||||||
|
#elseif($column.javaType == 'Boolean') boolean;
|
||||||
|
#else string;
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ${BusinessName}Query #if(!${treeCode})extends PageQuery #end{
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.query)
|
||||||
|
/**
|
||||||
|
* $column.columnComment
|
||||||
|
*/
|
||||||
|
$column.javaField?:#if($column.javaField.indexOf("id") != -1 || $column.javaField.indexOf("Id") != -1) string | number;
|
||||||
|
#elseif($column.javaType == 'Long' || $column.javaType == 'Integer' || $column.javaType == 'Double' || $column.javaType == 'Float' || $column.javaType == 'BigDecimal') number;
|
||||||
|
#elseif($column.javaType == 'Boolean') boolean;
|
||||||
|
#else string;
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="p-2">
|
||||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||||
|
<div class="search" v-show="showSearch">
|
||||||
|
<el-form :model="queryParams" ref="queryFormRef" :inline="true" 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)
|
||||||
@ -43,8 +45,8 @@
|
|||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
placeholder="选择${comment}">
|
placeholder="选择${comment}"
|
||||||
</el-date-picker>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
<el-form-item label="${comment}" style="width: 308px">
|
<el-form-item label="${comment}" style="width: 308px">
|
||||||
@ -56,7 +58,7 @@
|
|||||||
start-placeholder="开始日期"
|
start-placeholder="开始日期"
|
||||||
end-placeholder="结束日期"
|
end-placeholder="结束日期"
|
||||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
|
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
|
||||||
></el-date-picker>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
@ -66,15 +68,20 @@
|
|||||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
|
||||||
|
|
||||||
|
<el-card shadow="never">
|
||||||
|
<template #header>
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
plain
|
plain
|
||||||
icon="Plus"
|
icon="Plus"
|
||||||
@click="handleAdd"
|
@click="handleAdd()"
|
||||||
v-hasPermi="['${moduleName}:${businessName}:add']"
|
v-hasPermi="['${moduleName}:${businessName}:add']
|
||||||
>新增</el-button>
|
>新增</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
@ -82,19 +89,19 @@
|
|||||||
type="info"
|
type="info"
|
||||||
plain
|
plain
|
||||||
icon="Sort"
|
icon="Sort"
|
||||||
@click="toggleExpandAll"
|
@click="handleToggleExpandAll"
|
||||||
>展开/折叠</el-button>
|
>展开/折叠</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
</template>
|
||||||
<el-table
|
<el-table
|
||||||
v-if="refreshTable"
|
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
:data="${businessName}List"
|
:data="${businessName}List"
|
||||||
row-key="${treeCode}"
|
row-key="${treeCode}"
|
||||||
:default-expand-all="isExpandAll"
|
:default-expand-all="isExpandAll"
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
|
ref="${businessName}TableRef"
|
||||||
>
|
>
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#set($javaField=$column.javaField)
|
#set($javaField=$column.javaField)
|
||||||
@ -137,16 +144,22 @@
|
|||||||
#end
|
#end
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
|
<el-tooltip content="修改" placement="top">
|
||||||
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']" />
|
||||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
|
</el-tooltip>
|
||||||
|
<el-tooltip content="新增" placement="top">
|
||||||
|
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${moduleName}:${businessName}:add']" />
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip content="删除" placement="top">
|
||||||
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']" />
|
||||||
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
</el-card>
|
||||||
<!-- 添加或修改${functionName}对话框 -->
|
<!-- 添加或修改${functionName}对话框 -->
|
||||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||||
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
|
<el-form ref="${businessName}FormRef" :model="form" :rules="rules" label-width="80px">
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#set($field=$column.javaField)
|
#set($field=$column.javaField)
|
||||||
#if($column.insert && !$column.pk)
|
#if($column.insert && !$column.pk)
|
||||||
@ -248,8 +261,8 @@
|
|||||||
v-model="form.${field}"
|
v-model="form.${field}"
|
||||||
type="datetime"
|
type="datetime"
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
value-format="YYYY-MM-DD HH:mm:ss"
|
||||||
placeholder="选择${comment}">
|
placeholder="选择${comment}"
|
||||||
</el-date-picker>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "textarea")
|
#elseif($column.htmlType == "textarea")
|
||||||
<el-form-item label="${comment}" prop="${field}">
|
<el-form-item label="${comment}" prop="${field}">
|
||||||
@ -269,24 +282,43 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="${BusinessName}">
|
<script setup name="${BusinessName}" lang="ts">
|
||||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||||
|
import { ${BusinessName}VO, ${BusinessName}Query, ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types';
|
||||||
|
import { ComponentInternalInstance } from 'vue';
|
||||||
|
import { ElForm, ElTable } from 'element-plus';
|
||||||
|
|
||||||
|
|
||||||
|
type ${BusinessName}Option = {
|
||||||
|
${treeCode}: number;
|
||||||
|
${treeName}: string;
|
||||||
|
children?: ${BusinessName}Option[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;;
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance();
|
|
||||||
#if(${dicts} != '')
|
#if(${dicts} != '')
|
||||||
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
||||||
const { ${dictsNoSymbol} } = proxy.useDict(${dicts});
|
const { ${dictsNoSymbol} } = toRefs<any>(proxy?.useDict(${dicts}));
|
||||||
#end
|
#end
|
||||||
|
|
||||||
const ${businessName}List = ref([]);
|
const ${businessName}List = ref<${BusinessName}VO[]>([]);
|
||||||
const ${businessName}Options = ref([]);
|
const ${businessName}Options = ref<${BusinessName}Option[]>([]);
|
||||||
const open = ref(false);
|
|
||||||
const buttonLoading = ref(false);
|
const buttonLoading = ref(false);
|
||||||
const loading = ref(true);
|
|
||||||
const showSearch = ref(true);
|
const showSearch = ref(true);
|
||||||
const title = ref("");
|
|
||||||
const isExpandAll = ref(true);
|
const isExpandAll = ref(true);
|
||||||
const refreshTable = ref(true);
|
const refreshTable = ref(true);
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
const queryFormRef = ref(ElForm);
|
||||||
|
const ${businessName}FormRef = ref(ElForm);
|
||||||
|
const ${businessName}TableRef = ref(ElTable)
|
||||||
|
|
||||||
|
const dialog = reactive<DialogOption>({
|
||||||
|
visible: false,
|
||||||
|
title: ''
|
||||||
|
});
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
@ -294,8 +326,20 @@ const daterange${AttrName} = ref([]);
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
const data = reactive({
|
const initFormData: ${BusinessName}Form = {
|
||||||
form: {},
|
#foreach ($column in $columns)
|
||||||
|
#if($column.insert || $column.edit)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||||
|
#else
|
||||||
|
$column.javaField: undefined#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = reactive<PageData<${BusinessName}Form, ${BusinessName}Query>>({
|
||||||
|
form: {...initFormData},
|
||||||
queryParams: {
|
queryParams: {
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.query)
|
#if($column.query)
|
||||||
@ -325,7 +369,7 @@ const data = reactive({
|
|||||||
const { queryParams, form, rules } = toRefs(data);
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
/** 查询${functionName}列表 */
|
/** 查询${functionName}列表 */
|
||||||
function getList() {
|
const getList = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
@ -342,63 +386,57 @@ function getList() {
|
|||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
list${BusinessName}(queryParams.value).then(response => {
|
const res = await list${BusinessName}(queryParams.value);
|
||||||
${businessName}List.value = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
const data = proxy?.handleTree<${BusinessName}VO>(res.data, "${treeCode}", "${treeParentCode}");
|
||||||
|
if (data) {
|
||||||
|
${businessName}List.value = data;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询${functionName}下拉树结构 */
|
/** 查询${functionName}下拉树结构 */
|
||||||
function getTreeselect() {
|
const getTreeselect = async () => {
|
||||||
list${BusinessName}().then(response => {
|
const res = await list${BusinessName}();
|
||||||
${businessName}Options.value = [];
|
${businessName}Options.value = [];
|
||||||
const data = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] };
|
const data: ${BusinessName}Option = { ${treeCode}: 0, ${treeName}: '顶级节点', children: [] };
|
||||||
data.children = proxy.handleTree(response.data, "${treeCode}", "${treeParentCode}");
|
data.children = proxy?.handleTree<${BusinessName}Option>(res.data, "${treeCode}", "${treeParentCode}");
|
||||||
${businessName}Options.value.push(data);
|
${businessName}Options.value.push(data);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
function cancel() {
|
const cancel = () => {
|
||||||
open.value = false;
|
|
||||||
reset();
|
reset();
|
||||||
|
dialog.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表单重置
|
// 表单重置
|
||||||
function reset() {
|
const reset = () => {
|
||||||
form.value = {
|
form.value = {...initFormData}
|
||||||
#foreach ($column in $columns)
|
${businessName}FormRef.value.resetFields();
|
||||||
#if($column.insert || $column.edit)
|
|
||||||
#if($column.htmlType == "checkbox")
|
|
||||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
|
||||||
#else
|
|
||||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
};
|
|
||||||
proxy.resetForm("${businessName}Ref");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
function handleQuery() {
|
const handleQuery = () => {
|
||||||
getList();
|
getList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
function resetQuery() {
|
const resetQuery = () => {
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
daterange${AttrName}.value = [];
|
daterange${AttrName}.value = [];
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
proxy.resetForm("queryRef");
|
queryFormRef.value.resetFields();
|
||||||
handleQuery();
|
handleQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
function handleAdd(row) {
|
const handleAdd = (row?: ${BusinessName}VO) => {
|
||||||
|
dialog.visible = true;
|
||||||
|
dialog.title = "添加${functionName}";
|
||||||
|
nextTick(() => {
|
||||||
reset();
|
reset();
|
||||||
getTreeselect();
|
getTreeselect();
|
||||||
if (row != null && row.${treeCode}) {
|
if (row != null && row.${treeCode}) {
|
||||||
@ -406,22 +444,29 @@ function handleAdd(row) {
|
|||||||
} else {
|
} else {
|
||||||
form.value.${treeParentCode} = 0;
|
form.value.${treeParentCode} = 0;
|
||||||
}
|
}
|
||||||
open.value = true;
|
|
||||||
title.value = "添加${functionName}";
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 展开/折叠操作 */
|
|
||||||
function toggleExpandAll() {
|
|
||||||
refreshTable.value = false;
|
|
||||||
isExpandAll.value = !isExpandAll.value;
|
|
||||||
nextTick(() => {
|
|
||||||
refreshTable.value = true;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 展开/折叠操作 */
|
||||||
|
const handleToggleExpandAll = () => {
|
||||||
|
isExpandAll.value = !isExpandAll.value;
|
||||||
|
toggleExpandAll(${businessName}List.value, isExpandAll.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 展开/折叠操作 */
|
||||||
|
const toggleExpandAll = (data: ${BusinessName}VO[], status: boolean) => {
|
||||||
|
data.forEach((item) => {
|
||||||
|
${businessName}TableRef.value.toggleRowExpansion(item, status)
|
||||||
|
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
async function handleUpdate(row) {
|
const handleUpdate = (row: ${BusinessName}VO) => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
dialog.visible = true;
|
||||||
|
dialog.title = "修改${functionName}";
|
||||||
|
nextTick(async () => {
|
||||||
reset();
|
reset();
|
||||||
await getTreeselect();
|
await getTreeselect();
|
||||||
if (row != null) {
|
if (row != null) {
|
||||||
@ -435,14 +480,13 @@ async function handleUpdate(row) {
|
|||||||
form.value.$column.javaField = form.value.${column.javaField}.split(",");
|
form.value.$column.javaField = form.value.${column.javaField}.split(",");
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
open.value = true;
|
});
|
||||||
title.value = "修改${functionName}";
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
function submitForm() {
|
const submitForm = () => {
|
||||||
proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => {
|
${businessName}FormRef.value.validate((valid: boolean) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
buttonLoading.value = true;
|
buttonLoading.value = true;
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
@ -450,41 +494,28 @@ function submitForm() {
|
|||||||
form.value.$column.javaField = form.value.${column.javaField}.join(",");
|
form.value.$column.javaField = form.value.${column.javaField}.join(",");
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
if (form.value.${pkColumn.javaField} != null) {
|
if (form.value.${pkColumn.javaField}) {
|
||||||
update${BusinessName}(form.value).then(response => {
|
update${BusinessName}(form.value).finally(() => buttonLoading.value = false);
|
||||||
proxy.#[[$modal]]#.msgSuccess("修改成功");
|
|
||||||
open.value = false;
|
|
||||||
getList();
|
|
||||||
}).finally(() => {
|
|
||||||
buttonLoading.value = false;
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
add${BusinessName}(form.value).then(response => {
|
add${BusinessName}(form.value).finally(() => buttonLoading.value = false);
|
||||||
proxy.#[[$modal]]#.msgSuccess("新增成功");
|
|
||||||
open.value = false;
|
|
||||||
getList();
|
|
||||||
}).finally(() => {
|
|
||||||
buttonLoading.value = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
proxy?.#[[$modal]]#.msgSuccess("操作成功");
|
||||||
|
dialog.visible = false;
|
||||||
|
getList();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
function handleDelete(row) {
|
const handleDelete = async (row: ${BusinessName}VO) => {
|
||||||
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?').then(function() {
|
await proxy?.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?');
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
return del${BusinessName}(row.${pkColumn.javaField});
|
await del${BusinessName}(row.${pkColumn.javaField}).finally(() => loading.value = false);
|
||||||
}).then(() => {
|
await getList();
|
||||||
loading.value = false;
|
proxy?.#[[$modal]]#.msgSuccess("删除成功");
|
||||||
getList();
|
|
||||||
proxy.#[[$modal]]#.msgSuccess("删除成功");
|
|
||||||
}).catch(() => {
|
|
||||||
}).finally(() => {
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
getList();
|
getList();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="p-2">
|
||||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
|
||||||
|
<div class="search" v-show="showSearch">
|
||||||
|
<el-form :model="queryParams" ref="queryFormRef" :inline="true" 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)
|
||||||
@ -43,8 +45,8 @@
|
|||||||
v-model="queryParams.${column.javaField}"
|
v-model="queryParams.${column.javaField}"
|
||||||
type="date"
|
type="date"
|
||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
placeholder="请选择${comment}">
|
placeholder="请选择${comment}"
|
||||||
</el-date-picker>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
<el-form-item label="${comment}" style="width: 308px">
|
<el-form-item label="${comment}" style="width: 308px">
|
||||||
@ -56,7 +58,7 @@
|
|||||||
start-placeholder="开始日期"
|
start-placeholder="开始日期"
|
||||||
end-placeholder="结束日期"
|
end-placeholder="结束日期"
|
||||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
|
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
|
||||||
></el-date-picker>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
@ -66,7 +68,11 @@
|
|||||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</transition>
|
||||||
|
|
||||||
|
<el-card shadow="never">
|
||||||
|
<template #header>
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
@ -83,7 +89,7 @@
|
|||||||
plain
|
plain
|
||||||
icon="Edit"
|
icon="Edit"
|
||||||
:disabled="single"
|
:disabled="single"
|
||||||
@click="handleUpdate"
|
@click="handleUpdate()"
|
||||||
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
v-hasPermi="['${moduleName}:${businessName}:edit']"
|
||||||
>修改</el-button>
|
>修改</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -93,7 +99,7 @@
|
|||||||
plain
|
plain
|
||||||
icon="Delete"
|
icon="Delete"
|
||||||
:disabled="multiple"
|
:disabled="multiple"
|
||||||
@click="handleDelete"
|
@click="handleDelete()"
|
||||||
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
v-hasPermi="['${moduleName}:${businessName}:remove']"
|
||||||
>删除</el-button>
|
>删除</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -108,6 +114,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
@ -149,8 +156,12 @@
|
|||||||
#end
|
#end
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
|
<el-tooltip content="修改" placement="top">
|
||||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip content="删除" placement="top">
|
||||||
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -162,10 +173,10 @@
|
|||||||
v-model:limit="queryParams.pageSize"
|
v-model:limit="queryParams.pageSize"
|
||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
|
</el-card>
|
||||||
<!-- 添加或修改${functionName}对话框 -->
|
<!-- 添加或修改${functionName}对话框 -->
|
||||||
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||||
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
|
<el-form ref="${businessName}FormRef" :model="form" :rules="rules" label-width="80px">
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#set($field=$column.javaField)
|
#set($field=$column.javaField)
|
||||||
#if($column.insert && !$column.pk)
|
#if($column.insert && !$column.pk)
|
||||||
@ -277,25 +288,26 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="${BusinessName}">
|
<script setup name="${BusinessName}" lang="ts">
|
||||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from '@/api/${moduleName}/${businessName}';
|
||||||
|
import { ${BusinessName}VO, ${BusinessName}Query, ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types';
|
||||||
|
import { ComponentInternalInstance } from 'vue';
|
||||||
|
import { ElForm } from 'element-plus';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
||||||
#if(${dicts} != '')
|
#if(${dicts} != '')
|
||||||
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
#set($dictsNoSymbol=$dicts.replace("'", ""))
|
||||||
const { ${dictsNoSymbol} } = proxy.useDict(${dicts});
|
const { ${dictsNoSymbol} } = toRefs<any>(proxy?.useDict(${dicts}));
|
||||||
#end
|
#end
|
||||||
|
|
||||||
const ${businessName}List = ref([]);
|
const ${businessName}List = ref<${BusinessName}VO[]>([]);
|
||||||
const open = ref(false);
|
|
||||||
const buttonLoading = ref(false);
|
const buttonLoading = ref(false);
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const showSearch = ref(true);
|
const showSearch = ref(true);
|
||||||
const ids = ref([]);
|
const ids = ref<Array<string | number>>([]);
|
||||||
const single = ref(true);
|
const single = ref(true);
|
||||||
const multiple = ref(true);
|
const multiple = ref(true);
|
||||||
const total = ref(0);
|
const total = ref(0);
|
||||||
const title = ref("");
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
@ -303,8 +315,27 @@ const daterange${AttrName} = ref([]);
|
|||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
const data = reactive({
|
const queryFormRef = ref(ElForm);
|
||||||
form: {},
|
const ${businessName}FormRef = ref(ElForm);
|
||||||
|
|
||||||
|
const dialog = reactive<DialogOption>({
|
||||||
|
visible: false,
|
||||||
|
title: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const initFormData: ${BusinessName}Form = {
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.insert || $column.edit)
|
||||||
|
#if($column.htmlType == "checkbox")
|
||||||
|
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
||||||
|
#else
|
||||||
|
$column.javaField: undefined#if($foreach.count != $columns.size()),#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
const data = reactive<PageData<${BusinessName}Form, ${BusinessName}Query>>({
|
||||||
|
form: {...initFormData},
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@ -336,7 +367,7 @@ const data = reactive({
|
|||||||
const { queryParams, form, rules } = toRefs(data);
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
/** 查询${functionName}列表 */
|
/** 查询${functionName}列表 */
|
||||||
function getList() {
|
const getList = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
@ -353,88 +384,80 @@ function getList() {
|
|||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
list${BusinessName}(queryParams.value).then(response => {
|
const res = await list${BusinessName}(queryParams.value);
|
||||||
${businessName}List.value = response.rows;
|
${businessName}List.value = res.rows;
|
||||||
total.value = response.total;
|
total.value = res.total;
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消按钮
|
/** 取消按钮 */
|
||||||
function cancel() {
|
const cancel = () => {
|
||||||
open.value = false;
|
|
||||||
reset();
|
reset();
|
||||||
|
dialog.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表单重置
|
/** 表单重置 */
|
||||||
function reset() {
|
const reset = () => {
|
||||||
form.value = {
|
form.value = {...initFormData};
|
||||||
#foreach ($column in $columns)
|
${businessName}FormRef.value.resetFields();
|
||||||
#if($column.insert || $column.edit)
|
|
||||||
#if($column.htmlType == "checkbox")
|
|
||||||
$column.javaField: []#if($foreach.count != $columns.size()),#end
|
|
||||||
#else
|
|
||||||
$column.javaField: null#if($foreach.count != $columns.size()),#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
};
|
|
||||||
proxy.resetForm("${businessName}Ref");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
function handleQuery() {
|
const handleQuery = () => {
|
||||||
queryParams.value.pageNum = 1;
|
queryParams.value.pageNum = 1;
|
||||||
getList();
|
getList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
function resetQuery() {
|
const resetQuery = () => {
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
daterange${AttrName}.value = [];
|
daterange${AttrName}.value = [];
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
proxy.resetForm("queryRef");
|
queryFormRef.value.resetFields();
|
||||||
handleQuery();
|
handleQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 多选框选中数据
|
/** 多选框选中数据 */
|
||||||
function handleSelectionChange(selection) {
|
const handleSelectionChange = (selection: ${BusinessName}VO[]) => {
|
||||||
ids.value = selection.map(item => item.${pkColumn.javaField});
|
ids.value = selection.map(item => item.${pkColumn.javaField});
|
||||||
single.value = selection.length != 1;
|
single.value = selection.length != 1;
|
||||||
multiple.value = !selection.length;
|
multiple.value = !selection.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
function handleAdd() {
|
const handleAdd = () => {
|
||||||
|
dialog.visible = true;
|
||||||
|
dialog.title = "添加${functionName}";
|
||||||
|
nextTick(() => {
|
||||||
reset();
|
reset();
|
||||||
open.value = true;
|
});
|
||||||
title.value = "添加${functionName}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
function handleUpdate(row) {
|
const handleUpdate = (row?: ${BusinessName}VO) => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
dialog.visible = true;
|
||||||
|
dialog.title = "修改${functionName}";
|
||||||
|
nextTick(async () => {
|
||||||
reset();
|
reset();
|
||||||
const _${pkColumn.javaField} = row.${pkColumn.javaField} || ids.value
|
const _${pkColumn.javaField} = row?.${pkColumn.javaField} || ids.value[0]
|
||||||
get${BusinessName}(_${pkColumn.javaField}).then(response => {
|
const res = await get${BusinessName}(_${pkColumn.javaField});
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
form.value = response.data;
|
Object.assign(form.value, res.data);
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.htmlType == "checkbox")
|
#if($column.htmlType == "checkbox")
|
||||||
form.value.$column.javaField = form.value.${column.javaField}.split(",");
|
form.value.$column.javaField = form.value.${column.javaField}.split(",");
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
open.value = true;
|
|
||||||
title.value = "修改${functionName}";
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
function submitForm() {
|
const submitForm = () => {
|
||||||
proxy.#[[$]]#refs["${businessName}Ref"].validate(valid => {
|
${businessName}FormRef.value.validate(async (valid: boolean) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
buttonLoading.value = true;
|
buttonLoading.value = true;
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
@ -442,49 +465,35 @@ function submitForm() {
|
|||||||
form.value.$column.javaField = form.value.${column.javaField}.join(",");
|
form.value.$column.javaField = form.value.${column.javaField}.join(",");
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
if (form.value.${pkColumn.javaField} != null) {
|
if (form.value.${pkColumn.javaField}) {
|
||||||
update${BusinessName}(form.value).then(response => {
|
await update${BusinessName}(form.value).finally(() => buttonLoading.value = false);
|
||||||
proxy.#[[$modal]]#.msgSuccess("修改成功");
|
|
||||||
open.value = false;
|
|
||||||
getList();
|
|
||||||
}).finally(() => {
|
|
||||||
buttonLoading.value = false;
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
add${BusinessName}(form.value).then(response => {
|
await add${BusinessName}(form.value).finally(() => buttonLoading.value = false);
|
||||||
proxy.#[[$modal]]#.msgSuccess("新增成功");
|
|
||||||
open.value = false;
|
|
||||||
getList();
|
|
||||||
}).finally(() => {
|
|
||||||
buttonLoading.value = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
proxy?.#[[$modal]]#.msgSuccess("修改成功");
|
||||||
|
dialog.visible = false;
|
||||||
|
await getList();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
function handleDelete(row) {
|
const handleDelete = async (row?: ${BusinessName}VO) => {
|
||||||
const _${pkColumn.javaField}s = row.${pkColumn.javaField} || ids.value;
|
const _${pkColumn.javaField}s = row?.${pkColumn.javaField} || ids.value;
|
||||||
proxy.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').then(function() {
|
await proxy?.#[[$modal]]#.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?').finally(() => loading.value = false);
|
||||||
loading.value = true;
|
await del${BusinessName}(_${pkColumn.javaField}s);
|
||||||
return del${BusinessName}(_${pkColumn.javaField}s);
|
proxy?.#[[$modal]]#.msgSuccess("删除成功");
|
||||||
}).then(() => {
|
await getList();
|
||||||
loading.value = true;
|
|
||||||
getList();
|
|
||||||
proxy.#[[$modal]]#.msgSuccess("删除成功");
|
|
||||||
}).catch(() => {
|
|
||||||
}).finally(() => {
|
|
||||||
loading.value = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
function handleExport() {
|
const handleExport = () => {
|
||||||
proxy.download('${moduleName}/${businessName}/export', {
|
proxy?.download('${moduleName}/${businessName}/export', {
|
||||||
...queryParams.value
|
...queryParams.value
|
||||||
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
|
}, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
getList();
|
getList();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user