|
@@ -11,7 +11,7 @@
|
|
|
:active="true"
|
|
|
/>文档列表
|
|
|
</div>
|
|
|
- <div class="bm-main-box mt-[1.25rem]">
|
|
|
+ <div class="bm-main-box mt-[1.25rem]" v-if="state.knowledge.ID">
|
|
|
<div class="flex gap-[1rem]">
|
|
|
<CzrButton
|
|
|
:type="state.uploadType == UploadTypeEnum.Text ? 'primary' : 'normal'"
|
|
@@ -194,7 +194,7 @@
|
|
|
>
|
|
|
<div class="flex-1"></div>
|
|
|
<div>
|
|
|
- <CzrButton type="normal" title="预览块" />
|
|
|
+ <CzrButton type="normal" title="预览块" @click="onTextView" />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="mt-[1.5rem] flex justify-end gap-[var(--czr-gap)]">
|
|
@@ -203,7 +203,7 @@
|
|
|
title="返回上一步"
|
|
|
icon="czr_arrow"
|
|
|
:rotate="180"
|
|
|
- @click="() => (state.step = 1)"
|
|
|
+ @click="() => ((state.step = 1), (state.query.init = false))"
|
|
|
/>
|
|
|
<CzrButton
|
|
|
type="primary"
|
|
@@ -217,46 +217,67 @@
|
|
|
<div
|
|
|
class="flex flex-1 flex-col overflow-hidden rounded-[0.25rem] bg-[var(--czr-default-color)] p-[1rem]"
|
|
|
>
|
|
|
- <div>
|
|
|
+ <div class="flex items-center">
|
|
|
<CzrFormColumn
|
|
|
+ class="__czr-table-form-column"
|
|
|
:span="12"
|
|
|
label-width="0px"
|
|
|
v-model:param="state.previewFile"
|
|
|
link="select"
|
|
|
:options="state.uploadFileList"
|
|
|
labelKey="name"
|
|
|
- valueKey="name"
|
|
|
+ valueKey="url"
|
|
|
+ :clearable="false"
|
|
|
+ @change="() => $nextTick(() => onTextView())"
|
|
|
/>
|
|
|
+ <div class="ml-2" v-if="state.query.init">
|
|
|
+ <a-tag color="green"
|
|
|
+ >{{ state.query.result.data.length }} 预估块</a-tag
|
|
|
+ >
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <div class="flex flex-1 flex-col gap-[1rem] overflow-y-auto">
|
|
|
- <template v-for="(item, index) in state.query.result.data">
|
|
|
- <div>
|
|
|
- <div class="text-[1rem] font-bold text-[#576275]">
|
|
|
- Chunk-{{ index + 1 }} . 195 charact
|
|
|
- </div>
|
|
|
- <div
|
|
|
- class="mt-[0.25rem] text-[0.88rem] text-[#6F7889]"
|
|
|
- style="line-height: 1.25rem"
|
|
|
- >
|
|
|
- 啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
|
|
|
+ <div
|
|
|
+ class="mt-2 flex flex-1 flex-col gap-[1rem] overflow-y-auto"
|
|
|
+ v-loading="state.query.loading"
|
|
|
+ >
|
|
|
+ <template v-if="state.query.init">
|
|
|
+ <template v-for="(item, index) in state.query.result.data">
|
|
|
+ <div>
|
|
|
+ <div class="text-[1rem] font-bold text-[#576275]">
|
|
|
+ Chunk-{{ index + 1 }} .
|
|
|
+ {{ item.content.length }} charact
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class="mt-[0.25rem] text-[0.88rem] text-[#6F7889]"
|
|
|
+ style="line-height: 1.25rem"
|
|
|
+ >
|
|
|
+ {{ item.content }}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <div
|
|
|
+ class="flex flex-1 items-center justify-center text-gray-400"
|
|
|
+ >
|
|
|
+ 点击左侧的“预览块”按钮来加载预览
|
|
|
</div>
|
|
|
</template>
|
|
|
</div>
|
|
|
- <div class="mt-[1rem]">
|
|
|
- <el-pagination
|
|
|
- ref="ref_tablePage"
|
|
|
- class="__czr-pagination"
|
|
|
- :current-page="state.query.page.pageNum"
|
|
|
- :page-size="state.query.page.pageSize"
|
|
|
- background
|
|
|
- :page-sizes="[20]"
|
|
|
- layout="total,prev,pager,next"
|
|
|
- :total="Number(state.query.result.total)"
|
|
|
- @current-change="onPage"
|
|
|
- :pager-count="5"
|
|
|
- />
|
|
|
- </div>
|
|
|
+ <!-- <div class="mt-[1rem]">-->
|
|
|
+ <!-- <el-pagination-->
|
|
|
+ <!-- ref="ref_tablePage"-->
|
|
|
+ <!-- class="__czr-pagination"-->
|
|
|
+ <!-- :current-page="state.query.page.pageNum"-->
|
|
|
+ <!-- :page-size="state.query.page.pageSize"-->
|
|
|
+ <!-- background-->
|
|
|
+ <!-- :page-sizes="[20]"-->
|
|
|
+ <!-- layout="total,prev,pager,next"-->
|
|
|
+ <!-- :total="Number(state.query.result.total)"-->
|
|
|
+ <!-- @current-change="onTextPage"-->
|
|
|
+ <!-- :pager-count="5"-->
|
|
|
+ <!-- />-->
|
|
|
+ <!-- </div>-->
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -394,10 +415,12 @@ import {
|
|
|
} from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
-// import { axUpload } from '@/api/modules/global/upload'
|
|
|
import { v4 } from 'uuid'
|
|
|
import { useDialogStore } from '@/stores'
|
|
|
import { comTime } from '@/utils/czr-util'
|
|
|
+import { fileUploadFile } from '@/api/modules/global/upload'
|
|
|
+import { datasetsDetail } from '@/api/modules/knowledge'
|
|
|
+import { datasetsDocumentsDealView } from '@/api/modules/knowledge/document'
|
|
|
|
|
|
const DialogStore = useDialogStore()
|
|
|
const route = useRoute()
|
|
@@ -411,19 +434,21 @@ enum UploadTypeEnum {
|
|
|
}
|
|
|
const state: any = reactive({
|
|
|
ID: route.params.id,
|
|
|
+ knowledge: {},
|
|
|
uploadType: UploadTypeEnum.Text,
|
|
|
step: 1,
|
|
|
uploadFiles: new Map(),
|
|
|
uploadFileList: [],
|
|
|
previewFile: '',
|
|
|
query: {
|
|
|
+ init: false,
|
|
|
loading: false,
|
|
|
- page: {
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 20,
|
|
|
- },
|
|
|
+ // page: {
|
|
|
+ // pageNum: 1,
|
|
|
+ // pageSize: 20,
|
|
|
+ // },
|
|
|
result: {
|
|
|
- total: 0,
|
|
|
+ // total: 0,
|
|
|
data: [],
|
|
|
},
|
|
|
},
|
|
@@ -500,6 +525,14 @@ const AcceptType = {
|
|
|
}
|
|
|
const initDetail = () => {
|
|
|
if (state.ID) {
|
|
|
+ datasetsDetail(state.ID)
|
|
|
+ .then(({ data }: any) => {
|
|
|
+ state.knowledge = {
|
|
|
+ ...data,
|
|
|
+ ID: data.id,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
} else {
|
|
|
router.push({ name: '4342bfff-1ea8-4f4c-b562-3cdc1fde116f' })
|
|
|
}
|
|
@@ -530,6 +563,7 @@ const handleBeforeUpload = (file) => {
|
|
|
}
|
|
|
state.uploadFiles.set(file.uid, {
|
|
|
name: file.name,
|
|
|
+ url: '',
|
|
|
success: false,
|
|
|
process: 0,
|
|
|
})
|
|
@@ -540,21 +574,22 @@ const handleHttpRequest = (options) => {
|
|
|
const id = options.file.uid
|
|
|
const formData = new FormData()
|
|
|
formData.append('file', options.file)
|
|
|
- // axUpload(formData, (process) => {
|
|
|
- // if (state.uploadFiles.get(id)) {
|
|
|
- // state.uploadFiles.get(id).process = process
|
|
|
- // }
|
|
|
- // }).then((res) => {
|
|
|
- // if (state.uploadFiles.get(id)) {
|
|
|
- // state.uploadFiles.get(id).success = true
|
|
|
- // }
|
|
|
- // })
|
|
|
+ fileUploadFile(formData, (process) => {
|
|
|
+ if (state.uploadFiles.get(id)) {
|
|
|
+ state.uploadFiles.get(id).process = process
|
|
|
+ }
|
|
|
+ }).then(({ data }: any) => {
|
|
|
+ if (state.uploadFiles.get(id)) {
|
|
|
+ state.uploadFiles.get(id).success = true
|
|
|
+ state.uploadFiles.get(id).url = data.path
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
const onNextOne = () => {
|
|
|
state.uploadFileList = Array.from(state.uploadFiles.values()).filter(
|
|
|
(v: any) => v.success,
|
|
|
)
|
|
|
- // state.previewFile = state.uploadFileList[0]
|
|
|
+ state.previewFile = state.uploadFileList[0].url
|
|
|
if (state.uploadFileList.length === 0) {
|
|
|
DialogStore.confirm({
|
|
|
title: '上传确认',
|
|
@@ -574,48 +609,27 @@ const onNextOne = () => {
|
|
|
state.step = 2
|
|
|
}
|
|
|
}
|
|
|
-const onPage = (pageNum, pageSize) => {
|
|
|
- state.query.page = {
|
|
|
- pageNum: pageNum,
|
|
|
- pageSize: pageSize,
|
|
|
- }
|
|
|
- const params = {
|
|
|
- pageNum: state.query.page.pageNum,
|
|
|
- pageSize: state.query.page.pageSize,
|
|
|
- }
|
|
|
+const onTextView = () => {
|
|
|
+ state.query.init = true
|
|
|
state.query.loading = true
|
|
|
- setTimeout(() => {
|
|
|
- state.query.result.total = 100
|
|
|
- const arr: any = [{ empty: true }]
|
|
|
- for (let i = 1; i <= params.pageSize; i++) {
|
|
|
- const n = (params.pageNum - 1) * params.pageSize + i
|
|
|
- arr.push({
|
|
|
- p1: '部门知识库-部门知识库-部门知识库-' + n,
|
|
|
- p2: '王一鸣',
|
|
|
- p3: '只是一个政务服务事项办事指南',
|
|
|
- p4: n,
|
|
|
- p5: '2980k',
|
|
|
- p6: n % 4,
|
|
|
- p7: n % 2,
|
|
|
- tags: n % 2 ? '1,2,3,41,2,3,41,2,3,41,2,3,41,2,3,4' : '',
|
|
|
- })
|
|
|
- }
|
|
|
- state.query.result.data = arr
|
|
|
- state.query.loading = false
|
|
|
- }, 1000)
|
|
|
- // state.query.loading = true
|
|
|
- // listRuleLogisticsDataSubscribeInfo(params).then(res => {
|
|
|
- // if (res.code == 200) {
|
|
|
- // state.query.result.total = res.total
|
|
|
- // state.query.result.data = res.rows
|
|
|
- // state.query.loading = false
|
|
|
- // } else {
|
|
|
- // ElMessage.error(res.msg)
|
|
|
- // }
|
|
|
- // }).catch(() => {
|
|
|
- // state.query.loading = false
|
|
|
- // })
|
|
|
+ datasetsDocumentsDealView({
|
|
|
+ fileId: state.previewFile,
|
|
|
+ contentConfig: {
|
|
|
+ maxParentSize: 500,
|
|
|
+ overlapSize: 20,
|
|
|
+ parentSeparator: '\n\n',
|
|
|
+ splitType: 'CustomSymbolSplitter',
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .then(({ data }: any) => {
|
|
|
+ state.query.result.data = data.contentResult
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
+ .finally(() => {
|
|
|
+ state.query.loading = false
|
|
|
+ })
|
|
|
}
|
|
|
+
|
|
|
watch(
|
|
|
() => state.step,
|
|
|
(n) => {
|
|
@@ -630,7 +644,6 @@ watch(
|
|
|
const initTask = () => {}
|
|
|
onMounted(() => {
|
|
|
initDetail()
|
|
|
- onPage(1, 10)
|
|
|
})
|
|
|
</script>
|
|
|
|