|
@@ -16,12 +16,15 @@
|
|
<el-input v-model="querySearch" size="large" placeholder="搜索" @keydown.enter="getFilesList"
|
|
<el-input v-model="querySearch" size="large" placeholder="搜索" @keydown.enter="getFilesList"
|
|
:prefix-icon="Search" />
|
|
:prefix-icon="Search" />
|
|
</div>
|
|
</div>
|
|
|
|
+
|
|
<span @click="addFileVisible = true" class="add-file"><el-icon color="#fff">
|
|
<span @click="addFileVisible = true" class="add-file"><el-icon color="#fff">
|
|
<Plus />
|
|
<Plus />
|
|
</el-icon> <i class="text">添加文件</i></span>
|
|
</el-icon> <i class="text">添加文件</i></span>
|
|
|
|
+ <span class="add-file" style="margin-right: 10px;" @click="handleBatchEditFiles"><i class="text"
|
|
|
|
+ style="margin: 0px;">批量修改文件</i></span>
|
|
</div>
|
|
</div>
|
|
<div class="management-content-middle">
|
|
<div class="management-content-middle">
|
|
- <el-table :data="filesList" size="large">
|
|
|
|
|
|
+ <el-table :data="filesList" ref="fileTableRef" size="large">
|
|
<el-table-column type="selection" width="30" />
|
|
<el-table-column type="selection" width="30" />
|
|
<el-table-column label="#" prop="index" width="60" />
|
|
<el-table-column label="#" prop="index" width="60" />
|
|
<el-table-column prop="file_name" min-width="150" label="标题">
|
|
<el-table-column prop="file_name" min-width="150" label="标题">
|
|
@@ -39,37 +42,43 @@
|
|
<el-table-column prop="knowledge_type" label="知识类型" />
|
|
<el-table-column prop="knowledge_type" label="知识类型" />
|
|
<el-table-column prop="version" label="版本" />
|
|
<el-table-column prop="version" label="版本" />
|
|
<el-table-column prop="author" label="作者(主编)" />
|
|
<el-table-column prop="author" label="作者(主编)" />
|
|
- <el-table-column prop="year" label="年份" />
|
|
|
|
|
|
+ <el-table-column prop="year" label="年份" width="70" />
|
|
<el-table-column prop="creator" label="上传人" />
|
|
<el-table-column prop="creator" label="上传人" />
|
|
- <el-table-column prop="created_at" label="上传时间" min-width="155" />
|
|
|
|
|
|
+ <el-table-column prop="created_at" label="上传时间" width="170" />
|
|
<el-table-column prop="" label="状态" width="90">
|
|
<el-table-column prop="" label="状态" width="90">
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
- <span v-if="row.isValid">
|
|
|
|
|
|
+ <span v-if="row.status">
|
|
<i class="circle" type="success"></i>
|
|
<i class="circle" type="success"></i>
|
|
<el-text type="success">可用</el-text>
|
|
<el-text type="success">可用</el-text>
|
|
</span>
|
|
</span>
|
|
- <span v-else>
|
|
|
|
|
|
+ <!-- <span v-else>
|
|
<i class="circle" type="warning"></i>
|
|
<i class="circle" type="warning"></i>
|
|
<el-text type="warning">异常</el-text>
|
|
<el-text type="warning">异常</el-text>
|
|
|
|
+ </span> -->
|
|
|
|
+ <span v-else>
|
|
|
|
+ <i class="circle" type="danger"></i>
|
|
|
|
+ <el-text type="danger">禁用</el-text>
|
|
</span>
|
|
</span>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
<el-table-column prop="created_at" label="下载" width="70">
|
|
<el-table-column prop="created_at" label="下载" width="70">
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
- <i class="document-download-icon" @click="saveAs(row.minio_url, row.file_name)"></i>
|
|
|
|
|
|
+ <i class="document-download-icon" :disabled="row.status ? true : false"
|
|
|
|
+ @click="handleDownloadFile(row.minio_url, row.file_name, row.status)"></i>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column fixed="right" label="操作" width="120">
|
|
|
|
|
|
+ <el-table-column fixed="right" label="操作" width="150">
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
<div class="operation">
|
|
<div class="operation">
|
|
- <el-switch v-model="switchValue" />
|
|
|
|
|
|
+ <el-switch v-model="row.status" />
|
|
<!-- <el-icon size="24">
|
|
<!-- <el-icon size="24">
|
|
<Operation />
|
|
<Operation />
|
|
</el-icon>
|
|
</el-icon>
|
|
<el-icon size="24">
|
|
<el-icon size="24">
|
|
<MoreFilled />
|
|
<MoreFilled />
|
|
</el-icon> -->
|
|
</el-icon> -->
|
|
- <el-button link type="primary" @click="handleDeleteFile(row.id)">删除</el-button>
|
|
|
|
|
|
+ <el-button link type="primary" @click="handleEditFile(toRaw([row]))">修改</el-button>
|
|
|
|
+ <el-button link type="danger" @click="handleDeleteFile(row.id)">删除</el-button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
@@ -78,7 +87,7 @@
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</main>
|
|
<footer>
|
|
<footer>
|
|
- <div class="pagination" v-if="totalPage > 1">
|
|
|
|
|
|
+ <div class="pagination" v-if="totalPage > 1 || paginationData.defaultPageSize !== paginationData.currentPageSize">
|
|
<el-pagination :current-page="paginationData.currentPage" :page-sizes="paginationData.pageSizes"
|
|
<el-pagination :current-page="paginationData.currentPage" :page-sizes="paginationData.pageSizes"
|
|
:disabled="paginationData.disabled" :default-page-size="paginationData.defaultPageSize"
|
|
:disabled="paginationData.disabled" :default-page-size="paginationData.defaultPageSize"
|
|
layout="total, sizes, prev, pager, next, jumper" :total="paginationData.total" @size-change="handleSizeChange"
|
|
layout="total, sizes, prev, pager, next, jumper" :total="paginationData.total" @size-change="handleSizeChange"
|
|
@@ -86,8 +95,10 @@
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</footer>
|
|
<CreateKBFileDialog v-model="addFileVisible" :knowledgeBase="KBData" @updateFiles="getFilesList()" />
|
|
<CreateKBFileDialog v-model="addFileVisible" :knowledgeBase="KBData" @updateFiles="getFilesList()" />
|
|
- <FileViewer v-if="viewFileData.show" :fileType="viewFileData.type" :fileUrl="viewFileData.url"
|
|
|
|
- :width="viewFileData.width" @closeViewer="() => viewFileData.show = false" />
|
|
|
|
|
|
+ <FileViewer v-if="viewFileData.show" :fileType="viewFileData.type" :fileName="viewFileData.name"
|
|
|
|
+ :fileUrl="viewFileData.url" :width="viewFileData.width" @closeViewer="() => viewFileData.show = false" />
|
|
|
|
+ <EditKBFileDialog v-model="editKBFileData.show" :fileTable="editKBFileData.data"
|
|
|
|
+ @updateFiles="() => { getFilesList() }" />
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</template>
|
|
</template>
|
|
@@ -95,15 +106,15 @@
|
|
<script setup>
|
|
<script setup>
|
|
import { saveAs } from 'file-saver'
|
|
import { saveAs } from 'file-saver'
|
|
import { ElMessage } from 'element-plus'
|
|
import { ElMessage } from 'element-plus'
|
|
-import { ref, getCurrentInstance, computed, watch } from 'vue'
|
|
|
|
-import { Search } from '@element-plus/icons-vue'
|
|
|
|
|
|
+import { ref, getCurrentInstance, computed, watch, toRaw } from 'vue'
|
|
|
|
+import { Download, Search } from '@element-plus/icons-vue'
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
import axios from 'axios';
|
|
import axios from 'axios';
|
|
import { api } from '@/utils/config';
|
|
import { api } from '@/utils/config';
|
|
import { confirmDelete } from "@/utils/confirmation"
|
|
import { confirmDelete } from "@/utils/confirmation"
|
|
import CreateKBFileDialog from '@/components/CreateKBFileDialog.vue';
|
|
import CreateKBFileDialog from '@/components/CreateKBFileDialog.vue';
|
|
import FileViewer from "@/components/FileViewer/FileViewer.vue"
|
|
import FileViewer from "@/components/FileViewer/FileViewer.vue"
|
|
-
|
|
|
|
|
|
+import EditKBFileDialog from "@/components/EditKBFileDialog.vue"
|
|
const { proxy } = getCurrentInstance()
|
|
const { proxy } = getCurrentInstance()
|
|
const route = useRoute()
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
@@ -111,13 +122,18 @@ const kbId = route.params.kbId
|
|
let filesList = ref([])
|
|
let filesList = ref([])
|
|
let KBData = ref({})
|
|
let KBData = ref({})
|
|
let addFileVisible = ref(false)
|
|
let addFileVisible = ref(false)
|
|
-let switchValue = ref(true)
|
|
|
|
|
|
+
|
|
let querySearch = ref("")
|
|
let querySearch = ref("")
|
|
|
|
+let editKBFileData = ref({
|
|
|
|
+ show: false,
|
|
|
|
+ data: []
|
|
|
|
+})
|
|
let viewFileData = ref({
|
|
let viewFileData = ref({
|
|
url: "",
|
|
url: "",
|
|
|
|
+ name: "",
|
|
type: "",
|
|
type: "",
|
|
show: false,
|
|
show: false,
|
|
- width: 1000
|
|
|
|
|
|
+ width: 1000,
|
|
})
|
|
})
|
|
const paginationData = ref({
|
|
const paginationData = ref({
|
|
currentPage: 1,
|
|
currentPage: 1,
|
|
@@ -146,12 +162,30 @@ async function checkLinkValidity(index, url) {
|
|
filesList.value[index].isValid = false // 请求失败,返回 false
|
|
filesList.value[index].isValid = false // 请求失败,返回 false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+function handleBatchEditFiles() {
|
|
|
|
+ const fileTableRef = proxy.$refs['fileTableRef']
|
|
|
|
+ const selectionRows = fileTableRef.getSelectionRows()
|
|
|
|
+ if (selectionRows.length == 0) return;
|
|
|
|
+ handleEditFile(toRaw(selectionRows))
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function handleEditFile(data) {
|
|
|
|
+ editKBFileData.value.show = true;
|
|
|
|
+ editKBFileData.value.data = data;
|
|
|
|
+}
|
|
|
|
+
|
|
const handleViewFile = (url, type) => {
|
|
const handleViewFile = (url, type) => {
|
|
viewFileData.value.show = true;
|
|
viewFileData.value.show = true;
|
|
viewFileData.value.url = url;
|
|
viewFileData.value.url = url;
|
|
viewFileData.value.type = type
|
|
viewFileData.value.type = type
|
|
console.log(viewFileData.value)
|
|
console.log(viewFileData.value)
|
|
}
|
|
}
|
|
|
|
+function handleDownloadFile(file_url, file_name, status = true) {
|
|
|
|
+ if (status) {
|
|
|
|
+ saveAs(file_url, file_name)
|
|
|
|
+ }
|
|
|
|
+}
|
|
const handleCurrentChange = (page) => {
|
|
const handleCurrentChange = (page) => {
|
|
paginationData.value.currentPage = page
|
|
paginationData.value.currentPage = page
|
|
// console.log('handleCurrentChange', page)
|
|
// console.log('handleCurrentChange', page)
|
|
@@ -182,8 +216,9 @@ const getFilesList = async () => {
|
|
paginationData.value.total = data.total
|
|
paginationData.value.total = data.total
|
|
for (let i = 0; i < filesList.value.length; i++) {
|
|
for (let i = 0; i < filesList.value.length; i++) {
|
|
filesList.value[i].index = (paginationData.value.currentPage - 1) * paginationData.value.currentPageSize + i + 1
|
|
filesList.value[i].index = (paginationData.value.currentPage - 1) * paginationData.value.currentPageSize + i + 1
|
|
- filesList.value[i].isValid = true
|
|
|
|
- checkLinkValidity(i, filesList.value[i].minio_url)
|
|
|
|
|
|
+ // filesList.value[i].isValid = true
|
|
|
|
+ filesList.value[i].status = true
|
|
|
|
+ // checkLinkValidity(i, filesList.value[i].minio_url)
|
|
}
|
|
}
|
|
} catch (e) {
|
|
} catch (e) {
|
|
console.log(e)
|
|
console.log(e)
|
|
@@ -328,6 +363,11 @@ getKnowledgeBaseById()
|
|
width: 28px;
|
|
width: 28px;
|
|
height: 28px;
|
|
height: 28px;
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
|
|
+
|
|
|
|
+ &:is([disabled='false']) {
|
|
|
|
+ cursor: not-allowed;
|
|
|
|
+ opacity: 0.5;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
.list-name {
|
|
.list-name {
|
|
@@ -337,7 +377,7 @@ getKnowledgeBaseById()
|
|
|
|
|
|
.text-area,
|
|
.text-area,
|
|
.icon-area {
|
|
.icon-area {
|
|
- vertical-align: middle;
|
|
|
|
|
|
+ vertical-align: bottom;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -352,6 +392,10 @@ getKnowledgeBaseById()
|
|
&:is([type='warning']) {
|
|
&:is([type='warning']) {
|
|
background-color: #E6A23C;
|
|
background-color: #E6A23C;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ &:is([type='danger']) {
|
|
|
|
+ background-color: #F56C6C;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
.operation {
|
|
.operation {
|
|
@@ -359,6 +403,10 @@ getKnowledgeBaseById()
|
|
align-items: center;
|
|
align-items: center;
|
|
justify-content: space-evenly;
|
|
justify-content: space-evenly;
|
|
|
|
|
|
|
|
+ .el-button+.el-button {
|
|
|
|
+ margin: 0px;
|
|
|
|
+ }
|
|
|
|
+
|
|
.el-switch {
|
|
.el-switch {
|
|
&:is(.is-checked) {
|
|
&:is(.is-checked) {
|
|
.el-switch__core {
|
|
.el-switch__core {
|