wujingjing
2024-09-06 58782051bb707118f0736bf7de533e3ec030d398
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<template>
    <div class="flex flex-col h100">
        <div class="h100" v-show="!state.showKnowledgeForm">
            <div class="mb-[10px] flex flex-shrink-0 items-center">
                <el-button style="margin-left: 8px; width: 40px" link @click="handleShowKnowledge">
                    <el-icon style="font-size: 24px !important">
                        <ArrowLeft />
                    </el-icon>
                </el-button>
                <span class="text-[24px] text-[#26244c] font-[700]">{{ state.knowledgeInfo.knowledge_title }}</span>
            </div>
            <div class="set-table-height">
                <!-- <div class="mx-0 mt-[12px] mb-[16px] flex justify-between items-center">
                    <div class="flex-col">
                        <el-input
                            v-model="knowledgeFileForm.title"
                            style="width: 230px; margin-right: 10px; background: #ffffff; border-radius: 6px; transition: all 0.2s"
                            placeholder="搜索知识库名称"
                            clearable
                        ></el-input>
                        <el-button type="primary" icon="ele-Search" @click="handleQueryTable"> 查询 </el-button>
                        <el-button icon="ele-Refresh" @click="resetQuery">重置 </el-button>
                    </div>
                </div> -->
                <div class="relative transition-[opacity 0.3s]">
                    <div class="flex flex-wrap gap-[12px] mt-4 box-border">
                        <div
                            v-for="(item, index) in displayTableData"
                            class="set_slice"
                            :key="index"
                            @mouseover="mouseOver(index)"
                            @mouseleave="mouseLeave()"
                        >
                            <!-- <div class="flex justify-between">
                                <div class="items-center font-[500] flex">{{ item.title }}</div>
                                <el-switch v-model="state.isSliceValueTime" class="ml-2" size="small" />
                            </div> -->
                            <div class="set_content" :class="state.selectSliceID == index ? 'h-[48px]' : 'h-[88px]'">{{ item }}</div>
                            <div :class="{ viewFileClassHover: state.selectSliceID == index }">
                                <el-button type="primary" link style="color: #0062be" @click="viewSliceFile(item)">{{
                                    state.selectSliceID == index ? '查看详情' : ''
                                }}</el-button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <el-dialog v-model="state.isShowSliceDetail" title="切片内容" width="50%" :before-close="handleClose">
            <el-form v-model="state.knowLedgeDetailForm" label-position="right">
                <el-form-item>
                    <el-input v-model="state.knowLedgeDetailForm" readonly type="textarea" :rows="10"></el-input>
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>
 
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { list_knowledge_file_vector } from '/@/api/knowledge/group';
import { useQueryTable } from '/@/hooks/useQueryTable';
const router = useRouter();
const route = useRoute();
// 定义变量内容
const state = reactive({
    knowledgeInfo: {
        knowledge_title: '查看文件',
        knowledge_id: '',
    } as any,
    knowLedgeDetailForm: '',
    showKnowledgeForm: false,
    knowledgeFile: {},
    isSliceValueTime: true,
    selectSliceID: null,
    isShowSliceDetail: false,
});
//返回到知识库查看页面
const handleShowKnowledge = () => {
    router.back();
};
const handleClose = () => {
    state.isShowSliceDetail = false;
};
//#region ====================== 获取切换的数据 ======================
const mouseOver = (index) => {
    state.selectSliceID = index;
};
const mouseLeave = () => {
    state.selectSliceID = null;
};
const getSliceFile = async () => {
    const res = await list_knowledge_file_vector({
        file_id: state.knowledgeInfo.knowledge_id,
    });
    if (res.json_ok) {
        sliceFileData.value = res.values;
    }
};
const viewSliceFile = (row) => {
    state.isShowSliceDetail = true;
    state.knowLedgeDetailForm = row;
};
//#endregion
//#region ====================== 搜索表格,对表格排序 ======================
const sliceFileData = ref([]);
const knowledgeFileForm = ref({
    title: '',
});
const { resetQuery, handleQueryTable, displayTableData } = useQueryTable(sliceFileData, knowledgeFileForm, () => {
    displayTableData.value = sliceFileData.value;
});
//#endregion
onMounted(() => {
    const { id } = route.query;
    state.knowledgeInfo.knowledge_id = id;
    getSliceFile();
});
</script>
<style scoped lang="scss">
.set-table-height {
    background: #fff;
    border-radius: 16px;
    height: calc(100% - 80px);
    margin-top: 12px;
    overflow-y: auto;
    padding: 20px 24px;
    box-sizing: border-box;
    .set_slice {
        border: 1px solid rgba(135, 138, 171, 0.15);
        border-radius: 16px;
        padding: 12px 20px;
        width: calc(33.33333% - 8px);
        &:hover {
            border-color: #0062be;
        }
        .viewFileClassHover {
            border-top: 1px solid hsla(0, 0%, 94%, 0.5);
            display: flex;
            justify-content: space-between;
            margin-top: 6px;
            height: 44px;
            padding-top: 4px;
            background-color: #fff;
            -webkit-line-clamp: 2;
        }
    }
    .set_content {
        color: rgba(38, 36, 76, 0.8);
        font-size: 12px;
        line-height: 22px;
        margin: 6px 0 0;
        -webkit-line-clamp: 4;
        display: -webkit-box;
        overflow: hidden;
        -webkit-box-orient: vertical;
    }
}
.set-file-height {
    height: calc(100% - 48px);
}
 
.set-form-footer {
    align-items: center;
    background: #fff;
    bottom: 0;
    box-shadow: 4px 0 5px 1px rgba(16, 9, 65, 0.06);
    display: flex;
    flex-shrink: 0;
    gap: 8px;
    height: 64px;
    padding-left: 24px;
    // position: fixed;
    width: 100%;
    left: 220px;
}
</style>