perf: 优化 vue2 代码生成模板,增加批量删除功能
This commit is contained in:
parent
6a5d343036
commit
b76c39fa8d
|
@ -27,6 +27,16 @@ export function delete${simpleClassName}(id) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ( $table.templateType != 2 && $deleteBatchEnable)
|
||||||
|
/** 批量删除${table.classComment} */
|
||||||
|
export function delete${simpleClassName}List(ids) {
|
||||||
|
return request({
|
||||||
|
url: `${baseURL}/delete-list?ids=${ids.join(',')}`,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
// 获得${table.classComment}
|
// 获得${table.classComment}
|
||||||
export function get${simpleClassName}(id) {
|
export function get${simpleClassName}(id) {
|
||||||
return request({
|
return request({
|
||||||
|
@ -130,6 +140,15 @@ export function export${simpleClassName}Excel(params) {
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
#if ($deleteBatchEnable)
|
||||||
|
/** 批量删除${subTable.classComment} */
|
||||||
|
export function delete${subSimpleClassName}List(ids) {
|
||||||
|
return request({
|
||||||
|
url: `${baseURL}/${subSimpleClassName_strikeCase}/delete-list?ids=${ids.join(',')}`,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
#end
|
||||||
// 获得${subTable.classComment}
|
// 获得${subTable.classComment}
|
||||||
export function get${subSimpleClassName}(id) {
|
export function get${subSimpleClassName}(id) {
|
||||||
return request({
|
return request({
|
||||||
|
|
|
@ -13,10 +13,36 @@
|
||||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
|
||||||
v-hasPermi="['${permissionPrefix}:create']">新增</el-button>
|
v-hasPermi="['${permissionPrefix}:create']">新增</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
#if ($deleteBatchEnable)
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="isEmpty(checkedIds)"
|
||||||
|
@click="handleDeleteBatch"
|
||||||
|
v-hasPermi="['${permissionPrefix}:delete']"
|
||||||
|
>
|
||||||
|
批量删除
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
#end
|
||||||
</el-row>
|
</el-row>
|
||||||
#end
|
#end
|
||||||
## 列表
|
## 列表
|
||||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="list"
|
||||||
|
:stripe="true"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
#if ($table.templateType == 11 && $deleteBatchEnable)
|
||||||
|
@selection-change="handleRowCheckboxChange"
|
||||||
|
#end
|
||||||
|
>
|
||||||
|
#if ($table.templateType == 11 && $deleteBatchEnable)
|
||||||
|
<el-table-column type="selection" width="55" />
|
||||||
|
#end
|
||||||
#foreach($column in $subColumns)
|
#foreach($column in $subColumns)
|
||||||
#if ($column.listOperationResult)
|
#if ($column.listOperationResult)
|
||||||
#set ($dictType=$column.dictType)
|
#set ($dictType=$column.dictType)
|
||||||
|
@ -82,6 +108,9 @@
|
||||||
// 列表的数据
|
// 列表的数据
|
||||||
list: [],
|
list: [],
|
||||||
#if ($table.templateType == 11)
|
#if ($table.templateType == 11)
|
||||||
|
#if ($deleteBatchEnable)
|
||||||
|
checkedIds: [],
|
||||||
|
#end
|
||||||
// 列表的总页数
|
// 列表的总页数
|
||||||
total: 0,
|
total: 0,
|
||||||
// 查询参数
|
// 查询参数
|
||||||
|
@ -135,12 +164,27 @@
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
#if ($table.templateType == 11 && $deleteBatchEnable)
|
||||||
|
/** 批量删除${table.classComment} */
|
||||||
|
async handleDeleteBatch() {
|
||||||
|
await this.#[[$modal]]#.confirm('是否确认删除?')
|
||||||
|
try {
|
||||||
|
await ${simpleClassName}Api.delete${subSimpleClassName}List(this.checkedIds);
|
||||||
|
await this.getList();
|
||||||
|
this.#[[$modal]]#.msgSuccess("删除成功");
|
||||||
|
} catch {}
|
||||||
|
},
|
||||||
|
handleRowCheckboxChange(records) {
|
||||||
|
this.checkedIds = records.map((item) => item.id);
|
||||||
|
},
|
||||||
|
#end
|
||||||
|
|
||||||
|
#if ($table.templateType == 11)
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
this.queryParams.pageNo = 1;
|
this.queryParams.pageNo = 1;
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
#if ($table.templateType == 11)
|
|
||||||
/** 添加/修改操作 */
|
/** 添加/修改操作 */
|
||||||
openForm(id) {
|
openForm(id) {
|
||||||
if (!this.${subJoinColumn.javaField}) {
|
if (!this.${subJoinColumn.javaField}) {
|
||||||
|
|
|
@ -60,6 +60,21 @@
|
||||||
展开/折叠
|
展开/折叠
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
#end
|
||||||
|
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="isEmpty(checkedIds)"
|
||||||
|
@click="handleDeleteBatch"
|
||||||
|
v-hasPermi="['${permissionPrefix}:delete']"
|
||||||
|
>
|
||||||
|
批量删除
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
#end
|
#end
|
||||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
@ -67,12 +82,16 @@
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
|
#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
|
||||||
<el-table
|
<el-table
|
||||||
|
row-key="id"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
:data="list"
|
:data="list"
|
||||||
:stripe="true"
|
:stripe="true"
|
||||||
:highlight-current-row="true"
|
:highlight-current-row="true"
|
||||||
:show-overflow-tooltip="true"
|
:show-overflow-tooltip="true"
|
||||||
@current-change="handleCurrentChange"
|
@current-change="handleCurrentChange"
|
||||||
|
#if ($deleteBatchEnable)
|
||||||
|
@selection-change="handleRowCheckboxChange"
|
||||||
|
#end
|
||||||
>
|
>
|
||||||
## 特殊:树表专属逻辑
|
## 特殊:树表专属逻辑
|
||||||
#elseif ( $table.templateType == 2 )
|
#elseif ( $table.templateType == 2 )
|
||||||
|
@ -87,7 +106,18 @@
|
||||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||||
>
|
>
|
||||||
#else
|
#else
|
||||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
<el-table
|
||||||
|
v-loading="loading"
|
||||||
|
:data="list"
|
||||||
|
:stripe="true"
|
||||||
|
:show-overflow-tooltip="true"
|
||||||
|
#if ($deleteBatchEnable)
|
||||||
|
@selection-change="handleRowCheckboxChange"
|
||||||
|
#end
|
||||||
|
>
|
||||||
|
#end
|
||||||
|
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||||
|
<el-table-column type="selection" width="55" />
|
||||||
#end
|
#end
|
||||||
## 特殊:主子表专属逻辑
|
## 特殊:主子表专属逻辑
|
||||||
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
||||||
|
@ -229,6 +259,7 @@ export default {
|
||||||
refreshTable: true,
|
refreshTable: true,
|
||||||
// 选中行
|
// 选中行
|
||||||
currentRow: {},
|
currentRow: {},
|
||||||
|
checkedIds: [],
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
## 特殊:树表专属逻辑(树不需要分页接口)
|
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||||
|
@ -301,6 +332,20 @@ export default {
|
||||||
this.#[[$modal]]#.msgSuccess("删除成功");
|
this.#[[$modal]]#.msgSuccess("删除成功");
|
||||||
} catch {}
|
} catch {}
|
||||||
},
|
},
|
||||||
|
#if ($table.templateType != 2 && $deleteBatchEnable)
|
||||||
|
/** 批量删除${table.classComment} */
|
||||||
|
async handleDeleteBatch() {
|
||||||
|
await this.#[[$modal]]#.confirm('是否确认删除?')
|
||||||
|
try {
|
||||||
|
await ${simpleClassName}Api.delete${simpleClassName}List(this.checkedIds);
|
||||||
|
await this.getList();
|
||||||
|
this.#[[$modal]]#.msgSuccess("删除成功");
|
||||||
|
} catch {}
|
||||||
|
},
|
||||||
|
handleRowCheckboxChange(records) {
|
||||||
|
this.checkedIds = records.map((item) => item.id);
|
||||||
|
},
|
||||||
|
#end
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
async handleExport() {
|
async handleExport() {
|
||||||
await this.#[[$modal]]#.confirm('是否确认导出所有${table.classComment}数据项?');
|
await this.#[[$modal]]#.confirm('是否确认导出所有${table.classComment}数据项?');
|
||||||
|
|
Loading…
Reference in New Issue