|
|
|
|
@ -6,18 +6,19 @@ |
|
|
|
|
<el-form> |
|
|
|
|
<el-form-item prop="name"> |
|
|
|
|
<el-input |
|
|
|
|
v-model="queryLeftParams.name" |
|
|
|
|
placeholder="输入部门名称过滤" |
|
|
|
|
v-model="queryRightParams.title" |
|
|
|
|
placeholder="输入内容过滤" |
|
|
|
|
clearable |
|
|
|
|
size="small" |
|
|
|
|
prefix-icon="el-icon-search" |
|
|
|
|
@keyup.enter.native="getKnowledgeCateList" |
|
|
|
|
@keyup.enter.native="handleRightQuery" |
|
|
|
|
@submit.native.prevent |
|
|
|
|
> |
|
|
|
|
<template slot="append"> |
|
|
|
|
<el-button |
|
|
|
|
slot="append" |
|
|
|
|
icon="el-icon-refresh-right" |
|
|
|
|
@click="refreshKnowledgeCateList" |
|
|
|
|
@click="resetRightQuery" |
|
|
|
|
/> |
|
|
|
|
</template> |
|
|
|
|
</el-input> |
|
|
|
|
@ -27,8 +28,8 @@ |
|
|
|
|
<!-- 内置标签 --> |
|
|
|
|
<el-menu-item |
|
|
|
|
v-for="(item, index) in systemCateList" |
|
|
|
|
:key="`built-in-${index}`" |
|
|
|
|
:index="`built-in-${index}`" |
|
|
|
|
:key="item.id" |
|
|
|
|
:index="item.id" |
|
|
|
|
class="custom-item" |
|
|
|
|
> |
|
|
|
|
<div class="left"> |
|
|
|
|
@ -39,25 +40,25 @@ |
|
|
|
|
</el-menu-item> |
|
|
|
|
<!-- 自定义标签 --> |
|
|
|
|
<el-menu-item |
|
|
|
|
v-for="(dept, index) in filteredCustomDeptList" |
|
|
|
|
:key="`custom-${index}`" |
|
|
|
|
:index="`custom-${index}`" |
|
|
|
|
v-for="(item, index) in userCateList" |
|
|
|
|
:key="item.id" |
|
|
|
|
:index="item.id" |
|
|
|
|
class="custom-item" |
|
|
|
|
> |
|
|
|
|
<div class="left"> |
|
|
|
|
<i class="el-icon-collection-tag" /> |
|
|
|
|
<span>{{ dept.name }}</span> |
|
|
|
|
<span>{{ item.name }}</span> |
|
|
|
|
</div> |
|
|
|
|
<div class="right"> |
|
|
|
|
<el-button |
|
|
|
|
type="text" |
|
|
|
|
icon="el-icon-edit" |
|
|
|
|
@click.stop="handleEditTag(dept)" |
|
|
|
|
@click.stop="handleEditTag(item)" |
|
|
|
|
/> |
|
|
|
|
<el-button |
|
|
|
|
type="text" |
|
|
|
|
icon="el-icon-delete" |
|
|
|
|
@click.stop="handleDeleteTag(dept)" |
|
|
|
|
@click.stop="handleLeftDelete(item)" |
|
|
|
|
/> |
|
|
|
|
</div> |
|
|
|
|
</el-menu-item> |
|
|
|
|
@ -72,95 +73,88 @@ |
|
|
|
|
|
|
|
|
|
<!-- 右侧资源列表 --> |
|
|
|
|
<el-col :span="18"> |
|
|
|
|
<!-- 搜索区域 --> |
|
|
|
|
<el-form |
|
|
|
|
:model="queryRightParams" |
|
|
|
|
ref="queryForm" |
|
|
|
|
:inline="true" |
|
|
|
|
v-show="showSearch" |
|
|
|
|
label-width="68px" |
|
|
|
|
> |
|
|
|
|
<el-form-item label="文件名称" prop="file_name"> |
|
|
|
|
<el-input |
|
|
|
|
v-model="queryRightParams.file_name" |
|
|
|
|
placeholder="请输入文件名称" |
|
|
|
|
clearable |
|
|
|
|
style="width: 240px" |
|
|
|
|
@keyup.enter.native="handleQuery" |
|
|
|
|
/> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item> |
|
|
|
|
<el-button |
|
|
|
|
type="primary" |
|
|
|
|
icon="el-icon-search" |
|
|
|
|
@click="handleQuery" |
|
|
|
|
> |
|
|
|
|
搜索 |
|
|
|
|
</el-button> |
|
|
|
|
<el-button icon="el-icon-refresh" @click="resetQuery"> |
|
|
|
|
重置 |
|
|
|
|
</el-button> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item> |
|
|
|
|
<el-card shadow="never"> |
|
|
|
|
<div slot="header" class="clearfix"> |
|
|
|
|
<span>{{ queryRightParams.name }}</span> |
|
|
|
|
<el-button |
|
|
|
|
type="primary" |
|
|
|
|
style="float: right; padding: 3px 0" |
|
|
|
|
type="text" |
|
|
|
|
icon="el-icon-upload2" |
|
|
|
|
size="mini" |
|
|
|
|
@click="openUploadTypeDialog" |
|
|
|
|
v-if=" |
|
|
|
|
queryRightParams.is_mine != 0 && queryRightParams.is_mine != 2 |
|
|
|
|
" |
|
|
|
|
> |
|
|
|
|
上传 |
|
|
|
|
</el-button> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form> |
|
|
|
|
</div> |
|
|
|
|
<!-- 资源列表 --> |
|
|
|
|
<el-table v-loading="loading" :data="userList"> |
|
|
|
|
<el-table |
|
|
|
|
:data="list" |
|
|
|
|
height="calc(100vh - 264px)" |
|
|
|
|
:show-header="false" |
|
|
|
|
> |
|
|
|
|
<el-table-column |
|
|
|
|
label="缩略图" |
|
|
|
|
label="内容" |
|
|
|
|
prop="thumbnail_path" |
|
|
|
|
align="center" |
|
|
|
|
v-if="columns.thumbnail_path.visible" |
|
|
|
|
width="250" |
|
|
|
|
> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-image |
|
|
|
|
class="resource-thumb" |
|
|
|
|
:src=" |
|
|
|
|
scope.row.thumbnail_path || defaultthumbnail_path(scope.row.fileType) |
|
|
|
|
" |
|
|
|
|
fit="contain" |
|
|
|
|
@click="handlePreview(scope.row)" |
|
|
|
|
:src="scope.row.thumbnail_path" |
|
|
|
|
@click="handlePlay(scope.row)" |
|
|
|
|
> |
|
|
|
|
<i slot="load" :class="getFileIcon(scope.row.fileType)" /> |
|
|
|
|
<div slot="error" class="image-slot"> |
|
|
|
|
<i :class="getFileIconClass(scope.row.file_type)" /> |
|
|
|
|
</div> |
|
|
|
|
</el-image> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column |
|
|
|
|
label="文件名" |
|
|
|
|
align="center" |
|
|
|
|
prop="file_name" |
|
|
|
|
v-if="columns.file_name.visible" |
|
|
|
|
label="标题" |
|
|
|
|
prop="title" |
|
|
|
|
:show-overflow-tooltip="true" |
|
|
|
|
/> |
|
|
|
|
<!-- <el-table-column |
|
|
|
|
label="文件类型" |
|
|
|
|
align="center" |
|
|
|
|
prop="file_type" |
|
|
|
|
width="120" |
|
|
|
|
/> |
|
|
|
|
<el-table-column |
|
|
|
|
label="描述" |
|
|
|
|
align="center" |
|
|
|
|
prop="description" |
|
|
|
|
width="200" |
|
|
|
|
/> |
|
|
|
|
<el-table-column label="播放次数" align="center" prop="play_times" width="120" /> |
|
|
|
|
<el-table-column |
|
|
|
|
label="创建人" |
|
|
|
|
align="center" |
|
|
|
|
prop="username" |
|
|
|
|
width="200" |
|
|
|
|
/> --> |
|
|
|
|
<el-table-column |
|
|
|
|
label="上传时间" |
|
|
|
|
label="创建时间" |
|
|
|
|
align="center" |
|
|
|
|
prop="createTime" |
|
|
|
|
v-if="columns.createTime.visible" |
|
|
|
|
prop="create_time" |
|
|
|
|
width="200" |
|
|
|
|
> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<span>{{ parseTime(scope.row.createTime) }}上传</span> |
|
|
|
|
<span>{{ parseTime(scope.row.create_time) }}上传</span> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column |
|
|
|
|
label="文件大小" |
|
|
|
|
align="center" |
|
|
|
|
prop="fileSize" |
|
|
|
|
v-if="columns.fileSize.visible" |
|
|
|
|
prop="file_size" |
|
|
|
|
width="120" |
|
|
|
|
> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<span>{{ formatFileSize(scope.row.fileSize) }}</span> |
|
|
|
|
<span>{{ formatfile_size(scope.row.file_size) }}</span> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
<el-table-column |
|
|
|
|
@ -178,6 +172,7 @@ |
|
|
|
|
分享 |
|
|
|
|
</el-button> |
|
|
|
|
<el-button |
|
|
|
|
v-if="scope.row.is_mine == 1" |
|
|
|
|
type="text" |
|
|
|
|
icon="el-icon-edit" |
|
|
|
|
@click="handleUpdateFileName(scope.row)" |
|
|
|
|
@ -185,9 +180,10 @@ |
|
|
|
|
修改 |
|
|
|
|
</el-button> |
|
|
|
|
<el-button |
|
|
|
|
v-if="scope.row.is_mine == 1" |
|
|
|
|
type="text" |
|
|
|
|
icon="el-icon-delete" |
|
|
|
|
@click="handleDelete(scope.row)" |
|
|
|
|
@click="handleRightDelete(scope.row)" |
|
|
|
|
> |
|
|
|
|
删除 |
|
|
|
|
</el-button> |
|
|
|
|
@ -196,12 +192,13 @@ |
|
|
|
|
</el-table> |
|
|
|
|
<!-- 分页 --> |
|
|
|
|
<pagination |
|
|
|
|
v-show="total > 0" |
|
|
|
|
:total="total" |
|
|
|
|
:page.sync="queryRightParams.pageNum" |
|
|
|
|
v-show="queryRightParams.total > 0" |
|
|
|
|
:total="queryRightParams.total" |
|
|
|
|
:page.sync="queryRightParams.page" |
|
|
|
|
:limit.sync="queryRightParams.pageSize" |
|
|
|
|
@pagination="getList" |
|
|
|
|
@pagination="getKnowledgeList" |
|
|
|
|
/> |
|
|
|
|
</el-card> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
|
|
|
|
|
@ -218,9 +215,9 @@ |
|
|
|
|
ref="tagFormRef" |
|
|
|
|
label-width="80px" |
|
|
|
|
> |
|
|
|
|
<el-form-item label="标签名称" prop="label"> |
|
|
|
|
<el-form-item label="标签名称" prop="name"> |
|
|
|
|
<el-input |
|
|
|
|
v-model="tagForm.label" |
|
|
|
|
v-model="tagForm.name" |
|
|
|
|
placeholder="请输入最多8个字符" |
|
|
|
|
maxlength="8" |
|
|
|
|
show-word-limit |
|
|
|
|
@ -235,7 +232,7 @@ |
|
|
|
|
|
|
|
|
|
<!-- 修改文件名弹窗 --> |
|
|
|
|
<el-dialog |
|
|
|
|
title="修改文件名称" |
|
|
|
|
title="修改" |
|
|
|
|
:visible.sync="fileNameDialogVisible" |
|
|
|
|
width="400px" |
|
|
|
|
destroy-on-close |
|
|
|
|
@ -246,10 +243,10 @@ |
|
|
|
|
ref="fileNameFormRef" |
|
|
|
|
label-width="80px" |
|
|
|
|
> |
|
|
|
|
<el-form-item label="文件名称" prop="file_name"> |
|
|
|
|
<el-form-item label="标题" prop="title"> |
|
|
|
|
<el-input |
|
|
|
|
v-model="fileNameForm.file_name" |
|
|
|
|
placeholder="请输入文件名称" |
|
|
|
|
v-model="fileNameForm.title" |
|
|
|
|
placeholder="请输入标题" |
|
|
|
|
show-word-limit |
|
|
|
|
maxlength="8" |
|
|
|
|
/> |
|
|
|
|
@ -325,8 +322,17 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { getKnowledgeCateList, getKnowledgeList } from "@/api/knowledge"; |
|
|
|
|
|
|
|
|
|
import { |
|
|
|
|
postKnowledgeCateList, |
|
|
|
|
postKnowledgeCateCreate, |
|
|
|
|
postKnowledgeCateEdit, |
|
|
|
|
postKnowledgeCateDelete, |
|
|
|
|
postKnowledgeList, |
|
|
|
|
postKnowledgeCreate, |
|
|
|
|
postKnowledgeDetail, |
|
|
|
|
postKnowledgeEdit, |
|
|
|
|
postKnowledgeDelete, |
|
|
|
|
} from "@/api/knowledge"; |
|
|
|
|
|
|
|
|
|
import { listUser, delUser, deptTreeSelect } from "@/api/system/user"; |
|
|
|
|
import { getToken } from "@/utils/auth"; |
|
|
|
|
@ -339,49 +345,45 @@ export default { |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
// 知识库左侧-默认选中分类 |
|
|
|
|
defaultActive: "", |
|
|
|
|
queryLeftParams: { |
|
|
|
|
name: "", |
|
|
|
|
}, |
|
|
|
|
// 知识库左侧-系统分类 |
|
|
|
|
systemCateList: [], |
|
|
|
|
// 知识库左侧-用户分类 |
|
|
|
|
userCateList: [], |
|
|
|
|
queryRightParams: { |
|
|
|
|
pageNum: 1, |
|
|
|
|
pageSize: 10, |
|
|
|
|
total: 0, |
|
|
|
|
}, |
|
|
|
|
columns: { |
|
|
|
|
thumbnail_path: { label: "缩略图", visible: true }, |
|
|
|
|
file_name: { label: "文件名", visible: true }, |
|
|
|
|
createTime: { label: "上传时间", visible: true }, |
|
|
|
|
fileSize: { label: "文件大小", visible: true }, |
|
|
|
|
}, |
|
|
|
|
list: [], |
|
|
|
|
|
|
|
|
|
loading: true, |
|
|
|
|
userList: [], |
|
|
|
|
showSearch: true, |
|
|
|
|
deptFilterText: "", |
|
|
|
|
deptOptions: [], |
|
|
|
|
currentTag: "", |
|
|
|
|
// 标签弹窗 |
|
|
|
|
// 知识库左侧-自定义标签 |
|
|
|
|
tagDialogVisible: false, |
|
|
|
|
tagForm: { id: null, label: "" }, |
|
|
|
|
// 知识库左侧-自定义标签-表单数据 |
|
|
|
|
tagForm: { id: null, name: "" }, |
|
|
|
|
// 知识库左侧-自定义标签-表单验证规则 |
|
|
|
|
tagRules: { |
|
|
|
|
label: [ |
|
|
|
|
name: [ |
|
|
|
|
{ required: true, message: "标签名称不能为空", trigger: "blur" }, |
|
|
|
|
{ max: 8, message: "最多8个字符", trigger: "blur" }, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
// 文件名弹窗 |
|
|
|
|
// 知识库右侧-查询参数 |
|
|
|
|
queryRightParams: { |
|
|
|
|
title: "", |
|
|
|
|
cate_id: 0, |
|
|
|
|
is_mine: "-1", |
|
|
|
|
page: 1, |
|
|
|
|
pageSize: 10, |
|
|
|
|
total: 0, |
|
|
|
|
}, |
|
|
|
|
// 知识库右侧-列表 |
|
|
|
|
list: [], |
|
|
|
|
// 知识库右侧-文件名弹窗 |
|
|
|
|
fileNameDialogVisible: false, |
|
|
|
|
fileNameForm: { userId: undefined, file_name: "" }, |
|
|
|
|
// 知识库右侧-文件名弹窗-表单数据 |
|
|
|
|
fileNameForm: { userId: undefined, title: "" }, |
|
|
|
|
// 知识库右侧-文件名弹窗-表单验证规则 |
|
|
|
|
fileNameRules: { |
|
|
|
|
file_name: [ |
|
|
|
|
{ required: true, message: "文件名不能为空", trigger: "blur" }, |
|
|
|
|
], |
|
|
|
|
title: [{ required: true, message: "标题不能为空", trigger: "blur" }], |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
loading: true, |
|
|
|
|
userList: [], |
|
|
|
|
// ================== 上传相关 ================== |
|
|
|
|
uploadTypeDialogVisible: false, // 类型选择弹窗 |
|
|
|
|
currentFileType: "", // 当前选择的文件类型 video/pdf |
|
|
|
|
@ -392,7 +394,6 @@ export default { |
|
|
|
|
fileList: [], // 只允许一个 |
|
|
|
|
uploadProgressDialogVisible: false, |
|
|
|
|
uploadPercent: 0, |
|
|
|
|
|
|
|
|
|
// ================== 分享相关 ================== |
|
|
|
|
shareDialogVisible: false, // 分享弹窗 |
|
|
|
|
shareItem: null, // 当前分享的文件 |
|
|
|
|
@ -400,231 +401,235 @@ export default { |
|
|
|
|
recentGroups: [], // 最近群组 |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
|
filteredCustomDeptList() { |
|
|
|
|
if (!this.deptOptions) return []; |
|
|
|
|
let list = this.deptOptions[0]?.children[0]?.children || []; |
|
|
|
|
if (!this.deptFilterText) return list; |
|
|
|
|
return list.filter((item) => |
|
|
|
|
item.label.includes(this.deptFilterText.trim()) |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
created() { |
|
|
|
|
this.getKnowledgeCateList(); |
|
|
|
|
// this.getList(); |
|
|
|
|
// this.getDeptTree(); |
|
|
|
|
// this.getContactList(); |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
refreshKnowledgeCateList() { |
|
|
|
|
this.queryLeftParams.name = ""; |
|
|
|
|
this.getKnowledgeCateList(); |
|
|
|
|
// 知识库左侧-图标 |
|
|
|
|
getBuiltInIcon(idx) { |
|
|
|
|
return ["el-icon-coin", "el-icon-video-camera", "el-icon-user"][idx]; |
|
|
|
|
}, |
|
|
|
|
// 知识库左侧-分类列表 |
|
|
|
|
getKnowledgeCateList() { |
|
|
|
|
// getKnowledgeCateList().then((res) => { |
|
|
|
|
let res = { |
|
|
|
|
code: 200, |
|
|
|
|
message: "成功", |
|
|
|
|
data: { |
|
|
|
|
system_cate_list: [ |
|
|
|
|
{ id: 2, name: "产品介绍" }, |
|
|
|
|
{ id: 0, name: "公共教学视频" }, |
|
|
|
|
{ id: 1, name: "个人收藏录像" }, |
|
|
|
|
], |
|
|
|
|
user_cate_list: [], |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
this.systemCateList = res.data.system_cate_list; |
|
|
|
|
postKnowledgeCateList().then((res) => { |
|
|
|
|
this.systemCateList = res.data.system_cate_list.map((item) => ({ |
|
|
|
|
...item, |
|
|
|
|
id: item.id.toString(), |
|
|
|
|
})); |
|
|
|
|
this.defaultActive = this.systemCateList[0].id; |
|
|
|
|
this.userCateList = res.data.user_cate_list; |
|
|
|
|
// }) |
|
|
|
|
}, |
|
|
|
|
handleSelect(key) { |
|
|
|
|
console.log(key); |
|
|
|
|
// const [type, idx] = key.split("-"); |
|
|
|
|
// this.currentTag = |
|
|
|
|
// type === "built-in" |
|
|
|
|
// ? this.systemCateList[idx].id |
|
|
|
|
// : this.filteredCustomDeptList[idx]?.id; |
|
|
|
|
this.queryRightParams.deptId = this.currentTag; |
|
|
|
|
this.handleQuery(); |
|
|
|
|
}, |
|
|
|
|
getKnowledgeList() { |
|
|
|
|
// getKnowledgeList(this.queryRightParams).then((res) => { |
|
|
|
|
let res = { |
|
|
|
|
code: 200, |
|
|
|
|
message: "成功", |
|
|
|
|
data: { |
|
|
|
|
list: [ |
|
|
|
|
{ |
|
|
|
|
id: 824, |
|
|
|
|
title: "1633500241136.mp4", |
|
|
|
|
thumbnail_path_path: |
|
|
|
|
"personal-test/video/688/1779759317/1633500241136.png", |
|
|
|
|
file_path: "personal-test/video/688/1779759317/1633500241136.mp4", |
|
|
|
|
file_name: "1633500241136.mp4", |
|
|
|
|
file_type: "MP4", |
|
|
|
|
file_size: 18794616, |
|
|
|
|
true_file_size: 18796714, |
|
|
|
|
creator_id: 688, |
|
|
|
|
play_times: 0, |
|
|
|
|
is_mine: 1, |
|
|
|
|
cate_id: 152, |
|
|
|
|
description: "", |
|
|
|
|
del_flag: 0, |
|
|
|
|
create_time: "2026-05-26 09:35:14", |
|
|
|
|
update_time: "2026-05-26 09:35:14", |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
total: 1, |
|
|
|
|
is_mine: 0, |
|
|
|
|
cate_id: 152, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
this.list = res.data.list; |
|
|
|
|
this.queryRightParams.total = res.data.total; |
|
|
|
|
// }) |
|
|
|
|
}, |
|
|
|
|
getContactList() { |
|
|
|
|
listUser({ pageNum: 1, pageSize: 100 }).then((res) => { |
|
|
|
|
this.recentContacts = res.rows.map((user) => ({ |
|
|
|
|
id: user.userId, |
|
|
|
|
name: user.nickName || user.file_name, |
|
|
|
|
avatar: user.avatar || "", |
|
|
|
|
this.userCateList = res.data.user_cate_list.map((item) => ({ |
|
|
|
|
...item, |
|
|
|
|
id: item.id.toString(), |
|
|
|
|
})); |
|
|
|
|
console.log("知识库左侧分类列表", res.data); |
|
|
|
|
this.handleSelect(this.defaultActive); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
getDeptTree() { |
|
|
|
|
deptTreeSelect().then((res) => { |
|
|
|
|
this.deptOptions = res.data; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
getBuiltInIcon(idx) { |
|
|
|
|
return ["el-icon-coin", "el-icon-video-camera", "el-icon-user"][idx]; |
|
|
|
|
}, |
|
|
|
|
getFileIcon(t) { |
|
|
|
|
return t === "video" ? "el-icon-video-play" : "el-icon-document"; |
|
|
|
|
}, |
|
|
|
|
defaultthumbnail_path(t) { |
|
|
|
|
return t === "video" |
|
|
|
|
? "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg" |
|
|
|
|
: "https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3794312f7670b85636.jpeg"; |
|
|
|
|
}, |
|
|
|
|
formatFileSize(bytes) { |
|
|
|
|
if (!bytes) return "0B"; |
|
|
|
|
const u = ["B", "KB", "MB", "GB"]; |
|
|
|
|
let s = bytes, |
|
|
|
|
i = 0; |
|
|
|
|
while (s >= 1024 && i < 3) { |
|
|
|
|
s /= 1024; |
|
|
|
|
i++; |
|
|
|
|
} |
|
|
|
|
return s.toFixed(2) + u[i]; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 知识库左侧-自定义标签-新增 |
|
|
|
|
handleAddTag() { |
|
|
|
|
this.tagForm = { id: null, label: "" }; |
|
|
|
|
this.tagForm = { name: "" }; |
|
|
|
|
this.tagDialogVisible = true; |
|
|
|
|
}, |
|
|
|
|
// 知识库左侧-自定义标签-编辑 |
|
|
|
|
handleEditTag(t) { |
|
|
|
|
this.tagForm = { ...t }; |
|
|
|
|
this.tagForm = { ...t, cate_id: t.id }; |
|
|
|
|
this.tagDialogVisible = true; |
|
|
|
|
}, |
|
|
|
|
// 删除标签 |
|
|
|
|
handleDeleteTag(tag) { |
|
|
|
|
this.$modal |
|
|
|
|
.confirm( |
|
|
|
|
`是否删除该自定义标签?若删除,该标签下资源将迁移至[个人收藏录像]标签下。` |
|
|
|
|
) |
|
|
|
|
.then(() => { |
|
|
|
|
this.$modal.msgSuccess("删除成功"); |
|
|
|
|
this.getDeptTree(); |
|
|
|
|
this.migrateResource(tag.id, this.systemCateList[2].id); |
|
|
|
|
}) |
|
|
|
|
.catch(() => {}); |
|
|
|
|
}, |
|
|
|
|
// 迁移资源 |
|
|
|
|
migrateResource(oldDeptId, newDeptId) { |
|
|
|
|
this.getList(); |
|
|
|
|
}, |
|
|
|
|
// 知识库左侧-自定义标签-提交 |
|
|
|
|
submitTagForm() { |
|
|
|
|
this.$refs["tagFormRef"].validate((valid) => { |
|
|
|
|
if (valid) { |
|
|
|
|
if (this.tagForm.id) { |
|
|
|
|
postKnowledgeCateEdit(this.tagForm).then(() => { |
|
|
|
|
this.$modal.msgSuccess("修改成功"); |
|
|
|
|
this.tagDialogVisible = false; |
|
|
|
|
this.getDeptTree(); |
|
|
|
|
this.getKnowledgeCateList(); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
postKnowledgeCateCreate(this.tagForm).then(() => { |
|
|
|
|
this.$modal.msgSuccess("新增成功"); |
|
|
|
|
this.tagDialogVisible = false; |
|
|
|
|
this.getDeptTree(); |
|
|
|
|
this.getKnowledgeCateList(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
// 知识库左侧-自定义标签-取消 |
|
|
|
|
cancelTagForm() { |
|
|
|
|
this.tagDialogVisible = false; |
|
|
|
|
}, |
|
|
|
|
handleQuery() { |
|
|
|
|
this.queryRightParams.pageNum = 1; |
|
|
|
|
this.getList(); |
|
|
|
|
// 知识库右侧-查询 |
|
|
|
|
handleSelect(key) { |
|
|
|
|
console.log("handleSelect", key); |
|
|
|
|
if (key == 0 || key == 2) { |
|
|
|
|
console.log("handleSelect1", key); |
|
|
|
|
this.queryRightParams.is_mine = key; |
|
|
|
|
this.queryRightParams.cate_id = 0; |
|
|
|
|
delete this.queryRightParams.creator_id; |
|
|
|
|
} else { |
|
|
|
|
console.log("handleSelect2", key); |
|
|
|
|
this.queryRightParams.is_mine = key; |
|
|
|
|
this.queryRightParams.creator_id = key; |
|
|
|
|
delete this.queryRightParams.cate_id; |
|
|
|
|
} |
|
|
|
|
// 获取选中的菜单项名称s |
|
|
|
|
const selectedItem = this.findMenuItem(key); |
|
|
|
|
if (selectedItem) { |
|
|
|
|
this.queryRightParams.name = selectedItem.name; |
|
|
|
|
} |
|
|
|
|
this.handleRightQuery(); |
|
|
|
|
}, |
|
|
|
|
resetQuery() { |
|
|
|
|
this.resetForm("queryForm"); |
|
|
|
|
this.queryRightParams.deptId = null; |
|
|
|
|
this.currentTag = ""; |
|
|
|
|
this.handleQuery(); |
|
|
|
|
}, |
|
|
|
|
getList() { |
|
|
|
|
this.loading = true; |
|
|
|
|
listUser(this.queryRightParams).then((res) => { |
|
|
|
|
this.userList = res.rows; |
|
|
|
|
this.total = res.total; |
|
|
|
|
this.loading = false; |
|
|
|
|
}); |
|
|
|
|
// 删除资源 |
|
|
|
|
handleLeftDelete(row) { |
|
|
|
|
this.$modal |
|
|
|
|
.confirm( |
|
|
|
|
`是否删除该自定义标签?若删除,该标签下资源将迁移至[个人收藏录像]标签下。` |
|
|
|
|
) |
|
|
|
|
.then(function () { |
|
|
|
|
return postKnowledgeCateDelete({ cate_id: row.id }); |
|
|
|
|
}) |
|
|
|
|
.then(() => { |
|
|
|
|
this.getKnowledgeCateList(); |
|
|
|
|
this.$modal.msgSuccess("删除成功"); |
|
|
|
|
}) |
|
|
|
|
.catch(() => {}); |
|
|
|
|
}, |
|
|
|
|
handleShare(row) { |
|
|
|
|
this.shareItem = row; |
|
|
|
|
this.shareDialogVisible = true; |
|
|
|
|
// 查找菜单项 |
|
|
|
|
findMenuItem(key) { |
|
|
|
|
// 先在系统分类中查找 |
|
|
|
|
const systemItem = this.systemCateList.find((item) => item.id === key); |
|
|
|
|
if (systemItem) return systemItem; |
|
|
|
|
// 再在用户分类中查找 |
|
|
|
|
const userItem = this.userCateList.find((item) => item.id === key); |
|
|
|
|
if (userItem) return userItem; |
|
|
|
|
return null; |
|
|
|
|
}, |
|
|
|
|
// 知识库右侧-列表 |
|
|
|
|
handleRightQuery() { |
|
|
|
|
this.queryRightParams.page = 1; |
|
|
|
|
this.getKnowledgeList(); |
|
|
|
|
}, |
|
|
|
|
// 知识库右侧-重置查询条件 |
|
|
|
|
resetRightQuery() { |
|
|
|
|
this.resetForm("queryRightForm"); |
|
|
|
|
this.queryRightParams.deptId = null; |
|
|
|
|
this.handleRightQuery(); |
|
|
|
|
}, |
|
|
|
|
// 知识库右侧-文件图标 |
|
|
|
|
getFileIconClass(fileName) { |
|
|
|
|
if (!fileName) return "el-icon-document"; |
|
|
|
|
const suffix = fileName.split(".").pop().toLowerCase(); |
|
|
|
|
const iconMap = { |
|
|
|
|
txt: "el-icon-tickets", |
|
|
|
|
pdf: "el-icon-document-copy", |
|
|
|
|
mp3: "el-icon-headset", |
|
|
|
|
wav: "el-icon-headset", |
|
|
|
|
avi: "el-icon-video-camera", |
|
|
|
|
mp4: "el-icon-video-camera", |
|
|
|
|
wmv: "el-icon-video-camera", |
|
|
|
|
mov: "el-icon-video-camera", |
|
|
|
|
zip: "el-icon-folder-opened", |
|
|
|
|
rar: "el-icon-folder-opened", |
|
|
|
|
ppt: "el-icon-data-board", |
|
|
|
|
pps: "el-icon-data-board", |
|
|
|
|
xls: "el-icon-s-grid", |
|
|
|
|
xlsx: "el-icon-s-grid", |
|
|
|
|
doc: "el-icon-document", |
|
|
|
|
docx: "el-icon-document", |
|
|
|
|
jpg: "el-icon-picture", |
|
|
|
|
jpeg: "el-icon-picture", |
|
|
|
|
jpe: "el-icon-picture", |
|
|
|
|
bmp: "el-icon-picture", |
|
|
|
|
gif: "el-icon-picture", |
|
|
|
|
png: "el-icon-picture", |
|
|
|
|
tif: "el-icon-picture", |
|
|
|
|
tiff: "el-icon-picture", |
|
|
|
|
}; |
|
|
|
|
return iconMap[suffix] || "el-icon-document"; |
|
|
|
|
}, |
|
|
|
|
handleShareToContacts(selectedMembers) { |
|
|
|
|
if (selectedMembers && selectedMembers.length > 0) { |
|
|
|
|
const shareTarget = selectedMembers[0]; |
|
|
|
|
this.$modal.msgSuccess(`已分享给 ${shareTarget.name}`); |
|
|
|
|
console.log("分享文件:", this.shareItem, "给:", shareTarget); |
|
|
|
|
// 知识库右侧-格式化文件大小 |
|
|
|
|
formatfile_size(bytes) { |
|
|
|
|
if (!bytes) return "0B"; |
|
|
|
|
const u = ["B", "KB", "MB", "GB"]; |
|
|
|
|
let s = bytes, |
|
|
|
|
i = 0; |
|
|
|
|
while (s >= 1024 && i < 3) { |
|
|
|
|
s /= 1024; |
|
|
|
|
i++; |
|
|
|
|
} |
|
|
|
|
this.shareDialogVisible = false; |
|
|
|
|
this.shareItem = null; |
|
|
|
|
return s.toFixed(2) + u[i]; |
|
|
|
|
}, |
|
|
|
|
// 知识库右侧-列表 |
|
|
|
|
getKnowledgeList() { |
|
|
|
|
this.list = []; |
|
|
|
|
postKnowledgeList(this.queryRightParams).then((res) => { |
|
|
|
|
console.log("知识库右侧-列表", res.data.list); |
|
|
|
|
this.list = res.data.list; |
|
|
|
|
this.queryRightParams.total = Number(res.data.total); |
|
|
|
|
this.queryRightParams.is_mine = res.data.is_mine; |
|
|
|
|
console.log("知识库右侧-列表", this.queryRightParams); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
// 知识库右侧-预览 |
|
|
|
|
handlePlay(row) { |
|
|
|
|
window.open(row.file_path, "_blank"); |
|
|
|
|
}, |
|
|
|
|
handleUpdateFileName(row) { |
|
|
|
|
this.fileNameForm = { ...row }; |
|
|
|
|
this.fileNameForm = { title: row.title, knowledge_id: row.id }; |
|
|
|
|
this.fileNameDialogVisible = true; |
|
|
|
|
}, |
|
|
|
|
submitFileNameForm() { |
|
|
|
|
this.$refs.fileNameFormRef.validate((v) => { |
|
|
|
|
if (v) { |
|
|
|
|
this.$refs.fileNameFormRef.validate((valid) => { |
|
|
|
|
if (valid) { |
|
|
|
|
postKnowledgeEdit(this.fileNameForm).then(() => { |
|
|
|
|
this.$modal.msgSuccess("修改成功"); |
|
|
|
|
this.fileNameDialogVisible = false; |
|
|
|
|
this.getList(); |
|
|
|
|
this.getKnowledgeList(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
cancelFileNameForm() { |
|
|
|
|
this.fileNameDialogVisible = false; |
|
|
|
|
}, |
|
|
|
|
handleDelete(row) { |
|
|
|
|
this.$modal.confirm("确认删除?").then(() => { |
|
|
|
|
delUser(row.userId).then(() => { |
|
|
|
|
// 知识库右侧-删除 |
|
|
|
|
handleRightDelete(row) { |
|
|
|
|
this.$modal |
|
|
|
|
.confirm("确认要删除此资源?") |
|
|
|
|
.then(function () { |
|
|
|
|
return postKnowledgeDelete({ knowledge_id: row.id }); |
|
|
|
|
}) |
|
|
|
|
.then(() => { |
|
|
|
|
this.getKnowledgeList(); |
|
|
|
|
this.$modal.msgSuccess("删除成功"); |
|
|
|
|
this.getList(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
.catch(() => {}); |
|
|
|
|
}, |
|
|
|
|
handlePreview() { |
|
|
|
|
this.$modal.msg("预览功能开发中"); |
|
|
|
|
|
|
|
|
|
getContactList() { |
|
|
|
|
listUser({ page: 1, pageSize: 100 }).then((res) => { |
|
|
|
|
this.recentContacts = res.rows.map((user) => ({ |
|
|
|
|
id: user.userId, |
|
|
|
|
name: user.nickName || user.title, |
|
|
|
|
avatar: user.avatar || "", |
|
|
|
|
})); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
handleShare(row) { |
|
|
|
|
this.shareItem = row; |
|
|
|
|
this.shareDialogVisible = true; |
|
|
|
|
}, |
|
|
|
|
handleShareToContacts(selectedMembers) { |
|
|
|
|
if (selectedMembers && selectedMembers.length > 0) { |
|
|
|
|
const shareTarget = selectedMembers[0]; |
|
|
|
|
this.$modal.msgSuccess(`已分享给 ${shareTarget.name}`); |
|
|
|
|
console.log("分享文件:", this.shareItem, "给:", shareTarget); |
|
|
|
|
} |
|
|
|
|
this.shareDialogVisible = false; |
|
|
|
|
this.shareItem = null; |
|
|
|
|
}, |
|
|
|
|
// ====================== 上传核心逻辑 ====================== |
|
|
|
|
// 打开类型选择 |
|
|
|
|
openUploadTypeDialog() { |
|
|
|
|
@ -642,7 +647,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 上传前校验 |
|
|
|
|
beforeUpload(file) { |
|
|
|
|
this.uploadParams.deptId = this.currentTag || this.systemCateList[2].id; |
|
|
|
|
this.uploadParams.deptId = this.systemCateList[2].id; |
|
|
|
|
this.uploadParams.fileType = this.currentFileType; |
|
|
|
|
this.uploadProgressDialogVisible = true; |
|
|
|
|
this.uploadPercent = 0; |
|
|
|
|
@ -662,7 +667,7 @@ export default { |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.uploadProgressDialogVisible = false; |
|
|
|
|
this.$modal.msgSuccess("上传成功"); |
|
|
|
|
this.getList(); // 刷新列表 |
|
|
|
|
this.getKnowledgeList(); // 刷新列表 |
|
|
|
|
this.fileList = []; |
|
|
|
|
}, 500); |
|
|
|
|
}, |
|
|
|
|
@ -676,11 +681,7 @@ export default { |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
|
.app-container { |
|
|
|
|
padding: 20px; |
|
|
|
|
height: 100%; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 自定义项 |
|
|
|
|
.custom-item { |
|
|
|
|
display: flex; |
|
|
|
|
justify-content: space-between; |
|
|
|
|
@ -691,12 +692,16 @@ export default { |
|
|
|
|
gap: 8px; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 资源缩略图 |
|
|
|
|
.resource-thumb { |
|
|
|
|
width: 230px; |
|
|
|
|
height: 80px; |
|
|
|
|
border-radius: 4px; |
|
|
|
|
cursor: pointer; |
|
|
|
|
display: flex; |
|
|
|
|
align-items: center; |
|
|
|
|
justify-content: center; |
|
|
|
|
font-size: 20px; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
.upload-type-box { |
|
|
|
|
|