Skip to content

Commit cebdfd6

Browse files
feat: paragraph
1 parent 003b911 commit cebdfd6

File tree

2 files changed

+93
-18
lines changed

2 files changed

+93
-18
lines changed

ui/src/views/paragraph/component/ParagraphCard.vue

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,62 @@
1212
:modelValue="data.content"
1313
class="maxkb-md"
1414
/>
15+
<el-card shadow="always" style="--el-card-padding: 8px 12px; --el-card-border-radius: 8px">
16+
<el-switch
17+
:loading="changeStateloading"
18+
v-model="data.is_active"
19+
:before-change="() => changeState(data)"
20+
size="small"
21+
/>
22+
23+
<el-divider direction="vertical" />
24+
<el-button link>
25+
<el-icon :size="16" :title="$t('views.applicationWorkflow.control.zoomOut')"
26+
><ZoomOut
27+
/></el-icon>
28+
</el-button>
29+
<el-dropdown trigger="click">
30+
<el-button text>
31+
<el-icon><MoreFilled /></el-icon>
32+
</el-button>
33+
<template #dropdown>
34+
<el-dropdown-menu>
35+
<el-dropdown-item @click="openGenerateDialog(data)">
36+
<el-icon><Connection /></el-icon>
37+
{{ $t('views.document.generateQuestion.title') }}</el-dropdown-item
38+
>
39+
<el-dropdown-item @click="openSelectDocumentDialog(data)">
40+
<AppIcon iconName="app-migrate"></AppIcon>
41+
{{ $t('views.document.setting.migration') }}</el-dropdown-item
42+
>
43+
<el-dropdown-item icon="Delete" @click.stop="deleteParagraph(data)">{{
44+
$t('common.delete')
45+
}}</el-dropdown-item>
46+
</el-dropdown-menu>
47+
</template>
48+
</el-dropdown>
49+
</el-card>
1550
</el-card>
1651
</template>
1752
<script setup lang="ts">
1853
import { ref, useSlots } from 'vue'
54+
import { useRoute } from 'vue-router'
1955
import { t } from '@/locales'
56+
import useStore from '@/stores'
57+
import GenerateRelatedDialog from '@/components/generate-related-dialog/index.vue'
58+
import { MsgSuccess, MsgConfirm } from '@/utils/message'
59+
const { paragraph } = useStore()
60+
61+
const route = useRoute()
62+
const {
63+
params: { id, documentId },
64+
} = route as any
2065
const props = defineProps<{
2166
data: any
2267
}>()
2368
69+
const SelectDocumentDialogRef = ref()
70+
const changeStateloading = ref(false)
2471
const show = ref(false)
2572
// card上面存在dropdown菜单
2673
const subHovered = ref(false)
@@ -33,8 +80,52 @@ function cardLeave() {
3380
show.value = subHovered.value
3481
}
3582
36-
function subHoveredEnter() {
37-
subHovered.value = true
83+
function changeState(row: any) {
84+
const obj = {
85+
is_active: !row.is_active,
86+
}
87+
paragraph
88+
.asyncPutParagraph(id, documentId, row.id, obj, changeStateloading)
89+
.then((res) => {
90+
// const index = paragraphDetail.value.findIndex((v) => v.id === row.id)
91+
// paragraphDetail.value[index].is_active = !paragraphDetail.value[index].is_active
92+
return true
93+
})
94+
.catch(() => {
95+
return false
96+
})
97+
}
98+
99+
const GenerateRelatedDialogRef = ref<InstanceType<typeof GenerateRelatedDialog>>()
100+
function openGenerateDialog(row: any) {
101+
if (GenerateRelatedDialogRef.value) {
102+
GenerateRelatedDialogRef.value.open([], 'dataset', row.id)
103+
}
104+
}
105+
function openSelectDocumentDialog(row?: any) {
106+
// if (row) {
107+
// multipleSelection.value = [row.id]
108+
// }
109+
// SelectDocumentDialogRef.value.open(multipleSelection.value)
110+
}
111+
112+
function deleteParagraph(row: any) {
113+
MsgConfirm(
114+
`${t('views.paragraph.delete.confirmTitle')} ${row.title || '-'} ?`,
115+
t('views.paragraph.delete.confirmMessage'),
116+
{
117+
confirmButtonText: t('common.confirm'),
118+
confirmButtonClass: 'danger',
119+
},
120+
)
121+
.then(() => {
122+
paragraph.asyncDelParagraph(id, documentId, row.id, loading).then(() => {
123+
// const index = paragraphDetail.value.findIndex((v) => v.id === row.id)
124+
// paragraphDetail.value.splice(index, 1)
125+
MsgSuccess(t('common.deleteSuccess'))
126+
})
127+
})
128+
.catch(() => {})
38129
}
39130
</script>
40131
<style lang="scss" scoped>

ui/src/views/paragraph/index.vue

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,22 +224,6 @@ function searchHandle() {
224224
getParagraphList()
225225
}
226226
227-
function changeState(row: any) {
228-
const obj = {
229-
is_active: !row.is_active,
230-
}
231-
paragraph
232-
.asyncPutParagraph(id, documentId, row.id, obj, changeStateloading)
233-
.then((res) => {
234-
const index = paragraphDetail.value.findIndex((v) => v.id === row.id)
235-
paragraphDetail.value[index].is_active = !paragraphDetail.value[index].is_active
236-
return true
237-
})
238-
.catch(() => {
239-
return false
240-
})
241-
}
242-
243227
function deleteParagraph(row: any) {
244228
MsgConfirm(
245229
`${t('views.paragraph.delete.confirmTitle')} ${row.title || '-'} ?`,

0 commit comments

Comments
 (0)