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}
|
||||
export function get${simpleClassName}(id) {
|
||||
return request({
|
||||
|
@ -130,6 +140,15 @@ export function export${simpleClassName}Excel(params) {
|
|||
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}
|
||||
export function get${subSimpleClassName}(id) {
|
||||
return request({
|
||||
|
|
|
@ -13,10 +13,36 @@
|
|||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="openForm(undefined)"
|
||||
v-hasPermi="['${permissionPrefix}:create']">新增</el-button>
|
||||
</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>
|
||||
#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)
|
||||
#if ($column.listOperationResult)
|
||||
#set ($dictType=$column.dictType)
|
||||
|
@ -82,6 +108,9 @@
|
|||
// 列表的数据
|
||||
list: [],
|
||||
#if ($table.templateType == 11)
|
||||
#if ($deleteBatchEnable)
|
||||
checkedIds: [],
|
||||
#end
|
||||
// 列表的总页数
|
||||
total: 0,
|
||||
// 查询参数
|
||||
|
@ -135,12 +164,27 @@
|
|||
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() {
|
||||
this.queryParams.pageNo = 1;
|
||||
this.getList();
|
||||
},
|
||||
#if ($table.templateType == 11)
|
||||
/** 添加/修改操作 */
|
||||
openForm(id) {
|
||||
if (!this.${subJoinColumn.javaField}) {
|
||||
|
|
|
@ -60,6 +60,21 @@
|
|||
展开/折叠
|
||||
</el-button>
|
||||
</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
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
@ -67,12 +82,16 @@
|
|||
## 特殊:主子表专属逻辑
|
||||
#if ( $table.templateType == 11 && $subTables && $subTables.size() > 0 )
|
||||
<el-table
|
||||
row-key="id"
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:highlight-current-row="true"
|
||||
:show-overflow-tooltip="true"
|
||||
@current-change="handleCurrentChange"
|
||||
#if ($deleteBatchEnable)
|
||||
@selection-change="handleRowCheckboxChange"
|
||||
#end
|
||||
>
|
||||
## 特殊:树表专属逻辑
|
||||
#elseif ( $table.templateType == 2 )
|
||||
|
@ -87,7 +106,18 @@
|
|||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
>
|
||||
#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
|
||||
## 特殊:主子表专属逻辑
|
||||
#if ( $table.templateType == 12 && $subTables && $subTables.size() > 0 )
|
||||
|
@ -229,6 +259,7 @@ export default {
|
|||
refreshTable: true,
|
||||
// 选中行
|
||||
currentRow: {},
|
||||
checkedIds: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||
|
@ -301,6 +332,20 @@ export default {
|
|||
this.#[[$modal]]#.msgSuccess("删除成功");
|
||||
} 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() {
|
||||
await this.#[[$modal]]#.confirm('是否确认导出所有${table.classComment}数据项?');
|
||||
|
|
Loading…
Reference in New Issue