|
@@ -21,6 +21,7 @@
|
|
|
:cache-key="cacheKeyUrl"
|
|
:cache-key="cacheKeyUrl"
|
|
|
height="calc(100vh - 350px)"
|
|
height="calc(100vh - 350px)"
|
|
|
@columns-change="handleColumnChange"
|
|
@columns-change="handleColumnChange"
|
|
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
>
|
|
>
|
|
|
<template v-slot:toolbar>
|
|
<template v-slot:toolbar>
|
|
|
<div class="toolbar-left">
|
|
<div class="toolbar-left">
|
|
@@ -32,6 +33,15 @@
|
|
|
@click="handleAdd"
|
|
@click="handleAdd"
|
|
|
>添加记录</el-button
|
|
>添加记录</el-button
|
|
|
>
|
|
>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="danger"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ icon="el-icon-delete"
|
|
|
|
|
+ :disabled="!selectedRows.length"
|
|
|
|
|
+ v-if="$hasPermission('ehs:offlineTraining:delete')"
|
|
|
|
|
+ @click="handleBatchDelete"
|
|
|
|
|
+ >批量删除</el-button
|
|
|
|
|
+ >
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-slot:action="{ row }">
|
|
<template v-slot:action="{ row }">
|
|
@@ -92,8 +102,17 @@
|
|
|
mixins: [tabMixins],
|
|
mixins: [tabMixins],
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
|
|
+ selectedRows: [],
|
|
|
// 表格列配置
|
|
// 表格列配置
|
|
|
columns: [
|
|
columns: [
|
|
|
|
|
+ {
|
|
|
|
|
+ columnKey: 'selection',
|
|
|
|
|
+ type: 'selection',
|
|
|
|
|
+ width: 50,
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ reserveSelection: true,
|
|
|
|
|
+ fixed: 'left'
|
|
|
|
|
+ },
|
|
|
{
|
|
{
|
|
|
columnKey: 'index',
|
|
columnKey: 'index',
|
|
|
label: '序号',
|
|
label: '序号',
|
|
@@ -243,6 +262,31 @@
|
|
|
})
|
|
})
|
|
|
.catch(() => {});
|
|
.catch(() => {});
|
|
|
},
|
|
},
|
|
|
|
|
+ // 多选
|
|
|
|
|
+ handleSelectionChange(rows) {
|
|
|
|
|
+ this.selectedRows = rows || [];
|
|
|
|
|
+ },
|
|
|
|
|
+ // 批量删除
|
|
|
|
|
+ handleBatchDelete() {
|
|
|
|
|
+ const ids = this.selectedRows.map((row) => row.id);
|
|
|
|
|
+ if (!ids.length) {
|
|
|
|
|
+ this.$message.warning('请至少选择一条数据');
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.$confirm(`确认删除选中的 ${ids.length} 条培训记录吗?`, '提示', {
|
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
|
+ type: 'warning'
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(() => remove(ids))
|
|
|
|
|
+ .then((message) => {
|
|
|
|
|
+ this.$message.success(message || '删除成功');
|
|
|
|
|
+ this.selectedRows = [];
|
|
|
|
|
+ this.$refs.table.clearSelection();
|
|
|
|
|
+ this.$refs.table.reload({ page: 1 });
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {});
|
|
|
|
|
+ },
|
|
|
// 搜索
|
|
// 搜索
|
|
|
handleSearch(where) {
|
|
handleSearch(where) {
|
|
|
this.$refs.table.reload({ page: 1, where });
|
|
this.$refs.table.reload({ page: 1, where });
|