1
1
<template >
2
- <el-tabs v-model =" activeName" class =" paragraph-tabs" @tab-click = " handleClick " >
2
+ <el-tabs v-model =" activeName" class =" paragraph-tabs" >
3
3
<template v-for =" (item , index ) in newData " :key =" index " >
4
4
<el-tab-pane :label =" item.name" :name =" index" >
5
5
<template #label >
8
8
<span class =" ml-4" >{{ item?.name }}</span >
9
9
</div >
10
10
</template >
11
- <el-scrollbar ref =" scrollRef" :key =" index" >
12
- <div class =" mb-16" >
13
- <el-text type =" info" >{{ item.content.length }} 段落</el-text >
14
- </div >
15
- <div class =" paragraph-list" v-infinite-scroll =" loadScroll" >
16
- <el-card
17
- v-for =" (child, cIndex) in scrollData"
18
- :key =" cIndex"
19
- shadow =" never"
20
- class =" card-never mb-16"
21
- >
22
- <div class =" flex-between" >
23
- <span >{{ child.title || '-' }}</span >
24
- <div >
25
- <!-- 编辑分段按钮 -->
26
- <el-button link @click =" editHandle(child, index, cIndex)" >
27
- <el-icon ><EditPen /></el-icon >
28
- </el-button >
29
- <!-- 删除分段按钮 -->
30
- <el-button link @click =" deleteHandle(child, index, cIndex)" >
31
- <el-icon ><Delete /></el-icon >
32
- </el-button >
33
- </div >
34
- </div >
35
- <div class =" lighter mt-12" >
36
- {{ child.content }}
37
- </div >
38
- <div class =" lighter mt-12" >
39
- <el-text type =" info" > {{ child.content.length }} 个字符 </el-text >
40
- </div >
41
- </el-card >
42
- </div >
43
- </el-scrollbar >
11
+ <div class =" mb-16" >
12
+ <el-text type =" info" >{{ item.content.length }} 段落</el-text >
13
+ </div >
14
+ <div class =" paragraph-list" v-if =" activeName == index" >
15
+ <el-scrollbar >
16
+ <ParagraphList v-model =" item.content" :isConnect =" isConnect" > </ParagraphList >
17
+ </el-scrollbar >
18
+ </div >
44
19
</el-tab-pane >
45
20
</template >
46
21
</el-tabs >
47
- <EditParagraphDialog
48
- ref =" EditParagraphDialogRef"
49
- @updateContent =" updateContent"
50
- :isConnect =" isConnect"
51
- />
52
22
</template >
53
23
<script setup lang="ts">
54
- import { ref , reactive , onMounted , watch , nextTick } from ' vue'
55
- import { cloneDeep } from ' lodash'
56
- import type { TabsPaneContext } from ' element-plus'
57
- import EditParagraphDialog from ' ./EditParagraphDialog.vue'
58
- import { filesize , getImgUrl } from ' @/utils/utils'
59
- import { MsgConfirm } from ' @/utils/message'
24
+ import { ref , onMounted , watch } from ' vue'
25
+ import { getImgUrl } from ' @/utils/utils'
26
+ import ParagraphList from ' ./ParagraphList.vue'
60
27
61
28
const props = defineProps ({
62
29
data: {
@@ -68,80 +35,20 @@ const props = defineProps({
68
35
69
36
const emit = defineEmits ([' update:data' ])
70
37
71
- const EditParagraphDialogRef = ref ()
72
- const scrollRef = ref ()
73
-
74
38
const activeName = ref (0 )
75
- const currentPIndex = ref (null ) as any
76
- const currentCIndex = ref (null ) as any
77
39
78
40
const newData = ref <any []>([])
79
41
80
- // 滚动加载数据
81
- const paginationConfig = reactive ({
82
- current_page: 1 ,
83
- page_size: 20
84
- })
85
-
86
- const scrollData = ref <any []>([])
87
-
88
42
watch (
89
43
() => props .data ,
90
44
(value ) => {
91
45
newData .value = value
92
- paginationConfig .current_page = 1
93
- nextTick (() => {
94
- scrollRef .value ?.[activeName .value ]?.scrollTo (0 , 0 )
95
- })
96
- scrollData .value = newData .value [activeName .value ]?.content .slice (0 , paginationConfig .page_size )
97
46
},
98
47
{
99
48
immediate: true
100
49
}
101
50
)
102
51
103
- function loadScroll() {
104
- if (newData .value [activeName .value ]?.content .length > scrollData .value .length ) {
105
- paginationConfig .current_page += 1
106
- scrollData .value .push (
107
- ... newData .value [activeName .value ].content .slice (
108
- (paginationConfig .current_page - 1 ) * paginationConfig .page_size ,
109
- paginationConfig .current_page * paginationConfig .page_size
110
- )
111
- )
112
- }
113
- }
114
-
115
- function editHandle(item : any , index : number , cIndex : number ) {
116
- currentPIndex .value = index
117
- currentCIndex .value = cIndex
118
- EditParagraphDialogRef .value .open (item )
119
- }
120
-
121
- function deleteHandle(item : any , index : number , cIndex : number ) {
122
- MsgConfirm (` 是否删除分段:${item .title || ' -' } ? ` , ` 删除后将不会存入知识库,对本地文档无影响。 ` , {
123
- confirmButtonText: ' 删除' ,
124
- confirmButtonClass: ' danger'
125
- })
126
- .then (() => {
127
- newData .value [index ].content .splice (cIndex , 1 )
128
- scrollData .value .splice (cIndex , 1 )
129
- emit (' update:data' , newData .value )
130
- })
131
- .catch (() => {})
132
- }
133
-
134
- function updateContent(data : any ) {
135
- newData .value [currentPIndex .value ].content [currentCIndex .value ] = cloneDeep (data )
136
- scrollData .value [currentCIndex .value ] = cloneDeep (data )
137
- emit (' update:data' , newData .value )
138
- }
139
-
140
- const handleClick = (tab : TabsPaneContext , event : Event ) => {
141
- paginationConfig .current_page = 1
142
- scrollData .value = newData .value [Number (tab .index )]?.content .slice (0 , paginationConfig .page_size )
143
- }
144
-
145
52
onMounted (() => {})
146
53
</script >
147
54
<style scoped lang="scss">
@@ -172,6 +79,6 @@ onMounted(() => {})
172
79
}
173
80
}
174
81
.paragraph-list {
175
- height : calc (var (--create-dataset-height ) - 131 px );
82
+ height : calc (var (--create-dataset-height ) - 101 px );
176
83
}
177
84
</style >
0 commit comments