Skip to content

Commit f595fd6

Browse files
feat: Batch transfer tool
1 parent e5a6580 commit f595fd6

File tree

8 files changed

+84
-42
lines changed

8 files changed

+84
-42
lines changed

ui/src/api/tool/tool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ const delMulTool: (data: any, loading?: Ref<boolean>) => Promise<Result<boolean>
312312
data,
313313
loading,
314314
) => {
315-
return put(`${prefix.value}/tool/batch_delete`, { id_list: data }, undefined, loading)
315+
return put(`${prefix.value}/batch_delete`, { id_list: data }, undefined, loading)
316316
}
317317
/**
318318
* 批量删除工具
@@ -326,7 +326,7 @@ const putMulMoveTool: (data: any, loading?: Ref<boolean>) => Promise<Result<bool
326326
data,
327327
loading,
328328
) => {
329-
return put(`${prefix.value}/tool/batch_move`, data, undefined, loading)
329+
return put(`${prefix.value}/batch_move`, data, undefined, loading)
330330
}
331331
export default {
332332
getToolList,

ui/src/components/folder-breadcrumb/index.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<template v-if="breadcrumbData?.length > 3">
77
<el-breadcrumb-item>
88
<el-button link @click="handleClick(breadcrumbData[0])" :title="breadcrumbData[0].name">
9-
<span class="ellipsis"> {{ breadcrumbData[0].name }}</span>
9+
<span class="ellipsis" style="max-width: 60px"> {{ breadcrumbData[0].name }}</span>
1010
</el-button>
1111
</el-breadcrumb-item>
1212
<el-breadcrumb-item>
@@ -15,19 +15,27 @@
1515
</el-button>
1616
</el-breadcrumb-item>
1717
<el-breadcrumb-item>
18-
<h5 class="ml-4 ellipsis" :title="breadcrumbData[breadcrumbData.length - 1].name">
18+
<h5
19+
class="ml-4 ellipsis"
20+
:title="breadcrumbData[breadcrumbData.length - 1].name"
21+
>
1922
{{ breadcrumbData[breadcrumbData.length - 1].name }}
2023
</h5>
2124
</el-breadcrumb-item>
2225
</template>
2326
<template v-else>
2427
<el-breadcrumb-item v-for="(item, index) in breadcrumbData" :key="index">
25-
<h5 class="ml-4 ellipsis" v-if="index === breadcrumbData.length - 1" :title="item.name">
28+
<h5
29+
class="ml-4 ellipsis"
30+
style="max-width: 100px"
31+
v-if="index === breadcrumbData.length - 1"
32+
:title="item.name"
33+
>
2634
{{ item.name }}
2735
</h5>
2836

2937
<el-button v-else link @click="handleClick(item)" :title="item.name">
30-
<span class="ellipsis"> {{ item.name }}</span>
38+
<span class="ellipsis" style="max-width: 60px"> {{ item.name }}</span>
3139
</el-button>
3240
</el-breadcrumb-item>
3341
</template>
@@ -39,7 +47,7 @@ import { computed } from 'vue'
3947
import { TreeToFlatten } from '@/utils/array'
4048
defineOptions({ name: 'FolderBreadcrumb' })
4149
import useStore from '@/stores'
42-
import {i18n_name} from "@/utils/common.ts";
50+
import { i18n_name } from '@/utils/common.ts'
4351
const { folder, user } = useStore()
4452
4553
const props = defineProps({

ui/src/components/layout-container/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="layout-container flex h-full">
2+
<div class="layout-container flex h-full" :class="isCollapse ? 'layout-container__collapse' : ''">
33
<div
44
:class="`layout-container__left border-r ${isCollapse ? 'hidden' : ''}`"
55
:style="{ width: isCollapse ? 0 : `${leftWidth}px` }"
@@ -150,5 +150,10 @@ onUnmounted(() => {
150150
flex: 1;
151151
overflow: hidden;
152152
}
153+
&__collapse {
154+
:deep(.mul-operation) {
155+
width: 100% !important;
156+
}
157+
}
153158
}
154159
</style>

ui/src/locales/lang/en-US/views/tool.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default {
6565
},
6666
delete: {
6767
confirmTitle: 'Confirm deletion of tool:',
68+
confirmTitle2: 'tools?',
6869
confirmMessage:
6970
'Deleting this tool will cause errors in agent that reference it when they are queried. Please proceed with caution.',
7071
resourceCountMessage:

ui/src/locales/lang/zh-CN/views/tool.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export default {
6262

6363
delete: {
6464
confirmTitle: '是否刪除工具',
65+
confirmTitle2: '个工具?',
6566
confirmMessage: '删除后,引用了该工具的智能体提问时会报错 ,请谨慎操作。',
6667
resourceCountMessage: '此工具关联 {count} 个资源,删除后无法使用,请谨慎操作。',
6768
},

ui/src/locales/lang/zh-Hant/views/tool.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export default {
6464
},
6565
delete: {
6666
confirmTitle: '是否刪除工具',
67+
confirmTitle2: '个工具?',
6768
confirmMessage: '刪除後,引用該工具的智能體在查詢時會報錯,請謹慎操作。',
6869
resourceCountMessage: '此工具關聯 {count} 個資源,刪除後無法使用,請謹慎操作。',
6970
},

ui/src/views/paragraph/index.vue

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -158,32 +158,51 @@
158158
</el-scrollbar>
159159
</div>
160160
</div>
161-
</LayoutContainer>
162-
163-
<div class="mul-operation border-t w-full flex align-center" v-if="isBatch === true">
164-
<el-button :disabled="multipleSelection.length === 0" @click="openGenerateDialog()">
165-
{{ $t('views.document.generateQuestion.title') }}
166-
</el-button>
167-
<el-button :disabled="multipleSelection.length === 0" @click="openSelectDocumentDialog()">
168-
{{ $t('views.document.setting.migration') }}
169-
</el-button>
161+
<div class="mul-operation border-t w-full" v-if="isBatch === true">
162+
<div class="flex align-center" style="max-width: 1000px; margin: auto; flex-grow: 1">
163+
<el-checkbox
164+
v-model="checkAll"
165+
:indeterminate="isIndeterminate"
166+
@change="handleCheckAllChange"
167+
>
168+
{{ $t('common.allCheck') }}
169+
</el-checkbox>
170+
<el-button
171+
class="ml-16"
172+
:disabled="multipleSelection.length === 0"
173+
@click="openGenerateDialog()"
174+
>
175+
{{ $t('views.document.generateQuestion.title') }}
176+
</el-button>
177+
<el-button
178+
:disabled="multipleSelection.length === 0"
179+
@click="openSelectDocumentDialog()"
180+
>
181+
{{ $t('views.document.setting.migration') }}
182+
</el-button>
170183

171-
<el-button :disabled="multipleSelection.length === 0" @click="deleteMulParagraph">
172-
{{ $t('common.delete') }}
173-
</el-button>
174-
<span class="color-secondary ml-24 mr-16">
175-
{{ $t('common.selected') }} {{ multipleSelection.length }}
176-
{{ $t('views.document.items') }}
177-
</span>
178-
<el-button
179-
link
180-
type="primary"
181-
v-if="multipleSelection.length > 0"
182-
@click="multipleSelection = []"
183-
>
184-
{{ $t('common.clear') }}
185-
</el-button>
186-
</div>
184+
<el-button :disabled="multipleSelection.length === 0" @click="deleteMulParagraph">
185+
{{ $t('common.delete') }}
186+
</el-button>
187+
<span class="color-secondary ml-24 mr-16">
188+
{{ $t('common.selected') }} {{ multipleSelection.length }}
189+
{{ $t('views.document.items') }}
190+
</span>
191+
<span class="color-secondary mr-16">
192+
{{ $t('common.total') }} {{ paginationConfig.total }}
193+
{{ $t('views.document.items') }}
194+
</span>
195+
<el-button
196+
link
197+
type="primary"
198+
v-if="multipleSelection.length > 0"
199+
@click="multipleSelection = []"
200+
>
201+
{{ $t('common.clear') }}
202+
</el-button>
203+
</div>
204+
</div>
205+
</LayoutContainer>
187206
</el-card>
188207
<ParagraphDialog
189208
ref="ParagraphDialogRef"
@@ -203,6 +222,7 @@
203222
<script setup lang="ts">
204223
import { reactive, ref, onMounted, computed, watch } from 'vue'
205224
import { useRoute } from 'vue-router'
225+
import type { CheckboxValueType } from 'element-plus'
206226
import ParagraphDialog from './component/ParagraphDialog.vue'
207227
import ParagraphCard from './component/ParagraphCard.vue'
208228
import SelectDocumentDialog from './component/SelectDocumentDialog.vue'
@@ -275,6 +295,17 @@ const handleClick = (e: MouseEvent, ele: any) => {
275295
// 批量操作
276296
const isBatch = ref(false)
277297
const multipleSelection = ref<any[]>([])
298+
const checkAll = ref(false)
299+
const isIndeterminate = computed(() => {
300+
return (
301+
multipleSelection.value.length > 0 &&
302+
multipleSelection.value.length < paragraphDetail.value.length
303+
)
304+
})
305+
const handleCheckAllChange = (val: CheckboxValueType) => {
306+
multipleSelection.value = val ? paragraphDetail.value.map((v) => v.id) : []
307+
checkAll.value = val as boolean
308+
}
278309
279310
function toggleSelect(id: number) {
280311
const index = multipleSelection.value.indexOf(id)
@@ -472,11 +503,6 @@ onMounted(() => {
472503
box-sizing: border-box;
473504
.mul-operation {
474505
position: absolute;
475-
bottom: 0;
476-
left: 0;
477-
padding: 16px 24px;
478-
box-sizing: border-box;
479-
background: #ffffff;
480506
}
481507
}
482508
.paragraph-card {

ui/src/views/tool/component/ToolListContainer.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,7 @@ const isBatch = ref(false)
617617
const multipleSelection = ref<any[]>([])
618618
const checkAll = ref(false)
619619
const isIndeterminate = computed(() => {
620-
return (
621-
multipleSelection.value.length > 0 && multipleSelection.value.length < tool.toolList.length
622-
)
620+
return multipleSelection.value.length > 0 && multipleSelection.value.length < tool.toolList.length
623621
})
624622
function batchSelectedHandle(bool: boolean) {
625623
isBatch.value = bool
@@ -648,7 +646,7 @@ const checkboxChange = (data?: any) => {
648646
649647
function deleteMulTool() {
650648
MsgConfirm(
651-
`${t('views.document.delete.confirmTitle1')} ${multipleSelection.value.length} ${t('views.document.delete.confirmTitle2')}`,
649+
`${t('views.document.delete.confirmTitle1')} ${multipleSelection.value.length} ${t('views.tool.delete.confirmTitle2')}`,
652650
t('views.paragraph.delete.confirmMessage'),
653651
{
654652
confirmButtonText: t('common.confirm'),
@@ -659,6 +657,7 @@ function deleteMulTool() {
659657
loadSharedApi({ type: 'tool', systemType: apiType.value })
660658
.delMulTool(multipleSelection.value, changeStateloading)
661659
.then(() => {
660+
batchSelectedHandle(false)
662661
paginationConfig.current_page = 1
663662
tool.setToolList([])
664663
getList()
@@ -762,6 +761,7 @@ function refreshToolList(row: any) {
762761
tool.setToolList(list)
763762
}
764763
} else {
764+
batchSelectedHandle(false)
765765
paginationConfig.current_page = 1
766766
tool.setToolList([])
767767
getList()

0 commit comments

Comments
 (0)