Skip to content

Commit bdc48d9

Browse files
feat: Add import document view
1 parent 3a9780d commit bdc48d9

File tree

8 files changed

+196
-22
lines changed

8 files changed

+196
-22
lines changed

ui/src/components/generate-related-dialog/index.vue

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@
4848
type="textarea"
4949
/>
5050
</el-form-item>
51-
<el-form-item v-if="apiType === 'document'" :label="$t('components.selectParagraph.title')" prop="state">
51+
<el-form-item
52+
v-if="apiType === 'document'"
53+
:label="$t('components.selectParagraph.title')"
54+
prop="state"
55+
>
5256
<el-radio-group v-model="state" class="radio-block">
5357
<el-radio value="error" size="large">{{
5458
$t('components.selectParagraph.error')
5559
}}</el-radio>
56-
<el-radio value="all" size="large">{{
57-
$t('components.selectParagraph.all')
58-
}}</el-radio>
60+
<el-radio value="all" size="large">{{ $t('components.selectParagraph.all') }}</el-radio>
5961
</el-radio-group>
6062
</el-form-item>
6163
</el-form>
@@ -147,7 +149,7 @@ const submitHandle = async (formEl: FormInstance) => {
147149
if (apiType.value === 'paragraph') {
148150
const data = {
149151
...form.value,
150-
paragraph_id_list: idList.value,
152+
paragraph_id_list: idList.value
151153
}
152154
paragraphApi.batchGenerateRelated(id, documentId, data, loading).then(() => {
153155
MsgSuccess(t('views.document.generateQuestion.successMessage'))
@@ -185,9 +187,4 @@ function getModel() {
185187
186188
defineExpose({ open })
187189
</script>
188-
<style lang="scss" scope>
189-
.update-info {
190-
background: #d6e2ff;
191-
line-height: 25px;
192-
}
193-
</style>
190+
<style lang="scss" scope></style>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,11 @@ export default {
168168
prompt1:
169169
'Content: {data}\n \n Please summarize the above and generate 5 questions based on the summary. \nAnswer requirements: \n - Please output only questions; \n - Please place each question in',
170170
prompt2: 'tag.'
171+
},
172+
feishu: {
173+
selectDocument: 'Select Document',
174+
tip1: 'Only documents and tables are supported. Documents will be segmented based on titles, and tables will be converted to Markdown format before segmentation.',
175+
tip2: 'The system does not store the original document. Before importing the document, it is recommended to standardize the document segmentation markers.',
176+
allCheck: 'Select All'
171177
}
172178
}

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
cancelGenerateQuestion: '取消生成问题',
1313
cancelVectorization: '取消向量化',
1414
cancelGenerate: '取消生成',
15-
export: '导出',
15+
export: '导出'
1616
},
1717
tip: {
1818
saveMessage: '当前的更改尚未保存,确认退出吗?',
@@ -108,7 +108,7 @@ export default {
108108
GENERATE: '生成中',
109109
SYNC: '同步中',
110110
REVOKE: '取消中',
111-
finish:'完成'
111+
finish: '完成'
112112
},
113113
enableStatus: {
114114
label: '启用状态',
@@ -149,7 +149,7 @@ export default {
149149
label: '相似度高于',
150150
placeholder: '直接返回分段内容',
151151
requiredMessage: '请输入相似度'
152-
},
152+
}
153153
},
154154
hitHandlingMethod: {
155155
optimization: '模型优化',
@@ -163,6 +163,12 @@ export default {
163163
tip3: '标签中,系统会自动关联标签中的问题;',
164164
tip4: '生成效果依赖于所选模型和提示词,用户可自行调整至最佳效果。',
165165
prompt1: `内容:{data}\n\n请总结上面的内容,并根据内容总结生成 5 个问题。\n回答要求:\n- 请只输出问题;\n- 请将每个问题放置`,
166-
prompt2: `标签中。`,
166+
prompt2: `标签中。`
167+
},
168+
feishu: {
169+
selectDocument: '选择文档',
170+
tip1: '仅支持文档和表格类型,文档会根据标题分段,表格会转为Markdown格式后再分段。',
171+
tip2: '系统不存储原始文档,导入文档前,建议规范文档的分段标识。',
172+
allCheck: '全选'
167173
}
168174
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,11 @@ export default {
164164
tip4: '生成效果取決於所選模型和提示詞,用戶可自行調整至最佳效果。',
165165
prompt1: `內容:{data}\n\n請總結上面的內容,並根據內容總結生成 5 個問題。\n回答要求:\n - 請只輸出問題;\n - 請將每個問題放置在`,
166166
prompt2: `標籤中。`,
167+
},
168+
feishu: {
169+
selectDocument: '選擇文檔',
170+
tip1: '僅支持文檔和表格類型,文檔會根據標題分段,表格會轉為Markdown格式後再分段。',
171+
tip2: '系統不存儲原始文檔,導入文檔前,建議規範文檔的分段標識。',
172+
allCheck: '全選'
167173
}
168174
}

ui/src/router/modules/dataset.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Layout from '@/layout/layout-template/DetailLayout.vue'
22
const datasetRouter = {
33
path: '/dataset',
44
name: 'dataset',
5-
meta: { title: 'views.dataset.title', permission: 'DATASET:READ' },
5+
meta: { title: 'views.dataset.title', permission: 'DATASET:READ' },
66
component: () => import('@/layout/layout-template/AppLayout.vue'),
77
redirect: '/dataset',
88
children: [
@@ -13,7 +13,7 @@ const datasetRouter = {
1313
component: () => import('@/views/dataset/index.vue')
1414
},
1515
{
16-
path: '/dataset/:type', // upload
16+
path: '/dataset/upload',
1717
name: 'UploadDocumentDataset',
1818
meta: { activeMenu: '/dataset' },
1919
component: () => import('@/views/dataset/UploadDocumentDataset.vue'),
@@ -85,7 +85,14 @@ const datasetRouter = {
8585
meta: { activeMenu: '/dataset' },
8686
component: () => import('@/views/paragraph/index.vue'),
8787
hidden: true
88-
}
88+
},
89+
{
90+
path: '/dataset/import',
91+
name: 'ImportDocumentDataset',
92+
meta: { activeMenu: '/dataset' },
93+
component: () => import('@/views/dataset/ImportDocumentDataset.vue'),
94+
hidden: true
95+
},
8996
]
9097
}
9198

ui/src/styles/app.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,3 +765,9 @@ h5 {
765765
width: 90% !important;
766766
}
767767
}
768+
769+
// 蓝色提示框
770+
.update-info {
771+
background: #d6e2ff;
772+
line-height: 25px;
773+
}
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<template>
2+
<LayoutContainer :header="$t('views.document.importDocument')" class="create-dataset">
3+
<template #backButton>
4+
<back-button @click="back"></back-button>
5+
</template>
6+
<div class="create-dataset__main flex" v-loading="loading">
7+
<div class="create-dataset__component main-calc-height">
8+
<el-scrollbar>
9+
<div class="upload-document p-24">
10+
<h4 class="title-decoration-1 mb-8">
11+
{{ $t('views.document.feishu.selectDocument') }}
12+
</h4>
13+
<el-form
14+
ref="FormRef"
15+
:model="form"
16+
:rules="rules"
17+
label-position="top"
18+
require-asterisk-position="right"
19+
>
20+
<div class="mt-16 mb-16">
21+
<el-radio-group v-model="form.fileType" class="app-radio-button-group">
22+
<el-radio-button value="txt">{{
23+
$t('views.document.fileType.txt.label')
24+
}}</el-radio-button>
25+
</el-radio-group>
26+
</div>
27+
<div class="update-info flex p-8-12 border-r-4 mb-16">
28+
<div class="mt-4">
29+
<AppIcon iconName="app-warning-colorful" style="font-size: 16px"></AppIcon>
30+
</div>
31+
<div class="ml-16 lighter">
32+
<p>{{ $t('views.document.feishu.tip1') }}</p>
33+
<p>{{ $t('views.document.feishu.tip2') }}</p>
34+
</div>
35+
</div>
36+
<div class="card-never border-r-4 mb-16">
37+
<el-checkbox
38+
v-model="allCheck"
39+
:label="$t('views.document.feishu.allCheck')"
40+
size="large"
41+
class="ml-24"
42+
/>
43+
</div>
44+
45+
<el-tree :props="props" :load="loadNode" lazy show-checkbox />
46+
</el-form>
47+
</div>
48+
</el-scrollbar>
49+
</div>
50+
</div>
51+
<div class="create-dataset__footer text-right border-t">
52+
<el-button @click="router.go(-1)">{{ $t('common.cancel') }}</el-button>
53+
54+
<el-button @click="submit" type="primary">
55+
{{ $t('views.document.buttons.import') }}
56+
</el-button>
57+
</div>
58+
</LayoutContainer>
59+
</template>
60+
<script setup lang="ts">
61+
import { ref, reactive, computed, onUnmounted } from 'vue'
62+
import { useRouter, useRoute } from 'vue-router'
63+
64+
import documentApi from '@/api/document'
65+
import { MsgConfirm, MsgSuccess } from '@/utils/message'
66+
import { t } from '@/locales'
67+
import type Node from 'element-plus/es/components/tree/src/model/node'
68+
69+
interface Tree {
70+
name: string
71+
leaf?: boolean
72+
}
73+
const router = useRouter()
74+
const route = useRoute()
75+
const {
76+
query: { id } // id为datasetID,有id的是上传文档
77+
} = route
78+
79+
const loading = ref(false)
80+
const disabled = ref(false)
81+
const allCheck = ref(false)
82+
const form = ref({
83+
fileType: 'txt',
84+
fileList: [] as any
85+
})
86+
87+
const rules = reactive({
88+
fileList: [
89+
{ required: true, message: t('views.document.upload.requiredMessage'), trigger: 'change' }
90+
]
91+
})
92+
93+
const props = {
94+
label: 'name',
95+
children: 'zones',
96+
isLeaf: 'leaf'
97+
}
98+
99+
const loadNode = (node: Node, resolve: (data: Tree[]) => void) => {
100+
if (node.level === 0) {
101+
return resolve([{ name: 'region' }])
102+
}
103+
if (node.level > 1) return resolve([])
104+
105+
setTimeout(() => {
106+
const data: Tree[] = [
107+
{
108+
name: 'leaf',
109+
leaf: true
110+
},
111+
{
112+
name: 'zone'
113+
}
114+
]
115+
116+
resolve(data)
117+
}, 500)
118+
}
119+
120+
function submit() {
121+
loading.value = true
122+
}
123+
function back() {
124+
router.go(-1)
125+
}
126+
</script>
127+
<style lang="scss" scoped>
128+
.create-dataset {
129+
&__component {
130+
width: 100%;
131+
margin: 0 auto;
132+
overflow: hidden;
133+
}
134+
&__footer {
135+
padding: 16px 24px;
136+
position: fixed;
137+
bottom: 0;
138+
left: 0;
139+
background: #ffffff;
140+
width: 100%;
141+
box-sizing: border-box;
142+
}
143+
.upload-document {
144+
width: 70%;
145+
margin: 0 auto;
146+
margin-bottom: 20px;
147+
}
148+
}
149+
</style>

ui/src/views/dataset/component/UploadComponent.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,5 @@ defineExpose({
323323
color: var(--el-color-primary-light-5);
324324
}
325325
}
326-
.update-info {
327-
background: #d6e2ff;
328-
line-height: 25px;
329-
}
326+
330327
</style>

0 commit comments

Comments
 (0)