Ver código fonte

feat: add batchDel

double.huang 5 anos atrás
pai
commit
8eb10af483
2 arquivos alterados com 16 adições e 8 exclusões
  1. 10 0
      src/api/modules/sys_user.js
  2. 6 8
      src/views/user/index.vue

+ 10 - 0
src/api/modules/sys_user.js

@@ -21,6 +21,16 @@ module.exports.del = (data) => {
   })
 }
 
+// batchDel 删除用户
+module.exports.batchDel = (data) => {
+  const url = '/api/sys/user/batch_del'
+  return axios({
+    url: url,
+    method: 'delete',
+    data
+  })
+}
+
 // update 更新用户
 module.exports.update = (data) => {
   const url = '/api/sys/user/update'

+ 6 - 8
src/views/user/index.vue

@@ -23,7 +23,7 @@
               </el-row>
             </el-header>
             <el-main class="table-main">
-              <sheet ref="qtable" :api="this.$api.sysUser.page" :columns="tableColumns" :data-query="dataQuery" :operates="operates" :float-type="'right'" :select-type="'selection'" header-name="searchForm" />
+              <sheet ref="qtable" :api="this.$api.sysUser.page" :columns="tableColumns" :data-query="dataQuery" :operates="operates" :float-type="'right'" :select-type="'selection'" header-name="searchForm" :selection-data.sync="selectionData" />
             </el-main>
           </el-container>
         </el-container>
@@ -165,7 +165,8 @@ export default {
       orgs: [],
       options: [],
       templs: [],
-      temp_items: []
+      temp_items: [],
+      selectionData: []
     }
   },
   computed: {
@@ -223,7 +224,7 @@ export default {
       this.$api.sysUserTemplateDetail.page({ page: 1, size: 100, 'temp_id': temp_id }).then(res => {
         this.temp_items = res.data.data
         var tempValue
-        if (this.temp.temp_value !== '' && this.temp.temp_value !== undefined) {
+        if (this.temp.temp_value) {
           tempValue = JSON.parse(this.temp.temp_value)
         } else {
           tempValue = []
@@ -354,14 +355,11 @@ export default {
       })
     },
     deleteBatch() {
-      const ids = []
-      this.$refs.qtable.multipleSelection.forEach(row => {
-        ids.push({ id: row.id })
-      })
+      const ids = this.selectionData.map(row => ({ id: row.id }))
       this.$confirm('确认批量删除选中数据吗?', '提示', {
         type: 'warning'
       }).then(() => {
-        this.$api.user.del(ids).then(res => {
+        this.$api.sysUser.batchDel(ids).then(res => {
           if (res.code === 200) {
             this.$refs.qtable.getData()
             this.$message({