提交 dea8597d authored 作者: 王鹏飞's avatar 王鹏飞

chore: 新增批量删除标签

上级 f728161a
...@@ -41,6 +41,11 @@ export function deleteLabel(data: { id: string }) { ...@@ -41,6 +41,11 @@ export function deleteLabel(data: { id: string }) {
return httpRequest.post('/api/lab/v1/experiment/tag/bda-delete', data) return httpRequest.post('/api/lab/v1/experiment/tag/bda-delete', data)
} }
// 删除标签
export function deleteLabels(data: { ids: string }) {
return httpRequest.post('/api/lab/v1/experiment/tag/batch-delete', data)
}
// 获取标签数据信息 // 获取标签数据信息
export function getLabelStatistics(params: { id: string }) { export function getLabelStatistics(params: { id: string }) {
return httpRequest.get('/api/lab/v1/experiment/tag/bda-statistics', { params }) return httpRequest.get('/api/lab/v1/experiment/tag/bda-statistics', { params })
......
<script setup lang="ts"> <script setup lang="ts">
import type { Label } from '../types' import type { Label } from '../types'
import { Plus } from '@element-plus/icons-vue' import { Plus, Delete } from '@element-plus/icons-vue'
import AppList from '@/components/base/AppList.vue' import AppList from '@/components/base/AppList.vue'
import LabelType from '../components/LabelType.vue' import LabelType from '../components/LabelType.vue'
import { ElMessageBox, ElMessage } from 'element-plus' import { ElMessageBox, ElMessage } from 'element-plus'
import { getLabelList, deleteLabel } from '../api' import { getLabelList, deleteLabel, deleteLabels } from '../api'
import { useMapStore } from '@/stores/map' import { useMapStore } from '@/stores/map'
import { getNameByValue, updateStatusRuleList, labelList } from '@/utils/dictionary' import { getNameByValue, updateStatusRuleList, labelList } from '@/utils/dictionary'
import { useLabelType } from '../composables/useLabelType' import { useLabelType } from '../composables/useLabelType'
...@@ -58,6 +58,7 @@ const listOptions = computed(() => { ...@@ -58,6 +58,7 @@ const listOptions = computed(() => {
{ type: 'input', prop: 'updated_operator', placeholder: '更新人', slots: 'filter-user' } { type: 'input', prop: 'updated_operator', placeholder: '更新人', slots: 'filter-user' }
], ],
columns: [ columns: [
{ type: 'selection' },
{ label: '序号', type: 'index', width: 60 }, { label: '序号', type: 'index', width: 60 },
{ label: '标签ID', prop: 'id' }, { label: '标签ID', prop: 'id' },
{ label: '标签名称', prop: 'name' }, { label: '标签名称', prop: 'name' },
...@@ -143,16 +144,35 @@ function handleSelect(id: string) { ...@@ -143,16 +144,35 @@ function handleSelect(id: string) {
appList?.refetch() appList?.refetch()
}) })
} }
let multipleSelection = $ref<Label[]>([])
function handleSelectionChange(selection: Label[]) {
multipleSelection = selection
}
const handleRemoves = async function () {
const ids = multipleSelection.map(item => item.id)
await ElMessageBox.confirm('确定要删除选中的用户数据吗?', '提示', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning'
})
await deleteLabels({ ids: JSON.stringify(ids) })
appList?.refetch(true)
ElMessage({ message: '删除成功', type: 'success' })
}
</script> </script>
<!-- import { useUserStore } from '@/stores/user'
const userStore = useUserStore() -->
<template> <template>
<AppCard> <AppCard>
<div class="label-wrap"> <div class="label-wrap">
<div class="label-left"><LabelType :active-id="listParams.type_id" @select="handleSelect"></LabelType></div> <div class="label-left"><LabelType :active-id="listParams.type_id" @select="handleSelect"></LabelType></div>
<AppList v-bind="listOptions" ref="appList" class="label-right"> <AppList v-bind="listOptions" ref="appList" class="label-right" @selection-change="handleSelectionChange">
<template #header-buttons> <template #header-buttons>
<el-button type="primary" :icon="Plus" @click="handleAdd" v-if="!userStore.status.tag_status">新建</el-button> <el-button type="primary" :icon="Plus" @click="handleAdd" v-if="!userStore.status.tag_status">新建</el-button>
<el-button type="primary" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves" v-permission="'experiment_tag_delete'"
>删除</el-button
>
</template> </template>
<template #filter-user> <template #filter-user>
<SelectUser v-model="listParams.updated_operator" placeholder="更新人" @change="handleRefresh"></SelectUser> <SelectUser v-model="listParams.updated_operator" placeholder="更新人" @change="handleRefresh"></SelectUser>
...@@ -161,23 +181,14 @@ const userStore = useUserStore() --> ...@@ -161,23 +181,14 @@ const userStore = useUserStore() -->
<template #table-x="{ row }"> <template #table-x="{ row }">
<el-button type="primary" plain @click="handleRule(row)">规则</el-button> <el-button type="primary" plain @click="handleRule(row)">规则</el-button>
<el-button type="primary" plain @click="handleView(row)">查看</el-button> <el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain @click="handleUpdate(row)" v-permission="'experiment_tag_update'" <el-button type="primary" plain @click="handleUpdate(row)" v-permission="'experiment_tag_update'">编辑</el-button>
>编辑</el-button <el-button type="primary" plain @click="handleRemove(row)" v-permission="'experiment_tag_delete'">删除</el-button>
>
<el-button type="primary" plain @click="handleRemove(row)" v-permission="'experiment_tag_delete'"
>删除</el-button
>
</template> </template>
</AppList> </AppList>
</div> </div>
</AppCard> </AppCard>
<!-- 新建/修改标签 --> <!-- 新建/修改标签 -->
<LabelFormDialog <LabelFormDialog v-model="formVisible" :data="currentRow" @update="handleRefresh" v-if="formVisible"></LabelFormDialog>
v-model="formVisible"
:data="currentRow"
@update="handleRefresh"
v-if="formVisible"
></LabelFormDialog>
<!-- 查看标签 --> <!-- 查看标签 -->
<LabelViewDialog v-model="viewVisible" :data="currentRow" v-if="viewVisible && currentRow"></LabelViewDialog> <LabelViewDialog v-model="viewVisible" :data="currentRow" v-if="viewVisible && currentRow"></LabelViewDialog>
<!-- 规则 --> <!-- 规则 -->
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论