add batch delete user token
This commit is contained in:
@@ -14,3 +14,11 @@ export function remove (data) {
|
|||||||
data,
|
data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function batchRemove (data) {
|
||||||
|
return request({
|
||||||
|
url: '/user_token/batchDelete',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
+19
-1
@@ -1,5 +1,5 @@
|
|||||||
import { reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
import { list, remove } from '@/api/user_token'
|
import { batchRemove, list, remove } from '@/api/user_token'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
@@ -52,11 +52,29 @@ export function useRepositories () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const batchDelete = async (ids) => {
|
||||||
|
const cf = await ElMessageBox.confirm(T('Confirm?', { param: T('BatchDelete') }), {
|
||||||
|
confirmButtonText: T('Confirm'),
|
||||||
|
cancelButtonText: T('Cancel'),
|
||||||
|
type: 'warning',
|
||||||
|
}).catch(_ => false)
|
||||||
|
if (!cf) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await batchRemove({ ids }).catch(_ => false)
|
||||||
|
if (res) {
|
||||||
|
ElMessage.success(T('OperationSuccess'))
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
listRes,
|
listRes,
|
||||||
listQuery,
|
listQuery,
|
||||||
getList,
|
getList,
|
||||||
handlerQuery,
|
handlerQuery,
|
||||||
del,
|
del,
|
||||||
|
batchDelete,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,13 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
|
<el-button type="primary" @click="handlerQuery">{{ T('Filter') }}</el-button>
|
||||||
|
<el-button type="danger" @click="toBatchDelete">{{ T('BatchDelete') }}</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card class="list-body" shadow="hover">
|
<el-card class="list-body" shadow="hover">
|
||||||
<el-table :data="listRes.list" v-loading="listRes.loading" border>
|
<el-table :data="listRes.list" v-loading="listRes.loading" border @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" align="center" width="50"/>
|
||||||
<el-table-column prop="id" label="id" align="center" width="100"/>
|
<el-table-column prop="id" label="id" align="center" width="100"/>
|
||||||
<el-table-column :label="T('Owner')" align="center">
|
<el-table-column :label="T('Owner')" align="center">
|
||||||
<template #default="{row}">
|
<template #default="{row}">
|
||||||
@@ -56,7 +58,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onActivated, onMounted, watch } from 'vue'
|
import { onActivated, onMounted, ref, watch } from 'vue'
|
||||||
import { loadAllUsers } from '@/global'
|
import { loadAllUsers } from '@/global'
|
||||||
import { useRepositories } from '@/views/user/token.js'
|
import { useRepositories } from '@/views/user/token.js'
|
||||||
import { T } from '@/utils/i18n'
|
import { T } from '@/utils/i18n'
|
||||||
@@ -70,6 +72,7 @@
|
|||||||
getList,
|
getList,
|
||||||
handlerQuery,
|
handlerQuery,
|
||||||
del,
|
del,
|
||||||
|
batchDelete,
|
||||||
} = useRepositories()
|
} = useRepositories()
|
||||||
|
|
||||||
onMounted(getList)
|
onMounted(getList)
|
||||||
@@ -85,6 +88,17 @@
|
|||||||
const now = new Date().getTime()
|
const now = new Date().getTime()
|
||||||
return row.expired_at * 1000 < now
|
return row.expired_at * 1000 < now
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const multipleSelection = ref([])
|
||||||
|
const handleSelectionChange = (val) => {
|
||||||
|
multipleSelection.value = val
|
||||||
|
}
|
||||||
|
const toBatchDelete = () => {
|
||||||
|
if (multipleSelection.value.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
batchDelete(multipleSelection.value.map(v => v.id))
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
Reference in New Issue
Block a user