66 <el-button type =" primary" plain icon =" el-icon-plus" size =" mini" @click =" handleAdd"
77 v-hasPermi =" ['infra:data-source-config:create']" >新增</el-button >
88 </el-col >
9+ <el-col :span =" 1.5" >
10+ <el-button
11+ type =" danger"
12+ plain
13+ icon =" el-icon-delete"
14+ size =" mini"
15+ :disabled =" isEmpty(checkedIds)"
16+ @click =" handleDeleteBatch"
17+ v-hasPermi =" ['infra:data-source-config:delete']"
18+ >
19+ 批量删除
20+ </el-button >
21+ </el-col >
922 </el-row >
1023
1124 <!-- 列表 -->
12- <el-table v-loading =" loading" :data =" list" >
25+ <el-table v-loading =" loading" :data =" list" @selection-change =" handleRowCheckboxChange" >
26+ <el-table-column type =" selection" width =" 55" />
1327 <el-table-column label =" 主键编号" align =" center" prop =" id" />
1428 <el-table-column label =" 数据源名称" align =" center" prop =" name" />
1529 <el-table-column label =" 数据源连接" align =" center" prop =" url" />
5468</template >
5569
5670<script >
57- import { createDataSourceConfig , updateDataSourceConfig , deleteDataSourceConfig , getDataSourceConfig , getDataSourceConfigList } from " @/api/infra/dataSourceConfig" ;
71+ import { createDataSourceConfig , updateDataSourceConfig , deleteDataSourceConfig , getDataSourceConfig , getDataSourceConfigList , deleteDataSourceConfigList } from " @/api/infra/dataSourceConfig" ;
5872
5973export default {
6074 name: " InfraDataSourceConfig" ,
@@ -80,7 +94,8 @@ export default {
8094 url: [{ required: true , message: " 数据源连接不能为空" , trigger: " blur" }],
8195 username: [{ required: true , message: " 用户名不能为空" , trigger: " blur" }],
8296 password: [{ required: true , message: " 密码不能为空" , trigger: " blur" }],
83- }
97+ },
98+ checkedIds: []
8499 };
85100 },
86101 created () {
@@ -160,6 +175,18 @@ export default {
160175 this .getList ();
161176 this .$modal .msgSuccess (" 删除成功" );
162177 }).catch (() => {});
178+ },
179+ handleRowCheckboxChange (val ) {
180+ this .checkedIds = val .map (item => item .id );
181+ },
182+ handleDeleteBatch () {
183+ const ids = this .checkedIds ;
184+ this .$modal .confirm (' 是否确认删除选中的数据源配置?' ).then (function () {
185+ return deleteDataSourceConfigList (ids);
186+ }).then (() => {
187+ this .getList ();
188+ this .$modal .msgSuccess (" 删除成功" );
189+ }).catch (() => {});
163190 }
164191 }
165192};
0 commit comments