Skip to content

Commit 2e15552

Browse files
feat: folder
1 parent e02d417 commit 2e15552

File tree

14 files changed

+336
-295
lines changed

14 files changed

+336
-295
lines changed

ui/src/components/folder-tree/CreateFolderDialog.vue

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
{{ $t('common.cancel') }}
4242
</el-button>
4343
<el-button type="primary" @click="submitHandle" :loading="loading">
44-
{{ $t('common.add') }}
44+
{{ isEdit ? $t('common.confirm') : $t('common.add') }}
4545
</el-button>
4646
</span>
4747
</template>
@@ -67,6 +67,7 @@ const loading = ref(false)
6767
const dialogVisible = ref<boolean>(false)
6868
const sourceType = ref<any>('')
6969
const isEdit = ref<boolean>(false)
70+
const editId = ref<string>('')
7071
7172
const folderForm = ref<any>({
7273
name: '',
@@ -98,11 +99,16 @@ watch(dialogVisible, (bool) => {
9899
99100
const open = (source: string, id: string, data?: any) => {
100101
sourceType.value = source
101-
folderForm.value.parent_id = id
102102
if (data) {
103+
// 编辑当前id
104+
editId.value = data.id
103105
folderForm.value.name = data.name
104106
folderForm.value.desc = data.desc
107+
folderForm.value.parent_id = data.parent_id
105108
isEdit.value = true
109+
} else {
110+
// 给当前id添加子id
111+
folderForm.value.parent_id = id
106112
}
107113
dialogVisible.value = true
108114
}
@@ -111,11 +117,13 @@ const submitHandle = async () => {
111117
await FolderFormRef.value.validate((valid: any) => {
112118
if (valid) {
113119
if (isEdit.value) {
114-
folderApi.putFolder(sourceType.value, folderForm.value, loading).then((res) => {
115-
MsgSuccess(t('common.editSuccess'))
116-
emit('refresh')
117-
dialogVisible.value = false
118-
})
120+
folderApi
121+
.putFolder(editId.value, sourceType.value, folderForm.value, loading)
122+
.then((res) => {
123+
MsgSuccess(t('common.editSuccess'))
124+
emit('refresh')
125+
dialogVisible.value = false
126+
})
119127
} else {
120128
folderApi.postFolder(sourceType.value, folderForm.value, loading).then((res) => {
121129
MsgSuccess(t('common.createSuccess'))

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
highlight-current
2828
class="overflow-inherit_node__children"
2929
node-key="id"
30+
v-loading="loading"
3031
>
3132
<template #default="{ node, data }">
3233
<div class="flex-between w-full" @mouseenter.stop="handleMouseEnter(data)">
@@ -36,6 +37,7 @@
3637
</div>
3738

3839
<div
40+
v-if="canOperation"
3941
@click.stop
4042
v-show="hoverNodeId === data.id"
4143
@mouseenter.stop="handleMouseEnter(data)"
@@ -103,6 +105,10 @@ const props = defineProps({
103105
type: String,
104106
default: 'views.system.share_knowledge',
105107
},
108+
canOperation: {
109+
type: Boolean,
110+
default: true,
111+
},
106112
})
107113
interface Tree {
108114
name: string
@@ -122,11 +128,12 @@ const treeRef = ref<TreeInstance>()
122128
const filterText = ref('')
123129
const hoverNodeId = ref<string | undefined>('')
124130
const title = ref('')
131+
const loading = ref(false)
125132
126133
watch(filterText, (val) => {
127134
treeRef.value!.filter(val)
128135
})
129-
let time
136+
let time: any
130137
131138
function handleMouseEnter(data: Tree) {
132139
clearTimeout(time)
@@ -153,7 +160,7 @@ const handleSharedNodeClick = () => {
153160
}
154161
155162
function deleteFolder(row: Tree) {
156-
folderApi.delFolder(row.id as string, props.source).then(() => {
163+
folderApi.delFolder(row.id as string, props.source, loading).then(() => {
157164
emit('refreshTree')
158165
})
159166
}

ui/src/components/infinite-scroll/index.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<div v-infinite-scroll="loadData" :infinite-scroll-disabled="disabledScroll">
33
<slot />
44
</div>
5-
<div style="padding: 16px 10px">
6-
<el-divider v-if="size > 0 && loading">
5+
<div style="padding: 0 10px 16px">
6+
<el-divider v-if="size > 0 && loading" style="background: none">
77
<el-text type="info"> {{ $t('components.loading') }}...</el-text>
88
</el-divider>
9-
<el-divider v-if="noMore">
9+
<el-divider v-if="noMore" style="background: none !important">
1010
<el-text type="info"> {{ $t('components.noMore') }}</el-text>
1111
</el-divider>
1212
</div>
@@ -21,27 +21,27 @@ const props = defineProps({
2121
*/
2222
size: {
2323
type: Number,
24-
default: 0
24+
default: 0,
2525
},
2626
/**
2727
* 总数
2828
*/
2929
total: {
3030
type: Number,
31-
default: 0
31+
default: 0,
3232
},
3333
/**
3434
* 总数
3535
*/
3636
page_size: {
3737
type: Number,
38-
default: 0
38+
default: 0,
3939
},
4040
current_page: {
4141
type: Number,
42-
default: 0
42+
default: 0,
4343
},
44-
loading: Boolean
44+
loading: Boolean,
4545
})
4646
4747
const emit = defineEmits(['update:current_page', 'load'])
@@ -53,12 +53,12 @@ watch(
5353
if (val === 1) {
5454
current.value = 1
5555
}
56-
}
56+
},
5757
)
5858
5959
const noMore = computed(
6060
() =>
61-
props.size > 0 && props.size === props.total && props.total > props.page_size && !props.loading
61+
props.size > 0 && props.size === props.total && props.total > props.page_size && !props.loading,
6262
)
6363
const disabledScroll = computed(() => props.size > 0 && (props.loading || noMore.value))
6464

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
<slot name="search"> </slot>
1212
</div>
1313
</div>
14-
15-
<div class="content-container__main p-16">
16-
<slot></slot>
17-
</div>
14+
<el-scrollbar>
15+
<div class="content-container__main p-16">
16+
<slot></slot>
17+
</div>
18+
</el-scrollbar>
1819
</div>
1920
</template>
2021

ui/src/styles/element-plus.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,7 @@
241241
.el-form--label-top .el-form-item .el-form-item__label {
242242
padding-right: 0;
243243
}
244+
245+
.el-divider__text {
246+
background: var(--app-layout-bg-color);
247+
}

ui/src/views/application/component/AddKnowledgeDialog.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
@handleNodeClick="folderClickHandel"
4444
class="p-8"
4545
v-loading="folderLoading"
46+
:canOperation="false"
4647
/>
4748
</template>
4849
<el-scrollbar>

ui/src/views/application/index.vue

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
:data="folderList"
88
:currentNodeKey="currentFolder?.id"
99
@handleNodeClick="folderClickHandel"
10+
@refreshTree="refreshFolder"
1011
class="p-8"
1112
/>
1213
</template>
@@ -129,7 +130,10 @@
129130
</el-dropdown>
130131
</div>
131132
</template>
132-
<div v-loading.fullscreen.lock="paginationConfig.current_page === 1 && loading">
133+
<div
134+
v-loading.fullscreen.lock="paginationConfig.current_page === 1 && loading"
135+
style="max-height: calc(100vh - 140px)"
136+
>
133137
<InfiniteScroll
134138
:size="applicationList.length"
135139
:total="paginationConfig.total"
@@ -367,21 +371,6 @@ function getList() {
367371
})
368372
}
369373
370-
function getFolder() {
371-
const params = {}
372-
folder.asyncGetFolder(FolderSource.APPLICATION, params, loading).then((res: any) => {
373-
folderList.value = res.data
374-
currentFolder.value = res.data?.[0] || {}
375-
getList()
376-
})
377-
}
378-
379-
function folderClickHandel(row: any) {
380-
currentFolder.value = row
381-
applicationList.value = []
382-
getList()
383-
}
384-
385374
function clickFolder(item: any) {
386375
currentFolder.value.id = item.id
387376
applicationList.value = []
@@ -482,15 +471,6 @@ const exportApplication = (application: any) => {
482471
})
483472
}
484473
485-
const CreateFolderDialogRef = ref()
486-
function openCreateFolder() {
487-
CreateFolderDialogRef.value.open(FolderSource.APPLICATION, currentFolder.value.parent_id)
488-
}
489-
function refreshFolder() {
490-
applicationList.value = []
491-
getFolder()
492-
getList()
493-
}
494474
const elUploadRef = ref()
495475
const importApplication = (file: any) => {
496476
const formData = new FormData()
@@ -515,8 +495,34 @@ const importApplication = (file: any) => {
515495
})
516496
}
517497
518-
onMounted(() => {
498+
// 文件夹相关
499+
const CreateFolderDialogRef = ref()
500+
function openCreateFolder() {
501+
CreateFolderDialogRef.value.open(FolderSource.APPLICATION, currentFolder.value.id)
502+
}
503+
504+
function getFolder(bool?: boolean) {
505+
const params = {}
506+
folder.asyncGetFolder(FolderSource.APPLICATION, params, loading).then((res: any) => {
507+
folderList.value = res.data
508+
if (bool) {
509+
// 初始化刷新
510+
currentFolder.value = res.data?.[0] || {}
511+
}
512+
getList()
513+
})
514+
}
515+
function folderClickHandel(row: any) {
516+
currentFolder.value = row
517+
applicationList.value = []
518+
getList()
519+
}
520+
function refreshFolder() {
521+
applicationList.value = []
519522
getFolder()
523+
}
524+
onMounted(() => {
525+
getFolder(true)
520526
})
521527
</script>
522528

ui/src/views/chat-log/component/ChatRecordDrawer.vue

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ const props = withDefaults(
6161
6262
next_disable: boolean
6363
}>(),
64-
{}
64+
{},
6565
)
6666
6767
const emit = defineEmits(['update:chatId', 'update:currentAbstract', 'refresh'])
6868
6969
const route = useRoute()
7070
const {
71-
params: { id }
71+
params: { id },
7272
} = route
7373
const loading = ref(false)
7474
const visible = ref(false)
@@ -77,7 +77,7 @@ const recordList = ref<chatType[]>([])
7777
const paginationConfig = reactive({
7878
current_page: 1,
7979
page_size: 20,
80-
total: 0
80+
total: 0,
8181
})
8282
8383
function closeHandle() {
@@ -93,7 +93,7 @@ function getChatRecord() {
9393
paginationConfig.total = res.data.total
9494
const list = res.data.records
9595
recordList.value = [...list, ...recordList.value].sort((a, b) =>
96-
a.create_time.localeCompare(b.create_time)
96+
a.create_time.localeCompare(b.create_time),
9797
)
9898
if (paginationConfig.current_page === 1) {
9999
nextTick(() => {
@@ -113,7 +113,7 @@ watch(
113113
if (props.chatId) {
114114
getChatRecord()
115115
}
116-
}
116+
},
117117
)
118118
119119
watch(visible, (bool) => {
@@ -143,7 +143,7 @@ const open = () => {
143143
}
144144
145145
defineExpose({
146-
open
146+
open,
147147
})
148148
</script>
149149
<style lang="scss">
@@ -158,9 +158,5 @@ defineExpose({
158158
background: var(--app-layout-bg-color);
159159
padding: 0;
160160
}
161-
162-
:deep(.el-divider__text) {
163-
background: var(--app-layout-bg-color);
164-
}
165161
}
166162
</style>

0 commit comments

Comments
 (0)