办学质量监测教学评价系统
shenrongliang
2025-06-13 11d86cc6c26bb4f709e407acadf4805c2024e79f
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
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { NButton, NDataTable, useMessage } from "naive-ui";
import { getfragmentList } from "@/api/knowledge";
import to from "await-to-js";
import { useRouter } from "vue-router";
import { t } from "@/locales";
import { SvgIcon } from "@/components/common";
 
const router = useRouter();
 
const docId = ref<string>("");
 
onMounted(() => {
    docId.value = router.currentRoute.value.query.docId as string;
    fetchData();
});
 
const message = useMessage();
 
const goBack = () => {
    router.go(-1);
};
 
const pagination = ref({
    page: 1,
    pageSize: 10,
    showSizePicker: true,
    pageSizes: [10, 20, 30, 40],
    onChange: (page: number) => {
        pagination.value.page = page;
    },
    onUpdatePageSize: (pageSize: number) => {
        pagination.value.pageSize = pageSize;
        pagination.value.page = 1;
    },
});
 
const createColumns = () => {
    return [
        ...(false
            ? [
                    {
                        title: "ID",
                        key: "id",
                        width: 80,
                        ellipsis: true,
                    },
              ]
            : []),
        {
            title: t("knowledge.no"),
            key: "fid",
        },
 
        {
            title: t("knowledge.content"),
            key: "content",
            width: 800,
            ellipsis: {
                tooltip: {
                    contentStyle: "max-width:300px",
                },
            },
        },
    ];
};
 
const tableData = ref([]);
const fetchData = async () => {
    try {
        // 发起一个请求
        const [err, result] = await to(getfragmentList(docId.value));
        console.log("fragmenresult===", result);
        if (err) {
            message.error(err.message);
        } else {
            tableData.value = result.rows;
        }
    } catch (error) {
        console.error("Error fetching data:", error);
    }
};
 
const columns = ref(createColumns());
</script>
<template>
    <div class="flex h-full table-box" style="border-bottom-left-radius: 20px">
        <main class="flex-1 overflow-hidden h-full annex-main p-4">
            <div class="annex-header">
                <n-button @click="goBack" class="back-button">
                    <svg-icon icon="mage:arrow-left" class="back-icon"></svg-icon>
                    返回
                </n-button>
            </div>
            <n-data-table
                :columns="columns"
                :data="tableData"
                :pagination="pagination"
                :theme-overrides="{
                    thPaddingMedium: '12px 16px',
                    tdPaddingMedium: '12px 16px',
                    thTextColor: 'var(--n-text-color)',
                    tdColor: 'var(--n-color)',
                    borderColor: 'var(--n-border-color)',
                }"
                class="rounded-lg shadow-sm"
                :scroll-x="1200"
            />
        </main>
    </div>
</template>
 
<style scoped>
.annex-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding: 8px 0;
}
.back-button {
    display: flex;
    align-items: center;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
}
 
.back-icon {
    margin-right: 4px;
    font-size: 1rem;
}
</style>