知识库-分享/上传暂时搁置

main
ysn 3 days ago
parent 9fe1f20550
commit ece3b41942
  1. 4
      src/api/contacts/index.js
  2. 118
      src/api/knowledge.js
  3. 7
      src/api/login.js
  4. 583
      src/views/knowledge/index.vue

@ -7,7 +7,7 @@ export function getMessagesLatestContacts(data) {
data data
}) })
} }
// 获取群组列表(包含用户) // 获取组织架构
export function getGroupsList(data) { export function getGroupsList(data) {
return request({ return request({
url: '/groups/list', url: '/groups/list',
@ -15,7 +15,7 @@ export function getGroupsList(data) {
data data
}) })
} }
// 获取群组列表(包含用户) // 获取组织架构下的用户列表
export function getGroupsListUser(data) { export function getGroupsListUser(data) {
return request({ return request({
url: '/groups/list-user', url: '/groups/list-user',

@ -1,40 +1,104 @@
import request from '@/utils/request' import request from '@/utils/request'
// 获取知识库左侧分类列表 // 知识库分类管理
export function getKnowledgeCateList(data) { // 知识库分类-列表
return request({ url: '/v1/knowledge/cate/list', method: 'post', data }) export function postKnowledgeCateList(data) {
return request({ url: '/knowledge/cate/list', method: 'post', data })
} }
// 获取知识库右侧列表
export function getKnowledgeList(data) {
return request({ url: '/v1/knowledge/list', method: 'post', data })
}
export function createKnowledge(data) { // 知识库分类-新增
return request({ url: '/api/v1/knowledge/create', method: 'post', data }) export function postKnowledgeCateCreate(data) {
return request({ url: '/knowledge/cate/create', method: 'post', data })
} }
// 知识库分类-编辑
export function playKnowledge(data) { export function postKnowledgeCateEdit(data) {
return request({ url: '/api/v1/knowledge/play', method: 'post', data }) return request({ url: '/knowledge/cate/edit', method: 'post', data })
} }
export function deleteKnowledge(data) { //知识库分类-删除
return request({ url: '/api/v1/knowledge/delete', method: 'post', data }) export function postKnowledgeCateDelete(data) {
return request({ url: '/knowledge/cate/delete', method: 'post', data })
} }
// 知识库文件管理
export function editKnowledge(data) { // 知识库文件-列表
return request({ url: '/api/v1/knowledge/edit', method: 'post', data }) export function postKnowledgeList(data) {
return request({ url: '/knowledge/list', method: 'post', data })
} }
// 知识库文件-新增
export function createKnowledgeCate(data) { export function postKnowledgeCreate(data) {
return request({ url: '/api/v1/knowledge/cate/create', method: 'post', data }) return request({ url: '/knowledge/create', method: 'post', data })
} }
// 知识库文件-详情
export function editKnowledgeCate(data) { export function postKnowledgeDetail(data) {
return request({ url: '/api/v1/knowledge/cate/edit', method: 'post', data }) return request({ url: '/knowledge/detail', method: 'post', data })
} }
// 知识库文件-编辑
export function deleteKnowledgeCate(data) { export function postKnowledgeEdit(data) {
return request({ url: '/api/v1/knowledge/cate/delete', method: 'post', data }) return request({ url: '/knowledge/edit', method: 'post', data })
} }
// 知识库文件-删除
export function postKnowledgeDelete(data) {
return request({ url: '/knowledge/delete', method: 'post', data })
}
// // 知识库-预览/播放文件
// export function knowledgePlay(data) {
// return request({ url: '/knowledge/play', method: 'post', data })
// }
// // 知识库-上传文件
// export function knowledgeUpload(data) {
// return request({
// url: '/knowledge/upload',
// method: 'post',
// data,
// headers: {
// 'Content-Type': 'multipart/form-data'
// }
// })
// }
// // 知识库-下载文件
// export function knowledgeDownload(data) {
// return request({
// url: '/knowledge/download',
// method: 'post',
// data,
// responseType: 'blob'
// })
// }
// // 知识库分享功能
// // 知识库-分享文件
// export function knowledgeShare(data) {
// return request({ url: '/knowledge/share', method: 'post', data })
// }
// // 知识库-分享记录列表
// export function knowledgeShareList(data) {
// return request({ url: '/knowledge/share/list', method: 'post', data })
// }
// // 知识库-取消分享
// export function knowledgeCancelShare(data) {
// return request({ url: '/knowledge/share/cancel', method: 'post', data })
// }
// // 知识库搜索功能
// // 知识库-搜索文件
// export function knowledgeSearch(data) {
// return request({ url: '/knowledge/search', method: 'post', data })
// }
// // 知识库-热门搜索
// export function knowledgeHotSearch(data) {
// return request({ url: '/knowledge/search/hot', method: 'post', data })
// }
// // 知识库统计功能
// // 知识库-统计信息
// export function knowledgeStats(data) {
// return request({ url: '/knowledge/stats', method: 'post', data })
// }
// // 知识库-分类统计
// export function knowledgeCateStats(data) {
// return request({ url: '/knowledge/cate/stats', method: 'post', data })
// }

@ -22,10 +22,11 @@ export function register(data) {
} }
// 获取用户详细信息 // 获取用户详细信息
export function getInfo() { export function getInfo(data) {
return request({ return request({
url: '/users/detail', url: '/users/info',
method: 'POST' method: 'POST',
data: data
}) })
} }

@ -6,18 +6,19 @@
<el-form> <el-form>
<el-form-item prop="name"> <el-form-item prop="name">
<el-input <el-input
v-model="queryLeftParams.name" v-model="queryRightParams.title"
placeholder="输入部门名称过滤" placeholder="输入内容过滤"
clearable clearable
size="small" size="small"
prefix-icon="el-icon-search" prefix-icon="el-icon-search"
@keyup.enter.native="getKnowledgeCateList" @keyup.enter.native="handleRightQuery"
@submit.native.prevent
> >
<template slot="append"> <template slot="append">
<el-button <el-button
slot="append" slot="append"
icon="el-icon-refresh-right" icon="el-icon-refresh-right"
@click="refreshKnowledgeCateList" @click="resetRightQuery"
/> />
</template> </template>
</el-input> </el-input>
@ -27,8 +28,8 @@
<!-- 内置标签 --> <!-- 内置标签 -->
<el-menu-item <el-menu-item
v-for="(item, index) in systemCateList" v-for="(item, index) in systemCateList"
:key="`built-in-${index}`" :key="item.id"
:index="`built-in-${index}`" :index="item.id"
class="custom-item" class="custom-item"
> >
<div class="left"> <div class="left">
@ -39,25 +40,25 @@
</el-menu-item> </el-menu-item>
<!-- 自定义标签 --> <!-- 自定义标签 -->
<el-menu-item <el-menu-item
v-for="(dept, index) in filteredCustomDeptList" v-for="(item, index) in userCateList"
:key="`custom-${index}`" :key="item.id"
:index="`custom-${index}`" :index="item.id"
class="custom-item" class="custom-item"
> >
<div class="left"> <div class="left">
<i class="el-icon-collection-tag" /> <i class="el-icon-collection-tag" />
<span>{{ dept.name }}</span> <span>{{ item.name }}</span>
</div> </div>
<div class="right"> <div class="right">
<el-button <el-button
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click.stop="handleEditTag(dept)" @click.stop="handleEditTag(item)"
/> />
<el-button <el-button
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click.stop="handleDeleteTag(dept)" @click.stop="handleLeftDelete(item)"
/> />
</div> </div>
</el-menu-item> </el-menu-item>
@ -72,95 +73,88 @@
<!-- 右侧资源列表 --> <!-- 右侧资源列表 -->
<el-col :span="18"> <el-col :span="18">
<!-- 搜索区域 --> <el-card shadow="never">
<el-form <div slot="header" class="clearfix">
:model="queryRightParams" <span>{{ queryRightParams.name }}</span>
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-button <el-button
type="primary" style="float: right; padding: 3px 0"
type="text"
icon="el-icon-upload2" icon="el-icon-upload2"
size="mini"
@click="openUploadTypeDialog" @click="openUploadTypeDialog"
v-if="
queryRightParams.is_mine != 0 && queryRightParams.is_mine != 2
"
> >
上传 上传
</el-button> </el-button>
</el-form-item> </div>
</el-form>
<!-- 资源列表 --> <!-- 资源列表 -->
<el-table v-loading="loading" :data="userList"> <el-table
:data="list"
height="calc(100vh - 264px)"
:show-header="false"
>
<el-table-column <el-table-column
label="缩略图" label="内容"
prop="thumbnail_path" prop="thumbnail_path"
align="center" align="center"
v-if="columns.thumbnail_path.visible"
width="250" width="250"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-image <el-image
class="resource-thumb" class="resource-thumb"
:src="
scope.row.thumbnail_path || defaultthumbnail_path(scope.row.fileType)
"
fit="contain" 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> </el-image>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="文件名" label="标题"
align="center" prop="title"
prop="file_name"
v-if="columns.file_name.visible"
:show-overflow-tooltip="true" :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 <el-table-column
label="上传时间" label="创建时间"
align="center" align="center"
prop="createTime" prop="create_time"
v-if="columns.createTime.visible"
width="200" width="200"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}上传</span> <span>{{ parseTime(scope.row.create_time) }}上传</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
label="文件大小" label="文件大小"
align="center" align="center"
prop="fileSize" prop="file_size"
v-if="columns.fileSize.visible"
width="120" width="120"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ formatFileSize(scope.row.fileSize) }}</span> <span>{{ formatfile_size(scope.row.file_size) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -178,6 +172,7 @@
分享 分享
</el-button> </el-button>
<el-button <el-button
v-if="scope.row.is_mine == 1"
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdateFileName(scope.row)" @click="handleUpdateFileName(scope.row)"
@ -185,9 +180,10 @@
修改 修改
</el-button> </el-button>
<el-button <el-button
v-if="scope.row.is_mine == 1"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" @click="handleRightDelete(scope.row)"
> >
删除 删除
</el-button> </el-button>
@ -196,12 +192,13 @@
</el-table> </el-table>
<!-- 分页 --> <!-- 分页 -->
<pagination <pagination
v-show="total > 0" v-show="queryRightParams.total > 0"
:total="total" :total="queryRightParams.total"
:page.sync="queryRightParams.pageNum" :page.sync="queryRightParams.page"
:limit.sync="queryRightParams.pageSize" :limit.sync="queryRightParams.pageSize"
@pagination="getList" @pagination="getKnowledgeList"
/> />
</el-card>
</el-col> </el-col>
</el-row> </el-row>
@ -218,9 +215,9 @@
ref="tagFormRef" ref="tagFormRef"
label-width="80px" label-width="80px"
> >
<el-form-item label="标签名称" prop="label"> <el-form-item label="标签名称" prop="name">
<el-input <el-input
v-model="tagForm.label" v-model="tagForm.name"
placeholder="请输入最多8个字符" placeholder="请输入最多8个字符"
maxlength="8" maxlength="8"
show-word-limit show-word-limit
@ -235,7 +232,7 @@
<!-- 修改文件名弹窗 --> <!-- 修改文件名弹窗 -->
<el-dialog <el-dialog
title="修改文件名称" title="修改"
:visible.sync="fileNameDialogVisible" :visible.sync="fileNameDialogVisible"
width="400px" width="400px"
destroy-on-close destroy-on-close
@ -246,10 +243,10 @@
ref="fileNameFormRef" ref="fileNameFormRef"
label-width="80px" label-width="80px"
> >
<el-form-item label="文件名称" prop="file_name"> <el-form-item label="标题" prop="title">
<el-input <el-input
v-model="fileNameForm.file_name" v-model="fileNameForm.title"
placeholder="请输入文件名称" placeholder="请输入标题"
show-word-limit show-word-limit
maxlength="8" maxlength="8"
/> />
@ -325,8 +322,17 @@
</template> </template>
<script> <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 { listUser, delUser, deptTreeSelect } from "@/api/system/user";
import { getToken } from "@/utils/auth"; import { getToken } from "@/utils/auth";
@ -339,49 +345,45 @@ export default {
}, },
data() { data() {
return { return {
// -
defaultActive: "", defaultActive: "",
queryLeftParams: { // -
name: "",
},
systemCateList: [], systemCateList: [],
// -
userCateList: [], 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, tagDialogVisible: false,
tagForm: { id: null, label: "" }, // --
tagForm: { id: null, name: "" },
// --
tagRules: { tagRules: {
label: [ name: [
{ required: true, message: "标签名称不能为空", trigger: "blur" }, { required: true, message: "标签名称不能为空", trigger: "blur" },
{ max: 8, message: "最多8个字符", 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, fileNameDialogVisible: false,
fileNameForm: { userId: undefined, file_name: "" }, // --
fileNameForm: { userId: undefined, title: "" },
// --
fileNameRules: { fileNameRules: {
file_name: [ title: [{ required: true, message: "标题不能为空", trigger: "blur" }],
{ required: true, message: "文件名不能为空", trigger: "blur" },
],
}, },
loading: true,
userList: [],
// ================== ================== // ================== ==================
uploadTypeDialogVisible: false, // uploadTypeDialogVisible: false, //
currentFileType: "", // video/pdf currentFileType: "", // video/pdf
@ -392,7 +394,6 @@ export default {
fileList: [], // fileList: [], //
uploadProgressDialogVisible: false, uploadProgressDialogVisible: false,
uploadPercent: 0, uploadPercent: 0,
// ================== ================== // ================== ==================
shareDialogVisible: false, // shareDialogVisible: false, //
shareItem: null, // shareItem: null, //
@ -400,231 +401,235 @@ export default {
recentGroups: [], // 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() { created() {
this.getKnowledgeCateList(); this.getKnowledgeCateList();
// this.getList();
// this.getDeptTree();
// this.getContactList();
}, },
methods: { methods: {
refreshKnowledgeCateList() { // -
this.queryLeftParams.name = ""; getBuiltInIcon(idx) {
this.getKnowledgeCateList(); return ["el-icon-coin", "el-icon-video-camera", "el-icon-user"][idx];
}, },
// -
getKnowledgeCateList() { getKnowledgeCateList() {
// getKnowledgeCateList().then((res) => { postKnowledgeCateList().then((res) => {
let res = { this.systemCateList = res.data.system_cate_list.map((item) => ({
code: 200, ...item,
message: "成功", id: item.id.toString(),
data: { }));
system_cate_list: [
{ id: 2, name: "产品介绍" },
{ id: 0, name: "公共教学视频" },
{ id: 1, name: "个人收藏录像" },
],
user_cate_list: [],
},
};
this.systemCateList = res.data.system_cate_list;
this.defaultActive = this.systemCateList[0].id; this.defaultActive = this.systemCateList[0].id;
this.userCateList = res.data.user_cate_list; this.userCateList = res.data.user_cate_list.map((item) => ({
// }) ...item,
}, id: item.id.toString(),
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 || "",
})); }));
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() { handleAddTag() {
this.tagForm = { id: null, label: "" }; this.tagForm = { name: "" };
this.tagDialogVisible = true; this.tagDialogVisible = true;
}, },
// --
handleEditTag(t) { handleEditTag(t) {
this.tagForm = { ...t }; this.tagForm = { ...t, cate_id: t.id };
this.tagDialogVisible = true; 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() { submitTagForm() {
this.$refs["tagFormRef"].validate((valid) => { this.$refs["tagFormRef"].validate((valid) => {
if (valid) { if (valid) {
if (this.tagForm.id) { if (this.tagForm.id) {
postKnowledgeCateEdit(this.tagForm).then(() => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.tagDialogVisible = false; this.tagDialogVisible = false;
this.getDeptTree(); this.getKnowledgeCateList();
});
} else { } else {
postKnowledgeCateCreate(this.tagForm).then(() => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.tagDialogVisible = false; this.tagDialogVisible = false;
this.getDeptTree(); this.getKnowledgeCateList();
});
} }
} }
}); });
}, },
// --
cancelTagForm() { cancelTagForm() {
this.tagDialogVisible = false; this.tagDialogVisible = false;
}, },
handleQuery() { // -
this.queryRightParams.pageNum = 1; handleSelect(key) {
this.getList(); 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"); handleLeftDelete(row) {
this.queryRightParams.deptId = null; this.$modal
this.currentTag = ""; .confirm(
this.handleQuery(); `是否删除该自定义标签?若删除,该标签下资源将迁移至[个人收藏录像]标签下。`
}, )
getList() { .then(function () {
this.loading = true; return postKnowledgeCateDelete({ cate_id: row.id });
listUser(this.queryRightParams).then((res) => { })
this.userList = res.rows; .then(() => {
this.total = res.total; this.getKnowledgeCateList();
this.loading = false; this.$modal.msgSuccess("删除成功");
}); })
.catch(() => {});
}, },
handleShare(row) { //
this.shareItem = row; findMenuItem(key) {
this.shareDialogVisible = true; //
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) { formatfile_size(bytes) {
const shareTarget = selectedMembers[0]; if (!bytes) return "0B";
this.$modal.msgSuccess(`已分享给 ${shareTarget.name}`); const u = ["B", "KB", "MB", "GB"];
console.log("分享文件:", this.shareItem, "给:", shareTarget); let s = bytes,
i = 0;
while (s >= 1024 && i < 3) {
s /= 1024;
i++;
} }
this.shareDialogVisible = false; return s.toFixed(2) + u[i];
this.shareItem = null; },
// -
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) { handleUpdateFileName(row) {
this.fileNameForm = { ...row }; this.fileNameForm = { title: row.title, knowledge_id: row.id };
this.fileNameDialogVisible = true; this.fileNameDialogVisible = true;
}, },
submitFileNameForm() { submitFileNameForm() {
this.$refs.fileNameFormRef.validate((v) => { this.$refs.fileNameFormRef.validate((valid) => {
if (v) { if (valid) {
postKnowledgeEdit(this.fileNameForm).then(() => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
this.fileNameDialogVisible = false; this.fileNameDialogVisible = false;
this.getList(); this.getKnowledgeList();
});
} }
}); });
}, },
cancelFileNameForm() { cancelFileNameForm() {
this.fileNameDialogVisible = false; this.fileNameDialogVisible = false;
}, },
handleDelete(row) { // -
this.$modal.confirm("确认删除?").then(() => { handleRightDelete(row) {
delUser(row.userId).then(() => { this.$modal
.confirm("确认要删除此资源?")
.then(function () {
return postKnowledgeDelete({ knowledge_id: row.id });
})
.then(() => {
this.getKnowledgeList();
this.$modal.msgSuccess("删除成功"); 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() { openUploadTypeDialog() {
@ -642,7 +647,7 @@ export default {
}, },
// //
beforeUpload(file) { beforeUpload(file) {
this.uploadParams.deptId = this.currentTag || this.systemCateList[2].id; this.uploadParams.deptId = this.systemCateList[2].id;
this.uploadParams.fileType = this.currentFileType; this.uploadParams.fileType = this.currentFileType;
this.uploadProgressDialogVisible = true; this.uploadProgressDialogVisible = true;
this.uploadPercent = 0; this.uploadPercent = 0;
@ -662,7 +667,7 @@ export default {
setTimeout(() => { setTimeout(() => {
this.uploadProgressDialogVisible = false; this.uploadProgressDialogVisible = false;
this.$modal.msgSuccess("上传成功"); this.$modal.msgSuccess("上传成功");
this.getList(); // this.getKnowledgeList(); //
this.fileList = []; this.fileList = [];
}, 500); }, 500);
}, },
@ -676,11 +681,7 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.app-container { //
padding: 20px;
height: 100%;
}
.custom-item { .custom-item {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -691,12 +692,16 @@ export default {
gap: 8px; gap: 8px;
} }
} }
//
.resource-thumb { .resource-thumb {
width: 230px; width: 230px;
height: 80px; height: 80px;
border-radius: 4px; border-radius: 4px;
cursor: pointer; cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
} }
.upload-type-box { .upload-type-box {

Loading…
Cancel
Save